@unimaze/billing 0.21.12 → 0.21.14

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.
@@ -109,7 +109,7 @@ var BillingCalculations = function (props) {
109
109
  roundingAmount !== 0 && (react_1.default.createElement(antd_1.Typography.Text, null,
110
110
  props.intl.formatMessage(translationMessages.billingCalculations_labels_RoundingAmount),
111
111
  ":"))),
112
- react_1.default.createElement(antd_1.Flex, { vertical: true },
112
+ react_1.default.createElement(antd_1.Flex, { vertical: true, style: { alignItems: 'end' } },
113
113
  react_1.default.createElement(antd_1.Typography.Text, { strong: true },
114
114
  (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(totals.totalTaxableAmount, props.intl, {
115
115
  style: "decimal",
@@ -2,11 +2,13 @@ import React from "react";
2
2
  import { AvailableTaxCategoryTypeEnum } from "../../../enums";
3
3
  import { WrappedComponentProps } from "react-intl";
4
4
  interface BillingLinePreviewProps extends WrappedComponentProps {
5
+ itemNo?: string;
5
6
  name?: string;
6
7
  taxableAmount?: number;
7
8
  quantity?: number;
8
9
  unit?: string;
9
10
  unitPriceAmount?: number;
11
+ unitOfMeasure?: any;
10
12
  taxCategoryType?: AvailableTaxCategoryTypeEnum;
11
13
  discountValue?: string;
12
14
  discountType?: string;
@@ -10,33 +10,53 @@ var antd_1 = require("antd");
10
10
  var icons_1 = require("@ant-design/icons");
11
11
  var NewBillingLines_1 = require("./NewBillingLines");
12
12
  var react_intl_1 = require("react-intl");
13
+ var IntlUtility_1 = require("../../../utils/IntlUtility");
13
14
  var BillingLinePreview = function (props) {
14
- var taxPercentage = (0, BillingLineUtility_1.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[props.taxCategoryType]);
15
+ var billingLineHeader = function () {
16
+ var itemNo = props.itemNo, name = props.name, taxableAmount = props.taxableAmount, currencyCode = props.currencyCode;
17
+ var formattedTaxableAmount = (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(taxableAmount, props.intl, { style: "decimal", });
18
+ return react_1.default.createElement("div", { style: { display: "flex", justifyContent: "space-between", flexDirection: 'row' } },
19
+ react_1.default.createElement("div", null,
20
+ itemNo,
21
+ " ",
22
+ react_1.default.createElement("span", { style: { fontWeight: 'bold' } }, name)),
23
+ react_1.default.createElement("div", { style: { fontWeight: 'bold' } },
24
+ formattedTaxableAmount,
25
+ " ",
26
+ currencyCode));
27
+ };
28
+ var billingLineContent = function () {
29
+ var quantity = props.quantity, unitOfMeasure = props.unitOfMeasure, unitPriceAmount = props.unitPriceAmount, currencyCode = props.currencyCode, discountValue = props.discountValue, discountType = props.discountType;
30
+ var unitOfMeasureUnitLabel = (0, BillingLineUtility_1.getUnitOfMeasureUnitLabel)(unitOfMeasure);
31
+ var discountExist = Number(discountValue) > 0;
32
+ var taxPercentage = (0, BillingLineUtility_1.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[props.taxCategoryType]);
33
+ var discountText = props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_lineDiscount);
34
+ var discount = discountExist ? ", ".concat((0, BillingLineUtility_1.getDiscountLabel)(discountValue, discountType, currencyCode, discountText)) : null;
35
+ var tax = "".concat(taxPercentage, "% ").concat(props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_tax));
36
+ return react_1.default.createElement(antd_1.Typography.Text, null,
37
+ quantity,
38
+ " ",
39
+ unitOfMeasureUnitLabel,
40
+ " ",
41
+ "@",
42
+ " ",
43
+ unitPriceAmount,
44
+ " ",
45
+ currencyCode,
46
+ " ",
47
+ props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_each),
48
+ " ",
49
+ "(",
50
+ tax,
51
+ discount && " ".concat(discount),
52
+ ")");
53
+ };
15
54
  return (react_1.default.createElement(antd_1.Card, { style: { backgroundColor: "#F5F5F5", width: "full" }, size: "small", bordered: false },
16
55
  react_1.default.createElement(antd_1.Flex, { align: "center", justify: "space-between" },
17
- react_1.default.createElement(antd_1.Flex, { vertical: true },
18
- react_1.default.createElement(antd_1.Typography.Text, { strong: true },
19
- props.name,
20
- " = ",
21
- props.taxableAmount,
22
- " ",
23
- props.currencyCode),
24
- react_1.default.createElement(antd_1.Typography.Text, null,
25
- props.quantity,
26
- " ",
27
- props.unit,
28
- " | ",
29
- props.unitPriceAmount,
30
- " ",
31
- props.currencyCode,
32
- " / ",
33
- props.unit,
34
- " | ",
35
- taxPercentage,
36
- "%",
37
- " ",
38
- props.discountValue && " | ".concat(props.discountValue).concat(props.discountType === "PERCENTAGE" ? "%" : " ".concat(props.currencyCode), " ").concat(props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount)))),
39
- react_1.default.createElement("div", null,
56
+ react_1.default.createElement(antd_1.Flex, { vertical: true, style: { width: '100%' } },
57
+ react_1.default.createElement(antd_1.Typography.Text, null, billingLineHeader()),
58
+ react_1.default.createElement(antd_1.Typography.Text, null, billingLineContent())),
59
+ react_1.default.createElement("div", { style: { display: "flex", flexDirection: 'row' } },
40
60
  react_1.default.createElement(antd_1.Button, { onClick: props.onEdit, icon: react_1.default.createElement(icons_1.EditOutlined, null), type: "text" }),
41
61
  react_1.default.createElement(antd_1.Button, { onClick: props.onDelete, icon: react_1.default.createElement(icons_1.DeleteOutlined, null), type: "text", danger: true })))));
42
62
  };
@@ -47,6 +47,10 @@ export declare const translationMessages: {
47
47
  id: string;
48
48
  defaultMessage: string;
49
49
  };
50
+ billingLines_lineDiscount: {
51
+ id: string;
52
+ defaultMessage: string;
53
+ };
50
54
  billingLines_lineAmount: {
51
55
  id: string;
52
56
  defaultMessage: string;
@@ -119,6 +123,14 @@ export declare const translationMessages: {
119
123
  id: string;
120
124
  defaultMessage: string;
121
125
  };
126
+ billingLines_each: {
127
+ id: string;
128
+ defaultMessage: string;
129
+ };
130
+ billingLines_tax: {
131
+ id: string;
132
+ defaultMessage: string;
133
+ };
122
134
  };
123
135
  interface Props extends WrappedComponentProps {
124
136
  receiverRequirements: NewReceiverRequirements;
@@ -87,6 +87,10 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
87
87
  id: "billingLines_discount_helpText",
88
88
  defaultMessage: "Discount can be represented as an amount or a percentage indicated with a percentage sign (%)",
89
89
  },
90
+ billingLines_lineDiscount: {
91
+ id: "billingLines_lineDiscount",
92
+ defaultMessage: "line discount",
93
+ },
90
94
  billingLines_lineAmount: {
91
95
  id: "billingLines_lineAmount",
92
96
  defaultMessage: "Amount",
@@ -159,6 +163,14 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
159
163
  id: "billingLines_input_must_be_number_validationMessage",
160
164
  defaultMessage: "Input must be a number",
161
165
  },
166
+ billingLines_each: {
167
+ id: "billingLines_each",
168
+ defaultMessage: "each",
169
+ },
170
+ billingLines_tax: {
171
+ id: "billingLines_tax",
172
+ defaultMessage: "tax",
173
+ },
162
174
  });
163
175
  var BillingLines = function (props) {
164
176
  (0, react_1.useEffect)(function () {
@@ -270,6 +270,6 @@ var SingleBillingLine = function (props) {
270
270
  props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_labels_addButton))))));
271
271
  return (React.createElement(React.Fragment, null, isEditing
272
272
  ? editingRender
273
- : React.createElement(BillingLinePreview_1.default, { name: field === null || field === void 0 ? void 0 : field.name, discountValue: field === null || field === void 0 ? void 0 : field.discountValue, discountType: field === null || field === void 0 ? void 0 : field.discountType, taxCategoryType: field === null || field === void 0 ? void 0 : field.taxCategoryType, currencyCode: field === null || field === void 0 ? void 0 : field.currencyCode, onEdit: handleOnEdit, quantity: field === null || field === void 0 ? void 0 : field.quantity, taxableAmount: field === null || field === void 0 ? void 0 : field.taxableAmount, unitPriceAmount: field === null || field === void 0 ? void 0 : field.unitPriceAmount, unit: field === null || field === void 0 ? void 0 : field.unitPriceAmount, onDelete: handleRemove })));
273
+ : React.createElement(BillingLinePreview_1.default, { itemNo: field === null || field === void 0 ? void 0 : field.itemNo, name: field === null || field === void 0 ? void 0 : field.name, discountValue: field === null || field === void 0 ? void 0 : field.discountValue, discountType: field === null || field === void 0 ? void 0 : field.discountType, taxCategoryType: field === null || field === void 0 ? void 0 : field.taxCategoryType, currencyCode: field === null || field === void 0 ? void 0 : field.currencyCode, onEdit: handleOnEdit, quantity: field === null || field === void 0 ? void 0 : field.quantity, taxableAmount: field === null || field === void 0 ? void 0 : field.taxableAmount, unitPriceAmount: field === null || field === void 0 ? void 0 : field.unitPriceAmount, unit: field === null || field === void 0 ? void 0 : field.unitPriceAmount, unitOfMeasure: field === null || field === void 0 ? void 0 : field.unitOfMeasure, onDelete: handleRemove })));
274
274
  };
