@unimaze/billing 0.21.8 → 0.21.10

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 (89) hide show
  1. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +0 -0
  2. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +109 -0
  3. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.d.ts +14 -0
  4. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.js +73 -0
  5. package/lib/common/components/invoice-preview/InvoicePreviewInvoiceLines.d.ts +12 -0
  6. package/lib/common/components/invoice-preview/InvoicePreviewInvoiceLines.js +93 -0
  7. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +0 -0
  8. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +110 -0
  9. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.d.ts +14 -0
  10. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.js +77 -0
  11. package/lib/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.d.ts +14 -0
  12. package/lib/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.js +52 -0
  13. package/lib/common/components/payment-method/index.js +5 -0
  14. package/lib/unimaze-billing/src/common/components/CommonTranslations.d.ts +1 -29
  15. package/lib/unimaze-billing/src/common/components/CommonTranslations.js +4 -32
  16. package/lib/unimaze-billing/src/common/components/attachments/Attachment.d.ts +1 -1
  17. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.d.ts +1 -1
  18. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.js +5 -2
  19. package/lib/unimaze-billing/src/common/components/attachments/index.d.ts +1 -1
  20. package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.d.ts +1 -1
  21. package/lib/unimaze-billing/src/common/components/base-information/OrderReference.d.ts +1 -1
  22. package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.d.ts +1 -1
  23. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.d.ts +6 -1
  24. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.js +34 -12
  25. package/lib/unimaze-billing/src/common/components/base-information/index.d.ts +10 -1
  26. package/lib/unimaze-billing/src/common/components/base-information/index.js +10 -2
  27. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.d.ts +1 -1
  28. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.js +3 -5
  29. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.d.ts +4 -1
  30. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.js +45 -25
  31. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.d.ts +1 -1
  32. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.js +0 -1
  33. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.d.ts +6 -1
  34. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.js +41 -327
  35. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.d.ts +10 -5
  36. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.js +137 -61
  37. package/lib/unimaze-billing/src/common/components/billing-lines/index.d.ts +3 -6
  38. package/lib/unimaze-billing/src/common/components/billing-lines/index.js +1 -1
  39. package/lib/unimaze-billing/src/common/components/customer/CostCenter.d.ts +1 -1
  40. package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.d.ts +1 -1
  41. package/lib/unimaze-billing/src/common/components/customer/index.d.ts +1 -1
  42. package/lib/unimaze-billing/src/common/components/customer/index.js +7 -9
  43. package/lib/unimaze-billing/src/common/components/delivery-location/index.d.ts +1 -1
  44. package/lib/unimaze-billing/src/common/components/form-item/index.d.ts +1 -1
  45. package/lib/unimaze-billing/src/common/components/input/index.d.ts +1 -1
  46. package/lib/unimaze-billing/src/common/components/invoice/index.d.ts +3 -1
  47. package/lib/unimaze-billing/src/common/components/invoice/index.js +21 -14
  48. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +14 -0
  49. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +75 -0
  50. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.d.ts +14 -0
  51. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.js +73 -0
  52. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.d.ts +1 -1
  53. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.js +7 -8
  54. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.d.ts +12 -0
  55. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.js +93 -0
  56. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +14 -0
  57. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +77 -0
  58. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.d.ts +14 -0
  59. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.js +58 -0
  60. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.d.ts +14 -0
  61. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.js +52 -0
  62. package/lib/unimaze-billing/src/common/components/invoice-preview/index.d.ts +87 -1
  63. package/lib/unimaze-billing/src/common/components/invoice-preview/index.js +27 -236
  64. package/lib/unimaze-billing/src/common/components/payment-method/index.d.ts +1 -1
  65. package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.d.ts +1 -1
  66. package/lib/unimaze-billing/src/common/components/supplier/index.d.ts +1 -1
  67. package/lib/unimaze-billing/src/common/components/supplier/index.js +1 -1
  68. package/lib/unimaze-billing/src/common/components/welcome-modal/index.d.ts +1 -1
  69. package/lib/unimaze-billing/src/common/types/AppConfiguration.d.ts +7 -4
  70. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.d.ts +2 -0
  71. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.js +2 -0
  72. package/lib/unimaze-billing/src/create-invoice/index.d.ts +11 -3
  73. package/lib/unimaze-billing/src/create-invoice/index.js +91 -64
  74. package/lib/unimaze-billing/src/enums.d.ts +3 -0
  75. package/lib/unimaze-billing/src/translations/locales/en.json +13 -13
  76. package/lib/unimaze-billing/src/translations/locales/is.json +8 -8
  77. package/lib/unimaze-billing/src/translations/locales.d.ts +16 -16
  78. package/lib/unimaze-billing/src/utils/ApiUtility.d.ts +9 -3
  79. package/lib/unimaze-billing/src/utils/ApiUtility.js +31 -13
  80. package/lib/unimaze-billing/src/utils/BillingLineUtility.d.ts +4 -1
  81. package/lib/unimaze-billing/src/utils/BillingLineUtility.js +36 -4
  82. package/lib/unimaze-billing/src/utils/ConversionUtility.d.ts +2 -2
  83. package/lib/unimaze-billing/src/utils/ConversionUtility.js +10 -11
  84. package/lib/unimaze-billing/src/utils/IntlUtility.d.ts +1 -0
  85. package/lib/unimaze-billing/src/utils/IntlUtility.js +33 -10
  86. package/lib/unimaze-billing/src/utils/RequirementsUtility.d.ts +3 -1
  87. package/lib/unimaze-billing/src/utils/RequirementsUtility.js +49 -1
  88. package/lib/utils/BillingLineUtility.js +3 -2
  89. package/package.json +1 -1
@@ -106,6 +106,7 @@ var CommonTranslations_1 = require("../common/components/CommonTranslations");
106
106
  var supplier_1 = require("../common/components/supplier");
