@unimaze/billing 0.21.3 → 0.21.4

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 (230) hide show
  1. package/lib/common/components/CommonTranslations.d.ts +1 -29
  2. package/lib/common/components/CommonTranslations.js +4 -32
  3. package/lib/common/components/attachments/Attachment.d.ts +1 -1
  4. package/lib/common/components/attachments/AttachmentModal.d.ts +1 -1
  5. package/lib/common/components/attachments/index.d.ts +1 -1
  6. package/lib/common/components/base-information/AccountingCost.d.ts +1 -1
  7. package/lib/common/components/base-information/OrderReference.d.ts +1 -1
  8. package/lib/common/components/base-information/ProjectReference.d.ts +1 -1
  9. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +2 -1
  10. package/lib/common/components/base-information/ReferenceIdentifiers.js +29 -11
  11. package/lib/common/components/base-information/index.d.ts +10 -1
  12. package/lib/common/components/base-information/index.js +9 -1
  13. package/lib/common/components/billing-lines/BillingCalculations.d.ts +1 -1
  14. package/lib/common/components/billing-lines/BillingLinePreview.d.ts +2 -1
  15. package/lib/common/components/billing-lines/BillingLinePreview.js +4 -2
  16. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +1 -1
  17. package/lib/common/components/billing-lines/BillingTaxSummary.js +0 -1
  18. package/lib/common/components/billing-lines/CurrencySelector.d.ts +20 -0
  19. package/lib/common/components/billing-lines/CurrencySelector.js +17 -0
  20. package/lib/common/components/billing-lines/DiscountTypeSelector.d.ts +10 -0
  21. package/lib/common/components/billing-lines/DiscountTypeSelector.js +16 -0
  22. package/lib/common/components/billing-lines/NewBillingLines.d.ts +2 -1
  23. package/lib/common/components/billing-lines/NewBillingLines.js +37 -327
  24. package/lib/common/components/billing-lines/NewNewBillingLines.d.ts +15 -0
  25. package/lib/common/components/billing-lines/NewNewBillingLines.js +36 -0
  26. package/lib/common/components/billing-lines/SingleBillingLine.d.ts +19 -0
  27. package/lib/common/components/billing-lines/SingleBillingLine.js +262 -0
  28. package/lib/common/components/billing-lines/UnitOfMeasureSelector.d.ts +14 -0
  29. package/lib/common/components/billing-lines/UnitOfMeasureSelector.js +15 -0
  30. package/lib/common/components/billing-lines/cwdwdw.d.ts +1 -0
  31. package/lib/common/components/billing-lines/cwdwdw.js +14 -0
  32. package/lib/common/components/billing-lines/index.d.ts +3 -6
  33. package/lib/common/components/billing-lines/index.js +1 -1
  34. package/lib/common/components/customer/CostCenter.d.ts +1 -1
  35. package/lib/common/components/customer/CustomerContactName.d.ts +1 -1
  36. package/lib/common/components/customer/index.d.ts +1 -1
  37. package/lib/common/components/customer/index.js +6 -4
  38. package/lib/common/components/delivery-location/index.d.ts +1 -1
  39. package/lib/common/components/form-item/index.d.ts +1 -1
  40. package/lib/common/components/input/index.d.ts +1 -1
  41. package/lib/common/components/invoice/index.d.ts +3 -1
  42. package/lib/common/components/invoice/index.js +21 -14
  43. package/lib/common/components/invoice-preview/InvoicePreviewHeader.d.ts +1 -1
  44. package/lib/common/components/invoice-preview/InvoicePreviewHeader.js +7 -8
  45. package/lib/common/components/invoice-preview/index.d.ts +1 -1
  46. package/lib/common/components/invoice-preview/index.js +8 -2
  47. package/lib/common/components/payment-method/index.d.ts +1 -1
  48. package/lib/common/components/payment-method/index.js +22 -7
  49. package/lib/common/components/supplier/CityAutofill.d.ts +1 -1
  50. package/lib/common/components/supplier/index.d.ts +1 -1
  51. package/lib/common/components/welcome-modal/index.d.ts +1 -1
  52. package/lib/common/types/ReceiverRequirements.d.ts +2 -0
  53. package/lib/common/types/ReceiverRequirements.js +2 -0
  54. package/lib/create-invoice/index.d.ts +9 -1
  55. package/lib/create-invoice/index.js +87 -60
  56. package/lib/enums.d.ts +3 -0
  57. package/lib/translations/locales/en.json +7 -10
  58. package/lib/translations/locales/is.json +5 -8
  59. package/lib/translations/locales.d.ts +10 -16
  60. package/lib/unimaze-api-clients/src/mapi/api.d.ts +6664 -0
  61. package/lib/unimaze-api-clients/src/mapi/api.js +4743 -0
  62. package/lib/unimaze-api-clients/src/mapi/base.d.ts +55 -0
  63. package/lib/unimaze-api-clients/src/mapi/base.js +84 -0
  64. package/lib/unimaze-api-clients/src/mapi/configuration.d.ts +63 -0
  65. package/lib/unimaze-api-clients/src/mapi/configuration.js +28 -0
  66. package/lib/unimaze-api-clients/src/mapi/index.d.ts +13 -0
  67. package/lib/unimaze-api-clients/src/mapi/index.js +30 -0
  68. package/lib/unimaze-api-clients/src/rapi/api.d.ts +5015 -0
  69. package/lib/unimaze-api-clients/src/rapi/api.js +5582 -0
  70. package/lib/unimaze-api-clients/src/rapi/base.d.ts +55 -0
  71. package/lib/unimaze-api-clients/src/rapi/base.js +84 -0
  72. package/lib/unimaze-api-clients/src/rapi/configuration.d.ts +63 -0
  73. package/lib/unimaze-api-clients/src/rapi/configuration.js +28 -0
  74. package/lib/unimaze-api-clients/src/rapi/index.d.ts +13 -0
  75. package/lib/unimaze-api-clients/src/rapi/index.js +30 -0
  76. package/lib/unimaze-billing/src/common/components/CommonTranslations.d.ts +102 -0
  77. package/lib/unimaze-billing/src/common/components/CommonTranslations.js +106 -0
  78. package/lib/unimaze-billing/src/common/components/attachments/Attachment.d.ts +20 -0
  79. package/lib/unimaze-billing/src/common/components/attachments/Attachment.js +164 -0
  80. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.d.ts +21 -0
  81. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.js +203 -0
  82. package/lib/unimaze-billing/src/common/components/attachments/index.d.ts +27 -0
  83. package/lib/unimaze-billing/src/common/components/attachments/index.js +214 -0
  84. package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.d.ts +17 -0
  85. package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.js +61 -0
  86. package/lib/unimaze-billing/src/common/components/base-information/OrderReference.d.ts +16 -0
  87. package/lib/unimaze-billing/src/common/components/base-information/OrderReference.js +58 -0
  88. package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.d.ts +14 -0
  89. package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.js +30 -0
  90. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.d.ts +48 -0
  91. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.js +306 -0
  92. package/lib/unimaze-billing/src/common/components/base-information/index.d.ts +68 -0
  93. package/lib/unimaze-billing/src/common/components/base-information/index.js +178 -0
  94. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.d.ts +14 -0
  95. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.js +153 -0
  96. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.d.ts +21 -0
  97. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.js +41 -0
  98. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.d.ts +13 -0
  99. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.js +134 -0
  100. package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.d.ts +20 -0
  101. package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.js +17 -0
  102. package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.d.ts +10 -0
  103. package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.js +16 -0
  104. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.d.ts +129 -0
  105. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.js +495 -0
  106. package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.d.ts +15 -0
  107. package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.js +36 -0
  108. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.d.ts +14 -0
  109. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.js +199 -0
  110. package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.d.ts +14 -0
  111. package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.js +15 -0
  112. package/lib/unimaze-billing/src/common/components/billing-lines/index.d.ts +52 -0
  113. package/lib/unimaze-billing/src/common/components/billing-lines/index.js +104 -0
  114. package/lib/unimaze-billing/src/common/components/component-container/Content.d.ts +7 -0
  115. package/lib/unimaze-billing/src/common/components/component-container/Content.js +13 -0
  116. package/lib/unimaze-billing/src/common/components/component-container/Header.d.ts +9 -0
  117. package/lib/unimaze-billing/src/common/components/component-container/Header.js +28 -0
  118. package/lib/unimaze-billing/src/common/components/component-container/index.d.ts +12 -0
  119. package/lib/unimaze-billing/src/common/components/component-container/index.js +22 -0
  120. package/lib/unimaze-billing/src/common/components/customer/CostCenter.d.ts +17 -0
  121. package/lib/unimaze-billing/src/common/components/customer/CostCenter.js +163 -0
  122. package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.d.ts +17 -0
  123. package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.js +53 -0
  124. package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.d.ts +7 -0
  125. package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.js +41 -0
  126. package/lib/unimaze-billing/src/common/components/customer/index.d.ts +26 -0
  127. package/lib/unimaze-billing/src/common/components/customer/index.js +168 -0
  128. package/lib/unimaze-billing/src/common/components/date-picker/index.d.ts +21 -0
  129. package/lib/unimaze-billing/src/common/components/date-picker/index.js +23 -0
  130. package/lib/unimaze-billing/src/common/components/delivery-location/index.d.ts +12 -0
  131. package/lib/unimaze-billing/src/common/components/delivery-location/index.js +89 -0
  132. package/lib/unimaze-billing/src/common/components/editable-cell/index.d.ts +0 -0
  133. package/lib/unimaze-billing/src/common/components/editable-cell/index.js +295 -0
  134. package/lib/unimaze-billing/src/common/components/editable-row/index.d.ts +5 -0
  135. package/lib/unimaze-billing/src/common/components/editable-row/index.js +59 -0
  136. package/lib/unimaze-billing/src/common/components/form-item/index.d.ts +35 -0
  137. package/lib/unimaze-billing/src/common/components/form-item/index.js +60 -0
  138. package/lib/unimaze-billing/src/common/components/index.d.ts +18 -0
  139. package/lib/unimaze-billing/src/common/components/index.js +42 -0
  140. package/lib/unimaze-billing/src/common/components/input/index.d.ts +23 -0
  141. package/lib/unimaze-billing/src/common/components/input/index.js +37 -0
  142. package/lib/unimaze-billing/src/common/components/invoice/index.d.ts +40 -0
  143. package/lib/unimaze-billing/src/common/components/invoice/index.js +52 -0
  144. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.d.ts +12 -0
  145. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.js +105 -0
  146. package/lib/unimaze-billing/src/common/components/invoice-preview/index.d.ts +16 -0
  147. package/lib/unimaze-billing/src/common/components/invoice-preview/index.js +405 -0
  148. package/lib/unimaze-billing/src/common/components/locale-intl/index.d.ts +0 -0
  149. package/lib/unimaze-billing/src/common/components/locale-intl/index.js +51 -0
  150. package/lib/unimaze-billing/src/common/components/payment-method/index.d.ts +76 -0
  151. package/lib/unimaze-billing/src/common/components/payment-method/index.js +356 -0
  152. package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.d.ts +8 -0
  153. package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.js +37 -0
  154. package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.d.ts +3 -0
  155. package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.js +17 -0
  156. package/lib/unimaze-billing/src/common/components/submit-confirmation/index.d.ts +8 -0
  157. package/lib/unimaze-billing/src/common/components/submit-confirmation/index.js +34 -0
  158. package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.d.ts +18 -0
  159. package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.js +159 -0
  160. package/lib/unimaze-billing/src/common/components/supplier/index.d.ts +94 -0
  161. package/lib/unimaze-billing/src/common/components/supplier/index.js +334 -0
  162. package/lib/unimaze-billing/src/common/components/tooltip/index.d.ts +7 -0
  163. package/lib/unimaze-billing/src/common/components/tooltip/index.js +15 -0
  164. package/lib/unimaze-billing/src/common/components/welcome-modal/index.d.ts +15 -0
  165. package/lib/unimaze-billing/src/common/components/welcome-modal/index.js +26 -0
  166. package/lib/unimaze-billing/src/common/consts/formLayout.d.ts +74 -0
  167. package/lib/unimaze-billing/src/common/consts/formLayout.js +45 -0
  168. package/lib/unimaze-billing/src/common/consts/validationRules.d.ts +6 -0
  169. package/lib/unimaze-billing/src/common/consts/validationRules.js +69 -0
  170. package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.d.ts +5 -0
  171. package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.js +8 -0
  172. package/lib/unimaze-billing/src/common/enums/index.d.ts +1 -0
  173. package/lib/unimaze-billing/src/common/enums/index.js +8 -0
  174. package/lib/unimaze-billing/src/common/types/AppConfiguration.d.ts +23 -0
  175. package/lib/unimaze-billing/src/common/types/AppConfiguration.js +2 -0
  176. package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.d.ts +10 -0
  177. package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.js +2 -0
  178. package/lib/unimaze-billing/src/common/types/CommonProps.d.ts +33 -0
  179. package/lib/unimaze-billing/src/common/types/CommonProps.js +2 -0
  180. package/lib/unimaze-billing/src/common/types/DiscountType.d.ts +1 -0
  181. package/lib/unimaze-billing/src/common/types/DiscountType.js +2 -0
  182. package/lib/unimaze-billing/src/common/types/InvoiceFormFields.d.ts +1 -0
  183. package/lib/unimaze-billing/src/common/types/InvoiceFormFields.js +2 -0
  184. package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.d.ts +27 -0
  185. package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.js +2 -0
  186. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.d.ts +81 -0
  187. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.js +391 -0
  188. package/lib/unimaze-billing/src/common/types/SupplierInfo.d.ts +11 -0
  189. package/lib/unimaze-billing/src/common/types/SupplierInfo.js +2 -0
  190. package/lib/unimaze-billing/src/common/types/index.d.ts +1 -0
  191. package/lib/unimaze-billing/src/common/types/index.js +17 -0
  192. package/lib/unimaze-billing/src/create-credit-note/index.d.ts +9 -0
  193. package/lib/unimaze-billing/src/create-credit-note/index.js +62 -0
  194. package/lib/unimaze-billing/src/create-invoice/IntlLoader.d.ts +11 -0
  195. package/lib/unimaze-billing/src/create-invoice/IntlLoader.js +116 -0
  196. package/lib/unimaze-billing/src/create-invoice/index.d.ts +74 -0
  197. package/lib/unimaze-billing/src/create-invoice/index.js +680 -0
  198. package/lib/unimaze-billing/src/enums.d.ts +11 -0
  199. package/lib/unimaze-billing/src/enums.js +18 -0
  200. package/lib/unimaze-billing/src/index.d.ts +4 -0
  201. package/lib/unimaze-billing/src/index.js +28 -0
  202. package/lib/unimaze-billing/src/translations/locales/en.json +183 -0
  203. package/lib/unimaze-billing/src/translations/locales/is.json +183 -0
  204. package/lib/unimaze-billing/src/translations/locales.d.ts +369 -0
  205. package/lib/unimaze-billing/src/translations/locales.js +11 -0
  206. package/lib/unimaze-billing/src/utils/ApiUtility.d.ts +23 -0
  207. package/lib/unimaze-billing/src/utils/ApiUtility.js +115 -0
  208. package/lib/unimaze-billing/src/utils/BillingLineUtility.d.ts +22 -0
  209. package/lib/unimaze-billing/src/utils/BillingLineUtility.js +158 -0
  210. package/lib/unimaze-billing/src/utils/ConversionUtility.d.ts +9 -0
  211. package/lib/unimaze-billing/src/utils/ConversionUtility.js +223 -0
  212. package/lib/unimaze-billing/src/utils/FileUploadUtility.d.ts +9 -0
  213. package/lib/unimaze-billing/src/utils/FileUploadUtility.js +45 -0
  214. package/lib/unimaze-billing/src/utils/IntlUtility.d.ts +5 -0
  215. package/lib/unimaze-billing/src/utils/IntlUtility.js +55 -0
  216. package/lib/unimaze-billing/src/utils/LocationUtility.d.ts +1 -0
  217. package/lib/unimaze-billing/src/utils/LocationUtility.js +81 -0
  218. package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.d.ts +7 -0
  219. package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.js +26 -0
  220. package/lib/unimaze-billing/src/utils/RequirementsUtility.d.ts +19 -0
  221. package/lib/unimaze-billing/src/utils/RequirementsUtility.js +189 -0
  222. package/lib/unimaze-billing/src/utils/index.d.ts +2 -0
  223. package/lib/unimaze-billing/src/utils/index.js +8 -0
  224. package/lib/utils/ApiUtility.d.ts +9 -3
  225. package/lib/utils/ApiUtility.js +30 -2
  226. package/lib/utils/BillingLineUtility.d.ts +3 -0
  227. package/lib/utils/BillingLineUtility.js +32 -1
  228. package/lib/utils/RequirementsUtility.d.ts +4 -1
  229. package/lib/utils/RequirementsUtility.js +56 -1
  230. package/package.json +2 -2
