@unimaze/billing 0.11.3 → 0.12.0

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.
Files changed (27) hide show
  1. package/lib/common/components/base-information/OrderReference.d.ts +12 -0
  2. package/lib/common/components/base-information/OrderReference.js +41 -0
  3. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +1 -10
  4. package/lib/common/components/base-information/ReferenceIdentifiers.js +78 -16
  5. package/lib/common/components/base-information/index.js +26 -36
  6. package/lib/common/components/billing-lines/BillingCalculations.js +11 -9
  7. package/lib/common/components/billing-lines/BillingTaxSummary.js +5 -4
  8. package/lib/common/components/billing-lines/NewBillingLines.js +91 -16
  9. package/lib/common/components/billing-lines/index.d.ts +6 -10
  10. package/lib/common/components/billing-lines/index.js +188 -195
  11. package/lib/common/components/form-item/index.d.ts +1 -1
  12. package/lib/common/components/form-item/index.js +1 -1
  13. package/lib/common/components/supplier/index.d.ts +1 -3
  14. package/lib/common/components/supplier/index.js +16 -5
  15. package/lib/common/types/BillingLineMetadataOverride.d.ts +3 -2
  16. package/lib/create-invoice/index.js +122 -69
  17. package/lib/style/index.css +4 -0
  18. package/lib/translations/locales/is.json +4 -2
  19. package/lib/translations/locales.d.ts +2 -0
  20. package/lib/utils/BillingLineUtility.d.ts +2 -2
  21. package/lib/utils/BillingLineUtility.js +5 -3
  22. package/lib/utils/ConversionUtility.d.ts +1 -1
  23. package/lib/utils/ConversionUtility.js +3 -2
  24. package/lib/utils/ReferenceIdentifierUtility.d.ts +2 -1
  25. package/lib/utils/ReferenceIdentifierUtility.js +1 -0
  26. package/lib/utils/RequirementsUtility.js +1 -1
  27. package/package.json +1 -1
@@ -12,17 +12,6 @@ var __extends = (this && this.__extends) || (function () {
12
12
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
13
  };
14
14
  })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