275
275
  exports.default = (0, react_intl_1.injectIntl)(SingleBillingLine);
@@ -24,16 +24,10 @@ var InvoicePreviewCustomerSupplierInfoBox = function (props) {
24
24
  props.intl.formatMessage(index_1.translationMessages.customer_title),
25
25
  ":"),
26
26
  react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.chosenCustomer.name),
27
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
28
- props.intl.formatMessage(index_1.translationMessages.customer_identifier),
29
- ":",
30
- " ",
31
- props.chosenCustomer.identifier),
27
+ react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.chosenCustomer.identifier),
32
28
  ((_c = props.chosenCustomer.address) === null || _c === void 0 ? void 0 : _c.streetNameAndNumber) &&
33
29
  ((_d = props.chosenCustomer.address) === null || _d === void 0 ? void 0 : _d.postalZone) &&
34
30
  ((_e = props.chosenCustomer.address) === null || _e === void 0 ? void 0 : _e.city) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
35
- props.intl.formatMessage(index_1.translationMessages.customer_address_streetNameAndNumber),
36
- ": ",
37
31
  props.chosenCustomer.address.streetNameAndNumber,
38
32
  ",",
39
33
  " ",
@@ -50,24 +44,14 @@ var InvoicePreviewCustomerSupplierInfoBox = function (props) {
50
44
  props.intl.formatMessage(index_1.translationMessages.supplier_title),
51
45
  ":"),
52
46
  react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.form.getFieldValue(["invoice", "supplier", "name"])),
47
+ react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.form.getFieldValue(["invoice", "supplier", "identifier"])),
53
48
  react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
54
- props.intl.formatMessage(index_1.translationMessages.supplier_identifier),
55
- ":",
56
- " ",
57
- props.form.getFieldValue(["invoice", "supplier", "identifier"])),
58
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
59
- props.intl.formatMessage(index_1.translationMessages.supplier_address_streetNameAndNumber),
60
- ":",
61
- " ",
62
49
  props.form.getFieldValue(["invoice", "supplier", "address", "streetNameAndNumber",]),
63
50
  ", ",
64
51
  props.form.getFieldValue(["invoice", "supplier", "address", "postalZone"]),
65
52
  " ",
66
53
  props.form.getFieldValue(["invoice", "supplier", "address", "city"])),
67
- props.form.getFieldValue(["invoice", "supplier", "contact", "telephone"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
68
- props.intl.formatMessage(index_1.translationMessages.supplier_contact_phoneNumber),
69
- ":",
70
- props.form.getFieldValue(["invoice", "supplier", "contact", "telephone"]))),
54
+ props.form.getFieldValue(["invoice", "supplier", "contact", "telephone"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.form.getFieldValue(["invoice", "supplier", "contact", "telephone"]))),
71
55
  props.form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"])))))));
72
56
  };
73
57
  exports.default = (0, react_intl_1.injectIntl)(InvoicePreviewCustomerSupplierInfoBox);
@@ -8,6 +8,7 @@ var react_1 = __importDefault(require("react"));
8
8
  var react_intl_1 = require("react-intl");
9
9
  var BillingLineUtility_1 = require("../../../utils/BillingLineUtility");
10
10
  var index_1 = require("./index");
11
+ var NewBillingLines_1 = require("../billing-lines/NewBillingLines");
11
12
  var IntlUtility_1 = require("../../../utils/IntlUtility");
12
13
  var enums_1 = require("../../../enums");
