@unimaze/billing 0.20.17 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. package/lib/common/components/CommonTranslations.d.ts +102 -2
  2. package/lib/common/components/CommonTranslations.js +10 -1
  3. package/lib/common/components/attachments/Attachment.d.ts +6 -4
  4. package/lib/common/components/attachments/Attachment.js +26 -10
  5. package/lib/common/components/attachments/AttachmentModal.d.ts +21 -0
  6. package/lib/common/components/attachments/AttachmentModal.js +195 -0
  7. package/lib/common/components/attachments/index.d.ts +13 -17
  8. package/lib/common/components/attachments/index.js +189 -23
  9. package/lib/common/components/base-information/AccountingCost.d.ts +7 -5
  10. package/lib/common/components/base-information/AccountingCost.js +32 -11
  11. package/lib/common/components/base-information/OrderReference.d.ts +6 -4
  12. package/lib/common/components/base-information/OrderReference.js +31 -14
  13. package/lib/common/components/base-information/ProjectReference.d.ts +9 -5
  14. package/lib/common/components/base-information/ProjectReference.js +8 -6
  15. package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +32 -5
  16. package/lib/common/components/base-information/ReferenceIdentifiers.js +126 -83
  17. package/lib/common/components/base-information/index.d.ts +51 -5
  18. package/lib/common/components/base-information/index.js +99 -154
  19. package/lib/common/components/billing-lines/BillingCalculations.d.ts +7 -5
  20. package/lib/common/components/billing-lines/BillingCalculations.js +79 -46
  21. package/lib/common/components/billing-lines/BillingLinePreview.d.ts +21 -0
  22. package/lib/common/components/billing-lines/BillingLinePreview.js +41 -0
  23. package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +6 -4
  24. package/lib/common/components/billing-lines/BillingTaxSummary.js +39 -13
  25. package/lib/common/components/billing-lines/NewBillingLines.d.ts +120 -4
  26. package/lib/common/components/billing-lines/NewBillingLines.js +396 -72
  27. package/lib/common/components/billing-lines/index.d.ts +33 -6
  28. package/lib/common/components/billing-lines/index.js +71 -244
  29. package/lib/common/components/component-container/Content.d.ts +2 -2
  30. package/lib/common/components/component-container/index.d.ts +1 -0
  31. package/lib/common/components/component-container/index.js +1 -1
  32. package/lib/common/components/customer/CostCenter.d.ts +6 -4
  33. package/lib/common/components/customer/CostCenter.js +25 -9
  34. package/lib/common/components/customer/CustomerContactName.d.ts +6 -4
  35. package/lib/common/components/customer/CustomerContactName.js +24 -8
  36. package/lib/common/components/customer/hardCoddedCustomer.js +19 -3
  37. package/lib/common/components/customer/index.d.ts +11 -5
  38. package/lib/common/components/customer/index.js +97 -42
  39. package/lib/common/components/date-picker/index.d.ts +21 -0
  40. package/lib/common/components/date-picker/index.js +23 -0
  41. package/lib/common/components/delivery-location/index.d.ts +6 -4
  42. package/lib/common/components/delivery-location/index.js +20 -4
  43. package/lib/common/components/editable-cell/index.js +2 -2
  44. package/lib/common/components/editable-row/index.d.ts +1 -1
  45. package/lib/common/components/editable-row/index.js +24 -7
  46. package/lib/common/components/form-item/index.d.ts +13 -6
  47. package/lib/common/components/form-item/index.js +16 -20
  48. package/lib/common/components/index.d.ts +10 -0
  49. package/lib/common/components/index.js +30 -8
  50. package/lib/common/components/input/index.d.ts +23 -0
  51. package/lib/common/components/input/index.js +37 -0
  52. package/lib/common/components/invoice/index.d.ts +40 -0
  53. package/lib/common/components/invoice/index.js +52 -0
  54. package/lib/common/components/invoice-preview/InvoicePreviewHeader.d.ts +12 -0
  55. package/lib/common/components/invoice-preview/InvoicePreviewHeader.js +105 -0
  56. package/lib/common/components/invoice-preview/index.d.ts +16 -0
  57. package/lib/common/components/invoice-preview/index.js +393 -0
  58. package/lib/common/components/locale-intl/index.d.ts +0 -10
  59. package/lib/common/components/locale-intl/index.js +50 -42
  60. package/lib/common/components/payment-method/index.d.ts +69 -6
  61. package/lib/common/components/payment-method/index.js +145 -57
  62. package/lib/common/components/payment-method/paymentMethodForConversion.js +3 -1
  63. package/lib/common/components/submit-confirmation/SubmitConfirmationSVG.d.ts +3 -0
  64. package/lib/common/components/submit-confirmation/SubmitConfirmationSVG.js +17 -0
  65. package/lib/common/components/submit-confirmation/index.d.ts +8 -0
  66. package/lib/common/components/submit-confirmation/index.js +34 -0
  67. package/lib/common/components/supplier/CityAutofill.d.ts +18 -0
  68. package/lib/common/components/supplier/CityAutofill.js +159 -0
  69. package/lib/common/components/supplier/index.d.ts +79 -5
  70. package/lib/common/components/supplier/index.js +195 -103
  71. package/lib/common/components/tooltip/index.d.ts +7 -0
  72. package/lib/common/components/tooltip/index.js +15 -0
  73. package/lib/common/components/welcome-modal/index.d.ts +15 -0
  74. package/lib/common/components/welcome-modal/index.js +26 -0
  75. package/lib/common/consts/formLayout.js +4 -3
  76. package/lib/common/consts/validationRules.d.ts +1 -1
  77. package/lib/common/consts/validationRules.js +6 -0
  78. package/lib/common/enums/index.js +5 -1
  79. package/lib/common/style/index.css +18 -0
  80. package/lib/common/types/BillingLineMetadataOverride.d.ts +2 -0
  81. package/lib/common/types/CommonProps.d.ts +15 -1
  82. package/lib/common/types/DiscountType.d.ts +1 -0
  83. package/lib/common/types/DiscountType.js +2 -0
  84. package/lib/common/types/ReceiverRequirements.d.ts +1 -1
  85. package/lib/common/types/ReceiverRequirements.js +1 -0
  86. package/lib/common/types/index.js +15 -0
  87. package/lib/create-invoice/IntlLoader.d.ts +0 -6
  88. package/lib/create-invoice/IntlLoader.js +78 -13
  89. package/lib/create-invoice/index.d.ts +65 -4
  90. package/lib/create-invoice/index.js +437 -181
  91. package/lib/enums.d.ts +2 -3
  92. package/lib/enums.js +1 -0
  93. package/lib/index.js +22 -6
  94. package/lib/translations/locales/en.json +181 -0
  95. package/lib/translations/locales/is.json +135 -116
  96. package/lib/translations/locales.d.ts +360 -161
  97. package/lib/translations/locales.js +3 -2
  98. package/lib/utils/ApiUtility.d.ts +4 -4
  99. package/lib/utils/ApiUtility.js +13 -10
  100. package/lib/utils/BillingLineUtility.d.ts +16 -5
  101. package/lib/utils/BillingLineUtility.js +65 -26
  102. package/lib/utils/ConversionUtility.js +15 -7
  103. package/lib/utils/FileUploadUtility.d.ts +4 -2
  104. package/lib/utils/FileUploadUtility.js +28 -9
  105. package/lib/utils/IntlUtility.d.ts +3 -2
  106. package/lib/utils/IntlUtility.js +2 -1
  107. package/lib/utils/LocationUtility.d.ts +1 -0
  108. package/lib/utils/LocationUtility.js +81 -0
  109. package/lib/utils/ReferenceIdentifierUtility.js +2 -1
  110. package/lib/utils/RequirementsUtility.d.ts +9 -7
  111. package/lib/utils/RequirementsUtility.js +46 -22
  112. package/lib/utils/index.js +4 -3
  113. package/package.json +36 -18
  114. package/lib/style/index.css +0 -51