15
  var __importStar = (this && this.__importStar) || function (mod) {
27
16
  if (mod && mod.__esModule) return mod;
28
17
  var result = {};
@@ -40,13 +29,10 @@ var icons_1 = require("@ant-design/icons");
40
29
  // import '@ant-design/compatible/assets/index.css';
41
30
  var antd_1 = require("antd");
42
31
  var react_intl_1 = require("react-intl");
43
- var BillingLineUtility_1 = require("../../../utils/BillingLineUtility");
44
- var api_1 = require("@unimaze/api-clients/lib/mapi/api");
32
+ // import {defineMessages} from "react-intl.macro"
33
+ var NewBillingLines_1 = __importDefault(require("./NewBillingLines"));
45
34
  var BillingCalculations_1 = __importDefault(require("./BillingCalculations"));
46
35
  var BillingTaxSummary_1 = __importDefault(require("./BillingTaxSummary"));
47
- var formLayout_1 = require("../../consts/formLayout");
48
- var editable_cell_1 = require("../editable-cell");
49
- var IntlUtility_1 = require("../../../utils/IntlUtility");
50
36
  exports.translationMessages = react_intl_1.defineMessages({
51
37
  billingLines_title: {
52
38
  id: "billingLines_title",
@@ -57,50 +43,50 @@ exports.translationMessages = react_intl_1.defineMessages({
57
43
  defaultMessage: "Item number, Name, Quantity, Unit of measure, Unit price amount Tax category and Discount need to be defined here.\n" + "VAT is automatically applied.\n" +
58
44
  "Click \"Add a row\" to add a new line",
59
45
  },
60
- billingLines_itemNo: {
61
- id: "billingLines_itemNo",
62
- defaultMessage: "Item no",
63
- },
64
- billingLines_name: {
65
- id: "billingLines_name",
66
- defaultMessage: "Name"
67
- },
68
- billingLines_quantity: {
69
- id: "billingLines_quantity",
70
- defaultMessage: "Quantity"
71
- },
72
- billingLines_unitOfMeasure: {
73
- id: "billingLines_unitOfMeasure",
74
- defaultMessage: "Unit of measure"
75
- },
76
- billingLines_unitPriceAmount: {
77
- id: "billingLines_unitPriceAmount",
78
- defaultMessage: "Unit price amount"
79
- },
80
- billingLines_taxCategoryType: {
81
- id: "billingLines_taxCategoryType",
82
- defaultMessage: "Tax category"
83
- },
84
- billingLines_taxCategoryType_title: {
85
- id: "billingLines_taxCategoryType_title",
86
- defaultMessage: "A product can not contain VAT unless a VAT number is present" // Ekki er hægt að leggja virðisauka á vöru nema gefa upp VSK númer
87
- },
88
- billingLines_taxCategoryPercentage: {
89
- id: "billingLines_taxCategoryPercentage",
90
- defaultMessage: "Tax percentage"
91
- },
92
- billingLines_discount: {
93
- id: "billingLines_discount",
94
- defaultMessage: "Discount"
95
- },
96
- billingLines_lineAmount: {
97
- id: "billingLines_lineAmount",
98
- defaultMessage: "Amount"
99
- },
100
- billingLines_taxAmount: {
101
- id: "billingLines_taxAmount",
102
- defaultMessage: "Tax inclusive amount"
103
- },
46
+ // billingLines_itemNo: {
47
+ // id: "billingLines_itemNo",
48
+ // defaultMessage: "Item no",
49
+ // },
50
+ // billingLines_name: {
51
+ // id: "billingLines_name",
52
+ // defaultMessage: "Name"
53
+ // },
54
+ // billingLines_quantity: {
55
+ // id: "billingLines_quantity",
56
+ // defaultMessage: "Quantity"
57
+ // },
58
+ // billingLines_unitOfMeasure: {
59
+ // id: "billingLines_unitOfMeasure",
60
+ // defaultMessage: "Unit of measure"
61
+ // },
62
+ // billingLines_unitPriceAmount: {
63
+ // id: "billingLines_unitPriceAmount",
64
+ // defaultMessage: "Unit price amount"
65
+ // },
66
+ // billingLines_taxCategoryType: {
67
+ // id: "billingLines_taxCategoryType",
68
+ // defaultMessage: "Tax category"
69
+ // },
70
+ // billingLines_taxCategoryType_title: {
71
+ // id: "billingLines_taxCategoryType_title",
72
+ // defaultMessage: "A product can not contain VAT unless a VAT number is present" // Ekki er hægt að leggja virðisauka á vöru nema gefa upp VSK númer
73
+ // },
74
+ // billingLines_taxCategoryPercentage: {
75
+ // id: "billingLines_taxCategoryPercentage",
76
+ // defaultMessage: "Tax percentage"
77
+ // },
78
+ // billingLines_discount: {
79
+ // id: "billingLines_discount",
80
+ // defaultMessage: "Discount"
81
+ // },
82
+ // billingLines_lineAmount: {
83
+ // id: "billingLines_lineAmount",
84
+ // defaultMessage: "Amount"
85
+ // },
86
+ // billingLines_taxAmount: {
87
+ // id: "billingLines_taxAmount",
88
+ // defaultMessage: "Tax inclusive amount"
89
+ // },
104
90
  billingLines_button_addRow: {
105
91
  id: "billingLines_button_addRow",
106
92
  defaultMessage: "Add a row"
@@ -116,159 +102,166 @@ exports.translationMessages = react_intl_1.defineMessages({
116
102
  });
117
103
  var BillingLines = /** @class */ (function (_super) {
118
104
  __extends(BillingLines, _super);
105
+ // columns: EditableColumnProps<BillingLineMetadataOverride>[];
119
106
  function BillingLines(props) {
120
- var _this = _super.call(this, props) || this;
121
- _this.columns = [
122
- {
123
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_itemNo),
124
- dataIndex: 'itemNo',
125
- editable: true,
126
- width: "12em",
127
- },
128
- {
129
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_name),
130
- dataIndex: 'name',
131
- editable: true,
132
- },
133
- {
134
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_quantity),
135
- dataIndex: 'quantity',
136
- editable: true,
137
- align: "right",
138
- },
139
- {
140
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_unitOfMeasure),
141
- dataIndex: 'unitOfMeasure',
142
- align: "right",
143
- editable: true,
144
- render: (function (text, record) {
145
- return React.createElement("span", null, _this.props.intl.formatMessage(editable_cell_1.commonTranslationMessages["unitOfMeasure_labels_" + record.unitOfMeasure.value]));
146
- })
147
- },
148
- {
149
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_unitPriceAmount),
150
- dataIndex: 'unitPriceAmount',
151
- editable: true,
152
- align: "right",
153
- render: function (text, record) {
154
- return IntlUtility_1.icelandicNumberLocaleWorkaroundChrome(record.unitPriceAmount ? record.unitPriceAmount : 0, props.intl);
155
- }
156
- // render: this.renderCurrencyColumn,
157
- },
158
- {
159
- title: (React.createElement(antd_1.Tooltip, { title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_taxCategoryType_title), placement: "right" },
160
- React.createElement("span", null,
161
- _this.props.intl.formatMessage(exports.translationMessages.billingLines_taxCategoryType),
162
- " ",
163
- React.createElement(icons_1.QuestionCircleOutlined, null)))),
164
- dataIndex: 'taxCategoryType',
165
- align: "right",
166
- editable: true,
167
- render: (function (text, record) {
168
- var taxPercentage = BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType.value]);
169
- return React.createElement("span", null, _this.props.intl.formatMessage(editable_cell_1.commonTranslationMessages["taxCategoryType_labels_" + record.taxCategoryType.value]) + " (" + taxPercentage + "%)");
170
- })
171
- },
172
- // {
173
- // title: this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryPercentage),
174
- // dataIndex: 'taxCategoryPercentage',
175
- // editable: false,
176
- // align: "right",
177
- // render: ((text, record) => {
178
- // const taxPercentage = calculateTaxPercentage(TaxCategoryTypeEnum[record.taxCategoryType]); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
179
- // return <span>{taxPercentage}%</span>
180
- // })
181
- // },
182
- {
183
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_discount),
184
- dataIndex: 'discountValue',
185
- editable: true,
186
- align: "right",
187
- width: "5em",
188
- render: (function (text, record) {
189
- return React.createElement("div", null, record.discountValue);
190
- })
191
- },
192
- {
193
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_lineAmount),
194
- dataIndex: 'taxableAmount',
195
- editable: false,
196
- align: "right",
197
- render: function (text, record) {
198
- var taxableAmount = BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount);
199
- return (React.createElement("span", null, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome(taxableAmount, props.intl, { style: "decimal" })));
200
- }
201
- },
202
- {
203
- title: _this.props.intl.formatMessage(exports.translationMessages.billingLines_taxAmount),
204
- dataIndex: 'taxInclusiveAmount',
205
- editable: false,
206
- align: "right",
207
- render: function (text, record) {
208
- var taxAmount = BillingLineUtility_1.calculateTaxAmount(BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount), BillingLineUtility_1.calculateTaxPercentage(api_1.TaxCategoryTypeEnum[record.taxCategoryType.value])); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
209
- var taxableAmount = BillingLineUtility_1.calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount);
210
- var taxInclusiveAmount = taxableAmount + taxAmount;
211
- return (React.createElement("span", null, IntlUtility_1.icelandicNumberLocaleWorkaroundChrome(taxInclusiveAmount, props.intl, { style: "decimal" })));
212
- }
213
- },
214
- {
215
- title: "",
216
- render: function (text, record) {
217
- return React.createElement(React.Fragment, null,
218
- React.createElement(icons_1.MinusCircleOutlined, { onClick: function () {
219
- _this.props.handleDelete(record.key);
220
- } }));
221
- }
222
- }
223
- ];
224
- return _this;
107
+ return _super.call(this, props) || this;
108
+ // this.columns = [
109
+ // {
110
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_itemNo),
111
+ // dataIndex: 'itemNo',
112
+ // editable: true,
113
+ // width: "12em",
114
+ // },
115
+ // {
116
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_name),
117
+ // dataIndex: 'name',
118
+ // editable: true,
119
+ // },
120
+ // {
121
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_quantity),
122
+ // dataIndex: 'quantity',
123
+ // editable: true,
124
+ // align: "right",
125
+ // },
126
+ // {
127
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_unitOfMeasure),
128
+ // dataIndex: 'unitOfMeasure',
129
+ // align: "right",
130
+ // editable: true,
131
+ // render: ((text, record) => {
132
+ // return <span>{this.props.intl.formatMessage(commonTranslationMessages[`unitOfMeasure_labels_${record.unitOfMeasure.value}` as keyof typeof commonTranslationMessages])}</span>
133
+ // })
134
+ // },
135
+ // {
136
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_unitPriceAmount),
137
+ // dataIndex: 'unitPriceAmount',
138
+ // editable: true,
139
+ // align: "right",
140
+ // render: (text, record) => {
141
+ // return icelandicNumberLocaleWorkaroundChrome(record.unitPriceAmount ? record.unitPriceAmount : 0, props.intl);
142
+ // }
143
+ // // render: this.renderCurrencyColumn,
144
+ // },
145
+ // {
146
+ // title: (
147
+ // <Tooltip
148
+ // title={this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryType_title)}
149
+ // placement={"right"}
150
+ // >
151
+ // <span>{this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryType)}&nbsp;<QuestionCircleOutlined/></span>
152
+ // </Tooltip>
153
+ // ),
154
+ // dataIndex: 'taxCategoryType',
155
+ // align: "right",
156
+ // editable: true,
157
+ // render: ((text, record) => {
158
+ // const taxPercentage = calculateTaxPercentage(TaxCategoryTypeEnum[record.taxCategoryType.value]);
159
+ // return <span>{`${this.props.intl.formatMessage(commonTranslationMessages[`taxCategoryType_labels_${record.taxCategoryType.value}` as keyof typeof commonTranslationMessages])} (${taxPercentage}%)`}</span>
160
+ // })
161
+ // },
162
+ // // {
163
+ // // title: this.props.intl.formatMessage(translationMessages.billingLines_taxCategoryPercentage),
164
+ // // dataIndex: 'taxCategoryPercentage',
165
+ // // editable: false,
166
+ // // align: "right",
167
+ // // render: ((text, record) => {
168
+ // // const taxPercentage = calculateTaxPercentage(TaxCategoryTypeEnum[record.taxCategoryType]); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
169
+ // // return <span>{taxPercentage}%</span>
170
+ // // })
171
+ // // },
172
+ // {
173
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_discount),
174
+ // dataIndex: 'discountValue',
175
+ // editable: true,
176
+ // align: "right",
177
+ // width: "5em",
178
+ // render: ((text, record) => {
179
+ // return <div>{record.discountValue}</div>
180
+ // })
181
+ // },
182
+ // {
183
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_lineAmount),
184
+ // dataIndex: 'taxableAmount',
185
+ // editable: false,
186
+ // align: "right",
187
+ // render: (text, record) => {
188
+ // const taxableAmount = calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount);
189
+ // return (
190
+ // <span>{icelandicNumberLocaleWorkaroundChrome(taxableAmount, props.intl, {style: "decimal"})}</span>
191
+ // );
192
+ // }
193
+ // },
194
+ // {
195
+ // title: this.props.intl.formatMessage(translationMessages.billingLines_taxAmount),
196
+ // dataIndex: 'taxInclusiveAmount',
197
+ // editable: false,
198
+ // align: "right",
199
+ // render: (text, record) => {
200
+ // const taxAmount = calculateTaxAmount(calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount), calculateTaxPercentage(TaxCategoryTypeEnum[record.taxCategoryType.value])); // BillingLineMetadataTaxCategoryTypeEnum -> TaxCategoryTypeEnum
201
+ // const taxableAmount = calculateTaxableAmount(record.discountValue, record.quantity, record.unitPriceAmount);
202
+ // const taxInclusiveAmount = taxableAmount + taxAmount;
203
+ // return (
204
+ // <span>{icelandicNumberLocaleWorkaroundChrome(taxInclusiveAmount, props.intl, {style: "decimal"})}</span>
205
+ // );
206
+ // }
207
+ // },
208
+ // {
209
+ // title: "",
210
+ // render: (text, record) => {
211
+ // return <>
212
+ // <MinusCircleOutlined
213
+ // onClick={() => {
214
+ // this.props.handleDelete(record.key);
215
+ // }}/>
216
+ // </>;
217
+ // }
218
+ // }
219
+ // ]
225
220
  }