13
14
  var InvoicePreviewInvoiceLines = function (props) {
@@ -15,19 +16,20 @@ var InvoicePreviewInvoiceLines = function (props) {
15
16
  var token = antd_1.theme.useToken().token;
16
17
  var billingLineContent = function (line) {
17
18
  var quantity = line.quantity, unitOfMeasure = line.unitOfMeasure, unitPriceAmount = line.unitPriceAmount, currencyCode = line.currencyCode;
18
- var unitOfMeasureUnit = (unitOfMeasure === null || unitOfMeasure === void 0 ? void 0 : unitOfMeasure.unit) === "One" ? undefined : (unitOfMeasure === null || unitOfMeasure === void 0 ? void 0 : unitOfMeasure.unit) + ("(s)");
19
+ var unitOfMeasureUnitLabel = (0, BillingLineUtility_1.getUnitOfMeasureUnitLabel)(unitOfMeasure);
20
+ var unitPriceAmountFormatted = (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(unitPriceAmount, props.intl, { style: "decimal" });
19
21
  return react_1.default.createElement(antd_1.Typography.Text, { style: { fontStyle: "italic", color: 'grey' } },
20
22
  quantity,
21
23
  " ",
22
- unitOfMeasureUnit,
24
+ unitOfMeasureUnitLabel,
23
25
  " ",
24
26
  "@",
25
27
  " ",
26
- unitPriceAmount,
28
+ unitPriceAmountFormatted,
27
29
  " ",
28
30
  currencyCode,
29
31
  " ",
30
- "each");
32
+ props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_each));
31
33
  };
32
34
  var getInvoiceLineHeader = function (line, taxPercentage, calculatedDiscountValue) {
33
35
  return react_1.default.createElement("div", { style: {
@@ -47,12 +49,12 @@ var InvoicePreviewInvoiceLines = function (props) {
47
49
  react_1.default.createElement("div", { style: { display: "flex", flexDirection: "row" } },
48
50
  billingLineContent(line),
49
51
  react_1.default.createElement("div", { style: { marginLeft: '10px' } },
50
- line.taxableAmount,
52
+ (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(line.taxableAmount, props.intl, { style: 'decimal' }),
51
53
  " ",
52
54
  line.currencyCode))),
53
55
  react_1.default.createElement("div", null,
54
56
  react_1.default.createElement(antd_1.Typography.Text, null,
55
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((line.quantity * line.unitPriceAmount) + (0, BillingLineUtility_1.calculateTaxAmount)(line.taxableAmount, taxPercentage) - calculatedDiscountValue, props.intl),
57
+ (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((line.quantity * line.unitPriceAmount) + (0, BillingLineUtility_1.calculateTaxAmount)(line.taxableAmount, taxPercentage) - calculatedDiscountValue, props.intl, { style: "decimal" }),
56
58
  " ",
57
59
  line.currencyCode)));
58
60
  };
@@ -71,9 +73,7 @@ var InvoicePreviewInvoiceLines = function (props) {
71
73
  return (react_1.default.createElement(antd_1.Flex, { key: index, vertical: true, gap: "small" },
72
74
  react_1.default.createElement(antd_1.Flex, { vertical: true }, getInvoiceLineHeader(line, taxPercentage, calculatedDiscountValue)),
73
75
  line.discountValue && (react_1.default.createElement(antd_1.Flex, { justify: "space-between", style: { width: "80%" }, align: "center" },
74
- react_1.default.createElement(antd_1.Typography.Text, null, "".concat(line.discountValue).concat(line.discountType === "PERCENTAGE" ? "%" : " ".concat(line.currencyCode)),
75
- " ",
76
- props.intl.formatMessage(index_1.translationMessages.invoicePreview_lineDiscount)),
76
+ react_1.default.createElement(antd_1.Typography.Text, null, " ".concat((0, BillingLineUtility_1.getDiscountLabel)(line.discountValue, line.discountType, line.currencyCode, props.intl.formatMessage(index_1.translationMessages.invoicePreview_lineDiscount)))),
77
77
  react_1.default.createElement(antd_1.Typography.Text, null,
78
78
  "-",
79
79
  (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(calculatedDiscountValue, props.intl),
@@ -83,7 +83,7 @@ var InvoicePreviewInvoiceLines = function (props) {
83
83
  react_1.default.createElement(antd_1.Typography.Text, null,
84
84
  taxPercentage,
85
85
  "% VAT of ",
86
- line.taxableAmount),
86
+ (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(line.taxableAmount, props.intl, { style: 'decimal' })),
87
87
  react_1.default.createElement(antd_1.Typography.Text, null,
88
88
  (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((0, BillingLineUtility_1.calculateTaxAmount)(line.taxableAmount, taxPercentage), props.intl),
89
89
  " ",
@@ -13,16 +13,15 @@ var enums_1 = require("../../../enums");
13
13
  var InvoicePreviewTotalAmountPreview = function (props) {
14
14
  var token = antd_1.theme.useToken().token;
15
15
  var getLinesTax = function () {
16
- var _a;
17
- return ((_a = props.form.getFieldValue(["invoice", "invoiceLines"])) === null || _a === void 0 ? void 0 : _a.length) > 0 &&
18
- props.form.getFieldValue(["invoice", "invoiceLines"]).map(function (line, index) {
19
- var taxPercentage = (0, BillingLineUtility_1.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[line.taxCategoryType]);
20
- return (react_1.default.createElement(antd_1.Flex, { justify: "space-between", key: index },
21
- react_1.default.createElement(antd_1.Typography.Text, null,
22
- taxPercentage,
23
- "% VAT"),
24
- react_1.default.createElement(antd_1.Typography.Text, null, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((0, BillingLineUtility_1.calculateTaxAmount)(line.taxableAmount, taxPercentage), props.intl))));
25
- });
16
+ var lineTaxes = (0, BillingLineUtility_1.combinedTaxesForLines)(props.form.getFieldValue(["invoice", "invoiceLines"]));
17
+ return (lineTaxes === null || lineTaxes === void 0 ? void 0 : lineTaxes.length) > 0 && lineTaxes.map(function (tax, index) {
18
+ var taxPercentage = (0, BillingLineUtility_1.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[tax.taxCategoryType]);
19
+ return (react_1.default.createElement(antd_1.Flex, { justify: "space-between", key: index },
20
+ react_1.default.createElement(antd_1.Typography.Text, null,
21
+ taxPercentage,
22
+ "% VAT"),
23
+ react_1.default.createElement(antd_1.Typography.Text, null, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(tax.taxAmount, props.intl))));
24
+ });
26
25
  };
27
26
  return (react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "small" },
28
27
  react_1.default.createElement(antd_1.Card, { bordered: false, style: { backgroundColor: "#F5F5F5" }, size: "small" },
@@ -39,7 +38,7 @@ var InvoicePreviewTotalAmountPreview = function (props) {
39
38
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
40
39
  props.form.getFieldValue(["invoice", "currencyCode"]),
41
40
  " ",
42
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(props.totals.discountAmount, props.intl)))))),
41
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(props.totals.roundingAmount, props.intl)))))),
43
42
  react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center", style: { padding: "0 24px" } },
44
43
  react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } },
45
44
  props.intl.formatMessage(index_1.translationMessages.billingCalculations_labels_AmountPayable),
@@ -3,6 +3,96 @@ import React from "react";
3
3
  import { FormInstance } from "antd";
4
4
  import { NewReceiverRequirements } from "../../types/NewReceiverRequirements";
5
5
  import { PartyMetadata } from "@unimaze/api-clients/lib/mapi";
6
+ export declare const translationMessages: {
7
+ customer_title: {
8
+ id: string;
9
+ defaultMessage: string;
10
+ };
11
+ customer_address_streetNameAndNumber: {
12
+ id: string;
13
+ defaultMessage: string;
14
+ };
15
+ customer_identifier: {
16
+ id: string;
17
+ defaultMessage: string;
18
+ };
19
+ baseInformation_costCenter: {
20
+ id: string;
21
+ defaultMessage: string;
22
+ };
23
+ baseInformation_issueDate: {
24
+ id: string;
25
+ defaultMessage: string;
26
+ };
27
+ baseInformation_dueDate: {
28
+ id: string;
29
+ defaultMessage: string;
30
+ };
31
+ baseInformation_notes: {
32
+ id: string;
33
+ defaultMessage: string;
34
+ };
35
+ supplier_title: {
36
+ id: string;
37
+ defaultMessage: string;
38
+ };
39
+ supplier_identifier: {
40
+ id: string;
41
+ defaultMessage: string;
42
+ };
43
+ supplier_address_streetNameAndNumber: {
44
+ id: string;
45
+ defaultMessage: string;
46
+ };
47
+ supplier_contact_phoneNumber: {
48
+ id: string;
49
+ defaultMessage: string;
50
+ };
51
+ billingCalculations_labels_TaxAmountWithoutVat: {
52
+ id: string;
53
+ defaultMessage: string;
54
+ };
55
+ billingCalculations_labels_AmountPayable: {
56
+ id: string;
57
+ defaultMessage: string;
58
+ };
59
+ billingCalculations_labels_TotalAmountWithVat: {
60
+ id: string;
61
+ defaultMessage: string;
62
+ };
63
+ billingCalculations_labels_TotalRoundingAmount: {
64
+ id: string;
65
+ defaultMessage: string;
66
+ };
67
+ billingLines_discount: {
68
+ id: string;
69
+ defaultMessage: string;
70
+ };
71
+ billingLines_total: {
72
+ id: string;
73
+ defaultMessage: string;
74
+ };
75
+ invoicePreview_billingLinesTitle: {
76
+ id: string;
77
+ defaultMessage: string;
78
+ };
79
+ invoicePreview_attachmentsTitle: {
80
+ id: string;
81
+ defaultMessage: string;
82
+ };
83
+ invoicePreview_paymentInfoTitle: {
84
+ id: string;
85
+ defaultMessage: string;
86
+ };
87
+ billingLines_total_discount: {
88
+ id: string;
89
+ defaultMessage: string;
90
+ };
91
+ invoicePreview_lineDiscount: {
92
+ id: string;
93
+ defaultMessage: string;
94
+ };
95
+ };
6
96
  interface Props extends WrappedComponentProps {
7
97
  recieverRequirements: NewReceiverRequirements;
8
98
  form: FormInstance;
@@ -3,19 +3,17 @@ 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.translationMessages = void 0;
6
7
  var react_intl_1 = require("react-intl");
7
8
  var react_1 = __importDefault(require("react"));
8
9
  var antd_1 = require("antd");
9
10
  var BillingLineUtility_1 = require("../../../utils/BillingLineUtility");
10
- var enums_1 = require("../../../enums");
11
11
  var icons_1 = require("@ant-design/icons");
12
- var colors_1 = require("@ant-design/colors");
13
- var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
14
- var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
15
- var mapi_1 = require("@unimaze/api-clients/lib/mapi");
16
- var payment_method_1 = require("../payment-method");
17
- var IntlUtility_1 = require("../../../utils/IntlUtility");
18
- var translationMessages = (0, react_intl_1.defineMessages)({
12
+ var InvoicePreviewTotalAmountPreview_1 = __importDefault(require("./InvoicePreviewTotalAmountPreview"));
13
+ var InvoicePreviewInvoiceLines_1 = __importDefault(require("./InvoicePreviewInvoiceLines"));
14
+ var InvoicePreviewCustomerSupplierInfoBox_1 = __importDefault(require("./InvoicePreviewCustomerSupplierInfoBox"));
15
+ var InvoicePreviewPaymentInfoBox_1 = __importDefault(require("./InvoicePreviewPaymentInfoBox"));
16
+ exports.translationMessages = (0, react_intl_1.defineMessages)({
19
17
  customer_title: {
20
18
  id: "customer_title",
21
19
  defaultMessage: "Customer",
@@ -62,11 +60,11 @@ var translationMessages = (0, react_intl_1.defineMessages)({
62
60
  },
63
61
  billingCalculations_labels_TaxAmountWithoutVat: {
64
62
  id: "billingCalculations_labels_TaxAmountWithoutVat",
65
- defaultMessage: "Total amount without VAT",
63
+ defaultMessage: "Total amount before VAT",
66
64
  },
67
65
  billingCalculations_labels_AmountPayable: {
68
66
  id: "billingCalculations_labels_AmountPayable",
69
- defaultMessage: "Amount payable",
67
+ defaultMessage: "Total invoiced amount",
70
68
  },
71
69
  billingCalculations_labels_TotalAmountWithVat: {
72
70
  id: "billingCalculations_labels_TotalAmountWithVat",
@@ -78,7 +76,7 @@ var translationMessages = (0, react_intl_1.defineMessages)({
78
76
  },
79
77
  billingLines_discount: {
80
78
  id: "billingLines_discount",
81
- defaultMessage: "Discount",
79
+ defaultMessage: "discount",
82
80
  },
83
81
  billingLines_total: {
84
82
  id: "billingLines_total",
@@ -96,42 +94,17 @@ var translationMessages = (0, react_intl_1.defineMessages)({
96
94
  id: "invoicePreview_paymentInfoTitle",
97
95
  defaultMessage: "Payment information",
98
96
  },
97
+ billingLines_total_discount: {
98
+ id: "billingLines_total_discount",
99
+ defaultMessage: "Total discount",
100
+ },
101
+ invoicePreview_lineDiscount: {
102
+ id: "invoicePreview_lineDiscount",
103
+ defaultMessage: "line discount",
104
+ },
99
105
  });
100
106
  var InvoicePreview = function (props) {
101
- var _a, _b, _c, _d, _e, _f;
102
- var defaultPaymentMethods = [
103
- {
104
- key: mapi_1.PaymentMeansType.NotSpecified,
105
- name: props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_methods_undefined),
106
- },
107
- {
108
- key: mapi_1.PaymentMeansType.MutuallyAgreed,
109
- name: props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_methods_mutuallyAgreed),
110
- },
111
- {
112
- key: mapi_1.PaymentMeansType.DomesticTransfer,
113
- name: props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_methods_domesticTransfer),
114
- },
115
- {
116
- key: mapi_1.PaymentMeansType.DomesticClaim,
117
- name: props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_methods_domesticClaim),
118
- },
119
- ];
120
107
  var token = antd_1.theme.useToken().token;
121
- var getPaymentMeansValue = function (paymentMeansType) {
122
- var paymentMeansTypes = (0, RequirementsUtility_1.getFieldRequirements)(props.recieverRequirements, ReceiverRequirements_1.AvailableFields["paymentMeans.type"]);
123
- if (paymentMeansTypes &&
124
- paymentMeansTypes.hasOwnProperty("properties") &&
125
- paymentMeansTypes.properties.hasOwnProperty("values") &&
126
- paymentMeansTypes.properties.values) {
127
- var paymentMeansValue = paymentMeansTypes.properties.values.find(function (value) { return value.key === paymentMeansType; });
128
- return paymentMeansValue === null || paymentMeansValue === void 0 ? void 0 : paymentMeansValue.name;
129
- }
130
- else {
131
- var paymentMeansValue = defaultPaymentMethods.find(function (value) { return value.key === paymentMeansType; });
132
- return paymentMeansValue === null || paymentMeansValue === void 0 ? void 0 : paymentMeansValue.name;
133
- }
134
- };
135
108
  var formValueFile1 = props.form.getFieldValue(["attachments", "file1", "file"]);
136
109
  var formValueFile2 = props.form.getFieldValue(["attachments", "file2", "file"]);
137
110
  var formValueFile3 = props.form.getFieldValue(["attachments", "file3", "file"]);
@@ -140,182 +113,23 @@ var InvoicePreview = function (props) {
140
113
  react_1.default.createElement(antd_1.Flex, { vertical: true, style: { width: "100%", maxWidth: "900px" } },
141
114
  react_1.default.createElement(antd_1.Row, { gutter: [20, 20] },
142
115
  react_1.default.createElement(antd_1.Col, { span: 24 },
143
- react_1.default.createElement(antd_1.Card, { bordered: false, style: { backgroundColor: "#F5F5F5" }, title: react_1.default.createElement(antd_1.Row, { gutter: 20 },
144
- react_1.default.createElement(antd_1.Col, { span: 12 },
145
- react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "flex-end", style: { fontWeight: 400 } },
146
- react_1.default.createElement(antd_1.Typography.Text, null, props.intl.formatMessage(translationMessages.baseInformation_issueDate)),
147
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary", style: { fontSize: token.fontSizeSM } }, (_a = props.form
148
- .getFieldValue(["invoice", "issueDate"])) === null || _a === void 0 ? void 0 : _a.format("DD.MM.YYYY")))),
149
- react_1.default.createElement(antd_1.Col, { span: 12, style: { borderLeft: "1px solid ".concat(colors_1.grey[0]) } },
150
- react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "flex-end", style: { fontWeight: 400 } },
151
- react_1.default.createElement(antd_1.Typography.Text, null, props.intl.formatMessage(translationMessages.baseInformation_dueDate)),
152
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary", style: { fontSize: token.fontSizeSM } }, (_b = props.form.getFieldValue(["invoice", "dueDate"])) === null || _b === void 0 ? void 0 : _b.format("DD.MM.YYYY"))))) },
153
- react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "small" },
154
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4, fontWeight: 500 } },
155
- props.intl.formatMessage(translationMessages.customer_title),
156
- ":"),
157
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.chosenCustomer.name),
158
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
159
- props.intl.formatMessage(translationMessages.customer_identifier),
160
- ":",
161
- " ",
162
- props.chosenCustomer.identifier),
163
- ((_c = props.chosenCustomer.address) === null || _c === void 0 ? void 0 : _c.streetNameAndNumber) &&
164
- ((_d = props.chosenCustomer.address) === null || _d === void 0 ? void 0 : _d.postalZone) &&
165
- ((_e = props.chosenCustomer.address) === null || _e === void 0 ? void 0 : _e.city) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
166
- props.intl.formatMessage(translationMessages.customer_address_streetNameAndNumber),
167
- ": ",
168
- props.chosenCustomer.address.streetNameAndNumber,
169
- ",",
170
- " ",
171
- props.chosenCustomer.address.postalZone,
172
- " ",
173
- props.chosenCustomer.address.city)),
174
- props.form.getFieldValue(["invoice", "customer", "locationIdentifier"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
175
- props.intl.formatMessage(translationMessages.baseInformation_costCenter),
176
- ":",
177
- " ",
178
- props.form.getFieldValue(["invoice", "customer", "locationIdentifier"]))),
179
- react_1.default.createElement(antd_1.Col, { span: 8, style: { padding: 0 } },
180
- react_1.default.createElement("hr", null)),
181
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4, fontWeight: 500 } },
182
- props.intl.formatMessage(translationMessages.supplier_title),
183
- ":"),
184
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.form.getFieldValue(["invoice", "supplier", "name"])),
185
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
186
- props.intl.formatMessage(translationMessages.supplier_identifier),
187
- ":",
188
- " ",
189
- props.form.getFieldValue(["invoice", "supplier", "identifier"])),
190
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
191
- props.intl.formatMessage(translationMessages.supplier_address_streetNameAndNumber),
192
- ":",
193
- " ",
194
- props.form.getFieldValue([
195
- "invoice",
196
- "supplier",
197
- "address",
198
- "streetNameAndNumber",
199
- ]),
200
- ", ",
201
- props.form.getFieldValue(["invoice", "supplier", "address", "postalZone"]),
202
- " ",
203
- props.form.getFieldValue(["invoice", "supplier", "address", "city"])),
204
- props.form.getFieldValue(["invoice", "supplier", "contact", "telephone"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
205
- props.intl.formatMessage(translationMessages.supplier_contact_phoneNumber),
206
- ":",
207
- props.form.getFieldValue(["invoice", "supplier", "contact", "telephone"]))),
208
- props.form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, props.form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"])))))),
116
+ react_1.default.createElement(InvoicePreviewCustomerSupplierInfoBox_1.default, { form: props.form, chosenCustomer: props.chosenCustomer })),
209
117
  react_1.default.createElement(antd_1.Col, { span: 24 },
210
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: { padding: "0 24px" }, gap: "middle" },
211
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4 } },
212
- props.intl.formatMessage(translationMessages.invoicePreview_billingLinesTitle),
213
- ":"),
214
- ((_f = props.form.getFieldValue(["invoice", "invoiceLines"])) === null || _f === void 0 ? void 0 : _f.length) > 0 &&
215
- props.form
216
- .getFieldValue(["invoice", "invoiceLines"])
217
- .map(function (line, index) {
218
- var _a, _b;
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;
223
- return (react_1.default.createElement(antd_1.Flex, { key: index, vertical: true, gap: "small" },
224
- react_1.default.createElement(antd_1.Flex, { vertical: true },
225
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, line.name),
226
- react_1.default.createElement(antd_1.Flex, { style: {
227
- backgroundColor: "#F5F5F5",
228
- margin: "0 -24px",
229
- padding: "0 24px",
230
- justifyContent: "space-between",
231
- } },
232
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
233
- line.quantity,
234
- " ", (_a = line.unitOfMeasure) === null || _a === void 0 ? void 0 :
235
- _a.unit,
236
- " -",
237
- " ",
238
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(line.unitPriceAmount, props.intl),
239
- " ",
240
- line.currencyCode,
241
- " / ", (_b = line.unitOfMeasure) === null || _b === void 0 ? void 0 :
242
- _b.unit),
243
- react_1.default.createElement(antd_1.Typography.Text, null,
244
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(line.quantity * line.unitPriceAmount, props.intl),
245
- " ",
246
- line.currencyCode))),
247
- react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center" },
248
- react_1.default.createElement(antd_1.Typography.Text, null,
249
- taxPercentage,
250
- "% VAT"),
251
- react_1.default.createElement(antd_1.Typography.Text, null,
252
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((0, BillingLineUtility_1.calculateTaxAmount)(line.taxableAmount, taxPercentage), props.intl),
253
- " ",
254
- line.currencyCode)),
255
- line.discountValue && (react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center" },
256
- react_1.default.createElement(antd_1.Typography.Text, null, "".concat(line.discountValue).concat(line.discountType === "PERCENTAGE" ? "%" : " ".concat(line.currencyCode)),
257
- " ",
258
- props.intl.formatMessage(translationMessages.billingLines_discount)),
259
- react_1.default.createElement(antd_1.Typography.Text, null,
260
- "-",
261
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(calculatedDiscountValue, props.intl),
262
- " ",
263
- line.currencyCode))),
264
- react_1.default.createElement(antd_1.Flex, { vertical: true },
265
- react_1.default.createElement(antd_1.Col, { span: 24, style: { padding: 0 } },
266
- react_1.default.createElement("hr", null)),
267
- react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center" },
268
- react_1.default.createElement(antd_1.Typography.Text, null, props.intl.formatMessage(translationMessages.billingLines_total)),
269
- react_1.default.createElement(antd_1.Typography.Text, null,
270
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)((line.quantity * line.unitPriceAmount) + (0, BillingLineUtility_1.calculateTaxAmount)(line.taxableAmount, taxPercentage) - calculatedDiscountValue, props.intl),
271
- " ",
272
- line.currencyCode)))));
273
- }))),
118
+ react_1.default.createElement(InvoicePreviewInvoiceLines_1.default, { form: props.form })),
274
119
  react_1.default.createElement(antd_1.Col, { span: 24 },
275
- react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "small" },
276
- react_1.default.createElement(antd_1.Card, { bordered: false, style: { backgroundColor: "#F5F5F5" }, size: "small" },
277
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: { padding: "0 12px" } },
278
- react_1.default.createElement(antd_1.Flex, { justify: "space-between" },
279
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, props.intl.formatMessage(translationMessages.billingCalculations_labels_TaxAmountWithoutVat)),
280
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
281
- props.form.getFieldValue(["invoice", "currencyCode"]),
282
- " ",
283
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
284
- .totalTaxableAmount, props.intl)))),
285
- react_1.default.createElement(antd_1.Flex, { justify: "space-between" },
286
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalAmountWithVat)),
287
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
288
- props.form.getFieldValue(["invoice", "currencyCode"]),
289
- " ",
290
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
291
- .totalTaxInclusiveAmount, props.intl)))),
292
- react_1.default.createElement(antd_1.Flex, { justify: "space-between" },
293
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalRoundingAmount)),
294
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeSM } },
295
- props.form.getFieldValue(["invoice", "currencyCode"]),
296
- " ",
297
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(_totals
298
- .roundingAmount, props.intl)))))),
299
- react_1.default.createElement(antd_1.Flex, { justify: "space-between", align: "center", style: { padding: "0 24px" } },
300
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: "16px" } },
301
- props.intl.formatMessage(translationMessages.billingCalculations_labels_AmountPayable),
302
- ":"),
303
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4 } },
304
- props.form.getFieldValue(["invoice", "currencyCode"]),
305
- " ",
306
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeXL } }, (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(Math.round(_totals.totalTaxInclusiveAmount), props.intl)))))),
120
+ react_1.default.createElement(InvoicePreviewTotalAmountPreview_1.default, { form: props.form, totals: _totals })),
307
121
  props.form.getFieldValue(["invoice", "notes"]) && (react_1.default.createElement(antd_1.Col, { span: 24 },
308
122
  react_1.default.createElement(antd_1.Card, { bordered: false, size: "small", style: { backgroundColor: "#F5F5F5" } },
309
123
  react_1.default.createElement(antd_1.Flex, { vertical: true, style: { padding: "0 12px" } },
310
124
  react_1.default.createElement(antd_1.Typography.Text, { disabled: true },
311
- props.intl.formatMessage(translationMessages.baseInformation_notes),
125
+ props.intl.formatMessage(exports.translationMessages.baseInformation_notes),
312
126
  ":"),
313
127
  react_1.default.createElement(antd_1.Typography.Text, null, props.form.getFieldValue(["invoice", "notes"])))))),