107
107
  var base_information_1 = require("../common/components/base-information");
108
108
  var payment_method_1 = require("../common/components/payment-method");
109
+ var ReferenceIdentifierUtility_1 = require("../utils/ReferenceIdentifierUtility");
109
110
  exports.translationMessages = (0, react_intl_1.defineMessages)({
110
111
  createInvoice_addDocumentLineMsg: {
111
112
  id: "createInvoice_addDocumentLineMsg",
@@ -163,6 +164,14 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
163
164
  id: "createInvoice_nextStep",
164
165
  defaultMessage: "Next step",
165
166
  },
167
+ createInvoice_validationErrorObjectIdentifierRequired: {
168
+ id: "createInvoice_validationErrorObjectIdentifierRequired",
169
+ defaultMessage: "Object identifier is required",
170
+ },
171
+ createInvoice_validationErrorObjectIdentifierNotValid: {
172
+ id: "createInvoice_validationErrorObjectIdentifierNotValid",
173
+ defaultMessage: "Object identifier is not valid",
174
+ },
166
175
  });
167
176
  /**
168
177
  * Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
@@ -194,18 +203,19 @@ var CreateInvoiceConstructor = function (props) {
194
203
  var _k = (0, react_1.useState)(""), supplierEmail = _k[0], setSupplierEmail = _k[1];
195
204
  var _l = (0, react_1.useState)(false), isSaveFieldValuesSelected = _l[0], setIsSaveFieldValuesSelected = _l[1];
196
205
  var _m = (0, react_1.useState)((0, ConversionUtility_1.profileOutputToPartyMetadata)(props.customers[0])), chosenCustomer = _m[0], setChosenCustomer = _m[1];
197
- // const [chosenCustomerApiKey, setChosenCustomerApiKey] = useState<string>(props.customers[0].apiKey);
198
- var _o = (0, react_1.useState)(true), sendCopyDisabled = _o[0], setSendCopyDisabled = _o[1];
199
- var _p = (0, react_1.useState)(false), sendCopy = _p[0], setSendCopy = _p[1];
200
- var _q = react_1.default.useState(""), referenceIdentifierValidateStatus = _q[0], setReferenceIdentifierValidateStatus = _q[1];
201
- var _r = (0, react_1.useState)(false), outsideVatScope = _r[0], setOutsideVatScope = _r[1];
202
- var _s = (0, react_1.useState)(false), captchaVerified = _s[0], setCaptchaVerified = _s[1];
203
- var _t = (0, react_1.useState)({}), removedInvoiceLine = _t[0], setRemovedInvoiceLine = _t[1];
204
- var _u = (0, react_1.useState)(undefined), missingRequiredDataTooltip = _u[0], setMissingRequiredDataTooltip = _u[1];
206
+ var _o = (0, react_1.useState)(props.customers[0].apiKey), chosenCustomerApiKey = _o[0], setChosenCustomerApiKey = _o[1];
207
+ var _p = (0, react_1.useState)(true), sendCopyDisabled = _p[0], setSendCopyDisabled = _p[1];
208
+ var _q = (0, react_1.useState)(false), sendCopy = _q[0], setSendCopy = _q[1];
209
+ var _r = react_1.default.useState(""), referenceIdentifierValidateStatus = _r[0], setReferenceIdentifierValidateStatus = _r[1];
210
+ var _s = (0, react_1.useState)(true), referenceIdentifierIsMandatory = _s[0], setReferenceIdentifierIsMandatory = _s[1];
211
+ var _t = (0, react_1.useState)(false), outsideVatScope = _t[0], setOutsideVatScope = _t[1];
212
+ var _u = (0, react_1.useState)(false), captchaVerified = _u[0], setCaptchaVerified = _u[1];
213
+ var _v = (0, react_1.useState)({}), removedInvoiceLine = _v[0], setRemovedInvoiceLine = _v[1];
214
+ var _w = (0, react_1.useState)(undefined), missingRequiredDataTooltip = _w[0], setMissingRequiredDataTooltip = _w[1];
205
215
  var getDefaultPaymentType = function (defaultPaymentType) {
206
216
  return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
207
217
  };
208
- var _v = (0, react_1.useState)({
218
+ var _x = (0, react_1.useState)({
209
219
  invoice: {
210
220
  supplier: {
211
221
  address: {
@@ -221,6 +231,7 @@ var CreateInvoiceConstructor = function (props) {
221
231
  referenceIdentifiers: [{ code: undefined }],
222
232
  singleReferenceIdentifier: {
223
233
  code: undefined,
234
+ value: undefined,
224
235
  },
225
236
  invoiceLines: [{}],
226
237
  attachments: {
@@ -230,34 +241,59 @@ var CreateInvoiceConstructor = function (props) {
230
241
  },
231
242
  issueDate: (0, dayjs_1.default)(),
232
243
  },
233
- }), formData = _v[0], setFormData = _v[1];
244
+ }), formData = _x[0], setFormData = _x[1];
234
245
  var validateFieldsForNextStep = function (fieldPaths, validateOnly) { return __awaiter(void 0, void 0, void 0, function () {
246
+ var referenceIdentifiersDefinitions, isSingleReferenceIdentifier, isMultipleReferenceIdentifier, someRequiredFieldsEmpty;
235
247
  return __generator(this, function (_a) {
236
248
  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) {
249
+ case 0:
250
+ referenceIdentifiersDefinitions = (0, ReferenceIdentifierUtility_1.getReferenceIdentifierFieldDefinitions)(props.receiverRequirements);
251
+ isSingleReferenceIdentifier = referenceIdentifiersDefinitions.length === 1;
252
+ isMultipleReferenceIdentifier = referenceIdentifiersDefinitions.length > 1;
253
+ someRequiredFieldsEmpty = function () {
254
+ var _a, _b;
255
+ var referenceIdentifierType = form.getFieldValue(["invoice", "referenceIdentifiers"]);
256
+ return ((_a = referenceIdentifierType[0]) === null || _a === void 0 ? void 0 : _a.code) ? !((_b = referenceIdentifierType[0]) === null || _b === void 0 ? void 0 : _b.value) : false;
257
+ };
258
+ return [4 /*yield*/, form.validateFields(fieldPaths, { validateOnly: validateOnly || true })
259
+ .then(function () {
252
260
  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
+ var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
262
+ var noInvoiceLines = invoiceLines.length <= 1 && ((_a = invoiceLines[0]) === null || _a === void 0 ? void 0 : _a.editing) === true;
263
+ if (activeStep === 2 && noInvoiceLines) {
264
+ setIsNextStepDisabled(true);
265
+ setMissingRequiredDataTooltip(react_1.default.createElement(react_1.default.Fragment, null, props.intl.formatMessage(exports.translationMessages.createInvoice_addDocumentLineMsg)));
266
+ }
267
+ else if (activeStep === 2 && isMultipleReferenceIdentifier && someRequiredFieldsEmpty()) {
268
+ setIsNextStepDisabled(true);
269
+ setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
270
+ }
271
+ else if (activeStep === 2 && isSingleReferenceIdentifier && referenceIdentifierIsMandatory && !form.getFieldValue(["invoice", "singleReferenceIdentifier", "value"])) {
272
+ setIsNextStepDisabled(true);
273
+ setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
274
+ }
275
+ else if (activeStep === 2 && referenceIdentifierValidateStatus === "error") {
276
+ setIsNextStepDisabled(true);
277
+ setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierNotValid));
278
+ }
279
+ else {
280
+ setIsNextStepDisabled(false);
281
+ setMissingRequiredDataTooltip(undefined);
282
+ }
283
+ })
284
+ .catch(function (error) {
285
+ var _a;
286
+ var requiredFields = [];
287
+ (_a = error === null || error === void 0 ? void 0 : error.errorFields) === null || _a === void 0 ? void 0 : _a.map(function (errorField) {
288
+ var _a;
289
+ requiredFields.push(errorField.name[((_a = errorField === null || errorField === void 0 ? void 0 : errorField.name) === null || _a === void 0 ? void 0 : _a.length) - 1]);
290
+ });
291
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.length) > 0) {
292
+ var names = getFieldNames(requiredFields);
293
+ setMissingRequiredDataTooltip((0, RequirementsUtility_1.getRequiredTooltipMessage)(props.intl.formatMessage(CommonTranslations_1.commonTranslationMessages.missingRequiredData), names));
294
+ }
295
+ setIsNextStepDisabled(true);
296
+ })];
261
297
  case 1:
262
298
  _a.sent();
263
299
  return [2 /*return*/];
@@ -291,6 +327,10 @@ var CreateInvoiceConstructor = function (props) {
291
327
  return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountNo);
292
328
  case "bankNumber":
293
329
  return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_icelandicClaim_bankNo);
330
+ case "value": // singleReferenceIdentifier
331
+ return intl.formatMessage(base_information_1.translationMessages.baseInformation_objectIdentifier);
332
+ case "documentNo":
333
+ return intl.formatMessage(base_information_1.translationMessages.baseInformation_projectReference);
294
334
  default:
295
335
  return "";
296
336
  }
@@ -299,9 +339,13 @@ var CreateInvoiceConstructor = function (props) {
299
339
  var saveFieldValuesToLocalStorage = function () {
300
340
  var flatFields = form.getFieldsValue();
301
341
  delete flatFields.attachments;
342
+ delete flatFields.invoice.invoiceNo;
302
343
  delete flatFields.invoice.invoiceLines;
303
344
  delete flatFields.invoice.dueDate;
304
345
  delete flatFields.invoice.issueDate;
346
+ delete flatFields.invoice.buyerReference;
347
+ delete flatFields.invoice.referenceIdentifiers;
348
+ delete flatFields.invoice.notes;
305
349
  localStorage.setItem("formData", JSON.stringify(flatFields));
306
350
  };
307
351
  var handlePrevStep = function () {
@@ -352,7 +396,9 @@ var CreateInvoiceConstructor = function (props) {
352
396
  setIsNextStepVisible(activeStep < items.length);
353
397
  }, [activeStep]);
354
398
  (0, react_1.useEffect)(function () {
355
- form.resetFields([["invoice", "supplier", "vatNumber"]]);
399
+ if (outsideVatScope) {
400
+ form.resetFields([["invoice", "supplier", "vatNumber"]]);
401
+ }
356
402
  var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
357
403
  if (outsideVatScope) {
358
404
  invoiceLines = invoiceLines.map(function (invoiceLine) {
@@ -411,7 +457,7 @@ var CreateInvoiceConstructor = function (props) {
411
457
  return;
412
458
  }
413
459
  var services = sendCopy
414
- ? ["urn:services:dispatcher:mail.pdf?email=".concat(supplierEmail)]
460
+ ? ["urn:services:dispatcher:mail.pdf?email=".concat(supplierEmail, "#$#lang=").concat(props.language)]
415
461
  : undefined;
416
462
  var invoiceMetadataInput = (0, utils_1.convertToInvoiceMetadataInput)(values, (0, BillingLineUtility_1.billingLinesFieldsMetadata)(form), (0, paymentMethodForConversion_1.PaymentMethodFormData)(values), chosenCustomer);
417
463
  var createSubmitInvoice = {
@@ -423,34 +469,15 @@ var CreateInvoiceConstructor = function (props) {
423
469
  };
424
470
  (0, utils_1.submitInvoice)(createSubmitInvoice, props.mapiBaseUrl, chosenCustomerApiKey, "submitInvoice", props.language)
425
471
  .then(function (resp) {
472
+ var _a;
426
473
  antd_1.message.success(intl.formatMessage(exports.translationMessages.createInvoice_successfullySubmittedInvoiceMsg));
427
- var messageId = resp.data.uniqueId;
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
- }
452
- };
453
- submitAttachmentIfAnyLeft(messageId, attachments, props.mapiBaseUrl, chosenCustomerApiKey);
474
+ if (resp.status === 200) {
475
+ var response = resp.data;
476
+ (0, ApiUtility_1.submitAttachmentIfAnyLeft)((_a = response === null || response === void 0 ? void 0 : response.uniqueId) !== null && _a !== void 0 ? _a : "", attachments, props.mapiBaseUrl, chosenCustomerApiKey, intl);
477
+ }
478
+ else {
479
+ antd_1.message.error("Created invoice had validation errors");
480
+ }
454
481
  setActiveStep(activeStep + 1);
455
482
  setSubmitting(false);
456
483
  form.resetFields();
@@ -576,7 +603,7 @@ var CreateInvoiceConstructor = function (props) {
576
603
  });
577
604
  setChosenCustomerApiKey(props.customers[0].apiKey);
578
605
  }
579
- var _w = (0, react_1.useState)(undefined), billingLinesMetadata = _w[0], setBillingLinesMetadata = _w[1];
606
+ var _y = (0, react_1.useState)(undefined), billingLinesMetadata = _y[0], setBillingLinesMetadata = _y[1];
580
607
  var getBillingLines = function (changedValues, allValues) {
581
608
  var invoiceLines = allValues.invoice.invoiceLines;
582
609
  if (invoiceLines) {
@@ -651,7 +678,7 @@ var CreateInvoiceConstructor = function (props) {
651
678
  react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 2 ? { display: "none" } : {} },
652
679
  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
680
  return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
654
- }, isActiveStep: activeStep === 2 })),
681
+ }, isActiveStep: activeStep === 2, setReferenceIdentifierIsMandatory: setReferenceIdentifierIsMandatory })),
655
682
  react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 3 ? { display: "none" } : {} },
