@unimaze/billing 0.21.19 → 0.21.20
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.
|
@@ -67,6 +67,9 @@ var dayjs_1 = __importDefault(require("dayjs"));
|
|
|
67
67
|
require("../common/style/index.css");
|
|
68
68
|
var formPaths_1 = require("../common/consts/formPaths");
|
|
69
69
|
var ValidationUtility_1 = require("../utils/ValidationUtility");
|
|
70
|
+
var ReferenceIdentifierUtility_1 = require("../utils/ReferenceIdentifierUtility");
|
|
71
|
+
var RequirementsUtility_1 = require("../utils/RequirementsUtility");
|
|
72
|
+
var CommonTranslations_1 = require("../common/components/CommonTranslations");
|
|
70
73
|
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
71
74
|
createInvoice_addDocumentLineMsg: {
|
|
72
75
|
id: "createInvoice_addDocumentLineMsg",
|
|
@@ -203,7 +206,20 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
203
206
|
},
|
|
204
207
|
}), formData = _1[0], setFormData = _1[1];
|
|
205
208
|
var values = antd_1.Form.useWatch([], form);
|
|
209
|
+
var validateBillingLinesAndRefIdentifierField = function (isMultipleReferenceIdentifier, isSingleReferenceIdentifier, someRequiredFieldsEmpty) {
|
|
210
|
+
var validationErrors = (0, ValidationUtility_1.validateInvoiceFieldsWithoutRules)(form, isMultipleReferenceIdentifier, isSingleReferenceIdentifier, someRequiredFieldsEmpty, setIsNextStepDisabled, referenceIdentifierIsMandatory, referenceIdentifierValidateStatus, intl);
|
|
211
|
+
var billingLineValidationMessage = (0, ValidationUtility_1.validateBillingLines)(form, setIsNextStepDisabled, intl);
|
|
212
|
+
return [validationErrors, billingLineValidationMessage];
|
|
213
|
+
};
|
|
206
214
|
(0, react_1.useEffect)(function () {
|
|
215
|
+
var referenceIdentifiersDefinitions = (0, ReferenceIdentifierUtility_1.getReferenceIdentifierFieldDefinitions)(props.receiverRequirements);
|
|
216
|
+
var isSingleReferenceIdentifier = (referenceIdentifiersDefinitions === null || referenceIdentifiersDefinitions === void 0 ? void 0 : referenceIdentifiersDefinitions.length) === 1;
|
|
217
|
+
var isMultipleReferenceIdentifier = (referenceIdentifiersDefinitions === null || referenceIdentifiersDefinitions === void 0 ? void 0 : referenceIdentifiersDefinitions.length) > 1;
|
|
218
|
+
var someRequiredFieldsEmpty = function () {
|
|
219
|
+
var _a, _b;
|
|
220
|
+
var referenceIdentifierType = form.getFieldValue(["invoice", "referenceIdentifiers"]);
|
|
221
|
+
return ((_a = referenceIdentifierType[0]) === null || _a === void 0 ? void 0 : _a.code) ? !((_b = referenceIdentifierType[0]) === null || _b === void 0 ? void 0 : _b.value) : false;
|
|
222
|
+
};
|
|
207
223
|
switch (activeStep) {
|
|
208
224
|
case 0: {
|
|
209
225
|
form.validateFields(formPaths_1.customerFieldPaths, { validateOnly: true })
|
|
@@ -227,13 +243,12 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
227
243
|
case 2: {
|
|
228
244
|
form.validateFields(formPaths_1.invoiceFieldPaths, { validateOnly: true })
|
|
229
245
|
.then(function () {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
setMissingRequiredDataTooltip(billingLineValidationMessage);
|
|
246
|
+
var additionalValidationMessages = validateBillingLinesAndRefIdentifierField(isMultipleReferenceIdentifier, isSingleReferenceIdentifier, someRequiredFieldsEmpty);
|
|
247
|
+
additionalValidationMessages.filter(function (messageEntry) { return messageEntry !== undefined; }).length > 0 ? setMissingRequiredDataTooltip((0, RequirementsUtility_1.getRequiredTooltipMessage)(intl.formatMessage(CommonTranslations_1.commonTranslationMessages.missingRequiredData), additionalValidationMessages)) : setMissingRequiredDataTooltip(undefined);
|
|
233
248
|
})
|
|
234
249
|
.catch(function (error) {
|
|
235
|
-
var
|
|
236
|
-
(0, ValidationUtility_1.handleValidationErrors)(error, setMissingRequiredDataTooltip, setIsNextStepDisabled, intl,
|
|
250
|
+
var additionalValidationMessages = validateBillingLinesAndRefIdentifierField(isMultipleReferenceIdentifier, isSingleReferenceIdentifier, someRequiredFieldsEmpty);
|
|
251
|
+
(0, ValidationUtility_1.handleValidationErrors)(error, setMissingRequiredDataTooltip, setIsNextStepDisabled, intl, additionalValidationMessages);
|
|
237
252
|
});
|
|
238
253
|
break;
|
|
239
254
|
}
|
|
@@ -183,7 +183,7 @@ var getRequiredTooltipMessage = function (title, fieldNames) {
|
|
|
183
183
|
react_1.default.createElement(antd_1.Row, null, title),
|
|
184
184
|
react_1.default.createElement(antd_1.Row, { wrap: false },
|
|
185
185
|
react_1.default.createElement("div", { className: "flex_direction_column", style: { minWidth: "100px" } },
|
|
186
|
-
react_1.default.createElement("ul", { style: { paddingLeft: "20px" } }, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.map(function (fieldName) { return react_1.default.createElement("li", null, fieldName); }))))));
|
|
186
|
+
react_1.default.createElement("ul", { style: { paddingLeft: "20px" } }, fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.map(function (fieldName) { return fieldName ? react_1.default.createElement("li", null, fieldName) : undefined; }))))));
|
|
187
187
|
};
|
|
188
188
|
exports.getRequiredTooltipMessage = getRequiredTooltipMessage;
|
|
189
189
|
var paymentMeansTypeFieldHasValues = function (paymentMeansTypeFieldDefinition) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { IntlShape } from "react-intl";
|
|
3
3
|
import { FormInstance } from "antd/es/form";
|
|
4
|
-
import { NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
|
|
5
4
|
import { ValidateStatus } from "antd/lib/form/FormItem";
|
|
6
5
|
declare const handleValidationErrors: (error: any, setMissingRequiredDataTooltip: (tooltip: ReactNode) => void, setIsNextStepDisabled: (isNextStepDisabled: boolean) => void, intl: IntlShape, additionalErrorMessages?: string[]) => void;
|
|
7
|
-
declare const validateInvoiceFieldsWithoutRules: (form: FormInstance,
|
|
6
|
+
declare const validateInvoiceFieldsWithoutRules: (form: FormInstance, isMultipleReferenceIdentifier: boolean, isSingleReferenceIdentifier: boolean, someRequiredFieldsEmpty: () => boolean, setIsNextStepDisabled: (isNextStepDisabled: boolean) => void, referenceIdentifierIsMandatory: boolean, referenceIdentifierValidateStatus: ValidateStatus, intl: IntlShape) => string;
|
|
8
7
|
declare const validateBillingLines: (form: FormInstance, setIsNextStepDisabled: (isNextStepDisabled: boolean) => void, intl: IntlShape) => string;
|
|
9
8
|
export { handleValidationErrors, validateBillingLines, validateInvoiceFieldsWithoutRules };
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.validateInvoiceFieldsWithoutRules = exports.validateBillingLines = exports.handleValidationErrors = void 0;
|
|
13
13
|
var RequirementsUtility_1 = require("./RequirementsUtility");
|
|
14
14
|
var CommonTranslations_1 = require("../common/components/CommonTranslations");
|
|
15
|
-
var ReferenceIdentifierUtility_1 = require("./ReferenceIdentifierUtility");
|
|
16
15
|
var create_invoice_1 = require("../create-invoice");
|
|
17
16
|
var supplier_1 = require("../common/components/supplier");
|
|
18
17
|
var base_information_1 = require("../common/components/base-information");
|
|
@@ -33,32 +32,23 @@ var handleValidationErrors = function (error, setMissingRequiredDataTooltip, set
|
|
|
33
32
|
}
|
|
34
33
|
};
|
|
35
34
|
exports.handleValidationErrors = handleValidationErrors;
|
|
36
|
-
var validateInvoiceFieldsWithoutRules = function (form,
|
|
37
|
-
var
|
|
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
|
-
};
|
|
35
|
+
var validateInvoiceFieldsWithoutRules = function (form, isMultipleReferenceIdentifier, isSingleReferenceIdentifier, someRequiredFieldsEmpty, setIsNextStepDisabled, referenceIdentifierIsMandatory, referenceIdentifierValidateStatus, intl) {
|
|
36
|
+
var objectIdentifierValidationField = intl.formatMessage(base_information_1.translationMessages.baseInformation_objectIdentifier);
|
|
49
37
|
if (isMultipleReferenceIdentifier && someRequiredFieldsEmpty()) {
|
|
50
|
-
|
|
38
|
+
setIsNextStepDisabled(true);
|
|
39
|
+
return objectIdentifierValidationField;
|
|
51
40
|
}
|
|
52
41
|
else if (isSingleReferenceIdentifier && referenceIdentifierIsMandatory && !form.getFieldValue(["invoice", "singleReferenceIdentifier", "value"])) {
|
|
53
|
-
|
|
42
|
+
setIsNextStepDisabled(true);
|
|
43
|
+
return objectIdentifierValidationField;
|
|
54
44
|
}
|
|
55
45
|
else if (referenceIdentifierValidateStatus === "error") {
|
|
56
46
|
setIsNextStepDisabled(true);
|
|
57
|
-
|
|
47
|
+
return intl.formatMessage(create_invoice_1.translationMessages.createInvoice_validationErrorObjectIdentifierNotValid);
|
|
58
48
|
}
|
|
59
49
|
else {
|
|
60
50
|
setIsNextStepDisabled(false);
|
|
61
|
-
|
|
51
|
+
return undefined;
|
|
62
52
|
}
|
|
63
53
|
};
|
|
64
54
|
exports.validateInvoiceFieldsWithoutRules = validateInvoiceFieldsWithoutRules;
|