314
128
  (formValueFile1 ||
315
129
  formValueFile2 ||
316
130
  formValueFile3) && (react_1.default.createElement(antd_1.Col, { span: 24 },
317
131
  react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "small" },
318
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4 } }, props.intl.formatMessage(translationMessages.invoicePreview_attachmentsTitle)),
132
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4 } }, props.intl.formatMessage(exports.translationMessages.invoicePreview_attachmentsTitle)),
319
133
  formValueFile1 && (react_1.default.createElement(antd_1.Flex, { gap: "middle", align: "flex-start" },
320
134
  react_1.default.createElement(icons_1.PaperClipOutlined, { style: { fontSize: "18px" } }),
321
135
  react_1.default.createElement(antd_1.Flex, { vertical: true },
@@ -344,69 +158,6 @@ var InvoicePreview = function (props) {
344
158
  "description",
345
159
  ])))))))),
346
160
  react_1.default.createElement(antd_1.Col, { span: 24 },
347
- react_1.default.createElement(antd_1.Card, { bordered: false, style: { backgroundColor: "#F5F5F5" }, size: "small" },
348
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: { padding: "0 12px" }, gap: "small" },
349
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontWeight: 700 } }, props.intl.formatMessage(translationMessages.invoicePreview_paymentInfoTitle)),
350
- react_1.default.createElement(antd_1.Flex, { vertical: true },
351
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
352
- props.form.getFieldValue(["invoice", "supplier", "name"]),
353
- " Kt:",
354
- " ",
355
- props.form.getFieldValue(["invoice", "supplier", "identifier"])),
356
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, getPaymentMeansValue(props.form.getFieldValue(["invoice", "paymentMeans", "type"]))),
357
- props.form.getFieldValue(["invoice", "paymentMeans", "domesticTransfer"]) && (react_1.default.createElement(react_1.default.Fragment, null,
358
- react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
359
- props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountNo),
360
- ":",
361
- " ",
362
- props.form.getFieldValue([
363
- "invoice",
364
- "paymentMeans",
365
- "domesticTransfer",
366
- "bankNumber",
367
- ]),
368
- "-",
369
- props.form.getFieldValue([
370
- "invoice",
371
- "paymentMeans",
372
- "domesticTransfer",
373
- "accountTypeNumber",
374
- ]),
375
- "-",
376
- props.form.getFieldValue([
377
- "invoice",
378
- "paymentMeans",
379
- "domesticTransfer",
380
- "accountNumber",
381
- ])),
382
- props.form.getFieldValue([
383
- "invoice",
384
- "paymentMeans",
385
- "domesticTransfer",
386
- "paymentIdentifier",
387
- ]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
388
- props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_paymentReference),
389
- ":",
390
- " ",
391
- props.form.getFieldValue([
392
- "invoice",
393
- "paymentMeans",
394
- "domesticTransfer",
395
- "paymentIdentifier",
396
- ]))))),
397
- props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
398
- props.form.getFieldValue([
399
- "invoice",
400
- "paymentMeans",
401
- "domesticClaim",
402
- "bankNumber",
403
- ]),
404
- "-66-",
405
- props.form.getFieldValue([
406
- "invoice",
407
- "paymentMeans",
408
- "domesticClaim",
409
- "accountNumber",
410
- ])))))))))));
161
+ react_1.default.createElement(InvoicePreviewPaymentInfoBox_1.default, { form: props.form, receiverRequirements: props.recieverRequirements }))))));
411
162
  };