656
683
  react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form, validateFields: validateFieldsForNextStep, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
657
684
  return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
@@ -5,6 +5,9 @@ declare const AvailableTaxCategoryTypeEnum: {
5
5
  ZeroRated: TaxCategoryTypeEnum.ZeroRated;
6
6
  Exempt: TaxCategoryTypeEnum.Exempt;
7
7
  OutsideTaxScope: TaxCategoryTypeEnum.OutsideTaxScope;
8
+ ExemptionForResale: TaxCategoryTypeEnum.ExemptionForResale;
9
+ SpecialTaxationProcedure: TaxCategoryTypeEnum.SpecialTaxationProcedure;
10
+ Annulled: TaxCategoryTypeEnum.Annulled;
8
11
  };
9
12
  type excludedOptions = typeof TaxCategoryTypeEnum.ExemptEuropeanEconomicArea | typeof TaxCategoryTypeEnum.FreeExportTaxNotCharged | typeof TaxCategoryTypeEnum.ReverseCharged;
10
13
  type AvailableTaxCategoryTypeEnum = Exclude<TaxCategoryTypeEnum, excludedOptions>;
@@ -26,13 +26,15 @@
26
26
  "baseInformation_issueDate": "Issue date",
27
27
  "baseInformation_issueDate_title": "The issue date controls on which settlement period the transfer is registered",
28
28
  "baseInformation_notes": "Notes",
29
+ "baseInformation_objectIdentifier": "Object identifier",
29
30
  "baseInformation_orderReferenceLabel": "Order number",
30
31
  "baseInformation_orderReferenceLabel_helpText": "Only use a reference to an actual order here. If no order exists, the buyer reference must be specified.",
32
+ "baseInformation_projectReference": "Project reference is required",
31
33
  "baseInformation_projectReferenceLabel": "Project reference",
32
34
  "baseInformation_title": "Base Information",
33
- "billingCalculations_labels_AmountPayable": "Amount payable",
35
+ "billingCalculations_labels_AmountPayable": "Total invoiced amount",
34
36
  "billingCalculations_labels_RoundingAmount": "Rounding amount",
35
- "billingCalculations_labels_TaxAmountWithoutVat": "Total amount without VAT",
37
+ "billingCalculations_labels_TaxAmountWithoutVat": "Total amount before VAT",
36
38
  "billingCalculations_labels_TotalAmountWithVat": "Total amount with VAT",
37
39
  "billingCalculations_labels_TotalRoundingAmount": "Rounding amount",
38
40
  "billingCalculations_labels_TotalVatAmount": "Total VAT amount",
@@ -52,10 +54,11 @@
52
54
  "billingLines_currency_SEK_short": "SEK",
53
55
  "billingLines_currency_USD": "US dollar (USD)",
54
56
  "billingLines_currency_USD_short": "USD",
55
- "billingLines_discount": "Discount",
57
+ "billingLines_discount": "line discount",
56
58
  "billingLines_discount_helpText": "Discount can be represented as an amount or a percentage indicated with a percentage sign (%)",
59
+ "billingLines_input_must_be_number_validationMessage": "Input must be a number",
57
60
  "billingLines_itemNo": "Item no",
58
- "billingLines_labels_addButton": "Add new line",
61
+ "billingLines_labels_addButton": "Save line",
59
62
  "billingLines_lineAmount": "Amount",
60
63
  "billingLines_name": "Name",
61
64
  "billingLines_placeholders_itemNo": "Item No",
@@ -68,6 +71,7 @@
68
71
  "billingLines_title": "Document lines",
69
72
  "billingLines_tooltip_title": "Item number, Name, Quantity, Unit of measure, Unit price amount Tax category and Discount need to be defined here. VAT is automatically applied. Click \"Add a row\" to add a new line",
70
73
  "billingLines_total": "Total",
