@unimaze/billing 0.21.3 → 0.21.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/components/CommonTranslations.d.ts +1 -29
- package/lib/common/components/CommonTranslations.js +4 -32
- package/lib/common/components/attachments/Attachment.d.ts +1 -1
- package/lib/common/components/attachments/AttachmentModal.d.ts +1 -1
- package/lib/common/components/attachments/index.d.ts +1 -1
- package/lib/common/components/base-information/AccountingCost.d.ts +1 -1
- package/lib/common/components/base-information/OrderReference.d.ts +1 -1
- package/lib/common/components/base-information/ProjectReference.d.ts +1 -1
- package/lib/common/components/base-information/ReferenceIdentifiers.d.ts +2 -1
- package/lib/common/components/base-information/ReferenceIdentifiers.js +29 -11
- package/lib/common/components/base-information/index.d.ts +10 -1
- package/lib/common/components/base-information/index.js +9 -1
- package/lib/common/components/billing-lines/BillingCalculations.d.ts +1 -1
- package/lib/common/components/billing-lines/BillingLinePreview.d.ts +2 -1
- package/lib/common/components/billing-lines/BillingLinePreview.js +4 -2
- package/lib/common/components/billing-lines/BillingTaxSummary.d.ts +1 -1
- package/lib/common/components/billing-lines/BillingTaxSummary.js +0 -1
- package/lib/common/components/billing-lines/CurrencySelector.d.ts +20 -0
- package/lib/common/components/billing-lines/CurrencySelector.js +17 -0
- package/lib/common/components/billing-lines/DiscountTypeSelector.d.ts +10 -0
- package/lib/common/components/billing-lines/DiscountTypeSelector.js +16 -0
- package/lib/common/components/billing-lines/NewBillingLines.d.ts +2 -1
- package/lib/common/components/billing-lines/NewBillingLines.js +37 -327
- package/lib/common/components/billing-lines/NewNewBillingLines.d.ts +15 -0
- package/lib/common/components/billing-lines/NewNewBillingLines.js +36 -0
- package/lib/common/components/billing-lines/SingleBillingLine.d.ts +19 -0
- package/lib/common/components/billing-lines/SingleBillingLine.js +262 -0
- package/lib/common/components/billing-lines/UnitOfMeasureSelector.d.ts +14 -0
- package/lib/common/components/billing-lines/UnitOfMeasureSelector.js +15 -0
- package/lib/common/components/billing-lines/cwdwdw.d.ts +1 -0
- package/lib/common/components/billing-lines/cwdwdw.js +14 -0
- package/lib/common/components/billing-lines/index.d.ts +3 -6
- package/lib/common/components/billing-lines/index.js +1 -1
- package/lib/common/components/customer/CostCenter.d.ts +1 -1
- package/lib/common/components/customer/CustomerContactName.d.ts +1 -1
- package/lib/common/components/customer/index.d.ts +1 -1
- package/lib/common/components/customer/index.js +6 -4
- package/lib/common/components/delivery-location/index.d.ts +1 -1
- package/lib/common/components/form-item/index.d.ts +1 -1
- package/lib/common/components/input/index.d.ts +1 -1
- package/lib/common/components/invoice/index.d.ts +3 -1
- package/lib/common/components/invoice/index.js +21 -14
- package/lib/common/components/invoice-preview/InvoicePreviewHeader.d.ts +1 -1
- package/lib/common/components/invoice-preview/InvoicePreviewHeader.js +7 -8
- package/lib/common/components/invoice-preview/index.d.ts +1 -1
- package/lib/common/components/invoice-preview/index.js +8 -2
- package/lib/common/components/payment-method/index.d.ts +1 -1
- package/lib/common/components/payment-method/index.js +22 -7
- package/lib/common/components/supplier/CityAutofill.d.ts +1 -1
- package/lib/common/components/supplier/index.d.ts +1 -1
- package/lib/common/components/welcome-modal/index.d.ts +1 -1
- package/lib/common/types/ReceiverRequirements.d.ts +2 -0
- package/lib/common/types/ReceiverRequirements.js +2 -0
- package/lib/create-invoice/index.d.ts +9 -1
- package/lib/create-invoice/index.js +87 -60
- package/lib/enums.d.ts +3 -0
- package/lib/translations/locales/en.json +7 -10
- package/lib/translations/locales/is.json +5 -8
- package/lib/translations/locales.d.ts +10 -16
- package/lib/unimaze-api-clients/src/mapi/api.d.ts +6664 -0
- package/lib/unimaze-api-clients/src/mapi/api.js +4743 -0
- package/lib/unimaze-api-clients/src/mapi/base.d.ts +55 -0
- package/lib/unimaze-api-clients/src/mapi/base.js +84 -0
- package/lib/unimaze-api-clients/src/mapi/configuration.d.ts +63 -0
- package/lib/unimaze-api-clients/src/mapi/configuration.js +28 -0
- package/lib/unimaze-api-clients/src/mapi/index.d.ts +13 -0
- package/lib/unimaze-api-clients/src/mapi/index.js +30 -0
- package/lib/unimaze-api-clients/src/rapi/api.d.ts +5015 -0
- package/lib/unimaze-api-clients/src/rapi/api.js +5582 -0
- package/lib/unimaze-api-clients/src/rapi/base.d.ts +55 -0
- package/lib/unimaze-api-clients/src/rapi/base.js +84 -0
- package/lib/unimaze-api-clients/src/rapi/configuration.d.ts +63 -0
- package/lib/unimaze-api-clients/src/rapi/configuration.js +28 -0
- package/lib/unimaze-api-clients/src/rapi/index.d.ts +13 -0
- package/lib/unimaze-api-clients/src/rapi/index.js +30 -0
- package/lib/unimaze-billing/src/common/components/CommonTranslations.d.ts +102 -0
- package/lib/unimaze-billing/src/common/components/CommonTranslations.js +106 -0
- package/lib/unimaze-billing/src/common/components/attachments/Attachment.d.ts +20 -0
- package/lib/unimaze-billing/src/common/components/attachments/Attachment.js +164 -0
- package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.d.ts +21 -0
- package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.js +203 -0
- package/lib/unimaze-billing/src/common/components/attachments/index.d.ts +27 -0
- package/lib/unimaze-billing/src/common/components/attachments/index.js +214 -0
- package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.d.ts +17 -0
- package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.js +61 -0
- package/lib/unimaze-billing/src/common/components/base-information/OrderReference.d.ts +16 -0
- package/lib/unimaze-billing/src/common/components/base-information/OrderReference.js +58 -0
- package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.js +30 -0
- package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.d.ts +48 -0
- package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.js +306 -0
- package/lib/unimaze-billing/src/common/components/base-information/index.d.ts +68 -0
- package/lib/unimaze-billing/src/common/components/base-information/index.js +178 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.js +153 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.d.ts +21 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.js +41 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.d.ts +13 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.js +134 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.d.ts +20 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/CurrencySelector.js +17 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.d.ts +10 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/DiscountTypeSelector.js +16 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.d.ts +129 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.js +495 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.d.ts +15 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/NewNewBillingLines.js +36 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.js +199 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/UnitOfMeasureSelector.js +15 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/index.d.ts +52 -0
- package/lib/unimaze-billing/src/common/components/billing-lines/index.js +104 -0
- package/lib/unimaze-billing/src/common/components/component-container/Content.d.ts +7 -0
- package/lib/unimaze-billing/src/common/components/component-container/Content.js +13 -0
- package/lib/unimaze-billing/src/common/components/component-container/Header.d.ts +9 -0
- package/lib/unimaze-billing/src/common/components/component-container/Header.js +28 -0
- package/lib/unimaze-billing/src/common/components/component-container/index.d.ts +12 -0
- package/lib/unimaze-billing/src/common/components/component-container/index.js +22 -0
- package/lib/unimaze-billing/src/common/components/customer/CostCenter.d.ts +17 -0
- package/lib/unimaze-billing/src/common/components/customer/CostCenter.js +163 -0
- package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.d.ts +17 -0
- package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.js +53 -0
- package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.d.ts +7 -0
- package/lib/unimaze-billing/src/common/components/customer/hardCoddedCustomer.js +41 -0
- package/lib/unimaze-billing/src/common/components/customer/index.d.ts +26 -0
- package/lib/unimaze-billing/src/common/components/customer/index.js +168 -0
- package/lib/unimaze-billing/src/common/components/date-picker/index.d.ts +21 -0
- package/lib/unimaze-billing/src/common/components/date-picker/index.js +23 -0
- package/lib/unimaze-billing/src/common/components/delivery-location/index.d.ts +12 -0
- package/lib/unimaze-billing/src/common/components/delivery-location/index.js +89 -0
- package/lib/unimaze-billing/src/common/components/editable-cell/index.d.ts +0 -0
- package/lib/unimaze-billing/src/common/components/editable-cell/index.js +295 -0
- package/lib/unimaze-billing/src/common/components/editable-row/index.d.ts +5 -0
- package/lib/unimaze-billing/src/common/components/editable-row/index.js +59 -0
- package/lib/unimaze-billing/src/common/components/form-item/index.d.ts +35 -0
- package/lib/unimaze-billing/src/common/components/form-item/index.js +60 -0
- package/lib/unimaze-billing/src/common/components/index.d.ts +18 -0
- package/lib/unimaze-billing/src/common/components/index.js +42 -0
- package/lib/unimaze-billing/src/common/components/input/index.d.ts +23 -0
- package/lib/unimaze-billing/src/common/components/input/index.js +37 -0
- package/lib/unimaze-billing/src/common/components/invoice/index.d.ts +40 -0
- package/lib/unimaze-billing/src/common/components/invoice/index.js +52 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.d.ts +12 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.js +105 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/index.d.ts +16 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/index.js +405 -0
- package/lib/unimaze-billing/src/common/components/locale-intl/index.d.ts +0 -0
- package/lib/unimaze-billing/src/common/components/locale-intl/index.js +51 -0
- package/lib/unimaze-billing/src/common/components/payment-method/index.d.ts +76 -0
- package/lib/unimaze-billing/src/common/components/payment-method/index.js +356 -0
- package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.d.ts +8 -0
- package/lib/unimaze-billing/src/common/components/payment-method/paymentMethodForConversion.js +37 -0
- package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.d.ts +3 -0
- package/lib/unimaze-billing/src/common/components/submit-confirmation/SubmitConfirmationSVG.js +17 -0
- package/lib/unimaze-billing/src/common/components/submit-confirmation/index.d.ts +8 -0
- package/lib/unimaze-billing/src/common/components/submit-confirmation/index.js +34 -0
- package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.d.ts +18 -0
- package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.js +159 -0
- package/lib/unimaze-billing/src/common/components/supplier/index.d.ts +94 -0
- package/lib/unimaze-billing/src/common/components/supplier/index.js +334 -0
- package/lib/unimaze-billing/src/common/components/tooltip/index.d.ts +7 -0
- package/lib/unimaze-billing/src/common/components/tooltip/index.js +15 -0
- package/lib/unimaze-billing/src/common/components/welcome-modal/index.d.ts +15 -0
- package/lib/unimaze-billing/src/common/components/welcome-modal/index.js +26 -0
- package/lib/unimaze-billing/src/common/consts/formLayout.d.ts +74 -0
- package/lib/unimaze-billing/src/common/consts/formLayout.js +45 -0
- package/lib/unimaze-billing/src/common/consts/validationRules.d.ts +6 -0
- package/lib/unimaze-billing/src/common/consts/validationRules.js +69 -0
- package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.d.ts +5 -0
- package/lib/unimaze-billing/src/common/enums/DocumentTypeEnum.js +8 -0
- package/lib/unimaze-billing/src/common/enums/index.d.ts +1 -0
- package/lib/unimaze-billing/src/common/enums/index.js +8 -0
- package/lib/unimaze-billing/src/common/types/AppConfiguration.d.ts +23 -0
- package/lib/unimaze-billing/src/common/types/AppConfiguration.js +2 -0
- package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.d.ts +10 -0
- package/lib/unimaze-billing/src/common/types/BillingLineMetadataOverride.js +2 -0
- package/lib/unimaze-billing/src/common/types/CommonProps.d.ts +33 -0
- package/lib/unimaze-billing/src/common/types/CommonProps.js +2 -0
- package/lib/unimaze-billing/src/common/types/DiscountType.d.ts +1 -0
- package/lib/unimaze-billing/src/common/types/DiscountType.js +2 -0
- package/lib/unimaze-billing/src/common/types/InvoiceFormFields.d.ts +1 -0
- package/lib/unimaze-billing/src/common/types/InvoiceFormFields.js +2 -0
- package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.d.ts +27 -0
- package/lib/unimaze-billing/src/common/types/NewReceiverRequirements.js +2 -0
- package/lib/unimaze-billing/src/common/types/ReceiverRequirements.d.ts +81 -0
- package/lib/unimaze-billing/src/common/types/ReceiverRequirements.js +391 -0
- package/lib/unimaze-billing/src/common/types/SupplierInfo.d.ts +11 -0
- package/lib/unimaze-billing/src/common/types/SupplierInfo.js +2 -0
- package/lib/unimaze-billing/src/common/types/index.d.ts +1 -0
- package/lib/unimaze-billing/src/common/types/index.js +17 -0
- package/lib/unimaze-billing/src/create-credit-note/index.d.ts +9 -0
- package/lib/unimaze-billing/src/create-credit-note/index.js +62 -0
- package/lib/unimaze-billing/src/create-invoice/IntlLoader.d.ts +11 -0
- package/lib/unimaze-billing/src/create-invoice/IntlLoader.js +116 -0
- package/lib/unimaze-billing/src/create-invoice/index.d.ts +74 -0
- package/lib/unimaze-billing/src/create-invoice/index.js +680 -0
- package/lib/unimaze-billing/src/enums.d.ts +11 -0
- package/lib/unimaze-billing/src/enums.js +18 -0
- package/lib/unimaze-billing/src/index.d.ts +4 -0
- package/lib/unimaze-billing/src/index.js +28 -0
- package/lib/unimaze-billing/src/translations/locales/en.json +183 -0
- package/lib/unimaze-billing/src/translations/locales/is.json +183 -0
- package/lib/unimaze-billing/src/translations/locales.d.ts +369 -0
- package/lib/unimaze-billing/src/translations/locales.js +11 -0
- package/lib/unimaze-billing/src/utils/ApiUtility.d.ts +23 -0
- package/lib/unimaze-billing/src/utils/ApiUtility.js +115 -0
- package/lib/unimaze-billing/src/utils/BillingLineUtility.d.ts +22 -0
- package/lib/unimaze-billing/src/utils/BillingLineUtility.js +158 -0
- package/lib/unimaze-billing/src/utils/ConversionUtility.d.ts +9 -0
- package/lib/unimaze-billing/src/utils/ConversionUtility.js +223 -0
- package/lib/unimaze-billing/src/utils/FileUploadUtility.d.ts +9 -0
- package/lib/unimaze-billing/src/utils/FileUploadUtility.js +45 -0
- package/lib/unimaze-billing/src/utils/IntlUtility.d.ts +5 -0
- package/lib/unimaze-billing/src/utils/IntlUtility.js +55 -0
- package/lib/unimaze-billing/src/utils/LocationUtility.d.ts +1 -0
- package/lib/unimaze-billing/src/utils/LocationUtility.js +81 -0
- package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.d.ts +7 -0
- package/lib/unimaze-billing/src/utils/ReferenceIdentifierUtility.js +26 -0
- package/lib/unimaze-billing/src/utils/RequirementsUtility.d.ts +19 -0
- package/lib/unimaze-billing/src/utils/RequirementsUtility.js +189 -0
- package/lib/unimaze-billing/src/utils/index.d.ts +2 -0
- package/lib/unimaze-billing/src/utils/index.js +8 -0
- package/lib/utils/ApiUtility.d.ts +9 -3
- package/lib/utils/ApiUtility.js +30 -2
- package/lib/utils/BillingLineUtility.d.ts +3 -0
- package/lib/utils/BillingLineUtility.js +32 -1
- package/lib/utils/RequirementsUtility.d.ts +4 -1
- package/lib/utils/RequirementsUtility.js +56 -1
- package/package.json +2 -2
|
@@ -0,0 +1,158 @@
|
|
|
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.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 billingLinesFieldsMetadata = function (formInstance) {
|
|
35
|
+
var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
|
|
36
|
+
return billingLinesMetadata.map(function (billingLine) {
|
|
37
|
+
var cleanBillingLine = (0, ConversionUtility_1.removeEmpty)(billingLine);
|
|
38
|
+
var discountType = cleanBillingLine.discountType, restBillingLines = __rest(cleanBillingLine, ["discountType"]); // NBNB: removing the added discountType from the properties that will be added to the mappedBillingLine
|
|
39
|
+
var taxableAmount = (0, exports.calculateTaxableAmount)(restBillingLines.discountValue, restBillingLines.quantity, restBillingLines.unitPriceAmount, discountType);
|
|
40
|
+
var taxPercentage = (0, exports.calculateTaxPercentage)(restBillingLines.taxCategoryType);
|
|
41
|
+
var taxAmount = (0, exports.calculateTaxAmount)(taxableAmount, taxPercentage);
|
|
42
|
+
var discountValue;
|
|
43
|
+
if (restBillingLines.discountValue) {
|
|
44
|
+
if (discountType === "PERCENTAGE") {
|
|
45
|
+
discountValue = "".concat(restBillingLines.discountValue, "%");
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
discountValue = restBillingLines.discountValue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
discountValue = restBillingLines.discountValue;
|
|
53
|
+
}
|
|
54
|
+
var mappedBillingLine = __assign(__assign({}, restBillingLines), { discountValue: discountValue, taxableAmount: taxableAmount, taxAmount: taxAmount, taxPercentage: taxPercentage });
|
|
55
|
+
if (mappedBillingLine.discountValue === "0" || mappedBillingLine.discountValue === "0%") {
|
|
56
|
+
delete mappedBillingLine.discountValue;
|
|
57
|
+
}
|
|
58
|
+
return mappedBillingLine;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
exports.billingLinesFieldsMetadata = billingLinesFieldsMetadata;
|
|
62
|
+
var calculateDiscountAmount = function (discountValue, quantity, unitPriceAmount) {
|
|
63
|
+
if (discountValue && quantity && unitPriceAmount) {
|
|
64
|
+
return quantity * unitPriceAmount * (parseFloat(discountValue) / 100);
|
|
65
|
+
}
|
|
66
|
+
return 0;
|
|
67
|
+
};
|
|
68
|
+
exports.calculateDiscountAmount = calculateDiscountAmount;
|
|
69
|
+
var calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount, discountType) {
|
|
70
|
+
if (!quantity || !unitPriceAmount) {
|
|
71
|
+
return 0;
|
|
72
|
+
}
|
|
73
|
+
if (discountValue) {
|
|
74
|
+
if (discountType === "PERCENTAGE") {
|
|
75
|
+
return quantity * unitPriceAmount * ((100 - parseFloat(discountValue)) / 100);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
return quantity * unitPriceAmount - parseFloat(discountValue);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return quantity * unitPriceAmount;
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.calculateTaxableAmount = calculateTaxableAmount;
|
|
86
|
+
var calculateTaxAmount = function (taxableAmount, taxPercentage) {
|
|
87
|
+
// taxableAmount * (taxPercentage / 100)
|
|
88
|
+
return taxableAmount * (taxPercentage / 100);
|
|
89
|
+
};
|
|
90
|
+
exports.calculateTaxAmount = calculateTaxAmount;
|
|
91
|
+
var calculateTaxPercentage = function (taxCategoryType) {
|
|
92
|
+
// inferred from the taxCategoryType? what is the mapping? ZeroRated/Exempt = 0, StandardRated = 24, ReducedRate = 11
|
|
93
|
+
switch (taxCategoryType) {
|
|
94
|
+
case api_1.TaxCategoryTypeEnum.StandardRated:
|
|
95
|
+
return 24;
|
|
96
|
+
case api_1.TaxCategoryTypeEnum.ReducedRated:
|
|
97
|
+
return 11;
|
|
98
|
+
case api_1.TaxCategoryTypeEnum.ZeroRated:
|
|
99
|
+
case api_1.TaxCategoryTypeEnum.Exempt:
|
|
100
|
+
case api_1.TaxCategoryTypeEnum.OutsideTaxScope:
|
|
101
|
+
return 0;
|
|
102
|
+
default:
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
exports.calculateTaxPercentage = calculateTaxPercentage;
|
|
107
|
+
var generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTranslated) {
|
|
108
|
+
return taxCategoryType ? "".concat(taxCategoryTypeTranslated, " (").concat((0, exports.calculateTaxPercentage)(taxCategoryType), "%)") : "";
|
|
109
|
+
};
|
|
110
|
+
exports.generateTaxCategoryLabel = generateTaxCategoryLabel;
|
|
111
|
+
var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile) {
|
|
112
|
+
switch (dataIdx) {
|
|
113
|
+
case "quantity":
|
|
114
|
+
case "unitPriceAmount":
|
|
115
|
+
case "discountValue":
|
|
116
|
+
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 }));
|
|
117
|
+
case "unitOfMeasure":
|
|
118
|
+
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) {
|
|
119
|
+
if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
|
|
120
|
+
return (react_1.default.createElement(antd_1.Select.Option, { value: unitOfMeasure, title: unitOfMeasure, key: unitOfMeasure }, intl.formatMessage(CommonTranslations_1.commonTranslationMessages["unitOfMeasure_labels_".concat(unitOfMeasure)])));
|
|
121
|
+
})));
|
|
122
|
+
case "taxCategoryType":
|
|
123
|
+
return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder }, Object.keys(api_1.TaxCategoryTypeEnum).map(function (taxCategoryType) {
|
|
124
|
+
return (react_1.default.createElement(antd_1.Select.Option, { value: taxCategoryType, title: taxCategoryType, key: taxCategoryType }, taxCategoryType));
|
|
125
|
+
})));
|
|
126
|
+
default:
|
|
127
|
+
return (react_1.default.createElement(antd_1.Input, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, placeholder: placeholder }));
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
exports.getCorrectInputNode = getCorrectInputNode;
|
|
131
|
+
var getTotals = function (invoiceLines) {
|
|
132
|
+
var totals = {
|
|
133
|
+
totalTaxableAmount: 0,
|
|
134
|
+
totalTaxAmount: 0,
|
|
135
|
+
totalTaxInclusiveAmount: 0,
|
|
136
|
+
roundingAmount: 0,
|
|
137
|
+
discountAmount: 0,
|
|
138
|
+
};
|
|
139
|
+
invoiceLines.map(function (billingLine) {
|
|
140
|
+
if (billingLine) {
|
|
141
|
+
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));
|
|
142
|
+
var taxableAmount = (0, exports.calculateTaxableAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount, billingLine.discountType);
|
|
143
|
+
var taxInclusiveAmount = taxableAmount + taxAmount;
|
|
144
|
+
var discountAmount = (0, exports.calculateDiscountAmount)(billingLine.discountValue, billingLine.quantity, billingLine.unitPriceAmount);
|
|
145
|
+
totals = {
|
|
146
|
+
totalTaxAmount: totals.totalTaxAmount + taxAmount,
|
|
147
|
+
totalTaxableAmount: totals.totalTaxableAmount + taxableAmount,
|
|
148
|
+
totalTaxInclusiveAmount: totals.totalTaxInclusiveAmount + taxInclusiveAmount,
|
|
149
|
+
roundingAmount: Math.abs(totals.totalTaxInclusiveAmount +
|
|
150
|
+
taxInclusiveAmount -
|
|
151
|
+
Math.round(totals.totalTaxInclusiveAmount + taxInclusiveAmount)),
|
|
152
|
+
discountAmount: totals.discountAmount + discountAmount,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
return totals;
|
|
157
|
+
};
|
|
158
|
+
exports.getTotals = getTotals;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BillingLineMetadata, InvoiceMetadataInput, PartyMetadata } from "@unimaze/api-clients/lib/mapi";
|
|
2
|
+
import { Store } from "antd/es/form/interface";
|
|
3
|
+
import { PortalConfigurationCustomer } from "@unimaze/api-clients/src/rapi";
|
|
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: (customer: PortalConfigurationCustomer) => PartyMetadata;
|
|
8
|
+
declare const convertToReadableKennitala: (isoIdentifier: string) => string;
|
|
9
|
+
export { convertToInvoiceMetadataInput, profileOutputToPartyMetadata, convertToReadableKennitala };
|
|
@@ -0,0 +1,223 @@
|
|
|
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 (customer) {
|
|
198
|
+
var _a, _b, _c, _d, _e, _f;
|
|
199
|
+
if (!(customer === null || customer === void 0 ? void 0 : customer.isoIdentifier) || !((_a = customer === null || customer === void 0 ? void 0 : customer.address) === null || _a === void 0 ? void 0 : _a.street) || !(customer === null || customer === void 0 ? void 0 : customer.name) || !((_b = customer === null || customer === void 0 ? void 0 : customer.address) === null || _b === void 0 ? void 0 : _b.country)) {
|
|
200
|
+
var errorMessage = "There was an error with the customer information, please check the application configuration";
|
|
201
|
+
antd_1.message.error(errorMessage);
|
|
202
|
+
throw new Error(errorMessage);
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
identifier: customer.isoIdentifier,
|
|
206
|
+
address: {
|
|
207
|
+
streetNameAndNumber: (_c = customer.address) === null || _c === void 0 ? void 0 : _c.street,
|
|
208
|
+
city: (_d = customer.address) === null || _d === void 0 ? void 0 : _d.city,
|
|
209
|
+
countryCode: (_e = customer.address) === null || _e === void 0 ? void 0 : _e.country,
|
|
210
|
+
postalZone: (_f = customer.address) === null || _f === void 0 ? void 0 : _f.postalCode
|
|
211
|
+
},
|
|
212
|
+
name: customer.name,
|
|
213
|
+
contact: {
|
|
214
|
+
electronicMail: customer.email,
|
|
215
|
+
telephone: customer.phoneNumber
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
exports.profileOutputToPartyMetadata = profileOutputToPartyMetadata;
|
|
220
|
+
var convertToReadableKennitala = function (isoIdentifier) {
|
|
221
|
+
return "".concat(isoIdentifier.substr(5, 6), "-").concat(isoIdentifier.substr(11));
|
|
222
|
+
};
|
|
223
|
+
exports.convertToReadableKennitala = convertToReadableKennitala;
|
|
@@ -0,0 +1,9 @@
|
|
|
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 };
|
|
@@ -0,0 +1,45 @@
|
|
|
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;
|
|
@@ -0,0 +1,5 @@
|
|
|
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
|
+
declare const returnDecimalSeparatorForLocale: (locale: string | null) => string | undefined;
|
|
5
|
+
export { icelandicNumberLocaleWorkaroundChrome, returnDecimalSeparatorForLocale };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.returnDecimalSeparatorForLocale = exports.icelandicNumberLocaleWorkaroundChrome = void 0;
|
|
4
|
+
var icelandicNumberLocaleWorkaroundChrome = function (value, intl, options) {
|
|
5
|
+
var locale = localStorage.getItem("languageString");
|
|
6
|
+
if (locale) {
|
|
7
|
+
var supportedLocalesArray = Intl.NumberFormat.supportedLocalesOf(locale);
|
|
8
|
+
if (supportedLocalesArray.every(function (x) { return x !== locale; })) {
|
|
9
|
+
switch (locale) {
|
|
10
|
+
case "is":
|
|
11
|
+
if (options) {
|
|
12
|
+
switch (options.style) {
|
|
13
|
+
case "decimal": {
|
|
14
|
+
return convertToIcelandicThousandAndDecimalSeparator(value.toFixed(2));
|
|
15
|
+
}
|
|
16
|
+
case "currency": {
|
|
17
|
+
if (!options.currency) {
|
|
18
|
+
throw new Error("options.currency must be specified if options.style = 'currency'");
|
|
19
|
+
}
|
|
20
|
+
var roundedValue = convertToIcelandicThousandAndDecimalSeparator(Math.round(value).toString());
|
|
21
|
+
var suffix = " ".concat(options.currency);
|
|
22
|
+
return roundedValue + suffix;
|
|
23
|
+
}
|
|
24
|
+
case "percent": {
|
|
25
|
+
var roundedValue = convertToIcelandicThousandAndDecimalSeparator(value.toString());
|
|
26
|
+
var suffix = " %";
|
|
27
|
+
return roundedValue + suffix;
|
|
28
|
+
}
|
|
29
|
+
case "unit": {
|
|
30
|
+
return convertToIcelandicThousandAndDecimalSeparator(value.toString());
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return convertToIcelandicThousandAndDecimalSeparator(value.toString());
|
|
35
|
+
default:
|
|
36
|
+
return intl.formatNumber(value, options);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return intl.formatNumber(value, options);
|
|
41
|
+
};
|
|
42
|
+
exports.icelandicNumberLocaleWorkaroundChrome = icelandicNumberLocaleWorkaroundChrome;
|
|
43
|
+
var convertToIcelandicThousandAndDecimalSeparator = function (value) {
|
|
44
|
+
var parts = value.split(".");
|
|
45
|
+
return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".") + (parts[1] ? "," + parts[1] : ",00");
|
|
46
|
+
};
|
|
47
|
+
var returnDecimalSeparatorForLocale = function (locale) {
|
|
48
|
+
switch (locale) {
|
|
49
|
+
case "is":
|
|
50
|
+
return ",";
|
|
51
|
+
default:
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.returnDecimalSeparatorForLocale = returnDecimalSeparatorForLocale;
|
|
@@ -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;
|
|
@@ -0,0 +1,7 @@
|
|
|
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 };
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.getReferenceIdentifierFieldDefinitions = exports.getReferenceIdentifierOptions = void 0;
|
|
15
|
+
var getReferenceIdentifierFieldDefinitions = function (receiverRequirements) {
|
|
16
|
+
return receiverRequirements ? receiverRequirements.fieldDefinitions.filter(function (fieldRequirement) { return fieldRequirement.key.startsWith("referenceIdentifier"); }) : [];
|
|
17
|
+
};
|
|
18
|
+
exports.getReferenceIdentifierFieldDefinitions = getReferenceIdentifierFieldDefinitions;
|
|
19
|
+
var getReferenceIdentifierOptions = function (receiverRequirements) {
|
|
20
|
+
var referenceIdentifierFieldDefinitions = getReferenceIdentifierFieldDefinitions(receiverRequirements);
|
|
21
|
+
return referenceIdentifierFieldDefinitions.map(function (fieldDefinition) {
|
|
22
|
+
var delimiterIndex = fieldDefinition.key.indexOf(".");
|
|
23
|
+
return __assign(__assign({}, fieldDefinition), { key: fieldDefinition.key.substring(delimiterIndex + 1), originalKey: fieldDefinition.key });
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.getReferenceIdentifierOptions = getReferenceIdentifierOptions;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="lodash" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { AvailableFields } from "../common/types/ReceiverRequirements";
|
|
4
|
+
import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
|
|
5
|
+
import { FormItemProps, ValidateStatus } from "antd/lib/form/FormItem";
|
|
6
|
+
import { NamePath } from "rc-field-form/es/interface";
|
|
7
|
+
import { FormInstance } from "antd/es/form";
|
|
8
|
+
export declare const getFieldRequirements: (receiverRequirements: NewReceiverRequirements, key: AvailableFields) => FieldDefinition | undefined;
|
|
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;
|
|
12
|
+
export declare const getFieldIsRequired: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultIsRequired: boolean) => boolean;
|
|
13
|
+
export interface FormItemPropsWithoutChildren extends Omit<FormItemProps, "children"> {
|
|
14
|
+
}
|
|
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;
|
|
19
|
+
export declare const paymentMeansTypeFieldHasValues: (paymentMeansTypeFieldDefinition: FieldDefinition | undefined) => boolean | undefined;
|