@@ -1,11 +1,22 @@
1
- import { BillingLineMetadata } from '@unimaze/api-clients/lib/mapi';
1
+ import { BillingLineMetadata } from "@unimaze/api-clients/lib/mapi";
2
2
  import { FormInstance } from "antd/es/form";
3
3
  import { TaxCategoryTypeEnum } from "@unimaze/api-clients/lib/mapi/api";
4
+ import { BillingLineMetadataOverride } from "../common/types/BillingLineMetadataOverride";
4
5
  import React from "react";
5
- import { InjectedIntl } from "react-intl";
6
- export declare const billingLinesFieldsMetadata: (formInstance: FormInstance<any>) => BillingLineMetadata[];
7
- export declare const calculateTaxableAmount: (discountValue: string | null | undefined, quantity: number | null, unitPriceAmount: number | null) => number;
6
+ import { IntlShape } from "react-intl";
7
+ import { DiscountType } from "../common/types/DiscountType";
8
+ export interface Totals {
9
+ totalTaxableAmount: number;
10
+ totalTaxAmount: number;
11
+ totalTaxInclusiveAmount: number;
12
+ roundingAmount: number;
13
+ discountAmount: number;
14
+ }
15
+ export declare const billingLinesFieldsMetadata: (formInstance: FormInstance) => BillingLineMetadata[];
16
+ export declare const calculateDiscountAmount: (discountValue: string | null | undefined, quantity: number | null, unitPriceAmount: number | null) => number;
17
+ export declare const calculateTaxableAmount: (discountValue: string | null | undefined, quantity: number | null, unitPriceAmount: number | null, discountType: DiscountType) => number;
8
18
  export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