74
+ "billingLines_total_discount": "Total discount",
71
75
  "billingLines_unitOfMeasure": "Unit of measure",
72
76
  "billingLines_unitPriceAmount": "Unit price",
73
77
  "billingTaxSummary_taxAmount": "Tax",
@@ -92,6 +96,8 @@
92
96
  "createInvoice_successfullySubmittedInvoiceMsg": "Successfully submitted the invoice",
93
97
  "createInvoice_successfullyUploadedAttachmentMsg": "Successfully uploaded attachment {attachment}",
94
98
  "createInvoice_supplierStepTitle": "Supplier",
99
+ "createInvoice_validationErrorObjectIdentifierNotValid": "Object identifier is not valid",
100
+ "createInvoice_validationErrorObjectIdentifierRequired": "Object identifier is required",
95
101
  "customer_address_city": "City",
96
102
  "customer_address_countryCode": "Country code",
97
103
  "customer_address_streetNameAndNumber": "Address",
@@ -134,6 +140,7 @@
134
140
  "referenceIdentifiers_labels_addButton": "Add reference identifier",
135
141
  "referenceIdentifiers_labels_referenceIdentifier": "Object identifier",
136
142
  "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.",
143
+ "referenceIdentifiers_values_validation_message": "This value doesn't exist",
137
144
  "saveInformation_label": "Save information",
138
145
  "submitConfirmation_footer_text": "If any questions arise, please contact us at",
139
146
  "submitConfirmation_text": "The invoice has been sent to the customer.",
@@ -155,14 +162,7 @@
155
162
  "supplier_title": "Supplier",
156
163
  "supplier_vatNumber": "VAT no",
157
164
  "supplier_vatNumber_mandatory": "VAT number is required if some document lines are using any tax category type other than 'Outside tax scope'",
158
- "taxCategoryType_labels_Exempt": "Exempt",
159
- "taxCategoryType_labels_ExemptEuropeanEconomicArea": "Exempt European economic area",
160
- "taxCategoryType_labels_FreeExportTaxNotCharged": "Free export tax not charged",
161
- "taxCategoryType_labels_OutsideTaxScope": "Outside tax scope",
162
- "taxCategoryType_labels_ReducedRated": "Reduced rated",
163
- "taxCategoryType_labels_ReverseCharged": "Reverse charged",
164
- "taxCategoryType_labels_StandardRated": "Standard rated",
165
- "taxCategoryType_labels_ZeroRated": "Zero rated",
165
+ "taxCategoryType_label": "{taxCategoryType, select , StandardRated {Standard rated} ReducedRated {Reduced rated} ZeroRated {Zero rated} Exempt {Exempt} OutsideTaxScope {Outside tax scope} ReverseCharged {Reverse charged} FreeExportTaxNotCharged {Free export tax not charged} ExemptEuropeanEconomicArea {Exempt European economic area} ExemptionForResale {Exemption for resale} other {taxCategoryType}}",
166
166
  "unitOfMeasure_labels_CubicMetre": "Cubic metre",
167
167
  "unitOfMeasure_labels_Day": "Day",
168
168
  "unitOfMeasure_labels_Hour": "Hour",
@@ -172,7 +172,7 @@
172
172
  "unitOfMeasure_labels_Litre": "Litre",
173
173
  "unitOfMeasure_labels_Metre": "Metre",
174
174
  "unitOfMeasure_labels_Month": "Month",
175
- "unitOfMeasure_labels_One": "One",
175
+ "unitOfMeasure_labels_One": "Unit",
176
176
  "unitOfMeasure_labels_Package": "Package",
177
177
  "unitOfMeasure_labels_Piece": "Piece",
178
178
  "unitOfMeasure_labels_SquareMetre": "Square metre",
@@ -26,8 +26,10 @@
26
26
  "baseInformation_issueDate": "Útgáfudags.",
27
27
  "baseInformation_issueDate_title": "Útgáfudagsetning stjórnar á hvaða uppgjörstímabili færslan skráist",
28
28
  "baseInformation_notes": "Athugasemdir",
29
+ "baseInformation_objectIdentifier": "Tilvísun",
29
30
  "baseInformation_orderReferenceLabel": "Pöntun nr.",
30
31
  "baseInformation_orderReferenceLabel_helpText": "Aðeins má nota númer raunverulegrar pöntunar. Ef engin pöntun er til, verður að nota tilvísun kaupanda.",
32
+ "baseInformation_projectReference": "Verknúmer er skilyrt svæði",
31
33
  "baseInformation_projectReferenceLabel": "Verknúmer",
32
34
  "baseInformation_title": "Grunnupplýsingar",
33
35
  "billingCalculations_labels_AmountPayable": "Til greiðslu",
@@ -54,6 +56,7 @@
54
56
  "billingLines_currency_USD_short": "USD",
55
57
  "billingLines_discount": "Afsláttur",
56
58
  "billingLines_discount_helpText": "Afslátt má setja fram sem upphæð eða sem hlutfall með því að bæta við prósentutákni (%)",
59
+ "billingLines_input_must_be_number_validationMessage": "Inntak verður að vera tala",
57
60
  "billingLines_itemNo": "Vörunr.",
58
61
  "billingLines_labels_addButton": "Bæta við línu",
59
62
  "billingLines_lineAmount": "Upphæð",
@@ -68,6 +71,7 @@
68
71
  "billingLines_title": "Reikningslínur",
69
72
  "billingLines_tooltip_title": "Hér þarf að skilgreina Vörunr, Nafn, Fjölda, Mælieiningu, Verð pr. einingu og upphæð. Virðisauki reiknast sjálfkrafa. Smelltu á \"Bæta við röð\" til þess að bæta við vörulínu",
70
73
  "billingLines_total": "Total",
74
+ "billingLines_total_discount": "Total discount",
71
75
  "billingLines_unitOfMeasure": "Mælieining",
