lazywait-calcs 1.0.2 → 1.0.4
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/lib/cjs/Calcs.js +40 -48
- package/lib/cjs/index.js +21 -5
- package/lib/cjs/types/Calcs.d.ts +1 -22
- package/lib/cjs/types/Calcs.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +2 -2
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/esm/Calcs.js +18 -38
- package/lib/esm/index.js +2 -2
- package/lib/esm/types/Calcs.d.ts +1 -22
- package/lib/esm/types/Calcs.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +2 -2
- package/lib/esm/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/cjs/Calcs.js
CHANGED
|
@@ -3,23 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getInvoicesDiffrence = exports.calcItemAddons = exports.calcItemDiscounts = exports.calcClosingCashBalance = exports.calPaymentTotal = exports.calcPaymentBalanceDue = exports.Total = exports.printedOrderTaxes = exports.OtherCharges = exports.Deliveries = exports.NonTaxableAmount = exports.TaxableAmount = exports.Vat = exports.ItemVat = exports.DiscountsWithVat = exports.Discounts = exports.calcItem = exports.Subtotal = exports.ItemTotal = void 0;
|
|
6
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
7
8
|
const moment_1 = __importDefault(require("moment"));
|
|
8
9
|
const utils_1 = require("./utils");
|
|
9
10
|
function ItemTotal(order_item, branch_vat, order_taxes, order_discounts, order_items_count = 1) {
|
|
10
|
-
var _a
|
|
11
|
+
var _a;
|
|
11
12
|
let total = 0;
|
|
12
13
|
const vat = branch_vat ? 1 + branch_vat / 100 : 1;
|
|
13
14
|
if (order_item.price && order_item.quantity) {
|
|
14
15
|
let price = order_item.price;
|
|
15
|
-
(
|
|
16
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.addons) || []).forEach((addon) => {
|
|
16
17
|
if (addon.price && addon.quantity) {
|
|
17
18
|
price += addon.price * addon.quantity;
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
21
|
const discounts = calcItemDiscounts(order_item, order_discounts, order_items_count);
|
|
21
22
|
price -= discounts;
|
|
22
|
-
let item_tax = lodash_1.default.sum((
|
|
23
|
+
let item_tax = lodash_1.default.sum((_a = order_item.taxes) === null || _a === void 0 ? void 0 : _a.map((tax) => {
|
|
23
24
|
return tax.isPercent ? ((tax.amount || 0) / 100) * price : tax.amount || 0;
|
|
24
25
|
}));
|
|
25
26
|
if (order_taxes) {
|
|
@@ -36,16 +37,17 @@ function ItemTotal(order_item, branch_vat, order_taxes, order_discounts, order_i
|
|
|
36
37
|
}
|
|
37
38
|
return total;
|
|
38
39
|
}
|
|
40
|
+
exports.ItemTotal = ItemTotal;
|
|
39
41
|
function Subtotal(order_items) {
|
|
40
42
|
if (order_items && order_items.length) {
|
|
41
43
|
return lodash_1.default.sum(order_items.map(calcItem));
|
|
42
44
|
}
|
|
43
45
|
return 0;
|
|
44
46
|
}
|
|
47
|
+
exports.Subtotal = Subtotal;
|
|
45
48
|
function calcItem(order_item) {
|
|
46
|
-
var _a;
|
|
47
49
|
let result = 0;
|
|
48
|
-
(
|
|
50
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.addons) || []).forEach((addon) => {
|
|
49
51
|
if (addon.price && addon.quantity) {
|
|
50
52
|
result += addon.price * addon.quantity;
|
|
51
53
|
}
|
|
@@ -55,6 +57,7 @@ function calcItem(order_item) {
|
|
|
55
57
|
}
|
|
56
58
|
return result;
|
|
57
59
|
}
|
|
60
|
+
exports.calcItem = calcItem;
|
|
58
61
|
function Discounts(order_discounts, order_items, loyalty_amount, branch_vat) {
|
|
59
62
|
let discounts = 0;
|
|
60
63
|
const subtotal = Subtotal(order_items);
|
|
@@ -80,8 +83,7 @@ function Discounts(order_discounts, order_items, loyalty_amount, branch_vat) {
|
|
|
80
83
|
});
|
|
81
84
|
}
|
|
82
85
|
order_items === null || order_items === void 0 ? void 0 : order_items.forEach((order_item) => {
|
|
83
|
-
|
|
84
|
-
(_a = order_item === null || order_item === void 0 ? void 0 : order_item.discounts) === null || _a === void 0 ? void 0 : _a.forEach((discount) => {
|
|
86
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.discounts) || []).forEach((discount) => {
|
|
85
87
|
var _a;
|
|
86
88
|
if (discount.is_percentage && discount.amount) {
|
|
87
89
|
const addons_arr = (_a = order_item === null || order_item === void 0 ? void 0 : order_item.addons) === null || _a === void 0 ? void 0 : _a.map((a) => { var _a; return ((_a = a.price) !== null && _a !== void 0 ? _a : 0) * a.quantity || 0; });
|
|
@@ -104,6 +106,7 @@ function Discounts(order_discounts, order_items, loyalty_amount, branch_vat) {
|
|
|
104
106
|
}
|
|
105
107
|
return discounts;
|
|
106
108
|
}
|
|
109
|
+
exports.Discounts = Discounts;
|
|
107
110
|
function DiscountsWithVat(order_discounts, order_items, loyalty_amount, branch_vat) {
|
|
108
111
|
let discounts = 0;
|
|
109
112
|
const subtotal = Subtotal(order_items);
|
|
@@ -128,9 +131,8 @@ function DiscountsWithVat(order_discounts, order_items, loyalty_amount, branch_v
|
|
|
128
131
|
}
|
|
129
132
|
});
|
|
130
133
|
}
|
|
131
|
-
order_items
|
|
132
|
-
|
|
133
|
-
(_a = order_item === null || order_item === void 0 ? void 0 : order_item.discounts) === null || _a === void 0 ? void 0 : _a.forEach((discount) => {
|
|
134
|
+
(order_items || []).forEach((order_item) => {
|
|
135
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.discounts) || []).forEach((discount) => {
|
|
134
136
|
var _a;
|
|
135
137
|
if (!order_item.not_taxable) {
|
|
136
138
|
if (discount.is_percentage && discount.amount) {
|
|
@@ -155,17 +157,17 @@ function DiscountsWithVat(order_discounts, order_items, loyalty_amount, branch_v
|
|
|
155
157
|
}
|
|
156
158
|
return discounts;
|
|
157
159
|
}
|
|
160
|
+
exports.DiscountsWithVat = DiscountsWithVat;
|
|
158
161
|
function ItemVat(order_item, branch_vat) {
|
|
159
|
-
var _a, _b;
|
|
160
162
|
const vat = branch_vat ? branch_vat / 100 : 1;
|
|
161
163
|
let addons = 0;
|
|
162
|
-
(
|
|
164
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.addons) || []).forEach((addon) => {
|
|
163
165
|
if (addon.price && addon.quantity) {
|
|
164
166
|
addons += (0, utils_1.toFixedFloat)(addon.price * addon.quantity);
|
|
165
167
|
}
|
|
166
168
|
});
|
|
167
169
|
let discounts = 0;
|
|
168
|
-
(
|
|
170
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.discounts) || []).forEach((discount) => {
|
|
169
171
|
if (discount.is_percentage && discount.amount) {
|
|
170
172
|
discounts += (0, utils_1.toFixedFloat)((order_item.price + addons) * order_item.quantity * (discount.amount / 100));
|
|
171
173
|
}
|
|
@@ -176,6 +178,7 @@ function ItemVat(order_item, branch_vat) {
|
|
|
176
178
|
const price = order_item.price + addons - discounts;
|
|
177
179
|
return order_item.not_taxable ? 0 : (0, utils_1.toFixedFloat)(price * vat);
|
|
178
180
|
}
|
|
181
|
+
exports.ItemVat = ItemVat;
|
|
179
182
|
function Vat(order, order_items, loyalty_amount, branch_vat) {
|
|
180
183
|
if (branch_vat && order_items.some((o) => !o.not_taxable)) {
|
|
181
184
|
const discount = DiscountsWithVat((order === null || order === void 0 ? void 0 : order.order_discounts) || [], order_items, (order === null || order === void 0 ? void 0 : order.loyalty_amount) || 0, branch_vat);
|
|
@@ -191,12 +194,15 @@ function Vat(order, order_items, loyalty_amount, branch_vat) {
|
|
|
191
194
|
}
|
|
192
195
|
return 0;
|
|
193
196
|
}
|
|
197
|
+
exports.Vat = Vat;
|
|
194
198
|
function TaxableAmount(order_items) {
|
|
195
199
|
return lodash_1.default.sum((order_items || []).filter((i) => !i.not_taxable).map(calcItem));
|
|
196
200
|
}
|
|
201
|
+
exports.TaxableAmount = TaxableAmount;
|
|
197
202
|
function NonTaxableAmount(order_items) {
|
|
198
203
|
return lodash_1.default.sum((order_items || []).filter((i) => i.not_taxable).map(calcItem));
|
|
199
204
|
}
|
|
205
|
+
exports.NonTaxableAmount = NonTaxableAmount;
|
|
200
206
|
function Deliveries(order_deliveries) {
|
|
201
207
|
let sum = 0;
|
|
202
208
|
if (order_deliveries) {
|
|
@@ -211,6 +217,7 @@ function Deliveries(order_deliveries) {
|
|
|
211
217
|
}
|
|
212
218
|
return sum;
|
|
213
219
|
}
|
|
220
|
+
exports.Deliveries = Deliveries;
|
|
214
221
|
function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
215
222
|
const sub = Subtotal(order_items);
|
|
216
223
|
const discounts = Number(Discounts((order === null || order === void 0 ? void 0 : order.order_deliveries) || [], order_items, loyalty_amount, branch_vat));
|
|
@@ -226,12 +233,12 @@ function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
|
226
233
|
}))
|
|
227
234
|
: 0;
|
|
228
235
|
}
|
|
229
|
-
order_items.forEach((order_item) => {
|
|
230
|
-
var _a
|
|
236
|
+
(order_items || []).forEach((order_item) => {
|
|
237
|
+
var _a;
|
|
231
238
|
const addons_total = lodash_1.default.sum((_a = order_item === null || order_item === void 0 ? void 0 : order_item.addons) === null || _a === void 0 ? void 0 : _a.map((a) => (a.price || 0) * (a.quantity || 0)));
|
|
232
239
|
const price = (order_item.price + addons_total) * order_item.quantity;
|
|
233
240
|
let _discounts = 0;
|
|
234
|
-
(
|
|
241
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.discounts) || []).forEach((discount) => {
|
|
235
242
|
if (discount.is_percentage && discount.amount) {
|
|
236
243
|
_discounts += price * (discount.amount / 100);
|
|
237
244
|
}
|
|
@@ -240,7 +247,7 @@ function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
|
240
247
|
}
|
|
241
248
|
});
|
|
242
249
|
const order_items_count = lodash_1.default.sum(order_items.map((i) => i.quantity));
|
|
243
|
-
order === null || order === void 0 ? void 0 : order.order_discounts.forEach((discount) => {
|
|
250
|
+
((order === null || order === void 0 ? void 0 : order.order_discounts) || []).forEach((discount) => {
|
|
244
251
|
if (discount.is_percentage && discount.amount) {
|
|
245
252
|
_discounts += price * (discount.amount / 100);
|
|
246
253
|
}
|
|
@@ -248,7 +255,7 @@ function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
|
248
255
|
_discounts += (discount.amount / order_items_count) * order_item.quantity;
|
|
249
256
|
}
|
|
250
257
|
});
|
|
251
|
-
(
|
|
258
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.taxes) || []).forEach((tax) => {
|
|
252
259
|
if (tax.isPercent && tax.amount) {
|
|
253
260
|
let temp = price - _discounts;
|
|
254
261
|
if (temp < 0) {
|
|
@@ -263,13 +270,14 @@ function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
|
263
270
|
});
|
|
264
271
|
return other_charges;
|
|
265
272
|
}
|
|
273
|
+
exports.OtherCharges = OtherCharges;
|
|
266
274
|
function printedOrderTaxes(order, loyalty_amount, branch_vat) {
|
|
267
275
|
let taxes = [];
|
|
268
276
|
if (order) {
|
|
269
277
|
const sub = Subtotal(order.order_items);
|
|
270
278
|
const discounts = Number(Discounts((order === null || order === void 0 ? void 0 : order.order_discounts) || [], order.order_items, loyalty_amount, branch_vat));
|
|
271
279
|
if (order && order.order_taxes) {
|
|
272
|
-
order.order_taxes.forEach((tax) => {
|
|
280
|
+
((order === null || order === void 0 ? void 0 : order.order_taxes) || []).forEach((tax) => {
|
|
273
281
|
if (tax.amount) {
|
|
274
282
|
taxes.push({
|
|
275
283
|
tax_id: tax.tax_id || '',
|
|
@@ -284,9 +292,8 @@ function printedOrderTaxes(order, loyalty_amount, branch_vat) {
|
|
|
284
292
|
}
|
|
285
293
|
const order_items_count = lodash_1.default.sum(order.order_items.map((i) => i.quantity));
|
|
286
294
|
const item_taxes = order.order_items.reduce((list, order_item) => {
|
|
287
|
-
var _a;
|
|
288
295
|
const addons_amount = calcItemAddons(order_item);
|
|
289
|
-
(
|
|
296
|
+
((order_item === null || order_item === void 0 ? void 0 : order_item.taxes) || []).forEach((tax) => {
|
|
290
297
|
let _discounts = calcItemDiscounts(order_item, order.order_discounts, order_items_count);
|
|
291
298
|
if (tax.tax_id) {
|
|
292
299
|
let charge = 0;
|
|
@@ -317,6 +324,7 @@ function printedOrderTaxes(order, loyalty_amount, branch_vat) {
|
|
|
317
324
|
}
|
|
318
325
|
return taxes;
|
|
319
326
|
}
|
|
327
|
+
exports.printedOrderTaxes = printedOrderTaxes;
|
|
320
328
|
function Total(order, order_items, loyalty_amount, branch_vat) {
|
|
321
329
|
const sub = Number(Subtotal(order_items));
|
|
322
330
|
const discounts = Number(Discounts((order === null || order === void 0 ? void 0 : order.order_discounts) || [], order_items, loyalty_amount, branch_vat));
|
|
@@ -328,6 +336,7 @@ function Total(order, order_items, loyalty_amount, branch_vat) {
|
|
|
328
336
|
return 0;
|
|
329
337
|
return total;
|
|
330
338
|
}
|
|
339
|
+
exports.Total = Total;
|
|
331
340
|
function calcPaymentBalanceDue(invoice, branch) {
|
|
332
341
|
let due = (invoice.total || 0) - (invoice.received_amount || 0);
|
|
333
342
|
if (branch && branch.payment_methods) {
|
|
@@ -337,6 +346,7 @@ function calcPaymentBalanceDue(invoice, branch) {
|
|
|
337
346
|
}
|
|
338
347
|
return due > 0 ? due : 0;
|
|
339
348
|
}
|
|
349
|
+
exports.calcPaymentBalanceDue = calcPaymentBalanceDue;
|
|
340
350
|
function calPaymentTotal(info) {
|
|
341
351
|
let groupByPaymnets = lodash_1.default.map(info.payments, (p) => ({
|
|
342
352
|
name_lan_p: p.name_lan_p,
|
|
@@ -357,21 +367,22 @@ function calPaymentTotal(info) {
|
|
|
357
367
|
}, {});
|
|
358
368
|
return groupByPaymnets;
|
|
359
369
|
}
|
|
370
|
+
exports.calPaymentTotal = calPaymentTotal;
|
|
360
371
|
function calcClosingCashBalance(closing, opening_start_cash) {
|
|
361
372
|
return ((0, utils_1.preventNaN)(closing.closing_cash_sales || 0) +
|
|
362
373
|
(0, utils_1.preventNaN)(opening_start_cash || 0) +
|
|
363
374
|
((0, utils_1.preventNaN)(closing.closing_cash_add || 0) - (0, utils_1.preventNaN)(closing.closing_cash_remove || 0)));
|
|
364
375
|
}
|
|
376
|
+
exports.calcClosingCashBalance = calcClosingCashBalance;
|
|
365
377
|
function calcItemDiscounts(item, order_discounts, order_items_count) {
|
|
366
|
-
var _a, _b;
|
|
367
378
|
let discounts = 0;
|
|
368
379
|
let addons = 0;
|
|
369
|
-
(
|
|
380
|
+
((item === null || item === void 0 ? void 0 : item.addons) || []).forEach((addon) => {
|
|
370
381
|
if (addon.price && addon.quantity) {
|
|
371
382
|
addons += addon.price * addon.quantity;
|
|
372
383
|
}
|
|
373
384
|
});
|
|
374
|
-
(
|
|
385
|
+
((item === null || item === void 0 ? void 0 : item.discounts) || []).forEach((discount) => {
|
|
375
386
|
if (discount.is_percentage && discount.amount) {
|
|
376
387
|
discounts += (item.price + addons) * (discount.amount / 100);
|
|
377
388
|
}
|
|
@@ -379,7 +390,7 @@ function calcItemDiscounts(item, order_discounts, order_items_count) {
|
|
|
379
390
|
discounts += discount.amount;
|
|
380
391
|
}
|
|
381
392
|
});
|
|
382
|
-
order_discounts
|
|
393
|
+
(order_discounts || []).forEach((discount) => {
|
|
383
394
|
if (discount.is_percentage && discount.amount) {
|
|
384
395
|
discounts += (item.price + addons) * (discount.amount / 100);
|
|
385
396
|
}
|
|
@@ -389,16 +400,17 @@ function calcItemDiscounts(item, order_discounts, order_items_count) {
|
|
|
389
400
|
});
|
|
390
401
|
return discounts;
|
|
391
402
|
}
|
|
403
|
+
exports.calcItemDiscounts = calcItemDiscounts;
|
|
392
404
|
function calcItemAddons(item) {
|
|
393
|
-
var _a;
|
|
394
405
|
let addons = 0;
|
|
395
|
-
(
|
|
406
|
+
((item === null || item === void 0 ? void 0 : item.addons) || []).forEach((addon) => {
|
|
396
407
|
if (addon.price && addon.quantity) {
|
|
397
408
|
addons += addon.price * addon.quantity;
|
|
398
409
|
}
|
|
399
410
|
});
|
|
400
411
|
return addons;
|
|
401
412
|
}
|
|
413
|
+
exports.calcItemAddons = calcItemAddons;
|
|
402
414
|
function getInvoicesDiffrence(openning, invoices) {
|
|
403
415
|
const now = (0, moment_1.default)();
|
|
404
416
|
const openningTime = (0, moment_1.default)((0, utils_1.convertToDate)(openning.cashier_opening_date));
|
|
@@ -410,24 +422,4 @@ function getInvoicesDiffrence(openning, invoices) {
|
|
|
410
422
|
});
|
|
411
423
|
return orders;
|
|
412
424
|
}
|
|
413
|
-
exports.
|
|
414
|
-
ItemTotal,
|
|
415
|
-
Subtotal,
|
|
416
|
-
calcItem,
|
|
417
|
-
Discounts,
|
|
418
|
-
DiscountsWithVat,
|
|
419
|
-
ItemVat,
|
|
420
|
-
Vat,
|
|
421
|
-
TaxableAmount,
|
|
422
|
-
NonTaxableAmount,
|
|
423
|
-
Deliveries,
|
|
424
|
-
OtherCharges,
|
|
425
|
-
printedOrderTaxes,
|
|
426
|
-
Total,
|
|
427
|
-
calcPaymentBalanceDue,
|
|
428
|
-
calPaymentTotal,
|
|
429
|
-
calcClosingCashBalance,
|
|
430
|
-
calcItemDiscounts,
|
|
431
|
-
calcItemAddons,
|
|
432
|
-
getInvoicesDiffrence,
|
|
433
|
-
};
|
|
425
|
+
exports.getInvoicesDiffrence = getInvoicesDiffrence;
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.getInvoicesDiffrence = exports.calcItemAddons = exports.calcItemDiscounts = exports.calcClosingCashBalance = exports.calPaymentTotal = exports.calcPaymentBalanceDue = exports.Total = exports.printedOrderTaxes = exports.OtherCharges = exports.Deliveries = exports.NonTaxableAmount = exports.TaxableAmount = exports.Vat = exports.ItemVat = exports.DiscountsWithVat = exports.Discounts = exports.calcItem = exports.Subtotal = exports.ItemTotal = void 0;
|
|
4
|
+
const Calcs_1 = require("./Calcs");
|
|
5
|
+
Object.defineProperty(exports, "ItemTotal", { enumerable: true, get: function () { return Calcs_1.ItemTotal; } });
|
|
6
|
+
Object.defineProperty(exports, "Subtotal", { enumerable: true, get: function () { return Calcs_1.Subtotal; } });
|
|
7
|
+
Object.defineProperty(exports, "calcItem", { enumerable: true, get: function () { return Calcs_1.calcItem; } });
|
|
8
|
+
Object.defineProperty(exports, "Discounts", { enumerable: true, get: function () { return Calcs_1.Discounts; } });
|
|
9
|
+
Object.defineProperty(exports, "DiscountsWithVat", { enumerable: true, get: function () { return Calcs_1.DiscountsWithVat; } });
|
|
10
|
+
Object.defineProperty(exports, "ItemVat", { enumerable: true, get: function () { return Calcs_1.ItemVat; } });
|
|
11
|
+
Object.defineProperty(exports, "Vat", { enumerable: true, get: function () { return Calcs_1.Vat; } });
|
|
12
|
+
Object.defineProperty(exports, "TaxableAmount", { enumerable: true, get: function () { return Calcs_1.TaxableAmount; } });
|
|
13
|
+
Object.defineProperty(exports, "NonTaxableAmount", { enumerable: true, get: function () { return Calcs_1.NonTaxableAmount; } });
|
|
14
|
+
Object.defineProperty(exports, "Deliveries", { enumerable: true, get: function () { return Calcs_1.Deliveries; } });
|
|
15
|
+
Object.defineProperty(exports, "OtherCharges", { enumerable: true, get: function () { return Calcs_1.OtherCharges; } });
|
|
16
|
+
Object.defineProperty(exports, "printedOrderTaxes", { enumerable: true, get: function () { return Calcs_1.printedOrderTaxes; } });
|
|
17
|
+
Object.defineProperty(exports, "Total", { enumerable: true, get: function () { return Calcs_1.Total; } });
|
|
18
|
+
Object.defineProperty(exports, "calcPaymentBalanceDue", { enumerable: true, get: function () { return Calcs_1.calcPaymentBalanceDue; } });
|
|
19
|
+
Object.defineProperty(exports, "calPaymentTotal", { enumerable: true, get: function () { return Calcs_1.calPaymentTotal; } });
|
|
20
|
+
Object.defineProperty(exports, "calcClosingCashBalance", { enumerable: true, get: function () { return Calcs_1.calcClosingCashBalance; } });
|
|
21
|
+
Object.defineProperty(exports, "calcItemDiscounts", { enumerable: true, get: function () { return Calcs_1.calcItemDiscounts; } });
|
|
22
|
+
Object.defineProperty(exports, "calcItemAddons", { enumerable: true, get: function () { return Calcs_1.calcItemAddons; } });
|
|
23
|
+
Object.defineProperty(exports, "getInvoicesDiffrence", { enumerable: true, get: function () { return Calcs_1.getInvoicesDiffrence; } });
|
package/lib/cjs/types/Calcs.d.ts
CHANGED
|
@@ -18,26 +18,5 @@ declare function calcClosingCashBalance(closing: Partial<CashierClosing>, openin
|
|
|
18
18
|
declare function calcItemDiscounts(item: OrderItem, order_discounts: OrderDiscount[] | undefined, order_items_count: number): number;
|
|
19
19
|
declare function calcItemAddons(item: OrderItem): number;
|
|
20
20
|
declare function getInvoicesDiffrence(openning: CashierOpening, invoices: Order[]): (Order | undefined)[];
|
|
21
|
-
|
|
22
|
-
ItemTotal: typeof ItemTotal;
|
|
23
|
-
Subtotal: typeof Subtotal;
|
|
24
|
-
calcItem: typeof calcItem;
|
|
25
|
-
Discounts: typeof Discounts;
|
|
26
|
-
DiscountsWithVat: typeof DiscountsWithVat;
|
|
27
|
-
ItemVat: typeof ItemVat;
|
|
28
|
-
Vat: typeof Vat;
|
|
29
|
-
TaxableAmount: typeof TaxableAmount;
|
|
30
|
-
NonTaxableAmount: typeof NonTaxableAmount;
|
|
31
|
-
Deliveries: typeof Deliveries;
|
|
32
|
-
OtherCharges: typeof OtherCharges;
|
|
33
|
-
printedOrderTaxes: typeof printedOrderTaxes;
|
|
34
|
-
Total: typeof Total;
|
|
35
|
-
calcPaymentBalanceDue: typeof calcPaymentBalanceDue;
|
|
36
|
-
calPaymentTotal: typeof calPaymentTotal;
|
|
37
|
-
calcClosingCashBalance: typeof calcClosingCashBalance;
|
|
38
|
-
calcItemDiscounts: typeof calcItemDiscounts;
|
|
39
|
-
calcItemAddons: typeof calcItemAddons;
|
|
40
|
-
getInvoicesDiffrence: typeof getInvoicesDiffrence;
|
|
41
|
-
};
|
|
42
|
-
export default _default;
|
|
21
|
+
export { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence, };
|
|
43
22
|
//# sourceMappingURL=Calcs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calcs.d.ts","sourceRoot":"","sources":["../../../src/Calcs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAiB,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGtJ,iBAAS,SAAS,CACjB,UAAU,EAAE,SAAS,EACrB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,WAAW,CAAC,EAAE,QAAQ,EAAE,EACxB,eAAe,CAAC,EAAE,aAAa,EAAE,EACjC,iBAAiB,SAAI,UAqCrB;AAED,iBAAS,QAAQ,CAAC,WAAW,EAAE,SAAS,EAAE,GAAG,IAAI,UAKhD;AAED,iBAAS,QAAQ,CAAC,UAAU,EAAE,SAAS,UActC;AAED,iBAAS,SAAS,CACjB,eAAe,EAAE,aAAa,EAAE,GAAG,IAAI,EACvC,WAAW,EAAE,SAAS,EAAE,GAAG,IAAI,EAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,EAC7B,UAAU,EAAE,MAAM,GAAG,IAAI,UA8CzB;AAED,iBAAS,gBAAgB,CACxB,eAAe,EAAE,aAAa,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SAAS,EAAE,iBAAiB,EAAE,MAAM,UA2BlH;AAED,iBAAS,cAAc,CAAC,IAAI,EAAE,SAAS,UAStC;AAED,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,EAAE,yBAUxE;AAED,OAAO,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACpB,CAAC"}
|
package/lib/cjs/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
1
|
+
import { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence } from './Calcs';
|
|
2
|
+
export { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence, };
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACpB,CAAC"}
|
package/lib/esm/Calcs.js
CHANGED
|
@@ -6,7 +6,7 @@ function ItemTotal(order_item, branch_vat, order_taxes, order_discounts, order_i
|
|
|
6
6
|
const vat = branch_vat ? 1 + branch_vat / 100 : 1;
|
|
7
7
|
if (order_item.price && order_item.quantity) {
|
|
8
8
|
let price = order_item.price;
|
|
9
|
-
order_item.
|
|
9
|
+
(order_item?.addons || []).forEach((addon) => {
|
|
10
10
|
if (addon.price && addon.quantity) {
|
|
11
11
|
price += addon.price * addon.quantity;
|
|
12
12
|
}
|
|
@@ -38,7 +38,7 @@ function Subtotal(order_items) {
|
|
|
38
38
|
}
|
|
39
39
|
function calcItem(order_item) {
|
|
40
40
|
let result = 0;
|
|
41
|
-
order_item?.addons
|
|
41
|
+
(order_item?.addons || []).forEach((addon) => {
|
|
42
42
|
if (addon.price && addon.quantity) {
|
|
43
43
|
result += addon.price * addon.quantity;
|
|
44
44
|
}
|
|
@@ -73,7 +73,7 @@ function Discounts(order_discounts, order_items, loyalty_amount, branch_vat) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
order_items?.forEach((order_item) => {
|
|
76
|
-
order_item?.discounts
|
|
76
|
+
(order_item?.discounts || []).forEach((discount) => {
|
|
77
77
|
if (discount.is_percentage && discount.amount) {
|
|
78
78
|
const addons_arr = order_item?.addons?.map((a) => (a.price ?? 0) * a.quantity || 0);
|
|
79
79
|
const addons_total = _.sum(addons_arr);
|
|
@@ -119,8 +119,8 @@ function DiscountsWithVat(order_discounts, order_items, loyalty_amount, branch_v
|
|
|
119
119
|
}
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
order_items
|
|
123
|
-
order_item?.discounts
|
|
122
|
+
(order_items || []).forEach((order_item) => {
|
|
123
|
+
(order_item?.discounts || []).forEach((discount) => {
|
|
124
124
|
if (!order_item.not_taxable) {
|
|
125
125
|
if (discount.is_percentage && discount.amount) {
|
|
126
126
|
const addons_arr = order_item?.addons?.map((a) => (a.price || 0) * (a.quantity || 0));
|
|
@@ -147,13 +147,13 @@ function DiscountsWithVat(order_discounts, order_items, loyalty_amount, branch_v
|
|
|
147
147
|
function ItemVat(order_item, branch_vat) {
|
|
148
148
|
const vat = branch_vat ? branch_vat / 100 : 1;
|
|
149
149
|
let addons = 0;
|
|
150
|
-
order_item?.addons
|
|
150
|
+
(order_item?.addons || []).forEach((addon) => {
|
|
151
151
|
if (addon.price && addon.quantity) {
|
|
152
152
|
addons += toFixedFloat(addon.price * addon.quantity);
|
|
153
153
|
}
|
|
154
154
|
});
|
|
155
155
|
let discounts = 0;
|
|
156
|
-
order_item.
|
|
156
|
+
(order_item?.discounts || []).forEach((discount) => {
|
|
157
157
|
if (discount.is_percentage && discount.amount) {
|
|
158
158
|
discounts += toFixedFloat((order_item.price + addons) * order_item.quantity * (discount.amount / 100));
|
|
159
159
|
}
|
|
@@ -214,11 +214,11 @@ function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
|
214
214
|
}))
|
|
215
215
|
: 0;
|
|
216
216
|
}
|
|
217
|
-
order_items.forEach((order_item) => {
|
|
217
|
+
(order_items || []).forEach((order_item) => {
|
|
218
218
|
const addons_total = _.sum(order_item?.addons?.map((a) => (a.price || 0) * (a.quantity || 0)));
|
|
219
219
|
const price = (order_item.price + addons_total) * order_item.quantity;
|
|
220
220
|
let _discounts = 0;
|
|
221
|
-
order_item?.discounts
|
|
221
|
+
(order_item?.discounts || []).forEach((discount) => {
|
|
222
222
|
if (discount.is_percentage && discount.amount) {
|
|
223
223
|
_discounts += price * (discount.amount / 100);
|
|
224
224
|
}
|
|
@@ -227,7 +227,7 @@ function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
|
227
227
|
}
|
|
228
228
|
});
|
|
229
229
|
const order_items_count = _.sum(order_items.map((i) => i.quantity));
|
|
230
|
-
order?.order_discounts.forEach((discount) => {
|
|
230
|
+
(order?.order_discounts || []).forEach((discount) => {
|
|
231
231
|
if (discount.is_percentage && discount.amount) {
|
|
232
232
|
_discounts += price * (discount.amount / 100);
|
|
233
233
|
}
|
|
@@ -235,7 +235,7 @@ function OtherCharges(order_items, order, loyalty_amount, branch_vat) {
|
|
|
235
235
|
_discounts += (discount.amount / order_items_count) * order_item.quantity;
|
|
236
236
|
}
|
|
237
237
|
});
|
|
238
|
-
order_item?.taxes
|
|
238
|
+
(order_item?.taxes || []).forEach((tax) => {
|
|
239
239
|
if (tax.isPercent && tax.amount) {
|
|
240
240
|
let temp = price - _discounts;
|
|
241
241
|
if (temp < 0) {
|
|
@@ -256,7 +256,7 @@ function printedOrderTaxes(order, loyalty_amount, branch_vat) {
|
|
|
256
256
|
const sub = Subtotal(order.order_items);
|
|
257
257
|
const discounts = Number(Discounts(order?.order_discounts || [], order.order_items, loyalty_amount, branch_vat));
|
|
258
258
|
if (order && order.order_taxes) {
|
|
259
|
-
order
|
|
259
|
+
(order?.order_taxes || []).forEach((tax) => {
|
|
260
260
|
if (tax.amount) {
|
|
261
261
|
taxes.push({
|
|
262
262
|
tax_id: tax.tax_id || '',
|
|
@@ -272,7 +272,7 @@ function printedOrderTaxes(order, loyalty_amount, branch_vat) {
|
|
|
272
272
|
const order_items_count = _.sum(order.order_items.map((i) => i.quantity));
|
|
273
273
|
const item_taxes = order.order_items.reduce((list, order_item) => {
|
|
274
274
|
const addons_amount = calcItemAddons(order_item);
|
|
275
|
-
order_item?.taxes
|
|
275
|
+
(order_item?.taxes || []).forEach((tax) => {
|
|
276
276
|
let _discounts = calcItemDiscounts(order_item, order.order_discounts, order_items_count);
|
|
277
277
|
if (tax.tax_id) {
|
|
278
278
|
let charge = 0;
|
|
@@ -351,12 +351,12 @@ function calcClosingCashBalance(closing, opening_start_cash) {
|
|
|
351
351
|
function calcItemDiscounts(item, order_discounts, order_items_count) {
|
|
352
352
|
let discounts = 0;
|
|
353
353
|
let addons = 0;
|
|
354
|
-
item?.addons
|
|
354
|
+
(item?.addons || []).forEach((addon) => {
|
|
355
355
|
if (addon.price && addon.quantity) {
|
|
356
356
|
addons += addon.price * addon.quantity;
|
|
357
357
|
}
|
|
358
358
|
});
|
|
359
|
-
item.
|
|
359
|
+
(item?.discounts || []).forEach((discount) => {
|
|
360
360
|
if (discount.is_percentage && discount.amount) {
|
|
361
361
|
discounts += (item.price + addons) * (discount.amount / 100);
|
|
362
362
|
}
|
|
@@ -364,7 +364,7 @@ function calcItemDiscounts(item, order_discounts, order_items_count) {
|
|
|
364
364
|
discounts += discount.amount;
|
|
365
365
|
}
|
|
366
366
|
});
|
|
367
|
-
order_discounts
|
|
367
|
+
(order_discounts || []).forEach((discount) => {
|
|
368
368
|
if (discount.is_percentage && discount.amount) {
|
|
369
369
|
discounts += (item.price + addons) * (discount.amount / 100);
|
|
370
370
|
}
|
|
@@ -376,7 +376,7 @@ function calcItemDiscounts(item, order_discounts, order_items_count) {
|
|
|
376
376
|
}
|
|
377
377
|
function calcItemAddons(item) {
|
|
378
378
|
let addons = 0;
|
|
379
|
-
item?.addons
|
|
379
|
+
(item?.addons || []).forEach((addon) => {
|
|
380
380
|
if (addon.price && addon.quantity) {
|
|
381
381
|
addons += addon.price * addon.quantity;
|
|
382
382
|
}
|
|
@@ -394,24 +394,4 @@ function getInvoicesDiffrence(openning, invoices) {
|
|
|
394
394
|
});
|
|
395
395
|
return orders;
|
|
396
396
|
}
|
|
397
|
-
export
|
|
398
|
-
ItemTotal,
|
|
399
|
-
Subtotal,
|
|
400
|
-
calcItem,
|
|
401
|
-
Discounts,
|
|
402
|
-
DiscountsWithVat,
|
|
403
|
-
ItemVat,
|
|
404
|
-
Vat,
|
|
405
|
-
TaxableAmount,
|
|
406
|
-
NonTaxableAmount,
|
|
407
|
-
Deliveries,
|
|
408
|
-
OtherCharges,
|
|
409
|
-
printedOrderTaxes,
|
|
410
|
-
Total,
|
|
411
|
-
calcPaymentBalanceDue,
|
|
412
|
-
calPaymentTotal,
|
|
413
|
-
calcClosingCashBalance,
|
|
414
|
-
calcItemDiscounts,
|
|
415
|
-
calcItemAddons,
|
|
416
|
-
getInvoicesDiffrence,
|
|
417
|
-
};
|
|
397
|
+
export { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence, };
|
package/lib/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
1
|
+
import { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence, } from './Calcs';
|
|
2
|
+
export { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence, };
|
package/lib/esm/types/Calcs.d.ts
CHANGED
|
@@ -18,26 +18,5 @@ declare function calcClosingCashBalance(closing: Partial<CashierClosing>, openin
|
|
|
18
18
|
declare function calcItemDiscounts(item: OrderItem, order_discounts: OrderDiscount[] | undefined, order_items_count: number): number;
|
|
19
19
|
declare function calcItemAddons(item: OrderItem): number;
|
|
20
20
|
declare function getInvoicesDiffrence(openning: CashierOpening, invoices: Order[]): (Order | undefined)[];
|
|
21
|
-
|
|
22
|
-
ItemTotal: typeof ItemTotal;
|
|
23
|
-
Subtotal: typeof Subtotal;
|
|
24
|
-
calcItem: typeof calcItem;
|
|
25
|
-
Discounts: typeof Discounts;
|
|
26
|
-
DiscountsWithVat: typeof DiscountsWithVat;
|
|
27
|
-
ItemVat: typeof ItemVat;
|
|
28
|
-
Vat: typeof Vat;
|
|
29
|
-
TaxableAmount: typeof TaxableAmount;
|
|
30
|
-
NonTaxableAmount: typeof NonTaxableAmount;
|
|
31
|
-
Deliveries: typeof Deliveries;
|
|
32
|
-
OtherCharges: typeof OtherCharges;
|
|
33
|
-
printedOrderTaxes: typeof printedOrderTaxes;
|
|
34
|
-
Total: typeof Total;
|
|
35
|
-
calcPaymentBalanceDue: typeof calcPaymentBalanceDue;
|
|
36
|
-
calPaymentTotal: typeof calPaymentTotal;
|
|
37
|
-
calcClosingCashBalance: typeof calcClosingCashBalance;
|
|
38
|
-
calcItemDiscounts: typeof calcItemDiscounts;
|
|
39
|
-
calcItemAddons: typeof calcItemAddons;
|
|
40
|
-
getInvoicesDiffrence: typeof getInvoicesDiffrence;
|
|
41
|
-
};
|
|
42
|
-
export default _default;
|
|
21
|
+
export { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence, };
|
|
43
22
|
//# sourceMappingURL=Calcs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calcs.d.ts","sour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-
export
|
|
1
|
+
import { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence } from './Calcs';
|
|
2
|
+
export { ItemTotal, Subtotal, calcItem, Discounts, DiscountsWithVat, ItemVat, Vat, TaxableAmount, NonTaxableAmount, Deliveries, OtherCharges, printedOrderTaxes, Total, calcPaymentBalanceDue, calPaymentTotal, calcClosingCashBalance, calcItemDiscounts, calcItemAddons, getInvoicesDiffrence, };
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EACN,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,gBAAgB,EAChB,OAAO,EACP,GAAG,EACH,aAAa,EACb,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,iBAAiB,EACjB,KAAK,EACL,qBAAqB,EACrB,eAAe,EACf,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,oBAAoB,GACpB,CAAC"}
|
package/package.json
CHANGED