9
19
  export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum | undefined) => number;
10
20
  export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum | undefined, taxCategoryTypeTranslated: string) => string;
11
- export declare const getCorrectInputNode: (dataIdx: "key" | "name" | "description" | "referenceIdentifiers" | "accountingCost" | "notes" | "billingPeriod" | "unitOfMeasure" | "taxCategoryType" | "itemNo" | "quantity" | "unitPriceAmount" | "taxableAmount" | "taxAmount" | "taxPercentage" | "discountValue" | "discountReason" | "chargeValue" | "chargeReason" | "buyersItemNo" | "standardItemNo" | "originCountryCode" | "commodityClassification" | "additionalItemProperties" | "orderLineReference", intl: InjectedIntl) => React.ReactChild;
21
+ export declare const getCorrectInputNode: (dataIdx: keyof BillingLineMetadataOverride, intl: IntlShape, placeholder: string, required: boolean, addonAfter?: React.ReactNode, mobile?: boolean) => React.ReactChild;
22
+ export declare const getTotals: (invoiceLines: BillingLineMetadataOverride[]) => Totals;
@@ -14,50 +14,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getTotals = exports.getCorrectInputNode = exports.generateTaxCategoryLabel = exports.calculateTaxPercentage = exports.calculateTaxAmount = exports.calculateTaxableAmount = exports.calculateDiscountAmount = exports.billingLinesFieldsMetadata = void 0;
17
18
  var api_1 = require("@unimaze/api-clients/lib/mapi/api");
18
19
  var react_1 = __importDefault(require("react"));
19
20
  var antd_1 = require("antd");
20
21
  var CommonTranslations_1 = require("../common/components/CommonTranslations");
21
22
  var ConversionUtility_1 = require("./ConversionUtility");