72
76
  "billingLines_unitPriceAmount": "Verð pr. einingu",
73
77
  "billingTaxSummary_taxAmount": "Skattur",
@@ -92,6 +96,8 @@
92
96
  "createInvoice_successfullySubmittedInvoiceMsg": "Sending reiknings tókst",
93
97
  "createInvoice_successfullyUploadedAttachmentMsg": "Það tókst að hlaða upp viðhenginu {attachment}",
94
98
  "createInvoice_supplierStepTitle": "Þínar upplýsingar",
99
+ "createInvoice_validationErrorObjectIdentifierNotValid": "Tilvísun er ekki gild",
100
+ "createInvoice_validationErrorObjectIdentifierRequired": "Tilvísun þarf að fylla út",
95
101
  "customer_address_city": "Borg",
96
102
  "customer_address_countryCode": "Landsnúmer",
97
103
  "customer_address_streetNameAndNumber": "Heimilisfang",
@@ -134,6 +140,7 @@
134
140
  "referenceIdentifiers_labels_addButton": "Bætið við tilvísunarnúmeri",
135
141
  "referenceIdentifiers_labels_referenceIdentifier": "Viðfang",
136
142
  "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ð á.",
143
+ "referenceIdentifiers_values_validation_message": "Þetta gildi er ekki til",
137
144
  "saveInformation_label": "Vista upplýsingar",
138
145
  "submitConfirmation_footer_text": "If any questions arise, please contact us at",
139
146
  "submitConfirmation_text": "The invoice has been sent to the customer.",
@@ -155,14 +162,7 @@
155
162
  "supplier_title": "Birgi",
156
163
  "supplier_vatNumber": "VSK nr.",
157
164
  "supplier_vatNumber_mandatory": "Gerð er krafa um VSK númer ef línur í skjali nota aðra skattflokka heldur en 'Utan skattumfangs'",
158
- "taxCategoryType_labels_Exempt": "Undaþeginn skatti",
159
- "taxCategoryType_labels_ExemptEuropeanEconomicArea": "Exempt European economic area",
160
- "taxCategoryType_labels_FreeExportTaxNotCharged": "Free export tax not charged",
161
- "taxCategoryType_labels_OutsideTaxScope": "Utan skattumfangs",
162
- "taxCategoryType_labels_ReducedRated": "Lækkaður skattur",
163
- "taxCategoryType_labels_ReverseCharged": "Reverse charged",
164
- "taxCategoryType_labels_StandardRated": "Hefðbundinn skattur",
165
- "taxCategoryType_labels_ZeroRated": "Enginn skattur",
165
+ "taxCategoryType_label": "{taxCategoryType, select , StandardRated {Hefðbundinn skattur} ReducedRated {Lækkaður skattur} ZeroRated {Enginn skattur} Exempt {Undaþeginn skatti} OutsideTaxScope {Utan skattumfangs} ReverseCharged {Reverse charged} FreeExportTaxNotCharged {Free export tax not charged} ExemptEuropeanEconomicArea {Exempt European economic area} ExemptionForResale {Undanþága vegna endursölu} other {taxCategoryType}}",
166
166
  "unitOfMeasure_labels_CubicMetre": "Rúmmetri",
167
167
  "unitOfMeasure_labels_Day": "Dagur",
168
168
  "unitOfMeasure_labels_Hour": "Klukkustund",
