@unimaze/billing 0.21.52 → 0.21.54

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 (186) hide show
  1. package/lib/create-invoice/index.js +13 -5
  2. package/package.json +2 -10
  3. package/lib/common/components/billing-lines/NewNewBillingLines.d.ts +0 -15
  4. package/lib/common/components/billing-lines/NewNewBillingLines.js +0 -36
  5. package/lib/common/components/billing-lines/cwdwdw.d.ts +0 -1
  6. package/lib/common/components/billing-lines/cwdwdw.js +0 -14
  7. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +0 -0
  8. package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +0 -109
  9. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +0 -0
  10. package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +0 -110
  11. package/lib/unimaze-api-clients/src/mapi/api.d.ts +0 -6664
  12. package/lib/unimaze-api-clients/src/mapi/api.js +0 -4743
  13. package/lib/unimaze-api-clients/src/mapi/base.d.ts +0 -55
  14. package/lib/unimaze-api-clients/src/mapi/base.js +0 -84
  15. package/lib/unimaze-api-clients/src/mapi/configuration.d.ts +0 -63
  16. package/lib/unimaze-api-clients/src/mapi/configuration.js +0 -28
  17. package/lib/unimaze-api-clients/src/mapi/index.d.ts +0 -13
  18. package/lib/unimaze-api-clients/src/mapi/index.js +0 -30
  19. package/lib/unimaze-api-clients/src/rapi/api.d.ts +0 -5015
  20. package/lib/unimaze-api-clients/src/rapi/api.js +0 -5582
  21. package/lib/unimaze-api-clients/src/rapi/base.d.ts +0 -55
  22. package/lib/unimaze-api-clients/src/rapi/base.js +0 -84
  23. package/lib/unimaze-api-clients/src/rapi/configuration.d.ts +0 -63
  24. package/lib/unimaze-api-clients/src/rapi/configuration.js +0 -28
  25. package/lib/unimaze-api-clients/src/rapi/index.d.ts +0 -13
  26. package/lib/unimaze-api-clients/src/rapi/index.js +0 -30
  27. package/lib/unimaze-billing/src/common/components/CommonTranslations.d.ts +0 -74
  28. package/lib/unimaze-billing/src/common/components/CommonTranslations.js +0 -78
  29. package/lib/unimaze-billing/src/common/components/attachments/Attachment.d.ts +0 -20
  30. package/lib/unimaze-billing/src/common/components/attachments/Attachment.js +0 -164
  31. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.d.ts +0 -21
  32. package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.js +0 -206
  33. package/lib/unimaze-billing/src/common/components/attachments/index.d.ts +0 -27
  34. package/lib/unimaze-billing/src/common/components/attachments/index.js +0 -214
  35. package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.d.ts +0 -17
  36. package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.js +0 -61
  37. package/lib/unimaze-billing/src/common/components/base-information/OrderReference.d.ts +0 -16
  38. package/lib/unimaze-billing/src/common/components/base-information/OrderReference.js +0 -58
  39. package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.d.ts +0 -14
  40. package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.js +0 -30
  41. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.d.ts +0 -53
  42. package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.js +0 -328
  43. package/lib/unimaze-billing/src/common/components/base-information/index.d.ts +0 -77
  44. package/lib/unimaze-billing/src/common/components/base-information/index.js +0 -186
  45. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.d.ts +0 -14
  46. package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.js +0 -151
  47. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.d.ts +0 -24
  48. package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.js +0 -61
  49. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.d.ts +0 -13
  50. package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.js +0 -133
  51. package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.d.ts +0 -20
  52. package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.js +0 -17
  53. package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.d.ts +0 -10
  54. package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.js +0 -16
  55. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.d.ts +0 -134
  56. package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.js +0 -209
  57. package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.d.ts +0 -15
  58. package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.js +0 -36
  59. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.d.ts +0 -19
  60. package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.js +0 -275
  61. package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.d.ts +0 -14
  62. package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.js +0 -15
  63. package/lib/unimaze-billing/src/common/components/billing-lines/index.d.ts +0 -49
  64. package/lib/unimaze-billing/src/common/components/billing-lines/index.js +0 -104
  65. package/lib/unimaze-billing/src/common/components/component-container/Content.d.ts +0 -7
  66. package/lib/unimaze-billing/src/common/components/component-container/Content.js +0 -13
  67. package/lib/unimaze-billing/src/common/components/component-container/Header.d.ts +0 -9
  68. package/lib/unimaze-billing/src/common/components/component-container/Header.js +0 -28
  69. package/lib/unimaze-billing/src/common/components/component-container/index.d.ts +0 -12
  70. package/lib/unimaze-billing/src/common/components/component-container/index.js +0 -22
  71. package/lib/unimaze-billing/src/common/components/customer/CostCenter.d.ts +0 -17
  72. package/lib/unimaze-billing/src/common/components/customer/CostCenter.js +0 -163
  73. package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.d.ts +0 -17
  74. package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.js +0 -53
  75. package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.d.ts +0 -7
  76. package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.js +0 -41
  77. package/lib/unimaze-billing/src/common/components/customer/index.d.ts +0 -26
  78. package/lib/unimaze-billing/src/common/components/customer/index.js +0 -166
  79. package/lib/unimaze-billing/src/common/components/date-picker/index.d.ts +0 -21
  80. package/lib/unimaze-billing/src/common/components/date-picker/index.js +0 -23
  81. package/lib/unimaze-billing/src/common/components/delivery-location/index.d.ts +0 -12
  82. package/lib/unimaze-billing/src/common/components/delivery-location/index.js +0 -89
  83. package/lib/unimaze-billing/src/common/components/editable-cell/index.d.ts +0 -0
  84. package/lib/unimaze-billing/src/common/components/editable-cell/index.js +0 -295
  85. package/lib/unimaze-billing/src/common/components/editable-row/index.d.ts +0 -5
  86. package/lib/unimaze-billing/src/common/components/editable-row/index.js +0 -59
  87. package/lib/unimaze-billing/src/common/components/form-item/index.d.ts +0 -35
  88. package/lib/unimaze-billing/src/common/components/form-item/index.js +0 -60
  89. package/lib/unimaze-billing/src/common/components/index.d.ts +0 -18
  90. package/lib/unimaze-billing/src/common/components/index.js +0 -42
  91. package/lib/unimaze-billing/src/common/components/input/index.d.ts +0 -23
  92. package/lib/unimaze-billing/src/common/components/input/index.js +0 -37
  93. package/lib/unimaze-billing/src/common/components/invoice/index.d.ts +0 -42
  94. package/lib/unimaze-billing/src/common/components/invoice/index.js +0 -59
  95. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +0 -14
  96. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +0 -75
  97. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.d.ts +0 -14
  98. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.js +0 -73
  99. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.d.ts +0 -12
  100. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.js +0 -104
  101. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.d.ts +0 -12
  102. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.js +0 -93
  103. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +0 -14
  104. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +0 -77
  105. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.d.ts +0 -14
  106. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.js +0 -58
  107. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.d.ts +0 -14
  108. package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.js +0 -52
  109. package/lib/unimaze-billing/src/common/components/invoice-preview/index.d.ts +0 -102
  110. package/lib/unimaze-billing/src/common/components/invoice-preview/index.js +0 -196
  111. package/lib/unimaze-billing/src/common/components/locale-intl/index.d.ts +0 -0
  112. package/lib/unimaze-billing/src/common/components/locale-intl/index.js +0 -51
  113. package/lib/unimaze-billing/src/common/components/payment-method/index.d.ts +0 -76
  114. package/lib/unimaze-billing/src/common/components/payment-method/index.js +0 -356
  115. package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.d.ts +0 -8
  116. package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.js +0 -37
  117. package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.d.ts +0 -3
  118. package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.js +0 -17
  119. package/lib/unimaze-billing/src/common/components/submit-confirmation/index.d.ts +0 -8
  120. package/lib/unimaze-billing/src/common/components/submit-confirmation/index.js +0 -34
  121. package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.d.ts +0 -18
  122. package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.js +0 -159
  123. package/lib/unimaze-billing/src/common/components/supplier/index.d.ts +0 -94
  124. package/lib/unimaze-billing/src/common/components/supplier/index.js +0 -334
  125. package/lib/unimaze-billing/src/common/components/tooltip/index.d.ts +0 -7
  126. package/lib/unimaze-billing/src/common/components/tooltip/index.js +0 -15
  127. package/lib/unimaze-billing/src/common/components/welcome-modal/index.d.ts +0 -15
  128. package/lib/unimaze-billing/src/common/components/welcome-modal/index.js +0 -26
  129. package/lib/unimaze-billing/src/common/consts/formLayout.d.ts +0 -74
  130. package/lib/unimaze-billing/src/common/consts/formLayout.js +0 -45
  131. package/lib/unimaze-billing/src/common/consts/validationRules.d.ts +0 -6
  132. package/lib/unimaze-billing/src/common/consts/validationRules.js +0 -69
  133. package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.d.ts +0 -5
  134. package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.js +0 -8
  135. package/lib/unimaze-billing/src/common/enums/index.d.ts +0 -1
  136. package/lib/unimaze-billing/src/common/enums/index.js +0 -8
  137. package/lib/unimaze-billing/src/common/types/AppConfiguration.d.ts +0 -26
  138. package/lib/unimaze-billing/src/common/types/AppConfiguration.js +0 -2
  139. package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.d.ts +0 -10
  140. package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.js +0 -2
  141. package/lib/unimaze-billing/src/common/types/CommonProps.d.ts +0 -33
  142. package/lib/unimaze-billing/src/common/types/CommonProps.js +0 -2
  143. package/lib/unimaze-billing/src/common/types/DiscountType.d.ts +0 -1
  144. package/lib/unimaze-billing/src/common/types/DiscountType.js +0 -2
  145. package/lib/unimaze-billing/src/common/types/InvoiceFormFields.d.ts +0 -1
  146. package/lib/unimaze-billing/src/common/types/InvoiceFormFields.js +0 -2
  147. package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.d.ts +0 -27
  148. package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.js +0 -2
  149. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.d.ts +0 -83
  150. package/lib/unimaze-billing/src/common/types/ReceiverRequirements.js +0 -393
  151. package/lib/unimaze-billing/src/common/types/SupplierInfo.d.ts +0 -11
  152. package/lib/unimaze-billing/src/common/types/SupplierInfo.js +0 -2
  153. package/lib/unimaze-billing/src/common/types/index.d.ts +0 -1
  154. package/lib/unimaze-billing/src/common/types/index.js +0 -17
  155. package/lib/unimaze-billing/src/create-credit-note/index.d.ts +0 -9
  156. package/lib/unimaze-billing/src/create-credit-note/index.js +0 -62
  157. package/lib/unimaze-billing/src/create-invoice/IntlLoader.d.ts +0 -11
  158. package/lib/unimaze-billing/src/create-invoice/IntlLoader.js +0 -116
  159. package/lib/unimaze-billing/src/create-invoice/index.d.ts +0 -82
  160. package/lib/unimaze-billing/src/create-invoice/index.js +0 -710
  161. package/lib/unimaze-billing/src/enums.d.ts +0 -14
  162. package/lib/unimaze-billing/src/enums.js +0 -18
  163. package/lib/unimaze-billing/src/index.d.ts +0 -4
  164. package/lib/unimaze-billing/src/index.js +0 -28
  165. package/lib/unimaze-billing/src/translations/locales/en.json +0 -183
  166. package/lib/unimaze-billing/src/translations/locales/is.json +0 -183
  167. package/lib/unimaze-billing/src/translations/locales.d.ts +0 -369
  168. package/lib/unimaze-billing/src/translations/locales.js +0 -11
  169. package/lib/unimaze-billing/src/utils/ApiUtility.d.ts +0 -29
  170. package/lib/unimaze-billing/src/utils/ApiUtility.js +0 -133
  171. package/lib/unimaze-billing/src/utils/BillingLineUtility.d.ts +0 -25
  172. package/lib/unimaze-billing/src/utils/BillingLineUtility.js +0 -190
  173. package/lib/unimaze-billing/src/utils/ConversionUtility.d.ts +0 -9
  174. package/lib/unimaze-billing/src/utils/ConversionUtility.js +0 -222
  175. package/lib/unimaze-billing/src/utils/FileUploadUtility.d.ts +0 -9
  176. package/lib/unimaze-billing/src/utils/FileUploadUtility.js +0 -45
  177. package/lib/unimaze-billing/src/utils/IntlUtility.d.ts +0 -6
  178. package/lib/unimaze-billing/src/utils/IntlUtility.js +0 -78
  179. package/lib/unimaze-billing/src/utils/LocationUtility.d.ts +0 -1
  180. package/lib/unimaze-billing/src/utils/LocationUtility.js +0 -81
  181. package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.d.ts +0 -7
  182. package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.js +0 -26
  183. package/lib/unimaze-billing/src/utils/RequirementsUtility.d.ts +0 -21
  184. package/lib/unimaze-billing/src/utils/RequirementsUtility.js +0 -237
  185. package/lib/unimaze-billing/src/utils/index.d.ts +0 -2
  186. package/lib/unimaze-billing/src/utils/index.js +0 -8