22
- exports.billingLinesFieldsMetadata = function (formInstance) {
23
+ var billingLinesFieldsMetadata = function (formInstance) {
23
24
  var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
24
25
  return billingLinesMetadata.map(function (billingLine) {
25
- var cleanBillingLine = ConversionUtility_1.removeEmpty(billingLine);
26
- var taxableAmount = exports.calculateTaxableAmount(cleanBillingLine.discountValue, cleanBillingLine.quantity, cleanBillingLine.unitPriceAmount);
27
- var taxPercentage = exports.calculateTaxPercentage(cleanBillingLine.taxCategoryType);
28
- var taxAmount = exports.calculateTaxAmount(taxableAmount, taxPercentage);
29
- var mappedBillingLine = __assign({}, cleanBillingLine, { taxableAmount: taxableAmount,
30
- taxAmount: taxAmount,
31
- taxPercentage: taxPercentage });
26
+ var cleanBillingLine = (0, ConversionUtility_1.removeEmpty)(billingLine);
27
+ var taxableAmount = (0, exports.calculateTaxableAmount)(cleanBillingLine.discountValue, cleanBillingLine.quantity, cleanBillingLine.unitPriceAmount, cleanBillingLine.discountType);
28
+ var taxPercentage = (0, exports.calculateTaxPercentage)(cleanBillingLine.taxCategoryType);
29
+ var taxAmount = (0, exports.calculateTaxAmount)(taxableAmount, taxPercentage);
30
+ var mappedBillingLine = __assign(__assign({}, cleanBillingLine), { taxableAmount: taxableAmount, taxAmount: taxAmount, taxPercentage: taxPercentage });
32
31
  if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
33
32
  delete mappedBillingLine.discountValue;
34
33
  }
35
34
  return mappedBillingLine;
36
35
  });
37
36
  };
38
- exports.calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount) {
37
+ exports.billingLinesFieldsMetadata = billingLinesFieldsMetadata;
38
+ var calculateDiscountAmount = function (discountValue, quantity, unitPriceAmount) {
39
+ if (discountValue && quantity && unitPriceAmount) {
40
+ return quantity * unitPriceAmount * (parseFloat(discountValue) / 100);
41
+ }
42
+ return 0;
43
+ };
44
+ exports.calculateDiscountAmount = calculateDiscountAmount;
45
+ var calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount, discountType) {
39
46
  if (!quantity || !unitPriceAmount) {
40
47
  return 0;
41
48
  }
42
49
  if (discountValue) {
43
- if (discountValue.endsWith("%")) {
44
- // (quantity * unitPriceAmount) * ((100 - discountValue) / 100)
45
- return ((quantity * unitPriceAmount) * ((100 - parseFloat(discountValue)) / 100));
50
+ if (discountType === "PERCENTAGE") {
51
+ return quantity * unitPriceAmount * ((100 - parseFloat(discountValue)) / 100);
46
52
  }
47
53
  else {
48
- // (quantity * unitPriceAmount) - discountValue
49
- return ((quantity * unitPriceAmount) - parseFloat(discountValue));
54
+ return quantity * unitPriceAmount - parseFloat(discountValue);
50
55
  }
51
56
  }
52
57
  else {
53
- return (quantity * unitPriceAmount);
58
+ return quantity * unitPriceAmount;
54
59
  }
55
60
  };
56
- exports.calculateTaxAmount = function (taxableAmount, taxPercentage) {
61
+ exports.calculateTaxableAmount = calculateTaxableAmount;
62
+ var calculateTaxAmount = function (taxableAmount, taxPercentage) {
57
63
  // taxableAmount * (taxPercentage / 100)
58
- return (taxableAmount * (taxPercentage / 100));
64
+ return taxableAmount * (taxPercentage / 100);
59
65
  };
60
- exports.calculateTaxPercentage = function (taxCategoryType) {
66
+ exports.calculateTaxAmount = calculateTaxAmount;
67
+ var calculateTaxPercentage = function (taxCategoryType) {
61
68
  // inferred from the taxCategoryType? what is the mapping? ZeroRated/Exempt = 0, StandardRated = 24, ReducedRate = 11
62
69
  switch (taxCategoryType) {
63
70
  case api_1.TaxCategoryTypeEnum.StandardRated:
@@ -72,24 +79,56 @@ exports.calculateTaxPercentage = function (taxCategoryType) {
72
79
  return 0;
73
80
  }
74
81
  };
75
- exports.generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTranslated) {
76
- return taxCategoryType ? taxCategoryTypeTranslated + " (" + exports.calculateTaxPercentage(taxCategoryType) + "%)" : "";
82
+ exports.calculateTaxPercentage = calculateTaxPercentage;
83
+ var generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTranslated) {
84
+ return taxCategoryType ? "".concat(taxCategoryTypeTranslated, " (").concat((0, exports.calculateTaxPercentage)(taxCategoryType), "%)") : "";
77
85
  };
78
- exports.getCorrectInputNode = function (dataIdx, intl) {
86
+ exports.generateTaxCategoryLabel = generateTaxCategoryLabel;
87
+ var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile) {
79
88
  switch (dataIdx) {
80
89
  case "quantity":
81
90
  case "unitPriceAmount":
82
- return react_1.default.createElement(antd_1.InputNumber, { step: 1, style: { width: "100%" } });
91
+ case "discountValue":
92
+ 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 }));
83
93
  case "unitOfMeasure":
84
- return (react_1.default.createElement(antd_1.Select, { dropdownMatchSelectWidth: false }, Object.keys(api_1.Units).map(function (unitOfMeasure) {
94
+ 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) {
85
95
  if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
86
- return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, intl.formatMessage(CommonTranslations_1.commonTranslationMessages["unitOfMeasure_labels_" + unitOfMeasure])));
96
+ return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, intl.formatMessage(CommonTranslations_1.commonTranslationMessages["unitOfMeasure_labels_".concat(unitOfMeasure)])));
87
97
  })));