@@ -0,0 +1,680 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
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
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
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);
34
+ return result;
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
+ };
81
+ var __importDefault = (this && this.__importDefault) || function (mod) {
82
+ return (mod && mod.__esModule) ? mod : { "default": mod };
83
+ };
84
+ Object.defineProperty(exports, "__esModule", { value: true });
85
+ exports.translationMessages = void 0;
86
+ var mapi_1 = require("@unimaze/api-clients/lib/mapi");
87
+ var antd_1 = require("antd");
88
+ var formLayout_1 = require("../common/consts/formLayout");
89
+ var components_1 = require("../common/components");
90
+ var react_1 = __importStar(require("react"));
91
+ var react_intl_1 = require("react-intl");
92
+ var utils_1 = require("../utils");
93
+ var BillingLineUtility_1 = require("../utils/BillingLineUtility");
94
+ var paymentMethodForConversion_1 = require("../common/components/payment-method/paymentMethodForConversion");
95
+ var uuid_1 = require("uuid");
96
+ var ApiUtility_1 = require("../utils/ApiUtility");
97
+ var ConversionUtility_1 = require("../utils/ConversionUtility");
98
+ var icons_1 = require("@ant-design/icons");
99
+ var reaptcha_1 = __importDefault(require("reaptcha"));
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)({
110
+ createInvoice_addDocumentLineMsg: {
111
+ id: "createInvoice_addDocumentLineMsg",
112
+ defaultMessage: "Add at least one document line",
113
+ },
114
+ createInvoice_selectCustomerMsg: {
115
+ id: "createInvoice_selectCustomerMsg",
116
+ defaultMessage: "Customer must be selected",
117
+ },
118
+ createInvoice_successfullySubmittedInvoiceMsg: {
119
+ id: "createInvoice_successfullySubmittedInvoiceMsg",
120
+ defaultMessage: "Successfully submitted the invoice",
121
+ },
122
+ createInvoice_successfullyUploadedAttachmentMsg: {
123
+ id: "createInvoice_successfullyUploadedAttachmentMsg",
124
+ defaultMessage: "Successfully uploaded attachment {attachment}",
125
+ },
126
+ createInvoice_ErrorUploadedAttachmentMsg: {
127
+ id: "createInvoice_ErrorUploadedAttachmentMsg",
128
+ defaultMessage: "Error uploaded attachment {attachment}",
129
+ },
130
+ createInvoice_Submit: {
131
+ id: "createInvoice_Submit",
132
+ defaultMessage: "Submit",
133
+ },
134
+ createInvoice_SendCopy: {
135
+ id: "createInvoice_SendCopy",
136
+ defaultMessage: "Send a copy",
137
+ },
138
+ createInvoice_SendCopyTooltip: {
139
+ id: "createInvoice_SendCopyTooltip",
140
+ defaultMessage: "Sends you a PDF copy of the invoice",
141
+ },
142
+ createInvoice_SendCopyTooltipDisabled: {
143
+ id: "createInvoice_SendCopyTooltipDisabled",
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",
165
+ },
166
+ });
167
+ /**
168
+ * Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
169
+ *
170
+ * @component
171
+ */
172
+ var CreateInvoiceConstructor = function (props) {
173
+ var _a;
174
+ var recaptchaRef = react_1.default.useRef(null);
175
+ var intl = props.intl;
176
+ var form = antd_1.Form.useForm()[0];
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
+ // 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];
205
+ var getDefaultPaymentType = function (defaultPaymentType) {
206
+ return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
207
+ };
208
+ var _v = (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: [{ code: undefined }],
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 = _v[0], setFormData = _v[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 () {
348
+ setIsSubmitDisabled(!captchaVerified);
349
+ }, [captchaVerified]);
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"]]);
356
+ var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
357
+ if (outsideVatScope) {
358
+ invoiceLines = invoiceLines.map(function (invoiceLine) {
359
+ invoiceLine.taxCategoryType = mapi_1.TaxCategoryTypeEnum.OutsideTaxScope;
360
+ return invoiceLine;
361
+ });
362
+ }
363
+ else {
364
+ invoiceLines = invoiceLines.map(function (invoiceLine) {
365
+ invoiceLine.taxCategoryType = mapi_1.TaxCategoryTypeEnum.StandardRated;
366
+ return invoiceLine;
367
+ });
368
+ }
369
+ form.setFieldsValue({
370
+ invoice: {
371
+ invoiceLines: invoiceLines,
372
+ },
373
+ });
374
+ }, [outsideVatScope]);
375
+ (0, react_1.useEffect)(function () {
376
+ if (supplierEmail) {
377
+ form.validateFields([["invoice", "supplier", "contact", "electronicMail"]])
378
+ .then(function () {
379
+ setSendCopyDisabled(!supplierEmail);
380
+ setSendCopy(true);
381
+ })
382
+ .catch(function () {
383
+ setSendCopyDisabled(true);
384
+ setSendCopy(false);
385
+ });
386
+ }
387
+ else {
388
+ setSendCopy(false);
389
+ setSendCopyDisabled(true);
390
+ }
391
+ }, [supplierEmail]);
392
+ var handleSubmit = function (values) {
393
+ var _a, _b, _c, _d, _e, _f;
394
+ setSubmitting(true);
395
+ if (referenceIdentifierValidateStatus !== "" && referenceIdentifierValidateStatus !== "success") {
396
+ form.scrollToField(["invoice", "referenceIdentifiers", 0, "value"]);
397
+ setSubmitting(false);
398
+ return;
399
+ }
400
+ var attachments = [
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),
404
+ ];
405
+ // Clear the array of undefined
406
+ attachments = attachments.filter(function (attachment) { return attachment && attachment.file; });
407
+ if (!chosenCustomer) {
408
+ antd_1.message.error(intl.formatMessage(exports.translationMessages.createInvoice_selectCustomerMsg));
409
+ // TODO: handle this better?
410
+ setSubmitting(false);
411
+ return;
412
+ }
413
+ var services = sendCopy
414
+ ? ["urn:services:dispatcher:mail.pdf?email=".concat(supplierEmail)]
415
+ : undefined;
416
+ var invoiceMetadataInput = (0, utils_1.convertToInvoiceMetadataInput)(values, (0, BillingLineUtility_1.billingLinesFieldsMetadata)(form), (0, paymentMethodForConversion_1.PaymentMethodFormData)(values), chosenCustomer);
417
+ var createSubmitInvoice = {
418
+ invoiceMetadataInput: invoiceMetadataInput,
419
+ more: attachments.length > 0,
420
+ messageId: (0, uuid_1.v4)(),
421
+ processingMode: mapi_1.TransactionProcessingMode.Device,
422
+ services: services,
423
+ };
424
+ (0, utils_1.submitInvoice)(createSubmitInvoice, props.mapiBaseUrl, chosenCustomerApiKey, "submitInvoice", props.language)
425
+ .then(function (resp) {
426
+ 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);
454
+ setActiveStep(activeStep + 1);
455
+ setSubmitting(false);
456
+ form.resetFields();
457
+ form.setFields([
458
+ {
459
+ name: ["invoice", "invoiceLines"],
460
+ value: [{}],
461
+ },
462
+ {
463
+ name: ["invoice", "supplier"],
464
+ value: values.invoice.supplier,
465
+ },
466
+ {
467
+ name: ["outsideVatScope"],
468
+ value: !values.invoice.supplier.vatNumber,
469
+ },
470
+ {
471
+ name: ["attachments"],
472
+ value: {
473
+ file1: { file: undefined, description: undefined },
474
+ file2: { file: undefined, description: undefined },
475
+ file3: { file: undefined, description: undefined },
476
+ },
477
+ },
478
+ ]);
479
+ // Clear the billing line dataSource
480
+ setChosenCustomer((0, ConversionUtility_1.profileOutputToPartyMetadata)(props.customers[0]));
481
+ setChosenCustomerApiKey(props.customers[0].apiKey);
482
+ // setBillingLinesDataSource([{...initialBillingLineData, key: 0}])
483
+ // setBillingLinesEditableIndex(0);
484
+ // TODO: remove this as soon as possible
485
+ // location.reload();
486
+ })
487
+ .catch(function (error) {
488
+ setSubmitting(false);
489
+ if (error.response) {
490
+ // The request was made and the server responded with a status code
491
+ // that falls out of the range of 2xx
492
+ if (error.response.data) {
493
+ var errorData = error.response.data;
494
+ if (errorData.hasOwnProperty("message")) {
495
+ antd_1.message.error(errorData.message);
496
+ }
497
+ else {
498
+ for (var errorMessageKey in errorData) {
499
+ if (errorData.hasOwnProperty(errorMessageKey)) {
500
+ antd_1.message.error(react_1.default.createElement(react_1.default.Fragment, null,
501
+ react_1.default.createElement("strong", null, errorMessageKey),
502
+ react_1.default.createElement("br", null),
503
+ errorData[errorMessageKey]));
504
+ }
505
+ }
506
+ }
507
+ }
508
+ }
509
+ else if (error.request) {
510
+ // The request was made but no response was received
511
+ // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
512
+ // http.ClientRequest in node.js
513
+ var request = error.request;
514
+ antd_1.message.error(request.responseText);
515
+ }
516
+ else {
517
+ // Something happened in setting up the request that triggered an Error
518
+ antd_1.message.error(error.message);
519
+ }
520
+ });
521
+ if (recaptchaRef) {
522
+ if (recaptchaRef.current) {
523
+ recaptchaRef.current.reset();
524
+ }
525
+ }
526
+ setIsSubmitDisabled(true);
527
+ };
528
+ var getReceiverRequirements = function () {
529
+ var _a, _b, _c, _d, _e;
530
+ if (chosenCustomer) {
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
+ }
554
+ props.getReceiverRequirements(props.rapiBaseUrl, chosenCustomer.identifier);
555
+ }
556
+ };
557
+ (0, react_1.useEffect)(function () {
558
+ getReceiverRequirements();
559
+ }, [chosenCustomer]);
560
+ var defaultCustomer;
561
+ if (props.customers.length === 1 && !chosenCustomer) {
562
+ defaultCustomer = props.customers[0];
563
+ setChosenCustomer({
564
+ contact: {
565
+ electronicMail: defaultCustomer.email,
566
+ telephone: defaultCustomer.phoneNumber,
567
+ },
568
+ address: {
569
+ countryCode: defaultCustomer.country,
570
+ city: defaultCustomer.participantLegalAddressCity,
571
+ postalZone: defaultCustomer.participantLegalAddressPostalCode,
572
+ streetNameAndNumber: defaultCustomer.participantLegalAddressStreet,
573
+ },
574
+ identifier: defaultCustomer.participantLegalIsoIdentifier,
575
+ name: defaultCustomer.name,
576
+ });
577
+ setChosenCustomerApiKey(props.customers[0].apiKey);
578
+ }
579
+ var _w = (0, react_1.useState)(undefined), billingLinesMetadata = _w[0], setBillingLinesMetadata = _w[1];
580
+ var getBillingLines = function (changedValues, allValues) {
581
+ var invoiceLines = allValues.invoice.invoiceLines;
582
+ if (invoiceLines) {
583
+ var mappedBillingLines = invoiceLines.map(function (invoiceLine) {
584
+ if (invoiceLine) {
585
+ return {
586
+ itemNo: invoiceLine.itemNo ? invoiceLine.itemNo : undefined,
587
+ name: invoiceLine.name ? invoiceLine.name : undefined,
588
+ quantity: invoiceLine.quantity ? invoiceLine.quantity : undefined,
589
+ unitPriceAmount: invoiceLine.unitPriceAmount ? invoiceLine.unitPriceAmount : undefined,
590
+ unitOfMeasure: {
591
+ unit: invoiceLine.unitOfMeasure && invoiceLine.unitOfMeasure.unit
592
+ ? mapi_1.Units[invoiceLine.unitOfMeasure.unit]
593
+ : undefined,
594
+ },
595
+ taxCategoryType: invoiceLine.taxCategoryType
596
+ ? mapi_1.TaxCategoryTypeEnum[invoiceLine.taxCategoryType]
597
+ : undefined,
598
+ discountValue: invoiceLine.discountValue ? invoiceLine.discountValue : undefined,
599
+ };
600
+ }
601
+ else {
602
+ return {};
603
+ }
604
+ });
605
+ setBillingLinesMetadata(mappedBillingLines);
606
+ }
607
+ };
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
+ ];
622
+ return (react_1.default.createElement(antd_1.Spin, { spinning: submitting },
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 }))));
679
+ };
680
+ exports.default = (0, react_intl_1.injectIntl)(CreateInvoiceConstructor);