412
163
  exports.default = (0, react_intl_1.injectIntl)(InvoicePreview);
@@ -32,9 +32,9 @@
32
32
  "baseInformation_projectReference": "Project reference is required",
33
33
  "baseInformation_projectReferenceLabel": "Project reference",
34
34
  "baseInformation_title": "Base Information",
35
- "billingCalculations_labels_AmountPayable": "Amount payable",
35
+ "billingCalculations_labels_AmountPayable": "Total invoiced amount",
36
36
  "billingCalculations_labels_RoundingAmount": "Rounding amount",
37
- "billingCalculations_labels_TaxAmountWithoutVat": "Total amount without VAT",
37
+ "billingCalculations_labels_TaxAmountWithoutVat": "Total amount before VAT",
38
38
  "billingCalculations_labels_TotalAmountWithVat": "Total amount with VAT",
39
39
  "billingCalculations_labels_TotalRoundingAmount": "Rounding amount",
40
40
  "billingCalculations_labels_TotalVatAmount": "Total VAT amount",
@@ -56,14 +56,17 @@
56
56
  "billingLines_currency_USD_short": "USD",
57
57
  "billingLines_discount": "Discount",
58
58
  "billingLines_discount_helpText": "Discount can be represented as an amount or a percentage indicated with a percentage sign (%)",