88
98
  case "taxCategoryType":
89
- return (react_1.default.createElement(antd_1.Select, { dropdownMatchSelectWidth: false }, Object.keys(api_1.TaxCategoryTypeEnum).map(function (taxCategoryType) {
99
+ return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder }, Object.keys(api_1.TaxCategoryTypeEnum).map(function (taxCategoryType) {
90
100
  return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
91
101
  })));
92
102
  default:
93
- return react_1.default.createElement(antd_1.Input, null);
103
+ return (react_1.default.createElement(antd_1.Input, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, placeholder: placeholder }));
94
104
  }
95
105
  };
106
+ exports.getCorrectInputNode = getCorrectInputNode;
107
+ var getTotals = function (invoiceLines) {
108
+ var totals = {
109
+ totalTaxableAmount: 0,
110
+ totalTaxAmount: 0,
111
+ totalTaxInclusiveAmount: 0,
112
+ roundingAmount: 0,
113
+ discountAmount: 0,
114
+ };
115
+ invoiceLines.map(function (billingLine) {
116
+ if (billingLine) {
117
+ 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));
118
+ var taxableAmount = (0, exports.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType);
119
+ var taxInclusiveAmount = taxableAmount + taxAmount;
120
+ var discountAmount = (0, exports.calculateDiscountAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
121
+ totals = {
122
+ totalTaxAmount: totals.totalTaxAmount + taxAmount,
123
+ totalTaxableAmount: totals.totalTaxableAmount + taxableAmount,
124
+ totalTaxInclusiveAmount: totals.totalTaxInclusiveAmount + taxInclusiveAmount,
125
+ roundingAmount: Math.abs(totals.totalTaxInclusiveAmount +
126
+ taxInclusiveAmount -
127
+ Math.round(totals.totalTaxInclusiveAmount + taxInclusiveAmount)),
128
+ discountAmount: totals.discountAmount + discountAmount,
129
+ };
130
+ }
131
+ });
132
+ return totals;
133
+ };
134
+ exports.getTotals = getTotals;
@@ -10,9 +10,16 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
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"));
14
19
  var antd_1 = require("antd");