@@ -1,190 +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 __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __importDefault = (this && this.__importDefault) || function (mod) {
25
- return (mod && mod.__esModule) ? mod : { "default": mod };
26
- };
27
- Object.defineProperty(exports, "__esModule", { value: true });
28
- exports.getFieldNames = exports.getTaxCategoryDisabled = exports.getTotals = exports.getCorrectInputNode = exports.generateTaxCategoryLabel = exports.calculateTaxPercentage = exports.calculateTaxAmount = exports.calculateTaxableAmount = exports.calculateDiscountAmount = exports.billingLinesFieldsMetadata = void 0;
29
- var api_1 = require("@unimaze/api-clients/lib/mapi/api");
30
- var react_1 = __importDefault(require("react"));
31
- var antd_1 = require("antd");
32
- var CommonTranslations_1 = require("../common/components/CommonTranslations");
33
- var ConversionUtility_1 = require("./ConversionUtility");
34
- var enums_1 = require("../enums");
35
- var NewBillingLines_1 = require("../common/components/billing-lines/NewBillingLines");
36
- var lodash_1 = require("lodash");
37
- var billingLinesFieldsMetadata = function (formInstance) {
38
- var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
39
- return billingLinesMetadata.map(function (billingLine) {
40
- var cleanBillingLine = (0, ConversionUtility_1.removeEmpty)(billingLine);
41
- var discountType = cleanBillingLine.discountType, restBillingLines = __rest(cleanBillingLine, ["discountType"]); // NBNB: removing the added discountType from the properties that will be added to the mappedBillingLine
42
- var taxableAmount = (0, exports.calculateTaxableAmount)(restBillingLines.discountValue, restBillingLines.quantity, restBillingLines.unitPriceAmount, discountType);
43
- var taxPercentage = (0, exports.calculateTaxPercentage)(restBillingLines.taxCategoryType);
44
- var taxAmount = (0, exports.calculateTaxAmount)(taxableAmount, taxPercentage);
45
- var discountValue;
46
- if (restBillingLines.discountValue) {
47
- if (discountType === "PERCENTAGE") {
48
- discountValue = "".concat(restBillingLines.discountValue, "%");
49
- }
50
- else {
51
- discountValue = restBillingLines.discountValue;
52
- }
53
- }
54
- else {
55
- discountValue = restBillingLines.discountValue;
56
- }
57
- var mappedBillingLine = __assign(__assign({}, restBillingLines), { discountValue: discountValue, taxableAmount: taxableAmount, taxAmount: taxAmount, taxPercentage: taxPercentage });
58
- if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
59
- delete mappedBillingLine.discountValue;
60
- }
61
- return mappedBillingLine;
62
- });
63
- };
64
- exports.billingLinesFieldsMetadata = billingLinesFieldsMetadata;
65
- var calculateDiscountAmount = function (discountValue, quantity, unitPriceAmount) {
66
- if (discountValue && quantity && unitPriceAmount) {
67
- return quantity * unitPriceAmount * (parseFloat(discountValue) / 100);
68
- }
69
- return 0;
70
- };
71
- exports.calculateDiscountAmount = calculateDiscountAmount;
72
- var calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount, discountType) {
73
- if (!quantity || !unitPriceAmount) {
74
- return 0;
75
- }
76
- if ((0, lodash_1.isNaN)(discountValue)) {
77
- if (discountType === "PERCENTAGE") {
78
- return quantity * unitPriceAmount * ((100 - parseFloat(discountValue)) / 100);
79
- }
80
- else {
81
- return quantity * unitPriceAmount - parseFloat(discountValue);
82
- }
83
- }
84
- else {
85
- return quantity * unitPriceAmount;
86
- }
87
- };
88
- exports.calculateTaxableAmount = calculateTaxableAmount;
89
- var calculateTaxAmount = function (taxableAmount, taxPercentage) {
90
- // taxableAmount * (taxPercentage / 100)
91
- return taxableAmount * (taxPercentage / 100);
92
- };
93
- exports.calculateTaxAmount = calculateTaxAmount;
94
- var calculateTaxPercentage = function (taxCategoryType) {
95
- // inferred from the taxCategoryType? what is the mapping? ZeroRated/Exempt = 0, StandardRated = 24, ReducedRate = 11
96
- switch (taxCategoryType) {
97
- case api_1.TaxCategoryTypeEnum.StandardRated:
98
- return 24;
99
- case api_1.TaxCategoryTypeEnum.ReducedRated:
100
- return 11;
101
- case api_1.TaxCategoryTypeEnum.ZeroRated:
102
- case api_1.TaxCategoryTypeEnum.Exempt:
103
- case api_1.TaxCategoryTypeEnum.OutsideTaxScope:
104
- return 0;
105
- default:
106
- return 0;
107
- }
108
- };
109
- exports.calculateTaxPercentage = calculateTaxPercentage;
110
- var generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTranslated) {
111
- return taxCategoryType ? "".concat(taxCategoryTypeTranslated, " (").concat((0, exports.calculateTaxPercentage)(taxCategoryType), "%)") : "";
112
- };
113
- exports.generateTaxCategoryLabel = generateTaxCategoryLabel;
114
- var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile, value) {
115
- switch (dataIdx) {
116
- case "quantity":
117
- case "unitPriceAmount":
118
- case "discountValue":
119
- return (react_1.default.createElement(antd_1.InputNumber, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, step: 1, style: { width: "100%" }, placeholder: placeholder, addonAfter: addonAfter, value: value }));
120
- case "unitOfMeasure":
121
- return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder, style: { width: mobile ? 64 : "auto" } }, Object.keys(api_1.Units).map(function (unitOfMeasure) {
122
- if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
123
- return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, intl.formatMessage(CommonTranslations_1.commonTranslationMessages["unitOfMeasure_labels_".concat(unitOfMeasure)])));
124
- })));
125
- case "taxCategoryType":
126
- return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder }, Object.keys(api_1.TaxCategoryTypeEnum).map(function (taxCategoryType) {
127
- return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
128
- })));
129
- default:
130
- return (react_1.default.createElement(antd_1.Input, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, placeholder: placeholder }));
131
- }
132
- };
133
- exports.getCorrectInputNode = getCorrectInputNode;
134
- var getTotals = function (invoiceLines) {
135
- var totals = {
136
- totalTaxableAmount: 0,
137
- totalTaxAmount: 0,
138
- totalTaxInclusiveAmount: 0,
139
- roundingAmount: 0,
140
- discountAmount: 0,
141
- };
142
- invoiceLines.map(function (billingLine) {
143
- if (billingLine) {
144
- var taxAmount = (0, exports.calculateTaxAmount)((0, exports.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType), (0, exports.calculateTaxPercentage)(billingLine.taxCategoryType ? api_1.TaxCategoryTypeEnum[billingLine.taxCategoryType] : undefined));
145
- var taxableAmount = (0, exports.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType);
146
- var taxInclusiveAmount = taxableAmount + taxAmount;
147
- var discountAmount = (0, exports.calculateDiscountAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
148
- totals = {
149
- totalTaxAmount: totals.totalTaxAmount + taxAmount,
150
- totalTaxableAmount: totals.totalTaxableAmount + taxableAmount,
151
- totalTaxInclusiveAmount: totals.totalTaxInclusiveAmount + taxInclusiveAmount,
152
- roundingAmount: Math.abs(totals.totalTaxInclusiveAmount +
153
- taxInclusiveAmount -
154
- Math.round(totals.totalTaxInclusiveAmount + taxInclusiveAmount)),
155
- discountAmount: totals.discountAmount + discountAmount,
156
- };
157
- }
158
- });
159
- return totals;
160
- };
161
- exports.getTotals = getTotals;
162
- var getTaxCategoryDisabled = function (taxCategoryType, outsideVatScope) {
163
- switch (taxCategoryType) {
164
- case enums_1.AvailableTaxCategoryTypeEnum.StandardRated:
165
- case enums_1.AvailableTaxCategoryTypeEnum.ReducedRated:
166
- case enums_1.AvailableTaxCategoryTypeEnum.ZeroRated:
167
- case enums_1.AvailableTaxCategoryTypeEnum.Exempt:
168
- return outsideVatScope;
169
- case enums_1.AvailableTaxCategoryTypeEnum.OutsideTaxScope:
170
- return !outsideVatScope;
171
- default:
172
- return true;
173
- }
174
- };
175
- exports.getTaxCategoryDisabled = getTaxCategoryDisabled;
176
- var getFieldNames = function (keys, intl) {
177
- return keys === null || keys === void 0 ? void 0 : keys.map(function (key) {
178
- switch (key) {
179
- case "name":
180
- return intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_name);
181
- case "quantity":
182
- return intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_quantity);
183
- case "unitPriceAmount":
184
- return intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_unitPriceAmount);
185
- default:
186
- return "";
187
- }
188
- });
189
- };
190
- exports.getFieldNames = getFieldNames;
@@ -1,9 +0,0 @@
1
- import { BillingLineMetadata, InvoiceMetadataInput, PartyMetadata } from "@unimaze/api-clients/lib/mapi";
2
- import { Store } from "antd/es/form/interface";
3
- import { ProfileOutput } from "@unimaze/api-clients/lib/wapi2";
4
- import { PaymentMeansMetadata } from "@unimaze/api-clients/lib/mapi/api";
5
- export declare const removeEmpty: (obj: any) => any;
6
- declare const convertToInvoiceMetadataInput: (formValues: Store, invoiceLinesWithCalculations: BillingLineMetadata[], paymentMethod: PaymentMeansMetadata, chosenCustomer: PartyMetadata) => InvoiceMetadataInput;
7
- declare const profileOutputToPartyMetadata: (profileOutput: ProfileOutput) => PartyMetadata;
8
- declare const convertToReadableKennitala: (isoIdentifier: string) => string;
9
- export { convertToInvoiceMetadataInput, profileOutputToPartyMetadata, convertToReadableKennitala };
@@ -1,222 +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 __importDefault = (this && this.__importDefault) || function (mod) {
14
- return (mod && mod.__esModule) ? mod : { "default": mod };
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.convertToReadableKennitala = exports.profileOutputToPartyMetadata = exports.convertToInvoiceMetadataInput = exports.removeEmpty = void 0;
18
- var dayjs_1 = __importDefault(require("dayjs"));
19
- var antd_1 = require("antd");
20
- var utc_1 = __importDefault(require("dayjs/plugin/utc"));
21
- dayjs_1.default.extend(utc_1.default);
22
- var removeEmpty = function (obj) {
23
- var listOfKeys = Object.keys(obj);
24
- var filteredObject = listOfKeys.filter(function (k) {
25
- var value = obj[k];
26
- var valueIsNotNull = value != null;
27
- var valueIsNotUndefined = value !== undefined;
28
- var valueIsNotEmptyString = value !== '';
29
- return valueIsNotNull
30
- && valueIsNotUndefined
31
- && valueIsNotEmptyString;
32
- }); // Remove undef. and null.
33
- var reducedObject = filteredObject.reduce(function (newObj, k) {
34
- var _a, _b;
35
- return typeof obj[k] === "object"
36
- ? __assign(__assign({}, newObj), (_a = {}, _a[k] = (0, exports.removeEmpty)(obj[k]), _a)) : __assign(__assign({}, newObj), (_b = {}, _b[k] = obj[k], _b));
37
- }, // Copy value.
38
- {});
39
- return reducedObject;
40
- };
41
- exports.removeEmpty = removeEmpty;
42
- var convertDates = function (date) {
43
- return date ? (0, dayjs_1.default)(date).utc().toDate() : undefined;
44
- };
45
- var isEmpty = function (map) {
46
- for (var key in map) {
47
- if (map.hasOwnProperty(key)) {
48
- return false;
49
- }
50
- }
51
- return true;
52
- };
53
- var getIdentifierWithPrefix = function (identifier) {
54
- if (!identifier.startsWith("0196:")) {
55
- return "0196:".concat(cleanIdentifier(identifier));
56
- }
57
- else {
58
- return cleanIdentifier(identifier);
59
- }
60
- };
61
- var cleanIdentifier = function (identifier) {
62
- // return identifier.replace(/[^0-9]/g, "") // replace anything that isn't a numeric character
63
- return identifier.replace("-", ""); // remove the '-'
64
- };
65
- var convertToInvoiceMetadataInput = function (formValues, invoiceLinesWithCalculations, paymentMethod, chosenCustomer) {
66
- var issueDate = convertDates(formValues.invoice.issueDate);
67
- var dueDate = convertDates(formValues.invoice.dueDate);
68
- var referenceIdentifiersArray = formValues.invoice && formValues.invoice.singleReferenceIdentifier && formValues.invoice.singleReferenceIdentifier.code && formValues.invoice.singleReferenceIdentifier.value
69
- ? [{
70
- code: {
71
- value: formValues.invoice.singleReferenceIdentifier.code
72
- },
73
- value: formValues.invoice.singleReferenceIdentifier.value
74
- }]
75
- : formValues.invoice.referenceIdentifiers;
76
- var cleanedFormValues = (0, exports.removeEmpty)(formValues);
77
- var invoice = cleanedFormValues.invoice;
78
- // fix delivery
79
- var delivery = invoice.delivery;
80
- if (delivery) {
81
- if (isEmpty(delivery.address)) {
82
- delete delivery.address;
83
- }
84
- if (Object.keys(delivery).length === 0 && delivery.constructor === Object) {
85
- delivery = undefined;
86
- }
87
- }
88
- // const referenceIdentifiers: ReferenceIdentifierMetadata[] | null | undefined =
89
- // referenceIdentifiersArray
90
- // ? referenceIdentifiersArray.length === 0
91
- // ? null
92
- // : referenceIdentifiersArray.map(referenceId => (
93
- // {
94
- // code: referenceId.code!.value,
95
- // value: referenceId.value
96
- // })
97
- // )
98
- // : null;
99
- var referenceIdentifiers = referenceIdentifiersArray
100
- ? referenceIdentifiersArray.length === 0
101
- ? null
102
- : referenceIdentifiersArray[0].code
103
- ?
104
- // TODO: handle multiple?
105
- [{
106
- code: referenceIdentifiersArray[0].code.value,
107
- value: referenceIdentifiersArray[0].value
108
- }]
109
- : null
110
- : null;
111
- var getMessageHandling = function (partyMetadata) {
112
- if (!partyMetadata) {
113
- antd_1.message.error("There is an error in the configuration file for the receiver information");
114
- throw new Error("There is an error in the configuration file for the receiver information");
115
- }
116
- return {
117
- receiverIdentifier: partyMetadata.identifier,
118
- fallbackEmailAddress: partyMetadata.contact && partyMetadata.contact.electronicMail ? partyMetadata.contact.electronicMail : "",
119
- fallbackContactName: partyMetadata.name
120
- };
121
- };
122
- var vatNumber = invoice.supplier.vatNumber ? invoice.supplier.vatNumber : null;
123
- var orderReference = invoice.orderReference && invoice.orderReference.hasOwnProperty("documentNo")
124
- ? invoice.orderReference
125
- : undefined;
126
- // NBNB: FOR NOW THIS IS ONLY FOR PROJECT, CREATE FUNCTION THAT WOULD RETURN CORRECT OBJECT STRUCTURE IF OTHER PROPERTIES ARE BEING USED
127
- var documentReferences = invoice.documentReferences
128
- && invoice.documentReferences.project
129
- && invoice.documentReferences.project.documentNo
130
- ? invoice.documentReferences
131
- : undefined;
132
- var resp = {
133
- messageHandling: getMessageHandling(chosenCustomer),
134
- invoice: {
135
- customer: {
136
- identifier: getIdentifierWithPrefix(chosenCustomer.identifier),
137
- address: {
138
- streetNameAndNumber: chosenCustomer.address.streetNameAndNumber,
139
- postalZone: chosenCustomer.address.postalZone,
140
- city: chosenCustomer.address.city,
141
- countryCode: chosenCustomer.address.countryCode
142
- },
143
- name: chosenCustomer.name,
144
- contact: {
145
- electronicMail: chosenCustomer.contact.electronicMail,
146
- telephone: chosenCustomer.contact.telephone,
147
- name: invoice.customer.contact && invoice.customer.contact.name ? invoice.customer.contact.name : undefined,
148
- },
149
- locationIdentifier: invoice.customer.locationIdentifier,
150
- },
151
- supplier: {
152
- identifier: getIdentifierWithPrefix(invoice.supplier.identifier),
153
- address: {
154
- streetNameAndNumber: invoice.supplier.address.streetNameAndNumber,
155
- postalZone: invoice.supplier.address.postalZone,
156
- city: invoice.supplier.address.city,
157
- countryCode: invoice.supplier.address.countryCode,
158
- },
159
- vatNumber: vatNumber,
160
- name: invoice.supplier.name,
161
- contact: {
162
- electronicMail: invoice.supplier.contact.electronicMail,
163
- name: invoice.supplier.contact.name,
164
- },
165
- },
166
- delivery: delivery,
167
- invoiceNo: invoice.invoiceNo,
168
- issueDate: issueDate,
169
- dueDate: dueDate,
170
- notes: invoice.notes,
171
- currencyCode: invoice.currencyCode,
172
- invoiceLines: invoiceLinesWithCalculations,
173
- // invoiceLines: invoice.invoiceLines, // FOR NEW BILLING LINES
174
- // payableAmount: 0, // Calculated? either doesnt exist or part of the Billing/Invoice Lines
175
- buyerReference: invoice.buyerReference,
176
- paymentMeans: paymentMethod,
177
- referenceIdentifiers: referenceIdentifiers,
178
- documentReferences: documentReferences,
179
- orderReference: orderReference,
180
- documentDescriptions: [
181
- {
182
- identifier: "UNIMAZE-BILLING-WEB",
183
- description: location.hostname,
184
- }
185
- ],
186
- }
187
- };
188
- if (resp.invoice && resp.invoice.delivery && Object.keys(resp.invoice.delivery).length === 0) {
189
- delete resp.invoice.delivery;
190
- }
191
- if (resp.invoice && !resp.invoice.orderReference) {
192
- delete resp.invoice.orderReference;
193
- }
194
- return resp;
195
- };
196
- exports.convertToInvoiceMetadataInput = convertToInvoiceMetadataInput;
197
- var profileOutputToPartyMetadata = function (profileOutput) {
198
- if (!profileOutput.participantLegalIsoIdentifier || !profileOutput.participantLegalAddressStreet || !profileOutput.name || !profileOutput.country) {
199
- var errorMessage = "There was an error with the customer information, please check the application configuration";
200
- antd_1.message.error(errorMessage);
201
- throw new Error(errorMessage);
202
- }
203
- return {
204
- identifier: profileOutput.participantLegalIsoIdentifier,
205
- address: {
206
- streetNameAndNumber: profileOutput.participantLegalAddressStreet,
207
- city: profileOutput.participantLegalAddressCity,
208
- countryCode: profileOutput.country,
209
- postalZone: profileOutput.participantLegalAddressPostalCode
210
- },
211
- name: profileOutput.name,
212
- contact: {
213
- electronicMail: profileOutput.email,
214
- telephone: profileOutput.phoneNumber
215
- }
216
- };
217
- };
218
- exports.profileOutputToPartyMetadata = profileOutputToPartyMetadata;
219
- var convertToReadableKennitala = function (isoIdentifier) {
220
- return "".concat(isoIdentifier.substr(5, 6), "-").concat(isoIdentifier.substr(11));
221
- };
222
- exports.convertToReadableKennitala = convertToReadableKennitala;
@@ -1,9 +0,0 @@
1
- import { UploadFile } from "antd/es/upload/interface";
2
- declare const validFileTypes: string[];
3
- declare const reportIfFileIsValid: (file: UploadFile, uploadSizeLimit: number, errorMessages: {
4
- uploadFailed: string;
5
- uploadErrorWrongType: string;
6
- uploadErrorToLarge: string;
7
- }) => boolean;
8
- declare const getBase64: (file: Blob) => Promise<string | ArrayBuffer | null>;
9
- export { validFileTypes, reportIfFileIsValid, getBase64 };
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBase64 = exports.reportIfFileIsValid = exports.validFileTypes = void 0;
4
- var antd_1 = require("antd");
5
- var validFileTypes = [
6
- "application/pdf",
7
- "image/jpeg",
8
- "image/png",
9
- "text/csv",
10
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
11
- "application/vnd.oasis.opendocument.spreadsheet",
12
- ];
13
- exports.validFileTypes = validFileTypes;
14
- var reportIfFileIsValid = function (file, uploadSizeLimit, errorMessages) {
15
- var isFileCorrectType = file.type === "application/pdf" ||
16
- file.type === "image/jpeg" ||
17
- file.type === "image/png" ||
18
- file.type === "text/csv" ||
19
- file.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ||
20
- file.type === "application/vnd.oasis.opendocument.spreadsheet";
21
- var isFileCorrectSize = (file === null || file === void 0 ? void 0 : file.size) !== undefined && file.size <= uploadSizeLimit;
22
- if (!isFileCorrectType) {
23
- antd_1.notification.error({
24
- message: errorMessages.uploadFailed,
25
- description: errorMessages.uploadErrorWrongType,
26
- });
27
- }
28
- if (!isFileCorrectSize) {
29
- antd_1.notification.error({
30
- message: errorMessages.uploadFailed,
31
- description: errorMessages.uploadErrorToLarge,
32
- });
33
- }
34
- return isFileCorrectType && isFileCorrectSize;
35
- };
36
- exports.reportIfFileIsValid = reportIfFileIsValid;
37
- var getBase64 = function (file) {
38
- return new Promise(function (resolve, reject) {
39
- var reader = new FileReader();
40
- reader.readAsDataURL(file);
41
- reader.onload = function () { return resolve(reader.result); };
42
- reader.onerror = function (error) { return reject(error); };
43
- });
44
- };
45
- exports.getBase64 = getBase64;
@@ -1,6 +0,0 @@
1
- import { IntlShape } from "react-intl";
2
- import { FormatNumberOptions } from "react-intl/src/types";
3
- declare const icelandicNumberLocaleWorkaroundChrome: (value: number, intl: IntlShape, options?: FormatNumberOptions) => string;
4
- export declare const convertToIcelandicThousandAndDecimalSeparator: (value: string, minimumFractionDigits?: number, maximumFractionDigits?: number) => string;
5
- declare const returnDecimalSeparatorForLocale: (locale: string | null) => string | undefined;
6
- export { icelandicNumberLocaleWorkaroundChrome, returnDecimalSeparatorForLocale };
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.returnDecimalSeparatorForLocale = exports.icelandicNumberLocaleWorkaroundChrome = exports.convertToIcelandicThousandAndDecimalSeparator = void 0;
4
- var icelandicNumberLocaleWorkaroundChrome = function (value, intl, options) {
5
- var locale = localStorage.getItem("languageString");
6
- var cleanedValue = value === null || value === undefined ? 0 : value;
7
- if (locale) {
8
- var supportedLocalesArray = Intl.NumberFormat.supportedLocalesOf(locale);
9
- if (supportedLocalesArray.every(function (x) { return x !== locale; })) {
10
- switch (locale) {
11
- case "is":
12
- if (options) {
13
- switch (options.style) {
14
- case "decimal": {
15
- var decimalPart = options.maximumFractionDigits ? options.maximumFractionDigits : options.minimumFractionDigits ? options.minimumFractionDigits : 2;
16
- return (0, exports.convertToIcelandicThousandAndDecimalSeparator)(Number(cleanedValue).toFixed(decimalPart), options.minimumFractionDigits, options.maximumFractionDigits);
17
- }
18
- case "currency": {
19
- if (!options.currency) {
20
- throw new Error("options.currency must be specified if options.style = 'currency'");
21
- }
22
- var roundedValue = (0, exports.convertToIcelandicThousandAndDecimalSeparator)(Math.round(value).toString());
23
- var suffix = " ".concat(options.currency);
24
- return roundedValue + suffix;
25
- }
26
- case "percent": {
27
- var roundedValue = (0, exports.convertToIcelandicThousandAndDecimalSeparator)(cleanedValue.toString());
28
- var suffix = " %";
29
- return roundedValue + suffix;
30
- }
31
- case "unit": {
32
- return (0, exports.convertToIcelandicThousandAndDecimalSeparator)(value.toString());
33
- }
34
- }
35
- }
36
- return (0, exports.convertToIcelandicThousandAndDecimalSeparator)(value.toString());
37
- default:
38
- return intl.formatNumber(cleanedValue, options);
39
- }
40
- }
41
- }
42
- return intl.formatNumber(cleanedValue, options);
43
- };
44
- exports.icelandicNumberLocaleWorkaroundChrome = icelandicNumberLocaleWorkaroundChrome;
45
- var convertToIcelandicThousandAndDecimalSeparator = function (value, minimumFractionDigits, maximumFractionDigits) {
46
- var _a;
47
- var parts = value.split(".");
48
- if (parts.length === 1)
49
- return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
50
- if (maximumFractionDigits === 0) {
51
- return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
52
- }
53
- var decimalPart = parts[1];
54
- if (minimumFractionDigits) {
55
- if ((decimalPart === null || decimalPart === void 0 ? void 0 : decimalPart.length) < minimumFractionDigits) {
56
- var minimumFractionDigitsDifference = minimumFractionDigits - ((_a = parts[1]) === null || _a === void 0 ? void 0 : _a.length);
57
- for (var i = 0; i < minimumFractionDigitsDifference; i++) {
58
- decimalPart += "0";
59
- }
60
- }
61
- }
62
- if (maximumFractionDigits) {
63
- if ((decimalPart === null || decimalPart === void 0 ? void 0 : decimalPart.length) > maximumFractionDigits) {
64
- decimalPart = decimalPart.substring(0, maximumFractionDigits);
65
- }
66
- }
67
- return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".") + ",".concat(decimalPart);
68
- };
69
- exports.convertToIcelandicThousandAndDecimalSeparator = convertToIcelandicThousandAndDecimalSeparator;
70
- var returnDecimalSeparatorForLocale = function (locale) {
71
- switch (locale) {
72
- case "is":
73
- return ",";
74
- default:
75
- return undefined;
76
- }
77
- };
78
- exports.returnDecimalSeparatorForLocale = returnDecimalSeparatorForLocale;
@@ -1 +0,0 @@
1
- export declare const fetchCityAndPostcode: (query: string, country: string) => Promise<any>;
@@ -1,81 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.fetchCityAndPostcode = void 0;
40
- var antd_1 = require("antd");
41
- function capitalize(word) {
42
- if (!word)
43
- return "";
44
- return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
45
- }
46
- var fetchCityAndPostcode = function (query, country) { return __awaiter(void 0, void 0, void 0, function () {
47
- var baseUrl, selectFields, whereCondition, limit, apiUrl, response, data, results, error_1;
48
- return __generator(this, function (_a) {
49
- switch (_a.label) {
50
- case 0:
51
- baseUrl = "https://data.opendatasoft.com/api/explore/v2.1/catalog/datasets/geonames-postal-code@public/records";
52
- selectFields = "postal_code, place_name";
53
- whereCondition = "country_code like \"".concat(country, "\" and startswith(place_name, \"").concat(capitalize(query), "\")");
54
- limit = 20;
55
- apiUrl = "".concat(baseUrl, "?select=").concat(encodeURIComponent(selectFields), "&where=").concat(encodeURIComponent(whereCondition), "&limit=").concat(limit);
56
- _a.label = 1;
57
- case 1:
58
- _a.trys.push([1, 4, , 5]);
59
- return [4 /*yield*/, fetch(apiUrl)];
60
- case 2:
61
- response = _a.sent();
62
- return [4 /*yield*/, response.json()];
63
- case 3:
64
- data = _a.sent();
65
- if (!data || !data.results) {
66
- return [2 /*return*/, []];
67
- }
68
- results = data.results.map(function (result) {
69
- var placeNameCleaned = result.place_name.replace(/\s*-\s*\d+$/, "");
70
- return { place_name: placeNameCleaned, postal_code: result.postal_code };
71
- });
72
- return [2 /*return*/, results];
73
- case 4:
74
- error_1 = _a.sent();
75
- antd_1.message.error("Error fetching city and postcode data:".concat(error_1));
76
- return [3 /*break*/, 5];
77
- case 5: return [2 /*return*/];
78
- }
79
- });
80
- }); };
81
- exports.fetchCityAndPostcode = fetchCityAndPostcode;
@@ -1,7 +0,0 @@
1
- import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
2
- export interface FieldDefinitionWithOriginalKey extends FieldDefinition {
3
- originalKey: string;
4
- }
5
- declare const getReferenceIdentifierFieldDefinitions: (receiverRequirements: NewReceiverRequirements) => FieldDefinition[];
6
- declare const getReferenceIdentifierOptions: (receiverRequirements: NewReceiverRequirements) => FieldDefinitionWithOriginalKey[];
7
- export { getReferenceIdentifierOptions, getReferenceIdentifierFieldDefinitions };