@managesome/eposmatic-toolkit 0.2.496 → 0.2.498
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { 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;
|
|
@@ -40,5 +40,5 @@ export declare function getPaymentSmartTitle(paymentType: string): {
|
|
|
40
40
|
export declare const getQRCodePaymentLink: (grandTotal: number | undefined, payments: IOrderPayment[] | null | undefined) => {
|
|
41
41
|
qrLink: string;
|
|
42
42
|
amount: number;
|
|
43
|
-
|
|
43
|
+
scanMessage: string;
|
|
44
44
|
} | null;
|
|
@@ -300,14 +300,14 @@ const getQRCodePaymentLink = (grandTotal, payments) => {
|
|
|
300
300
|
return null;
|
|
301
301
|
let qrLink = undefined;
|
|
302
302
|
let amount = undefined;
|
|
303
|
-
let
|
|
303
|
+
let scanMessage = 'Scan To Pay';
|
|
304
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
305
|
if (raastPayment) {
|
|
306
306
|
const raw = raastPayment?.card_details?.card_number;
|
|
307
307
|
// Only accept a real QR payload (not the initial placeholder)
|
|
308
308
|
qrLink = raw != null && raw !== '**** **** **** ****' ? raw : undefined;
|
|
309
309
|
amount = raastPayment?.amount_due;
|
|
310
|
-
|
|
310
|
+
scanMessage = 'Scan with JazzCash, EasyPaisa, or Bank App to Pay';
|
|
311
311
|
}
|
|
312
312
|
if (!qrLink || !amount) {
|
|
313
313
|
return null;
|
|
@@ -315,7 +315,7 @@ const getQRCodePaymentLink = (grandTotal, payments) => {
|
|
|
315
315
|
return {
|
|
316
316
|
qrLink,
|
|
317
317
|
amount: (0, common_1.parseNum)(amount),
|
|
318
|
-
|
|
318
|
+
scanMessage,
|
|
319
319
|
};
|
|
320
320
|
};
|
|
321
321
|
exports.getQRCodePaymentLink = getQRCodePaymentLink;
|
|
@@ -831,12 +831,7 @@ function receiptEngine(payload, mappedItems = {}) {
|
|
|
831
831
|
const qrCodePayment = (0, payment_helpers_1.getQRCodePaymentLink)(grandTotal, payments);
|
|
832
832
|
if (qrCodePayment != null) {
|
|
833
833
|
order_link = qrCodePayment.qrLink;
|
|
834
|
-
|
|
835
|
-
custom_message = 'Scan with JazzCash, EasyPaisa, or Bank App to Pay';
|
|
836
|
-
}
|
|
837
|
-
else {
|
|
838
|
-
custom_message = 'Scan To Pay';
|
|
839
|
-
}
|
|
834
|
+
custom_message = qrCodePayment.scanMessage;
|
|
840
835
|
}
|
|
841
836
|
else if (display_qr_code_on_receipt) {
|
|
842
837
|
const digitalReceiptLink = business_website != null ? `https://${business_website}/orders/${payload.order._id}` : null;
|
|
@@ -1369,24 +1369,10 @@ const getUsableData = (data, subtitles) => {
|
|
|
1369
1369
|
const netSale = totalPaymentSalesAmount || salesData.grossAmount;
|
|
1370
1370
|
const itemSales = salesData.totalItemSales;
|
|
1371
1371
|
const amountCollected = netSale - unpaidAmount;
|
|
1372
|
-
//
|
|
1373
|
-
//
|
|
1374
|
-
//
|
|
1375
|
-
|
|
1376
|
-
// "Net Revenue excl. Tax" reflects only GST on collected amounts.
|
|
1377
|
-
const collectedRatio = netSale > 0 ? Math.min(1, amountCollected / netSale) : 0;
|
|
1378
|
-
const netWithoutGst = netSale - totalGst * collectedRatio;
|
|
1379
|
-
// Scale down GST subchannel amounts proportionally so unpaid
|
|
1380
|
-
// invoices don't inflate the GST breakdown.
|
|
1381
|
-
if (collectedRatio < 1) {
|
|
1382
|
-
for (const ch of topLevelChannels) {
|
|
1383
|
-
if (ch.ref === constants_1.WAREHOUSE_SALE_ORDER_X_REPORT_TYPE_ENUM.GST) {
|
|
1384
|
-
for (const sc of ch.subChannels) {
|
|
1385
|
-
sc.amount = (0, common_1.parseNum)(sc.amount * collectedRatio);
|
|
1386
|
-
}
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1372
|
+
// Backend already excludes unpaid invoices from the GST aggregation,
|
|
1373
|
+
// so the GST amounts reflect only collected payments. No proportional
|
|
1374
|
+
// scaling is needed — the full GST amount is already correct.
|
|
1375
|
+
const netWithoutGst = netSale - totalGst;
|
|
1390
1376
|
const channelData = {
|
|
1391
1377
|
...subtitles,
|
|
1392
1378
|
_id: staffId,
|