@qrwise/pos-calculations 0.0.24 → 0.0.25
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.
- package/dist/index.cjs +1 -15
- package/dist/index.js +1 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -416,17 +416,6 @@ function voucherVatNet(transaction, voucher, discount) {
|
|
|
416
416
|
const eligibleGross = itemizedGross > 0 ? itemizedGross : percentageGross > 0 ? percentageGross : gross;
|
|
417
417
|
return format2(Math.min(gross, eligibleGross) / 1.12);
|
|
418
418
|
}
|
|
419
|
-
function itemizedVoucherCount(transaction) {
|
|
420
|
-
const splits = transaction.metadata?.split_discounts;
|
|
421
|
-
if (!Array.isArray(splits)) return 0;
|
|
422
|
-
return splits.reduce((count, rawSplit) => {
|
|
423
|
-
if (!rawSplit || typeof rawSplit !== "object") return count;
|
|
424
|
-
const rawVoucher = rawSplit.voucher;
|
|
425
|
-
if (!rawVoucher || typeof rawVoucher !== "object") return count;
|
|
426
|
-
const voucher = rawVoucher;
|
|
427
|
-
return Math.abs(toMoneyNumber(voucher.discount_amount)) > 0 ? count + 1 : count;
|
|
428
|
-
}, 0);
|
|
429
|
-
}
|
|
430
419
|
function buildTransactionProjection(transaction, options = {}) {
|
|
431
420
|
const status = `${transaction.status} ${transaction.payment_status}`.toLowerCase();
|
|
432
421
|
const state = status.includes("refund") || status.includes("return") ? "RETURNED" : status.includes("cancel") || status.includes("void") ? "CANCELLED" : "SUCCESS";
|
|
@@ -434,13 +423,10 @@ function buildTransactionProjection(transaction, options = {}) {
|
|
|
434
423
|
const gross = toMoneyNumber(transaction.gross_amount);
|
|
435
424
|
const discount = Math.abs(toMoneyNumber(transaction.discount_amount));
|
|
436
425
|
const voucher = Math.abs(toMoneyNumber(transaction.voucher_discount_amount));
|
|
437
|
-
const voucherRate = toMoneyNumber(transaction.voucher_rate);
|
|
438
426
|
const hasVoucher = voucher > 0;
|
|
439
427
|
const hasVoucherAndDiscount = isSuccessful && voucher > 0 && discount > 0;
|
|
440
428
|
const scopedVoucherVatNet = voucherVatNet(transaction, voucher, discount);
|
|
441
|
-
const voucherForBirDiscount =
|
|
442
|
-
transaction.voucher_type?.toLowerCase() === "fixed" ? scopedVoucherVatNet - format2(voucherRate) : scopedVoucherVatNet * format2(voucherRate / 100)
|
|
443
|
-
);
|
|
429
|
+
const voucherForBirDiscount = -format2(voucher / 1.12);
|
|
444
430
|
const otherDiscount = isSuccessful && hasVoucher ? format2(voucherForBirDiscount) : 0;
|
|
445
431
|
const otherDiscountAdjustment = -format2(Math.abs(otherDiscount * 0.12));
|
|
446
432
|
const storedVat = Math.abs(toMoneyNumber(transaction.vat_amount));
|
package/dist/index.js
CHANGED
|
@@ -383,17 +383,6 @@ function voucherVatNet(transaction, voucher, discount) {
|
|
|
383
383
|
const eligibleGross = itemizedGross > 0 ? itemizedGross : percentageGross > 0 ? percentageGross : gross;
|
|
384
384
|
return format2(Math.min(gross, eligibleGross) / 1.12);
|
|
385
385
|
}
|
|
386
|
-
function itemizedVoucherCount(transaction) {
|
|
387
|
-
const splits = transaction.metadata?.split_discounts;
|
|
388
|
-
if (!Array.isArray(splits)) return 0;
|
|
389
|
-
return splits.reduce((count, rawSplit) => {
|
|
390
|
-
if (!rawSplit || typeof rawSplit !== "object") return count;
|
|
391
|
-
const rawVoucher = rawSplit.voucher;
|
|
392
|
-
if (!rawVoucher || typeof rawVoucher !== "object") return count;
|
|
393
|
-
const voucher = rawVoucher;
|
|
394
|
-
return Math.abs(toMoneyNumber(voucher.discount_amount)) > 0 ? count + 1 : count;
|
|
395
|
-
}, 0);
|
|
396
|
-
}
|
|
397
386
|
function buildTransactionProjection(transaction, options = {}) {
|
|
398
387
|
const status = `${transaction.status} ${transaction.payment_status}`.toLowerCase();
|
|
399
388
|
const state = status.includes("refund") || status.includes("return") ? "RETURNED" : status.includes("cancel") || status.includes("void") ? "CANCELLED" : "SUCCESS";
|
|
@@ -401,13 +390,10 @@ function buildTransactionProjection(transaction, options = {}) {
|
|
|
401
390
|
const gross = toMoneyNumber(transaction.gross_amount);
|
|
402
391
|
const discount = Math.abs(toMoneyNumber(transaction.discount_amount));
|
|
403
392
|
const voucher = Math.abs(toMoneyNumber(transaction.voucher_discount_amount));
|
|
404
|
-
const voucherRate = toMoneyNumber(transaction.voucher_rate);
|
|
405
393
|
const hasVoucher = voucher > 0;
|
|
406
394
|
const hasVoucherAndDiscount = isSuccessful && voucher > 0 && discount > 0;
|
|
407
395
|
const scopedVoucherVatNet = voucherVatNet(transaction, voucher, discount);
|
|
408
|
-
const voucherForBirDiscount =
|
|
409
|
-
transaction.voucher_type?.toLowerCase() === "fixed" ? scopedVoucherVatNet - format2(voucherRate) : scopedVoucherVatNet * format2(voucherRate / 100)
|
|
410
|
-
);
|
|
396
|
+
const voucherForBirDiscount = -format2(voucher / 1.12);
|
|
411
397
|
const otherDiscount = isSuccessful && hasVoucher ? format2(voucherForBirDiscount) : 0;
|
|
412
398
|
const otherDiscountAdjustment = -format2(Math.abs(otherDiscount * 0.12));
|
|
413
399
|
const storedVat = Math.abs(toMoneyNumber(transaction.vat_amount));
|