@unimaze/billing 0.21.36 → 0.21.37

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.
@@ -22,13 +22,16 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
29
  var react_1 = __importStar(require("react"));
27
30
  var antd_1 = require("antd");
28
31
  var BillingLineUtility_1 = require("../../../utils/BillingLineUtility");
29
32
  var api_1 = require("@unimaze/api-clients/lib/mapi/api");
30
33
  var react_intl_1 = require("react-intl");
31
- var IntlUtility_1 = require("../../../utils/IntlUtility");
34
+ var InvoicePreviewTotalAmountPreview_1 = __importDefault(require("../invoice-preview/InvoicePreviewTotalAmountPreview"));
32
35
  var translationMessages = (0, react_intl_1.defineMessages)({
33
36
  billingCalculations_labels_TaxAmountWithoutVat: {
34
37
  id: "billingCalculations_labels_TaxAmountWithoutVat",
@@ -95,58 +98,82 @@ var BillingCalculations = function (props) {
95
98
  }
96
99
  var roundedAmount = Math.round(totals.totalTaxInclusiveAmount);
97
100
  var roundingAmount = totals.totalTaxInclusiveAmount - roundedAmount;
98
- return (react_1.default.createElement(antd_1.Flex, { vertical: true },
99
- react_1.default.createElement(antd_1.Flex, { justify: "end", gap: 'large' },
100
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: { fontWeight: 300 } },
101
- react_1.default.createElement(antd_1.Typography.Text, null,
102
- props.intl.formatMessage(translationMessages.billingCalculations_labels_TaxAmountWithoutVat),
103
- ":"),
104
- react_1.default.createElement(antd_1.Typography.Text, null,
105
- props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalAmountWithVat),
106
- ":"),
107
- totals.discountAmount > 0 && (react_1.default.createElement(antd_1.Typography.Text, null,
108
- props.intl.formatMessage(translationMessages.billingLines_discount),
109
- ":")),
110
- roundingAmount !== 0 && (react_1.default.createElement(antd_1.Typography.Text, null,
111
- props.intl.formatMessage(translationMessages.billingCalculations_labels_RoundingAmount),
112
- ":"))),
113
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: { alignItems: 'end' } },
114
- react_1.default.createElement(antd_1.Typography.Text, { strong: true },
115
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(totals.totalTaxableAmount, props.intl, {
116
- style: "decimal",
117
- }),
118
- " ",
119
- props.formInstance.getFieldValue(["invoice", "currencyCode"])),
120
- react_1.default.createElement(antd_1.Typography.Text, { strong: true },
121
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(totals.totalTaxInclusiveAmount, props.intl, {
122
- style: "decimal",
123
- }),
124
- " ",
125
- props.formInstance.getFieldValue(["invoice", "currencyCode"])),
126
- totals.discountAmount > 0 && (react_1.default.createElement(antd_1.Typography.Text, { strong: true },
127
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(totals.discountAmount, props.intl, {
128
- style: "decimal",
129
- }),
130
- " ",
131
- props.formInstance.getFieldValue(["invoice", "currencyCode"]))),
132
- roundingAmount !== 0 && (react_1.default.createElement(antd_1.Typography.Text, { strong: true },
133
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(roundingAmount, props.intl, {
134
- style: "decimal",
135
- }),
136
- " ",
137
- props.formInstance.getFieldValue(["invoice", "currencyCode"]))))),
138
- react_1.default.createElement(antd_1.Row, null,
139
- react_1.default.createElement(antd_1.Col, { span: 24 },
140
- react_1.default.createElement("hr", null))),
141
- react_1.default.createElement(antd_1.Flex, { justify: "end" },
142
- react_1.default.createElement(antd_1.Typography.Text, { strong: true, style: { fontSize: "18px" } },
143
- " ",
144
- "=",
145
- " ",
146
- (0, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome)(roundedAmount, props.intl, {
147
- style: "decimal",
148
- }),
149
- " ",
150
- props.formInstance.getFieldValue(["invoice", "currencyCode"])))));
101
+ var _totals = (0, BillingLineUtility_1.getTotals)(props.formInstance.getFieldValue(["invoice", "invoiceLines"]));
102
+ // TODO check if we still need commented out render
103
+ return (react_1.default.createElement(react_1.default.Fragment, null, (invoiceLines === null || invoiceLines === void 0 ? void 0 : invoiceLines.length) > 0 && react_1.default.createElement(antd_1.Col, { span: 24 },
104
+ react_1.default.createElement(InvoicePreviewTotalAmountPreview_1.default, { form: props.formInstance, totals: _totals })))
105
+ // <Flex vertical>
106
+ // <Flex justify="end" gap={'large'}>
107
+ // <Flex vertical style={{ fontWeight: 300 }}>
108
+ // <Typography.Text>
109
+ // {props.intl.formatMessage(translationMessages.billingCalculations_labels_TaxAmountWithoutVat)}:
110
+ // </Typography.Text>
111
+ //
112
+ // <Typography.Text >
113
+ // {props.intl.formatMessage(translationMessages.billingCalculations_labels_TotalAmountWithVat)}:
114
+ // </Typography.Text>
115
+ // {totals.discountAmount > 0 && (
116
+ // <Typography.Text >
117
+ // {props.intl.formatMessage(translationMessages.billingLines_discount)}:
118
+ // </Typography.Text>
119
+ // )}
120
+ // {roundingAmount !== 0 && (
121
+ // <Typography.Text >
122
+ // {props.intl.formatMessage(translationMessages.billingCalculations_labels_RoundingAmount)}:
123
+ // </Typography.Text>
124
+ // )}
125
+ // </Flex>
126
+ //
127
+ // <Flex vertical style={{alignItems:'end'}}>
128
+ // <Typography.Text strong>
129
+ // {icelandicNumberLocaleWorkaroundChrome(totals.totalTaxableAmount, props.intl, {
130
+ // style: "decimal",
131
+ // })} {props.formInstance.getFieldValue(["invoice", "currencyCode"])}
132
+ // </Typography.Text>
133
+ // <Typography.Text strong>
134
+ // {icelandicNumberLocaleWorkaroundChrome(totals.totalTaxInclusiveAmount, props.intl, {
135
+ // style: "decimal",
136
+ // })} {props.formInstance.getFieldValue(["invoice", "currencyCode"])}
137
+ // </Typography.Text>
138
+ // {totals.discountAmount > 0 && (
139
+ // <Typography.Text strong>
140
+ // {icelandicNumberLocaleWorkaroundChrome(totals.discountAmount, props.intl, {
141
+ // style: "decimal",
142
+ // })} {props.formInstance.getFieldValue(["invoice", "currencyCode"])}
143
+ // </Typography.Text>
144
+ // )}
145
+ // {roundingAmount !== 0 && (
146
+ // <Typography.Text strong>
147
+ // {icelandicNumberLocaleWorkaroundChrome(roundingAmount, props.intl, {
148
+ // style: "decimal",
149
+ // })} {props.formInstance.getFieldValue(["invoice", "currencyCode"])}
150
+ // </Typography.Text>
151
+ // )}
152
+ // </Flex>
153
+ // </Flex>
154
+ //
155
+ // <Row>
156
+ // <Col span={24}>
157
+ // <hr />
158
+ // </Col>
159
+ // </Row>
160
+ // <Flex justify="end">
161
+ // <Typography.Text strong style={{ fontSize: "18px" }}>
162
+ // {" "}
163
+ // ={" "}
164
+ // {icelandicNumberLocaleWorkaroundChrome(roundedAmount, props.intl, {
165
+ // style: "decimal",
166
+ // })} {props.formInstance.getFieldValue(["invoice", "currencyCode"])}
167
+ // </Typography.Text>
168
+ //
169
+ // {/*<Col span={24}>*/}
170
+ // {/* <InvoicePreviewInvoiceLines form={props.formInstance}/>*/}
171
+ // {/*</Col>*/}
172
+ // <Col span={24}>
173
+ // <InvoicePreviewTotalAmountPreview form={props.formInstance} totals={_totals}/>
174
+ // </Col>
175
+ // </Flex>
176
+ // </Flex>
177
+ );
151
178
  };
