@unimaze/billing 0.21.39 → 0.21.41

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.
@@ -51,6 +51,7 @@ var FileUploadUtility_1 = require("../../../utils/FileUploadUtility");
51
51
  var lib_1 = require("antd/lib");
52
52
  var formLayout_1 = require("../../consts/formLayout");
53
53
  var validationRules_1 = require("../../consts/validationRules");
54
+ var react_1 = require("react");
54
55
  var translationMessages = (0, react_intl_1.defineMessages)({
55
56
  attachment_title: {
56
57
  id: "attachment_title",
@@ -88,10 +89,15 @@ var translationMessages = (0, react_intl_1.defineMessages)({
88
89
  id: "attachment_labels_Description",
89
90
  defaultMessage: "Description",
90
91
  },
92
+ attachments_sameDescription_warning: {
93
+ id: "attachments_sameDescription_warning",
94
+ defaultMessage: "Please provide a unique description for this attachment.",
95
+ },
91
96
  });
92
97
  var AttachmentModal = function (props) {
93
98
  var _a = React.useState(false), isUploading = _a[0], setIsUploading = _a[1];
94
99
  var _b = React.useState(true), isSaveAttachmentsDisabled = _b[0], setIsSaveAttachmentsDisabled = _b[1];
100
+ var _c = (0, react_1.useState)(false), sameDescriptionWarning = _c[0], setSameDescriptionWarning = _c[1];
95
101
  var normFile = function (e) {
96
102
  if (!e)
97
103
  return;
@@ -108,6 +114,15 @@ var AttachmentModal = function (props) {
108
114
  else {
109
115
  var updatedAttachments = props.attachments.map(function (attachment) {
110
116
  if (attachment.file.uid === file.uid) {
117
+ var filterAlreadyExist = props.attachments.filter(function (att) {
118
+ return att.uid !== file.uid && att.description === updatedProps.description;
119
+ });
120
+ if ((filterAlreadyExist === null || filterAlreadyExist === void 0 ? void 0 : filterAlreadyExist.length) > 0) {
121
+ setSameDescriptionWarning(true);
122
+ }
123
+ else {
124
+ setSameDescriptionWarning(false);
125
+ }
111
126
  return __assign(__assign({}, attachment), updatedProps);
112
127
  }
113
128
  return attachment;
@@ -116,7 +131,7 @@ var AttachmentModal = function (props) {
116
131
  }
117
132
  };
118
133
  React.useEffect(function () {
119
- var _isSaveAttachmentsDisabled = props.attachments.length > 0 ? props.attachments.some(function (attachment) { return attachment.fieldValidation !== "success" || (!attachment.description.trim()); }) : true;
134
+ var _isSaveAttachmentsDisabled = props.attachments.length > 0 ? props.attachments.some(function (attachment) { return attachment.fieldValidation !== "success" || (!attachment.description.trim() || sameDescriptionWarning); }) : true;
120
135
  setIsSaveAttachmentsDisabled(_isSaveAttachmentsDisabled);
121
136
  }, [props.attachments]);
122
137
  var verifyAttachment = function (info, uploadSizeLimit, onRemove) {
@@ -182,10 +197,11 @@ var AttachmentModal = function (props) {
182
197
  }
183
198
  }
184
199
  };
185
- return (React.createElement(antd_1.Modal, { open: props.isModalOpen, onCancel: props.onCancel, title: props.intl.formatMessage(translationMessages.attachment_title), footer: React.createElement(antd_1.Button, { disabled: isSaveAttachmentsDisabled, icon: React.createElement(icons_1.CheckCircleOutlined, null), type: "primary", style: { width: "100%" }, size: "large", onClick: function () {
186
- props.onSave();
187
- props.setIsModalOpen(false);
188
- } }, props.intl.formatMessage(translationMessages.attachment_saveButton_title)) },
200
+ return (React.createElement(antd_1.Modal, { open: props.isModalOpen, onCancel: props.onCancel, title: props.intl.formatMessage(translationMessages.attachment_title), footer: React.createElement(antd_1.Tooltip, { title: sameDescriptionWarning ? props.intl.formatMessage(translationMessages.attachments_sameDescription_warning) : undefined },
201
+ React.createElement(antd_1.Button, { disabled: isSaveAttachmentsDisabled, icon: React.createElement(icons_1.CheckCircleOutlined, null), type: "primary", style: { width: "100%" }, size: "large", onClick: function () {
202
+ props.onSave();
203
+ props.setIsModalOpen(false);
204
+ } }, props.intl.formatMessage(translationMessages.attachment_saveButton_title))) },
189
205
  React.createElement(lib_1.Form.Item, __assign({}, formLayout_1.fullWidthInput, { valuePropName: "fileList", getValueFromEvent: normFile, className: "upload-container" }),
190
206
  React.createElement(antd_1.Upload, __assign({}, uploadProps, { style: { width: '100%' } }),
191
207
  React.createElement(antd_1.Button, { loading: isUploading, disabled: uploadProps.disabled, icon: React.createElement(icons_1.UploadOutlined, null), size: "large", style: { width: "100%" } }, isUploading
@@ -41,7 +41,6 @@ var react_1 = require("react");
41
41
  var ProjectReference_1 = __importDefault(require("./ProjectReference"));
42
42
  var __1 = require("..");
43
43
  var react_use_1 = require("react-use");
44
- var CommonTranslations_1 = require("../CommonTranslations");
45
44
  exports.translationMessages = (0, react_intl_1.defineMessages)({
46
45
  baseInformation_title: {
47
46
  id: "baseInformation_title",
@@ -179,8 +178,7 @@ var BaseInformation = function (props) {
179
178
  React.createElement(__1.UmzInput, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.buyerReference, defaultIsRequired: !props.form.getFieldValue(["invoice", "orderReference", "documentNo"]), defaultPlaceholder: props.intl.formatMessage(exports.translationMessages.baseInformation_buyerReferenceLabel), defaultTooltip: props.intl.formatMessage(exports.translationMessages.baseInformation_buyerReferenceLabel_helpText), defaultValue: (_b = formData.invoice) === null || _b === void 0 ? void 0 : _b.buyerReference })),
180
179
  React.createElement(ReferenceIdentifiers_1.default, { receiverRequirements: props.receiverRequirements, formInstance: props.form, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: props.legalIdentifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: props.referenceIdentifierValidateStatus, setReferenceIdentifierValidateStatus: props.setReferenceIdentifierValidateStatus, setReferenceIdentifierIsMandatory: props.setReferenceIdentifierIsMandatory }),
181
180
  React.createElement(AccountingCost_1.default, { formInstance: props.form, rapiBaseUrl: props.rapiBaseUrl, receiverRequirements: props.receiverRequirements, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, legalIdentifier: props.legalIdentifier }),
182
- React.createElement(ProjectReference_1.default, { receiverRequirements: props.receiverRequirements, form: props.form }))),
183
- React.createElement(antd_1.Checkbox, { checked: props.isSaveFieldValuesSelected, onChange: props.onSaveFieldValuesChange }, props.intl.formatMessage(CommonTranslations_1.commonTranslationMessages.saveInformation_label)))));
181
+ React.createElement(ProjectReference_1.default, { receiverRequirements: props.receiverRequirements, form: props.form }))))));
184
182
  };
185
183
  var BaseInformationIntl = (0, react_intl_1.injectIntl)(BaseInformation);
186
184
  exports.default = BaseInformationIntl;
@@ -36,6 +36,7 @@ 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 RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
39
40
  exports.translationMessages = (0, react_intl_1.defineMessages)({
40
41
  billingLines_title: {
41
42
  id: "billingLines_title",
@@ -81,6 +82,11 @@ var BillingLines = function (props) {
81
82
  var currencyCode = props.formInstance.getFieldValue(["invoice", "currencyCode"])
82
83
  ? props.formInstance.getFieldValue(["invoice", "currencyCode"])
83
84
  : "";
85
+ var getTextAreaPlaceholder = function () {
86
+ var isNoteRequired = (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields.notes, false);
87
+ var notesPlaceholder = props.intl.formatMessage(exports.translationMessages.baseInformation_notes);
88
+ return isNoteRequired ? ("* " + notesPlaceholder) : notesPlaceholder;
89
+ };
84
90
  return (React.createElement(antd_1.Flex, { justify: "center" },
85
91
  React.createElement(antd_1.Flex, { vertical: true, style: { width: "100%", maxWidth: "900px", paddingBottom: isMobile ? "20px" : "35px" }, gap: "middle" },
86
92
  React.createElement(antd_1.Flex, { gap: isMobile ? "small" : "middle", vertical: true, style: isMobile
@@ -99,7 +105,7 @@ var BillingLines = function (props) {
99
105
  React.createElement(antd_1.Flex, { gap: "middle", vertical: true },
100
106
  React.createElement(BillingCalculations_1.default, { currencyCode: currencyCode, formInstance: props.formInstance, outsideVatScope: props.outsideVatScope, newLineSaved: newLineSaved })),
101
107
  React.createElement(form_item_1.default, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields.notes, defaultLabel: props.intl.formatMessage(exports.translationMessages.baseInformation_notes), defaultIsRequired: false, fieldName: ["invoice", "notes"], style: { marginBottom: 0 } },
102
- React.createElement(antd_1.Input.TextArea, { placeholder: props.intl.formatMessage(exports.translationMessages.baseInformation_notes) })))));
108
+ React.createElement(antd_1.Input.TextArea, { placeholder: getTextAreaPlaceholder() })))));
103
109
  };
104
110
  var BillingLinesIntl = (0, react_intl_1.injectIntl)(BillingLines);
105
111
  exports.default = BillingLinesIntl;
@@ -68,10 +68,10 @@ var InvoicePreviewPaymentInfoBox = function (props) {
68
68
  props.intl.formatMessage(index_2.translationMessages.paymentMethod_labels_domesticTransfer_paymentReference),
69
69
  ":",
70
70
  " ",
71
- props.form.getFieldValue(["invoice", "paymentMeans", "domesticTransfer", "paymentIdentifier",]))),
72
- props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
73
- props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim", "bankNumber",]),
74
- "-66-",
75
- props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim", "accountNumber",])))))))));
71
+ props.form.getFieldValue(["invoice", "paymentMeans", "domesticTransfer", "paymentIdentifier",]))))),
72
+ props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim"]) && (react_1.default.createElement(react_1.default.Fragment, null, props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim"]) && (react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
73
+ props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim", "bankNumber",]),
74
+ "-66-",
75
+ props.form.getFieldValue(["invoice", "paymentMeans", "domesticClaim", "accountNumber",])))))))));
76
76
  };
