@unimaze/billing 0.21.1 → 0.21.3
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/common/components/billing-lines/BillingCalculations.js +17 -2
- package/lib/common/components/invoice-preview/index.js +21 -9
- package/lib/create-invoice/index.js +1 -1
- package/lib/translations/locales/en.json +1 -0
- package/lib/translations/locales/is.json +1 -0
- package/lib/translations/locales.d.ts +2 -0
- package/lib/utils/BillingLineUtility.js +27 -3
- package/package.json +1 -1
|
@@ -74,7 +74,11 @@ var BillingCalculations = function (props) {
|
|
|
74
74
|
var taxAmount = (0, BillingLineUtility_1.calculateTaxAmount)((0, BillingLineUtility_1.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType), (0, BillingLineUtility_1.calculateTaxPercentage)(billingLine.taxCategoryType ? api_1.TaxCategoryTypeEnum[billingLine.taxCategoryType] : undefined));
|
|
75
75
|
var taxableAmount = (0, BillingLineUtility_1.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType);
|
|
76
76
|
var taxInclusiveAmount = taxableAmount + taxAmount;
|
|
77
|
-
var discountAmount =
|
|
77
|
+
var discountAmount = billingLine.discountType === "PERCENTAGE"
|
|
78
|
+
? (0, BillingLineUtility_1.calculateDiscountAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount)
|
|
79
|
+
: billingLine.discountValue
|
|
80
|
+
? parseFloat(billingLine.discountValue)
|
|
81
|
+
: 0;
|
|
78
82
|
totals = {
|
|
79
83
|
totalTaxAmount: totals.totalTaxAmount + taxAmount,
|
|
80
84
|
totalTaxableAmount: totals.totalTaxableAmount + taxableAmount,
|
|
@@ -90,6 +94,8 @@ var BillingCalculations = function (props) {
|
|
|
90
94
|
if (totals.totalTaxableAmount <= 0 || totals.totalTaxInclusiveAmount <= 0) {
|
|
91
95
|
return null;
|
|
92
96
|
}
|
|
97
|
+
var roundedAmount = Math.round(totals.totalTaxInclusiveAmount);
|
|
98
|
+
var roundingAmount = totals.totalTaxInclusiveAmount - roundedAmount;
|
|
93
99
|
return (react_1.default.createElement(antd_1.Flex, { vertical: true },
|
|
94
100
|
react_1.default.createElement(antd_1.Flex, { justify: "end", gap: 'large' },
|
|
95
101
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: { fontWeight: 300 } },
|
|
@@ -101,6 +107,9 @@ var BillingCalculations = function (props) {
|
|
|
101
107
|
":"),
|
|
102
108
|
totals.discountAmount > 0 && (react_1.default.createElement(antd_1.Typography.Text, null,
|
|
103
109
|
props.intl.formatMessage(translationMessages.billingLines_discount),
|
|
110
|
+
":")),
|
|
111
|
+
roundingAmount !== 0 && (react_1.default.createElement(antd_1.Typography.Text, null,
|
|
112
|
+
props.intl.formatMessage(translationMessages.billingCalculations_labels_RoundingAmount),
|
|
104
113
|
":"))),
|
|
105
114
|
react_1.default.createElement(antd_1.Flex, { vertical: true },
|
|
106
115
|
react_1.default.createElement(antd_1.Typography.Text, { strong: true },
|
|
@@ -120,6 +129,12 @@ var BillingCalculations = function (props) {
|
|
|
120
129
|
style: "decimal",
|
|
121
130
|
}),
|
|
122
131
|
" ",
|
|
132
|
+
props.formInstance.getFieldValue(["invoice", "currencyCode"]))),
|
|
133
|
+
roundingAmount !== 0 && (react_1.default.createElement(antd_1.Typography.Text, { strong: true },
|
|
134
|
+
(0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(roundingAmount, props.intl, {
|
|
135
|
+
style: "decimal",
|
|
136
|
+
}),
|
|
137
|
+
" ",
|
|
123
138
|
props.formInstance.getFieldValue(["invoice", "currencyCode"]))))),
|
|
124
139
|
react_1.default.createElement(antd_1.Row, null,
|
|
125
140
|
react_1.default.createElement(antd_1.Col, { span: 24 },
|
|
@@ -129,7 +144,7 @@ var BillingCalculations = function (props) {
|
|
|
129
144
|
" ",
|
|
130
145
|
"=",
|
|
131
146
|
" ",
|
|
132
|
-
(0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(
|
|
147
|
+
(0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(roundedAmount, props.intl, {
|
|
133
148
|
style: "decimal",
|
|
134
149
|
}),
|
|
135
150
|
" ",
|
|
@@ -72,6 +72,10 @@ var translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
72
72
|
id: "billingCalculations_labels_TotalAmountWithVat",
|
|
73
73
|
defaultMessage: "Total amount with VAT",
|
|
74
74
|
},
|
|
75
|
+
billingCalculations_labels_TotalRoundingAmount: {
|
|
76
|
+
id: "billingCalculations_labels_TotalRoundingAmount",
|
|
77
|
+
defaultMessage: "Rounding amount",
|
|
78
|
+
},
|
|
75
79
|
billingLines_discount: {
|
|
76
80
|
id: "billingLines_discount",
|
|
77
81
|
defaultMessage: "Discount",
|
|
@@ -131,6 +135,7 @@ var InvoicePreview = function (props) {
|
|
|
131
135
|
var formValueFile1 = props.form.getFieldValue(["attachments", "file1", "file"]);
|
|
132
136
|
var formValueFile2 = props.form.getFieldValue(["attachments", "file2", "file"]);
|
|
133
137
|
var formValueFile3 = props.form.getFieldValue(["attachments", "file3", "file"]);
|
|
138
|
+
var _totals = (0, BillingLineUtility_1.getTotals)(props.form.getFieldValue(["invoice", "invoiceLines"]));
|
|
134
139
|
return (react_1.default.createElement(antd_1.Flex, { justify: "center" },
|
|
135
140
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: { width: "100%", maxWidth: "900px" } },
|
|
136
141
|
react_1.default.createElement(antd_1.Row, { gutter: [20, 20] },
|
|
@@ -212,6 +217,9 @@ var InvoicePreview = function (props) {
|
|
|
212
217
|
.map(function (line, index) {
|
|
213
218
|
var _a, _b;
|
|
214
219
|
var taxPercentage = (0, BillingLineUtility_1.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[line.taxCategoryType]);
|
|
220
|
+
var calculatedDiscountValue = line.discountType === "PERCENTAGE"
|
|
221
|
+
? (0, BillingLineUtility_1.calculateDiscountAmount)(line.discountValue, line.quantity, line.unitPriceAmount)
|
|
222
|
+
: line.discountValue;
|
|
215
223
|
return (react_1.default.createElement(antd_1.Flex, { key: index, vertical: true, gap: "small" },
|
|
216
224
|
react_1.default.createElement(antd_1.Flex, { vertical: true },
|
|
217
225
|
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, line.name),
|
|
@@ -240,13 +248,11 @@ var InvoicePreview = function (props) {
|
|
|
240
248
|
" ",
|
|
241
249
|
line.currencyCode)),
|
|
242
250
|
line.discountValue && (react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center" },
|
|
243
|
-
react_1.default.createElement(antd_1.Typography.Text, null,
|
|
244
|
-
line.discountValue,
|
|
245
|
-
"%",
|
|
251
|
+
react_1.default.createElement(antd_1.Typography.Text, null, "".concat(line.discountValue).concat(line.discountType === "PERCENTAGE" ? "%" : " ".concat(line.currencyCode)),
|
|
246
252
|
" ",
|
|
247
253
|
props.intl.formatMessage(translationMessages.billingLines_discount)),
|
|
248
254
|
react_1.default.createElement(antd_1.Typography.Text, null,
|
|
249
|
-
(0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(
|
|
255
|
+
(0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(calculatedDiscountValue, props.intl),
|
|
250
256
|
" ",
|
|
251
257
|
line.currencyCode))),
|
|
252
258
|
react_1.default.createElement(antd_1.Flex, { vertical: true },
|
|
@@ -268,15 +274,22 @@ var InvoicePreview = function (props) {
|
|
|
268
274
|
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
|
|
269
275
|
props.form.getFieldValue(["invoice", "currencyCode"]),
|
|
270
276
|
" ",
|
|
271
|
-
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(
|
|
277
|
+
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
|
|
272
278
|
.totalTaxableAmount, props.intl)))),
|
|
273
279
|
react_1.default.createElement(antd_1.Flex, { justify: "space-between" },
|
|
274
280
|
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalAmountWithVat)),
|
|
275
281
|
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
|
|
276
282
|
props.form.getFieldValue(["invoice", "currencyCode"]),
|
|
277
283
|
" ",
|
|
278
|
-
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(
|
|
279
|
-
.totalTaxInclusiveAmount, props.intl))))
|
|
284
|
+
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
|
|
285
|
+
.totalTaxInclusiveAmount, props.intl)))),
|
|
286
|
+
react_1.default.createElement(antd_1.Flex, { justify: "space-between" },
|
|
287
|
+
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalRoundingAmount)),
|
|
288
|
+
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
|
|
289
|
+
props.form.getFieldValue(["invoice", "currencyCode"]),
|
|
290
|
+
" ",
|
|
291
|
+
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
|
|
292
|
+
.roundingAmount, props.intl)))))),
|
|
280
293
|
react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center", style: { padding: "0 24px" } },
|
|
281
294
|
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } },
|
|
282
295
|
props.intl.formatMessage(translationMessages.billingCalculations_labels_AmountPayable),
|
|
@@ -284,8 +297,7 @@ var InvoicePreview = function (props) {
|
|
|
284
297
|
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4 } },
|
|
285
298
|
props.form.getFieldValue(["invoice", "currencyCode"]),
|
|
286
299
|
" ",
|
|
287
|
-
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeXL } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((
|
|
288
|
-
.totalTaxInclusiveAmount, props.intl)))))),
|
|
300
|
+
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeXL } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(Math.round(_totals.totalTaxInclusiveAmount), props.intl)))))),
|
|
289
301
|
props.form.getFieldValue(["invoice", "notes"]) && (react_1.default.createElement(antd_1.Col, { span: 24 },
|
|
290
302
|
react_1.default.createElement(antd_1.Card, { bordered: false, size: "small", style: { backgroundColor: "#F5F5F5" } },
|
|
291
303
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: { padding: "0 12px" } },
|
|
@@ -218,7 +218,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
218
218
|
paymentMeans: {
|
|
219
219
|
type: getDefaultPaymentType(props.defaultPaymentType),
|
|
220
220
|
},
|
|
221
|
-
referenceIdentifiers: [{}],
|
|
221
|
+
referenceIdentifiers: [{ code: undefined }],
|
|
222
222
|
singleReferenceIdentifier: {
|
|
223
223
|
code: undefined,
|
|
224
224
|
},
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"billingCalculations_labels_RoundingAmount": "Rounding amount",
|
|
35
35
|
"billingCalculations_labels_TaxAmountWithoutVat": "Total amount without VAT",
|
|
36
36
|
"billingCalculations_labels_TotalAmountWithVat": "Total amount with VAT",
|
|
37
|
+
"billingCalculations_labels_TotalRoundingAmount": "Rounding amount",
|
|
37
38
|
"billingCalculations_labels_TotalVatAmount": "Total VAT amount",
|
|
38
39
|
"billingLines_button_addRow": "Add a row",
|
|
39
40
|
"billingLines_currencyCode": "Currency",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"billingCalculations_labels_RoundingAmount": "Afrúningur aura",
|
|
35
35
|
"billingCalculations_labels_TaxAmountWithoutVat": "Samtals án VSK",
|
|
36
36
|
"billingCalculations_labels_TotalAmountWithVat": "Samtals með VSK",
|
|
37
|
+
"billingCalculations_labels_TotalRoundingAmount": "Afrúningur aura",
|
|
37
38
|
"billingCalculations_labels_TotalVatAmount": "Samtals VSK upphæð",
|
|
38
39
|
"billingLines_button_addRow": "Bæta við röð",
|
|
39
40
|
"billingLines_currencyCode": "Currency",
|
|
@@ -35,6 +35,7 @@ declare const _default: {
|
|
|
35
35
|
billingCalculations_labels_RoundingAmount: string;
|
|
36
36
|
billingCalculations_labels_TaxAmountWithoutVat: string;
|
|
37
37
|
billingCalculations_labels_TotalAmountWithVat: string;
|
|
38
|
+
billingCalculations_labels_TotalRoundingAmount: string;
|
|
38
39
|
billingCalculations_labels_TotalVatAmount: string;
|
|
39
40
|
billingLines_button_addRow: string;
|
|
40
41
|
billingLines_currencyCode: string;
|
|
@@ -217,6 +218,7 @@ declare const _default: {
|
|
|
217
218
|
billingCalculations_labels_RoundingAmount: string;
|
|
218
219
|
billingCalculations_labels_TaxAmountWithoutVat: string;
|
|
219
220
|
billingCalculations_labels_TotalAmountWithVat: string;
|
|
221
|
+
billingCalculations_labels_TotalRoundingAmount: string;
|
|
220
222
|
billingCalculations_labels_TotalVatAmount: string;
|
|
221
223
|
billingLines_button_addRow: string;
|
|
222
224
|
billingLines_currencyCode: string;
|
|
@@ -10,6 +10,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
+
t[p] = s[p];
|
|
17
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
+
t[p[i]] = s[p[i]];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
13
24
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
26
|
};
|
|
@@ -24,10 +35,23 @@ var billingLinesFieldsMetadata = function (formInstance) {
|
|
|
24
35
|
var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
|
|
25
36
|
return billingLinesMetadata.map(function (billingLine) {
|
|
26
37
|
var cleanBillingLine = (0, ConversionUtility_1.removeEmpty)(billingLine);
|
|
27
|
-
var
|
|
28
|
-
var
|
|
38
|
+
var discountType = cleanBillingLine.discountType, restBillingLines = __rest(cleanBillingLine, ["discountType"]); // NBNB: removing the added discountType from the properties that will be added to the mappedBillingLine
|
|
39
|
+
var taxableAmount = (0, exports.calculateTaxableAmount)(restBillingLines.discountValue, restBillingLines.quantity, restBillingLines.unitPriceAmount, discountType);
|
|
40
|
+
var taxPercentage = (0, exports.calculateTaxPercentage)(restBillingLines.taxCategoryType);
|
|
29
41
|
var taxAmount = (0, exports.calculateTaxAmount)(taxableAmount, taxPercentage);
|
|
30
|
-
var
|
|
42
|
+
var discountValue;
|
|
43
|
+
if (restBillingLines.discountValue) {
|
|
44
|
+
if (discountType === "PERCENTAGE") {
|
|
45
|
+
discountValue = "".concat(restBillingLines.discountValue, "%");
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
discountValue = restBillingLines.discountValue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
discountValue = restBillingLines.discountValue;
|
|
53
|
+
}
|
|
54
|
+
var mappedBillingLine = __assign(__assign({}, restBillingLines), { discountValue: discountValue, taxableAmount: taxableAmount, taxAmount: taxAmount, taxPercentage: taxPercentage });
|
|
31
55
|
if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
|
|
32
56
|
delete mappedBillingLine.discountValue;
|
|
33
57
|
}
|