@unimaze/billing 0.21.52 → 0.21.53

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 (187) hide show
  1. package/lib/create-invoice/index.js +5 -0
  2. package/lib/style/index.css +51 -0
  3. package/package.json +2 -10
  4. package/lib/common/components/billing-lines/NewNewBillingLines.d.ts +0 -15
  5. package/lib/common/components/billing-lines/NewNewBillingLines.js +0 -36
  6. package/lib/common/components/billing-lines/cwdwdw.d.ts +0 -1
  7. package/lib/common/components/billing-lines/cwdwdw.js +0 -14
  8. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +0 -0
  9. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +0 -109
  10. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +0 -0
  11. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +0 -110
  12. package/lib/unimaze-api-clients/src/mapi/api.d.ts +0 -6664
  13. package/lib/unimaze-api-clients/src/mapi/api.js +0 -4743
  14. package/lib/unimaze-api-clients/src/mapi/base.d.ts +0 -55
  15. package/lib/unimaze-api-clients/src/mapi/base.js +0 -84
  16. package/lib/unimaze-api-clients/src/mapi/configuration.d.ts +0 -63
  17. package/lib/unimaze-api-clients/src/mapi/configuration.js +0 -28
  18. package/lib/unimaze-api-clients/src/mapi/index.d.ts +0 -13
  19. package/lib/unimaze-api-clients/src/mapi/index.js +0 -30
  20. package/lib/unimaze-api-clients/src/rapi/api.d.ts +0 -5015
  21. package/lib/unimaze-api-clients/src/rapi/api.js +0 -5582
  22. package/lib/unimaze-api-clients/src/rapi/base.d.ts +0 -55
  23. package/lib/unimaze-api-clients/src/rapi/base.js +0 -84
  24. package/lib/unimaze-api-clients/src/rapi/configuration.d.ts +0 -63
  25. package/lib/unimaze-api-clients/src/rapi/configuration.js +0 -28
  26. package/lib/unimaze-api-clients/src/rapi/index.d.ts +0 -13
  27. package/lib/unimaze-api-clients/src/rapi/index.js +0 -30
  28. package/lib/unimaze-billing/src/common/components/CommonTranslations.d.ts +0 -74
  29. package/lib/unimaze-billing/src/common/components/CommonTranslations.js +0 -78
  30. package/lib/unimaze-billing/src/common/components/attachments/Attachment.d.ts +0 -20
  31. package/lib/unimaze-billing/src/common/components/attachments/Attachment.js +0 -164
  32. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.d.ts +0 -21
  33. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.js +0 -206
  34. package/lib/unimaze-billing/src/common/components/attachments/index.d.ts +0 -27
  35. package/lib/unimaze-billing/src/common/components/attachments/index.js +0 -214
  36. package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.d.ts +0 -17
  37. package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.js +0 -61
  38. package/lib/unimaze-billing/src/common/components/base-information/OrderReference.d.ts +0 -16
  39. package/lib/unimaze-billing/src/common/components/base-information/OrderReference.js +0 -58
  40. package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.d.ts +0 -14
  41. package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.js +0 -30
  42. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.d.ts +0 -53
  43. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.js +0 -328
  44. package/lib/unimaze-billing/src/common/components/base-information/index.d.ts +0 -77
  45. package/lib/unimaze-billing/src/common/components/base-information/index.js +0 -186
  46. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.d.ts +0 -14
  47. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.js +0 -151
  48. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.d.ts +0 -24
  49. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.js +0 -61
  50. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.d.ts +0 -13
  51. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.js +0 -133
  52. package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.d.ts +0 -20
  53. package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.js +0 -17
  54. package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.d.ts +0 -10
  55. package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.js +0 -16
  56. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.d.ts +0 -134
  57. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.js +0 -209
  58. package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.d.ts +0 -15
  59. package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.js +0 -36
  60. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.d.ts +0 -19
  61. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.js +0 -275
  62. package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.d.ts +0 -14
  63. package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.js +0 -15
  64. package/lib/unimaze-billing/src/common/components/billing-lines/index.d.ts +0 -49
  65. package/lib/unimaze-billing/src/common/components/billing-lines/index.js +0 -104
  66. package/lib/unimaze-billing/src/common/components/component-container/Content.d.ts +0 -7
  67. package/lib/unimaze-billing/src/common/components/component-container/Content.js +0 -13
  68. package/lib/unimaze-billing/src/common/components/component-container/Header.d.ts +0 -9
  69. package/lib/unimaze-billing/src/common/components/component-container/Header.js +0 -28
  70. package/lib/unimaze-billing/src/common/components/component-container/index.d.ts +0 -12
  71. package/lib/unimaze-billing/src/common/components/component-container/index.js +0 -22
  72. package/lib/unimaze-billing/src/common/components/customer/CostCenter.d.ts +0 -17
  73. package/lib/unimaze-billing/src/common/components/customer/CostCenter.js +0 -163
  74. package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.d.ts +0 -17
  75. package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.js +0 -53
  76. package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.d.ts +0 -7
  77. package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.js +0 -41
  78. package/lib/unimaze-billing/src/common/components/customer/index.d.ts +0 -26
  79. package/lib/unimaze-billing/src/common/components/customer/index.js +0 -166
  80. package/lib/unimaze-billing/src/common/components/date-picker/index.d.ts +0 -21
  81. package/lib/unimaze-billing/src/common/components/date-picker/index.js +0 -23
  82. package/lib/unimaze-billing/src/common/components/delivery-location/index.d.ts +0 -12
  83. package/lib/unimaze-billing/src/common/components/delivery-location/index.js +0 -89
  84. package/lib/unimaze-billing/src/common/components/editable-cell/index.d.ts +0 -0
  85. package/lib/unimaze-billing/src/common/components/editable-cell/index.js +0 -295
  86. package/lib/unimaze-billing/src/common/components/editable-row/index.d.ts +0 -5
  87. package/lib/unimaze-billing/src/common/components/editable-row/index.js +0 -59
  88. package/lib/unimaze-billing/src/common/components/form-item/index.d.ts +0 -35
  89. package/lib/unimaze-billing/src/common/components/form-item/index.js +0 -60
  90. package/lib/unimaze-billing/src/common/components/index.d.ts +0 -18
  91. package/lib/unimaze-billing/src/common/components/index.js +0 -42
  92. package/lib/unimaze-billing/src/common/components/input/index.d.ts +0 -23
  93. package/lib/unimaze-billing/src/common/components/input/index.js +0 -37
  94. package/lib/unimaze-billing/src/common/components/invoice/index.d.ts +0 -42
  95. package/lib/unimaze-billing/src/common/components/invoice/index.js +0 -59
  96. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +0 -14
  97. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +0 -75
  98. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.d.ts +0 -14
  99. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.js +0 -73
  100. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.d.ts +0 -12
  101. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.js +0 -104
  102. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.d.ts +0 -12
  103. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.js +0 -93
  104. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +0 -14
  105. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +0 -77
  106. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.d.ts +0 -14
  107. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.js +0 -58
  108. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.d.ts +0 -14
  109. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.js +0 -52
  110. package/lib/unimaze-billing/src/common/components/invoice-preview/index.d.ts +0 -102
  111. package/lib/unimaze-billing/src/common/components/invoice-preview/index.js +0 -196
  112. package/lib/unimaze-billing/src/common/components/locale-intl/index.d.ts +0 -0
  113. package/lib/unimaze-billing/src/common/components/locale-intl/index.js +0 -51
  114. package/lib/unimaze-billing/src/common/components/payment-method/index.d.ts +0 -76
  115. package/lib/unimaze-billing/src/common/components/payment-method/index.js +0 -356
  116. package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.d.ts +0 -8
  117. package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.js +0 -37
  118. package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.d.ts +0 -3
  119. package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.js +0 -17
  120. package/lib/unimaze-billing/src/common/components/submit-confirmation/index.d.ts +0 -8
  121. package/lib/unimaze-billing/src/common/components/submit-confirmation/index.js +0 -34
  122. package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.d.ts +0 -18
  123. package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.js +0 -159
  124. package/lib/unimaze-billing/src/common/components/supplier/index.d.ts +0 -94
  125. package/lib/unimaze-billing/src/common/components/supplier/index.js +0 -334
  126. package/lib/unimaze-billing/src/common/components/tooltip/index.d.ts +0 -7
  127. package/lib/unimaze-billing/src/common/components/tooltip/index.js +0 -15
  128. package/lib/unimaze-billing/src/common/components/welcome-modal/index.d.ts +0 -15
  129. package/lib/unimaze-billing/src/common/components/welcome-modal/index.js +0 -26
  130. package/lib/unimaze-billing/src/common/consts/formLayout.d.ts +0 -74
  131. package/lib/unimaze-billing/src/common/consts/formLayout.js +0 -45
  132. package/lib/unimaze-billing/src/common/consts/validationRules.d.ts +0 -6
  133. package/lib/unimaze-billing/src/common/consts/validationRules.js +0 -69
  134. package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.d.ts +0 -5
  135. package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.js +0 -8
  136. package/lib/unimaze-billing/src/common/enums/index.d.ts +0 -1
  137. package/lib/unimaze-billing/src/common/enums/index.js +0 -8
  138. package/lib/unimaze-billing/src/common/types/AppConfiguration.d.ts +0 -26
  139. package/lib/unimaze-billing/src/common/types/AppConfiguration.js +0 -2
  140. package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.d.ts +0 -10
  141. package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.js +0 -2
  142. package/lib/unimaze-billing/src/common/types/CommonProps.d.ts +0 -33
  143. package/lib/unimaze-billing/src/common/types/CommonProps.js +0 -2
  144. package/lib/unimaze-billing/src/common/types/DiscountType.d.ts +0 -1
  145. package/lib/unimaze-billing/src/common/types/DiscountType.js +0 -2
  146. package/lib/unimaze-billing/src/common/types/InvoiceFormFields.d.ts +0 -1
  147. package/lib/unimaze-billing/src/common/types/InvoiceFormFields.js +0 -2
  148. package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.d.ts +0 -27
  149. package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.js +0 -2
  150. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.d.ts +0 -83
  151. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.js +0 -393
  152. package/lib/unimaze-billing/src/common/types/SupplierInfo.d.ts +0 -11
  153. package/lib/unimaze-billing/src/common/types/SupplierInfo.js +0 -2
  154. package/lib/unimaze-billing/src/common/types/index.d.ts +0 -1
  155. package/lib/unimaze-billing/src/common/types/index.js +0 -17
  156. package/lib/unimaze-billing/src/create-credit-note/index.d.ts +0 -9
  157. package/lib/unimaze-billing/src/create-credit-note/index.js +0 -62
  158. package/lib/unimaze-billing/src/create-invoice/IntlLoader.d.ts +0 -11
  159. package/lib/unimaze-billing/src/create-invoice/IntlLoader.js +0 -116
  160. package/lib/unimaze-billing/src/create-invoice/index.d.ts +0 -82
  161. package/lib/unimaze-billing/src/create-invoice/index.js +0 -710
  162. package/lib/unimaze-billing/src/enums.d.ts +0 -14
  163. package/lib/unimaze-billing/src/enums.js +0 -18
  164. package/lib/unimaze-billing/src/index.d.ts +0 -4
  165. package/lib/unimaze-billing/src/index.js +0 -28
  166. package/lib/unimaze-billing/src/translations/locales/en.json +0 -183
  167. package/lib/unimaze-billing/src/translations/locales/is.json +0 -183
  168. package/lib/unimaze-billing/src/translations/locales.d.ts +0 -369
  169. package/lib/unimaze-billing/src/translations/locales.js +0 -11
  170. package/lib/unimaze-billing/src/utils/ApiUtility.d.ts +0 -29
  171. package/lib/unimaze-billing/src/utils/ApiUtility.js +0 -133
  172. package/lib/unimaze-billing/src/utils/BillingLineUtility.d.ts +0 -25
  173. package/lib/unimaze-billing/src/utils/BillingLineUtility.js +0 -190
  174. package/lib/unimaze-billing/src/utils/ConversionUtility.d.ts +0 -9
  175. package/lib/unimaze-billing/src/utils/ConversionUtility.js +0 -222
  176. package/lib/unimaze-billing/src/utils/FileUploadUtility.d.ts +0 -9
  177. package/lib/unimaze-billing/src/utils/FileUploadUtility.js +0 -45
  178. package/lib/unimaze-billing/src/utils/IntlUtility.d.ts +0 -6
  179. package/lib/unimaze-billing/src/utils/IntlUtility.js +0 -78
  180. package/lib/unimaze-billing/src/utils/LocationUtility.d.ts +0 -1
  181. package/lib/unimaze-billing/src/utils/LocationUtility.js +0 -81
  182. package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.d.ts +0 -7
  183. package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.js +0 -26
  184. package/lib/unimaze-billing/src/utils/RequirementsUtility.d.ts +0 -21
  185. package/lib/unimaze-billing/src/utils/RequirementsUtility.js +0 -237
  186. package/lib/unimaze-billing/src/utils/index.d.ts +0 -2
  187. package/lib/unimaze-billing/src/utils/index.js +0 -8