59
+ "billingLines_each": "each",
59
60
  "billingLines_input_must_be_number_validationMessage": "Input must be a number",
60
61
  "billingLines_itemNo": "Item no",
61
62
  "billingLines_labels_addButton": "Save line",
62
63
  "billingLines_lineAmount": "Amount",
64
+ "billingLines_lineDiscount": "line discount",
63
65
  "billingLines_name": "Name",
64
66
  "billingLines_placeholders_itemNo": "Item No",
65
67
  "billingLines_placeholders_newItem": "New Item",
66
68
  "billingLines_quantity": "Quantity",
69
+ "billingLines_tax": "tax",
67
70
  "billingLines_taxAmount": "Tax inclusive amount",
68
71
  "billingLines_taxCategoryPercentage": "Tax percentage",
69
72
  "billingLines_taxCategoryType": "Tax category",
@@ -71,6 +74,7 @@
71
74
  "billingLines_title": "Document lines",
72
75
  "billingLines_tooltip_title": "Item number, Name, Quantity, Unit of measure, Unit price amount Tax category and Discount need to be defined here. VAT is automatically applied. Click \"Add a row\" to add a new line",
73
76
  "billingLines_total": "Total",
77
+ "billingLines_total_discount": "Total discount",
74
78
  "billingLines_unitOfMeasure": "Unit of measure",