226
221
  // renderCurrencyColumn = (text: string | number) => {
227
222
  // const currency = this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) ? this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) : "";
228
223
  // return text + " " + currency;
229
224
  // };
230
225
  BillingLines.prototype.render = function () {
231
- var _this = this;
232
226
  // const dataSource = this.props.formInstance.getFieldValue(["invoice", "invoiceLines"]);
233
- var dataSource = this.props.dataSource;
227
+ // const {dataSource} = this.props;
234
228
  // console.log(dataSource);
235
- var components = {
236
- body: {
237
- row: components_1.EditableRow,
238
- cell: components_1.EditableCell,
239
- },
240
- };
241
- var columns = this.columns.map(function (col) {
242
- if (!col.editable) {
243
- return col;
244
- }
245
- return __assign({}, col, { onCell: function (record) { return ({
246
- record: record,
247
- editable: col.editable,
248
- dataIndex: col.dataIndex,
249
- title: col.title ? col.title.toString() : "",
250
- handleSave: function (billingLineMetadataOverrideRecord, rowIndex) { return _this.props.handleSave(billingLineMetadataOverrideRecord, _this.props.formInstance); },
251
- }); } });
252
- });
229
+ // const components = {
230
+ // body: {
231
+ // row: EditableRow,
232
+ // cell: EditableCell,
233
+ // },
234
+ // };
235
+ // const columns: ColumnsType<BillingLineMetadataOverride> = this.columns.map(col => {
236
+ // if (!col.editable) {
237
+ // return col;
238
+ // }
239
+ // return {
240
+ // ...col,
241
+ // onCell: (record: BillingLineMetadataOverride) => ({
242
+ // record,
243
+ // editable: col.editable,
244
+ // dataIndex: col.dataIndex,
245
+ // title: col.title ? col.title.toString() : "", // TODO: will this work?????
246
+ // handleSave: (billingLineMetadataOverrideRecord: BillingLineMetadataOverride, rowIndex: number) => this.props.handleSave(billingLineMetadataOverrideRecord, this.props.formInstance),
247
+ // }),
248
+ // };
249
+ // });
253
250
  var billingLinesLabelNode = (React.createElement(antd_1.Tooltip, { title: this.props.intl.formatMessage(exports.translationMessages.billingLines_tooltip_title), placement: "right" },
254
251
  React.createElement("span", null,
255
252
  this.props.intl.formatMessage(exports.translationMessages.billingLines_title),
256
- " ",
253
+ "\u00A0",
257
254
  React.createElement(icons_1.QuestionCircleOutlined, null))));
258
255
  var currencyCode = this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) ? this.props.formInstance.getFieldValue(["invoice", "currencyCode"]) : "";