77
77
  exports.default = (0, react_intl_1.injectIntl)(InvoicePreviewPaymentInfoBox);
@@ -107,19 +107,50 @@ var PaymentMethod = function (props) {
107
107
  }
108
108
  }, [width]);
109
109
  var _b = (0, react_1.useState)(mapi_1.PaymentMeansType.DomesticClaim), paymentMethod = _b[0], setPaymentMethod = _b[1];
110
+ var _c = (0, react_1.useState)(undefined), paymentMeansFromStorage = _c[0], setPaymentMeansFromStorage = _c[1];
110
111
  (0, react_1.useEffect)(function () {
111
- if (props.formInstance.getFieldValue(["invoice", "paymentMeans", "type"]) === mapi_1.PaymentMeansType.DomesticTransfer && !props.formInstance.getFieldValue(["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"])) {
112
- props.formInstance.setFieldValue(["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"], "04");
113
- }
114
- }, [props.formInstance.getFieldValue(["invoice", "paymentMeans", "type"])]);
115
- (0, react_1.useEffect)(function () {
116
- var _a, _b;
112
+ var _a, _b, _c, _d, _e, _f;
117
113
  var formFromLocalStorage = (0, LocalStorageUtility_1.getFormFromLocalStorage)(props.localStorageFormDataVersion);
118
114
  var paymentTypeFromLocalStorage = (_b = (_a = formFromLocalStorage === null || formFromLocalStorage === void 0 ? void 0 : formFromLocalStorage.invoice) === null || _a === void 0 ? void 0 : _a.paymentMeans) === null || _b === void 0 ? void 0 : _b.type;
119
115
  var paymentFromFormInitialValue = props.formInstance.getFieldValue(["invoice", "paymentMeans", "type"]);
120
116
  var initialType = paymentTypeFromLocalStorage ? mapi_1.PaymentMeansType[paymentTypeFromLocalStorage] : mapi_1.PaymentMeansType[paymentFromFormInitialValue];
117
+ if (paymentTypeFromLocalStorage) {
118
+ if (paymentTypeFromLocalStorage === mapi_1.PaymentMeansType.DomesticTransfer) {
119
+ setPaymentMeansFromStorage((_d = (_c = formFromLocalStorage === null || formFromLocalStorage === void 0 ? void 0 : formFromLocalStorage.invoice) === null || _c === void 0 ? void 0 : _c.paymentMeans) === null || _d === void 0 ? void 0 : _d.domesticTransfer);
120
+ }
121
+ else if (paymentTypeFromLocalStorage === mapi_1.PaymentMeansType.DomesticClaim) {
122
+ setPaymentMeansFromStorage((_f = (_e = formFromLocalStorage === null || formFromLocalStorage === void 0 ? void 0 : formFromLocalStorage.invoice) === null || _e === void 0 ? void 0 : _e.paymentMeans) === null || _f === void 0 ? void 0 : _f.domesticClaim);
123
+ }
124
+ }
125
+ else {
126
+ setPaymentMeansFromStorage(undefined);
127
+ }
121
128
  setPaymentMethod(initialType);
122
129
  }, []);