75
79
  "billingLines_unitPriceAmount": "Unit price",
76
80
  "billingTaxSummary_taxAmount": "Tax",
@@ -117,6 +121,7 @@
117
121
  "invoicePreview.headerTitle": "Invoice",
118
122
  "invoicePreview_attachmentsTitle": "Attachments",
119
123
  "invoicePreview_billingLinesTitle": "Invoice lines",
124
+ "invoicePreview_lineDiscount": "line discount",
120
125
  "invoicePreview_paymentInfoTitle": "Payment information",
121
126
  "missingRequiredData": "Missing required data:",
122
127
  "paymentMethod_label": "Account number",
@@ -56,14 +56,17 @@
56
56
  "billingLines_currency_USD_short": "USD",
57
57
  "billingLines_discount": "Afsláttur",
58
58
  "billingLines_discount_helpText": "Afslátt má setja fram sem upphæð eða sem hlutfall með því að bæta við prósentutákni (%)",
59
+ "billingLines_each": "stk",
59
60
  "billingLines_input_must_be_number_validationMessage": "Inntak verður að vera tala",
60
61
  "billingLines_itemNo": "Vörunr.",
61
62
  "billingLines_labels_addButton": "Bæta við línu",
62
63
  "billingLines_lineAmount": "Upphæð",
64
+ "billingLines_lineDiscount": "afsláttur á línu",
63
65
  "billingLines_name": "Nafn",
64
66
  "billingLines_placeholders_itemNo": "Vörunúmer",
65
67
  "billingLines_placeholders_newItem": "Ný vara",
66
68
  "billingLines_quantity": "Fjöldi",
69
+ "billingLines_tax": "VSK",
67
70
  "billingLines_taxAmount": "Upphæð með skatti",
68
71
  "billingLines_taxCategoryPercentage": "Skattprósenta",
69
72
  "billingLines_taxCategoryType": "Skattflokkur",
@@ -71,6 +74,7 @@
71
74
  "billingLines_title": "Reikningslínur",
72
75
  "billingLines_tooltip_title": "Hér þarf að skilgreina Vörunr, Nafn, Fjölda, Mælieiningu, Verð pr. einingu og upphæð. Virðisauki reiknast sjálfkrafa. Smelltu á \"Bæta við röð\" til þess að bæta við vörulínu",
73
76
  "billingLines_total": "Total",
77
+ "billingLines_total_discount": "Afsláttur alls",
74
78
  "billingLines_unitOfMeasure": "Mælieining",
75
79
  "billingLines_unitPriceAmount": "Verð pr. einingu",
76
80
  "billingTaxSummary_taxAmount": "Skattur",
@@ -117,6 +121,7 @@
117
121
  "invoicePreview.headerTitle": "Invoice",
118
122
  "invoicePreview_attachmentsTitle": "Attachments",
119
123
  "invoicePreview_billingLinesTitle": "Invoice lines",
124
+ "invoicePreview_lineDiscount": "line discount",
120
125
  "invoicePreview_paymentInfoTitle": "Payment information",
121
126
  "missingRequiredData": "Vantar skilyrt gögn:",
122
127
  "paymentMethod_label": "Reikningsnúmer",