256
+ var billingLinesFormValues = this.props.formInstance.getFieldsValue(["invoice", "invoiceLines"]);
257
+ // console.log(billingLinesFormValues)
259
258
  return (React.createElement(components_1.ComponentContainer, { title: billingLinesLabelNode },
260
- React.createElement(antd_1.Table, {
261
- // style={{minHeight: "170px"}}
262
- components: components, dataSource: dataSource, columns: columns, pagination: false, rowKey: (function (record, index) { return index.toString(); }) }),
263
- React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.fullWidthInput),
264
- React.createElement(antd_1.Button, { type: "dashed", onClick: function () { return _this.props.handleAdd(_this.props.initialBillingLineData); }, style: { width: "100%" } },
265
- React.createElement(icons_1.PlusOutlined, null),
266
- this.props.intl.formatMessage(exports.translationMessages.billingLines_button_addRow))),
259
+ React.createElement(NewBillingLines_1.default, { formInstance: this.props.formInstance, receiverRequirements: this.props.receiverRequirements }),
267
260
  React.createElement(antd_1.Row, { style: { marginTop: "1em" }, align: "top", justify: "space-between", gutter: [16, 16] },
268
261
  React.createElement(antd_1.Col, { span: 16 },
269
- React.createElement(BillingTaxSummary_1.default, { billingLines: dataSource })),
262
+ React.createElement(BillingTaxSummary_1.default, { billingLines: this.props.billingLinesMetadata })),
270
263
  React.createElement(antd_1.Col, { span: 8 },
271
- React.createElement(BillingCalculations_1.default, { billingLinesMetadata: dataSource,
264
+ React.createElement(BillingCalculations_1.default, { billingLinesMetadata: this.props.billingLinesMetadata,
272
265
  // renderCurrencyColumn={this.renderCurrencyColumn}
273
266
  currencyCode: currencyCode })))));