152
179
  exports.default = (0, react_intl_1.injectIntl)(BillingCalculations);
@@ -97,9 +97,9 @@ var BillingLines = function (props) {
97
97
  React.createElement(tooltip_1.default, { title: props.intl.formatMessage(exports.translationMessages.billingLines_tooltip_title) }))),
98
98
  React.createElement(NewBillingLines_1.default, { formInstance: props.formInstance, receiverRequirements: props.receiverRequirements, outsideVatScope: props.outsideVatScope, newLineSaved: newLineSaved, setNewLineSaved: setNewLineSaved })),
99
99
  React.createElement(antd_1.Flex, { gap: "middle", vertical: true },
100
- React.createElement(BillingCalculations_1.default, { currencyCode: currencyCode, formInstance: props.formInstance, outsideVatScope: props.outsideVatScope, newLineSaved: newLineSaved }),
101
- React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.notes, defaultLabel: props.intl.formatMessage(exports.translationMessages.baseInformation_notes), defaultIsRequired: false, fieldName: ["invoice", "notes"], style: { marginBottom: 0 } },
102
- React.createElement(antd_1.Input.TextArea, { placeholder: props.intl.formatMessage(exports.translationMessages.baseInformation_notes) }))))));
100
+ React.createElement(BillingCalculations_1.default, { currencyCode: currencyCode, formInstance: props.formInstance, outsideVatScope: props.outsideVatScope, newLineSaved: newLineSaved })),
101
+ React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.notes, defaultLabel: props.intl.formatMessage(exports.translationMessages.baseInformation_notes), defaultIsRequired: false, fieldName: ["invoice", "notes"], style: { marginBottom: 0 } },
102
+ React.createElement(antd_1.Input.TextArea, { placeholder: props.intl.formatMessage(exports.translationMessages.baseInformation_notes) })))));
103
103
  };
104
104
  var BillingLinesIntl = (0, react_intl_1.injectIntl)(BillingLines);
105
105
  exports.default = BillingLinesIntl;
@@ -193,19 +193,21 @@ exports.getFieldNames = getFieldNames;
193
193
  var combinedTaxesForLines = function (invoiceLines) {
194
194
  var taxes = [];
195
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
- });
196
+ if (invoiceLine === null || invoiceLine === void 0 ? void 0 : invoiceLine.taxableAmount) {
197
+ var taxType = mapi_1.TaxCategoryTypeEnum[invoiceLine.taxCategoryType];
198
+ var taxPercentage = (0, exports.calculateTaxPercentage)(enums_1.AvailableTaxCategoryTypeEnum[taxType]);
199
+ if (taxPercentage !== 0) {
200
+ var taxIndex = taxes.findIndex(function (tax) { return tax.taxCategoryType === invoiceLine.taxCategoryType; });
201
+ var amountToAdd = (0, exports.calculateTaxAmount)(invoiceLine.taxableAmount, taxPercentage);
202
+ if (taxIndex !== -1) {
203
+ taxes[taxIndex].taxAmount += amountToAdd;
204
+ }
205
+ else {
206
+ taxes.push({
207
+ taxCategoryType: invoiceLine.taxCategoryType,
208
+ taxAmount: amountToAdd,
209
+ });
210
+ }
209
211
  }
210
212
  }
211
213
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.21.36",
3
+ "version": "0.21.37",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",