@@ -1,710 +0,0 @@
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
- var ReferenceIdentifierUtility_1 = require("../utils/ReferenceIdentifierUtility");
110
- exports.translationMessages = (0, react_intl_1.defineMessages)({
111
- createInvoice_addDocumentLineMsg: {
112
- id: "createInvoice_addDocumentLineMsg",
113
- defaultMessage: "Add at least one document line",
114
- },
115
- createInvoice_selectCustomerMsg: {
116
- id: "createInvoice_selectCustomerMsg",
117
- defaultMessage: "Customer must be selected",
118
- },
119
- createInvoice_successfullySubmittedInvoiceMsg: {
120
- id: "createInvoice_successfullySubmittedInvoiceMsg",
121
- defaultMessage: "Successfully submitted the invoice",
122
- },
123
- createInvoice_successfullyUploadedAttachmentMsg: {
124
- id: "createInvoice_successfullyUploadedAttachmentMsg",
125
- defaultMessage: "Successfully uploaded attachment {attachment}",
126
- },
127
- createInvoice_ErrorUploadedAttachmentMsg: {
128
- id: "createInvoice_ErrorUploadedAttachmentMsg",
129
- defaultMessage: "Error uploaded attachment {attachment}",
130
- },
131
- createInvoice_Submit: {
132
- id: "createInvoice_Submit",
133
- defaultMessage: "Submit",
134
- },
135
- createInvoice_SendCopy: {
136
- id: "createInvoice_SendCopy",
137
- defaultMessage: "Send a copy",
138
- },
139
- createInvoice_SendCopyTooltip: {
140
- id: "createInvoice_SendCopyTooltip",
141
- defaultMessage: "Sends you a PDF copy of the invoice",
142
- },
143
- createInvoice_SendCopyTooltipDisabled: {
144
- id: "createInvoice_SendCopyTooltipDisabled",
145
- defaultMessage: "You must fill in your email address to send yourself a copy",
146
- },
147
- createInvoice_customerStepTitle: {
148
- id: "createInvoice_customerStepTitle",
149
- defaultMessage: "Customer",
150
- },
151
- createInvoice_supplierStepTitle: {
152
- id: "createInvoice_supplierStepTitle",
153
- defaultMessage: "Supplier",
154
- },
155
- createInvoice_invoiceStepTitle: {
156
- id: "createInvoice_invoiceStepTitle",
157
- defaultMessage: "Invoice",
158
- },
159
- createInvoice_paymentStepTitle: {
160
- id: "createInvoice_paymentStepTitle",
161
- defaultMessage: "Payment",
162
- },
163
- createInvoice_nextStep: {
164
- id: "createInvoice_nextStep",
165
- defaultMessage: "Next step",
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
- },
175
- });
176
- /**
177
- * Component for creating a form for creating an invoice and submitting it to the MAPI transaction services
178
- *
179
- * @component
180
- */
181
- var CreateInvoiceConstructor = function (props) {
182
- var _a;
183
- var recaptchaRef = react_1.default.useRef(null);
184
- var intl = props.intl;
185
- var form = antd_1.Form.useForm()[0];
186
- var width = (0, react_use_1.useWindowSize)().width;
187
- var _b = (0, react_1.useState)(false), isMobile = _b[0], setIsMobile = _b[1];
188
- (0, react_1.useEffect)(function () {
189
- if (width < 768) {
190
- setIsMobile(true);
191
- }
192
- else {
193
- setIsMobile(false);
194
- }
195
- }, [width]);
196
- var _c = (0, react_1.useState)(false), submitting = _c[0], setSubmitting = _c[1];
197
- var _d = (0, react_1.useState)(true), isSubmitDisabled = _d[0], setIsSubmitDisabled = _d[1];
198
- var _e = (0, react_1.useState)(false), isBackButtonVisible = _e[0], setIsBackButtonVisible = _e[1];
199
- var _f = (0, react_1.useState)(true), isNextStepDisabled = _f[0], setIsNextStepDisabled = _f[1];
200
- var _g = (0, react_1.useState)(false), isNextStepVisible = _g[0], setIsNextStepVisible = _g[1];
201
- var _h = (0, react_1.useState)(0), activeStep = _h[0], setActiveStep = _h[1];
202
- var _j = (0, react_1.useState)(true), isWelcomeModalOpen = _j[0], setIsWelcomeModalOpen = _j[1];
203
- var _k = (0, react_1.useState)(""), supplierEmail = _k[0], setSupplierEmail = _k[1];
204
- var _l = (0, react_1.useState)(false), isSaveFieldValuesSelected = _l[0], setIsSaveFieldValuesSelected = _l[1];
205
- var _m = (0, react_1.useState)((0, ConversionUtility_1.profileOutputToPartyMetadata)(props.customers[0])), chosenCustomer = _m[0], setChosenCustomer = _m[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];
215
- var getDefaultPaymentType = function (defaultPaymentType) {
216
- return defaultPaymentType || mapi_1.PaymentMeansType.DomesticClaim;
217
- };
218
- var _x = (0, react_1.useState)({
219
- invoice: {
220
- supplier: {
221
- address: {
222
- countryCode: "IS",
223
- },
224
- },
225
- customer: __assign(__assign({}, chosenCustomer), { address: {
226
- countryCode: "IS",
227
- } }),
228
- paymentMeans: {
229
- type: getDefaultPaymentType(props.defaultPaymentType),
230
- },
231
- referenceIdentifiers: [{ code: undefined }],
232
- singleReferenceIdentifier: {
233
- code: undefined,
234
- value: undefined,
235
- },
236
- invoiceLines: [{}],
237
- attachments: {
238
- file1: { file: undefined, description: undefined },
239
- file2: { file: undefined, description: undefined },
240
- file3: { file: undefined, description: undefined },
241
- },
242
- issueDate: (0, dayjs_1.default)(),
243
- },
244
- }), formData = _x[0], setFormData = _x[1];
245
- var validateFieldsForNextStep = function (fieldPaths, validateOnly) { return __awaiter(void 0, void 0, void 0, function () {
246
- var referenceIdentifiersDefinitions, isSingleReferenceIdentifier, isMultipleReferenceIdentifier, someRequiredFieldsEmpty;
247
- return __generator(this, function (_a) {
248
- switch (_a.label) {
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 () {
260
- var _a;
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
- console.log("Uso za multiple")
269
- setIsNextStepDisabled(true);
270
- setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
271
- }
272
- else if (activeStep === 2 && isSingleReferenceIdentifier && referenceIdentifierIsMandatory && !form.getFieldValue(["invoice", "singleReferenceIdentifier", "value"])) {
273
- console.log("uso za single")
274
- setIsNextStepDisabled(true);
275
- setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierRequired));
276
- }
277
- else if (activeStep === 2 && referenceIdentifierValidateStatus === "error") {
278
- console.log("uso za error")
279
- setIsNextStepDisabled(true);
280
- setMissingRequiredDataTooltip(intl.formatMessage(exports.translationMessages.createInvoice_validationErrorObjectIdentifierNotValid));
281
- }
282
- else {
283
- setIsNextStepDisabled(false);
284
- setMissingRequiredDataTooltip(undefined);
285
- }
286
- })
287
- .catch(function (error) {
288
- var _a;
289
- var requiredFields = [];
290
- (_a = error === null || error === void 0 ? void 0 : error.errorFields) === null || _a === void 0 ? void 0 : _a.map(function (errorField) {
291
- var _a;
292
- requiredFields.push(errorField.name[((_a = errorField === null || errorField === void 0 ? void 0 : errorField.name) === null || _a === void 0 ? void 0 : _a.length) - 1]);
293
- });
294
- if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.length) > 0) {
295
- var names = getFieldNames(requiredFields);
296
- setMissingRequiredDataTooltip((0, RequirementsUtility_1.getRequiredTooltipMessage)(props.intl.formatMessage(CommonTranslations_1.commonTranslationMessages.missingRequiredData), names));
297
- }
298
- setIsNextStepDisabled(true);
299
- })];
300
- case 1:
301
- _a.sent();
302
- return [2 /*return*/];
303
- }
304
- });
305
- }); };
306
- var getFieldNames = function (keys) {
307
- return keys === null || keys === void 0 ? void 0 : keys.map(function (key) {
308
- switch (key) {
309
- case "identifier":
310
- return props.intl.formatMessage(supplier_1.translationMessages.supplier_identifier);
311
- case "name":
312
- return props.intl.formatMessage(supplier_1.translationMessages.supplier_name);
313
- case "streetNameAndNumber":
314
- return props.intl.formatMessage(supplier_1.translationMessages.supplier_address_streetNameAndNumber);
315
- case "postalZone":
316
- return props.intl.formatMessage(supplier_1.translationMessages.supplier_address_zip_postalCode);
317
- case "vatNumber":
318
- return props.intl.formatMessage(supplier_1.translationMessages.supplier_vatNumber);
319
- case "invoiceNo":
320
- return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_invoiceNo);
321
- case "issueDate":
322
- return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_issueDate);
323
- case "dueDate":
324
- return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_dueDate);
325
- case "buyerReference":
326
- return props.intl.formatMessage(base_information_1.translationMessages.baseInformation_buyerReferenceLabel);
327
- case "accountTypeNumber":
328
- return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountType);
329
- case "accountNumber":
330
- return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountNo);
331
- case "bankNumber":
332
- return props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_icelandicClaim_bankNo);
333
- case "value": // singleReferenceIdentifier
334
- return intl.formatMessage(base_information_1.translationMessages.baseInformation_objectIdentifier);
335
- case "documentNo":
336
- return intl.formatMessage(base_information_1.translationMessages.baseInformation_projectReference);
337
- default:
338
- return "";
339
- }
340
- });
341
- };
342
- var saveFieldValuesToLocalStorage = function () {
343
- var flatFields = form.getFieldsValue();
344
- delete flatFields.attachments;
345
- delete flatFields.invoice.invoiceNo;
346
- delete flatFields.invoice.invoiceLines;
347
- delete flatFields.invoice.dueDate;
348
- delete flatFields.invoice.issueDate;
349
- delete flatFields.invoice.buyerReference;
350
- delete flatFields.invoice.referenceIdentifiers;
351
- delete flatFields.invoice.notes;
352
- localStorage.setItem("formData", JSON.stringify(flatFields));
353
- };
354
- var handlePrevStep = function () {
355
- if (activeStep === 3 && removedInvoiceLine) {
356
- var currentInvoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
357
- form.setFieldsValue({
358
- invoice: {
359
- invoiceLines: __spreadArray(__spreadArray([], currentInvoiceLines, true), [removedInvoiceLine], false),
360
- },
361
- });
362
- }
363
- setActiveStep(activeStep - 1);
364
- };
365
- var handleNextStep = function () {
366
- if (activeStep === 2) {
367
- var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
368
- var _removedInvoiceLine = invoiceLines[invoiceLines.length - 1];
369
- setRemovedInvoiceLine(_removedInvoiceLine);
370
- form.setFieldsValue({
371
- invoice: {
372
- invoiceLines: invoiceLines.slice(0, -1),
373
- },
374
- });
375
- }
376
- setIsNextStepDisabled(true);
377
- setActiveStep(activeStep + 1);
378
- if (isSaveFieldValuesSelected) {
379
- saveFieldValuesToLocalStorage();
380
- }
381
- };
382
- (0, react_1.useEffect)(function () {
383
- var savedValues = localStorage.getItem("formData");
384
- var savedValuesObject = savedValues ? JSON.parse(savedValues) : null;
385
- if (savedValuesObject)
386
- form.setFieldsValue(savedValuesObject);
387
- }, []);
388
- (0, react_1.useEffect)(function () {
389
- setSupplierEmail(form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"]));
390
- }, [form.getFieldValue(["invoice", "supplier", "contact", "electronicMail"])]);
391
- (0, react_1.useEffect)(function () {
392
- setOutsideVatScope(form.getFieldValue(["outsideVatScope"]));
393
- }, [form.getFieldValue(["outsideVatScope"])]);
394
- (0, react_1.useEffect)(function () {
395
- setIsSubmitDisabled(!captchaVerified);
396
- }, [captchaVerified]);
397
- (0, react_1.useEffect)(function () {
398
- setIsBackButtonVisible(activeStep > 0 && activeStep <= items.length);
399
- setIsNextStepVisible(activeStep < items.length);
400
- }, [activeStep]);
401
- (0, react_1.useEffect)(function () {
402
- if (outsideVatScope) {
403
- form.resetFields([["invoice", "supplier", "vatNumber"]]);
404
- }
405
- var invoiceLines = form.getFieldValue(["invoice", "invoiceLines"]);
406
- if (outsideVatScope) {
407
- invoiceLines = invoiceLines.map(function (invoiceLine) {
408
- invoiceLine.taxCategoryType = mapi_1.TaxCategoryTypeEnum.OutsideTaxScope;
409
- return invoiceLine;
410
- });
411
- }
412
- else {
413
- invoiceLines = invoiceLines.map(function (invoiceLine) {
414
- invoiceLine.taxCategoryType = mapi_1.TaxCategoryTypeEnum.StandardRated;
415
- return invoiceLine;
416
- });
417
- }
418
- form.setFieldsValue({
419
- invoice: {
420
- invoiceLines: invoiceLines,
421
- },
422
- });
423
- }, [outsideVatScope]);
424
- (0, react_1.useEffect)(function () {
425
- if (supplierEmail) {
426
- form.validateFields([["invoice", "supplier", "contact", "electronicMail"]])
427
- .then(function () {
428
- setSendCopyDisabled(!supplierEmail);
429
- setSendCopy(true);
430
- })
431
- .catch(function () {
432
- setSendCopyDisabled(true);
433
- setSendCopy(false);
434
- });
435
- }
436
- else {
437
- setSendCopy(false);
438
- setSendCopyDisabled(true);
439
- }
440
- }, [supplierEmail]);
441
- var handleSubmit = function (values) {
442
- var _a, _b, _c, _d, _e, _f;
443
- setSubmitting(true);
444
- if (referenceIdentifierValidateStatus !== "" && referenceIdentifierValidateStatus !== "success") {
445
- form.scrollToField(["invoice", "referenceIdentifiers", 0, "value"]);
446
- setSubmitting(false);
447
- return;
448
- }
449
- var attachments = [
450
- ((_a = values.attachments) === null || _a === void 0 ? void 0 : _a.file1) && ((_b = values.attachments) === null || _b === void 0 ? void 0 : _b.file1),
451
- ((_c = values.attachments) === null || _c === void 0 ? void 0 : _c.file2) && ((_d = values.attachments) === null || _d === void 0 ? void 0 : _d.file2),
452
- ((_e = values.attachments) === null || _e === void 0 ? void 0 : _e.file3) && ((_f = values.attachments) === null || _f === void 0 ? void 0 : _f.file3),
453
- ];
454
- // Clear the array of undefined
455
- attachments = attachments.filter(function (attachment) { return attachment && attachment.file; });
456
- if (!chosenCustomer) {
457
- antd_1.message.error(intl.formatMessage(exports.translationMessages.createInvoice_selectCustomerMsg));
458
- // TODO: handle this better?
459
- setSubmitting(false);
460
- return;
461
- }
462
- var services = sendCopy
463
- ? ["urn:services:dispatcher:mail.pdf?email=".concat(supplierEmail, "#$#lang=").concat(props.language)]
464
- : undefined;
465
- var invoiceMetadataInput = (0, utils_1.convertToInvoiceMetadataInput)(values, (0, BillingLineUtility_1.billingLinesFieldsMetadata)(form), (0, paymentMethodForConversion_1.PaymentMethodFormData)(values), chosenCustomer);
466
- var createSubmitInvoice = {
467
- invoiceMetadataInput: invoiceMetadataInput,
468
- more: attachments.length > 0,
469
- messageId: (0, uuid_1.v4)(),
470
- processingMode: mapi_1.TransactionProcessingMode.Device,
471
- services: services,
472
- };
473
- (0, utils_1.submitInvoice)(createSubmitInvoice, props.mapiBaseUrl, chosenCustomerApiKey, "submitInvoice", props.language)
474
- .then(function (resp) {
475
- var _a;
476
- antd_1.message.success(intl.formatMessage(exports.translationMessages.createInvoice_successfullySubmittedInvoiceMsg));
477
- if (resp.status === 200) {
478
- var response = resp.data;
479
- (0, ApiUtility_1.submitAttachmentIfAnyLeft)((_a = response === null || response === void 0 ? void 0 : response.uniqueId) !== null && _a !== void 0 ? _a : "", attachments, props.mapiBaseUrl, chosenCustomerApiKey, intl);
480
- }
481
- else {
482
- antd_1.message.error("Created invoice had validation errors");
483
- }
484
- setActiveStep(activeStep + 1);
485
- setSubmitting(false);
486
- form.resetFields();
487
- form.setFields([
488
- {
489
- name: ["invoice", "invoiceLines"],
490
- value: [{}],
491
- },
492
- {
493
- name: ["invoice", "supplier"],
494
- value: values.invoice.supplier,
495
- },
496
- {
497
- name: ["outsideVatScope"],
498
- value: !values.invoice.supplier.vatNumber,
499
- },
500
- {
501
- name: ["attachments"],
502
- value: {
503
- file1: { file: undefined, description: undefined },
504
- file2: { file: undefined, description: undefined },
505
- file3: { file: undefined, description: undefined },
506
- },
507
- },
508
- ]);
509
- // Clear the billing line dataSource
510
- setChosenCustomer((0, ConversionUtility_1.profileOutputToPartyMetadata)(props.customers[0]));
511
- setChosenCustomerApiKey(props.customers[0].apiKey);
512
- // setBillingLinesDataSource([{...initialBillingLineData, key: 0}])
513
- // setBillingLinesEditableIndex(0);
514
- // TODO: remove this as soon as possible
515
- // location.reload();
516
- })
517
- .catch(function (error) {
518
- setSubmitting(false);
519
- if (error.response) {
520
- // The request was made and the server responded with a status code
521
- // that falls out of the range of 2xx
522
- if (error.response.data) {
523
- var errorData = error.response.data;
524
- if (errorData.hasOwnProperty("message")) {
525
- antd_1.message.error(errorData.message);
526
- }
527
- else {
528
- for (var errorMessageKey in errorData) {
529
- if (errorData.hasOwnProperty(errorMessageKey)) {
530
- antd_1.message.error(react_1.default.createElement(react_1.default.Fragment, null,
531
- react_1.default.createElement("strong", null, errorMessageKey),
532
- react_1.default.createElement("br", null),
533
- errorData[errorMessageKey]));
534
- }
535
- }
536
- }
537
- }
538
- }
539
- else if (error.request) {
540
- // The request was made but no response was received
541
- // `error.request` is an instance of XMLHttpRequest in the browser and an instance of
542
- // http.ClientRequest in node.js
543
- var request = error.request;
544
- antd_1.message.error(request.responseText);
545
- }
546
- else {
547
- // Something happened in setting up the request that triggered an Error
548
- antd_1.message.error(error.message);
549
- }
550
- });
551
- if (recaptchaRef) {
552
- if (recaptchaRef.current) {
553
- recaptchaRef.current.reset();
554
- }
555
- }
556
- setIsSubmitDisabled(true);
557
- };
558
- var getReceiverRequirements = function () {
559
- var _a, _b, _c, _d, _e;
560
- if (chosenCustomer) {
561
- var savedFieldValues = localStorage.getItem("formData");
562
- var savedFieldValuesObject = savedFieldValues ? JSON.parse(savedFieldValues) : null;
563
- var savedChosenCustomer = (_a = savedFieldValuesObject === null || savedFieldValuesObject === void 0 ? void 0 : savedFieldValuesObject.invoice) === null || _a === void 0 ? void 0 : _a.customer;
564
- if (chosenCustomer.name === (savedChosenCustomer === null || savedChosenCustomer === void 0 ? void 0 : savedChosenCustomer.name)) {
565
- var savedValues = localStorage.getItem("formData");
566
- var savedValuesObject = savedValues ? JSON.parse(savedValues) : null;
567
- form.setFieldsValue({
568
- invoice: {
569
- referenceIdentifiers: (_b = savedValuesObject === null || savedValuesObject === void 0 ? void 0 : savedValuesObject.invoice) === null || _b === void 0 ? void 0 : _b.referenceIdentifiers,
570
- customer: {
571
- 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,
572
- },
573
- paymentMeans: (_e = savedValuesObject === null || savedValuesObject === void 0 ? void 0 : savedValuesObject.invoice) === null || _e === void 0 ? void 0 : _e.paymentMeans,
574
- },
575
- });
576
- }
577
- else {
578
- form.resetFields([
579
- ["invoice", "referenceIdentifiers"],
580
- ["invoice", "customer", "locationIdentifier"],
581
- ["invoice", "paymentMeans"],
582
- ]);
583
- }
584
- props.getReceiverRequirements(props.rapiBaseUrl, chosenCustomer.identifier);
585
- }
586
- };
587
- (0, react_1.useEffect)(function () {
588
- getReceiverRequirements();
589
- }, [chosenCustomer]);
590
- var defaultCustomer;
591
- if (props.customers.length === 1 && !chosenCustomer) {
592
- defaultCustomer = props.customers[0];
593
- setChosenCustomer({
594
- contact: {
595
- electronicMail: defaultCustomer.email,
596
- telephone: defaultCustomer.phoneNumber,
597
- },
598
- address: {
599
- countryCode: defaultCustomer.country,
600
- city: defaultCustomer.participantLegalAddressCity,
601
- postalZone: defaultCustomer.participantLegalAddressPostalCode,
602
- streetNameAndNumber: defaultCustomer.participantLegalAddressStreet,
603
- },
604
- identifier: defaultCustomer.participantLegalIsoIdentifier,
605
- name: defaultCustomer.name,
606
- });
607
- setChosenCustomerApiKey(props.customers[0].apiKey);
608
- }
609
- var _y = (0, react_1.useState)(undefined), billingLinesMetadata = _y[0], setBillingLinesMetadata = _y[1];
610
- var getBillingLines = function (changedValues, allValues) {
611
- var invoiceLines = allValues.invoice.invoiceLines;
612
- if (invoiceLines) {
613
- var mappedBillingLines = invoiceLines.map(function (invoiceLine) {
614
- if (invoiceLine) {
615
- return {
616
- itemNo: invoiceLine.itemNo ? invoiceLine.itemNo : undefined,
617
- name: invoiceLine.name ? invoiceLine.name : undefined,
618
- quantity: invoiceLine.quantity ? invoiceLine.quantity : undefined,
619
- unitPriceAmount: invoiceLine.unitPriceAmount ? invoiceLine.unitPriceAmount : undefined,
620
- unitOfMeasure: {
621
- unit: invoiceLine.unitOfMeasure && invoiceLine.unitOfMeasure.unit
622
- ? mapi_1.Units[invoiceLine.unitOfMeasure.unit]
623
- : undefined,
624
- },
625
- taxCategoryType: invoiceLine.taxCategoryType
626
- ? mapi_1.TaxCategoryTypeEnum[invoiceLine.taxCategoryType]
627
- : undefined,
628
- discountValue: invoiceLine.discountValue ? invoiceLine.discountValue : undefined,
629
- };
630
- }
631
- else {
632
- return {};
633
- }
634
- });
635
- setBillingLinesMetadata(mappedBillingLines);
636
- }
637
- };
638
- var items = [
639
- {
640
- title: intl.formatMessage(exports.translationMessages.createInvoice_customerStepTitle),
641
- },
642
- {
643
- title: intl.formatMessage(exports.translationMessages.createInvoice_supplierStepTitle),
644
- },
645
- {
646
- title: intl.formatMessage(exports.translationMessages.createInvoice_invoiceStepTitle),
647
- },
648
- {
649
- title: intl.formatMessage(exports.translationMessages.createInvoice_paymentStepTitle),
650
- },
651
- ];
652
- return (react_1.default.createElement(antd_1.Spin, { spinning: submitting },
653
- react_1.default.createElement(antd_1.Flex, { vertical: true, gap: "middle", style: { alignItems: "center", marginBottom: "50px" } },
654
- 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 }))),
655
- react_1.default.createElement(antd_1.Layout.Content, null,
656
- react_1.default.createElement(antd_1.Flex, { style: { width: "100vw", padding: isMobile ? "0 20px" : 0 } },
657
- react_1.default.createElement(antd_1.Form, __assign({ style: { width: "100%" }, size: "large", onFieldsChange: function () {
658
- if (captchaVerified && recaptchaRef) {
659
- if (recaptchaRef.current) {
660
- setCaptchaVerified(false);
661
- recaptchaRef.current.reset();
662
- }
663
- }
664
- }, scrollToFirstError: true, onValuesChange: function (changedValues, allValues) {
665
- getBillingLines(changedValues, allValues);
666
- } }, formLayout_1.formItemLayout, { form: form, onFinish: handleSubmit, onFinishFailed: function (error) {
667
- // tslint:disable-next-line:no-console
668
- console.log(error);
669
- }, initialValues: formData }),
670
- react_1.default.createElement(antd_1.Form.Item, { name: ["invoice", "currencyCode"], hidden: true }),
671
- react_1.default.createElement(antd_1.Flex, { gap: "middle", vertical: true },
672
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 0 ? { display: "none" } : {} },
673
- 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 () {
674
- return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
675
- }, isActiveStep: activeStep === 0 })),
676
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 1 ? { display: "none" } : {} },
677
- 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 () {
678
- return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
679
- }, isActiveStep: activeStep === 1 }),
680
- " "),
681
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 2 ? { display: "none" } : {} },
682
- 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 () {
683
- return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
684
- }, isActiveStep: activeStep === 2, setReferenceIdentifierIsMandatory: setReferenceIdentifierIsMandatory })),
685
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== 3 ? { display: "none" } : {} },
686
- react_1.default.createElement(components_1.PaymentMethod, { receiverRequirements: props.receiverRequirements, formInstance: form, validateFields: validateFieldsForNextStep, isSaveFieldValuesSelected: isSaveFieldValuesSelected, onSaveFieldValuesChange: function () {
687
- return setIsSaveFieldValuesSelected(!isSaveFieldValuesSelected);
688
- }, isActiveStep: activeStep === 3 })),
689
- activeStep === items.length && (react_1.default.createElement(components_1.InvoicePreview, { recieverRequirements: props.receiverRequirements, form: form, chosenCustomer: chosenCustomer })),
690
- react_1.default.createElement(antd_1.Flex, { vertical: true, style: activeStep !== items.length ? { display: "none" } : {} },
691
- react_1.default.createElement(antd_1.Row, { style: { width: "100%", padding: "8px" }, justify: "center" },
692
- react_1.default.createElement(antd_1.Col, null,
693
- react_1.default.createElement(reaptcha_1.default, { sitekey: "6LdMUdEZAAAAAG--2WEyu8CIRVlv6CzdZIwaQ-zt", ref: recaptchaRef, onVerify: function (response) {
694
- setCaptchaVerified(true);
695
- }, hl: props.language, onExpire: function () { return setCaptchaVerified(false); }, onError: function () { return setCaptchaVerified(false); } })))),
696
- activeStep === 5 && react_1.default.createElement(components_1.SubmitConfirmation, null),
697
- react_1.default.createElement(antd_1.Flex, { justify: "center" },
698
- react_1.default.createElement(antd_1.Flex, { gap: isMobile ? "middle" : 60, justify: "end", style: { width: "100%", maxWidth: "900px" } },
699
- isBackButtonVisible && (react_1.default.createElement(antd_1.Button, { onClick: handlePrevStep, size: "large", block: true },
700
- react_1.default.createElement(icons_1.ArrowLeftOutlined, null), (_a = items[activeStep - 1]) === null || _a === void 0 ? void 0 :
701
- _a.title)),
702
- isNextStepVisible ? (react_1.default.createElement(antd_1.Tooltip, { title: missingRequiredDataTooltip },
703
- react_1.default.createElement(antd_1.Button, { onClick: handleNextStep, type: "primary", size: "large", style: { maxWidth: "50%" }, disabled: isNextStepDisabled, block: true },
704
- intl.formatMessage(exports.translationMessages.createInvoice_nextStep),
705
- 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 },
706
- intl.formatMessage(exports.translationMessages.createInvoice_Submit),
707
- react_1.default.createElement(icons_1.ArrowRightOutlined, null))))))))))),
708
- 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 }))));
709
- };
710
- exports.default = (0, react_intl_1.injectIntl)(CreateInvoiceConstructor);