@unimaze/billing 0.20.16 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/lib/common/components/CommonTranslations.d.ts +102 -2
  2. package/lib/common/components/CommonTranslations.js +10 -1
  3. package/lib/common/components/attachments/Attachment.d.ts +6 -4
  4. package/lib/common/components/attachments/Attachment.js +26 -10
  5. package/lib/common/components/attachments/AttachmentModal.d.ts +21 -0
  6. package/lib/common/components/attachments/AttachmentModal.js +195 -0
  7. package/lib/common/components/attachments/index.d.ts +13 -17
  8. package/lib/common/components/attachments/index.js +189 -23
  9. package/lib/common/components/base-information/AccountingCost.d.ts +7 -5
  10. package/lib/common/components/base-information/AccountingCost.js +32 -11
  11. package/lib/common/components/base-information/OrderReference.d.ts +6 -4
  12. package/lib/common/components/base-information/OrderReference.js +31 -14
  13. package/lib/common/components/base-information/ProjectReference.d.ts +9 -5
  14. package/lib/common/components/base-information/ProjectReference.js +8 -6
  15. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +32 -5
  16. package/lib/common/components/base-information/ReferenceIdentifiers.js +126 -83
  17. package/lib/common/components/base-information/index.d.ts +51 -5
  18. package/lib/common/components/base-information/index.js +99 -154
  19. package/lib/common/components/billing-lines/BillingCalculations.d.ts +7 -5
  20. package/lib/common/components/billing-lines/BillingCalculations.js +79 -46
  21. package/lib/common/components/billing-lines/BillingLinePreview.d.ts +21 -0
  22. package/lib/common/components/billing-lines/BillingLinePreview.js +41 -0
  23. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +6 -4
  24. package/lib/common/components/billing-lines/BillingTaxSummary.js +39 -13
  25. package/lib/common/components/billing-lines/NewBillingLines.d.ts +120 -4
  26. package/lib/common/components/billing-lines/NewBillingLines.js +396 -72
  27. package/lib/common/components/billing-lines/index.d.ts +33 -6
  28. package/lib/common/components/billing-lines/index.js +71 -244
  29. package/lib/common/components/component-container/Content.d.ts +2 -2
  30. package/lib/common/components/component-container/index.d.ts +1 -0
  31. package/lib/common/components/component-container/index.js +1 -1
  32. package/lib/common/components/customer/CostCenter.d.ts +6 -4
  33. package/lib/common/components/customer/CostCenter.js +25 -9
  34. package/lib/common/components/customer/CustomerContactName.d.ts +6 -4
  35. package/lib/common/components/customer/CustomerContactName.js +24 -8
  36. package/lib/common/components/customer/hardCoddedCustomer.js +19 -3
  37. package/lib/common/components/customer/index.d.ts +11 -5
  38. package/lib/common/components/customer/index.js +97 -42
  39. package/lib/common/components/date-picker/index.d.ts +21 -0
  40. package/lib/common/components/date-picker/index.js +23 -0
  41. package/lib/common/components/delivery-location/index.d.ts +6 -4
  42. package/lib/common/components/delivery-location/index.js +20 -4
  43. package/lib/common/components/editable-cell/index.js +2 -2
  44. package/lib/common/components/editable-row/index.d.ts +1 -1
  45. package/lib/common/components/editable-row/index.js +24 -7
  46. package/lib/common/components/form-item/index.d.ts +13 -6
  47. package/lib/common/components/form-item/index.js +16 -20
  48. package/lib/common/components/index.d.ts +10 -0
  49. package/lib/common/components/index.js +30 -8
  50. package/lib/common/components/input/index.d.ts +23 -0
  51. package/lib/common/components/input/index.js +37 -0
  52. package/lib/common/components/invoice/index.d.ts +40 -0
  53. package/lib/common/components/invoice/index.js +52 -0
  54. package/lib/common/components/invoice-preview/InvoicePreviewHeader.d.ts +12 -0
  55. package/lib/common/components/invoice-preview/InvoicePreviewHeader.js +105 -0
  56. package/lib/common/components/invoice-preview/index.d.ts +16 -0
  57. package/lib/common/components/invoice-preview/index.js +393 -0
  58. package/lib/common/components/locale-intl/index.d.ts +0 -10
  59. package/lib/common/components/locale-intl/index.js +50 -42
  60. package/lib/common/components/payment-method/index.d.ts +69 -6
  61. package/lib/common/components/payment-method/index.js +145 -57
  62. package/lib/common/components/payment-method/paymentMethodForConversion.js +3 -1
  63. package/lib/common/components/submit-confirmation/SubmitConfirmationSVG.d.ts +3 -0
  64. package/lib/common/components/submit-confirmation/SubmitConfirmationSVG.js +17 -0
  65. package/lib/common/components/submit-confirmation/index.d.ts +8 -0
  66. package/lib/common/components/submit-confirmation/index.js +34 -0
  67. package/lib/common/components/supplier/CityAutofill.d.ts +18 -0
  68. package/lib/common/components/supplier/CityAutofill.js +159 -0
  69. package/lib/common/components/supplier/index.d.ts +79 -5
  70. package/lib/common/components/supplier/index.js +195 -103
  71. package/lib/common/components/tooltip/index.d.ts +7 -0
  72. package/lib/common/components/tooltip/index.js +15 -0
  73. package/lib/common/components/welcome-modal/index.d.ts +15 -0
  74. package/lib/common/components/welcome-modal/index.js +26 -0
  75. package/lib/common/consts/formLayout.js +4 -3
  76. package/lib/common/consts/validationRules.d.ts +1 -1
  77. package/lib/common/consts/validationRules.js +6 -0
  78. package/lib/common/enums/index.js +5 -1
  79. package/lib/common/style/index.css +18 -0
  80. package/lib/common/types/BillingLineMetadataOverride.d.ts +2 -0
  81. package/lib/common/types/CommonProps.d.ts +15 -1
  82. package/lib/common/types/DiscountType.d.ts +1 -0
  83. package/lib/common/types/DiscountType.js +2 -0
  84. package/lib/common/types/ReceiverRequirements.d.ts +1 -1
  85. package/lib/common/types/ReceiverRequirements.js +1 -0
  86. package/lib/common/types/index.js +15 -0
  87. package/lib/create-invoice/IntlLoader.d.ts +0 -6
  88. package/lib/create-invoice/IntlLoader.js +78 -13
  89. package/lib/create-invoice/index.d.ts +65 -4
  90. package/lib/create-invoice/index.js +437 -181
  91. package/lib/enums.d.ts +2 -3
  92. package/lib/enums.js +1 -0
  93. package/lib/index.js +22 -6
  94. package/lib/translations/locales/en.json +181 -0
  95. package/lib/translations/locales/is.json +135 -116
  96. package/lib/translations/locales.d.ts +360 -161
  97. package/lib/translations/locales.js +3 -2
  98. package/lib/utils/ApiUtility.d.ts +4 -4
  99. package/lib/utils/ApiUtility.js +13 -10
  100. package/lib/utils/BillingLineUtility.d.ts +16 -5
  101. package/lib/utils/BillingLineUtility.js +65 -26
  102. package/lib/utils/ConversionUtility.js +15 -7
  103. package/lib/utils/FileUploadUtility.d.ts +4 -2
  104. package/lib/utils/FileUploadUtility.js +28 -9
  105. package/lib/utils/IntlUtility.d.ts +3 -2
  106. package/lib/utils/IntlUtility.js +2 -1
  107. package/lib/utils/LocationUtility.d.ts +1 -0
  108. package/lib/utils/LocationUtility.js +81 -0
  109. package/lib/utils/ReferenceIdentifierUtility.js +2 -1
  110. package/lib/utils/RequirementsUtility.d.ts +9 -7
  111. package/lib/utils/RequirementsUtility.js +46 -22
  112. package/lib/utils/index.js +4 -3
  113. package/package.json +36 -18
  114. package/lib/style/index.css +0 -51
