@managesome/eposmatic-toolkit 0.2.493 → 0.2.495
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1501,7 +1501,7 @@ function getRewardPreviewHashKey(rewardPreview) {
|
|
|
1501
1501
|
// The same rule applies to getUnlockedOffersApplicableTimesHashKey and getRewardPreviewHashKey.
|
|
1502
1502
|
function getOffersWithStatsHashKey({ offersWithStats, totalClaimableOffers, isEdit, itemsCount, itemsPrice, }) {
|
|
1503
1503
|
const editSegment = isEdit ? 'edit:' : '';
|
|
1504
|
-
const cartSegment = `c:${itemsCount ?? 0}:${itemsPrice ?? 0}`;
|
|
1504
|
+
const cartSegment = `c:${itemsCount ?? 0}:${(0, common_1.parseNum)(itemsPrice ?? 0)}`;
|
|
1505
1505
|
if (offersWithStats.length === 0) {
|
|
1506
1506
|
return `offers:v1:${editSegment}${cartSegment}:empty:${totalClaimableOffers.length}`;
|
|
1507
1507
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PAYMENT_EXTENSION_ENUM, PAYMENT_TYPE_ENUM } from '../../constants';
|
|
1
|
+
import { COUNTRY_ALPHA_3_ENUM, PAYMENT_EXTENSION_ENUM, PAYMENT_TYPE_ENUM } from '../../constants';
|
|
2
2
|
import { IOrderPayment } from '../../schemas';
|
|
3
3
|
export declare function getPaymentAmountPayed(payment: IOrderPayment, allowUnverifiedPayments?: boolean): {
|
|
4
4
|
amountPaid: number;
|
|
@@ -37,3 +37,8 @@ export declare function getPaymentSmartTitle(paymentType: string): {
|
|
|
37
37
|
details: IPaymentDiscount | null;
|
|
38
38
|
extensionType: PAYMENT_EXTENSION_ENUM;
|
|
39
39
|
};
|
|
40
|
+
export declare const getQRCodePaymentLink: (grandTotal: number | undefined, payments: IOrderPayment[] | null | undefined) => {
|
|
41
|
+
qrLink: string;
|
|
42
|
+
amount: number;
|
|
43
|
+
countryAlpha3: COUNTRY_ALPHA_3_ENUM.PAK | null;
|
|
44
|
+
} | null;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getQRCodePaymentLink = void 0;
|
|
6
7
|
exports.getPaymentAmountPayed = getPaymentAmountPayed;
|
|
7
8
|
exports.getOrderPaymentsDetails = getOrderPaymentsDetails;
|
|
8
9
|
exports.getTotalCardCharges = getTotalCardCharges;
|
|
@@ -291,3 +292,30 @@ function getPaymentSmartTitle(paymentType) {
|
|
|
291
292
|
extensionType,
|
|
292
293
|
};
|
|
293
294
|
}
|
|
295
|
+
const getQRCodePaymentLink = (grandTotal, payments) => {
|
|
296
|
+
if (!grandTotal || !payments)
|
|
297
|
+
return null;
|
|
298
|
+
const isFullyPaid = isOrderFullyPaid(grandTotal, payments);
|
|
299
|
+
if (isFullyPaid)
|
|
300
|
+
return null;
|
|
301
|
+
let qrLink = undefined;
|
|
302
|
+
let amount = undefined;
|
|
303
|
+
let countryAlpha3 = null;
|
|
304
|
+
const raastPayment = payments.find((p) => p.payment_status === constants_1.PAYMENT_STATUS_ENUM.PENDING && p?.payment_type === constants_1.PAYMENT_TYPE_ENUM.RAAST_PAY);
|
|
305
|
+
if (raastPayment) {
|
|
306
|
+
const raw = raastPayment?.card_details?.card_number;
|
|
307
|
+
// Only accept a real QR payload (not the initial placeholder)
|
|
308
|
+
qrLink = raw != null && raw !== '**** **** **** ****' ? raw : undefined;
|
|
309
|
+
amount = raastPayment?.amount_due;
|
|
310
|
+
countryAlpha3 = constants_1.COUNTRY_ALPHA_3_ENUM.PAK;
|
|
311
|
+
}
|
|
312
|
+
if (!qrLink || !amount) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
qrLink,
|
|
317
|
+
amount: (0, common_1.parseNum)(amount),
|
|
318
|
+
countryAlpha3,
|
|
319
|
+
};
|
|
320
|
+
};
|
|
321
|
+
exports.getQRCodePaymentLink = getQRCodePaymentLink;
|
|
@@ -42,6 +42,7 @@ export interface IReceiptProps {
|
|
|
42
42
|
display_unit_item_price_on_customer_receipt: boolean;
|
|
43
43
|
hide_modifier_name: boolean;
|
|
44
44
|
display_qr_code_on_receipt: boolean;
|
|
45
|
+
customMessage: string | null;
|
|
45
46
|
};
|
|
46
47
|
}
|
|
47
48
|
export interface IReceiptItem {
|
|
@@ -100,6 +101,7 @@ export interface IReceiptEngine {
|
|
|
100
101
|
display_item_price_on_kitchen_receipt: boolean;
|
|
101
102
|
keep_kitchen_receipt_concise: boolean;
|
|
102
103
|
cancel_reason: string | null;
|
|
104
|
+
custom_message: string | null;
|
|
103
105
|
}
|
|
104
106
|
interface ISettings {
|
|
105
107
|
currency_symbol: ITenant['currency_symbol'] | null | undefined;
|
|
@@ -501,7 +501,7 @@ const getPartialItems = (categories = [], included_categories_map, filterEmpty)
|
|
|
501
501
|
exports.getPartialItems = getPartialItems;
|
|
502
502
|
function receiptEngine(payload, mappedItems = {}) {
|
|
503
503
|
const { currency_symbol, image_url, name, public_phone_numbers, restaurant_address, support_email, tax_business_number, takeaway_is_pickup, tax_invoice_provider, country_alpha_2, hide_gst_value, receipt_qr_type, business_website, google_review_link, playstore_url, appstore_url, fb_link, instagram_link, twitter_link, tiktok_link, } = payload.tenant_settings;
|
|
504
|
-
const { full_width, included_categories_map, printing_preference, receipt_type, show_modifiers, display_modifiers_on_separate_lines, display_item_instructions_on_customer_receipt, display_order_instructions_on_customer_receipt, display_unit_item_price_on_customer_receipt, hide_modifier_name, display_qr_code_on_receipt, } = payload.printer_settings;
|
|
504
|
+
const { full_width, included_categories_map, printing_preference, receipt_type, show_modifiers, display_modifiers_on_separate_lines, display_item_instructions_on_customer_receipt, display_order_instructions_on_customer_receipt, display_unit_item_price_on_customer_receipt, hide_modifier_name, display_qr_code_on_receipt, customMessage, } = payload.printer_settings;
|
|
505
505
|
const currencySymbol = currency_symbol ?? '';
|
|
506
506
|
const grandTotal = payload.order.grand_total ?? 0;
|
|
507
507
|
const { amountPayedSoFar, existingPayments, change, openAmount } = (0, payment_helpers_1.getOrderPaymentsDetails)(payload.order.grand_total, payload.order.payments);
|
|
@@ -811,11 +811,13 @@ function receiptEngine(payload, mappedItems = {}) {
|
|
|
811
811
|
}
|
|
812
812
|
let order_link = null;
|
|
813
813
|
let invoice_name = '';
|
|
814
|
+
let custom_message = null;
|
|
814
815
|
if (is_kitchen_receipt) {
|
|
815
816
|
invoice_name = `Order #${payload.order.order_number ?? ''}`;
|
|
816
817
|
}
|
|
817
818
|
else {
|
|
818
819
|
invoice_name = `Invoice #${payload.order.order_number ?? ''}`;
|
|
820
|
+
custom_message = customMessage;
|
|
819
821
|
if (isFullyPaid) {
|
|
820
822
|
// Either tax invoice ID is present or country is not Pakistan and tax business number is present
|
|
821
823
|
if (payload.order.tax_invoice_id || (country_alpha_2 !== constants_1.COUNTRY_ALPHA_2_ENUM.PK && tax_business_number)) {
|
|
@@ -825,34 +827,46 @@ function receiptEngine(payload, mappedItems = {}) {
|
|
|
825
827
|
if (payload.order.tax_invoice_id) {
|
|
826
828
|
order_link = payload.order.tax_invoice_id;
|
|
827
829
|
}
|
|
828
|
-
else
|
|
829
|
-
const
|
|
830
|
-
if (
|
|
831
|
-
order_link =
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
}
|
|
839
|
-
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.GOOGLE_REVIEW && google_review_link != null) {
|
|
840
|
-
order_link = google_review_link;
|
|
841
|
-
}
|
|
842
|
-
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.FACEBOOK_FOLLOW && fb_link != null) {
|
|
843
|
-
order_link = fb_link;
|
|
844
|
-
}
|
|
845
|
-
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.INSTA_FOLLOW && instagram_link != null) {
|
|
846
|
-
order_link = instagram_link;
|
|
847
|
-
}
|
|
848
|
-
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.TWITTER_FOLLOW && twitter_link != null) {
|
|
849
|
-
order_link = twitter_link;
|
|
850
|
-
}
|
|
851
|
-
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.TIKTOK_FOLLOW && tiktok_link != null) {
|
|
852
|
-
order_link = tiktok_link;
|
|
830
|
+
else {
|
|
831
|
+
const qrCodePayment = (0, payment_helpers_1.getQRCodePaymentLink)(grandTotal, payments);
|
|
832
|
+
if (qrCodePayment != null) {
|
|
833
|
+
order_link = qrCodePayment.qrLink;
|
|
834
|
+
if (qrCodePayment.countryAlpha3 === constants_1.COUNTRY_ALPHA_3_ENUM.PAK) {
|
|
835
|
+
custom_message = 'Scan with JazzCash, EasyPaisa, or Bank App to Pay';
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
custom_message = 'Scan To Pay';
|
|
839
|
+
}
|
|
853
840
|
}
|
|
854
|
-
else if (
|
|
855
|
-
|
|
841
|
+
else if (display_qr_code_on_receipt) {
|
|
842
|
+
const digitalReceiptLink = business_website != null ? `https://${business_website}/orders/${payload.order._id}` : null;
|
|
843
|
+
if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.DIGITAL_RECEIPT && digitalReceiptLink != null) {
|
|
844
|
+
order_link = digitalReceiptLink;
|
|
845
|
+
}
|
|
846
|
+
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.APPSTORE_APP_DOWNLOAD && appstore_url != null) {
|
|
847
|
+
order_link = appstore_url;
|
|
848
|
+
}
|
|
849
|
+
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.PLAYSTORE_APP_DOWNLOAD && playstore_url != null) {
|
|
850
|
+
order_link = playstore_url;
|
|
851
|
+
}
|
|
852
|
+
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.GOOGLE_REVIEW && google_review_link != null) {
|
|
853
|
+
order_link = google_review_link;
|
|
854
|
+
}
|
|
855
|
+
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.FACEBOOK_FOLLOW && fb_link != null) {
|
|
856
|
+
order_link = fb_link;
|
|
857
|
+
}
|
|
858
|
+
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.INSTA_FOLLOW && instagram_link != null) {
|
|
859
|
+
order_link = instagram_link;
|
|
860
|
+
}
|
|
861
|
+
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.TWITTER_FOLLOW && twitter_link != null) {
|
|
862
|
+
order_link = twitter_link;
|
|
863
|
+
}
|
|
864
|
+
else if (receipt_qr_type === constants_1.RECEIPT_QR_CODE_TYPE_ENUM.TIKTOK_FOLLOW && tiktok_link != null) {
|
|
865
|
+
order_link = tiktok_link;
|
|
866
|
+
}
|
|
867
|
+
else if (digitalReceiptLink != null) {
|
|
868
|
+
order_link = digitalReceiptLink;
|
|
869
|
+
}
|
|
856
870
|
}
|
|
857
871
|
}
|
|
858
872
|
}
|
|
@@ -918,6 +932,7 @@ function receiptEngine(payload, mappedItems = {}) {
|
|
|
918
932
|
display_item_price_on_kitchen_receipt: payload.printer_settings.display_item_price_on_kitchen_receipt,
|
|
919
933
|
keep_kitchen_receipt_concise: payload.printer_settings.keep_kitchen_receipt_concise,
|
|
920
934
|
cancel_reason,
|
|
935
|
+
custom_message,
|
|
921
936
|
};
|
|
922
937
|
return engine;
|
|
923
938
|
}
|