@qrwise/pos-calculations 0.0.7 → 0.0.9
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.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -66,6 +66,7 @@ function calculateTotals(input) {
|
|
|
66
66
|
discountableTotalAmount = 0,
|
|
67
67
|
nonDiscountableTotalAmount = 0,
|
|
68
68
|
serviceChargeableTotalAmount = 0,
|
|
69
|
+
togoableTotalAmount = 0,
|
|
69
70
|
voucherType = null,
|
|
70
71
|
voucherRate = 0,
|
|
71
72
|
discountType = null,
|
|
@@ -89,7 +90,7 @@ function calculateTotals(input) {
|
|
|
89
90
|
let vat = Number((vatNet * 0.12).toFixed(2));
|
|
90
91
|
const isSpecial = discountRate > 0;
|
|
91
92
|
const isAddVat = isAddVatAfterDiscount(discountType);
|
|
92
|
-
const discounted = Number((discountRate * -vatNet).toFixed(2));
|
|
93
|
+
const discounted = Number((discountRate / 100 * -vatNet).toFixed(2));
|
|
93
94
|
if (isSpecial) {
|
|
94
95
|
vatNet = Number((vatNet + discounted).toFixed(2));
|
|
95
96
|
if (!isAddVat) {
|
|
@@ -105,7 +106,7 @@ function calculateTotals(input) {
|
|
|
105
106
|
serviceCharge = Number((vatNet * scRate).toFixed(2));
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
|
-
let totalAmount = vatNet + vat + serviceCharge + togoCharge;
|
|
109
|
+
let totalAmount = vatNet + vat + serviceCharge + (togoableTotalAmount > 0 ? togoCharge : 0);
|
|
109
110
|
if (isSpecial && !isAddVat) {
|
|
110
111
|
totalAmount -= vat;
|
|
111
112
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,7 @@ interface CalculateTotalsInput {
|
|
|
5
5
|
discountableTotalAmount: number;
|
|
6
6
|
nonDiscountableTotalAmount: number;
|
|
7
7
|
serviceChargeableTotalAmount?: number;
|
|
8
|
+
togoableTotalAmount?: number;
|
|
8
9
|
voucherType?: VoucherType | null;
|
|
9
10
|
voucherRate?: number;
|
|
10
11
|
discountType?: DiscountType | null;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ interface CalculateTotalsInput {
|
|
|
5
5
|
discountableTotalAmount: number;
|
|
6
6
|
nonDiscountableTotalAmount: number;
|
|
7
7
|
serviceChargeableTotalAmount?: number;
|
|
8
|
+
togoableTotalAmount?: number;
|
|
8
9
|
voucherType?: VoucherType | null;
|
|
9
10
|
voucherRate?: number;
|
|
10
11
|
discountType?: DiscountType | null;
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ function calculateTotals(input) {
|
|
|
34
34
|
discountableTotalAmount = 0,
|
|
35
35
|
nonDiscountableTotalAmount = 0,
|
|
36
36
|
serviceChargeableTotalAmount = 0,
|
|
37
|
+
togoableTotalAmount = 0,
|
|
37
38
|
voucherType = null,
|
|
38
39
|
voucherRate = 0,
|
|
39
40
|
discountType = null,
|
|
@@ -57,7 +58,7 @@ function calculateTotals(input) {
|
|
|
57
58
|
let vat = Number((vatNet * 0.12).toFixed(2));
|
|
58
59
|
const isSpecial = discountRate > 0;
|
|
59
60
|
const isAddVat = isAddVatAfterDiscount(discountType);
|
|
60
|
-
const discounted = Number((discountRate * -vatNet).toFixed(2));
|
|
61
|
+
const discounted = Number((discountRate / 100 * -vatNet).toFixed(2));
|
|
61
62
|
if (isSpecial) {
|
|
62
63
|
vatNet = Number((vatNet + discounted).toFixed(2));
|
|
63
64
|
if (!isAddVat) {
|
|
@@ -73,7 +74,7 @@ function calculateTotals(input) {
|
|
|
73
74
|
serviceCharge = Number((vatNet * scRate).toFixed(2));
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
|
-
let totalAmount = vatNet + vat + serviceCharge + togoCharge;
|
|
77
|
+
let totalAmount = vatNet + vat + serviceCharge + (togoableTotalAmount > 0 ? togoCharge : 0);
|
|
77
78
|
if (isSpecial && !isAddVat) {
|
|
78
79
|
totalAmount -= vat;
|
|
79
80
|
}
|