@@ -57,14 +57,17 @@ declare const _default: {
57
57
  billingLines_currency_USD_short: string;
58
58
  billingLines_discount: string;
59
59
  billingLines_discount_helpText: string;
60
+ billingLines_each: string;
60
61
  billingLines_input_must_be_number_validationMessage: string;
61
62
  billingLines_itemNo: string;
62
63
  billingLines_labels_addButton: string;
63
64
  billingLines_lineAmount: string;
65
+ billingLines_lineDiscount: string;
64
66
  billingLines_name: string;
65
67
  billingLines_placeholders_itemNo: string;
66
68
  billingLines_placeholders_newItem: string;
67
69
  billingLines_quantity: string;
70
+ billingLines_tax: string;
68
71
  billingLines_taxAmount: string;
69
72
  billingLines_taxCategoryPercentage: string;
70
73
  billingLines_taxCategoryType: string;
@@ -72,6 +75,7 @@ declare const _default: {
72
75
  billingLines_title: string;
73
76
  billingLines_tooltip_title: string;
74
77
  billingLines_total: string;
78
+ billingLines_total_discount: string;
75
79
  billingLines_unitOfMeasure: string;
76
80
  billingLines_unitPriceAmount: string;
77
81
  billingTaxSummary_taxAmount: string;
@@ -118,6 +122,7 @@ declare const _default: {
118
122
  "invoicePreview.headerTitle": string;
119
123
  invoicePreview_attachmentsTitle: string;
120
124
  invoicePreview_billingLinesTitle: string;
125
+ invoicePreview_lineDiscount: string;
121
126
  invoicePreview_paymentInfoTitle: string;
122
127
  missingRequiredData: string;
123
128
  paymentMethod_label: string;
@@ -239,14 +244,17 @@ declare const _default: {
239
244
  billingLines_currency_USD_short: string;
240
245
  billingLines_discount: string;
241
246
  billingLines_discount_helpText: string;
247
+ billingLines_each: string;
242
248
  billingLines_input_must_be_number_validationMessage: string;
243
249
  billingLines_itemNo: string;
244
250
  billingLines_labels_addButton: string;
245
251
  billingLines_lineAmount: string;
252
+ billingLines_lineDiscount: string;
246
253
  billingLines_name: string;
247
254
  billingLines_placeholders_itemNo: string;
248
255
  billingLines_placeholders_newItem: string;
249
256
  billingLines_quantity: string;
257
+ billingLines_tax: string;
250
258
  billingLines_taxAmount: string;
251
259
  billingLines_taxCategoryPercentage: string;
252
260
  billingLines_taxCategoryType: string;
@@ -254,6 +262,7 @@ declare const _default: {
254
262
  billingLines_title: string;
255
263
  billingLines_tooltip_title: string;
256
264
  billingLines_total: string;
265
+ billingLines_total_discount: string;
257
266
  billingLines_unitOfMeasure: string;
258
267
  billingLines_unitPriceAmount: string;
259
268
  billingTaxSummary_taxAmount: string;
@@ -300,6 +309,7 @@ declare const _default: {
300
309
  "invoicePreview.headerTitle": string;
301
310
  invoicePreview_attachmentsTitle: string;
302
311
  invoicePreview_billingLinesTitle: string;
312
+ invoicePreview_lineDiscount: string;
303
313
  invoicePreview_paymentInfoTitle: string;
304
314
  missingRequiredData: string;
305
315
  paymentMethod_label: string;
@@ -1,6 +1,5 @@
1
- import { BillingLineMetadata } from "@unimaze/api-clients/lib/mapi";
1
+ import { BillingLineMetadata, TaxCategoryTypeEnum } from "@unimaze/api-clients/lib/mapi";
2
2
  import { FormInstance } from "antd/es/form";
3
- import { TaxCategoryTypeEnum } from "@unimaze/api-clients/lib/mapi/api";
4
3
  import { BillingLineMetadataOverride } from "../common/types/BillingLineMetadataOverride";
5
4
  import React from "react";
6
5
  import { IntlShape } from "react-intl";
@@ -23,3 +22,11 @@ export declare const getCorrectInputNode: (dataIdx: keyof BillingLineMetadataOve
23
22
  export declare const getTotals: (invoiceLines: BillingLineMetadataOverride[]) => Totals;
24
23
  export declare const getTaxCategoryDisabled: (taxCategoryType: AvailableTaxCategoryTypeEnum, outsideVatScope: boolean) => boolean;
25
24
  export declare const getFieldNames: (keys: string[], intl: IntlShape) => string[];
25
+ interface TaxDisplay {
26
+ taxCategoryType: TaxCategoryTypeEnum;
27
+ taxAmount: number;
28
+ }
29
+ export declare const combinedTaxesForLines: (invoiceLines: BillingLineMetadataOverride[]) => TaxDisplay[];
30
+ export declare const getUnitOfMeasureUnitLabel: (unitOfMeasure: any) => string;
31
+ export declare const getDiscountLabel: (discountValue: string, discountType: string, currencyCode: string, discountText: string) => string;
32
+ export {};
@@ -25,7 +25,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
25
25
  return (mod && mod.__esModule) ? mod : { "default": mod };
26
26
  };
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.getFieldNames = exports.getTaxCategoryDisabled = exports.getTotals = exports.getCorrectInputNode = exports.generateTaxCategoryLabel = exports.calculateTaxPercentage = exports.calculateTaxAmount = exports.calculateTaxableAmount = exports.calculateDiscountAmount = exports.billingLinesFieldsMetadata = void 0;
28
+ exports.getDiscountLabel = exports.getUnitOfMeasureUnitLabel = exports.combinedTaxesForLines = exports.getFieldNames = exports.getTaxCategoryDisabled = exports.getTotals = exports.getCorrectInputNode = exports.generateTaxCategoryLabel = exports.calculateTaxPercentage = exports.calculateTaxAmount = exports.calculateTaxableAmount = exports.calculateDiscountAmount = exports.billingLinesFieldsMetadata = void 0;
29
+ var mapi_1 = require("@unimaze/api-clients/lib/mapi");
29
30
  var api_1 = require("@unimaze/api-clients/lib/mapi/api");
30
31
  var react_1 = __importDefault(require("react"));
31
32
  var antd_1 = require("antd");
@@ -95,13 +96,13 @@ exports.calculateTaxAmount = calculateTaxAmount;
95
96
  var calculateTaxPercentage = function (taxCategoryType) {
96
97
  // inferred from the taxCategoryType? what is the mapping? ZeroRated/Exempt = 0, StandardRated = 24, ReducedRate = 11
97
98
  switch (taxCategoryType) {
98
- case api_1.TaxCategoryTypeEnum.StandardRated:
99
+ case mapi_1.TaxCategoryTypeEnum.StandardRated:
99
100
  return 24;
100
- case api_1.TaxCategoryTypeEnum.ReducedRated:
101
+ case mapi_1.TaxCategoryTypeEnum.ReducedRated:
101
102
  return 11;
102
- case api_1.TaxCategoryTypeEnum.ZeroRated:
103
- case api_1.TaxCategoryTypeEnum.Exempt:
104
- case api_1.TaxCategoryTypeEnum.OutsideTaxScope:
103
+ case mapi_1.TaxCategoryTypeEnum.ZeroRated:
104
+ case mapi_1.TaxCategoryTypeEnum.Exempt:
105
+ case mapi_1.TaxCategoryTypeEnum.OutsideTaxScope:
105
106
  return 0;
106
107
  default:
107
108
  return 0;
@@ -124,7 +125,7 @@ var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonA
124
125
  return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, intl.formatMessage(CommonTranslations_1.commonTranslationMessages["unitOfMeasure_labels_".concat(unitOfMeasure)])));
125
126
  })));
126
127
  case "taxCategoryType":
127
- return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder }, Object.keys(api_1.TaxCategoryTypeEnum).map(function (taxCategoryType) {
128
+ return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder }, Object.keys(mapi_1.TaxCategoryTypeEnum).map(function (taxCategoryType) {
128
129
  return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
129
130
  })));
130
131
  default:
@@ -142,7 +143,7 @@ var getTotals = function (invoiceLines) {
142
143
  };
143
144
  invoiceLines.map(function (billingLine) {
144
145
  if (billingLine) {
145
- var taxAmount = (0, exports.calculateTaxAmount)((0, exports.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType), (0, exports.calculateTaxPercentage)(billingLine.taxCategoryType ? api_1.TaxCategoryTypeEnum[billingLine.taxCategoryType] : undefined));
146
+ var taxAmount = (0, exports.calculateTaxAmount)((0, exports.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType), (0, exports.calculateTaxPercentage)(billingLine.taxCategoryType ? mapi_1.TaxCategoryTypeEnum[billingLine.taxCategoryType] : undefined));
146
147
  var taxableAmount = (0, exports.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType);
147
148
  var taxInclusiveAmount = taxableAmount + taxAmount;
148
149
  var discountAmount = (0, exports.calculateDiscountAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
@@ -189,3 +190,33 @@ var getFieldNames = function (keys, intl) {
189
190
  });
190
191
  };
191
192
  exports.getFieldNames = getFieldNames;
193
+ var combinedTaxesForLines = function (invoiceLines) {
194
+ var taxes = [];
195
+ invoiceLines === null || invoiceLines === void 0 ? void 0 : invoiceLines.forEach(function (invoiceLine) {
196
+ var taxType = mapi_1.TaxCategoryTypeEnum[invoiceLine.taxCategoryType];
197
+ var taxPercentage = (0, exports.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[taxType]);
198
+ if (taxPercentage !== 0) {
199
+ var taxIndex = taxes.findIndex(function (tax) { return tax.taxCategoryType === invoiceLine.taxCategoryType; });
200
+ var amountToAdd = (0, exports.calculateTaxAmount)(invoiceLine.taxableAmount, taxPercentage);
201
+ if (taxIndex !== -1) {
202
+ taxes[taxIndex].taxAmount += amountToAdd;
203
+ }
204
+ else {
205
+ taxes.push({
206
+ taxCategoryType: invoiceLine.taxCategoryType,
207
+ taxAmount: amountToAdd,
208
+ });
209
+ }
210
+ }
211
+ });
212
+ return taxes;
213
+ };
214
+ exports.combinedTaxesForLines = combinedTaxesForLines;
215
+ var getUnitOfMeasureUnitLabel = function (unitOfMeasure) {
216
+ return (unitOfMeasure === null || unitOfMeasure === void 0 ? void 0 : unitOfMeasure.unit) === "One" ? undefined : (unitOfMeasure === null || unitOfMeasure === void 0 ? void 0 : unitOfMeasure.unit) + ("(s)");
217
+ };
218
+ exports.getUnitOfMeasureUnitLabel = getUnitOfMeasureUnitLabel;
219
+ var getDiscountLabel = function (discountValue, discountType, currencyCode, discountText) {
220
+ return "".concat(discountValue).concat(discountType === "PERCENTAGE" ? "%" : " ".concat(currencyCode), " ").concat(discountText);
221
+ };
222
+ exports.getDiscountLabel = getDiscountLabel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.21.12",
3
+ "version": "0.21.14",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",