15
- exports.removeEmpty = function (obj) {
20
+ var utc_1 = __importDefault(require("dayjs/plugin/utc"));
21
+ dayjs_1.default.extend(utc_1.default);
22
+ var removeEmpty = function (obj) {
16
23
  var listOfKeys = Object.keys(obj);
17
24
  var filteredObject = listOfKeys.filter(function (k) {
18
25
  var value = obj[k];
@@ -26,13 +33,14 @@ exports.removeEmpty = function (obj) {
26
33
  var reducedObject = filteredObject.reduce(function (newObj, k) {
27
34
  var _a, _b;
28
35
  return typeof obj[k] === "object"
29
- ? __assign({}, newObj, (_a = {}, _a[k] = exports.removeEmpty(obj[k]), _a)) : __assign({}, newObj, (_b = {}, _b[k] = obj[k], _b));
36
+ ? __assign(__assign({}, newObj), (_a = {}, _a[k] = (0, exports.removeEmpty)(obj[k]), _a)) : __assign(__assign({}, newObj), (_b = {}, _b[k] = obj[k], _b));
30
37
  }, // Copy value.
31
38
  {});
32
39
  return reducedObject;
33
40
  };
41
+ exports.removeEmpty = removeEmpty;
34
42
  var convertDates = function (date) {
35
- return date ? date.utc().toDate() : undefined;
43
+ return date ? (0, dayjs_1.default)(date).utc().toDate() : undefined;
36
44
  };
37
45
  var isEmpty = function (map) {
38
46
  for (var key in map) {
@@ -44,7 +52,7 @@ var isEmpty = function (map) {
44
52
  };
45
53
  var getIdentifierWithPrefix = function (identifier) {
46
54
  if (!identifier.startsWith("0196:")) {
47
- return "0196:" + cleanIdentifier(identifier);
55
+ return "0196:".concat(cleanIdentifier(identifier));
48
56
  }
49
57
  else {
50
58
  return cleanIdentifier(identifier);
@@ -65,7 +73,7 @@ var convertToInvoiceMetadataInput = function (formValues, invoiceLinesWithCalcul
65
73
  value: formValues.invoice.singleReferenceIdentifier.value
66
74
  }]
67
75
  : formValues.invoice.referenceIdentifiers;
68
- var cleanedFormValues = exports.removeEmpty(formValues);
76
+ var cleanedFormValues = (0, exports.removeEmpty)(formValues);
69
77
  var invoice = cleanedFormValues.invoice;
70
78
  // fix delivery
71
79
  var delivery = invoice.delivery;
@@ -177,7 +185,7 @@ var convertToInvoiceMetadataInput = function (formValues, invoiceLinesWithCalcul
177
185
  ],
178
186
  }
179
187
  };
180
- if (resp.invoice && resp.invoice.delivery && resp.invoice.delivery === {}) {
188
+ if (resp.invoice && resp.invoice.delivery && Object.keys(resp.invoice.delivery).length === 0) {
181
189
  delete resp.invoice.delivery;
182
190
  }
183
191
  if (resp.invoice && !resp.invoice.orderReference) {
@@ -209,6 +217,6 @@ var profileOutputToPartyMetadata = function (profileOutput) {
209
217
  };
210
218
  exports.profileOutputToPartyMetadata = profileOutputToPartyMetadata;
211
219
  var convertToReadableKennitala = function (isoIdentifier) {
212
- return isoIdentifier.substr(5, 6) + "-" + isoIdentifier.substr(11);
220
+ return "".concat(isoIdentifier.substr(5, 6), "-").concat(isoIdentifier.substr(11));
213
221
  };
214
222
  exports.convertToReadableKennitala = convertToReadableKennitala;
@@ -1,7 +1,9 @@
1
1
  import { UploadFile } from "antd/es/upload/interface";
2
- declare const reportIfFileIsValid: (file: UploadFile<any>, uploadSizeLimit: number, errorMessages: {
2
+ declare const validFileTypes: string[];
3
+ declare const reportIfFileIsValid: (file: UploadFile, uploadSizeLimit: number, errorMessages: {
3
4
  uploadFailed: string;
4
5
  uploadErrorWrongType: string;
5
6
  uploadErrorToLarge: string;
6
7
  }) => boolean;
7
- export { reportIfFileIsValid };
8
+ declare const getBase64: (file: Blob) => Promise<string | ArrayBuffer | null>;
9
+ export { validFileTypes, reportIfFileIsValid, getBase64 };
@@ -1,26 +1,45 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBase64 = exports.reportIfFileIsValid = exports.validFileTypes = void 0;
3
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;
4
14
  var reportIfFileIsValid = function (file, uploadSizeLimit, errorMessages) {
5
- var isFileCorrectType = (file.type === "application/pdf"
6
- || file.type === "image/jpeg"
7
- || file.type === "image/png"
8
- || file.type === "text/csv"
9
- || file.type === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
10
- || file.type === "application/vnd.oasis.opendocument.spreadsheet");
11
- var isFileCorrectSize = (file.size <= uploadSizeLimit);
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;
12
22
  if (!isFileCorrectType) {
13
23
  antd_1.notification.error({
14
24
  message: errorMessages.uploadFailed,
15
- description: errorMessages.uploadErrorWrongType
25
+ description: errorMessages.uploadErrorWrongType,
16
26
  });
17
27
  }
18
28
  if (!isFileCorrectSize) {
19
29
  antd_1.notification.error({
20
30
  message: errorMessages.uploadFailed,
21
- description: errorMessages.uploadErrorToLarge
31
+ description: errorMessages.uploadErrorToLarge,
22
32
  });
23
33
  }
24
34
  return isFileCorrectType && isFileCorrectSize;
25
35
  };
26
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,4 +1,5 @@
1
- import { FormattedNumber, InjectedIntl } from "react-intl";
2
- declare const icelandicNumberLocaleWorkaroundChrome: (value: number, intl: InjectedIntl, options?: FormattedNumber.PropsBase | undefined) => string;
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;
3
4
  declare const returnDecimalSeparatorForLocale: (locale: string | null) => string | undefined;
4
5
  export { icelandicNumberLocaleWorkaroundChrome, returnDecimalSeparatorForLocale };
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.returnDecimalSeparatorForLocale = exports.icelandicNumberLocaleWorkaroundChrome = void 0;
3
4
  var icelandicNumberLocaleWorkaroundChrome = function (value, intl, options) {
4
5
  var locale = localStorage.getItem("languageString");
5
6
  if (locale) {
@@ -17,7 +18,7 @@ var icelandicNumberLocaleWorkaroundChrome = function (value, intl, options) {
17
18
  throw new Error("options.currency must be specified if options.style = 'currency'");
18
19
  }
19
20
  var roundedValue = convertToIcelandicThousandAndDecimalSeparator(Math.round(value).toString());
20
- var suffix = " " + options.currency;
21
+ var suffix = " ".concat(options.currency);
21
22
  return roundedValue + suffix;
22
23
  }
23
24
  case "percent": {
@@ -0,0 +1 @@
1
+ export declare const fetchCityAndPostcode: (query: string, country: string) => Promise<any>;
@@ -0,0 +1,81 @@
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;
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  return __assign.apply(this, arguments);
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.getReferenceIdentifierFieldDefinitions = exports.getReferenceIdentifierOptions = void 0;
14
15
  var getReferenceIdentifierFieldDefinitions = function (receiverRequirements) {
15
16
  return receiverRequirements ? receiverRequirements.fieldDefinitions.filter(function (fieldRequirement) { return fieldRequirement.key.startsWith("referenceIdentifier"); }) : [];
16
17
  };
@@ -19,7 +20,7 @@ var getReferenceIdentifierOptions = function (receiverRequirements) {
19
20
  var referenceIdentifierFieldDefinitions = getReferenceIdentifierFieldDefinitions(receiverRequirements);
20
21
  return referenceIdentifierFieldDefinitions.map(function (fieldDefinition) {
21
22
  var delimiterIndex = fieldDefinition.key.indexOf(".");
22
- return __assign({}, fieldDefinition, { key: fieldDefinition.key.substring(delimiterIndex + 1), originalKey: fieldDefinition.key });
23
+ return __assign(__assign({}, fieldDefinition), { key: fieldDefinition.key.substring(delimiterIndex + 1), originalKey: fieldDefinition.key });
23
24
  });
24
25
  };
25
26
  exports.getReferenceIdentifierOptions = getReferenceIdentifierOptions;
@@ -2,15 +2,17 @@
2
2
  import React from 'react';
3
3
  import { AvailableFields } from "../common/types/ReceiverRequirements";
4
4
  import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
5
- import { FormItemProps } from "antd/lib/form/FormItem";
5
+ import { FormItemProps, ValidateStatus } from "antd/lib/form/FormItem";
6
+ import { NamePath } from "rc-field-form/es/interface";
6
7
  import { FormInstance } from "antd/es/form";
7
8
  export declare const getFieldRequirements: (receiverRequirements: NewReceiverRequirements, key: AvailableFields) => FieldDefinition | undefined;
8
- export declare const getFieldLabelOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabel: React.ReactNode) => React.ReactNode;
9
- export declare const getFieldLabelTooltipOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabelTooltip: React.ReactNode) => React.ReactNode;
10
- export declare const getFieldPlaceholderOverride: (fieldRequirement: FieldDefinition, defaultPlaceholder?: string | undefined) => string;
9
+ export declare const getFieldLabelOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabel: string) => string | undefined;
10
+ export declare const getFieldLabelTooltipOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabelTooltip: React.ReactNode | string) => React.ReactNode | string | undefined;
11
+ export declare const getFieldPlaceholderOverride: (fieldRequirement: FieldDefinition, defaultPlaceholder?: string) => string;
11
12
  export declare const getFieldIsRequired: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultIsRequired: boolean) => boolean;
12
13
  export interface FormItemPropsWithoutChildren extends Omit<FormItemProps, "children"> {
13
14
  }
14
- export declare const handleValueValidation: ((isoNumber: string, fieldName: string, value: string, rapiBaseUrl: string, namePath: string | number | (string | number)[], setValidationStatus: (validationStatus: "" | "error" | "success" | "validating" | "warning") => void, formInstance: FormInstance<any>, callName: string) => void) & import("lodash").Cancelable;
15
- export declare const debouncedHandleSearchValues: ((searchValue: string, fieldDefinition: FieldDefinition, setLoadingValues: (loadingValues: boolean) => void, loadingValues: boolean, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (newReceiverRequirements: NewReceiverRequirements) => void, callName: string, rapiBaseUrl: string, overwrittenFieldDefinitionKey?: string | undefined) => void) & import("lodash").Cancelable;
16
- export declare const getInput: (fieldDefinition: FieldDefinition, namePath: string | number | (string | number)[], validationCallName: string, legalIdentifier: string, formInstance: FormInstance<any>, rapiBaseUrl: string, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void, setAccountingCostFieldProps: (accountingCostFiledProps: FormItemPropsWithoutChildren) => void, accountingCostFieldProps: FormItemPropsWithoutChildren, setLoadingAccountingCostValues: (loadingAccountingCostValues: boolean) => void, loadingAccountingCostValues: boolean, setHandlingValidationStatus: (handlingValidationStatus: "" | "error" | "success" | "validating" | "warning") => void, allowClearSelect?: boolean | undefined) => React.ReactNode;
15
+ export declare const handleValueValidation: import("lodash").DebouncedFunc<(isoNumber: string, fieldName: string, value: string, rapiBaseUrl: string, namePath: NamePath, setValidationStatus: (validationStatus: ValidateStatus) => void, formInstance: FormInstance, callName: string) => void>;
16
+ export declare const debouncedHandleSearchValues: import("lodash").DebouncedFunc<(searchValue: string, fieldDefinition: FieldDefinition, setLoadingValues: (loadingValues: boolean) => void, loadingValues: boolean, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (newReceiverRequirements: NewReceiverRequirements) => void, callName: string, rapiBaseUrl: string, overwrittenFieldDefinitionKey?: string) => void>;
17
+ export declare const getInput: (fieldDefinition: FieldDefinition, namePath: NamePath, validationCallName: string, legalIdentifier: string, formInstance: FormInstance, rapiBaseUrl: string, receiverRequirements: NewReceiverRequirements, updateReceiverRequirementsProp: (receiverRequirements: NewReceiverRequirements) => void, setAccountingCostFieldProps: (accountingCostFiledProps: FormItemPropsWithoutChildren) => void, accountingCostFieldProps: FormItemPropsWithoutChildren, setLoadingAccountingCostValues: (loadingAccountingCostValues: boolean) => void, loadingAccountingCostValues: boolean, setHandlingValidationStatus: (handlingValidationStatus: ValidateStatus) => void, defaultPlaceholder: string, allowClearSelect?: boolean) => React.ReactNode;
18
+ export declare const getRequiredTooltipMessage: (title: string, fieldNames: string[]) => React.ReactNode;