130
+ (0, react_1.useEffect)(function () {
131
+ props.formInstance.setFieldValue(["invoice", "paymentMeans"], null);
132
+ if (paymentMethod === mapi_1.PaymentMeansType.DomesticTransfer) {
133
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "type"], mapi_1.PaymentMeansType.DomesticTransfer);
134
+ if (paymentMeansFromStorage) {
135
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "domesticTransfer"], paymentMeansFromStorage);
136
+ }
137
+ else {
138
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"], "04");
139
+ }
140
+ }
141
+ else if (paymentMethod === mapi_1.PaymentMeansType.DomesticClaim) {
142
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "type"], mapi_1.PaymentMeansType.DomesticClaim);
143
+ if (paymentMeansFromStorage) {
144
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "domesticClaim"], paymentMeansFromStorage);
145
+ }
146
+ else {
147
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "domesticClaim"], {});
148
+ }
149
+ }
150
+ else {
151
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "type"], paymentMethod);
152
+ }
153
+ }, [paymentMethod, paymentMeansFromStorage]);
123
154
  var domesticTransferFormFields = (react_1.default.createElement(react_1.default.Fragment, null,
124
155
  react_1.default.createElement(antd_1.Form.Item, null,
125
156
  react_1.default.createElement(antd_1.Row, { gutter: [8, 0] },
@@ -139,7 +170,7 @@ var PaymentMethod = function (props) {
139
170
  }),
140
171
  },
141
172
  ] },