@@ -27,8 +27,10 @@ declare const _default: {
27
27
  baseInformation_issueDate: string;
28
28
  baseInformation_issueDate_title: string;
29
29
  baseInformation_notes: string;
30
+ baseInformation_objectIdentifier: string;
30
31
  baseInformation_orderReferenceLabel: string;
31
32
  baseInformation_orderReferenceLabel_helpText: string;
33
+ baseInformation_projectReference: string;
32
34
  baseInformation_projectReferenceLabel: string;
33
35
  baseInformation_title: string;
34
36
  billingCalculations_labels_AmountPayable: string;
@@ -55,6 +57,7 @@ declare const _default: {
55
57
  billingLines_currency_USD_short: string;
56
58
  billingLines_discount: string;
57
59
  billingLines_discount_helpText: string;
60
+ billingLines_input_must_be_number_validationMessage: string;
58
61
  billingLines_itemNo: string;
59
62
  billingLines_labels_addButton: string;
60
63
  billingLines_lineAmount: string;
@@ -69,6 +72,7 @@ declare const _default: {
69
72
  billingLines_title: string;
70
73
  billingLines_tooltip_title: string;
71
74
  billingLines_total: string;
75
+ billingLines_total_discount: string;
72
76
  billingLines_unitOfMeasure: string;
73
77
  billingLines_unitPriceAmount: string;
74
78
  billingTaxSummary_taxAmount: string;
@@ -93,6 +97,8 @@ declare const _default: {
93
97
  createInvoice_successfullySubmittedInvoiceMsg: string;
94
98
  createInvoice_successfullyUploadedAttachmentMsg: string;
95
99
  createInvoice_supplierStepTitle: string;
100
+ createInvoice_validationErrorObjectIdentifierNotValid: string;
101
+ createInvoice_validationErrorObjectIdentifierRequired: string;
96
102
  customer_address_city: string;
97
103
  customer_address_countryCode: string;
98
104
  customer_address_streetNameAndNumber: string;
@@ -135,6 +141,7 @@ declare const _default: {
135
141
  referenceIdentifiers_labels_addButton: string;
136
142
  referenceIdentifiers_labels_referenceIdentifier: string;
137
143
  referenceIdentifiers_labels_referenceIdentifier_title: string;
144
+ referenceIdentifiers_values_validation_message: string;
138
145
  saveInformation_label: string;
139
146
  submitConfirmation_footer_text: string;
140
147
  submitConfirmation_text: string;
@@ -156,14 +163,7 @@ declare const _default: {
156
163
  supplier_title: string;
157
164
  supplier_vatNumber: string;
158
165
  supplier_vatNumber_mandatory: string;
159
- taxCategoryType_labels_Exempt: string;
160
- taxCategoryType_labels_ExemptEuropeanEconomicArea: string;
161
- taxCategoryType_labels_FreeExportTaxNotCharged: string;
162
- taxCategoryType_labels_OutsideTaxScope: string;
163
- taxCategoryType_labels_ReducedRated: string;
164
- taxCategoryType_labels_ReverseCharged: string;
165
- taxCategoryType_labels_StandardRated: string;
166
- taxCategoryType_labels_ZeroRated: string;
166
+ taxCategoryType_label: string;
167
167
  unitOfMeasure_labels_CubicMetre: string;
168
168
  unitOfMeasure_labels_Day: string;
169
169
  unitOfMeasure_labels_Hour: string;
@@ -210,8 +210,10 @@ declare const _default: {
210
210
  baseInformation_issueDate: string;
211
211
  baseInformation_issueDate_title: string;
212
212
  baseInformation_notes: string;
213
+ baseInformation_objectIdentifier: string;
213
214
  baseInformation_orderReferenceLabel: string;
214
215
  baseInformation_orderReferenceLabel_helpText: string;
216
+ baseInformation_projectReference: string;
215
217
  baseInformation_projectReferenceLabel: string;
216
218
  baseInformation_title: string;
217
219
  billingCalculations_labels_AmountPayable: string;
@@ -238,6 +240,7 @@ declare const _default: {
238
240
  billingLines_currency_USD_short: string;
239
241
  billingLines_discount: string;
240
242
  billingLines_discount_helpText: string;
243
+ billingLines_input_must_be_number_validationMessage: string;
241
244
  billingLines_itemNo: string;
242
245
  billingLines_labels_addButton: string;
243
246
  billingLines_lineAmount: string;
@@ -252,6 +255,7 @@ declare const _default: {
252
255
  billingLines_title: string;
253
256
  billingLines_tooltip_title: string;
254
257
  billingLines_total: string;
258
+ billingLines_total_discount: string;
255
259
  billingLines_unitOfMeasure: string;
256
260
  billingLines_unitPriceAmount: string;
257
261
  billingTaxSummary_taxAmount: string;
@@ -276,6 +280,8 @@ declare const _default: {
276
280
  createInvoice_successfullySubmittedInvoiceMsg: string;
277
281
  createInvoice_successfullyUploadedAttachmentMsg: string;
278
282
  createInvoice_supplierStepTitle: string;
283
+ createInvoice_validationErrorObjectIdentifierNotValid: string;
284
+ createInvoice_validationErrorObjectIdentifierRequired: string;
279
285
  customer_address_city: string;
280
286
  customer_address_countryCode: string;
281
287
  customer_address_streetNameAndNumber: string;
@@ -318,6 +324,7 @@ declare const _default: {
318
324
  referenceIdentifiers_labels_addButton: string;
319
325
  referenceIdentifiers_labels_referenceIdentifier: string;
320
326
  referenceIdentifiers_labels_referenceIdentifier_title: string;
327
+ referenceIdentifiers_values_validation_message: string;
321
328
  saveInformation_label: string;
322
329
  submitConfirmation_footer_text: string;
323
330
  submitConfirmation_text: string;
@@ -339,14 +346,7 @@ declare const _default: {
339
346
  supplier_title: string;
340
347
  supplier_vatNumber: string;
341
348
  supplier_vatNumber_mandatory: string;
342
- taxCategoryType_labels_Exempt: string;
343
- taxCategoryType_labels_ExemptEuropeanEconomicArea: string;
344
- taxCategoryType_labels_FreeExportTaxNotCharged: string;
345
- taxCategoryType_labels_OutsideTaxScope: string;
346
- taxCategoryType_labels_ReducedRated: string;
347
- taxCategoryType_labels_ReverseCharged: string;
348
- taxCategoryType_labels_StandardRated: string;
349
- taxCategoryType_labels_ZeroRated: string;
349
+ taxCategoryType_label: string;
350
350
  unitOfMeasure_labels_CubicMetre: string;
351
351
  unitOfMeasure_labels_Day: string;
352
352
  unitOfMeasure_labels_Hour: string;
@@ -1,7 +1,9 @@
1
- import { MessageOutput } from "@unimaze/api-clients/lib/mapi";
1
+ import { ImportDocumentValidationData, MessageOutput } from "@unimaze/api-clients/lib/mapi";
2
2
  import { InvoiceMetadataInput, TransactionProcessingMode } from "@unimaze/api-clients/lib/mapi/api";
3
3
  import { AxiosPromise, CancelToken } from "axios";
4
4
  import { LanguageProp } from "../common/types/CommonProps";
5
+ import { UploadFile } from "antd/es/upload/interface";
6
+ import { IntlShape } from "react-intl";
5
7
  interface CreateSubmitInvoice {
6
8
  messageId: string;
7
9
  more: boolean;
@@ -18,6 +20,10 @@ interface AttachDocument {
18
20
  }
19
21
  declare const submitDocument: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, apiKey?: string) => AxiosPromise<MessageOutput>;
20
22
  declare const submitDocumentFetch: (data: any, attachDocument: AttachDocument, mapiBaseUrl: string, apiKey: string) => Promise<Response>;
21
- declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, rapiBaseUrl: string, apiKey: string, callName?: string, language?: LanguageProp) => AxiosPromise<MessageOutput>;
23
+ declare const submitInvoice: (createSubmitInvoice: CreateSubmitInvoice, mapiBaseUrl: string, apiKey: string, callName?: string, language?: LanguageProp) => AxiosPromise<MessageOutput | ImportDocumentValidationData[]>;
22
24
  export declare const getCancelToken: (callName: string, showMessage?: boolean) => CancelToken;
23
- export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument, submitDocumentFetch };
25
+ declare const submitAttachmentIfAnyLeft: (_messageId: string, _attachments: {
26
+ description: string;
27
+ file: UploadFile;
28
+ }[], _mapiBaseUrl: string, _chosenCustomerApiKey: string, intl: IntlShape) => void;
29
+ export { submitInvoice, CreateSubmitInvoice, submitDocument, AttachDocument, submitDocumentFetch, submitAttachmentIfAnyLeft };
@@ -14,11 +14,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.submitDocumentFetch = exports.submitDocument = exports.submitInvoice = exports.getCancelToken = void 0;
17
+ exports.submitAttachmentIfAnyLeft = exports.submitDocumentFetch = exports.submitDocument = exports.submitInvoice = exports.getCancelToken = void 0;
18
18
  var api_clients_1 = require("@unimaze/api-clients");
19
- var api_1 = require("@unimaze/api-clients/src/rapi/api");
20
19
  var mapi_1 = require("@unimaze/api-clients/lib/mapi");
21
20
  var axios_1 = __importDefault(require("axios"));
21
+ var antd_1 = require("antd");
22
+ var create_invoice_1 = require("../create-invoice");
22
23
  var initialiseTransactionApi = function (mapiBaseUrl) {
23
24
  var apiConfig = {
24
25
  basePath: mapiBaseUrl,
@@ -33,13 +34,6 @@ var initialiseMessageApi = function (mapiBaseUrl) {
33
34
  var initiatedConfig = new mapi_1.Configuration(apiConfig);
34
35
  return new api_clients_1.mapi.MessageApi(initiatedConfig);
35
36
  };
36
- var initialiseRapiPortalApi = function (rapiBaseUrl) {
37
- var apiConfig = {
38
- basePath: rapiBaseUrl,
39
- };
40
- var initiatedConfig = new mapi_1.Configuration(apiConfig);
41
- return new api_1.PortalApi(initiatedConfig);
42
- };
43
37
  var submitDocument = function (data, attachDocument, mapiBaseUrl, apiKey) {
44
38
  var messageId = attachDocument.messageId, name = attachDocument.name, contentType = attachDocument.contentType, more = attachDocument.more;
45
39
  var headers = __assign(__assign({}, (apiKey && { Authorization: "Bearer ".concat(window.btoa(apiKey)) })), { "Content-Type": "application/octet-stream", "X-test": "test" });
@@ -81,12 +75,10 @@ var submitDocumentFetch = function (data, attachDocument, mapiBaseUrl, apiKey) {
81
75
  return responsePromise;
82
76
  };
83
77
  exports.submitDocumentFetch = submitDocumentFetch;
84
- var submitInvoice = function (createSubmitInvoice, mapiBaseUrl, rapiBaseUrl, apiKey, callName, language) {
78
+ var submitInvoice = function (createSubmitInvoice, mapiBaseUrl, apiKey, callName, language) {
85
79
  var transactionApi = initialiseTransactionApi(mapiBaseUrl);
86
- var portalApi = initialiseRapiPortalApi(rapiBaseUrl);
87
- var token = portalApi.supplierPortalAuthenticate();
88
80
  var messageId = createSubmitInvoice.messageId, more = createSubmitInvoice.more, conversationIdentifier = createSubmitInvoice.conversationIdentifier, processingMode = createSubmitInvoice.processingMode, services = createSubmitInvoice.services, invoiceMetadataInput = createSubmitInvoice.invoiceMetadataInput;
89
- return transactionApi.createSubmitInvoice(messageId, more, conversationIdentifier, processingMode, services, invoiceMetadataInput, createOptions(apiKey, callName, language));
81
+ return transactionApi.createSubmitInvoice(messageId, more, conversationIdentifier, processingMode, services, undefined, invoiceMetadataInput, createOptions(apiKey, callName, language));
90
82
  };
91
83
  exports.submitInvoice = submitInvoice;
92
84
  var createOptions = function (apiKey, callName, language) {
@@ -113,3 +105,29 @@ var getCancelToken = function (callName, showMessage) {
113
105
  return window[callName].token;
114
106
  };
115
107
  exports.getCancelToken = getCancelToken;
108
+ var submitAttachmentIfAnyLeft = function (_messageId, _attachments, _mapiBaseUrl, _chosenCustomerApiKey, intl) {
109
+ if (_attachments && _attachments.length > 0) {
110
+ var nextFileArray = _attachments.splice(0, 1);
111
+ var nextFile = nextFileArray[0].file.originFileObj;
112
+ var nextFileDescription_1 = nextFileArray[0].description;
113
+ if (!nextFile)
114
+ throw new Error("NextFile is empty");
115
+ var createAttachDocument = {
116
+ messageId: _messageId,
117
+ contentType: nextFile.type,
118
+ more: _attachments.length > 0,
119
+ name: nextFileDescription_1, // nextFile.name,
120
+ };
121
+ submitDocumentFetch(nextFile, createAttachDocument, _mapiBaseUrl, _chosenCustomerApiKey)
122
+ .then(function (submitDocumentResponse) {
123
+ antd_1.message.success(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_successfullyUploadedAttachmentMsg, { attachment: nextFileDescription_1 }));
124
+ submitAttachmentIfAnyLeft(_messageId, _attachments, _mapiBaseUrl, _chosenCustomerApiKey, intl);
125
+ })
126
+ .catch(function (documentSendingErrorMessage) {
127
+ antd_1.message.error("".concat(intl.formatMessage(create_invoice_1.translationMessages.createInvoice_ErrorUploadedAttachmentMsg, {
128
+ attachment: nextFileDescription_1,
129
+ }), " - ").concat(documentSendingErrorMessage.message));
130
+ });
131
+ }
132
+ };
133
+ exports.submitAttachmentIfAnyLeft = submitAttachmentIfAnyLeft;