274
267
  };
@@ -17,7 +17,7 @@ interface Props extends InjectedIntlProps, FormItemProps {
17
17
  fieldName: NamePath;
18
18
  additionalRules?: Rule[];
19
19
  style?: React.CSSProperties;
20
- initialValue?: StringMap;
20
+ initialValue?: StringMap | string | number;
21
21
  verticalLabels?: boolean;
22
22
  onlyLabelOnFirstInList?: boolean;
23
23
  index?: number;
@@ -45,7 +45,7 @@ var UmzFormItem = function (props) {
45
45
  ? react_1.default.createElement(antd_1.Tooltip, { title: labelTooltip, placement: "right" },
46
46
  react_1.default.createElement("span", null,
47
47
  labelString,
48
- " ",
48
+ "\u00A0",
49
49
  react_1.default.createElement(icons_1.QuestionCircleOutlined, null)))
50
50
  : labelString;
51
51
  var isRequired = RequirementsUtility_1.getFieldIsRequired(receiverRequirements, receiverRequirementsKey, defaultIsRequired);
@@ -1,16 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import { InjectedIntlProps } from "react-intl";
3
- import { BillingLineMetadataOverride } from "../../types/BillingLineMetadataOverride";
4
3
  import { NewReceiverRequirements } from "../../types/NewReceiverRequirements";
5
4
  import { FormInstance } from "antd/lib/form";
6
5
  interface Props extends InjectedIntlProps {
7
6
  receiverRequirements: NewReceiverRequirements;
8
- billingLinesDataSource: BillingLineMetadataOverride[];
9
7
  rapiApiKey: string;
10
8
  rapiBaseUrl: string;
11
9
  form: FormInstance;
12
10
  }
13
- declare const SupplierIntl: React.ComponentClass<Pick<Props, "form" | "receiverRequirements" | "rapiBaseUrl" | "billingLinesDataSource" | "rapiApiKey">, any> & {
11
+ declare const SupplierIntl: React.ComponentClass<Pick<Props, "form" | "receiverRequirements" | "rapiBaseUrl" | "rapiApiKey">, any> & {
14
12
  WrappedComponent: React.ComponentType<Props & InjectedIntlProps>;
15
13
  };
16
14
  export default SupplierIntl;
@@ -89,10 +89,21 @@ var Supplier = function (props) {
89
89
  var electronicMailLabelNode = (React.createElement(antd_1.Tooltip, { title: props.intl.formatMessage(translationMessages.supplier_contact_email_title), placement: "right" },
90
90
  React.createElement("span", null,
91
91
  props.intl.formatMessage(translationMessages.supplier_contact_email),
92
- " ",
92
+ "\u00A0",
93
93
  React.createElement(icons_1.QuestionCircleOutlined, null))));
94
- var getRequired = function () {
95
- return props.billingLinesDataSource.some(function (billingLine) { return (billingLine.taxCategoryType.value !== mapi_1.TaxCategoryTypeEnum.OutsideTaxScope); });
94
+ var getRequiredVatNumber = function () {
95
+ var fieldsValueAll = props.form.getFieldsValue();
96
+ if (fieldsValueAll.hasOwnProperty("invoice")) {
97
+ if (fieldsValueAll.invoice.hasOwnProperty("invoiceLines")) {
98
+ var invoiceLines = fieldsValueAll.invoice.invoiceLines;
99
+ return invoiceLines.some(function (billingLine) {
100
+ if (billingLine) {
101
+ return (billingLine.taxCategoryType !== mapi_1.TaxCategoryTypeEnum.OutsideTaxScope);
102
+ }
103
+ });
104
+ }
105
+ }
106
+ return true;
96
107
  };
97
108
  react_1.useEffect(function () {
98
109
  if (participantInfo !== null && participantInfo !== undefined) {
@@ -176,9 +187,9 @@ var Supplier = function (props) {
176
187
  React.createElement(antd_mask_input_1.MaskedInput, { mask: "111111-1111", onChange: function (value) { return debouncerSearch(props.rapiBaseUrl, props.rapiApiKey, value.target.value); } })),
177
188
  React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.name"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_name), defaultIsRequired: true, fieldName: ["invoice", "supplier", "name"] },
178
189
  React.createElement(antd_1.Input, { disabled: isLoadingParticipantInfo })),
179
- React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.vatNumber"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_vatNumber), defaultIsRequired: false, fieldName: ["invoice", "supplier", "vatNumber"], additionalRules: [
190
+ React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.vatNumber"], defaultLabel: props.intl.formatMessage(translationMessages.supplier_vatNumber), defaultIsRequired: false, fieldName: ["invoice", "supplier", "vatNumber"], dependencies: ["invoice", "invoiceLines"], additionalRules: [
180
191
  {
181
- required: getRequired(),
192
+ required: getRequiredVatNumber(),
182
193
  message: props.intl.formatMessage(translationMessages.supplier_vatNumber_mandatory) // VAT number is required if some document lines are using any tax category type other than "outside tax scope"
183
194
  },
184
195
  {
@@ -1,7 +1,8 @@
1
1
  import { BillingLineMetadata } from "@unimaze/api-clients/lib/mapi";
2
- import { TaxCategoryTypeWithPercentageEnum, UnitOfMeasureLabelInValueEnum } from "../components/billing-lines";
2
+ import { UnitOfMeasureLabelInValueEnum } from "../components/billing-lines";
3
+ import { TaxCategoryTypeEnum } from "@unimaze/api-clients/lib/mapi/api";
3
4
  export interface BillingLineMetadataOverride extends Omit<BillingLineMetadata, 'unitOfMeasure' | 'taxCategoryType'> {
4
5
  key: number;
5
6
  unitOfMeasure: UnitOfMeasureLabelInValueEnum;
6
- taxCategoryType: TaxCategoryTypeWithPercentageEnum;
7
+ taxCategoryType: TaxCategoryTypeEnum;
7
8
  }