@qrwise/pos-calculations 0.0.23 → 0.0.24

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 CHANGED
@@ -449,9 +449,9 @@ 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 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;
454
- const netOfVat = storedNetOfVat || fullyDiscountedCancellationNet || Math.max(0, toMoneyNumber(transaction.amount_payable) - storedVat);
452
+ const reconstructsVoidedVoucherSale = !isSuccessful && hasVoucher && gross > 0 && options.isVatRegistered !== void 0;
453
+ const voidedVoucherNet = reconstructsVoidedVoucherSale ? format2(gross / (options.isVatRegistered ? 1.12 : 1)) : 0;
454
+ const netOfVat = voidedVoucherNet || storedNetOfVat || Math.max(0, toMoneyNumber(transaction.amount_payable) - storedVat);
455
455
  const returned = state === "RETURNED" ? -format2(netOfVat) : 0;
456
456
  const cancelled = state === "CANCELLED" ? -format2(netOfVat) : 0;
457
457
  const { counts, discountWeights, vatExemptWeights } = discountAllocation(transaction, options);
@@ -489,7 +489,7 @@ function buildTransactionProjection(transaction, options = {}) {
489
489
  };
490
490
  const regularVat = storedVat || format2(Math.abs(storedVatExemptSales * 0.12));
491
491
  let vatAmount = format2(
492
- isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : reconstructsFullyDiscountedCancellation ? gross - netOfVat : netOfVat * 0.12
492
+ isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : reconstructsVoidedVoucherSale ? gross - netOfVat : netOfVat * 0.12
493
493
  );
494
494
  const hasMixedStatutoryTax = isSuccessful && discount > 0 && storedVat > 0 && storedVatSales > 0 && storedVatExemptSales > 0;
495
495
  if (hasVoucherAndDiscount || hasMixedStatutoryTax) {
package/dist/index.js CHANGED
@@ -416,9 +416,9 @@ 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 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;
421
- const netOfVat = storedNetOfVat || fullyDiscountedCancellationNet || Math.max(0, toMoneyNumber(transaction.amount_payable) - storedVat);
419
+ const reconstructsVoidedVoucherSale = !isSuccessful && hasVoucher && gross > 0 && options.isVatRegistered !== void 0;
420
+ const voidedVoucherNet = reconstructsVoidedVoucherSale ? format2(gross / (options.isVatRegistered ? 1.12 : 1)) : 0;
421
+ const netOfVat = voidedVoucherNet || storedNetOfVat || Math.max(0, toMoneyNumber(transaction.amount_payable) - storedVat);
422
422
  const returned = state === "RETURNED" ? -format2(netOfVat) : 0;
423
423
  const cancelled = state === "CANCELLED" ? -format2(netOfVat) : 0;
424
424
  const { counts, discountWeights, vatExemptWeights } = discountAllocation(transaction, options);
@@ -456,7 +456,7 @@ function buildTransactionProjection(transaction, options = {}) {
456
456
  };
457
457
  const regularVat = storedVat || format2(Math.abs(storedVatExemptSales * 0.12));
458
458
  let vatAmount = format2(
459
- isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : reconstructsFullyDiscountedCancellation ? gross - netOfVat : netOfVat * 0.12
459
+ isSuccessful ? voucher > 0 ? Math.abs(scopedVoucherVatNet * 0.12) : regularVat : options.isVatRegistered === false ? 0 : reconstructsVoidedVoucherSale ? gross - netOfVat : netOfVat * 0.12
460
460
  );
461
461
  const hasMixedStatutoryTax = isSuccessful && discount > 0 && storedVat > 0 && storedVatSales > 0 && storedVatExemptSales > 0;
462
462
  if (hasVoucherAndDiscount || hasMixedStatutoryTax) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrwise/pos-calculations",
3
- "version": "0.0.23",
3
+ "version": "0.0.24",
4
4
  "description": "Shared POS calculations for QR Wise POS",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",