142
- react_1.default.createElement(components_1.UmzInput, { defaultIsRequired: true, defaultPlaceholder: props.intl.formatMessage(exports.translationMessages.paymentMethod_labels_domesticTransfer_bankNo) }))),
173
+ react_1.default.createElement(components_1.UmzInput, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["paymentMeans.domesticTransfer.bankNumber"], defaultIsRequired: true, defaultPlaceholder: props.intl.formatMessage(exports.translationMessages.paymentMethod_labels_domesticTransfer_bankNo) }))),
143
174
  react_1.default.createElement(antd_1.Col, { span: 6 },
144
175
  react_1.default.createElement(antd_1.Form.Item, { noStyle: true,
145
176
  // label={props.intl.formatMessage(translationMessages.paymentMethod_labels_domesticTransfer_accountType)}
@@ -283,6 +314,10 @@ var PaymentMethod = function (props) {
283
314
  if ((0, RequirementsUtility_1.paymentMeansTypeFieldHasValues)(paymentMeansTypeFieldDefinition) && ((_b = (_a = paymentMeansTypeFieldDefinition === null || paymentMeansTypeFieldDefinition === void 0 ? void 0 : paymentMeansTypeFieldDefinition.properties) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b.length) === 1) {
284
315
  var paymentFromReceiverRequirements = paymentMeansTypeFieldDefinition.properties.values[0].key;
285
316
  if (paymentMethod !== paymentFromReceiverRequirements) {
317
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "type"], paymentFromReceiverRequirements);
318
+ if (paymentFromReceiverRequirements === mapi_1.PaymentMeansType.DomesticTransfer && !props.formInstance.getFieldValue(["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"])) {
319
+ props.formInstance.setFieldValue(["invoice", "paymentMeans", "domesticTransfer", "accountTypeNumber"], "04");
320
+ }
286
321
  setPaymentMethod(paymentFromReceiverRequirements);
287
322
  }
288
323
  return paymentMeansTypeFieldDefinition.properties.values[0].name;
@@ -1,22 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentMethodFormData = void 0;
4
+ var mapi_1 = require("@unimaze/api-clients/lib/mapi");
4
5
  var PaymentMethodFormData = function (formData) {
5
- if (formData.invoice.paymentMeans.type === "DomesticTransfer") {
6
+ var _a, _b;
7
+ if (formData.invoice.paymentMeans.type === "DomesticTransfer" || ((_a = formData.invoice.paymentMeans) === null || _a === void 0 ? void 0 : _a.domesticTransfer) !== undefined) {
6
8
  return {
7
- type: formData.invoice.paymentMeans.type,
9
+ type: mapi_1.PaymentMeansType.DomesticTransfer,
8
10
  domesticTransfer: formData.invoice.paymentMeans.domesticTransfer
9
11
  };
10
12
  }
11
- if (formData.invoice.paymentMeans.type === "DomesticClaim") {
13
+ if (formData.invoice.paymentMeans.type === "DomesticClaim" || ((_b = formData.invoice.paymentMeans) === null || _b === void 0 ? void 0 : _b.domesticClaim) !== undefined) {
12
14
  return {
13
- type: formData.invoice.paymentMeans.type,
15
+ type: mapi_1.PaymentMeansType.DomesticClaim,
14
16
  domesticClaim: formData.invoice.paymentMeans.domesticClaim,
15
17
  };
16
18
  }
17
- if (formData.invoice.paymentMeans.type === "NotSpecified" || formData.invoice.paymentMeans.type === "MutuallyAgreed") {
19
+ if (formData.invoice.paymentMeans.type === "NotSpecified") {
18
20
  return {
19
- type: formData.invoice.paymentMeans.type
21
+ type: mapi_1.PaymentMeansType.NotSpecified,
22
+ };
23
+ }
24
+ if (formData.invoice.paymentMeans.type === "MutuallyAgreed") {
25
+ return {
26
+ type: mapi_1.PaymentMeansType.MutuallyAgreed
20
27
  };
21
28
  }
22
29
  var paymentMeansFull = {
@@ -1,8 +1,14 @@
1
+ import { FormInstance } from "antd";
1
2
  import { WrappedComponentProps } from "react-intl";
2
3
  import React from "react";
3
4
  interface Props extends WrappedComponentProps {
5
+ numberOfSuccessfulCalls: number;
6
+ totalNumberOfCalls: number;
7
+ form: FormInstance;
4
8
  }
5
- declare const _default: React.FC<import("react-intl").WithIntlProps<Props>> & {
9
+ declare const _default: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
10
+ forwardedRef?: React.Ref<any>;
11
+ } & React.RefAttributes<any>> & {
6
12
  WrappedComponent: React.ComponentType<Props>;
7
13
  };
8
14
  export default _default;
@@ -1,11 +1,34 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
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;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  var antd_1 = require("antd");
7
30
  var react_intl_1 = require("react-intl");
8
- var react_1 = __importDefault(require("react"));
31
+ var react_1 = __importStar(require("react"));
9
32
  var SubmitConfirmationSVG_1 = __importDefault(require("./SubmitConfirmationSVG"));
10
33
  var translationMessages = (0, react_intl_1.defineMessages)({
11
34
  submitConfirmation_title: {
@@ -20,15 +43,47 @@ var translationMessages = (0, react_intl_1.defineMessages)({
20
43
  id: "submitConfirmation_footer_text",
21
44
  defaultMessage: "If any questions arise, please contact us at",
22
45
  },
46
+ submitConfirmation_successfullyCreatedInvoice: {
47
+ id: "submitConfirmation_successfullyCreatedInvoice",
48
+ defaultMessage: "Successfully created invoice",
49
+ },
50
+ submitConfirmation_SuccessfullyUploadedAttachment: {
51
+ id: "submitConfirmation_SuccessfullyUploadedAttachment",
52
+ defaultMessage: "Successfully uploaded attachment:",
53
+ },
23
54
  });
24
55
  var SubmitConfirmation = function (props) {
56
+ var numberOfSuccessfulCalls = props.numberOfSuccessfulCalls, totalNumberOfCalls = props.totalNumberOfCalls, form = props.form;
57
+ var _a = (0, react_1.useState)([]), attachmentsNames = _a[0], setAttachmentsNames = _a[1];
25
58
  var token = antd_1.theme.useToken().token;
59
+ var percentUnit = 100 / totalNumberOfCalls;
60
+ (0, react_1.useEffect)(function () {
61
+ var _a, _b, _c, _d, _e;
62
+ var attachments = form.getFieldValue(['attachments']);
63
+ 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)) {
64
+ 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]);
65
+ }
66
+ }, [form]);
67
+ var getAttachmentUploadMessage = function (attachmentName) {
68
+ return react_1.default.createElement(antd_1.Typography.Title, { level: 5, style: { margin: 5 } }, "".concat(props.intl.formatMessage(translationMessages.submitConfirmation_SuccessfullyUploadedAttachment)).concat(attachmentName));
69
+ };
70
+ var getCreatedInvoiceMessage = function () {
71
+ return react_1.default.createElement(antd_1.Typography.Title, { level: 5, style: { margin: 5 } }, props.intl.formatMessage(translationMessages.submitConfirmation_successfullyCreatedInvoice));
72
+ };
26
73
  return (react_1.default.createElement(antd_1.Flex, { justify: "center", style: { padding: "45px" } },
27
74
  react_1.default.createElement(antd_1.Flex, { vertical: true, justify: "center", align: "center", style: { width: "100%", maxWidth: "900px" }, gap: "small" },
28
75
  react_1.default.createElement(SubmitConfirmationSVG_1.default, null),
29
76
  " ",
30
- react_1.default.createElement(antd_1.Flex, { vertical: true, align: "center", style: { paddingTop: "20px" } },
31
- react_1.default.createElement(antd_1.Typography.Title, { level: 2 }, props.intl.formatMessage(translationMessages.submitConfirmation_title)),
32
- react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4, textAlign: "center" } }, props.intl.formatMessage(translationMessages.submitConfirmation_text))))));
77
+ react_1.default.createElement(antd_1.Flex, { justify: "center", align: "center", style: { width: "100%", maxWidth: "900px" }, gap: "small" },
78
+ react_1.default.createElement(antd_1.Progress, { showInfo: false, percent: (numberOfSuccessfulCalls + 1) * percentUnit, success: { percent: numberOfSuccessfulCalls * percentUnit } }),
79
+ react_1.default.createElement(antd_1.Spin, { size: "small", spinning: totalNumberOfCalls !== numberOfSuccessfulCalls })),
80
+ numberOfSuccessfulCalls >= 1 && getCreatedInvoiceMessage(),
81
+ numberOfSuccessfulCalls >= 2 && getAttachmentUploadMessage(attachmentsNames[0]),
82
+ numberOfSuccessfulCalls >= 3 && getAttachmentUploadMessage(attachmentsNames[1]),
83
+ numberOfSuccessfulCalls >= 4 && getAttachmentUploadMessage(attachmentsNames[2]),
84
+ totalNumberOfCalls === numberOfSuccessfulCalls &&
85
+ react_1.default.createElement(antd_1.Flex, { vertical: true, align: "center", style: { paddingTop: "20px" } },
86
+ react_1.default.createElement(antd_1.Typography.Title, { level: 2 }, props.intl.formatMessage(translationMessages.submitConfirmation_title)),
87
+ react_1.default.createElement(antd_1.Typography.Text, { style: { fontSize: token.fontSizeHeading4, textAlign: "center" } }, props.intl.formatMessage(translationMessages.submitConfirmation_text))))));
33
88
  };
34
89
  exports.default = (0, react_intl_1.injectIntl)(SubmitConfirmation);
@@ -42,5 +42,6 @@ var invoiceFieldPaths = [
42
42
  ["invoice", "invoiceLines"],
43
43
  ["invoice", "singleReferenceIdentifier", "value"],
44
44
  ["invoice", "referenceIdentifiers"],
45
+ ["invoice", "notes"],
45
46
  ];
46
47
  exports.invoiceFieldPaths = invoiceFieldPaths;
@@ -383,6 +383,8 @@ var CreateInvoiceConstructor = function (props) {
383
383
  // setSendCopyDisabled(true);
384
384
  // }
385
385
  // }, [supplierEmail]);
386
+ var _2 = (0, react_1.useState)(0), totalNumberOfCalls = _2[0], setTotalNumberOfCalls = _2[1];
387
+ var _3 = (0, react_1.useState)(0), numberOfSuccessfulCalls = _3[0], setNumberOfSuccessfulCalls = _3[1];
386
388
  var handleSubmit = function (_values) {
387
389
  var _a, _b, _c, _d, _e, _f;
388
390
  setSubmitting(true);
@@ -417,18 +419,20 @@ var CreateInvoiceConstructor = function (props) {
417
419
  };
418
420
  (0, ApiUtility_1.getAuthToken)(props.rapiBaseUrl, chosenCustomer === null || chosenCustomer === void 0 ? void 0 : chosenCustomer.identifier).then(function (getAuthTokenResponse) {
419
421
  var token = getAuthTokenResponse.data;
422
+ setActiveStep(activeStep + 1);
423
+ setTotalNumberOfCalls((attachments === null || attachments === void 0 ? void 0 : attachments.length) + 1);
420
424
  (0, utils_1.submitInvoice)(createSubmitInvoice, props.mapiBaseUrl, token, "submitInvoice", props.language)
421
425
  .then(function (submitInvoiceResponse) {
422
426
  var _a;
427
+ setNumberOfSuccessfulCalls(numberOfSuccessfulCalls + 1);
423
428
  antd_1.message.success(intl.formatMessage(exports.translationMessages.createInvoice_successfullySubmittedInvoiceMsg));
424
429
  if (submitInvoiceResponse.status === 201) {
425
430
  var response = submitInvoiceResponse.data;
426
- (0, ApiUtility_1.submitAttachmentIfAnyLeft)((_a = response === null || response === void 0 ? void 0 : response.uniqueId) !== null && _a !== void 0 ? _a : "", attachments, props.mapiBaseUrl, token, intl);
431
+ (0, ApiUtility_1.submitAttachmentIfAnyLeft)((_a = response === null || response === void 0 ? void 0 : response.uniqueId) !== null && _a !== void 0 ? _a : "", attachments, props.mapiBaseUrl, token, intl, 1, setNumberOfSuccessfulCalls);
427
432
  }
428
433
  else {
429
434
  antd_1.message.error("Created invoice had validation errors");
430
435
  }
431
- setActiveStep(activeStep + 1);
432
436
  setSubmitting(false);
433
437
  form.resetFields();
434
438
  form.setFields([
@@ -540,7 +544,7 @@ var CreateInvoiceConstructor = function (props) {
540
544
  name: defaultCustomer.name,
541
545
  });
542
546
  }
543
- var _2 = (0, react_1.useState)(undefined), billingLinesMetadata = _2[0], setBillingLinesMetadata = _2[1];
547
+ var _4 = (0, react_1.useState)(undefined), billingLinesMetadata = _4[0], setBillingLinesMetadata = _4[1];
544
548
  var getBillingLines = function (changedValues, allValues) {
545
549
  var invoiceLines = allValues.invoice.invoiceLines;
546
550
  if (invoiceLines) {
@@ -583,7 +587,7 @@ var CreateInvoiceConstructor = function (props) {
583
587
  title: intl.formatMessage(exports.translationMessages.createInvoice_paymentStepTitle),
584
588
  },
585
589
  ];
586
- return (react_1.default.createElement(antd_1.Spin, { spinning: submitting },
590
+ return (react_1.default.createElement(react_1.default.Fragment, null,
587
591
  react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "middle", style: { alignItems: "center", marginBottom: "50px" } },
588
592
  activeStep === items.length ? (react_1.default.createElement(components_1.InvoicePreviewHeader, { form: form })) : (activeStep < items.length && (react_1.default.createElement(antd_1.Steps, { style: { maxWidth: "900px", margin: isMobile ? 0 : "30px 0" }, current: activeStep, initial: 0, labelPlacement: "vertical", items: items, type: isMobile ? "navigation" : "default", size: isMobile ? "small" : "default", direction: "horizontal", responsive: false }))),
589
593
  react_1.default.createElement(antd_1.Layout.Content, null,
@@ -627,7 +631,7 @@ var CreateInvoiceConstructor = function (props) {
627
631
  react_1.default.createElement(reaptcha_1.default, { sitekey: "6LdMUdEZAAAAAG--2WEyu8CIRVlv6CzdZIwaQ-zt", ref: recaptchaRef, onVerify: function (response) {
628
632
  setCaptchaVerified(true);
629
633
  }, hl: props.language, onExpire: function () { return setCaptchaVerified(false); }, onError: function () { return setCaptchaVerified(false); } })))),
630
- activeStep === 5 && react_1.default.createElement(components_1.SubmitConfirmation, null),
634
+ activeStep === 5 && react_1.default.createElement(components_1.SubmitConfirmation, { numberOfSuccessfulCalls: numberOfSuccessfulCalls, totalNumberOfCalls: totalNumberOfCalls, form: form }),
631
635
  react_1.default.createElement(antd_1.Flex, { justify: "center" },
632
636
  react_1.default.createElement(antd_1.Flex, { gap: isMobile ? "middle" : 60, justify: "end", style: { width: "100%", maxWidth: "900px" } },
633
637
  isBackButtonVisible && (react_1.default.createElement(antd_1.Button, { onClick: handlePrevStep, size: "large", block: true },
@@ -14,6 +14,7 @@
14
14
  "attachment_saveButton_title": "Save attachments",
15
15
  "attachment_title": "Attachments",
16
16
  "attachment_tooltip_title": "The maximum size is {uploadSizeLimit}KB. Accepted file formats are JPG, PNG, PDF, CSV, XLSX and ODS.. Enclosed documents can be a copy of the original invoice, or timesheets for example.",
17
+ "attachments_sameDescription_warning": "Please provide a unique description for this attachment.",
17
18
  "baseInformation_accountingCostLabel": "Accounting cost",
18
19
  "baseInformation_accountingCostLabel_helpText": "Accounting cost is a code provided by the buyer, either via phone or e-mail or taken directly from the an order associated with the invoice",
19
20
  "baseInformation_buyerReferenceLabel": "Buyer reference",
@@ -147,7 +148,9 @@
147
148
  "referenceIdentifiers_labels_referenceIdentifier_title": "An identifier for an object on which the invoice is based, given by the seller. It may be a subscription number, telephone number, meter point, vehicle, person etc., as applicable.",
148
149
  "referenceIdentifiers_values_validation_message": "This value doesn't exist",
149
150
  "saveInformation_label": "Save information",
151
+ "submitConfirmation_SuccessfullyUploadedAttachment": "Successfully uploaded attachment:",
150
152
  "submitConfirmation_footer_text": "If any questions arise, please contact us at",
153
+ "submitConfirmation_successfullyCreatedInvoice": "Successfully created invoice",
151
154
  "submitConfirmation_text": "The invoice has been sent to the customer.",
152
155
  "submitConfirmation_title": "Invoice sent",
153
156
  "supplier_address_city": "City",
@@ -14,6 +14,7 @@
14
14
  "attachment_saveButton_title": "Vista viðhengi",
15
15
  "attachment_title": "Viðhengi",
16
16
  "attachment_tooltip_title": "Hámarks stærð er {uploadSizeLimit}KB. Tekið er við skráarsniðum JPG, PNG, PDF, CSV, XLSX og ODS. Fylgigögn reiknings geta verið afrit af upprunalega reikningnum eða fylgigögn, svo sem tímaskýrslur",
17
+ "attachments_sameDescription_warning": "Lýsing má ekki vera sú sama og á öðru viðhengi",
17
18
  "baseInformation_accountingCostLabel": "Bókunarlykill",
18
19
  "baseInformation_accountingCostLabel_helpText": "Bókunarlykill er kóti gefinn upp af kaupanda, gegnum tölvupóst eða síma eða fenginn beint úr pöntun sem tengist þessum reikningi",
19
20
  "baseInformation_buyerReferenceLabel": "Tilvísun kaupanda",
@@ -147,7 +148,9 @@
147
148
  "referenceIdentifiers_labels_referenceIdentifier_title": "Tilvísun í viðfang sem tengt er reikningi, gefið upp af seljanda. Gæti verið áskriftarnúmer, símanúmer, mælistaður, ökutæki, einstaklingur o.fl. eftir því sem við á.",
148
149
  "referenceIdentifiers_values_validation_message": "Þetta gildi er ekki til",
149
150
  "saveInformation_label": "Vista upplýsingar",
151
+ "submitConfirmation_SuccessfullyUploadedAttachment": "Viðhengi sem hefur verið sent:",
150
152
  "submitConfirmation_footer_text": "If any questions arise, please contact us at",
153
+ "submitConfirmation_successfullyCreatedInvoice": "Reikningur hefur verið stofnaður",
151
154
  "submitConfirmation_text": "The invoice has been sent to the customer.",
152
155
  "submitConfirmation_title": "Invoice sent",
153
156
  "supplier_address_city": "Borg",
@@ -15,6 +15,7 @@ declare const _default: {
15
15
  attachment_saveButton_title: string;
16
16
  attachment_title: string;
17
17
  attachment_tooltip_title: string;
18
+ attachments_sameDescription_warning: string;
18
19
  baseInformation_accountingCostLabel: string;
19
20
  baseInformation_accountingCostLabel_helpText: string;
20
21
  baseInformation_buyerReferenceLabel: string;
@@ -148,7 +149,9 @@ declare const _default: {
148
149
  referenceIdentifiers_labels_referenceIdentifier_title: string;
149
150
  referenceIdentifiers_values_validation_message: string;
150
151
  saveInformation_label: string;
152
+ submitConfirmation_SuccessfullyUploadedAttachment: string;
151
153
  submitConfirmation_footer_text: string;
154
+ submitConfirmation_successfullyCreatedInvoice: string;
152
155
  submitConfirmation_text: string;
153
156
  submitConfirmation_title: string;
154
157
  supplier_address_city: string;
@@ -204,6 +207,7 @@ declare const _default: {
204
207
  attachment_saveButton_title: string;
205
208
  attachment_title: string;
206
209
  attachment_tooltip_title: string;
210
+ attachments_sameDescription_warning: string;
207
211
  baseInformation_accountingCostLabel: string;
208
212
  baseInformation_accountingCostLabel_helpText: string;
209
213
  baseInformation_buyerReferenceLabel: string;
@@ -337,7 +341,9 @@ declare const _default: {
337
341
  referenceIdentifiers_labels_referenceIdentifier_title: string;
338
342
  referenceIdentifiers_values_validation_message: string;
339
343
  saveInformation_label: string;
344
+ submitConfirmation_SuccessfullyUploadedAttachment: string;
340
345
  submitConfirmation_footer_text: string;
346
+ submitConfirmation_successfullyCreatedInvoice: string;
341
347
  submitConfirmation_text: string;
342
348
  submitConfirmation_title: string;
343
349
  supplier_address_city: string;
@@ -26,5 +26,5 @@ declare const getCancelToken: (callName: string, showMessage?: boolean) => Cance
26
26
  declare const submitAttachmentIfAnyLeft: (_messageId: string, _attachments: {
27
27
  description: string;
28
28
  file: UploadFile;
29
- }[], _mapiBaseUrl: string, token: string, intl: IntlShape) => void;
29
+ }[], _mapiBaseUrl: string, token: string, intl: IntlShape, numberOfSuccessfulCalls: number, setNumberOfSuccessfulCalls: (numberOfSuccessfulCalls: number) => void) => void;
30
30
  export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument, submitDocumentFetch, submitAttachmentIfAnyLeft, getAuthToken, getCancelToken };
@@ -118,7 +118,7 @@ var getCancelToken = function (callName, showMessage) {
118
118
  return window[callName].token;
119
119
  };
120
120
  exports.getCancelToken = getCancelToken;
121
- var submitAttachmentIfAnyLeft = function (_messageId, _attachments, _mapiBaseUrl, token, intl) {
121
+ var submitAttachmentIfAnyLeft = function (_messageId, _attachments, _mapiBaseUrl, token, intl, numberOfSuccessfulCalls, setNumberOfSuccessfulCalls) {
122
122
  if (_attachments && _attachments.length > 0) {
123
123
  var nextFileArray = _attachments.splice(0, 1);
124
124
  var nextFile = nextFileArray[0].file.originFileObj;
@@ -133,13 +133,16 @@ var submitAttachmentIfAnyLeft = function (_messageId, _attachments, _mapiBaseUrl
133
133
  };
134
134
  submitDocumentFetch(nextFile, createAttachDocument, _mapiBaseUrl, token)
135
135
  .then(function (submitDocumentResponse) {
136
- antd_1.message.success(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_successfullyUploadedAttachmentMsg, { attachment: nextFileDescription_1 }));
137
- submitAttachmentIfAnyLeft(_messageId, _attachments, _mapiBaseUrl, token, intl);
138
- })
139
- .catch(function (documentSendingErrorMessage) {
140
- antd_1.message.error("".concat(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_ErrorUploadedAttachmentMsg, {
141
- attachment: nextFileDescription_1,
142
- }), " - ").concat(documentSendingErrorMessage.message));
136
+ if (submitDocumentResponse.status === 200 || submitDocumentResponse.status === 201) {
137
+ var newProgress = numberOfSuccessfulCalls + 1;
138
+ setNumberOfSuccessfulCalls(newProgress);
139
+ submitAttachmentIfAnyLeft(_messageId, _attachments, _mapiBaseUrl, token, intl, newProgress, setNumberOfSuccessfulCalls);
140
+ }
141
+ else {
142
+ antd_1.message.error("".concat(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_ErrorUploadedAttachmentMsg, {
143
+ attachment: nextFileDescription_1,
144
+ }), " - ").concat(submitDocumentResponse.statusText));
145
+ }
143
146
  });
144
147
  }
145
148
  };
@@ -126,7 +126,7 @@ exports.handleValueValidation = (0, lodash_1.debounce)(function (isoNumber, fiel
126
126
  }, 500);
127
127
  var handleValueSearch = function (searchValue, fieldDefinition, setLoadingValues, loadingValues, receiverRequirements, updateReceiverRequirementsProp, callName, rapiBaseUrl, overwrittenFieldDefinitionKey) {
128
128
  if (fieldDefinition.properties.href) {
129
- var searchUrl = rapiBaseUrl + fieldDefinition.properties.href.replace("%7BtextFilter%7D", encodeURIComponent(searchValue)).replace("%7Boffset%7D", "0").replace("%7Blimit%7D", "15");
129
+ var searchUrl = rapiBaseUrl + fieldDefinition.properties.href.replace("%7BtextFilter%7D", encodeURIComponent(searchValue)).replace("%7Boffset%7D", "0").replace("%7Blimit%7D", "1000");
130
130
  if (!loadingValues) {
131
131
  setLoadingValues(true);
132
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unimaze/billing",
3
- "version": "0.21.39",
3
+ "version": "0.21.41",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",