@@ -10,17 +10,79 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
13
29
  var __importStar = (this && this.__importStar) || function (mod) {
14
30
  if (mod && mod.__esModule) return mod;
15
31
  var result = {};
16
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
17
- result["default"] = mod;
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
18
34
  return result;
19
35
  };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
73
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
74
+ if (ar || !(i in from)) {
75
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
76
+ ar[i] = from[i];
77
+ }
78
+ }
79
+ return to.concat(ar || Array.prototype.slice.call(from));
80
+ };
20
81
  var __importDefault = (this && this.__importDefault) || function (mod) {
21
82
  return (mod && mod.__esModule) ? mod : { "default": mod };
22
83
  };
23
84
  Object.defineProperty(exports, "__esModule", { value: true });
85
+ exports.translationMessages = void 0;
24
86
  var mapi_1 = require("@unimaze/api-clients/lib/mapi");
25
87
  var antd_1 = require("antd");
26
88
  var formLayout_1 = require("../common/consts/formLayout");
@@ -33,8 +95,18 @@ var paymentMethodForConversion_1 = require("../common/components/payment-method/
33
95
  var uuid_1 = require("uuid");
34
96
  var ApiUtility_1 = require("../utils/ApiUtility");
35
97
  var ConversionUtility_1 = require("../utils/ConversionUtility");
98
+ var icons_1 = require("@ant-design/icons");
36
99
  var reaptcha_1 = __importDefault(require("reaptcha"));
37
- var translationMessages = react_intl_1.defineMessages({
100
+ var welcome_modal_1 = __importDefault(require("../common/components/welcome-modal"));
101
+ var react_use_1 = require("react-use");
102
+ var dayjs_1 = __importDefault(require("dayjs"));
103
+ require("../common/style/index.css");
104
+ var RequirementsUtility_1 = require("../utils/RequirementsUtility");
105
+ var CommonTranslations_1 = require("../common/components/CommonTranslations");
106
+ var supplier_1 = require("../common/components/supplier");
107
+ var base_information_1 = require("../common/components/base-information");
108
+ var payment_method_1 = require("../common/components/payment-method");
109
+ exports.translationMessages = (0, react_intl_1.defineMessages)({
38
110
  createInvoice_addDocumentLineMsg: {
39
111
  id: "createInvoice_addDocumentLineMsg",
40
112
  defaultMessage: "Add at least one document line",
@@ -45,31 +117,51 @@ var translationMessages = react_intl_1.defineMessages({
45
117
  },
46
118
  createInvoice_successfullySubmittedInvoiceMsg: {
47
119
  id: "createInvoice_successfullySubmittedInvoiceMsg",
48
- defaultMessage: "Successfully submitted the invoice"
120
+ defaultMessage: "Successfully submitted the invoice",
49
121
  },
50
122
  createInvoice_successfullyUploadedAttachmentMsg: {
51
123
  id: "createInvoice_successfullyUploadedAttachmentMsg",
52
- defaultMessage: "Successfully uploaded attachment {attachment}"
124
+ defaultMessage: "Successfully uploaded attachment {attachment}",
53
125
  },
54
126
  createInvoice_ErrorUploadedAttachmentMsg: {
55
127
  id: "createInvoice_ErrorUploadedAttachmentMsg",
56
- defaultMessage: "Error uploaded attachment {attachment}"
128
+ defaultMessage: "Error uploaded attachment {attachment}",
57
129
  },
58
130
  createInvoice_Submit: {
59
131
  id: "createInvoice_Submit",
60
- defaultMessage: "Submit"
132
+ defaultMessage: "Submit",
61
133
  },
62
134
  createInvoice_SendCopy: {
63
135
  id: "createInvoice_SendCopy",
64
- defaultMessage: "Send a copy"
136
+ defaultMessage: "Send a copy",
65
137
  },
66
138
  createInvoice_SendCopyTooltip: {
67
139
  id: "createInvoice_SendCopyTooltip",
68
- defaultMessage: "Sends you a PDF copy of the invoice"
140
+ defaultMessage: "Sends you a PDF copy of the invoice",
69
141
  },
70
142
  createInvoice_SendCopyTooltipDisabled: {
71
143
  id: "createInvoice_SendCopyTooltipDisabled",
72
- defaultMessage: "You must fill in your email address to send yourself a copy"
144
+ defaultMessage: "You must fill in your email address to send yourself a copy",
145
+ },
146
+ createInvoice_customerStepTitle: {
147
+ id: "createInvoice_customerStepTitle",
148
+ defaultMessage: "Customer",
149
+ },
150
+ createInvoice_supplierStepTitle: {
151
+ id: "createInvoice_supplierStepTitle",
152
+ defaultMessage: "Supplier",
153
+ },
154
+ createInvoice_invoiceStepTitle: {
155
+ id: "createInvoice_invoiceStepTitle",
156
+ defaultMessage: "Invoice",
157
+ },
158
+ createInvoice_paymentStepTitle: {
159
+ id: "createInvoice_paymentStepTitle",
160
+ defaultMessage: "Payment",
161
+ },
162
+ createInvoice_nextStep: {
163
+ id: "createInvoice_nextStep",
164
+ defaultMessage: "Next step",
73
165
  },
74
166
  });
75
167
  /**
@@ -78,34 +170,189 @@ var translationMessages = react_intl_1.defineMessages({
78
170
  * @component
79
171
  */
80
172
  var CreateInvoiceConstructor = function (props) {
173
+ var _a;
81
174
  var recaptchaRef = react_1.default.useRef(null);
82
175
  var intl = props.intl;
83
176
  var form = antd_1.Form.useForm()[0];
84
- var _a = react_1.useState(false), submitting = _a[0], setSubmitting = _a[1];
85
- var _b = react_1.useState(true), isSubmitDisabled = _b[0], setIsSubmitDisabled = _b[1];
86
- var _c = react_1.useState(ConversionUtility_1.profileOutputToPartyMetadata(props.customers[0])), chosenCustomer = _c[0], setChosenCustomer = _c[1];
87
- var _d = react_1.useState(props.customers[0].apiKey), chosenCustomerApiKey = _d[0], setChosenCustomerApiKey = _d[1];
88
- var _e = react_1.useState(true), sendCopyDisabled = _e[0], setSendCopyDisabled = _e[1];
89
- var _f = react_1.useState(false), sendCopy = _f[0], setSendCopy = _f[1];
90
- var _g = react_1.default.useState(""), referenceIdentifierValidateStatus = _g[0], setReferenceIdentifierValidateStatus = _g[1];
91
- // const [billingLinesEditableIndex, setBillingLinesEditableIndex] = useState<number>(1)
92
- var _h = react_1.useState(false), outsideVatScope = _h[0], setOutsideVatScope = _h[1];
93
- var _j = react_1.useState(false), captchaVerified = _j[0], setCaptchaVerified = _j[1];
94
- react_1.useEffect(function () {
177
+ var width = (0, react_use_1.useWindowSize)().width;
178
+ var _b = (0, react_1.useState)(false), isMobile = _b[0], setIsMobile = _b[1];
179
+ (0, react_1.useEffect)(function () {
180
+ if (width < 768) {
181
+ setIsMobile(true);
182
+ }
183
+ else {
184
+ setIsMobile(false);
185
+ }
186
+ }, [width]);
187
+ var _c = (0, react_1.useState)(false), submitting = _c[0], setSubmitting = _c[1];
188
+ var _d = (0, react_1.useState)(true), isSubmitDisabled = _d[0], setIsSubmitDisabled = _d[1];
189
+ var _e = (0, react_1.useState)(false), isBackButtonVisible = _e[0], setIsBackButtonVisible = _e[1];
190
+ var _f = (0, react_1.useState)(true), isNextStepDisabled = _f[0], setIsNextStepDisabled = _f[1];
191
+ var _g = (0, react_1.useState)(false), isNextStepVisible = _g[0], setIsNextStepVisible = _g[1];
192
+ var _h = (0, react_1.useState)(0), activeStep = _h[0], setActiveStep = _h[1];
193
+ var _j = (0, react_1.useState)(true), isWelcomeModalOpen = _j[0], setIsWelcomeModalOpen = _j[1];
194
+ var _k = (0, react_1.useState)(""), supplierEmail = _k[0], setSupplierEmail = _k[1];
195
+ var _l = (0, react_1.useState)(false), isSaveFieldValuesSelected = _l[0], setIsSaveFieldValuesSelected = _l[1];
196
+ var _m = (0, react_1.useState)((0, ConversionUtility_1.profileOutputToPartyMetadata)(props.customers[0])), chosenCustomer = _m[0], setChosenCustomer = _m[1];
197
+ var _o = (0, react_1.useState)(props.customers[0].apiKey), chosenCustomerApiKey = _o[0], setChosenCustomerApiKey = _o[1];
198
+ var _p = (0, react_1.useState)(true), sendCopyDisabled = _p[0], setSendCopyDisabled = _p[1];
199
+ var _q = (0, react_1.useState)(false), sendCopy = _q[0], setSendCopy = _q[1];
200
+ var _r = react_1.default.useState(""), referenceIdentifierValidateStatus = _r[0], setReferenceIdentifierValidateStatus = _r[1];
201
+ var _s = (0, react_1.useState)(false), outsideVatScope = _s[0], setOutsideVatScope = _s[1];
202
+ var _t = (0, react_1.useState)(false), captchaVerified = _t[0], setCaptchaVerified = _t[1];
203
+ var _u = (0, react_1.useState)({}), removedInvoiceLine = _u[0], setRemovedInvoiceLine = _u[1];
204
+ var _v = (0, react_1.useState)(undefined), missingRequiredDataTooltip = _v[0], setMissingRequiredDataTooltip = _v[1];
205
+ var getDefaultPaymentType = function (defaultPaymentType) {
206
+ return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
207
+ };
208
+ var _w = (0, react_1.useState)({
209
+ invoice: {
210
+ supplier: {
211
+ address: {
212
+ countryCode: "IS",
213
+ },
214
+ },
215
+ customer: __assign(__assign({}, chosenCustomer), { address: {
216
+ countryCode: "IS",
217
+ } }),
218
+ paymentMeans: {
219
+ type: getDefaultPaymentType(props.defaultPaymentType),
220
+ },
221
+ referenceIdentifiers: [{}],
222
+ singleReferenceIdentifier: {
223
+ code: undefined,
224
+ },
225
+ invoiceLines: [{}],
226
+ attachments: {
227
+ file1: { file: undefined, description: undefined },
228
+ file2: { file: undefined, description: undefined },
229
+ file3: { file: undefined, description: undefined },
230
+ },
231
+ issueDate: (0, dayjs_1.default)(),
232
+ },
233
+ }), formData = _w[0], setFormData = _w[1];
234
+ var validateFieldsForNextStep = function (fieldPaths, validateOnly) { return __awaiter(void 0, void 0, void 0, function () {
235
+ return __generator(this, function (_a) {
236
+ switch (_a.label) {
237
+ case 0: return [4 /*yield*/, form.validateFields(fieldPaths, { validateOnly: validateOnly || true })
238
+ .then(function () {
239
+ if (activeStep === 2 && form.getFieldValue(["invoice", "invoiceLines"]).length <= 1) {
240
+ setIsNextStepDisabled(true);
241
+ setMissingRequiredDataTooltip(react_1.default.createElement(react_1.default.Fragment, null, props.intl.formatMessage(exports.translationMessages.createInvoice_addDocumentLineMsg)));
242
+ }
243
+ else {
244
+ setIsNextStepDisabled(false);
245
+ setMissingRequiredDataTooltip(undefined);
246
+ }
247
+ })
248
+ .catch(function (error) {
249
+ var _a;
250
+ var requiredFields = [];
251
+ (_a = error === null || error === void 0 ? void 0 : error.errorFields) === null || _a === void 0 ? void 0 : _a.map(function (errorField) {
252
+ var _a;
253
+ requiredFields.push(errorField.name[((_a = errorField === null || errorField === void 0 ? void 0 : errorField.name) === null || _a === void 0 ? void 0 : _a.length) - 1]);
254
+ });
255
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.length) > 0) {
256
+ var names = getFieldNames(requiredFields);
257
+ setMissingRequiredDataTooltip((0, RequirementsUtility_1.getRequiredTooltipMessage)(props.intl.formatMessage(CommonTranslations_1.commonTranslationMessages.missingRequiredData), names));
258
+ }
259
+ setIsNextStepDisabled(true);
260
+ })];
261
+ case 1:
262
+ _a.sent();
263
+ return [2 /*return*/];
264
+ }
265
+ });
266
+ }); };
267
+ var getFieldNames = function (keys) {
268
+ return keys === null || keys === void 0 ? void 0 : keys.map(function (key) {
269
+ switch (key) {
270
+ case "identifier":
271
+ return props.intl.formatMessage(supplier_1.translationMessages.supplier_identifier);
272
+ case "name":
273
+ return props.intl.formatMessage(supplier_1.translationMessages.supplier_name);
274
+ case "streetNameAndNumber":
275
+ return props.intl.formatMessage(supplier_1.translationMessages.supplier_address_streetNameAndNumber);
276
+ case "postalZone":
277
+ return props.intl.formatMessage(supplier_1.translationMessages.supplier_address_zip_postalCode);
278
+ case "vatNumber":
279
+ return props.intl.formatMessage(supplier_1.translationMessages.supplier_vatNumber);
280
+ case "invoiceNo":
281
+ return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_invoiceNo);
282
+ case "issueDate":
283
+ return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_issueDate);
284
+ case "dueDate":
285
+ return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_dueDate);
286
+ case "buyerReference":
287
+ return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_buyerReferenceLabel);
288
+ case "accountTypeNumber":
289
+ return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountType);
290
+ case "accountNumber":
291
+ return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountNo);
292
+ case "bankNumber":
293
+ return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_icelandicClaim_bankNo);
294
+ default:
295
+ return "";
296
+ }
297
+ });
298
+ };
299
+ var saveFieldValuesToLocalStorage = function () {
300
+ var flatFields = form.getFieldsValue();
301
+ delete flatFields.attachments;
302
+ delete flatFields.invoice.invoiceLines;
303
+ delete flatFields.invoice.dueDate;
304
+ delete flatFields.invoice.issueDate;
305
+ localStorage.setItem("formData", JSON.stringify(flatFields));
306
+ };
307
+ var handlePrevStep = function () {
308
+ if (activeStep === 3 && removedInvoiceLine) {
309
+ var currentInvoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
310
+ form.setFieldsValue({
311
+ invoice: {
312
+ invoiceLines: __spreadArray(__spreadArray([], currentInvoiceLines, true), [removedInvoiceLine], false),
313
+ },
314
+ });
315
+ }
316
+ setActiveStep(activeStep - 1);
317
+ };
318
+ var handleNextStep = function () {
319
+ if (activeStep === 2) {
320
+ var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
321
+ var _removedInvoiceLine = invoiceLines[invoiceLines.length - 1];
322
+ setRemovedInvoiceLine(_removedInvoiceLine);
323
+ form.setFieldsValue({
324
+ invoice: {
325
+ invoiceLines: invoiceLines.slice(0, -1),
326
+ },
327
+ });
328
+ }
329
+ setIsNextStepDisabled(true);
330
+ setActiveStep(activeStep + 1);
331
+ if (isSaveFieldValuesSelected) {
332
+ saveFieldValuesToLocalStorage();
333
+ }
334
+ };
335
+ (0, react_1.useEffect)(function () {
336
+ var savedValues = localStorage.getItem("formData");
337
+ var savedValuesObject = savedValues ? JSON.parse(savedValues) : null;
338
+ if (savedValuesObject)
339
+ form.setFieldsValue(savedValuesObject);
340
+ }, []);
341
+ (0, react_1.useEffect)(function () {
342
+ setSupplierEmail(form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]));
343
+ }, [form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"])]);
344
+ (0, react_1.useEffect)(function () {
345
+ setOutsideVatScope(form.getFieldValue(["outsideVatScope"]));
346
+ }, [form.getFieldValue(["outsideVatScope"])]);
347
+ (0, react_1.useEffect)(function () {
95
348
  setIsSubmitDisabled(!captchaVerified);
96
349
  }, [captchaVerified]);
97
- // attachments
98
- // TODO: remove the states, set the values to the form in attachment components
99
- var _k = react_1.useState([]), file1 = _k[0], setFile1 = _k[1];
100
- var _l = react_1.useState(""), attachmentFieldValidation1 = _l[0], setAttachmentFieldValidation1 = _l[1];
101
- var _m = react_1.useState([]), file2 = _m[0], setFile2 = _m[1];
102
- var _o = react_1.useState(""), attachmentFieldValidation2 = _o[0], setAttachmentFieldValidation2 = _o[1];
103
- var _p = react_1.useState([]), file3 = _p[0], setFile3 = _p[1];
104
- var _q = react_1.useState(""), attachmentFieldValidation3 = _q[0], setAttachmentFieldValidation3 = _q[1];
105
- react_1.useEffect(function () {
106
- form.resetFields([
107
- ["invoice", "supplier", "vatNumber"],
108
- ]);
350
+ (0, react_1.useEffect)(function () {
351
+ setIsBackButtonVisible(activeStep > 0 && activeStep <= items.length);
352
+ setIsNextStepVisible(activeStep < items.length);
353
+ }, [activeStep]);
354
+ (0, react_1.useEffect)(function () {
355
+ form.resetFields([["invoice", "supplier", "vatNumber"]]);
109
356
  var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
110
357
  if (outsideVatScope) {
111
358
  invoiceLines = invoiceLines.map(function (invoiceLine) {
@@ -121,24 +368,15 @@ var CreateInvoiceConstructor = function (props) {
121
368
  }
122
369
  form.setFieldsValue({
123
370
  invoice: {
124
- invoiceLines: invoiceLines
125
- }
371
+ invoiceLines: invoiceLines,
372
+ },
126
373
  });
127
374
  }, [outsideVatScope]);
128
- var resetAttachments = function () {
129
- setFile1([]);
130
- setAttachmentFieldValidation1("");
131
- setFile2([]);
132
- setAttachmentFieldValidation2("");
133
- setFile3([]);
134
- setAttachmentFieldValidation3("");
135
- };
136
- var supplierEmailValue = form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]);
137
- react_1.useEffect(function () {
138
- if (supplierEmailValue) {
375
+ (0, react_1.useEffect)(function () {
376
+ if (supplierEmail) {
139
377
  form.validateFields([["invoice", "supplier", "contact", "electronicMail"]])
140
378
  .then(function () {
141
- setSendCopyDisabled(!supplierEmailValue);
379
+ setSendCopyDisabled(!supplierEmail);
142
380
  setSendCopy(true);
143
381
  })
144
382
  .catch(function () {
@@ -150,8 +388,9 @@ var CreateInvoiceConstructor = function (props) {
150
388
  setSendCopy(false);
151
389
  setSendCopyDisabled(true);
152
390
  }
153
- }, [supplierEmailValue]);
391
+ }, [supplierEmail]);
154
392
  var handleSubmit = function (values) {
393
+ var _a, _b, _c, _d, _e, _f;
155
394
  setSubmitting(true);
156
395
  if (referenceIdentifierValidateStatus !== "" && referenceIdentifierValidateStatus !== "success") {
157
396
  form.scrollToField(["invoice", "referenceIdentifiers", 0, "value"]);
@@ -159,66 +398,66 @@ var CreateInvoiceConstructor = function (props) {
159
398
  return;
160
399
  }
161
400
  var attachments = [
162
- values.attachments.file1 && values.attachments.file1,
163
- values.attachments.file2 && values.attachments.file2,
164
- values.attachments.file3 && values.attachments.file3,
401
+ ((_a = values.attachments) === null || _a === void 0 ? void 0 : _a.file1) && ((_b = values.attachments) === null || _b === void 0 ? void 0 : _b.file1),
402
+ ((_c = values.attachments) === null || _c === void 0 ? void 0 : _c.file2) && ((_d = values.attachments) === null || _d === void 0 ? void 0 : _d.file2),
403
+ ((_e = values.attachments) === null || _e === void 0 ? void 0 : _e.file3) && ((_f = values.attachments) === null || _f === void 0 ? void 0 : _f.file3),
165
404
  ];
166
405
  // Clear the array of undefined
167
- attachments = attachments.filter(function (attachment) { return (attachment.file !== undefined) && (attachment.file && attachment.file.length > 0); });
406
+ attachments = attachments.filter(function (attachment) { return attachment && attachment.file; });
168
407
  if (!chosenCustomer) {
169
- antd_1.message.error(intl.formatMessage(translationMessages.createInvoice_selectCustomerMsg));
408
+ antd_1.message.error(intl.formatMessage(exports.translationMessages.createInvoice_selectCustomerMsg));
170
409
  // TODO: handle this better?
171
410
  setSubmitting(false);
172
411
  return;
173
412
  }
174
413
  var services = sendCopy
175
- ? ["urn:services:dispatcher:mail.pdf?email=" + supplierEmailValue + "&lang=" + props.language]
414
+ ? ["urn:services:dispatcher:mail.pdf?email=".concat(supplierEmail)]
176
415
  : undefined;
177
- var invoiceMetadataInput = utils_1.convertToInvoiceMetadataInput(values, BillingLineUtility_1.billingLinesFieldsMetadata(form), paymentMethodForConversion_1.PaymentMethodFormData(values), chosenCustomer);
416
+ var invoiceMetadataInput = (0, utils_1.convertToInvoiceMetadataInput)(values, (0, BillingLineUtility_1.billingLinesFieldsMetadata)(form), (0, paymentMethodForConversion_1.PaymentMethodFormData)(values), chosenCustomer);
178
417
  var createSubmitInvoice = {
179
418
  invoiceMetadataInput: invoiceMetadataInput,
180
419
  more: attachments.length > 0,
181
- messageId: uuid_1.v4(),
420
+ messageId: (0, uuid_1.v4)(),
182
421
  processingMode: mapi_1.TransactionProcessingMode.Device,
183
- services: services
184
- // processingMode: TransactionProcessingMode.DeviceRouted
422
+ services: services,
185
423
  };
186
- utils_1.submitInvoice(createSubmitInvoice, props.mapiBaseUrl, chosenCustomerApiKey, "submitInvoice", props.language)
424
+ (0, utils_1.submitInvoice)(createSubmitInvoice, props.mapiBaseUrl, chosenCustomerApiKey, "submitInvoice", props.language)
187
425
  .then(function (resp) {
188
- antd_1.message.success(intl.formatMessage(translationMessages.createInvoice_successfullySubmittedInvoiceMsg));
426
+ antd_1.message.success(intl.formatMessage(exports.translationMessages.createInvoice_successfullySubmittedInvoiceMsg));
189
427
  var messageId = resp.data.uniqueId;
190
- var _loop_1 = function () {
191
- var nextFileArray = attachments.splice(0, 1);
192
- var nextFile = nextFileArray[0].file[0].originFileObj;
193
- var nextFileDescription = nextFileArray[0].description;
194
- if (!nextFile)
195
- throw new Error("NextFile is empty");
196
- var createAttachDocument = {
197
- messageId: messageId,
198
- contentType: nextFile.type,
199
- more: attachments.length > 0,
200
- name: nextFileDescription // nextFile.name,
201
- };
202
- setSubmitting(true);
203
- ApiUtility_1.submitDocumentFetch(nextFile, createAttachDocument, props.mapiBaseUrl, chosenCustomerApiKey)
204
- .then(function (submitDocumentResponse) {
205
- antd_1.message.success(intl.formatMessage(translationMessages.createInvoice_successfullyUploadedAttachmentMsg, { attachment: nextFileDescription }));
206
- setSubmitting(false);
207
- })
208
- .catch(function (documentSendingErrorMessage) {
209
- antd_1.message.error(intl.formatMessage(translationMessages.createInvoice_ErrorUploadedAttachmentMsg, { attachment: nextFileDescription }) + " - " + documentSendingErrorMessage.message);
210
- setSubmitting(false);
211
- });
428
+ var submitAttachmentIfAnyLeft = function (_messageId, _attachments, _mapiBaseUrl, _chosenCustomerApiKey) {
429
+ if (_attachments && _attachments.length > 0) {
430
+ var nextFileArray = _attachments.splice(0, 1);
431
+ var nextFile = nextFileArray[0].file.originFileObj;
432
+ var nextFileDescription_1 = nextFileArray[0].description;
433
+ if (!nextFile)
434
+ throw new Error("NextFile is empty");
435
+ var createAttachDocument = {
436
+ messageId: _messageId,
437
+ contentType: nextFile.type,
438
+ more: _attachments.length > 0,
439
+ name: nextFileDescription_1, // nextFile.name,
440
+ };
441
+ (0, ApiUtility_1.submitDocumentFetch)(nextFile, createAttachDocument, _mapiBaseUrl, _chosenCustomerApiKey)
442
+ .then(function (submitDocumentResponse) {
443
+ antd_1.message.success(intl.formatMessage(exports.translationMessages.createInvoice_successfullyUploadedAttachmentMsg, { attachment: nextFileDescription_1 }));
444
+ submitAttachmentIfAnyLeft(_messageId, _attachments, _mapiBaseUrl, _chosenCustomerApiKey);
445
+ })
446
+ .catch(function (documentSendingErrorMessage) {
447
+ antd_1.message.error("".concat(intl.formatMessage(exports.translationMessages.createInvoice_ErrorUploadedAttachmentMsg, {
448
+ attachment: nextFileDescription_1,
449
+ }), " - ").concat(documentSendingErrorMessage.message));
450
+ });
451
+ }
212
452
  };
213
- while (attachments.length > 0) {
214
- _loop_1();
215
- }
453
+ submitAttachmentIfAnyLeft(messageId, attachments, props.mapiBaseUrl, chosenCustomerApiKey);
454
+ setActiveStep(activeStep + 1);
216
455
  setSubmitting(false);
217
456
  form.resetFields();
218
457
  form.setFields([
219
458
  {
220
459
  name: ["invoice", "invoiceLines"],
221
- value: [{}]
460
+ value: [{}],
222
461
  },
223
462
  {
224
463
  name: ["invoice", "supplier"],
@@ -226,7 +465,7 @@ var CreateInvoiceConstructor = function (props) {
226
465
  },
227
466
  {
228
467
  name: ["outsideVatScope"],
229
- value: !values.invoice.supplier.vatNumber
468
+ value: !values.invoice.supplier.vatNumber,
230
469
  },
231
470
  {
232
471
  name: ["attachments"],
@@ -234,12 +473,11 @@ var CreateInvoiceConstructor = function (props) {
234
473
  file1: { file: undefined, description: undefined },
235
474
  file2: { file: undefined, description: undefined },
236
475
  file3: { file: undefined, description: undefined },
237
- }
238
- }
476
+ },
477
+ },
239
478
  ]);
240
- resetAttachments();
241
479
  // Clear the billing line dataSource
242
- setChosenCustomer(ConversionUtility_1.profileOutputToPartyMetadata(props.customers[0]));
480
+ setChosenCustomer((0, ConversionUtility_1.profileOutputToPartyMetadata)(props.customers[0]));
243
481
  setChosenCustomerApiKey(props.customers[0].apiKey);
244
482
  // setBillingLinesDataSource([{...initialBillingLineData, key: 0}])
245
483
  // setBillingLinesEditableIndex(0);
@@ -287,19 +525,38 @@ var CreateInvoiceConstructor = function (props) {
287
525
  }
288
526
  setIsSubmitDisabled(true);
289
527
  };
290
- react_1.useEffect(function () {
291
- getReceiverRequirements();
292
- }, [chosenCustomer]);
293
528
  var getReceiverRequirements = function () {
529
+ var _a, _b, _c, _d, _e;
294
530
  if (chosenCustomer) {
295
- form.resetFields([
296
- ["invoice", "referenceIdentifiers"],
297
- ["invoice", "customer", "locationIdentifier"],
298
- ["invoice", "paymentMeans"]
299
- ]);
531
+ var savedFieldValues = localStorage.getItem("formData");
532
+ var savedFieldValuesObject = savedFieldValues ? JSON.parse(savedFieldValues) : null;
533
+ var savedChosenCustomer = (_a = savedFieldValuesObject === null || savedFieldValuesObject === void 0 ? void 0 : savedFieldValuesObject.invoice) === null || _a === void 0 ? void 0 : _a.customer;
534
+ if (chosenCustomer.name === (savedChosenCustomer === null || savedChosenCustomer === void 0 ? void 0 : savedChosenCustomer.name)) {
535
+ var savedValues = localStorage.getItem("formData");
536
+ var savedValuesObject = savedValues ? JSON.parse(savedValues) : null;
537
+ form.setFieldsValue({
538
+ invoice: {
539
+ referenceIdentifiers: (_b = savedValuesObject === null || savedValuesObject === void 0 ? void 0 : savedValuesObject.invoice) === null || _b === void 0 ? void 0 : _b.referenceIdentifiers,
540
+ customer: {
541
+ locationIdentifier: (_d = (_c = savedValuesObject === null || savedValuesObject === void 0 ? void 0 : savedValuesObject.invoice) === null || _c === void 0 ? void 0 : _c.customer) === null || _d === void 0 ? void 0 : _d.locationIdentifier,
542
+ },
543
+ paymentMeans: (_e = savedValuesObject === null || savedValuesObject === void 0 ? void 0 : savedValuesObject.invoice) === null || _e === void 0 ? void 0 : _e.paymentMeans,
544
+ },
545
+ });
546
+ }
547
+ else {
548
+ form.resetFields([
549
+ ["invoice", "referenceIdentifiers"],
550
+ ["invoice", "customer", "locationIdentifier"],
551
+ ["invoice", "paymentMeans"],
552
+ ]);
553
+ }
300
554
  props.getReceiverRequirements(props.rapiBaseUrl, chosenCustomer.identifier);
301
555
  }
302
556
  };
557
+ (0, react_1.useEffect)(function () {
558
+ getReceiverRequirements();
559
+ }, [chosenCustomer]);
303
560
  var defaultCustomer;
304
561
  if (props.customers.length === 1 && !chosenCustomer) {
305
562
  defaultCustomer = props.customers[0];
@@ -315,27 +572,31 @@ var CreateInvoiceConstructor = function (props) {
315
572
  streetNameAndNumber: defaultCustomer.participantLegalAddressStreet,
316
573
  },
317
574
  identifier: defaultCustomer.participantLegalIsoIdentifier,
318
- name: defaultCustomer.name
575
+ name: defaultCustomer.name,
319
576
  });
320
577
  setChosenCustomerApiKey(props.customers[0].apiKey);
321
578
  }
322
- var _r = react_1.useState(undefined), billingLinesMetadata = _r[0], setBillingLinesMetadata = _r[1];
579
+ var _x = (0, react_1.useState)(undefined), billingLinesMetadata = _x[0], setBillingLinesMetadata = _x[1];
323
580
  var getBillingLines = function (changedValues, allValues) {
324
581
  var invoiceLines = allValues.invoice.invoiceLines;
325
582
  if (invoiceLines) {
326
583
  var mappedBillingLines = invoiceLines.map(function (invoiceLine) {
327
584
  if (invoiceLine) {
328
- return ({
585
+ return {
329
586
  itemNo: invoiceLine.itemNo ? invoiceLine.itemNo : undefined,
330
587
  name: invoiceLine.name ? invoiceLine.name : undefined,
331
588
  quantity: invoiceLine.quantity ? invoiceLine.quantity : undefined,
332
589
  unitPriceAmount: invoiceLine.unitPriceAmount ? invoiceLine.unitPriceAmount : undefined,
333
590
  unitOfMeasure: {
334
- unit: invoiceLine.unitOfMeasure && invoiceLine.unitOfMeasure.unit ? mapi_1.Units[invoiceLine.unitOfMeasure.unit] : undefined,
591
+ unit: invoiceLine.unitOfMeasure && invoiceLine.unitOfMeasure.unit
592
+ ? mapi_1.Units[invoiceLine.unitOfMeasure.unit]
593
+ : undefined,
335
594
  },
336
- taxCategoryType: invoiceLine.taxCategoryType ? mapi_1.TaxCategoryTypeEnum[invoiceLine.taxCategoryType] : undefined,
595
+ taxCategoryType: invoiceLine.taxCategoryType
596
+ ? mapi_1.TaxCategoryTypeEnum[invoiceLine.taxCategoryType]
597
+ : undefined,
337
598
  discountValue: invoiceLine.discountValue ? invoiceLine.discountValue : undefined,
338
- });
599
+ };
339
600
  }
340
601
  else {
341
602
  return {};
@@ -344,81 +605,76 @@ var CreateInvoiceConstructor = function (props) {
344
605
  setBillingLinesMetadata(mappedBillingLines);
345
606
  }
346
607
  };
347
- var getDefaultPaymentType = function (defaultPaymentType) {
348
- return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
349
- };
608
+ var items = [
609
+ {
610
+ title: intl.formatMessage(exports.translationMessages.createInvoice_customerStepTitle),
611
+ },
612
+ {
613
+ title: intl.formatMessage(exports.translationMessages.createInvoice_supplierStepTitle),
614
+ },
615
+ {
616
+ title: intl.formatMessage(exports.translationMessages.createInvoice_invoiceStepTitle),
617
+ },
618
+ {
619
+ title: intl.formatMessage(exports.translationMessages.createInvoice_paymentStepTitle),
620
+ },
621
+ ];
350
622
  return (react_1.default.createElement(antd_1.Spin, { spinning: submitting },
351
- react_1.default.createElement(antd_1.Form, __assign({ onFieldsChange: function () {
352
- if (captchaVerified && recaptchaRef) {
353
- if (recaptchaRef.current) {
354
- setCaptchaVerified(false);
355
- recaptchaRef.current.reset();
356
- }
357
- }
358
- }, scrollToFirstError: true, onValuesChange: function (changedValues, allValues) { return getBillingLines(changedValues, allValues); } }, formLayout_1.formItemLayout, { form: form, onFinish: handleSubmit, initialValues: {
359
- invoice: {
360
- supplier: {
361
- address: {
362
- countryCode: "IS"
363
- },
364
- },
365
- customer: __assign({}, chosenCustomer, { address: {
366
- countryCode: "IS"
367
- } }),
368
- paymentMeans: {
369
- type: getDefaultPaymentType(props.defaultPaymentType),
370
- },
371
- referenceIdentifiers: [
372
- {}
373
- ],
374
- singleReferenceIdentifier: {
375
- code: undefined
376
- },
377
- invoiceLines: [{}],
378
- attachments: {
379
- file1: { file: undefined, description: undefined },
380
- file2: { file: undefined, description: undefined },
381
- file3: { file: undefined, description: undefined },
382
- }
383
- },
384
- } }),
385
- react_1.default.createElement(antd_1.Row, { gutter: [16, 16] },
386
- react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
387
- react_1.default.createElement(antd_1.Form.Item, { noStyle: true, name: ["invoice", "singleReferenceIdentifier", "code"] },
388
- react_1.default.createElement(antd_1.Input, { type: "hidden" })),
389
- react_1.default.createElement(components_1.Supplier, { receiverRequirements: props.receiverRequirements,
390
- // billingLinesDataSource={billingLinesDataSource}
391
- rapiBaseUrl: props.rapiBaseUrl, rapiApiKey: props.rapiApiKey, form: form, outsideVatScope: outsideVatScope, setOutsideVatScope: setOutsideVatScope })),
392
- react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
393
- react_1.default.createElement(components_1.Customer, { receiverRequirements: props.receiverRequirements, formInstance: form, customers: props.customers, chosenCustomer: chosenCustomer, setChosenCustomer: setChosenCustomer, setChosenCustomerApiKey: setChosenCustomerApiKey, rapiBaseUrl: props.rapiBaseUrl, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp })),
394
- react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
395
- react_1.default.createElement(components_1.BaseInformation, { receiverRequirements: props.receiverRequirements, form: form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: chosenCustomer.identifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: referenceIdentifierValidateStatus, setReferenceIdentifierValidateStatus: setReferenceIdentifierValidateStatus, dueDateMinimumOffset: props.dueDateMinimumOffset })),
396
- react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 24 } },
397
- react_1.default.createElement(components_1.BillingLines
398
- // setBillingLineMetadata={handleSetBillingLineMetadata}
399
- , {
400
- // setBillingLineMetadata={handleSetBillingLineMetadata}
401
- formInstance: form, billingLinesMetadata: billingLinesMetadata,
402
- // editableIndex={billingLinesEditableIndex}
403
- // handleAdd={handleBillingLinesAdd}
404
- // initialBillingLineData={initialBillingLineData}
405
- // handleDelete={handleBillingLinesDelete}
406
- // handleSave={handleBillingLinesSave}
407
- receiverRequirements: props.receiverRequirements, outsideVatScope: outsideVatScope })),
408
- react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 8 } },
409
- react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form })),
410
- react_1.default.createElement(antd_1.Col, { xs: { span: 24 }, md: { span: 16 } },
411
- react_1.default.createElement(components_1.Attachments, { formInstance: form, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.language, file1: file1, setFile1: setFile1, attachmentFieldValidation1: attachmentFieldValidation1, setAttachmentFieldValidation1: setAttachmentFieldValidation1, file2: file2, setFile2: setFile2, attachmentFieldValidation2: attachmentFieldValidation2, setAttachmentFieldValidation2: setAttachmentFieldValidation2, file3: file3, setFile3: setFile3, attachmentFieldValidation3: attachmentFieldValidation3, setAttachmentFieldValidation3: setAttachmentFieldValidation3 })),
412
- react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "end" },
413
- react_1.default.createElement(antd_1.Col, null,
414
- react_1.default.createElement(reaptcha_1.default, { sitekey: "6LdMUdEZAAAAAG--2WEyu8CIRVlv6CzdZIwaQ-zt", ref: recaptchaRef, onVerify: function (response) {
415
- setCaptchaVerified(true);
416
- }, hl: props.language, onExpire: function () { return setCaptchaVerified(false); }, onError: function () { return setCaptchaVerified(false); } }))),
417
- react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "end" },
418
- react_1.default.createElement(antd_1.Col, null,
419
- react_1.default.createElement(antd_1.Tooltip, { title: sendCopyDisabled ? intl.formatMessage(translationMessages.createInvoice_SendCopyTooltipDisabled) : intl.formatMessage(translationMessages.createInvoice_SendCopyTooltip) },
420
- react_1.default.createElement(antd_1.Checkbox, { disabled: sendCopyDisabled, checked: sendCopy, onChange: function (e) { return setSendCopy(e.target.checked); } }, intl.formatMessage(translationMessages.createInvoice_SendCopy)))),
421
- react_1.default.createElement(antd_1.Col, null,
422
- react_1.default.createElement(antd_1.Button, { type: "primary", htmlType: "submit", size: "large", disabled: isSubmitDisabled }, intl.formatMessage(translationMessages.createInvoice_Submit))))))));
623
+ react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "middle", style: { alignItems: "center", marginBottom: "50px" } },
624
+ 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 }))),
625
+ react_1.default.createElement(antd_1.Layout.Content, null,
626
+ react_1.default.createElement(antd_1.Flex, { style: { width: "100vw", padding: isMobile ? "0 20px" : 0 } },
627
+ react_1.default.createElement(antd_1.Form, __assign({ style: { width: "100%" }, size: "large", onFieldsChange: function () {
628
+ if (captchaVerified && recaptchaRef) {
629
+ if (recaptchaRef.current) {
630
+ setCaptchaVerified(false);
631
+ recaptchaRef.current.reset();
632
+ }
633
+ }
634
+ }, scrollToFirstError: true, onValuesChange: function (changedValues, allValues) {
635
+ getBillingLines(changedValues, allValues);
636
+ } }, formLayout_1.formItemLayout, { form: form, onFinish: handleSubmit, onFinishFailed: function (error) {
637
+ // tslint:disable-next-line:no-console
638
+ console.log(error);
639
+ }, initialValues: formData }),
640
+ react_1.default.createElement(antd_1.Form.Item, { name: ["invoice", "currencyCode"], hidden: true }),
641
+ react_1.default.createElement(antd_1.Flex, { gap: "middle", vertical: true },
642
+ react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 0 ? { display: "none" } : {} },
643
+ react_1.default.createElement(components_1.Customer, { receiverRequirements: props.receiverRequirements, formInstance: form, customers: props.customers, chosenCustomer: chosenCustomer, setChosenCustomer: setChosenCustomer, setChosenCustomerApiKey: setChosenCustomerApiKey, rapiBaseUrl: props.rapiBaseUrl, updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, validateFields: validateFieldsForNextStep, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
644
+ return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
645
+ }, isActiveStep: activeStep === 0 })),
646
+ react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 1 ? { display: "none" } : {} },
647
+ react_1.default.createElement(components_1.Supplier, { receiverRequirements: props.receiverRequirements, rapiBaseUrl: props.rapiBaseUrl, rapiApiKey: props.rapiApiKey, form: form, outsideVatScope: outsideVatScope, setOutsideVatScope: setOutsideVatScope, isMobile: isMobile, validateFields: validateFieldsForNextStep, onSaveFieldValues: saveFieldValuesToLocalStorage, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
648
+ return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
649
+ }, isActiveStep: activeStep === 1 }),
650
+ " "),
651
+ react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 2 ? { display: "none" } : {} },
652
+ react_1.default.createElement(components_1.Invoice, { receiverRequirements: props.receiverRequirements, form: form, documentType: "invoice", updateReceiverRequirementsProp: props.updateReceiverRequirementsProp, rapiBaseUrl: props.rapiBaseUrl, legalIdentifier: chosenCustomer.identifier, referenceIdentifiersLabelText: props.referenceIdentifiersLabelText, referenceIdentifiersHelpText: props.referenceIdentifiersHelpText, referenceIdentifierValidateStatus: referenceIdentifierValidateStatus, chosenCustomer: chosenCustomer, setReferenceIdentifierValidateStatus: setReferenceIdentifierValidateStatus, dueDateMinimumOffset: props.dueDateMinimumOffset, billingLinesMetadata: billingLinesMetadata, outsideVatScope: outsideVatScope, uploadSizeLimit: props.uploadSizeLimit, attachmentTooltipText: props.attachmentTooltipText, languageString: props.language, validateFields: validateFieldsForNextStep, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
653
+ return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
654
+ }, isActiveStep: activeStep === 2 })),
655
+ react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 3 ? { display: "none" } : {} },
656
+ react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form, validateFields: validateFieldsForNextStep, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
657
+ return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
658
+ }, isActiveStep: activeStep === 3 })),
659
+ activeStep === items.length && (react_1.default.createElement(components_1.InvoicePreview, { recieverRequirements: props.receiverRequirements, form: form, chosenCustomer: chosenCustomer })),
660
+ react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== items.length ? { display: "none" } : {} },
661
+ react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "center" },
662
+ react_1.default.createElement(antd_1.Col, null,
663
+ react_1.default.createElement(reaptcha_1.default, { sitekey: "6LdMUdEZAAAAAG--2WEyu8CIRVlv6CzdZIwaQ-zt", ref: recaptchaRef, onVerify: function (response) {
664
+ setCaptchaVerified(true);
665
+ }, hl: props.language, onExpire: function () { return setCaptchaVerified(false); }, onError: function () { return setCaptchaVerified(false); } })))),
666
+ activeStep === 5 && react_1.default.createElement(components_1.SubmitConfirmation, null),
667
+ react_1.default.createElement(antd_1.Flex, { justify: "center" },
668
+ react_1.default.createElement(antd_1.Flex, { gap: isMobile ? "middle" : 60, justify: "end", style: { width: "100%", maxWidth: "900px" } },
669
+ isBackButtonVisible && (react_1.default.createElement(antd_1.Button, { onClick: handlePrevStep, size: "large", block: true },
670
+ react_1.default.createElement(icons_1.ArrowLeftOutlined, null), (_a = items[activeStep - 1]) === null || _a === void 0 ? void 0 :
671
+ _a.title)),
672
+ isNextStepVisible ? (react_1.default.createElement(antd_1.Tooltip, { title: missingRequiredDataTooltip },
673
+ react_1.default.createElement(antd_1.Button, { onClick: handleNextStep, type: "primary", size: "large", style: { maxWidth: "50%" }, disabled: isNextStepDisabled, block: true },
674
+ intl.formatMessage(exports.translationMessages.createInvoice_nextStep),
675
+ react_1.default.createElement(icons_1.ArrowRightOutlined, null)))) : (activeStep === items.length && (react_1.default.createElement(antd_1.Button, { type: "primary", htmlType: "submit", size: "large", disabled: isSubmitDisabled, onClick: function () { return form.submit(); }, block: true },
676
+ intl.formatMessage(exports.translationMessages.createInvoice_Submit),
677
+ react_1.default.createElement(icons_1.ArrowRightOutlined, null))))))))))),
678
+ props.language && props.welcomeModalTitle && props.welcomeModalParagraph && (react_1.default.createElement(welcome_modal_1.default, { isOpen: isWelcomeModalOpen, onClose: function () { return setIsWelcomeModalOpen(false); }, title: props.welcomeModalTitle[props.language], paragraph: props.welcomeModalParagraph[props.language], imageUrl: props.welcomeModalImageUrl }))));
423
679
  };
424
- exports.default = react_intl_1.injectIntl(CreateInvoiceConstructor);
680
+ exports.default = (0, react_intl_1.injectIntl)(CreateInvoiceConstructor);