@qrwise/pos-calculations 0.0.22 → 0.0.23
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 +3 -2
- package/dist/index.js +3 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -449,7 +449,8 @@ function buildTransactionProjection(transaction, options = {}) {
|
|
|
449
449
|
const storedZeroRatedSales = toMoneyNumber(transaction.zero_rated_sales);
|
|
450
450
|
const storedNonTaxableSales = toMoneyNumber(transaction.non_taxable_sales);
|
|
451
451
|
const storedNetOfVat = storedVatSales + storedVatExemptSales + storedZeroRatedSales + storedNonTaxableSales;
|
|
452
|
-
const
|
|
452
|
+
const reconstructsFullyDiscountedCancellation = !isSuccessful && storedNetOfVat === 0 && toMoneyNumber(transaction.amount_payable) === 0 && gross > 0 && options.isVatRegistered !== void 0;
|
|
453
|
+
const fullyDiscountedCancellationNet = reconstructsFullyDiscountedCancellation ? format2(gross / (options.isVatRegistered ? 1.12 : 1)) : 0;
|
|
453
454
|
const netOfVat = storedNetOfVat || fullyDiscountedCancellationNet || Math.max(0, toMoneyNumber(transaction.amount_payable) - storedVat);
|
|
454
455
|
const returned = state === "RETURNED" ? -format2(netOfVat) : 0;
|
|
455
456
|
const cancelled = state === "CANCELLED" ? -format2(netOfVat) : 0;
|
|
@@ -488,7 +489,7 @@ function buildTransactionProjection(transaction, options = {}) {
|
|
|
488
489
|
};
|
|
489
490
|
const regularVat = storedVat || format2(Math.abs(storedVatExemptSales * 0.12));
|
|
490
491
|
let vatAmount = format2(
|
|
491
|
-
isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : netOfVat * 0.12
|
|
492
|
+
isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : reconstructsFullyDiscountedCancellation ? gross - netOfVat : netOfVat * 0.12
|
|
492
493
|
);
|
|
493
494
|
const hasMixedStatutoryTax = isSuccessful && discount > 0 && storedVat > 0 && storedVatSales > 0 && storedVatExemptSales > 0;
|
|
494
495
|
if (hasVoucherAndDiscount || hasMixedStatutoryTax) {
|
package/dist/index.js
CHANGED
|
@@ -416,7 +416,8 @@ function buildTransactionProjection(transaction, options = {}) {
|
|
|
416
416
|
const storedZeroRatedSales = toMoneyNumber(transaction.zero_rated_sales);
|
|
417
417
|
const storedNonTaxableSales = toMoneyNumber(transaction.non_taxable_sales);
|
|
418
418
|
const storedNetOfVat = storedVatSales + storedVatExemptSales + storedZeroRatedSales + storedNonTaxableSales;
|
|
419
|
-
const
|
|
419
|
+
const reconstructsFullyDiscountedCancellation = !isSuccessful && storedNetOfVat === 0 && toMoneyNumber(transaction.amount_payable) === 0 && gross > 0 && options.isVatRegistered !== void 0;
|
|
420
|
+
const fullyDiscountedCancellationNet = reconstructsFullyDiscountedCancellation ? format2(gross / (options.isVatRegistered ? 1.12 : 1)) : 0;
|
|
420
421
|
const netOfVat = storedNetOfVat || fullyDiscountedCancellationNet || Math.max(0, toMoneyNumber(transaction.amount_payable) - storedVat);
|
|
421
422
|
const returned = state === "RETURNED" ? -format2(netOfVat) : 0;
|
|
422
423
|
const cancelled = state === "CANCELLED" ? -format2(netOfVat) : 0;
|
|
@@ -455,7 +456,7 @@ function buildTransactionProjection(transaction, options = {}) {
|
|
|
455
456
|
};
|
|
456
457
|
const regularVat = storedVat || format2(Math.abs(storedVatExemptSales * 0.12));
|
|
457
458
|
let vatAmount = format2(
|
|
458
|
-
isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : netOfVat * 0.12
|
|
459
|
+
isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : reconstructsFullyDiscountedCancellation ? gross - netOfVat : netOfVat * 0.12
|
|
459
460
|
);
|
|
460
461
|
const hasMixedStatutoryTax = isSuccessful && discount > 0 && storedVat > 0 && storedVatSales > 0 && storedVatExemptSales > 0;
|
|
461
462
|
if (hasVoucherAndDiscount || hasMixedStatutoryTax) {
|