@bookipi/htmlgenerator 1.13.0-alpha.2 → 1.13.0-alpha.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/dist/index.js +22 -11
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +22 -11
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -11965,7 +11965,11 @@ var getTaxCodeBreakdown = function getTaxCodeBreakdown(document, company, curren
|
|
|
11965
11965
|
return (_ref2 = (_config$taxCodeRates$ = (_config$taxCodeRates = config.taxCodeRates) === null || _config$taxCodeRates === void 0 ? void 0 : _config$taxCodeRates[taxCode]) != null ? _config$taxCodeRates$ : Number(taxRate)) != null ? _ref2 : 0;
|
|
11966
11966
|
};
|
|
11967
11967
|
var items = Array.isArray(document === null || document === void 0 ? void 0 : document.it) ? document.it : [];
|
|
11968
|
-
var
|
|
11968
|
+
var documentInclusive = !!(document !== null && document !== void 0 && document.ti);
|
|
11969
|
+
var isLineInclusive = function isLineInclusive(item) {
|
|
11970
|
+
return (item === null || item === void 0 ? void 0 : item.ti) != null ? !!item.ti : documentInclusive;
|
|
11971
|
+
};
|
|
11972
|
+
var shippingInclusive = (document === null || document === void 0 ? void 0 : document.shippingTi) != null ? !!document.shippingTi : documentInclusive;
|
|
11969
11973
|
var itemsSubtotal = items.reduce(function (sum, item) {
|
|
11970
11974
|
return sum + (Number(item === null || item === void 0 ? void 0 : item.t) || 0);
|
|
11971
11975
|
}, 0);
|
|
@@ -11982,16 +11986,22 @@ var getTaxCodeBreakdown = function getTaxCodeBreakdown(document, company, curren
|
|
|
11982
11986
|
return share;
|
|
11983
11987
|
});
|
|
11984
11988
|
var buckets = new Map();
|
|
11985
|
-
var bucketFor = function bucketFor(taxCode, ratePercent) {
|
|
11986
|
-
|
|
11987
|
-
|
|
11989
|
+
var bucketFor = function bucketFor(taxCode, ratePercent, inclusive) {
|
|
11990
|
+
var key = taxCode + "|" + (inclusive ? 'in' : 'on');
|
|
11991
|
+
if (!buckets.has(key)) {
|
|
11992
|
+
buckets.set(key, {
|
|
11988
11993
|
taxCode: taxCode,
|
|
11989
11994
|
ratePercent: ratePercent,
|
|
11995
|
+
inclusive: inclusive,
|
|
11990
11996
|
itemsAmount: 0,
|
|
11991
11997
|
shippingAmount: 0
|
|
11992
11998
|
});
|
|
11993
11999
|
}
|
|
11994
|
-
return buckets.get(
|
|
12000
|
+
return buckets.get(key);
|
|
12001
|
+
};
|
|
12002
|
+
var addToBucket = function addToBucket(taxCode, rate, base, inclusive, key) {
|
|
12003
|
+
var mode = rate > 0 && inclusive;
|
|
12004
|
+
bucketFor(taxCode, rate, mode)[key] += vatOnBase(base, rate, mode);
|
|
11995
12005
|
};
|
|
11996
12006
|
items.forEach(function (item, index) {
|
|
11997
12007
|
if (!(item !== null && item !== void 0 && item.taxCode)) {
|
|
@@ -12000,25 +12010,26 @@ var getTaxCodeBreakdown = function getTaxCodeBreakdown(document, company, curren
|
|
|
12000
12010
|
var base = Number(item.t) || 0;
|
|
12001
12011
|
var share = discountShares[index];
|
|
12002
12012
|
var rate = rateFor(item.taxCode, item.taxRate) || 0;
|
|
12003
|
-
|
|
12013
|
+
addToBucket(item.taxCode, rate, base - share, isLineInclusive(item), 'itemsAmount');
|
|
12004
12014
|
});
|
|
12005
12015
|
var shipping = document !== null && document !== void 0 && document.sp && !(document !== null && document !== void 0 && document.sntx) ? parseFloat(document.sp) : 0;
|
|
12006
12016
|
if (shipping && document !== null && document !== void 0 && document.shippingTaxCode) {
|
|
12007
12017
|
var rate = rateFor(document.shippingTaxCode, document.shippingTaxRate) || 0;
|
|
12008
|
-
|
|
12018
|
+
addToBucket(document.shippingTaxCode, rate, shipping, shippingInclusive, 'shippingAmount');
|
|
12009
12019
|
}
|
|
12010
|
-
return
|
|
12020
|
+
return Array.from(buckets.values()).map(function (bucket) {
|
|
12011
12021
|
var itemsAmount = round(bucket.itemsAmount);
|
|
12012
12022
|
var shippingAmount = round(bucket.shippingAmount);
|
|
12023
|
+
var amount = round(itemsAmount + shippingAmount);
|
|
12013
12024
|
return _extends({}, bucket, {
|
|
12014
12025
|
itemsAmount: itemsAmount,
|
|
12015
12026
|
shippingAmount: shippingAmount,
|
|
12016
|
-
amount:
|
|
12017
|
-
included: inclusive,
|
|
12027
|
+
amount: amount,
|
|
12028
|
+
included: bucket.inclusive,
|
|
12018
12029
|
showSubBreakdown: itemsAmount > 0 && shippingAmount > 0
|
|
12019
12030
|
});
|
|
12020
12031
|
}).sort(function (a, b) {
|
|
12021
|
-
return b.ratePercent - a.ratePercent;
|
|
12032
|
+
return b.ratePercent - a.ratePercent || Number(b.included) - Number(a.included);
|
|
12022
12033
|
});
|
|
12023
12034
|
};
|
|
12024
12035
|
var getTaxCodeRowLabel = function getTaxCodeRowLabel(entry, _ref3) {
|