@unimaze/billing 0.21.18 → 0.21.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/components/base-information/index.js +1 -1
- package/lib/common/components/billing-lines/BillingCalculations.js +2 -1
- package/lib/common/components/billing-lines/NewBillingLines.d.ts +0 -1
- package/lib/common/components/billing-lines/NewBillingLines.js +37 -12
- package/lib/common/components/billing-lines/index.d.ts +2 -1
- package/lib/common/components/billing-lines/index.js +2 -3
- package/lib/common/components/customer/CostCenter.d.ts +14 -0
- package/lib/common/components/customer/CostCenter.js +3 -2
- package/lib/common/components/customer/index.d.ts +0 -2
- package/lib/common/components/customer/index.js +1 -36
- package/lib/common/components/invoice/index.d.ts +2 -3
- package/lib/common/components/invoice/index.js +5 -48
- package/lib/common/components/payment-method/index.d.ts +0 -2
- package/lib/common/components/payment-method/index.js +0 -16
- package/lib/common/components/supplier/index.d.ts +0 -2
- package/lib/common/components/supplier/index.js +0 -27
- package/lib/common/consts/formPaths.d.ts +6 -0
- package/lib/common/consts/formPaths.js +46 -0
- package/lib/create-invoice/index.js +71 -155
- package/lib/translations/locales/en.json +1 -1
- package/lib/unimaze-billing/src/create-invoice/index.js +3 -0
- package/lib/utils/ValidationUtility.d.ts +9 -0
- package/lib/utils/ValidationUtility.js +112 -0
- package/package.json +1 -1
|
@@ -90,7 +90,7 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
90
90
|
baseInformation_projectReference: {
|
|
91
91
|
id: "baseInformation_projectReference",
|
|
92
92
|
defaultMessage: "Project reference is required",
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
94
|
});
|
|
95
95
|
var BaseInformation = function (props) {
|
|
96
96
|
var _a, _b;
|
|
@@ -59,7 +59,8 @@ var translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
59
59
|
var BillingCalculations = function (props) {
|
|
60
60
|
var _a = (0, react_1.useState)([]), invoiceLines = _a[0], setInvoiceLines = _a[1];
|
|
61
61
|
(0, react_1.useEffect)(function () {
|
|
62
|
-
var
|
|
62
|
+
var _a;
|
|
63
|
+
var savedLines = (_a = props.formInstance.getFieldValue(["invoice", "invoiceLines"])) === null || _a === void 0 ? void 0 : _a.filter(function (line) { return line.editing === false; });
|
|
63
64
|
setInvoiceLines(savedLines);
|
|
64
65
|
}, [props.outsideVatScope, props.formInstance.getFieldValue(["invoice", "invoiceLines"]), props.newLineSaved]);
|
|
65
66
|
var totals = {
|
|
@@ -136,7 +136,6 @@ interface Props extends WrappedComponentProps {
|
|
|
136
136
|
receiverRequirements: NewReceiverRequirements;
|
|
137
137
|
formInstance: FormInstance;
|
|
138
138
|
outsideVatScope: boolean;
|
|
139
|
-
validateFields: (fieldNames: string[][], validateOnly?: boolean | undefined) => void;
|
|
140
139
|
newLineSaved: boolean;
|
|
141
140
|
setNewLineSaved: (isSaved: boolean) => void;
|
|
142
141
|
}
|
|
@@ -41,7 +41,6 @@ var react_intl_1 = require("react-intl");
|
|
|
41
41
|
var antd_1 = require("antd");
|
|
42
42
|
var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
|
|
43
43
|
var SingleBillingLine_1 = __importDefault(require("./SingleBillingLine"));
|
|
44
|
-
var invoice_1 = require("../invoice");
|
|
45
44
|
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
46
45
|
billingLines_labels_addButton: {
|
|
47
46
|
id: "billingLines_labels_addButton",
|
|
@@ -173,6 +172,12 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
173
172
|
},
|
|
174
173
|
});
|
|
175
174
|
var BillingLines = function (props) {
|
|
175
|
+
var invoiceLinesForm = antd_1.Form.useForm()[0];
|
|
176
|
+
var _a = (0, react_1.useState)({
|
|
177
|
+
invoice: {
|
|
178
|
+
invoiceLines: [{}],
|
|
179
|
+
}
|
|
180
|
+
}), formData = _a[0], setFormData = _a[1];
|
|
176
181
|
(0, react_1.useEffect)(function () {
|
|
177
182
|
if (!props.formInstance.getFieldValue(["invoice", "currencyCode"])) {
|
|
178
183
|
props.formInstance.setFieldsValue({
|
|
@@ -180,11 +185,12 @@ var BillingLines = function (props) {
|
|
|
180
185
|
});
|
|
181
186
|
}
|
|
182
187
|
}, []);
|
|
188
|
+
// INIT
|
|
183
189
|
(0, react_1.useEffect)(function () {
|
|
184
190
|
var _a;
|
|
185
191
|
var currentLines = ((_a = props.formInstance.getFieldValue(["invoice", "invoiceLines"])) === null || _a === void 0 ? void 0 : _a.filter(function (line) { return line.name; })) || [];
|
|
186
192
|
if (!(currentLines === null || currentLines === void 0 ? void 0 : currentLines.some(function (line) { return line.editing; }))) {
|
|
187
|
-
|
|
193
|
+
invoiceLinesForm.setFieldsValue({
|
|
188
194
|
invoice: {
|
|
189
195
|
invoiceLines: __spreadArray(__spreadArray([], currentLines, true), [
|
|
190
196
|
{
|
|
@@ -192,13 +198,13 @@ var BillingLines = function (props) {
|
|
|
192
198
|
name: "",
|
|
193
199
|
editing: true
|
|
194
200
|
},
|
|
195
|
-
], false)
|
|
201
|
+
], false)
|
|
196
202
|
}
|
|
197
203
|
});
|
|
198
204
|
}
|
|
199
|
-
}, [
|
|
205
|
+
}, []);
|
|
200
206
|
var handeAddNewLine = function (index) {
|
|
201
|
-
var lines =
|
|
207
|
+
var lines = invoiceLinesForm.getFieldValue(["invoice", "invoiceLines"]) || [];
|
|
202
208
|
lines[index].editing = false;
|
|
203
209
|
if (!lines.some(function (line) { return line.editing; })) {
|
|
204
210
|
lines.push({
|
|
@@ -207,16 +213,35 @@ var BillingLines = function (props) {
|
|
|
207
213
|
editing: true
|
|
208
214
|
});
|
|
209
215
|
}
|
|
210
|
-
|
|
216
|
+
invoiceLinesForm.setFieldValue(["invoice", "invoiceLines"], lines);
|
|
217
|
+
updateAllForms(lines);
|
|
218
|
+
};
|
|
219
|
+
var updateAllForms = function (lines) {
|
|
220
|
+
invoiceLinesForm.setFieldsValue({
|
|
221
|
+
invoice: {
|
|
222
|
+
invoiceLines: lines,
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
var onlyPlaceholderLine = (lines === null || lines === void 0 ? void 0 : lines.length) === 1 && lines[0].editing;
|
|
226
|
+
props.formInstance.setFieldsValue({
|
|
227
|
+
invoice: {
|
|
228
|
+
invoiceLines: onlyPlaceholderLine ? [] : lines,
|
|
229
|
+
},
|
|
230
|
+
});
|
|
211
231
|
props.setNewLineSaved(!props.newLineSaved);
|
|
212
|
-
props.validateFields(invoice_1.fieldPaths, true);
|
|
213
232
|
};
|
|
214
|
-
|
|
215
|
-
var
|
|
216
|
-
|
|
217
|
-
|
|
233
|
+
var handleRemove = function (indexToRemove) {
|
|
234
|
+
var lines = invoiceLinesForm.getFieldValue(["invoice", "invoiceLines"]) || [];
|
|
235
|
+
var updatedList = lines.filter(function (_, index) { return index !== indexToRemove; });
|
|
236
|
+
updateAllForms(updatedList);
|
|
237
|
+
};
|
|
238
|
+
return (react_1.default.createElement(antd_1.Form, { form: invoiceLinesForm, initialValues: formData },
|
|
239
|
+
react_1.default.createElement(antd_1.Form.List, { name: ["invoice", "invoiceLines"] }, function (fields, _a) {
|
|
240
|
+
var add = _a.add, remove = _a.remove;
|
|
241
|
+
return (react_1.default.createElement(antd_1.Flex, { vertical: true, gap: 20 }, fields.map(function (field, index) {
|
|
242
|
+
return react_1.default.createElement(SingleBillingLine_1.default, { key: "".concat(index + "" + (field === null || field === void 0 ? void 0 : field.key)), fieldName: field.name, index: index, receiverRequirements: props.receiverRequirements, outsideVatScope: props.outsideVatScope, formInstance: invoiceLinesForm, handleAddNewLine: handeAddNewLine, remove: handleRemove });
|
|
243
|
+
})));
|
|
218
244
|
})));
|
|
219
|
-
}));
|
|
220
245
|
};
|
|
221
246
|
var BillingLinesWithIntl = (0, react_intl_1.injectIntl)(BillingLines);
|
|
222
247
|
exports.default = BillingLinesWithIntl;
|
|
@@ -13,7 +13,8 @@ interface Props extends WrappedComponentProps {
|
|
|
13
13
|
billingLinesMetadata: BillingLineMetadataOverride[] | undefined;
|
|
14
14
|
receiverRequirements: NewReceiverRequirements;
|
|
15
15
|
outsideVatScope: boolean;
|
|
16
|
-
|
|
16
|
+
newLineSaved: boolean;
|
|
17
|
+
setNewLineSaved: (isSaved: boolean) => void;
|
|
17
18
|
}
|
|
18
19
|
export declare const translationMessages: {
|
|
19
20
|
billingLines_title: {
|
|
@@ -36,7 +36,6 @@ var BillingCalculations_1 = __importDefault(require("./BillingCalculations"));
|
|
|
36
36
|
var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
37
37
|
var react_use_1 = require("react-use");
|
|
38
38
|
var tooltip_1 = __importDefault(require("../tooltip"));
|
|
39
|
-
var react_1 = require("react");
|
|
40
39
|
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
41
40
|
billingLines_title: {
|
|
42
41
|
id: "billingLines_title",
|
|
@@ -70,7 +69,7 @@ var BillingLines = function (props) {
|
|
|
70
69
|
var width = (0, react_use_1.useWindowSize)().width;
|
|
71
70
|
var _b = React.useState(false), isMobile = _b[0], setIsMobile = _b[1];
|
|
72
71
|
var token = antd_1.theme.useToken().token;
|
|
73
|
-
var
|
|
72
|
+
var newLineSaved = props.newLineSaved, setNewLineSaved = props.setNewLineSaved;
|
|
74
73
|
React.useEffect(function () {
|
|
75
74
|
if (width < 768) {
|
|
76
75
|
setIsMobile(true);
|
|
@@ -96,7 +95,7 @@ var BillingLines = function (props) {
|
|
|
96
95
|
React.createElement(antd_1.Typography.Title, { level: 5 }, props.intl.formatMessage(exports.translationMessages.billingLines_title)),
|
|
97
96
|
React.createElement(antd_1.Flex, { style: { marginBottom: (_a = token.Typography) === null || _a === void 0 ? void 0 : _a.titleMarginBottom } },
|
|
98
97
|
React.createElement(tooltip_1.default, { title: props.intl.formatMessage(exports.translationMessages.billingLines_tooltip_title) }))),
|
|
99
|
-
React.createElement(NewBillingLines_1.default, { formInstance: props.formInstance, receiverRequirements: props.receiverRequirements, outsideVatScope: props.outsideVatScope,
|
|
98
|
+
React.createElement(NewBillingLines_1.default, { formInstance: props.formInstance, receiverRequirements: props.receiverRequirements, outsideVatScope: props.outsideVatScope, newLineSaved: newLineSaved, setNewLineSaved: setNewLineSaved })),
|
|
100
99
|
React.createElement(antd_1.Flex, { gap: "middle", vertical: true },
|
|
101
100
|
React.createElement(BillingCalculations_1.default, { currencyCode: currencyCode, formInstance: props.formInstance, outsideVatScope: props.outsideVatScope, newLineSaved: newLineSaved }),
|
|
102
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 } },
|
|
@@ -2,6 +2,20 @@ import React from 'react';
|
|
|
2
2
|
import { WrappedComponentProps } from "react-intl";
|
|
3
3
|
import { NewReceiverRequirements } from "../../types/NewReceiverRequirements";
|
|
4
4
|
import { FormInstance } from "antd/es/form";
|
|
5
|
+
export declare const translationMessages: {
|
|
6
|
+
baseInformation_costCenter: {
|
|
7
|
+
id: string;
|
|
8
|
+
defaultMessage: string;
|
|
9
|
+
};
|
|
10
|
+
baseInformation_costCenter_placeholder_input: {
|
|
11
|
+
id: string;
|
|
12
|
+
defaultMessage: string;
|
|
13
|
+
};
|
|
14
|
+
baseInformation_costCenter_placeholder_search: {
|
|
15
|
+
id: string;
|
|
16
|
+
defaultMessage: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
5
19
|
interface Props extends WrappedComponentProps {
|
|
6
20
|
receiverRequirements: NewReceiverRequirements;
|
|
7
21
|
updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void;
|
|
@@ -26,13 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.translationMessages = void 0;
|
|
29
30
|
var react_1 = __importStar(require("react"));
|
|
30
31
|
var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
31
32
|
var form_item_1 = __importDefault(require("../form-item"));
|
|
32
33
|
var react_intl_1 = require("react-intl");
|
|
33
34
|
var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
|
|
34
35
|
// import {FormInstance} from "antd/es/form";
|
|
35
|
-
|
|
36
|
+
exports.translationMessages = {
|
|
36
37
|
baseInformation_costCenter: {
|
|
37
38
|
id: "baseInformation_costCenter",
|
|
38
39
|
defaultMessage: "Cost center",
|
|
@@ -154,7 +155,7 @@ var CostCenter = function (props) {
|
|
|
154
155
|
var _c = (0, react_1.useState)(false), loadingCostCenterValues = _c[0], setLoadingCostCenterValues = _c[1];
|
|
155
156
|
var costCenterFieldDefinition = (0, RequirementsUtility_1.getFieldRequirements)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"]);
|
|
156
157
|
if (costCenterFieldDefinition) {
|
|
157
|
-
return (react_1.default.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"], defaultLabel: props.intl.formatMessage(translationMessages.baseInformation_costCenter), defaultIsRequired: false, fieldName: ["invoice", "customer", "locationIdentifier"], validateStatus: costCenterHandlingValidationStatus }, (0, RequirementsUtility_1.getInput)(costCenterFieldDefinition, ["invoice", "customer", "locationIdentifier"], "handleCostCenterValidation", props.legalIdentifier, props.formInstance, props.rapiBaseUrl, props.receiverRequirements, props.updateReceiverRequirementsProp, setCostCenterFieldProps, costCenterFieldProps, setLoadingCostCenterValues, loadingCostCenterValues, setCostCenterHandlingValidationStatus, props.intl.formatMessage(translationMessages.baseInformation_costCenter), true)));
|
|
158
|
+
return (react_1.default.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"], defaultLabel: props.intl.formatMessage(exports.translationMessages.baseInformation_costCenter), defaultIsRequired: false, fieldName: ["invoice", "customer", "locationIdentifier"], validateStatus: costCenterHandlingValidationStatus }, (0, RequirementsUtility_1.getInput)(costCenterFieldDefinition, ["invoice", "customer", "locationIdentifier"], "handleCostCenterValidation", props.legalIdentifier, props.formInstance, props.rapiBaseUrl, props.receiverRequirements, props.updateReceiverRequirementsProp, setCostCenterFieldProps, costCenterFieldProps, setLoadingCostCenterValues, loadingCostCenterValues, setCostCenterHandlingValidationStatus, props.intl.formatMessage(exports.translationMessages.baseInformation_costCenter), true)));
|
|
158
159
|
}
|
|
159
160
|
else {
|
|
160
161
|
return null;
|
|
@@ -12,10 +12,8 @@ interface Props extends WrappedComponentProps {
|
|
|
12
12
|
setChosenCustomer: (chosenCustomer: PartyMetadata) => void;
|
|
13
13
|
rapiBaseUrl: string;
|
|
14
14
|
updateReceiverRequirementsProp: (newReceiverRequirements: NewReceiverRequirements) => void;
|
|
15
|
-
validateFields: (fieldNames: string[][], validateOnly?: boolean | undefined) => void;
|
|
16
15
|
isSaveFieldValuesSelected: boolean;
|
|
17
16
|
onSaveFieldValuesChange: () => void;
|
|
18
|
-
isActiveStep: boolean;
|
|
19
17
|
}
|
|
20
18
|
declare const CustomerIntl: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
|
|
21
19
|
forwardedRef?: React.Ref<any>;
|
|
@@ -10,34 +10,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
-
}
|
|
19
|
-
Object.defineProperty(o, k2, desc);
|
|
20
|
-
}) : (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
o[k2] = m[k];
|
|
23
|
-
}));
|
|
24
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
-
}) : function(o, v) {
|
|
27
|
-
o["default"] = v;
|
|
28
|
-
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
13
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
15
|
};
|
|
39
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
var react_1 =
|
|
17
|
+
var react_1 = __importDefault(require("react"));
|
|
41
18
|
var antd_1 = require("antd");
|
|
42
19
|
var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
43
20
|
var form_item_1 = __importDefault(require("../form-item"));
|
|
@@ -49,7 +26,6 @@ var CustomerContactName_1 = __importDefault(require("./CustomerContactName"));
|
|
|
49
26
|
var Title_1 = __importDefault(require("antd/es/typography/Title"));
|
|
50
27
|
var react_use_1 = require("react-use");
|
|
51
28
|
var CommonTranslations_1 = require("../CommonTranslations");
|
|
52
|
-
var lodash_1 = require("lodash");
|
|
53
29
|
var translationMessages = (0, react_intl_1.defineMessages)({
|
|
54
30
|
customer_title: {
|
|
55
31
|
id: "customer_title",
|
|
@@ -112,17 +88,6 @@ var Customer = function (props) {
|
|
|
112
88
|
setChosenCustomer(__assign(__assign({}, prevValues.invoice.customer), customerPartyMetadata));
|
|
113
89
|
props.formInstance.setFieldsValue(newFormValues);
|
|
114
90
|
};
|
|
115
|
-
var fieldPaths = [
|
|
116
|
-
["invoice", "customer", "name"],
|
|
117
|
-
["invoice", "customer", "locationIdentifier"],
|
|
118
|
-
["invoice", "customer", "contact", "name"],
|
|
119
|
-
];
|
|
120
|
-
var debouncedValidateFields = (0, lodash_1.debounce)(props.validateFields, 500);
|
|
121
|
-
(0, react_1.useEffect)(function () {
|
|
122
|
-
if (!props.isActiveStep)
|
|
123
|
-
return;
|
|
124
|
-
debouncedValidateFields(fieldPaths, true);
|
|
125
|
-
}, [props.isActiveStep, props.formInstance.getFieldsValue(fieldPaths)]);
|
|
126
91
|
var onlyOneCustomer = props.customers.length === 1;
|
|
127
92
|
return (react_1.default.createElement(antd_1.Flex, { style: {
|
|
128
93
|
backgroundColor: isMobile ? undefined : colorInfoBg,
|
|
@@ -27,13 +27,12 @@ interface Props extends WrappedComponentProps {
|
|
|
27
27
|
en: string;
|
|
28
28
|
};
|
|
29
29
|
languageString: LanguageProp;
|
|
30
|
-
validateFields: (fieldNames: string[][], validateOnly?: boolean | undefined) => void;
|
|
31
30
|
isSaveFieldValuesSelected: boolean;
|
|
32
31
|
onSaveFieldValuesChange: () => void;
|
|
33
|
-
isActiveStep: boolean;
|
|
34
32
|
setReferenceIdentifierIsMandatory: (referenceIdentifierIsMandatory: boolean) => void;
|
|
33
|
+
newLineSaved: boolean;
|
|
34
|
+
setNewLineSaved: (isSaved: boolean) => void;
|
|
35
35
|
}
|
|
36
|
-
export declare const fieldPaths: string[][];
|
|
37
36
|
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
|
|
38
37
|
forwardedRef?: React.Ref<any>;
|
|
39
38
|
} & React.RefAttributes<any>> & {
|
|
@@ -1,59 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
27
|
-
var react_1 = __importStar(require("react"));
|
|
6
|
+
var react_1 = __importDefault(require("react"));
|
|
28
7
|
var react_intl_1 = require("react-intl");
|
|
29
8
|
var __1 = require("..");
|
|
30
|
-
var lodash_1 = require("lodash");
|
|
31
|
-
exports.fieldPaths = [
|
|
32
|
-
["invoice", "invoiceNo"],
|
|
33
|
-
["invoice", "issueDate"],
|
|
34
|
-
["invoice", "dueDate"],
|
|
35
|
-
["invoice", "buyerReference"],
|
|
36
|
-
["invoice", "orderReference", "documentNo"],
|
|
37
|
-
["invoice", "accountingCost"],
|
|
38
|
-
["invoice", "documentReferences", "project", "documentNo"],
|
|
39
|
-
["invoice", "invoiceLines"],
|
|
40
|
-
["invoice", "singleReferenceIdentifier", "value"],
|
|
41
|
-
["invoice", "referenceIdentifiers"],
|
|
42
|
-
];
|
|
43
9
|
var Invoice = function (props) {
|
|
44
|
-
var
|
|
45
|
-
(0, react_1.useEffect)(function () {
|
|
46
|
-
if (!props.isActiveStep)
|
|
47
|
-
return;
|
|
48
|
-
debouncedValidateFields(exports.fieldPaths, true);
|
|
49
|
-
}, [props.isActiveStep, JSON.stringify(props.form.getFieldsValue(exports.fieldPaths))]);
|
|
50
|
-
(0, react_1.useEffect)(function () {
|
|
51
|
-
// Update validateField if there are changes to referenceIdentifierValidateStatus (which are debounced and thus late)
|
|
52
|
-
props.validateFields(exports.fieldPaths, true);
|
|
53
|
-
}, [props.referenceIdentifierValidateStatus]);
|
|
10
|
+
var newLineSaved = props.newLineSaved, setNewLineSaved = props.setNewLineSaved;
|
|
54
11
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
55
12
|
react_1.default.createElement(__1.BaseInformation, { receiverRequirements: props.receiverRequirements, form: props.form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: props.chosenCustomer.identifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: props.referenceIdentifierValidateStatus, setReferenceIdentifierValidateStatus: props.setReferenceIdentifierValidateStatus, dueDateMinimumOffset: props.dueDateMinimumOffset, isSaveFieldValuesSelected: props.isSaveFieldValuesSelected, onSaveFieldValuesChange: props.onSaveFieldValuesChange, setReferenceIdentifierIsMandatory: props.setReferenceIdentifierIsMandatory }),
|
|
56
|
-
react_1.default.createElement(__1.BillingLines, { formInstance: props.form, billingLinesMetadata: props.billingLinesMetadata, receiverRequirements: props.receiverRequirements, outsideVatScope: props.outsideVatScope,
|
|
13
|
+
react_1.default.createElement(__1.BillingLines, { formInstance: props.form, billingLinesMetadata: props.billingLinesMetadata, receiverRequirements: props.receiverRequirements, outsideVatScope: props.outsideVatScope, newLineSaved: newLineSaved, setNewLineSaved: setNewLineSaved }),
|
|
57
14
|
react_1.default.createElement(__1.Attachments, { formInstance: props.form, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.languageString })));
|
|
58
15
|
};
|
|
59
16
|
exports.default = (0, react_intl_1.injectIntl)(Invoice);
|
|
@@ -63,10 +63,8 @@ export declare const translationMessages: {
|
|
|
63
63
|
interface Props extends WrappedComponentProps {
|
|
64
64
|
formInstance: FormInstance;
|
|
65
65
|
receiverRequirements: NewReceiverRequirements;
|
|
66
|
-
validateFields: (fieldNames: string[][], validateOnly?: boolean | undefined) => void;
|
|
67
66
|
isSaveFieldValuesSelected: boolean;
|
|
68
67
|
onSaveFieldValuesChange: () => void;
|
|
69
|
-
isActiveStep: boolean;
|
|
70
68
|
}
|
|
71
69
|
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
|
|
72
70
|
forwardedRef?: React.Ref<any>;
|
|
@@ -34,7 +34,6 @@ var ReceiverRequirements_1 = require("../../types/ReceiverRequirements");
|
|
|
34
34
|
var mapi_1 = require("@unimaze/api-clients/lib/mapi");
|
|
35
35
|
var react_use_1 = require("react-use");
|
|
36
36
|
var CommonTranslations_1 = require("../CommonTranslations");
|
|
37
|
-
var lodash_1 = require("lodash");
|
|
38
37
|
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
39
38
|
paymentMethod_title: {
|
|
40
39
|
id: "paymentMethod_title",
|
|
@@ -115,21 +114,6 @@ var PaymentMethod = function (props) {
|
|
|
115
114
|
: "NotSpecified";
|
|
116
115
|
var initialPaymentMeansType = mapi_1.PaymentMeansType[paymentMeansType];
|
|
117
116
|
var _b = (0, react_1.useState)(initialPaymentMeansType), paymentMethod = _b[0], setPaymentMethod = _b[1]; // PaymentMeansType.DomesticClaim);
|
|
118
|
-
var fieldPaths = [
|
|
119
|
-
["invoice", "paymentMeans", "domesticTransfer", "bankNumber"],
|
|
120
|
-
["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"],
|
|
121
|
-
["invoice", "paymentMeans", "domesticTransfer", "accountNumber"],
|
|
122
|
-
["invoice", "paymentMeans", "domesticTransfer", "paymentIdentifier"],
|
|
123
|
-
["invoice", "paymentMeans", "domesticClaim", "bankNumber"],
|
|
124
|
-
["invoice", "paymentMeans", "domesticClaim", "accountNumber"],
|
|
125
|
-
["invoice", "paymentMeans", "type"],
|
|
126
|
-
];
|
|
127
|
-
var debouncedValidateFields = (0, lodash_1.debounce)(props.validateFields, 500);
|
|
128
|
-
react_1.default.useEffect(function () {
|
|
129
|
-
if (!props.isActiveStep)
|
|
130
|
-
return;
|
|
131
|
-
debouncedValidateFields(fieldPaths, true);
|
|
132
|
-
}, [props.isActiveStep, JSON.stringify(props.formInstance.getFieldsValue(fieldPaths))]);
|
|
133
117
|
(0, react_1.useEffect)(function () {
|
|
134
118
|
if (!props.formInstance.getFieldValue(["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"])) {
|
|
135
119
|
props.formInstance.setFieldValue(["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"], "04");
|
|
@@ -80,11 +80,9 @@ interface Props extends WrappedComponentProps {
|
|
|
80
80
|
outsideVatScope: boolean;
|
|
81
81
|
setOutsideVatScope: (outsideVatScope: boolean) => void;
|
|
82
82
|
isMobile?: boolean;
|
|
83
|
-
validateFields: (fieldNames: string[][], validateOnly?: boolean | undefined) => void;
|
|
84
83
|
onSaveFieldValues: (fields: any) => void;
|
|
85
84
|
isSaveFieldValuesSelected: boolean;
|
|
86
85
|
onSaveFieldValuesChange: () => void;
|
|
87
|
-
isActiveStep: boolean;
|
|
88
86
|
}
|
|
89
87
|
declare const SupplierIntl: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
|
|
90
88
|
forwardedRef?: React.Ref<any>;
|
|
@@ -22,15 +22,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
-
if (ar || !(i in from)) {
|
|
28
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
-
ar[i] = from[i];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
-
};
|
|
34
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
27
|
};
|
|
@@ -128,24 +119,6 @@ var Supplier = function (props) {
|
|
|
128
119
|
var _b = (0, react_1.useState)(false), isLoadingParticipantInfo = _b[0], setIsLoadingParticipantInfo = _b[1];
|
|
129
120
|
var _c = (0, react_1.useState)({}), participantInfo = _c[0], setParticipantInfo = _c[1];
|
|
130
121
|
var colorInfoBg = antd_1.theme.useToken().token.colorInfoBg;
|
|
131
|
-
var fieldPaths = [
|
|
132
|
-
["invoice", "supplier", "identifier"],
|
|
133
|
-
["invoice", "supplier", "name"],
|
|
134
|
-
["invoice", "supplier", "address", "streetNameAndNumber"],
|
|
135
|
-
["invoice", "supplier", "address", "postalZone"],
|
|
136
|
-
["invoice", "supplier", "address", "city"],
|
|
137
|
-
["invoice", "supplier", "address", "countryCode"],
|
|
138
|
-
["invoice", "supplier", "contact", "name"],
|
|
139
|
-
["invoice", "supplier", "contact", "electronicMail"],
|
|
140
|
-
["invoice", "supplier", "contact", "telephone"],
|
|
141
|
-
];
|
|
142
|
-
var vatNoFieldPath = ["invoice", "supplier", "vatNumber"];
|
|
143
|
-
var debouncedValidateFields = (0, lodash_1.debounce)(props.validateFields, 500);
|
|
144
|
-
(0, react_1.useEffect)(function () {
|
|
145
|
-
if (!props.isActiveStep)
|
|
146
|
-
return;
|
|
147
|
-
debouncedValidateFields(__spreadArray(__spreadArray([], fieldPaths, true), [!props.outsideVatScope ? vatNoFieldPath : []], false), true);
|
|
148
|
-
}, [props.isActiveStep, JSON.stringify(props.form.getFieldsValue(__spreadArray(__spreadArray([], fieldPaths, true), [vatNoFieldPath], false))), props.outsideVatScope]);
|
|
149
122
|
(0, react_1.useEffect)(function () {
|
|
150
123
|
if (width < 768) {
|
|
151
124
|
setIsMobile(true);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare const paymentMeansFieldPaths: string[][];
|
|
2
|
+
declare const customerFieldPaths: string[][];
|
|
3
|
+
declare const supplierFieldPaths: string[][];
|
|
4
|
+
declare const vatNoFieldPath: string[];
|
|
5
|
+
declare const invoiceFieldPaths: string[][];
|
|
6
|
+
export { paymentMeansFieldPaths, customerFieldPaths, supplierFieldPaths, vatNoFieldPath, invoiceFieldPaths };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.invoiceFieldPaths = exports.vatNoFieldPath = exports.supplierFieldPaths = exports.customerFieldPaths = exports.paymentMeansFieldPaths = void 0;
|
|
4
|
+
var paymentMeansFieldPaths = [
|
|
5
|
+
["invoice", "paymentMeans", "domesticTransfer", "bankNumber"],
|
|
6
|
+
["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"],
|
|
7
|
+
["invoice", "paymentMeans", "domesticTransfer", "accountNumber"],
|
|
8
|
+
["invoice", "paymentMeans", "domesticTransfer", "paymentIdentifier"],
|
|
9
|
+
["invoice", "paymentMeans", "domesticClaim", "bankNumber"],
|
|
10
|
+
["invoice", "paymentMeans", "domesticClaim", "accountNumber"],
|
|
11
|
+
["invoice", "paymentMeans", "type"],
|
|
12
|
+
];
|
|
13
|
+
exports.paymentMeansFieldPaths = paymentMeansFieldPaths;
|
|
14
|
+
var customerFieldPaths = [
|
|
15
|
+
["invoice", "customer", "name"],
|
|
16
|
+
["invoice", "customer", "locationIdentifier"],
|
|
17
|
+
["invoice", "customer", "contact", "name"],
|
|
18
|
+
];
|
|
19
|
+
exports.customerFieldPaths = customerFieldPaths;
|
|
20
|
+
var supplierFieldPaths = [
|
|
21
|
+
["invoice", "supplier", "identifier"],
|
|
22
|
+
["invoice", "supplier", "name"],
|
|
23
|
+
["invoice", "supplier", "address", "streetNameAndNumber"],
|
|
24
|
+
["invoice", "supplier", "address", "postalZone"],
|
|
25
|
+
["invoice", "supplier", "address", "city"],
|
|
26
|
+
["invoice", "supplier", "address", "countryCode"],
|
|
27
|
+
["invoice", "supplier", "contact", "name"],
|
|
28
|
+
["invoice", "supplier", "contact", "electronicMail"],
|
|
29
|
+
["invoice", "supplier", "contact", "telephone"],
|
|
30
|
+
];
|
|
31
|
+
exports.supplierFieldPaths = supplierFieldPaths;
|
|
32
|
+
var vatNoFieldPath = ["invoice", "supplier", "vatNumber"];
|
|
33
|
+
exports.vatNoFieldPath = vatNoFieldPath;
|
|
34
|
+
var invoiceFieldPaths = [
|
|
35
|
+
["invoice", "invoiceNo"],
|
|
36
|
+
["invoice", "issueDate"],
|
|
37
|
+
["invoice", "dueDate"],
|
|
38
|
+
["invoice", "buyerReference"],
|
|
39
|
+
["invoice", "orderReference", "documentNo"],
|
|
40
|
+
["invoice", "accountingCost"],
|
|
41
|
+
["invoice", "documentReferences", "project", "documentNo"],
|
|
42
|
+
["invoice", "invoiceLines"],
|
|
43
|
+
["invoice", "singleReferenceIdentifier", "value"],
|
|
44
|
+
["invoice", "referenceIdentifiers"],
|
|
45
|
+
];
|
|
46
|
+
exports.invoiceFieldPaths = invoiceFieldPaths;
|
|
@@ -33,42 +33,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
33
33
|
__setModuleDefault(result, mod);
|
|
34
34
|
return result;
|
|
35
35
|
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
36
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
73
37
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
74
38
|
if (ar || !(i in from)) {
|
|
@@ -101,16 +65,12 @@ var welcome_modal_1 = __importDefault(require("../common/components/welcome-moda
|
|
|
101
65
|
var react_use_1 = require("react-use");
|
|
102
66
|
var dayjs_1 = __importDefault(require("dayjs"));
|
|
103
67
|
require("../common/style/index.css");
|
|
104
|
-
var
|
|
105
|
-
var
|
|
106
|
-
var supplier_1 = require("../common/components/supplier");
|
|
107
|
-
var base_information_1 = require("../common/components/base-information");
|
|
108
|
-
var payment_method_1 = require("../common/components/payment-method");
|
|
109
|
-
var ReferenceIdentifierUtility_1 = require("../utils/ReferenceIdentifierUtility");
|
|
68
|
+
var formPaths_1 = require("../common/consts/formPaths");
|
|
69
|
+
var ValidationUtility_1 = require("../utils/ValidationUtility");
|
|
110
70
|
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
111
71
|
createInvoice_addDocumentLineMsg: {
|
|
112
72
|
id: "createInvoice_addDocumentLineMsg",
|
|
113
|
-
defaultMessage: "
|
|
73
|
+
defaultMessage: "At least one document line",
|
|
114
74
|
},
|
|
115
75
|
createInvoice_selectCustomerMsg: {
|
|
116
76
|
id: "createInvoice_selectCustomerMsg",
|
|
@@ -211,10 +171,11 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
211
171
|
var _x = (0, react_1.useState)(false), captchaVerified = _x[0], setCaptchaVerified = _x[1];
|
|
212
172
|
var _y = (0, react_1.useState)({}), removedInvoiceLine = _y[0], setRemovedInvoiceLine = _y[1];
|
|
213
173
|
var _z = (0, react_1.useState)(undefined), missingRequiredDataTooltip = _z[0], setMissingRequiredDataTooltip = _z[1];
|
|
174
|
+
var _0 = (0, react_1.useState)(false), newLineSaved = _0[0], setNewLineSaved = _0[1];
|
|
214
175
|
var getDefaultPaymentType = function (defaultPaymentType) {
|
|
215
176
|
return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
|
|
216
177
|
};
|
|
217
|
-
var
|
|
178
|
+
var _1 = (0, react_1.useState)({
|
|
218
179
|
invoice: {
|
|
219
180
|
supplier: {
|
|
220
181
|
address: {
|
|
@@ -232,7 +193,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
232
193
|
code: undefined,
|
|
233
194
|
value: undefined,
|
|
234
195
|
},
|
|
235
|
-
invoiceLines: [
|
|
196
|
+
invoiceLines: [],
|
|
236
197
|
attachments: {
|
|
237
198
|
file1: { file: undefined, description: undefined },
|
|
238
199
|
file2: { file: undefined, description: undefined },
|
|
@@ -240,101 +201,56 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
240
201
|
},
|
|
241
202
|
issueDate: (0, dayjs_1.default)(),
|
|
242
203
|
},
|
|
243
|
-
}), formData =
|
|
244
|
-
var
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
var referenceIdentifierType = form.getFieldValue(["invoice", "referenceIdentifiers"]);
|
|
255
|
-
return ((_a = referenceIdentifierType[0]) === null || _a === void 0 ? void 0 : _a.code) ? !((_b = referenceIdentifierType[0]) === null || _b === void 0 ? void 0 : _b.value) : false;
|
|
256
|
-
};
|
|
257
|
-
return [4 /*yield*/, form.validateFields(fieldPaths, { validateOnly: validateOnly || true })
|
|
258
|
-
.then(function () {
|
|
259
|
-
var _a;
|
|
260
|
-
var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
|
|
261
|
-
var noInvoiceLines = invoiceLines.length <= 1 && ((_a = invoiceLines[0]) === null || _a === void 0 ? void 0 : _a.editing) === true;
|
|
262
|
-
if (activeStep === 2 && noInvoiceLines) {
|
|
263
|
-
setIsNextStepDisabled(true);
|
|
264
|
-
setMissingRequiredDataTooltip(react_1.default.createElement(react_1.default.Fragment, null, props.intl.formatMessage(exports.translationMessages.createInvoice_addDocumentLineMsg)));
|
|
265
|
-
}
|
|
266
|
-
else if (activeStep === 2 && isMultipleReferenceIdentifier && someRequiredFieldsEmpty()) {
|
|
267
|
-
setIsNextStepDisabled(true);
|
|
268
|
-
setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
|
|
269
|
-
}
|
|
270
|
-
else if (activeStep === 2 && isSingleReferenceIdentifier && referenceIdentifierIsMandatory && !form.getFieldValue(["invoice", "singleReferenceIdentifier", "value"])) {
|
|
271
|
-
setIsNextStepDisabled(true);
|
|
272
|
-
setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
|
|
273
|
-
}
|
|
274
|
-
else if (activeStep === 2 && referenceIdentifierValidateStatus === "error") {
|
|
275
|
-
setIsNextStepDisabled(true);
|
|
276
|
-
setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierNotValid));
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
setIsNextStepDisabled(false);
|
|
280
|
-
setMissingRequiredDataTooltip(undefined);
|
|
281
|
-
}
|
|
282
|
-
})
|
|
283
|
-
.catch(function (error) {
|
|
284
|
-
var _a;
|
|
285
|
-
var requiredFields = [];
|
|
286
|
-
(_a = error === null || error === void 0 ? void 0 : error.errorFields) === null || _a === void 0 ? void 0 : _a.map(function (errorField) {
|
|
287
|
-
var _a;
|
|
288
|
-
requiredFields.push(errorField.name[((_a = errorField === null || errorField === void 0 ? void 0 : errorField.name) === null || _a === void 0 ? void 0 : _a.length) - 1]);
|
|
289
|
-
});
|
|
290
|
-
if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.length) > 0) {
|
|
291
|
-
var names = getFieldNames(requiredFields);
|
|
292
|
-
setMissingRequiredDataTooltip((0, RequirementsUtility_1.getRequiredTooltipMessage)(props.intl.formatMessage(CommonTranslations_1.commonTranslationMessages.missingRequiredData), names));
|
|
293
|
-
}
|
|
294
|
-
setIsNextStepDisabled(true);
|
|
295
|
-
})];
|
|
296
|
-
case 1:
|
|
297
|
-
_a.sent();
|
|
298
|
-
return [2 /*return*/];
|
|
204
|
+
}), formData = _1[0], setFormData = _1[1];
|
|
205
|
+
var values = antd_1.Form.useWatch([], form);
|
|
206
|
+
(0, react_1.useEffect)(function () {
|
|
207
|
+
switch (activeStep) {
|
|
208
|
+
case 0: {
|
|
209
|
+
form.validateFields(formPaths_1.customerFieldPaths, { validateOnly: true })
|
|
210
|
+
.then(function () { return setIsNextStepDisabled(false); })
|
|
211
|
+
.catch(function (error) {
|
|
212
|
+
(0, ValidationUtility_1.handleValidationErrors)(error, setMissingRequiredDataTooltip, setIsNextStepDisabled, intl);
|
|
213
|
+
});
|
|
214
|
+
break;
|
|
299
215
|
}
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return props.intl.formatMessage(supplier_1.translationMessages.supplier_address_streetNameAndNumber);
|
|
311
|
-
case "postalZone":
|
|
312
|
-
return props.intl.formatMessage(supplier_1.translationMessages.supplier_address_zip_postalCode);
|
|
313
|
-
case "vatNumber":
|
|
314
|
-
return props.intl.formatMessage(supplier_1.translationMessages.supplier_vatNumber);
|
|
315
|
-
case "invoiceNo":
|
|
316
|
-
return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_invoiceNo);
|
|
317
|
-
case "issueDate":
|
|
318
|
-
return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_issueDate);
|
|
319
|
-
case "dueDate":
|
|
320
|
-
return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_dueDate);
|
|
321
|
-
case "buyerReference":
|
|
322
|
-
return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_buyerReferenceLabel);
|
|
323
|
-
case "accountTypeNumber":
|
|
324
|
-
return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountType);
|
|
325
|
-
case "accountNumber":
|
|
326
|
-
return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountNo);
|
|
327
|
-
case "bankNumber":
|
|
328
|
-
return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_icelandicClaim_bankNo);
|
|
329
|
-
case "value": // singleReferenceIdentifier
|
|
330
|
-
return intl.formatMessage(base_information_1.translationMessages.baseInformation_objectIdentifier);
|
|
331
|
-
case "documentNo":
|
|
332
|
-
return intl.formatMessage(base_information_1.translationMessages.baseInformation_projectReference);
|
|
333
|
-
default:
|
|
334
|
-
return "";
|
|
216
|
+
case 1: {
|
|
217
|
+
form.validateFields(__spreadArray(__spreadArray([], formPaths_1.supplierFieldPaths, true), [!outsideVatScope ? formPaths_1.vatNoFieldPath : []], false), { validateOnly: true })
|
|
218
|
+
.then(function () {
|
|
219
|
+
setIsNextStepDisabled(false);
|
|
220
|
+
setMissingRequiredDataTooltip(undefined);
|
|
221
|
+
})
|
|
222
|
+
.catch(function (error) {
|
|
223
|
+
(0, ValidationUtility_1.handleValidationErrors)(error, setMissingRequiredDataTooltip, setIsNextStepDisabled, intl);
|
|
224
|
+
});
|
|
225
|
+
break;
|
|
335
226
|
}
|
|
336
|
-
|
|
337
|
-
|
|
227
|
+
case 2: {
|
|
228
|
+
form.validateFields(formPaths_1.invoiceFieldPaths, { validateOnly: true })
|
|
229
|
+
.then(function () {
|
|
230
|
+
(0, ValidationUtility_1.validateInvoiceFieldsWithoutRules)(form, props.receiverRequirements, setMissingRequiredDataTooltip, setIsNextStepDisabled, referenceIdentifierIsMandatory, referenceIdentifierValidateStatus, intl);
|
|
231
|
+
var billingLineValidationMessage = (0, ValidationUtility_1.validateBillingLines)(form, setIsNextStepDisabled, intl);
|
|
232
|
+
setMissingRequiredDataTooltip(billingLineValidationMessage);
|
|
233
|
+
})
|
|
234
|
+
.catch(function (error) {
|
|
235
|
+
var billingLineValidationMessage = (0, ValidationUtility_1.validateBillingLines)(form, setIsNextStepDisabled, intl);
|
|
236
|
+
(0, ValidationUtility_1.handleValidationErrors)(error, setMissingRequiredDataTooltip, setIsNextStepDisabled, intl, billingLineValidationMessage ? [billingLineValidationMessage] : undefined);
|
|
237
|
+
});
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
case 3: {
|
|
241
|
+
form.validateFields(formPaths_1.paymentMeansFieldPaths, { validateOnly: true })
|
|
242
|
+
.then(function () { return setIsNextStepDisabled(false); })
|
|
243
|
+
.catch(function (error) {
|
|
244
|
+
(0, ValidationUtility_1.handleValidationErrors)(error, setMissingRequiredDataTooltip, setIsNextStepDisabled, intl);
|
|
245
|
+
});
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
default: {
|
|
249
|
+
setIsNextStepDisabled(false);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}, [form, values, activeStep, newLineSaved, referenceIdentifierValidateStatus]);
|
|
338
254
|
var saveFieldValuesToLocalStorage = function () {
|
|
339
255
|
var flatFields = form.getFieldsValue();
|
|
340
256
|
delete flatFields.attachments;
|
|
@@ -385,7 +301,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
385
301
|
setSupplierEmail(form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]));
|
|
386
302
|
}, [form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"])]);
|
|
387
303
|
(0, react_1.useEffect)(function () {
|
|
388
|
-
setOutsideVatScope(form.getFieldValue(["outsideVatScope"]));
|
|
304
|
+
setOutsideVatScope(!!form.getFieldValue(["outsideVatScope"]));
|
|
389
305
|
}, [form.getFieldValue(["outsideVatScope"])]);
|
|
390
306
|
(0, react_1.useEffect)(function () {
|
|
391
307
|
setIsSubmitDisabled(!captchaVerified);
|
|
@@ -434,7 +350,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
434
350
|
setSendCopyDisabled(true);
|
|
435
351
|
}
|
|
436
352
|
}, [supplierEmail]);
|
|
437
|
-
var handleSubmit = function (
|
|
353
|
+
var handleSubmit = function (_values) {
|
|
438
354
|
var _a, _b, _c, _d, _e, _f;
|
|
439
355
|
setSubmitting(true);
|
|
440
356
|
if (referenceIdentifierValidateStatus !== "" && referenceIdentifierValidateStatus !== "success") {
|
|
@@ -443,9 +359,9 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
443
359
|
return;
|
|
444
360
|
}
|
|
445
361
|
var attachments = [
|
|
446
|
-
((_a =
|
|
447
|
-
((_c =
|
|
448
|
-
((_e =
|
|
362
|
+
((_a = _values.attachments) === null || _a === void 0 ? void 0 : _a.file1) && ((_b = _values.attachments) === null || _b === void 0 ? void 0 : _b.file1),
|
|
363
|
+
((_c = _values.attachments) === null || _c === void 0 ? void 0 : _c.file2) && ((_d = _values.attachments) === null || _d === void 0 ? void 0 : _d.file2),
|
|
364
|
+
((_e = _values.attachments) === null || _e === void 0 ? void 0 : _e.file3) && ((_f = _values.attachments) === null || _f === void 0 ? void 0 : _f.file3),
|
|
449
365
|
];
|
|
450
366
|
// Clear the array of undefined
|
|
451
367
|
attachments = attachments.filter(function (attachment) { return attachment && attachment.file; });
|
|
@@ -458,7 +374,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
458
374
|
var services = sendCopy
|
|
459
375
|
? ["urn:services:dispatcher:mail.pdf?email=".concat(supplierEmail, "#$#lang=").concat(props.language)]
|
|
460
376
|
: undefined;
|
|
461
|
-
var invoiceMetadataInput = (0, utils_1.convertToInvoiceMetadataInput)(
|
|
377
|
+
var invoiceMetadataInput = (0, utils_1.convertToInvoiceMetadataInput)(_values, (0, BillingLineUtility_1.billingLinesFieldsMetadata)(form), (0, paymentMethodForConversion_1.PaymentMethodFormData)(_values), chosenCustomer);
|
|
462
378
|
var createSubmitInvoice = {
|
|
463
379
|
invoiceMetadataInput: invoiceMetadataInput,
|
|
464
380
|
more: attachments.length > 0,
|
|
@@ -489,11 +405,11 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
489
405
|
},
|
|
490
406
|
{
|
|
491
407
|
name: ["invoice", "supplier"],
|
|
492
|
-
value:
|
|
408
|
+
value: _values.invoice.supplier,
|
|
493
409
|
},
|
|
494
410
|
{
|
|
495
411
|
name: ["outsideVatScope"],
|
|
496
|
-
value: !
|
|
412
|
+
value: !_values.invoice.supplier.vatNumber,
|
|
497
413
|
},
|
|
498
414
|
{
|
|
499
415
|
name: ["attachments"],
|
|
@@ -601,7 +517,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
601
517
|
name: defaultCustomer.name,
|
|
602
518
|
});
|
|
603
519
|
}
|
|
604
|
-
var
|
|
520
|
+
var _2 = (0, react_1.useState)(undefined), billingLinesMetadata = _2[0], setBillingLinesMetadata = _2[1];
|
|
605
521
|
var getBillingLines = function (changedValues, allValues) {
|
|
606
522
|
var invoiceLines = allValues.invoice.invoiceLines;
|
|
607
523
|
if (invoiceLines) {
|
|
@@ -665,22 +581,22 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
665
581
|
react_1.default.createElement(antd_1.Form.Item, { name: ["invoice", "currencyCode"], hidden: true }),
|
|
666
582
|
react_1.default.createElement(antd_1.Flex, { gap: "middle", vertical: true },
|
|
667
583
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 0 ? { display: "none" } : {} },
|
|
668
|
-
react_1.default.createElement(components_1.Customer, { receiverRequirements: props.receiverRequirements, formInstance: form, customers: props.customers, chosenCustomer: chosenCustomer, setChosenCustomer: setChosenCustomer, rapiBaseUrl: props.rapiBaseUrl, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp,
|
|
584
|
+
react_1.default.createElement(components_1.Customer, { receiverRequirements: props.receiverRequirements, formInstance: form, customers: props.customers, chosenCustomer: chosenCustomer, setChosenCustomer: setChosenCustomer, rapiBaseUrl: props.rapiBaseUrl, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
|
|
669
585
|
return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
|
|
670
|
-
}
|
|
586
|
+
} })),
|
|
671
587
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 1 ? { display: "none" } : {} },
|
|
672
|
-
react_1.default.createElement(components_1.Supplier, { receiverRequirements: props.receiverRequirements, rapiBaseUrl: props.rapiBaseUrl, rapiApiKey: props.rapiApiKey, form: form, outsideVatScope: outsideVatScope, setOutsideVatScope: setOutsideVatScope, isMobile: isMobile,
|
|
588
|
+
react_1.default.createElement(components_1.Supplier, { receiverRequirements: props.receiverRequirements, rapiBaseUrl: props.rapiBaseUrl, rapiApiKey: props.rapiApiKey, form: form, outsideVatScope: outsideVatScope, setOutsideVatScope: setOutsideVatScope, isMobile: isMobile, onSaveFieldValues: saveFieldValuesToLocalStorage, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
|
|
673
589
|
return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
|
|
674
|
-
}
|
|
590
|
+
} }),
|
|
675
591
|
" "),
|
|
676
592
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 2 ? { display: "none" } : {} },
|
|
677
|
-
react_1.default.createElement(components_1.Invoice, { receiverRequirements: props.receiverRequirements, form: form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: chosenCustomer.identifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: referenceIdentifierValidateStatus, chosenCustomer: chosenCustomer, setReferenceIdentifierValidateStatus: setReferenceIdentifierValidateStatus, dueDateMinimumOffset: props.dueDateMinimumOffset, billingLinesMetadata: billingLinesMetadata, outsideVatScope: outsideVatScope, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.language,
|
|
593
|
+
react_1.default.createElement(components_1.Invoice, { receiverRequirements: props.receiverRequirements, form: form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: chosenCustomer.identifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: referenceIdentifierValidateStatus, chosenCustomer: chosenCustomer, setReferenceIdentifierValidateStatus: setReferenceIdentifierValidateStatus, dueDateMinimumOffset: props.dueDateMinimumOffset, billingLinesMetadata: billingLinesMetadata, outsideVatScope: outsideVatScope, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.language, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
|
|
678
594
|
return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
|
|
679
|
-
},
|
|
595
|
+
}, setReferenceIdentifierIsMandatory: setReferenceIdentifierIsMandatory, newLineSaved: newLineSaved, setNewLineSaved: setNewLineSaved })),
|
|
680
596
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 3 ? { display: "none" } : {} },
|
|
681
|
-
react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form,
|
|
597
|
+
react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
|
|
682
598
|
return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
|
|
683
|
-
}
|
|
599
|
+
} })),
|
|
684
600
|
activeStep === items.length && (react_1.default.createElement(components_1.InvoicePreview, { recieverRequirements: props.receiverRequirements, form: form, chosenCustomer: chosenCustomer })),
|
|
685
601
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== items.length ? { display: "none" } : {} },
|
|
686
602
|
react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "center" },
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"billingLines_currency_SEK_short": "SEK",
|
|
55
55
|
"billingLines_currency_USD": "US dollar (USD)",
|
|
56
56
|
"billingLines_currency_USD_short": "USD",
|
|
57
|
-
"billingLines_discount": "
|
|
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
59
|
"billingLines_each": "each",
|
|
60
60
|
"billingLines_input_must_be_number_validationMessage": "Input must be a number",
|
|
@@ -265,14 +265,17 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
265
265
|
setMissingRequiredDataTooltip(react_1.default.createElement(react_1.default.Fragment, null, props.intl.formatMessage(exports.translationMessages.createInvoice_addDocumentLineMsg)));
|
|
266
266
|
}
|
|
267
267
|
else if (activeStep === 2 && isMultipleReferenceIdentifier && someRequiredFieldsEmpty()) {
|
|
268
|
+
console.log("Uso za multiple")
|
|
268
269
|
setIsNextStepDisabled(true);
|
|
269
270
|
setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
|
|
270
271
|
}
|
|
271
272
|
else if (activeStep === 2 && isSingleReferenceIdentifier && referenceIdentifierIsMandatory && !form.getFieldValue(["invoice", "singleReferenceIdentifier", "value"])) {
|
|
273
|
+
console.log("uso za single")
|
|
272
274
|
setIsNextStepDisabled(true);
|
|
273
275
|
setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
|
|
274
276
|
}
|
|
275
277
|
else if (activeStep === 2 && referenceIdentifierValidateStatus === "error") {
|
|
278
|
+
console.log("uso za error")
|
|
276
279
|
setIsNextStepDisabled(true);
|
|
277
280
|
setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierNotValid));
|
|
278
281
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { IntlShape } from "react-intl";
|
|
3
|
+
import { FormInstance } from "antd/es/form";
|
|
4
|
+
import { NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
|
|
5
|
+
import { ValidateStatus } from "antd/lib/form/FormItem";
|
|
6
|
+
declare const handleValidationErrors: (error: any, setMissingRequiredDataTooltip: (tooltip: ReactNode) => void, setIsNextStepDisabled: (isNextStepDisabled: boolean) => void, intl: IntlShape, additionalErrorMessages?: string[]) => void;
|
|
7
|
+
declare const validateInvoiceFieldsWithoutRules: (form: FormInstance, receiverRequirements: NewReceiverRequirements, setMissingRequiredDataTooltip: (tooltip: ReactNode) => void, setIsNextStepDisabled: (isNextStepDisabled: boolean) => void, referenceIdentifierIsMandatory: boolean, referenceIdentifierValidateStatus: ValidateStatus, intl: IntlShape) => void;
|
|
8
|
+
declare const validateBillingLines: (form: FormInstance, setIsNextStepDisabled: (isNextStepDisabled: boolean) => void, intl: IntlShape) => string;
|
|
9
|
+
export { handleValidationErrors, validateBillingLines, validateInvoiceFieldsWithoutRules };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.validateInvoiceFieldsWithoutRules = exports.validateBillingLines = exports.handleValidationErrors = void 0;
|
|
13
|
+
var RequirementsUtility_1 = require("./RequirementsUtility");
|
|
14
|
+
var CommonTranslations_1 = require("../common/components/CommonTranslations");
|
|
15
|
+
var ReferenceIdentifierUtility_1 = require("./ReferenceIdentifierUtility");
|
|
16
|
+
var create_invoice_1 = require("../create-invoice");
|
|
17
|
+
var supplier_1 = require("../common/components/supplier");
|
|
18
|
+
var base_information_1 = require("../common/components/base-information");
|
|
19
|
+
var payment_method_1 = require("../common/components/payment-method");
|
|
20
|
+
var CostCenter_1 = require("../common/components/customer/CostCenter");
|
|
21
|
+
var handleValidationErrors = function (error, setMissingRequiredDataTooltip, setIsNextStepDisabled, intl, additionalErrorMessages) {
|
|
22
|
+
var _a;
|
|
23
|
+
var requiredFields = [];
|
|
24
|
+
(_a = error === null || error === void 0 ? void 0 : error.errorFields) === null || _a === void 0 ? void 0 : _a.map(function (errorField) {
|
|
25
|
+
var _a;
|
|
26
|
+
requiredFields.push(errorField.name[((_a = errorField === null || errorField === void 0 ? void 0 : errorField.name) === null || _a === void 0 ? void 0 : _a.length) - 1]);
|
|
27
|
+
});
|
|
28
|
+
if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.length) > 0) {
|
|
29
|
+
var names = getFieldNames(requiredFields, intl);
|
|
30
|
+
var includeAdditionalErrorMessages = additionalErrorMessages && additionalErrorMessages.length > 0 ? __spreadArray(__spreadArray([], names, true), additionalErrorMessages, true) : names;
|
|
31
|
+
setMissingRequiredDataTooltip((0, RequirementsUtility_1.getRequiredTooltipMessage)(intl.formatMessage(CommonTranslations_1.commonTranslationMessages.missingRequiredData), includeAdditionalErrorMessages));
|
|
32
|
+
setIsNextStepDisabled(true);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.handleValidationErrors = handleValidationErrors;
|
|
36
|
+
var validateInvoiceFieldsWithoutRules = function (form, receiverRequirements, setMissingRequiredDataTooltip, setIsNextStepDisabled, referenceIdentifierIsMandatory, referenceIdentifierValidateStatus, intl) {
|
|
37
|
+
var referenceIdentifiersDefinitions = (0, ReferenceIdentifierUtility_1.getReferenceIdentifierFieldDefinitions)(receiverRequirements);
|
|
38
|
+
var isSingleReferenceIdentifier = (referenceIdentifiersDefinitions === null || referenceIdentifiersDefinitions === void 0 ? void 0 : referenceIdentifiersDefinitions.length) === 1;
|
|
39
|
+
var isMultipleReferenceIdentifier = (referenceIdentifiersDefinitions === null || referenceIdentifiersDefinitions === void 0 ? void 0 : referenceIdentifiersDefinitions.length) > 1;
|
|
40
|
+
var someRequiredFieldsEmpty = function () {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
var referenceIdentifierType = form.getFieldValue(["invoice", "referenceIdentifiers"]);
|
|
43
|
+
return ((_a = referenceIdentifierType[0]) === null || _a === void 0 ? void 0 : _a.code) ? !((_b = referenceIdentifierType[0]) === null || _b === void 0 ? void 0 : _b.value) : false;
|
|
44
|
+
};
|
|
45
|
+
var objectIdentifierIsRequiredAction = function () {
|
|
46
|
+
setIsNextStepDisabled(true);
|
|
47
|
+
setMissingRequiredDataTooltip(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
|
|
48
|
+
};
|
|
49
|
+
if (isMultipleReferenceIdentifier && someRequiredFieldsEmpty()) {
|
|
50
|
+
objectIdentifierIsRequiredAction();
|
|
51
|
+
}
|
|
52
|
+
else if (isSingleReferenceIdentifier && referenceIdentifierIsMandatory && !form.getFieldValue(["invoice", "singleReferenceIdentifier", "value"])) {
|
|
53
|
+
objectIdentifierIsRequiredAction();
|
|
54
|
+
}
|
|
55
|
+
else if (referenceIdentifierValidateStatus === "error") {
|
|
56
|
+
setIsNextStepDisabled(true);
|
|
57
|
+
setMissingRequiredDataTooltip(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_validationErrorObjectIdentifierNotValid));
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
setIsNextStepDisabled(false);
|
|
61
|
+
setMissingRequiredDataTooltip(undefined);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
exports.validateInvoiceFieldsWithoutRules = validateInvoiceFieldsWithoutRules;
|
|
65
|
+
var validateBillingLines = function (form, setIsNextStepDisabled, intl) {
|
|
66
|
+
var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
|
|
67
|
+
var noInvoiceLines = invoiceLines.length === 0;
|
|
68
|
+
if (noInvoiceLines) {
|
|
69
|
+
setIsNextStepDisabled(true);
|
|
70
|
+
return intl.formatMessage(create_invoice_1.translationMessages.createInvoice_addDocumentLineMsg);
|
|
71
|
+
}
|
|
72
|
+
return undefined;
|
|
73
|
+
};
|
|
74
|
+
exports.validateBillingLines = validateBillingLines;
|
|
75
|
+
var getFieldNames = function (keys, intl) {
|
|
76
|
+
return keys === null || keys === void 0 ? void 0 : keys.map(function (key) {
|
|
77
|
+
switch (key) {
|
|
78
|
+
case "identifier":
|
|
79
|
+
return intl.formatMessage(supplier_1.translationMessages.supplier_identifier);
|
|
80
|
+
case "name":
|
|
81
|
+
return intl.formatMessage(supplier_1.translationMessages.supplier_name);
|
|
82
|
+
case "streetNameAndNumber":
|
|
83
|
+
return intl.formatMessage(supplier_1.translationMessages.supplier_address_streetNameAndNumber);
|
|
84
|
+
case "postalZone":
|
|
85
|
+
return intl.formatMessage(supplier_1.translationMessages.supplier_address_zip_postalCode);
|
|
86
|
+
case "vatNumber":
|
|
87
|
+
return intl.formatMessage(supplier_1.translationMessages.supplier_vatNumber);
|
|
88
|
+
case "invoiceNo":
|
|
89
|
+
return intl.formatMessage(base_information_1.translationMessages.baseInformation_invoiceNo);
|
|
90
|
+
case "issueDate":
|
|
91
|
+
return intl.formatMessage(base_information_1.translationMessages.baseInformation_issueDate);
|
|
92
|
+
case "dueDate":
|
|
93
|
+
return intl.formatMessage(base_information_1.translationMessages.baseInformation_dueDate);
|
|
94
|
+
case "buyerReference":
|
|
95
|
+
return intl.formatMessage(base_information_1.translationMessages.baseInformation_buyerReferenceLabel);
|
|
96
|
+
case "accountTypeNumber":
|
|
97
|
+
return intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountType);
|
|
98
|
+
case "accountNumber":
|
|
99
|
+
return intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountNo);
|
|
100
|
+
case "bankNumber":
|
|
101
|
+
return intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_icelandicClaim_bankNo);
|
|
102
|
+
case "value": // singleReferenceIdentifier
|
|
103
|
+
return intl.formatMessage(base_information_1.translationMessages.baseInformation_objectIdentifier);
|
|
104
|
+
case "documentNo":
|
|
105
|
+
return intl.formatMessage(base_information_1.translationMessages.baseInformation_projectReference);
|
|
106
|
+
case "locationIdentifier":
|
|
107
|
+
return intl.formatMessage(CostCenter_1.translationMessages.baseInformation_costCenter);
|
|
108
|
+
default:
|
|
109
|
+
return key;
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
};
|