@unimaze/billing 0.21.63 → 0.21.65
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/customer/CostCenter.js +1 -1
- package/lib/common/components/submit-confirmation/AttachmentUploadStatus.js +0 -20
- package/lib/common/components/submit-confirmation/index.d.ts +67 -4
- package/lib/common/components/submit-confirmation/index.js +99 -30
- package/lib/create-invoice/index.d.ts +7 -0
- package/lib/create-invoice/index.js +46 -15
- package/lib/translations/locales/en.json +9 -0
- package/lib/translations/locales/is.json +9 -0
- package/lib/translations/locales.d.ts +18 -0
- package/lib/utils/ApiUtility.d.ts +2 -5
- package/lib/utils/ApiUtility.js +50 -9
- package/lib/utils/AttachmentsUtility.d.ts +1 -1
- package/lib/utils/AttachmentsUtility.js +5 -3
- package/lib/utils/RequirementsUtility.d.ts +1 -1
- package/lib/utils/RequirementsUtility.js +11 -5
- package/lib/utils/SubmitConfirmationUtility.d.ts +13 -0
- package/lib/utils/SubmitConfirmationUtility.js +87 -0
- package/package.json +1 -1
|
@@ -155,7 +155,7 @@ var CostCenter = function (props) {
|
|
|
155
155
|
var _c = (0, react_1.useState)(false), loadingCostCenterValues = _c[0], setLoadingCostCenterValues = _c[1];
|
|
156
156
|
var costCenterFieldDefinition = (0, RequirementsUtility_1.getFieldRequirements)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["customer.locationIdentifier"]);
|
|
157
157
|
if (costCenterFieldDefinition) {
|
|
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
|
+
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, true)));
|
|
159
159
|
}
|
|
160
160
|
else {
|
|
161
161
|
return null;
|
|
@@ -14,26 +14,6 @@ var SubmittingStatus;
|
|
|
14
14
|
SubmittingStatus["Done"] = "DONE";
|
|
15
15
|
SubmittingStatus["Failed"] = "FAILED";
|
|
16
16
|
})(SubmittingStatus = exports.SubmittingStatus || (exports.SubmittingStatus = {}));
|
|
17
|
-
// const getSubmittingStatusIcon = (_name: string, _numberOfSuccessCalls: number, _namesOfFailedUploads: string[], _attachments: string[]) => {
|
|
18
|
-
// const _index = _attachments.findIndex((att) => att === _name);
|
|
19
|
-
// if (_namesOfFailedUploads.includes(_name)) return <CloseCircleTwoTone twoToneColor={"red"} style={{marginRight: 5}}/>
|
|
20
|
-
// if (_index <= _numberOfSuccessCalls && !_namesOfFailedUploads.includes(_name)) return <CheckCircleTwoTone twoToneColor={"green"} style={{marginRight: 5}}/>
|
|
21
|
-
// if (_index < _numberOfSuccessCalls || _index > _numberOfSuccessCalls) return <LoadingOutlined style={{marginRight: 5}}/>
|
|
22
|
-
// }
|
|
23
|
-
// const SingleSubmittingStatus: React.FC<AttachmentUploadStatusProps> = (props) => {
|
|
24
|
-
//
|
|
25
|
-
// const {name, index, numberOfSuccessCalls, namesOfFailedUploads, attachments, otherNameForDisplay} = props;
|
|
26
|
-
//
|
|
27
|
-
// return <Flex gap={5} align={"center"}>
|
|
28
|
-
// <>{getSubmittingStatusIcon(name, numberOfSuccessCalls - 1, namesOfFailedUploads, attachments)}</>
|
|
29
|
-
// <Typography.Text>
|
|
30
|
-
// { otherNameForDisplay
|
|
31
|
-
// ? otherNameForDisplay
|
|
32
|
-
// : `${props.intl.formatMessage(translationMessages.submitConfirmation_SuccessfullyUploadedAttachment)} ${name}`
|
|
33
|
-
// }
|
|
34
|
-
// </Typography.Text>
|
|
35
|
-
// </Flex>
|
|
36
|
-
// };
|
|
37
17
|
var SingleSubmittingStatus = function (props) {
|
|
38
18
|
var name = props.name, status = props.status;
|
|
39
19
|
var iconStyle = {
|
|
@@ -1,11 +1,74 @@
|
|
|
1
|
-
import { FormInstance } from "antd";
|
|
2
1
|
import { WrappedComponentProps } from "react-intl";
|
|
3
2
|
import React from "react";
|
|
3
|
+
import { SubmittingStatus } from "./AttachmentUploadStatus";
|
|
4
|
+
import { AttachmentProps } from "../../../create-invoice";
|
|
4
5
|
interface Props extends WrappedComponentProps {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
numberOfAttemptedCalls: number;
|
|
7
|
+
retryUploadingFailedAttachments(_failedAttemptsIndexes: AttachmentProps[]): void;
|
|
8
|
+
retrySubmittingInvoice(): void;
|
|
9
|
+
alreadyRetried: boolean;
|
|
10
|
+
invoiceSubmittingStatus: SubmittingStatus;
|
|
11
|
+
allAttachments: any[];
|
|
12
|
+
allAttachmentsWithStatuses: AttachmentProps[];
|
|
8
13
|
}
|
|
14
|
+
export declare const translationMessages: {
|
|
15
|
+
submitConfirmation_title: {
|
|
16
|
+
id: string;
|
|
17
|
+
defaultMessage: string;
|
|
18
|
+
};
|
|
19
|
+
submitConfirmation_text: {
|
|
20
|
+
id: string;
|
|
21
|
+
defaultMessage: string;
|
|
22
|
+
};
|
|
23
|
+
submitConfirmation_footer_text: {
|
|
24
|
+
id: string;
|
|
25
|
+
defaultMessage: string;
|
|
26
|
+
};
|
|
27
|
+
submitConfirmation_successfullyCreatedInvoice: {
|
|
28
|
+
id: string;
|
|
29
|
+
defaultMessage: string;
|
|
30
|
+
};
|
|
31
|
+
submitConfirmation_SuccessfullyUploadedAttachment: {
|
|
32
|
+
id: string;
|
|
33
|
+
defaultMessage: string;
|
|
34
|
+
};
|
|
35
|
+
submitConfirmation_retryFailedAttachments: {
|
|
36
|
+
id: string;
|
|
37
|
+
defaultMessage: string;
|
|
38
|
+
};
|
|
39
|
+
submitConfirmation_retryButton: {
|
|
40
|
+
id: string;
|
|
41
|
+
defaultMessage: string;
|
|
42
|
+
};
|
|
43
|
+
submitConfirmation_submitWithFailedAttachmentsInfoMessage: {
|
|
44
|
+
id: string;
|
|
45
|
+
defaultMessage: string;
|
|
46
|
+
};
|
|
47
|
+
submitConfirmation_attachmentFailedToUpload: {
|
|
48
|
+
id: string;
|
|
49
|
+
defaultMessage: string;
|
|
50
|
+
};
|
|
51
|
+
submitConfirmation_successfullyUploadedAttachment: {
|
|
52
|
+
id: string;
|
|
53
|
+
defaultMessage: string;
|
|
54
|
+
};
|
|
55
|
+
submitConfirmation_submittingAttachment: {
|
|
56
|
+
id: string;
|
|
57
|
+
defaultMessage: string;
|
|
58
|
+
};
|
|
59
|
+
submitConfirmation_submittingInvoiceFailed: {
|
|
60
|
+
id: string;
|
|
61
|
+
defaultMessage: string;
|
|
62
|
+
};
|
|
63
|
+
submitConfirmation_submittingInvoiceSuccessful: {
|
|
64
|
+
id: string;
|
|
65
|
+
defaultMessage: string;
|
|
66
|
+
};
|
|
67
|
+
submitConfirmation_submittingInvoice: {
|
|
68
|
+
id: string;
|
|
69
|
+
defaultMessage: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
9
72
|
declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
|
|
10
73
|
forwardedRef?: React.Ref<any>;
|
|
11
74
|
} & React.RefAttributes<any>> & {
|
|
@@ -26,12 +26,15 @@ 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 antd_1 = require("antd");
|
|
30
31
|
var react_intl_1 = require("react-intl");
|
|
31
32
|
var react_1 = __importStar(require("react"));
|
|
32
33
|
var SubmitConfirmationSVG_1 = __importDefault(require("./SubmitConfirmationSVG"));
|
|
33
|
-
var
|
|
34
|
-
var
|
|
34
|
+
var AttachmentUploadStatus_1 = __importStar(require("./AttachmentUploadStatus"));
|
|
35
|
+
var AttachmentsUtility_1 = require("../../../utils/AttachmentsUtility");
|
|
36
|
+
var SubmitConfirmationUtility_1 = require("../../../utils/SubmitConfirmationUtility");
|
|
37
|
+
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
35
38
|
submitConfirmation_title: {
|
|
36
39
|
id: "submitConfirmation_title",
|
|
37
40
|
defaultMessage: "Invoice sent",
|
|
@@ -52,28 +55,73 @@ var translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
52
55
|
id: "submitConfirmation_SuccessfullyUploadedAttachment",
|
|
53
56
|
defaultMessage: "Successfully uploaded attachment:",
|
|
54
57
|
},
|
|
58
|
+
submitConfirmation_retryFailedAttachments: {
|
|
59
|
+
id: "submitConfirmation_retryFailedAttachments",
|
|
60
|
+
defaultMessage: "Retry failed attachments",
|
|
61
|
+
},
|
|
62
|
+
submitConfirmation_retryButton: {
|
|
63
|
+
id: "submitConfirmation_retryButton",
|
|
64
|
+
defaultMessage: "Retry",
|
|
65
|
+
},
|
|
66
|
+
submitConfirmation_submitWithFailedAttachmentsInfoMessage: {
|
|
67
|
+
id: "submitConfirmation_submitWithFailedAttachmentsInfoMessage",
|
|
68
|
+
defaultMessage: "Invoice will be delivered without failed attachments within 24 hours.",
|
|
69
|
+
},
|
|
70
|
+
submitConfirmation_attachmentFailedToUpload: {
|
|
71
|
+
id: "submitConfirmation_attachmentFailedToUpload",
|
|
72
|
+
defaultMessage: "Attachment failed to upload:",
|
|
73
|
+
},
|
|
74
|
+
submitConfirmation_successfullyUploadedAttachment: {
|
|
75
|
+
id: "submitConfirmation_successfullyUploadedAttachment",
|
|
76
|
+
defaultMessage: "Successfully uploaded attachment:",
|
|
77
|
+
},
|
|
78
|
+
submitConfirmation_submittingAttachment: {
|
|
79
|
+
id: "submitConfirmation_submittingAttachment",
|
|
80
|
+
defaultMessage: "Submitting attachment:",
|
|
81
|
+
},
|
|
82
|
+
submitConfirmation_submittingInvoiceFailed: {
|
|
83
|
+
id: "submitConfirmation_submittingInvoiceFailed",
|
|
84
|
+
defaultMessage: "Submitting invoice failed",
|
|
85
|
+
},
|
|
86
|
+
submitConfirmation_submittingInvoiceSuccessful: {
|
|
87
|
+
id: "submitConfirmation_submittingInvoiceSuccessful",
|
|
88
|
+
defaultMessage: "Successfully submitted invoice",
|
|
89
|
+
},
|
|
90
|
+
submitConfirmation_submittingInvoice: {
|
|
91
|
+
id: "submitConfirmation_submittingInvoice",
|
|
92
|
+
defaultMessage: "Submitting invoice...",
|
|
93
|
+
},
|
|
55
94
|
});
|
|
56
95
|
var SubmitConfirmation = function (props) {
|
|
57
|
-
var
|
|
58
|
-
var _a = (0, react_1.useState)(
|
|
96
|
+
var numberOfAttemptedCalls = props.numberOfAttemptedCalls, retryUploadingFailedAttachments = props.retryUploadingFailedAttachments, retrySubmittingInvoice = props.retrySubmittingInvoice, alreadyRetried = props.alreadyRetried, invoiceSubmittingStatus = props.invoiceSubmittingStatus, allAttachments = props.allAttachments, allAttachmentsWithStatuses = props.allAttachmentsWithStatuses;
|
|
97
|
+
var _a = (0, react_1.useState)(''), progressBarColor = _a[0], setProgressBarColor = _a[1];
|
|
98
|
+
var _b = (0, react_1.useState)(false), retryButtonVisible = _b[0], setRetryButtonVisible = _b[1];
|
|
99
|
+
var _c = (0, react_1.useState)(false), allAttachmentsUploadedSuccessfully = _c[0], setAllAttachmentsUploadedSuccessfully = _c[1];
|
|
59
100
|
var token = antd_1.theme.useToken().token;
|
|
60
|
-
var percentUnit = 100 /
|
|
101
|
+
var percentUnit = 100 / (allAttachments.length + 1);
|
|
61
102
|
(0, react_1.useEffect)(function () {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (((_a = attachments === null || attachments === void 0 ? void 0 : attachments.file1) === null || _a === void 0 ? void 0 : _a.description) || ((_b = attachments === null || attachments === void 0 ? void 0 : attachments.file2) === null || _b === void 0 ? void 0 : _b.description) || ((_c = attachments === null || attachments === void 0 ? void 0 : attachments.file3) === null || _c === void 0 ? void 0 : _c.description)) {
|
|
65
|
-
setAttachmentsNames([attachments.file1.description, (_d = attachments === null || attachments === void 0 ? void 0 : attachments.file2) === null || _d === void 0 ? void 0 : _d.description, (_e = attachments === null || attachments === void 0 ? void 0 : attachments.file3) === null || _e === void 0 ? void 0 : _e.description]);
|
|
103
|
+
if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed) {
|
|
104
|
+
setProgressBarColor('red');
|
|
66
105
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
106
|
+
else {
|
|
107
|
+
var numberOfSuccessfulAttachmentUploads = (0, SubmitConfirmationUtility_1.getNumberOfUploadedAttachments)(allAttachmentsWithStatuses);
|
|
108
|
+
var numberOfFailedAttachmentUploads = (0, SubmitConfirmationUtility_1.getNumberOfFailedAttachments)(allAttachmentsWithStatuses);
|
|
109
|
+
if (numberOfAttemptedCalls === (allAttachments.length + 1) && ((numberOfSuccessfulAttachmentUploads + numberOfFailedAttachmentUploads) === allAttachments.length)) {
|
|
110
|
+
if (numberOfFailedAttachmentUploads > 0) {
|
|
111
|
+
setProgressBarColor('red');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}, [numberOfAttemptedCalls, allAttachments, allAttachmentsWithStatuses, invoiceSubmittingStatus]);
|
|
116
|
+
(0, react_1.useEffect)(function () {
|
|
117
|
+
var numberOfSuccessfulAttachmentUploads = (0, SubmitConfirmationUtility_1.getNumberOfUploadedAttachments)(allAttachmentsWithStatuses);
|
|
118
|
+
var numberOfFailedAttachmentUploads = (0, SubmitConfirmationUtility_1.getNumberOfFailedAttachments)(allAttachmentsWithStatuses);
|
|
119
|
+
var isRetryBtnVisible = (0, AttachmentsUtility_1.isRetryButtonVisible)(numberOfAttemptedCalls, allAttachments.length, numberOfSuccessfulAttachmentUploads, numberOfFailedAttachmentUploads, alreadyRetried, invoiceSubmittingStatus);
|
|
120
|
+
setRetryButtonVisible(isRetryBtnVisible);
|
|
121
|
+
if (allAttachments.length === numberOfSuccessfulAttachmentUploads && invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Done) {
|
|
122
|
+
setAllAttachmentsUploadedSuccessfully(true);
|
|
123
|
+
}
|
|
124
|
+
}, [numberOfAttemptedCalls, allAttachments, allAttachmentsWithStatuses, alreadyRetried, invoiceSubmittingStatus]);
|
|
77
125
|
var cardStyle = {
|
|
78
126
|
width: "auto",
|
|
79
127
|
backgroundColor: "whitesmoke",
|
|
@@ -81,22 +129,43 @@ var SubmitConfirmation = function (props) {
|
|
|
81
129
|
display: "flex",
|
|
82
130
|
justifyContent: "center"
|
|
83
131
|
};
|
|
132
|
+
var getSinnerStatus = function (_invoiceSubmittingStatus, _allAttachments, _allAttachmentsWithStatuses) {
|
|
133
|
+
if (_invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed || _invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Done)
|
|
134
|
+
return false;
|
|
135
|
+
return _allAttachments.length !== ((0, SubmitConfirmationUtility_1.getNumberOfUploadedAttachments)(_allAttachmentsWithStatuses) + (0, SubmitConfirmationUtility_1.getNumberOfFailedAttachments)(_allAttachmentsWithStatuses));
|
|
136
|
+
};
|
|
84
137
|
return (react_1.default.createElement(antd_1.Flex, { justify: "center", style: { padding: "45px" } },
|
|
85
138
|
react_1.default.createElement(antd_1.Flex, { vertical: true, justify: "center", align: "center", style: { width: "100%", maxWidth: "900px" }, gap: "small" },
|
|
86
139
|
react_1.default.createElement(SubmitConfirmationSVG_1.default, null),
|
|
87
140
|
" ",
|
|
88
141
|
react_1.default.createElement(antd_1.Flex, { justify: "center", align: "center", style: { width: "100%", maxWidth: "900px" }, gap: "small" },
|
|
89
|
-
react_1.default.createElement(antd_1.Progress, { showInfo: false, percent: (
|
|
90
|
-
react_1.default.createElement(antd_1.Spin, { size: "small", spinning:
|
|
91
|
-
|
|
142
|
+
react_1.default.createElement(antd_1.Progress, { showInfo: false, percent: (0, SubmitConfirmationUtility_1.getProgressPercent)((0, SubmitConfirmationUtility_1.getNumberOfUploadedAttachments)(allAttachmentsWithStatuses), (0, SubmitConfirmationUtility_1.getNumberOfFailedAttachments)(allAttachmentsWithStatuses), allAttachments.length, percentUnit, invoiceSubmittingStatus, numberOfAttemptedCalls), success: { percent: (0, SubmitConfirmationUtility_1.getSuccessPercent)(allAttachmentsWithStatuses, percentUnit, invoiceSubmittingStatus) }, trailColor: progressBarColor }),
|
|
143
|
+
react_1.default.createElement(antd_1.Spin, { size: "small", spinning: getSinnerStatus(invoiceSubmittingStatus, allAttachments, allAttachmentsWithStatuses) })),
|
|
144
|
+
react_1.default.createElement(antd_1.Card, { size: "small", style: cardStyle },
|
|
92
145
|
react_1.default.createElement("ul", { style: { listStyleType: 'none', paddingLeft: 0, margin: 0 } },
|
|
93
|
-
react_1.default.createElement("li", null,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
146
|
+
react_1.default.createElement("li", null,
|
|
147
|
+
react_1.default.createElement(AttachmentUploadStatus_1.default, { name: (0, SubmitConfirmationUtility_1.getInvoiceText)(invoiceSubmittingStatus, props.intl), status: invoiceSubmittingStatus })), allAttachments === null || allAttachments === void 0 ? void 0 :
|
|
148
|
+
allAttachments.map(function (attachment) {
|
|
149
|
+
var attachmentStatus = (0, SubmitConfirmationUtility_1.getStatusOfAttachment)(allAttachmentsWithStatuses, attachment.description);
|
|
150
|
+
var name = (0, SubmitConfirmationUtility_1.getAttachmentsText)(attachmentStatus, attachment.description, props.intl);
|
|
151
|
+
return react_1.default.createElement("li", { key: attachment.description },
|
|
152
|
+
react_1.default.createElement(AttachmentUploadStatus_1.default, { name: name, status: invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed ? invoiceSubmittingStatus : attachmentStatus }));
|
|
153
|
+
})),
|
|
154
|
+
retryButtonVisible &&
|
|
155
|
+
react_1.default.createElement(antd_1.Flex, { justify: 'center' },
|
|
156
|
+
react_1.default.createElement(antd_1.Button, { size: 'small', style: { marginTop: "10px" }, onClick: function () {
|
|
157
|
+
if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed) {
|
|
158
|
+
retrySubmittingInvoice();
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
retryUploadingFailedAttachments(allAttachmentsWithStatuses.filter(function (att) { return att.status === AttachmentUploadStatus_1.SubmittingStatus.Failed; }));
|
|
162
|
+
}
|
|
163
|
+
} }, invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed ? props.intl.formatMessage(exports.translationMessages.submitConfirmation_retryButton) : props.intl.formatMessage(exports.translationMessages.submitConfirmation_retryFailedAttachments)))),
|
|
164
|
+
react_1.default.createElement(antd_1.Flex, { vertical: true, align: "center", style: { paddingTop: "20px" } }, (0, SubmitConfirmationUtility_1.getNumberOfFailedAttachments)(allAttachmentsWithStatuses) > 0
|
|
165
|
+
? react_1.default.createElement(antd_1.Typography.Title, { level: 2 }, props.intl.formatMessage(exports.translationMessages.submitConfirmation_submitWithFailedAttachmentsInfoMessage))
|
|
166
|
+
: react_1.default.createElement(react_1.default.Fragment, null, allAttachmentsUploadedSuccessfully &&
|
|
167
|
+
react_1.default.createElement(react_1.default.Fragment, null,
|
|
168
|
+
react_1.default.createElement(antd_1.Typography.Title, { level: 2 }, props.intl.formatMessage(exports.translationMessages.submitConfirmation_title)),
|
|
169
|
+
react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4, textAlign: "center" } }, props.intl.formatMessage(exports.translationMessages.submitConfirmation_text))))))));
|
|
101
170
|
};
|
|
102
171
|
exports.default = (0, react_intl_1.injectIntl)(SubmitConfirmation);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { WrappedComponentProps } from "react-intl";
|
|
3
3
|
import { CommonProps } from "../common/types/CommonProps";
|
|
4
|
+
import { UploadFile } from "antd/es/upload/interface";
|
|
4
5
|
import "../common/style/index.css";
|
|
5
6
|
import { PortalConfigurationCustomer } from "@unimaze/api-clients/lib/rapi";
|
|
7
|
+
import { SubmittingStatus } from "../common/components/submit-confirmation/AttachmentUploadStatus";
|
|
6
8
|
export declare const translationMessages: {
|
|
7
9
|
createInvoice_addDocumentLineMsg: {
|
|
8
10
|
id: string;
|
|
@@ -73,6 +75,11 @@ export declare const translationMessages: {
|
|
|
73
75
|
defaultMessage: string;
|
|
74
76
|
};
|
|
75
77
|
};
|
|
78
|
+
export interface AttachmentProps {
|
|
79
|
+
description: string;
|
|
80
|
+
file: UploadFile;
|
|
81
|
+
status: SubmittingStatus;
|
|
82
|
+
}
|
|
76
83
|
interface Props extends CommonProps, WrappedComponentProps {
|
|
77
84
|
customers: PortalConfigurationCustomer[];
|
|
78
85
|
referenceIdentifiersHelpText?: string;
|
|
@@ -82,6 +82,8 @@ var ReferenceIdentifierUtility_1 = require("../utils/ReferenceIdentifierUtility"
|
|
|
82
82
|
var RequirementsUtility_1 = require("../utils/RequirementsUtility");
|
|
83
83
|
var CommonTranslations_1 = require("../common/components/CommonTranslations");
|
|
84
84
|
var LocalStorageUtility_1 = require("../utils/LocalStorageUtility");
|
|
85
|
+
var AttachmentUploadStatus_1 = require("../common/components/submit-confirmation/AttachmentUploadStatus");
|
|
86
|
+
var SubmitConfirmationUtility_1 = require("../utils/SubmitConfirmationUtility");
|
|
85
87
|
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
86
88
|
createInvoice_addDocumentLineMsg: {
|
|
87
89
|
id: "createInvoice_addDocumentLineMsg",
|
|
@@ -191,10 +193,17 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
191
193
|
var _y = (0, react_1.useState)({}), removedInvoiceLine = _y[0], setRemovedInvoiceLine = _y[1];
|
|
192
194
|
var _z = (0, react_1.useState)(undefined), missingRequiredDataTooltip = _z[0], setMissingRequiredDataTooltip = _z[1];
|
|
193
195
|
var _0 = (0, react_1.useState)(false), newLineSaved = _0[0], setNewLineSaved = _0[1];
|
|
196
|
+
var _1 = (0, react_1.useState)(0), numberOfAttemptedCalls = _1[0], setNumberOfAttemptedCalls = _1[1];
|
|
197
|
+
var _2 = (0, react_1.useState)(''), messageIdForRetryAttachments = _2[0], setMessageIdForRetryAttachments = _2[1];
|
|
198
|
+
var _3 = (0, react_1.useState)(''), tokenForRetryAttachments = _3[0], setTokenForRetryAttachments = _3[1];
|
|
199
|
+
var _4 = (0, react_1.useState)([]), allAttachments = _4[0], setAllAttachments = _4[1];
|
|
200
|
+
var _5 = (0, react_1.useState)(false), alreadyRetried = _5[0], setAlreadyRetried = _5[1];
|
|
201
|
+
var _6 = (0, react_1.useState)(AttachmentUploadStatus_1.SubmittingStatus.Pending), invoiceSubmittingStatus = _6[0], setInvoiceSubmittingStatus = _6[1];
|
|
202
|
+
var _7 = (0, react_1.useState)([]), allAttachmentsWithStatuses = _7[0], setAllAttachmentsWithStatuses = _7[1];
|
|
194
203
|
var getDefaultPaymentType = function (defaultPaymentType) {
|
|
195
204
|
return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
|
|
196
205
|
};
|
|
197
|
-
var
|
|
206
|
+
var _8 = (0, react_1.useState)({
|
|
198
207
|
invoice: {
|
|
199
208
|
supplier: {
|
|
200
209
|
address: {
|
|
@@ -220,7 +229,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
220
229
|
},
|
|
221
230
|
issueDate: (0, dayjs_1.default)(),
|
|
222
231
|
},
|
|
223
|
-
}), formData =
|
|
232
|
+
}), formData = _8[0], setFormData = _8[1];
|
|
224
233
|
var values = antd_1.Form.useWatch([], form);
|
|
225
234
|
var validateBillingLinesAndRefIdentifierField = function (isMultipleReferenceIdentifier, isSingleReferenceIdentifier, someRequiredFieldsEmpty) {
|
|
226
235
|
var validationErrors = (0, ValidationUtility_1.validateInvoiceFieldsWithoutRules)(form, isMultipleReferenceIdentifier, isSingleReferenceIdentifier, someRequiredFieldsEmpty, setIsNextStepDisabled, referenceIdentifierIsMandatory, referenceIdentifierValidateStatus, intl);
|
|
@@ -404,9 +413,18 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
404
413
|
// setSendCopyDisabled(true);
|
|
405
414
|
// }
|
|
406
415
|
// }, [supplierEmail]);
|
|
407
|
-
var
|
|
408
|
-
|
|
409
|
-
|
|
416
|
+
var retryUploadingFailedAttachments = function (_failedAttachments) {
|
|
417
|
+
var failed = (0, SubmitConfirmationUtility_1.getAllFailedUploads)(allAttachmentsWithStatuses);
|
|
418
|
+
var success = (0, SubmitConfirmationUtility_1.getAllSuccessfulUploads)(allAttachmentsWithStatuses);
|
|
419
|
+
setNumberOfAttemptedCalls(success.length + 1);
|
|
420
|
+
(0, ApiUtility_1.submitAttachmentIfAnyLeft)(messageIdForRetryAttachments, failed, props.mapiBaseUrl, tokenForRetryAttachments, intl, numberOfAttemptedCalls, setNumberOfAttemptedCalls, [], __spreadArray([], success, true));
|
|
421
|
+
setAlreadyRetried(true);
|
|
422
|
+
};
|
|
423
|
+
var retrySubmittingInvoice = function () {
|
|
424
|
+
setInvoiceSubmittingStatus(AttachmentUploadStatus_1.SubmittingStatus.Pending);
|
|
425
|
+
handleSubmit(form.getFieldsValue(), (0, uuid_1.v4)());
|
|
426
|
+
};
|
|
427
|
+
var handleSubmit = function (_values, messageId) {
|
|
410
428
|
var _a, _b, _c, _d, _e, _f;
|
|
411
429
|
setSubmitting(true);
|
|
412
430
|
if (referenceIdentifierValidateStatus !== "" && referenceIdentifierValidateStatus !== "success") {
|
|
@@ -421,6 +439,15 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
421
439
|
];
|
|
422
440
|
// Clear the array of undefined
|
|
423
441
|
attachments = attachments.filter(function (attachment) { return attachment && attachment.file; });
|
|
442
|
+
setAllAttachments(attachments);
|
|
443
|
+
var attachmentsWithStatuses = [];
|
|
444
|
+
attachments.forEach(function (at) {
|
|
445
|
+
attachmentsWithStatuses.push({
|
|
446
|
+
description: at.description,
|
|
447
|
+
file: at.file,
|
|
448
|
+
status: AttachmentUploadStatus_1.SubmittingStatus.Pending
|
|
449
|
+
});
|
|
450
|
+
});
|
|
424
451
|
if (!chosenCustomer) {
|
|
425
452
|
antd_1.message.error(intl.formatMessage(exports.translationMessages.createInvoice_selectCustomerMsg));
|
|
426
453
|
// TODO: handle this better?
|
|
@@ -434,21 +461,25 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
434
461
|
var createSubmitInvoice = {
|
|
435
462
|
invoiceMetadataInput: invoiceMetadataInput,
|
|
436
463
|
more: attachments.length > 0,
|
|
437
|
-
messageId: (0, uuid_1.v4)(),
|
|
464
|
+
messageId: messageId !== null && messageId !== void 0 ? messageId : (0, uuid_1.v4)(),
|
|
438
465
|
processingMode: mapi_1.TransactionProcessingMode.Device,
|
|
439
466
|
services: services,
|
|
440
467
|
};
|
|
441
468
|
(0, ApiUtility_1.getAuthToken)(props.rapiBaseUrl, chosenCustomer === null || chosenCustomer === void 0 ? void 0 : chosenCustomer.identifier).then(function (getAuthTokenResponse) {
|
|
442
469
|
var token = getAuthTokenResponse.data;
|
|
443
|
-
|
|
444
|
-
|
|
470
|
+
if (!messageId) {
|
|
471
|
+
setActiveStep(activeStep + 1);
|
|
472
|
+
}
|
|
473
|
+
setNumberOfAttemptedCalls(numberOfAttemptedCalls + 1);
|
|
474
|
+
setTokenForRetryAttachments(token);
|
|
445
475
|
(0, utils_1.submitInvoice)(createSubmitInvoice, props.mapiBaseUrl, token, "submitInvoice", props.language)
|
|
446
476
|
.then(function (submitInvoiceResponse) {
|
|
447
|
-
var _a;
|
|
448
|
-
|
|
477
|
+
var _a, _b;
|
|
478
|
+
setInvoiceSubmittingStatus(AttachmentUploadStatus_1.SubmittingStatus.Done);
|
|
449
479
|
if (submitInvoiceResponse.status === 201) {
|
|
450
480
|
var response = submitInvoiceResponse.data;
|
|
451
|
-
(
|
|
481
|
+
setMessageIdForRetryAttachments((_a = response === null || response === void 0 ? void 0 : response.uniqueId) !== null && _a !== void 0 ? _a : "");
|
|
482
|
+
(0, ApiUtility_1.submitAttachmentIfAnyLeft)((_b = response === null || response === void 0 ? void 0 : response.uniqueId) !== null && _b !== void 0 ? _b : "", attachmentsWithStatuses, props.mapiBaseUrl, token, intl, 1, setNumberOfAttemptedCalls, [], [], setAllAttachmentsWithStatuses);
|
|
452
483
|
}
|
|
453
484
|
else {
|
|
454
485
|
antd_1.message.error(props.intl.formatMessage(exports.translationMessages.createInvoice_invoiceHadValidationErrors));
|
|
@@ -484,6 +515,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
484
515
|
})
|
|
485
516
|
.catch(function (error) {
|
|
486
517
|
setSubmitting(false);
|
|
518
|
+
setInvoiceSubmittingStatus(AttachmentUploadStatus_1.SubmittingStatus.Failed);
|
|
487
519
|
if (error.response) {
|
|
488
520
|
// The request was made and the server responded with a status code
|
|
489
521
|
// that falls out of the range of 2xx
|
|
@@ -522,7 +554,6 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
522
554
|
recaptchaRef.current.reset();
|
|
523
555
|
}
|
|
524
556
|
}
|
|
525
|
-
setIsSubmitDisabled(true);
|
|
526
557
|
};
|
|
527
558
|
var getReceiverRequirements = function () {
|
|
528
559
|
var _a, _b, _c, _d, _e;
|
|
@@ -564,7 +595,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
564
595
|
name: defaultCustomer.name,
|
|
565
596
|
});
|
|
566
597
|
}
|
|
567
|
-
var
|
|
598
|
+
var _9 = (0, react_1.useState)(undefined), billingLinesMetadata = _9[0], setBillingLinesMetadata = _9[1];
|
|
568
599
|
var getBillingLines = function (changedValues, allValues) {
|
|
569
600
|
var invoiceLines = allValues.invoice.invoiceLines;
|
|
570
601
|
if (invoiceLines) {
|
|
@@ -621,7 +652,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
621
652
|
}
|
|
622
653
|
}, scrollToFirstError: true, onValuesChange: function (changedValues, allValues) {
|
|
623
654
|
getBillingLines(changedValues, allValues);
|
|
624
|
-
} }, formLayout_1.formItemLayout, { form: form, onFinish: handleSubmit, onFinishFailed: function (error) {
|
|
655
|
+
} }, formLayout_1.formItemLayout, { form: form, onFinish: function (_values) { return handleSubmit(_values); }, onFinishFailed: function (error) {
|
|
625
656
|
// tslint:disable-next-line:no-console
|
|
626
657
|
console.log(error);
|
|
627
658
|
}, initialValues: formData }),
|
|
@@ -645,7 +676,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
645
676
|
return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
|
|
646
677
|
}, localStorageFormDataVersion: props.localStorageFormDataVersion })),
|
|
647
678
|
activeStep === items.length && (react_1.default.createElement(components_1.InvoicePreview, { recieverRequirements: props.receiverRequirements, form: form, chosenCustomer: chosenCustomer })),
|
|
648
|
-
activeStep === 5 && react_1.default.createElement(components_1.SubmitConfirmation, {
|
|
679
|
+
activeStep === 5 && react_1.default.createElement(components_1.SubmitConfirmation, { numberOfAttemptedCalls: numberOfAttemptedCalls, retryUploadingFailedAttachments: retryUploadingFailedAttachments, retrySubmittingInvoice: retrySubmittingInvoice, alreadyRetried: alreadyRetried, invoiceSubmittingStatus: invoiceSubmittingStatus, allAttachments: allAttachments, allAttachmentsWithStatuses: allAttachmentsWithStatuses }),
|
|
649
680
|
activeStep === items.length && (react_1.default.createElement(antd_1.Flex, { justify: "center" },
|
|
650
681
|
react_1.default.createElement(antd_1.Flex, { gap: isMobile ? "middle" : 20, vertical: true, align: "end", style: { width: "100%", maxWidth: "900px" } },
|
|
651
682
|
react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== items.length ? { display: "none" } : {} },
|
|
@@ -154,8 +154,17 @@
|
|
|
154
154
|
"referenceIdentifiers_values_validation_message": "This value doesn't exist",
|
|
155
155
|
"saveInformation_label": "Save information",
|
|
156
156
|
"submitConfirmation_SuccessfullyUploadedAttachment": "Successfully uploaded attachment:",
|
|
157
|
+
"submitConfirmation_attachmentFailedToUpload": "Attachment failed to upload:",
|
|
157
158
|
"submitConfirmation_footer_text": "If any questions arise, please contact us at",
|
|
159
|
+
"submitConfirmation_retryButton": "Retry",
|
|
160
|
+
"submitConfirmation_retryFailedAttachments": "Retry failed attachments",
|
|
161
|
+
"submitConfirmation_submitWithFailedAttachmentsInfoMessage": "Invoice will be delivered without failed attachments within 24 hours.",
|
|
162
|
+
"submitConfirmation_submittingAttachment": "Submitting attachment:",
|
|
163
|
+
"submitConfirmation_submittingInvoice": "Submitting invoice...",
|
|
164
|
+
"submitConfirmation_submittingInvoiceFailed": "Submitting invoice failed",
|
|
165
|
+
"submitConfirmation_submittingInvoiceSuccessful": "Successfully submitted invoice",
|
|
158
166
|
"submitConfirmation_successfullyCreatedInvoice": "Successfully created invoice",
|
|
167
|
+
"submitConfirmation_successfullyUploadedAttachment": "Successfully uploaded attachment:",
|
|
159
168
|
"submitConfirmation_text": "The invoice has been sent to the customer.",
|
|
160
169
|
"submitConfirmation_title": "Invoice sent",
|
|
161
170
|
"supplier_address_city": "City",
|
|
@@ -154,8 +154,17 @@
|
|
|
154
154
|
"referenceIdentifiers_values_validation_message": "Þetta gildi er ekki til",
|
|
155
155
|
"saveInformation_label": "Vista upplýsingar",
|
|
156
156
|
"submitConfirmation_SuccessfullyUploadedAttachment": "Viðhengi sem hefur verið sent:",
|
|
157
|
+
"submitConfirmation_attachmentFailedToUpload": "Ekki tókst að hlaða upp viðhengi:",
|
|
157
158
|
"submitConfirmation_footer_text": "Ef spurningar vakna, hafið samband",
|
|
159
|
+
"submitConfirmation_retryButton": "Endurkeyra",
|
|
160
|
+
"submitConfirmation_retryFailedAttachments": "Endurkeyra viðhengi sem tókst ekki að senda",
|
|
161
|
+
"submitConfirmation_submitWithFailedAttachmentsInfoMessage": "Reikningur verður sendur innan 24 stunda án viðhengja á villu",
|
|
162
|
+
"submitConfirmation_submittingAttachment": "Sendi viðhengi:",
|
|
163
|
+
"submitConfirmation_submittingInvoice": "Sendi reikning...",
|
|
164
|
+
"submitConfirmation_submittingInvoiceFailed": "Villa við að senda reikning",
|
|
165
|
+
"submitConfirmation_submittingInvoiceSuccessful": "Reikningur sendur",
|
|
158
166
|
"submitConfirmation_successfullyCreatedInvoice": "Reikningur hefur verið stofnaður",
|
|
167
|
+
"submitConfirmation_successfullyUploadedAttachment": "Viðhengi hlaðið upp:",
|
|
159
168
|
"submitConfirmation_text": "Reikningur hefur verið sendur til viðskiptavinar.",
|
|
160
169
|
"submitConfirmation_title": "Reikningur sendur",
|
|
161
170
|
"supplier_address_city": "Borg",
|
|
@@ -155,8 +155,17 @@ declare const _default: {
|
|
|
155
155
|
referenceIdentifiers_values_validation_message: string;
|
|
156
156
|
saveInformation_label: string;
|
|
157
157
|
submitConfirmation_SuccessfullyUploadedAttachment: string;
|
|
158
|
+
submitConfirmation_attachmentFailedToUpload: string;
|
|
158
159
|
submitConfirmation_footer_text: string;
|
|
160
|
+
submitConfirmation_retryButton: string;
|
|
161
|
+
submitConfirmation_retryFailedAttachments: string;
|
|
162
|
+
submitConfirmation_submitWithFailedAttachmentsInfoMessage: string;
|
|
163
|
+
submitConfirmation_submittingAttachment: string;
|
|
164
|
+
submitConfirmation_submittingInvoice: string;
|
|
165
|
+
submitConfirmation_submittingInvoiceFailed: string;
|
|
166
|
+
submitConfirmation_submittingInvoiceSuccessful: string;
|
|
159
167
|
submitConfirmation_successfullyCreatedInvoice: string;
|
|
168
|
+
submitConfirmation_successfullyUploadedAttachment: string;
|
|
160
169
|
submitConfirmation_text: string;
|
|
161
170
|
submitConfirmation_title: string;
|
|
162
171
|
supplier_address_city: string;
|
|
@@ -354,8 +363,17 @@ declare const _default: {
|
|
|
354
363
|
referenceIdentifiers_values_validation_message: string;
|
|
355
364
|
saveInformation_label: string;
|
|
356
365
|
submitConfirmation_SuccessfullyUploadedAttachment: string;
|
|
366
|
+
submitConfirmation_attachmentFailedToUpload: string;
|
|
357
367
|
submitConfirmation_footer_text: string;
|
|
368
|
+
submitConfirmation_retryButton: string;
|
|
369
|
+
submitConfirmation_retryFailedAttachments: string;
|
|
370
|
+
submitConfirmation_submitWithFailedAttachmentsInfoMessage: string;
|
|
371
|
+
submitConfirmation_submittingAttachment: string;
|
|
372
|
+
submitConfirmation_submittingInvoice: string;
|
|
373
|
+
submitConfirmation_submittingInvoiceFailed: string;
|
|
374
|
+
submitConfirmation_submittingInvoiceSuccessful: string;
|
|
358
375
|
submitConfirmation_successfullyCreatedInvoice: string;
|
|
376
|
+
submitConfirmation_successfullyUploadedAttachment: string;
|
|
359
377
|
submitConfirmation_text: string;
|
|
360
378
|
submitConfirmation_title: string;
|
|
361
379
|
supplier_address_city: string;
|
|
@@ -2,7 +2,7 @@ import { ImportDocumentValidationData, MessageOutput } from "@unimaze/api-client
|
|
|
2
2
|
import { InvoiceMetadataInput, TransactionProcessingMode } from "@unimaze/api-clients/lib/mapi";
|
|
3
3
|
import { AxiosPromise, CancelToken } from "axios";
|
|
4
4
|
import { LanguageProp } from "../common/types/CommonProps";
|
|
5
|
-
import {
|
|
5
|
+
import { AttachmentProps } from "../create-invoice";
|
|
6
6
|
import { IntlShape } from "react-intl";
|
|
7
7
|
interface CreateSubmitInvoice {
|
|
8
8
|
messageId: string;
|
|
@@ -23,8 +23,5 @@ declare const submitDocumentFetch: (data: any, attachDocument: AttachDocument, m
|
|
|
23
23
|
declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, token: string, callName?: string, language?: LanguageProp) => AxiosPromise<ImportDocumentValidationData[] | MessageOutput>;
|
|
24
24
|
declare const getAuthToken: (rapiBaseUrl: string, entityIsoIdentifier: string) => AxiosPromise<string>;
|
|
25
25
|
declare const getCancelToken: (callName: string, showMessage?: boolean) => CancelToken;
|
|
26
|
-
declare const submitAttachmentIfAnyLeft: (_messageId: string, _attachments:
|
|
27
|
-
description: string;
|
|
28
|
-
file: UploadFile;
|
|
29
|
-
}[], _mapiBaseUrl: string, token: string, intl: IntlShape, numberOfSuccessfulCalls: number, setNumberOfSuccessfulCalls: (numberOfSuccessfulCalls: number) => void) => void;
|
|
26
|
+
declare const submitAttachmentIfAnyLeft: (_messageId: string, _attachments: AttachmentProps[], _mapiBaseUrl: string, token: string, intl: IntlShape, numberOfAttemptedCalls: number, setNumberOfAttemptedCalls: (numberOfAttemptedCalls: number) => void, numberOfFailedAttempts: number[], allAttachmentsWithStatuses: AttachmentProps[], setAllAttachmentsWithStatuses?: (allNewAttachments: AttachmentProps[]) => void) => void;
|
|
30
27
|
export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument, submitDocumentFetch, submitAttachmentIfAnyLeft, getAuthToken, getCancelToken };
|
package/lib/utils/ApiUtility.js
CHANGED
|
@@ -10,6 +10,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
13
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
24
|
};
|
|
@@ -21,6 +30,7 @@ var mapi_1 = require("@unimaze/api-clients/lib/mapi");
|
|
|
21
30
|
var axios_1 = __importDefault(require("axios"));
|
|
22
31
|
var antd_1 = require("antd");
|
|
23
32
|
var create_invoice_1 = require("../create-invoice");
|
|
33
|
+
var AttachmentUploadStatus_1 = require("../common/components/submit-confirmation/AttachmentUploadStatus");
|
|
24
34
|
var initialiseTransactionApi = function (mapiBaseUrl) {
|
|
25
35
|
var apiConfig = {
|
|
26
36
|
basePath: mapiBaseUrl,
|
|
@@ -118,31 +128,62 @@ var getCancelToken = function (callName, showMessage) {
|
|
|
118
128
|
return window[callName].token;
|
|
119
129
|
};
|
|
120
130
|
exports.getCancelToken = getCancelToken;
|
|
121
|
-
var submitAttachmentIfAnyLeft = function (_messageId, _attachments, _mapiBaseUrl, token, intl,
|
|
131
|
+
var submitAttachmentIfAnyLeft = function (_messageId, _attachments, _mapiBaseUrl, token, intl, numberOfAttemptedCalls, setNumberOfAttemptedCalls, numberOfFailedAttempts, allAttachmentsWithStatuses, setAllAttachmentsWithStatuses) {
|
|
122
132
|
if (_attachments && _attachments.length > 0) {
|
|
123
|
-
var
|
|
124
|
-
var nextFile =
|
|
125
|
-
var nextFileDescription_1 =
|
|
133
|
+
var nextFileArray_1 = _attachments.splice(0, 1);
|
|
134
|
+
var nextFile = nextFileArray_1[0].file.originFileObj;
|
|
135
|
+
var nextFileDescription_1 = nextFileArray_1[0].description;
|
|
126
136
|
if (!nextFile)
|
|
127
137
|
throw new Error("NextFile is empty");
|
|
128
138
|
var createAttachDocument = {
|
|
129
139
|
messageId: _messageId,
|
|
130
140
|
contentType: nextFile.type,
|
|
131
|
-
more: _attachments.length > 0,
|
|
141
|
+
more: numberOfFailedAttempts.length > 0 ? true : _attachments.length > 0,
|
|
132
142
|
name: nextFileDescription_1, // nextFile.name,
|
|
133
143
|
};
|
|
134
|
-
|
|
144
|
+
var newNumberOfAttachments_1 = numberOfAttemptedCalls + 1;
|
|
145
|
+
setNumberOfAttemptedCalls(newNumberOfAttachments_1);
|
|
146
|
+
// TODO remove aa bb just testing
|
|
147
|
+
submitDocumentFetch(nextFileDescription_1 === 'aa' || nextFileDescription_1 === 'bb' ? undefined : nextFile, createAttachDocument, _mapiBaseUrl, token)
|
|
135
148
|
.then(function (submitDocumentResponse) {
|
|
136
149
|
if (submitDocumentResponse.status === 200 || submitDocumentResponse.status === 201) {
|
|
137
|
-
var
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
var newAttachmentsWithStatuses = __spreadArray(__spreadArray([], allAttachmentsWithStatuses, true), [{
|
|
151
|
+
description: nextFileDescription_1,
|
|
152
|
+
file: nextFileArray_1[0].file,
|
|
153
|
+
status: AttachmentUploadStatus_1.SubmittingStatus.Done,
|
|
154
|
+
}], false);
|
|
155
|
+
if (typeof setAllAttachmentsWithStatuses === 'function') {
|
|
156
|
+
setAllAttachmentsWithStatuses(newAttachmentsWithStatuses);
|
|
157
|
+
}
|
|
158
|
+
submitAttachmentIfAnyLeft(_messageId, _attachments, _mapiBaseUrl, token, intl, newNumberOfAttachments_1, setNumberOfAttemptedCalls, numberOfFailedAttempts, newAttachmentsWithStatuses, setAllAttachmentsWithStatuses);
|
|
140
159
|
}
|
|
141
160
|
else {
|
|
142
161
|
antd_1.message.error("".concat(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_ErrorUploadedAttachmentMsg, {
|
|
143
162
|
attachment: nextFileDescription_1,
|
|
144
163
|
}), " - ").concat(submitDocumentResponse.statusText));
|
|
164
|
+
var newAttachmentsWithStatuses = __spreadArray(__spreadArray([], allAttachmentsWithStatuses, true), [{
|
|
165
|
+
description: nextFileDescription_1,
|
|
166
|
+
file: nextFileArray_1[0].file,
|
|
167
|
+
status: AttachmentUploadStatus_1.SubmittingStatus.Failed,
|
|
168
|
+
}], false);
|
|
169
|
+
if (typeof setAllAttachmentsWithStatuses === 'function') {
|
|
170
|
+
setAllAttachmentsWithStatuses(newAttachmentsWithStatuses);
|
|
171
|
+
}
|
|
172
|
+
submitAttachmentIfAnyLeft(_messageId, _attachments, _mapiBaseUrl, token, intl, newNumberOfAttachments_1, setNumberOfAttemptedCalls, numberOfFailedAttempts, newAttachmentsWithStatuses, setAllAttachmentsWithStatuses);
|
|
173
|
+
}
|
|
174
|
+
}).catch(function (error) {
|
|
175
|
+
antd_1.message.error("".concat(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_ErrorUploadedAttachmentMsg, {
|
|
176
|
+
attachment: nextFileDescription_1,
|
|
177
|
+
}), " - ").concat(error));
|
|
178
|
+
var newAttachmentsWithStatuses = __spreadArray(__spreadArray([], allAttachmentsWithStatuses, true), [{
|
|
179
|
+
description: nextFileDescription_1,
|
|
180
|
+
file: nextFileArray_1[0].file,
|
|
181
|
+
status: AttachmentUploadStatus_1.SubmittingStatus.Failed,
|
|
182
|
+
}], false);
|
|
183
|
+
if (typeof setAllAttachmentsWithStatuses === 'function') {
|
|
184
|
+
setAllAttachmentsWithStatuses(newAttachmentsWithStatuses);
|
|
145
185
|
}
|
|
186
|
+
submitAttachmentIfAnyLeft(_messageId, _attachments, _mapiBaseUrl, token, intl, newNumberOfAttachments_1, setNumberOfAttemptedCalls, numberOfFailedAttempts, newAttachmentsWithStatuses, setAllAttachmentsWithStatuses);
|
|
146
187
|
});
|
|
147
188
|
}
|
|
148
189
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SubmittingStatus } from "../common/components/submit-confirmation/AttachmentUploadStatus";
|
|
2
2
|
declare const getSubmittingStatus: (name: string, failedUploads: string[], attachments: string[], numberOfAttemptedCalls: number) => SubmittingStatus;
|
|
3
|
-
declare const isRetryButtonVisible: (numberOfAttemptedCalls: number, totalNumberOfCalls: number, numberOfSuccessfulCalls: number,
|
|
3
|
+
declare const isRetryButtonVisible: (numberOfAttemptedCalls: number, totalNumberOfCalls: number, numberOfSuccessfulCalls: number, numberOfFailedUploads: number, alreadyRetried: boolean, invoiceSubmittingStatus: SubmittingStatus) => boolean;
|
|
4
4
|
export { getSubmittingStatus, isRetryButtonVisible };
|
|
@@ -12,9 +12,11 @@ var getSubmittingStatus = function (name, failedUploads, attachments, numberOfAt
|
|
|
12
12
|
return AttachmentUploadStatus_1.SubmittingStatus.Pending;
|
|
13
13
|
};
|
|
14
14
|
exports.getSubmittingStatus = getSubmittingStatus;
|
|
15
|
-
var isRetryButtonVisible = function (numberOfAttemptedCalls, totalNumberOfCalls, numberOfSuccessfulCalls,
|
|
16
|
-
if (
|
|
17
|
-
return
|
|
15
|
+
var isRetryButtonVisible = function (numberOfAttemptedCalls, totalNumberOfCalls, numberOfSuccessfulCalls, numberOfFailedUploads, alreadyRetried, invoiceSubmittingStatus) {
|
|
16
|
+
if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed)
|
|
17
|
+
return true;
|
|
18
|
+
if (numberOfAttemptedCalls === (totalNumberOfCalls + 1) && ((numberOfSuccessfulCalls + numberOfFailedUploads) === totalNumberOfCalls)) {
|
|
19
|
+
return numberOfFailedUploads > 0 && !alreadyRetried;
|
|
18
20
|
}
|
|
19
21
|
};
|
|
20
22
|
exports.isRetryButtonVisible = isRetryButtonVisible;
|
|
@@ -17,7 +17,7 @@ export interface FormItemPropsWithoutChildren extends Omit<FormItemProps, "child
|
|
|
17
17
|
}
|
|
18
18
|
export declare const handleValueValidation: import("lodash").DebouncedFunc<(isoNumber: string, fieldName: string, value: string, rapiBaseUrl: string, namePath: NamePath, setValidationStatus: (validationStatus: ValidateStatus) => void, formInstance: FormInstance, callName: string) => void>;
|
|
19
19
|
export declare const debouncedHandleSearchValues: import("lodash").DebouncedFunc<(searchValue: string, fieldDefinition: FieldDefinition, setLoadingValues: (loadingValues: boolean) => void, loadingValues: boolean, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (newReceiverRequirements: NewReceiverRequirements) => void, callName: string, rapiBaseUrl: string, overwrittenFieldDefinitionKey?: string) => void>;
|
|
20
|
-
export declare const getInput: (fieldDefinition: FieldDefinition, namePath: NamePath, validationCallName: string, legalIdentifier: string, formInstance: FormInstance, rapiBaseUrl: string, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void, setAccountingCostFieldProps: (accountingCostFiledProps: FormItemPropsWithoutChildren) => void, accountingCostFieldProps: FormItemPropsWithoutChildren, setLoadingAccountingCostValues: (loadingAccountingCostValues: boolean) => void, loadingAccountingCostValues: boolean, setHandlingValidationStatus: (handlingValidationStatus: ValidateStatus) => void, defaultPlaceholder: string, allowClearSelect?: boolean) => React.ReactNode;
|
|
20
|
+
export declare const getInput: (fieldDefinition: FieldDefinition, namePath: NamePath, validationCallName: string, legalIdentifier: string, formInstance: FormInstance, rapiBaseUrl: string, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void, setAccountingCostFieldProps: (accountingCostFiledProps: FormItemPropsWithoutChildren) => void, accountingCostFieldProps: FormItemPropsWithoutChildren, setLoadingAccountingCostValues: (loadingAccountingCostValues: boolean) => void, loadingAccountingCostValues: boolean, setHandlingValidationStatus: (handlingValidationStatus: ValidateStatus) => void, defaultPlaceholder: string, allowClearSelect?: boolean, allowLocalSearch?: boolean) => React.ReactNode;
|
|
21
21
|
export declare const getRequiredTooltipMessage: (title: string, fieldNames: string[]) => React.ReactNode;
|
|
22
22
|
export declare const getRequiredTooltipErrorMessages: (errors: Record<string, ValidationErrorDisplayObject[]>) => React.ReactNode;
|
|
23
23
|
export declare const paymentMeansTypeFieldHasValues: (paymentMeansTypeFieldDefinition: FieldDefinition | undefined) => boolean | undefined;
|
|
@@ -147,7 +147,7 @@ var handleValueSearch = function (searchValue, fieldDefinition, setLoadingValues
|
|
|
147
147
|
}
|
|
148
148
|
};
|
|
149
149
|
exports.debouncedHandleSearchValues = (0, lodash_1.debounce)(handleValueSearch, 500);
|
|
150
|
-
var getInput = function (fieldDefinition, namePath, validationCallName, legalIdentifier, formInstance, rapiBaseUrl, receiverRequirements, updateReceiverRequirementsProp, setAccountingCostFieldProps, accountingCostFieldProps, setLoadingAccountingCostValues, loadingAccountingCostValues, setHandlingValidationStatus, defaultPlaceholder, allowClearSelect) {
|
|
150
|
+
var getInput = function (fieldDefinition, namePath, validationCallName, legalIdentifier, formInstance, rapiBaseUrl, receiverRequirements, updateReceiverRequirementsProp, setAccountingCostFieldProps, accountingCostFieldProps, setLoadingAccountingCostValues, loadingAccountingCostValues, setHandlingValidationStatus, defaultPlaceholder, allowClearSelect, allowLocalSearch) {
|
|
151
151
|
var handling = null;
|
|
152
152
|
if (fieldDefinition.properties.handling) {
|
|
153
153
|
handling = JSON.parse(fieldDefinition.properties.handling);
|
|
@@ -168,10 +168,16 @@ var getInput = function (fieldDefinition, namePath, validationCallName, legalIde
|
|
|
168
168
|
},
|
|
169
169
|
loading: loadingAccountingCostValues,
|
|
170
170
|
}
|
|
171
|
-
: {}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
: __assign({}, (allowLocalSearch ? {
|
|
172
|
+
showSearch: true,
|
|
173
|
+
optionFilterProp: 'label'
|
|
174
|
+
} : {}));
|
|
175
|
+
return (react_1.default.createElement(antd_1.Select, __assign({ popupMatchSelectWidth: false, allowClear: allowClearSelect }, selectProps, { placeholder: placeholder, options: fieldDefinition.properties.values.map(function (op) {
|
|
176
|
+
return {
|
|
177
|
+
value: op.key,
|
|
178
|
+
label: op.name,
|
|
179
|
+
};
|
|
180
|
+
}) })));
|
|
175
181
|
}
|
|
176
182
|
else {
|
|
177
183
|
return (react_1.default.createElement(antd_1.Input, { allowClear: allowClearSelect, placeholder: placeholder }));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IntlShape } from "react-intl";
|
|
2
|
+
import { SubmittingStatus } from "../common/components/submit-confirmation/AttachmentUploadStatus";
|
|
3
|
+
import { AttachmentProps } from "../create-invoice";
|
|
4
|
+
declare const getAttachmentsText: (_status: SubmittingStatus, _name: string, intl: IntlShape) => string;
|
|
5
|
+
declare const getInvoiceText: (_status: SubmittingStatus, intl: IntlShape) => string;
|
|
6
|
+
declare const getSuccessPercent: (allAttachments: AttachmentProps[], percentUnit: number, invoiceSubmittingStatus: SubmittingStatus) => number;
|
|
7
|
+
declare const getProgressPercent: (numberOfSuccessfulCalls: number, numberOfFailedUploads: number, totalNumberOfCalls: number, percentUnit: number, invoiceSubmittingStatus: SubmittingStatus, numberOfAttemptedCalls: number) => number;
|
|
8
|
+
declare const getNumberOfFailedAttachments: (attachments: AttachmentProps[]) => number;
|
|
9
|
+
declare const getNumberOfUploadedAttachments: (attachments: AttachmentProps[]) => number;
|
|
10
|
+
declare const getStatusOfAttachment: (attachments: AttachmentProps[], name: string) => SubmittingStatus;
|
|
11
|
+
declare const getAllFailedUploads: (allAttachmentsWithStatuses: AttachmentProps[]) => AttachmentProps[];
|
|
12
|
+
declare const getAllSuccessfulUploads: (allAttachmentsWithStatuses: AttachmentProps[]) => AttachmentProps[];
|
|
13
|
+
export { getAttachmentsText, getInvoiceText, getSuccessPercent, getProgressPercent, getNumberOfFailedAttachments, getNumberOfUploadedAttachments, getStatusOfAttachment, getAllFailedUploads, getAllSuccessfulUploads };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAllSuccessfulUploads = exports.getAllFailedUploads = exports.getStatusOfAttachment = exports.getNumberOfUploadedAttachments = exports.getNumberOfFailedAttachments = exports.getProgressPercent = exports.getSuccessPercent = exports.getInvoiceText = exports.getAttachmentsText = void 0;
|
|
4
|
+
var AttachmentUploadStatus_1 = require("../common/components/submit-confirmation/AttachmentUploadStatus");
|
|
5
|
+
var submit_confirmation_1 = require("../common/components/submit-confirmation");
|
|
6
|
+
var getAttachmentsText = function (_status, _name, intl) {
|
|
7
|
+
switch (_status) {
|
|
8
|
+
case AttachmentUploadStatus_1.SubmittingStatus.Failed:
|
|
9
|
+
return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_attachmentFailedToUpload), " ").concat(_name);
|
|
10
|
+
case AttachmentUploadStatus_1.SubmittingStatus.Done:
|
|
11
|
+
return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_successfullyUploadedAttachment), " ").concat(_name);
|
|
12
|
+
case AttachmentUploadStatus_1.SubmittingStatus.Pending:
|
|
13
|
+
return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingAttachment), " ").concat(_name);
|
|
14
|
+
default:
|
|
15
|
+
return "".concat(intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingAttachment), " ").concat(_name);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
exports.getAttachmentsText = getAttachmentsText;
|
|
19
|
+
var getInvoiceText = function (_status, intl) {
|
|
20
|
+
switch (_status) {
|
|
21
|
+
case AttachmentUploadStatus_1.SubmittingStatus.Failed:
|
|
22
|
+
return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoiceFailed);
|
|
23
|
+
case AttachmentUploadStatus_1.SubmittingStatus.Done:
|
|
24
|
+
return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoiceSuccessful);
|
|
25
|
+
case AttachmentUploadStatus_1.SubmittingStatus.Pending:
|
|
26
|
+
return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoice);
|
|
27
|
+
default:
|
|
28
|
+
return intl.formatMessage(submit_confirmation_1.translationMessages.submitConfirmation_submittingInvoice);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
exports.getInvoiceText = getInvoiceText;
|
|
32
|
+
var getSuccessPercent = function (allAttachments, percentUnit, invoiceSubmittingStatus) {
|
|
33
|
+
if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Pending) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
var successfulAttachments = getNumberOfUploadedAttachments(allAttachments);
|
|
38
|
+
var numberOfSuccessfulCalls = invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed ? successfulAttachments : successfulAttachments + 1;
|
|
39
|
+
return numberOfSuccessfulCalls * percentUnit;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.getSuccessPercent = getSuccessPercent;
|
|
43
|
+
var getProgressPercent = function (numberOfSuccessfulCalls, numberOfFailedUploads, totalNumberOfCalls, percentUnit, invoiceSubmittingStatus, numberOfAttemptedCalls) {
|
|
44
|
+
if (invoiceSubmittingStatus === AttachmentUploadStatus_1.SubmittingStatus.Failed) {
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
else if ((numberOfSuccessfulCalls + numberOfFailedUploads) === totalNumberOfCalls) {
|
|
48
|
+
return numberOfSuccessfulCalls * percentUnit;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return numberOfAttemptedCalls * percentUnit;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
exports.getProgressPercent = getProgressPercent;
|
|
55
|
+
var getNumberOfFailedAttachments = function (attachments) {
|
|
56
|
+
return attachments.filter(function (attachment) { return attachment.status === AttachmentUploadStatus_1.SubmittingStatus.Failed; }).length;
|
|
57
|
+
};
|
|
58
|
+
exports.getNumberOfFailedAttachments = getNumberOfFailedAttachments;
|
|
59
|
+
var getNumberOfUploadedAttachments = function (attachments) {
|
|
60
|
+
return attachments.filter(function (attachment) { return attachment.status === AttachmentUploadStatus_1.SubmittingStatus.Done; }).length;
|
|
61
|
+
};
|
|
62
|
+
exports.getNumberOfUploadedAttachments = getNumberOfUploadedAttachments;
|
|
63
|
+
var getStatusOfAttachment = function (attachments, name) {
|
|
64
|
+
var attachment = attachments === null || attachments === void 0 ? void 0 : attachments.find(function (att) { return att.description === name; });
|
|
65
|
+
return attachment ? attachment.status : AttachmentUploadStatus_1.SubmittingStatus.Pending;
|
|
66
|
+
};
|
|
67
|
+
exports.getStatusOfAttachment = getStatusOfAttachment;
|
|
68
|
+
var getAllFailedUploads = function (allAttachmentsWithStatuses) {
|
|
69
|
+
var failedAttachments = [];
|
|
70
|
+
allAttachmentsWithStatuses.forEach(function (at) {
|
|
71
|
+
if (at.status === AttachmentUploadStatus_1.SubmittingStatus.Failed) {
|
|
72
|
+
failedAttachments.push(at);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return failedAttachments;
|
|
76
|
+
};
|
|
77
|
+
exports.getAllFailedUploads = getAllFailedUploads;
|
|
78
|
+
var getAllSuccessfulUploads = function (allAttachmentsWithStatuses) {
|
|
79
|
+
var successfulUploads = [];
|
|
80
|
+
allAttachmentsWithStatuses.forEach(function (at) {
|
|
81
|
+
if (at.status === AttachmentUploadStatus_1.SubmittingStatus.Done) {
|
|
82
|
+
successfulUploads.push(at);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return successfulUploads;
|
|
86
|
+
};
|
|
87
|
+
exports.getAllSuccessfulUploads = getAllSuccessfulUploads;
|