@unimaze/billing 0.21.8 → 0.21.9
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/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +0 -0
- package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +109 -0
- package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.d.ts +14 -0
- package/lib/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.js +73 -0
- package/lib/common/components/invoice-preview/InvoicePreviewInvoiceLines.d.ts +12 -0
- package/lib/common/components/invoice-preview/InvoicePreviewInvoiceLines.js +93 -0
- package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +0 -0
- package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +110 -0
- package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.d.ts +14 -0
- package/lib/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.js +77 -0
- package/lib/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.d.ts +14 -0
- package/lib/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.js +52 -0
- package/lib/common/components/payment-method/index.js +3 -0
- package/lib/unimaze-billing/src/common/components/CommonTranslations.d.ts +1 -29
- package/lib/unimaze-billing/src/common/components/CommonTranslations.js +4 -32
- package/lib/unimaze-billing/src/common/components/attachments/Attachment.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/attachments/AttachmentModal.js +5 -2
- package/lib/unimaze-billing/src/common/components/attachments/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/base-information/AccountingCost.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/base-information/OrderReference.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/base-information/ProjectReference.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.d.ts +6 -1
- package/lib/unimaze-billing/src/common/components/base-information/ReferenceIdentifiers.js +34 -12
- package/lib/unimaze-billing/src/common/components/base-information/index.d.ts +10 -1
- package/lib/unimaze-billing/src/common/components/base-information/index.js +10 -2
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingCalculations.js +3 -5
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.d.ts +4 -1
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingLinePreview.js +45 -25
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/billing-lines/BillingTaxSummary.js +0 -1
- package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.d.ts +6 -1
- package/lib/unimaze-billing/src/common/components/billing-lines/NewBillingLines.js +41 -327
- package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.d.ts +10 -5
- package/lib/unimaze-billing/src/common/components/billing-lines/SingleBillingLine.js +137 -61
- package/lib/unimaze-billing/src/common/components/billing-lines/index.d.ts +3 -6
- package/lib/unimaze-billing/src/common/components/billing-lines/index.js +1 -1
- package/lib/unimaze-billing/src/common/components/customer/CostCenter.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/customer/CustomerContactName.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/customer/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/customer/index.js +7 -9
- package/lib/unimaze-billing/src/common/components/delivery-location/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/form-item/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/input/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/invoice/index.d.ts +3 -1
- package/lib/unimaze-billing/src/common/components/invoice/index.js +21 -14
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfo.js +75 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewCustomerSupplierInfoBox.js +73 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewHeader.js +7 -8
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.d.ts +12 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewInvoiceLines.js +93 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfo.js +77 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewPaymentInfoBox.js +58 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.d.ts +14 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/InvoicePreviewTotalAmountPreview.js +52 -0
- package/lib/unimaze-billing/src/common/components/invoice-preview/index.d.ts +87 -1
- package/lib/unimaze-billing/src/common/components/invoice-preview/index.js +27 -236
- package/lib/unimaze-billing/src/common/components/payment-method/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/supplier/CityAutofill.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/supplier/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/components/supplier/index.js +1 -1
- package/lib/unimaze-billing/src/common/components/welcome-modal/index.d.ts +1 -1
- package/lib/unimaze-billing/src/common/types/AppConfiguration.d.ts +7 -4
- package/lib/unimaze-billing/src/common/types/ReceiverRequirements.d.ts +2 -0
- package/lib/unimaze-billing/src/common/types/ReceiverRequirements.js +2 -0
- package/lib/unimaze-billing/src/create-invoice/index.d.ts +11 -3
- package/lib/unimaze-billing/src/create-invoice/index.js +91 -64
- package/lib/unimaze-billing/src/enums.d.ts +3 -0
- package/lib/unimaze-billing/src/translations/locales/en.json +13 -13
- package/lib/unimaze-billing/src/translations/locales/is.json +8 -8
- package/lib/unimaze-billing/src/translations/locales.d.ts +16 -16
- package/lib/unimaze-billing/src/utils/ApiUtility.d.ts +9 -3
- package/lib/unimaze-billing/src/utils/ApiUtility.js +31 -13
- package/lib/unimaze-billing/src/utils/BillingLineUtility.d.ts +4 -1
- package/lib/unimaze-billing/src/utils/BillingLineUtility.js +36 -4
- package/lib/unimaze-billing/src/utils/ConversionUtility.d.ts +2 -2
- package/lib/unimaze-billing/src/utils/ConversionUtility.js +10 -11
- package/lib/unimaze-billing/src/utils/IntlUtility.d.ts +1 -0
- package/lib/unimaze-billing/src/utils/IntlUtility.js +33 -10
- package/lib/unimaze-billing/src/utils/RequirementsUtility.d.ts +3 -1
- package/lib/unimaze-billing/src/utils/RequirementsUtility.js +49 -1
- package/lib/utils/BillingLineUtility.js +3 -2
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { BillingLineMetadataOverride } from "../common/types/BillingLineMetadata
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { IntlShape } from "react-intl";
|
|
7
7
|
import { DiscountType } from "../common/types/DiscountType";
|
|
8
|
+
import { AvailableTaxCategoryTypeEnum } from "../enums";
|
|
8
9
|
export interface Totals {
|
|
9
10
|
totalTaxableAmount: number;
|
|
10
11
|
totalTaxAmount: number;
|
|
@@ -18,5 +19,7 @@ export declare const calculateTaxableAmount: (discountValue: string | null | und
|
|
|
18
19
|
export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
|
|
19
20
|
export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum | undefined) => number;
|
|
20
21
|
export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum | undefined, taxCategoryTypeTranslated: string) => string;
|
|
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 getCorrectInputNode: (dataIdx: keyof BillingLineMetadataOverride, intl: IntlShape, placeholder: string, required: boolean, addonAfter?: React.ReactNode, mobile?: boolean, value?: any) => React.ReactChild;
|
|
22
23
|
export declare const getTotals: (invoiceLines: BillingLineMetadataOverride[]) => Totals;
|
|
24
|
+
export declare const getTaxCategoryDisabled: (taxCategoryType: AvailableTaxCategoryTypeEnum, outsideVatScope: boolean) => boolean;
|
|
25
|
+
export declare const getFieldNames: (keys: string[], intl: IntlShape) => string[];
|
|
@@ -25,12 +25,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
25
25
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
26
|
};
|
|
27
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;
|
|
28
|
+
exports.getFieldNames = exports.getTaxCategoryDisabled = exports.getTotals = exports.getCorrectInputNode = exports.generateTaxCategoryLabel = exports.calculateTaxPercentage = exports.calculateTaxAmount = exports.calculateTaxableAmount = exports.calculateDiscountAmount = exports.billingLinesFieldsMetadata = void 0;
|
|
29
29
|
var api_1 = require("@unimaze/api-clients/lib/mapi/api");
|
|
30
30
|
var react_1 = __importDefault(require("react"));
|
|
31
31
|
var antd_1 = require("antd");
|
|
32
32
|
var CommonTranslations_1 = require("../common/components/CommonTranslations");
|
|
33
33
|
var ConversionUtility_1 = require("./ConversionUtility");
|
|
34
|
+
var enums_1 = require("../enums");
|
|
35
|
+
var NewBillingLines_1 = require("../common/components/billing-lines/NewBillingLines");
|
|
36
|
+
var lodash_1 = require("lodash");
|
|
34
37
|
var billingLinesFieldsMetadata = function (formInstance) {
|
|
35
38
|
var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
|
|
36
39
|
return billingLinesMetadata.map(function (billingLine) {
|
|
@@ -70,7 +73,7 @@ var calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount,
|
|
|
70
73
|
if (!quantity || !unitPriceAmount) {
|
|
71
74
|
return 0;
|
|
72
75
|
}
|
|
73
|
-
if (discountValue) {
|
|
76
|
+
if ((0, lodash_1.isNaN)(discountValue)) {
|
|
74
77
|
if (discountType === "PERCENTAGE") {
|
|
75
78
|
return quantity * unitPriceAmount * ((100 - parseFloat(discountValue)) / 100);
|
|
76
79
|
}
|
|
@@ -108,12 +111,12 @@ var generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTransla
|
|
|
108
111
|
return taxCategoryType ? "".concat(taxCategoryTypeTranslated, " (").concat((0, exports.calculateTaxPercentage)(taxCategoryType), "%)") : "";
|
|
109
112
|
};
|
|
110
113
|
exports.generateTaxCategoryLabel = generateTaxCategoryLabel;
|
|
111
|
-
var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile) {
|
|
114
|
+
var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile, value) {
|
|
112
115
|
switch (dataIdx) {
|
|
113
116
|
case "quantity":
|
|
114
117
|
case "unitPriceAmount":
|
|
115
118
|
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 }));
|
|
119
|
+
return (react_1.default.createElement(antd_1.InputNumber, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, step: 1, style: { width: "100%" }, placeholder: placeholder, addonAfter: addonAfter, value: value }));
|
|
117
120
|
case "unitOfMeasure":
|
|
118
121
|
return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder, style: { width: mobile ? 64 : "auto" } }, Object.keys(api_1.Units).map(function (unitOfMeasure) {
|
|
119
122
|
if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
|
|
@@ -156,3 +159,32 @@ var getTotals = function (invoiceLines) {
|
|
|
156
159
|
return totals;
|
|
157
160
|
};
|
|
158
161
|
exports.getTotals = getTotals;
|
|
162
|
+
var getTaxCategoryDisabled = function (taxCategoryType, outsideVatScope) {
|
|
163
|
+
switch (taxCategoryType) {
|
|
164
|
+
case enums_1.AvailableTaxCategoryTypeEnum.StandardRated:
|
|
165
|
+
case enums_1.AvailableTaxCategoryTypeEnum.ReducedRated:
|
|
166
|
+
case enums_1.AvailableTaxCategoryTypeEnum.ZeroRated:
|
|
167
|
+
case enums_1.AvailableTaxCategoryTypeEnum.Exempt:
|
|
168
|
+
return outsideVatScope;
|
|
169
|
+
case enums_1.AvailableTaxCategoryTypeEnum.OutsideTaxScope:
|
|
170
|
+
return !outsideVatScope;
|
|
171
|
+
default:
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
exports.getTaxCategoryDisabled = getTaxCategoryDisabled;
|
|
176
|
+
var getFieldNames = function (keys, intl) {
|
|
177
|
+
return keys === null || keys === void 0 ? void 0 : keys.map(function (key) {
|
|
178
|
+
switch (key) {
|
|
179
|
+
case "name":
|
|
180
|
+
return intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_name);
|
|
181
|
+
case "quantity":
|
|
182
|
+
return intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_quantity);
|
|
183
|
+
case "unitPriceAmount":
|
|
184
|
+
return intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_unitPriceAmount);
|
|
185
|
+
default:
|
|
186
|
+
return "";
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
exports.getFieldNames = getFieldNames;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BillingLineMetadata, InvoiceMetadataInput, PartyMetadata } from "@unimaze/api-clients/lib/mapi";
|
|
2
2
|
import { Store } from "antd/es/form/interface";
|
|
3
|
-
import {
|
|
3
|
+
import { ProfileOutput } from "@unimaze/api-clients/lib/wapi2";
|
|
4
4
|
import { PaymentMeansMetadata } from "@unimaze/api-clients/lib/mapi/api";
|
|
5
5
|
export declare const removeEmpty: (obj: any) => any;
|
|
6
6
|
declare const convertToInvoiceMetadataInput: (formValues: Store, invoiceLinesWithCalculations: BillingLineMetadata[], paymentMethod: PaymentMeansMetadata, chosenCustomer: PartyMetadata) => InvoiceMetadataInput;
|
|
7
|
-
declare const profileOutputToPartyMetadata: (
|
|
7
|
+
declare const profileOutputToPartyMetadata: (profileOutput: ProfileOutput) => PartyMetadata;
|
|
8
8
|
declare const convertToReadableKennitala: (isoIdentifier: string) => string;
|
|
9
9
|
export { convertToInvoiceMetadataInput, profileOutputToPartyMetadata, convertToReadableKennitala };
|
|
@@ -194,25 +194,24 @@ var convertToInvoiceMetadataInput = function (formValues, invoiceLinesWithCalcul
|
|
|
194
194
|
return resp;
|
|
195
195
|
};
|
|
196
196
|
exports.convertToInvoiceMetadataInput = convertToInvoiceMetadataInput;
|
|
197
|
-
var profileOutputToPartyMetadata = function (
|
|
198
|
-
|
|
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)) {
|
|
197
|
+
var profileOutputToPartyMetadata = function (profileOutput) {
|
|
198
|
+
if (!profileOutput.participantLegalIsoIdentifier || !profileOutput.participantLegalAddressStreet || !profileOutput.name || !profileOutput.country) {
|
|
200
199
|
var errorMessage = "There was an error with the customer information, please check the application configuration";
|
|
201
200
|
antd_1.message.error(errorMessage);
|
|
202
201
|
throw new Error(errorMessage);
|
|
203
202
|
}
|
|
204
203
|
return {
|
|
205
|
-
identifier:
|
|
204
|
+
identifier: profileOutput.participantLegalIsoIdentifier,
|
|
206
205
|
address: {
|
|
207
|
-
streetNameAndNumber:
|
|
208
|
-
city:
|
|
209
|
-
countryCode:
|
|
210
|
-
postalZone:
|
|
206
|
+
streetNameAndNumber: profileOutput.participantLegalAddressStreet,
|
|
207
|
+
city: profileOutput.participantLegalAddressCity,
|
|
208
|
+
countryCode: profileOutput.country,
|
|
209
|
+
postalZone: profileOutput.participantLegalAddressPostalCode
|
|
211
210
|
},
|
|
212
|
-
name:
|
|
211
|
+
name: profileOutput.name,
|
|
213
212
|
contact: {
|
|
214
|
-
electronicMail:
|
|
215
|
-
telephone:
|
|
213
|
+
electronicMail: profileOutput.email,
|
|
214
|
+
telephone: profileOutput.phoneNumber
|
|
216
215
|
}
|
|
217
216
|
};
|
|
218
217
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IntlShape } from "react-intl";
|
|
2
2
|
import { FormatNumberOptions } from "react-intl/src/types";
|
|
3
3
|
declare const icelandicNumberLocaleWorkaroundChrome: (value: number, intl: IntlShape, options?: FormatNumberOptions) => string;
|
|
4
|
+
export declare const convertToIcelandicThousandAndDecimalSeparator: (value: string, minimumFractionDigits?: number, maximumFractionDigits?: number) => string;
|
|
4
5
|
declare const returnDecimalSeparatorForLocale: (locale: string | null) => string | undefined;
|
|
5
6
|
export { icelandicNumberLocaleWorkaroundChrome, returnDecimalSeparatorForLocale };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.returnDecimalSeparatorForLocale = exports.icelandicNumberLocaleWorkaroundChrome = void 0;
|
|
3
|
+
exports.returnDecimalSeparatorForLocale = exports.icelandicNumberLocaleWorkaroundChrome = exports.convertToIcelandicThousandAndDecimalSeparator = void 0;
|
|
4
4
|
var icelandicNumberLocaleWorkaroundChrome = function (value, intl, options) {
|
|
5
5
|
var locale = localStorage.getItem("languageString");
|
|
6
|
+
var cleanedValue = value === null || value === undefined ? 0 : value;
|
|
6
7
|
if (locale) {
|
|
7
8
|
var supportedLocalesArray = Intl.NumberFormat.supportedLocalesOf(locale);
|
|
8
9
|
if (supportedLocalesArray.every(function (x) { return x !== locale; })) {
|
|
@@ -11,39 +12,61 @@ var icelandicNumberLocaleWorkaroundChrome = function (value, intl, options) {
|
|
|
11
12
|
if (options) {
|
|
12
13
|
switch (options.style) {
|
|
13
14
|
case "decimal": {
|
|
14
|
-
|
|
15
|
+
var decimalPart = options.maximumFractionDigits ? options.maximumFractionDigits : options.minimumFractionDigits ? options.minimumFractionDigits : 2;
|
|
16
|
+
return (0, exports.convertToIcelandicThousandAndDecimalSeparator)(Number(cleanedValue).toFixed(decimalPart), options.minimumFractionDigits, options.maximumFractionDigits);
|
|
15
17
|
}
|
|
16
18
|
case "currency": {
|
|
17
19
|
if (!options.currency) {
|
|
18
20
|
throw new Error("options.currency must be specified if options.style = 'currency'");
|
|
19
21
|
}
|
|
20
|
-
var roundedValue = convertToIcelandicThousandAndDecimalSeparator(Math.round(value).toString());
|
|
22
|
+
var roundedValue = (0, exports.convertToIcelandicThousandAndDecimalSeparator)(Math.round(value).toString());
|
|
21
23
|
var suffix = " ".concat(options.currency);
|
|
22
24
|
return roundedValue + suffix;
|
|
23
25
|
}
|
|
24
26
|
case "percent": {
|
|
25
|
-
var roundedValue = convertToIcelandicThousandAndDecimalSeparator(
|
|
27
|
+
var roundedValue = (0, exports.convertToIcelandicThousandAndDecimalSeparator)(cleanedValue.toString());
|
|
26
28
|
var suffix = " %";
|
|
27
29
|
return roundedValue + suffix;
|
|
28
30
|
}
|
|
29
31
|
case "unit": {
|
|
30
|
-
return convertToIcelandicThousandAndDecimalSeparator(value.toString());
|
|
32
|
+
return (0, exports.convertToIcelandicThousandAndDecimalSeparator)(value.toString());
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
|
-
return convertToIcelandicThousandAndDecimalSeparator(value.toString());
|
|
36
|
+
return (0, exports.convertToIcelandicThousandAndDecimalSeparator)(value.toString());
|
|
35
37
|
default:
|
|
36
|
-
return intl.formatNumber(
|
|
38
|
+
return intl.formatNumber(cleanedValue, options);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
}
|
|
40
|
-
return intl.formatNumber(
|
|
42
|
+
return intl.formatNumber(cleanedValue, options);
|
|
41
43
|
};
|
|
42
44
|
exports.icelandicNumberLocaleWorkaroundChrome = icelandicNumberLocaleWorkaroundChrome;
|
|
43
|
-
var convertToIcelandicThousandAndDecimalSeparator = function (value) {
|
|
45
|
+
var convertToIcelandicThousandAndDecimalSeparator = function (value, minimumFractionDigits, maximumFractionDigits) {
|
|
46
|
+
var _a;
|
|
44
47
|
var parts = value.split(".");
|
|
45
|
-
|
|
48
|
+
if (parts.length === 1)
|
|
49
|
+
return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
50
|
+
if (maximumFractionDigits === 0) {
|
|
51
|
+
return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".");
|
|
52
|
+
}
|
|
53
|
+
var decimalPart = parts[1];
|
|
54
|
+
if (minimumFractionDigits) {
|
|
55
|
+
if ((decimalPart === null || decimalPart === void 0 ? void 0 : decimalPart.length) < minimumFractionDigits) {
|
|
56
|
+
var minimumFractionDigitsDifference = minimumFractionDigits - ((_a = parts[1]) === null || _a === void 0 ? void 0 : _a.length);
|
|
57
|
+
for (var i = 0; i < minimumFractionDigitsDifference; i++) {
|
|
58
|
+
decimalPart += "0";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (maximumFractionDigits) {
|
|
63
|
+
if ((decimalPart === null || decimalPart === void 0 ? void 0 : decimalPart.length) > maximumFractionDigits) {
|
|
64
|
+
decimalPart = decimalPart.substring(0, maximumFractionDigits);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ".") + ",".concat(decimalPart);
|
|
46
68
|
};
|
|
69
|
+
exports.convertToIcelandicThousandAndDecimalSeparator = convertToIcelandicThousandAndDecimalSeparator;
|
|
47
70
|
var returnDecimalSeparatorForLocale = function (locale) {
|
|
48
71
|
switch (locale) {
|
|
49
72
|
case "is":
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AvailableFields } from "../common/types/ReceiverRequirements";
|
|
4
|
-
import { FieldDefinition, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
|
|
4
|
+
import { FieldDefinition, FieldValues, NewReceiverRequirements } from "../common/types/NewReceiverRequirements";
|
|
5
5
|
import { FormItemProps, ValidateStatus } from "antd/lib/form/FormItem";
|
|
6
6
|
import { NamePath } from "rc-field-form/es/interface";
|
|
7
7
|
import { FormInstance } from "antd/es/form";
|
|
8
|
+
import { IntlShape } from "react-intl";
|
|
8
9
|
export declare const getFieldRequirements: (receiverRequirements: NewReceiverRequirements, key: AvailableFields) => FieldDefinition | undefined;
|
|
9
10
|
export declare const getFieldLabelOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabel: string) => string | undefined;
|
|
10
11
|
export declare const getFieldLabelTooltipOverride: (receiverRequirements: NewReceiverRequirements, key: AvailableFields, defaultLabelTooltip: React.ReactNode | string) => React.ReactNode | string | undefined;
|
|
@@ -17,3 +18,4 @@ export declare const debouncedHandleSearchValues: import("lodash").DebouncedFunc
|
|
|
17
18
|
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
19
|
export declare const getRequiredTooltipMessage: (title: string, fieldNames: string[]) => React.ReactNode;
|
|
19
20
|
export declare const paymentMeansTypeFieldHasValues: (paymentMeansTypeFieldDefinition: FieldDefinition | undefined) => boolean | undefined;
|
|
21
|
+
export declare const getCurrencies: (recRequirements: NewReceiverRequirements, intl: IntlShape) => FieldValues[];
|
|
@@ -23,12 +23,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.paymentMeansTypeFieldHasValues = exports.getRequiredTooltipMessage = exports.getInput = exports.debouncedHandleSearchValues = exports.handleValueValidation = exports.getFieldIsRequired = exports.getFieldPlaceholderOverride = exports.getFieldLabelTooltipOverride = exports.getFieldLabelOverride = exports.getFieldRequirements = void 0;
|
|
26
|
+
exports.getCurrencies = exports.paymentMeansTypeFieldHasValues = exports.getRequiredTooltipMessage = exports.getInput = exports.debouncedHandleSearchValues = exports.handleValueValidation = exports.getFieldIsRequired = exports.getFieldPlaceholderOverride = exports.getFieldLabelTooltipOverride = exports.getFieldLabelOverride = exports.getFieldRequirements = void 0;
|
|
27
27
|
var react_1 = __importDefault(require("react"));
|
|
28
|
+
var ReceiverRequirements_1 = require("../common/types/ReceiverRequirements");
|
|
28
29
|
var lodash_1 = require("lodash");
|
|
29
30
|
var axios_1 = __importDefault(require("axios"));
|
|
30
31
|
var ApiUtility_1 = require("./ApiUtility");
|
|
31
32
|
var antd_1 = require("antd");
|
|
33
|
+
var NewBillingLines_1 = require("../common/components/billing-lines/NewBillingLines");
|
|
32
34
|
// export const getReceiverRequirements = (recRequirements: ReceiverRequirements, key: AvailableFields): FieldRequirement => {
|
|
33
35
|
// return recRequirements[key]!;
|
|
34
36
|
// };
|
|
@@ -53,6 +55,9 @@ var antd_1 = require("antd");
|
|
|
53
55
|
// return defaultLabel;
|
|
54
56
|
// };
|
|
55
57
|
var getFieldRequirements = function (receiverRequirements, key) {
|
|
58
|
+
if (key === ReceiverRequirements_1.AvailableFields["referenceIdentifier.*"]) {
|
|
59
|
+
return receiverRequirements ? receiverRequirements.fieldDefinitions.find(function (field) { return field.key.startsWith("referenceIdentifier."); }) : undefined;
|
|
60
|
+
}
|
|
56
61
|
return receiverRequirements ? receiverRequirements.fieldDefinitions.find(function (field) { return field.key === key; }) : undefined;
|
|
57
62
|
};
|
|
58
63
|
exports.getFieldRequirements = getFieldRequirements;
|
|
@@ -187,3 +192,46 @@ var paymentMeansTypeFieldHasValues = function (paymentMeansTypeFieldDefinition)
|
|
|
187
192
|
paymentMeansTypeFieldDefinition.properties.values !== undefined;
|
|
188
193
|
};
|
|
189
194
|
exports.paymentMeansTypeFieldHasValues = paymentMeansTypeFieldHasValues;
|
|
195
|
+
var getCurrencies = function (recRequirements, intl) {
|
|
196
|
+
var currencies = [
|
|
197
|
+
{
|
|
198
|
+
key: "ISK",
|
|
199
|
+
name: intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_currency_ISK),
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
key: "DKK",
|
|
203
|
+
name: intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_currency_DKK),
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
key: "NOK",
|
|
207
|
+
name: intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_currency_NOK),
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
key: "SEK",
|
|
211
|
+
name: intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_currency_SEK),
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
key: "EUR",
|
|
215
|
+
name: intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_currency_EUR),
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
key: "USD",
|
|
219
|
+
name: intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_currency_USD),
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
key: "GBP",
|
|
223
|
+
name: intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_currency_GBP),
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
var currencyCodeRequirements = (0, exports.getFieldRequirements)(recRequirements, ReceiverRequirements_1.AvailableFields.currencyCode);
|
|
227
|
+
if (currencyCodeRequirements &&
|
|
228
|
+
currencyCodeRequirements.properties &&
|
|
229
|
+
currencyCodeRequirements.properties.values &&
|
|
230
|
+
currencyCodeRequirements.properties.values.length > 0) {
|
|
231
|
+
return currencyCodeRequirements.properties.values;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return currencies;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
exports.getCurrencies = getCurrencies;
|
|
@@ -73,9 +73,10 @@ var calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount,
|
|
|
73
73
|
if (!quantity || !unitPriceAmount) {
|
|
74
74
|
return 0;
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
var _discountValue = (0, lodash_1.toNumber)(discountValue);
|
|
77
|
+
if ((0, lodash_1.isNumber)(_discountValue)) {
|
|
77
78
|
if (discountType === "PERCENTAGE") {
|
|
78
|
-
return quantity * unitPriceAmount * ((100 -
|
|
79
|
+
return quantity * unitPriceAmount * ((100 - _discountValue) / 100);
|
|
79
80
|
}
|
|
80
81
|
else {
|
|
81
82
|
return quantity * unitPriceAmount - parseFloat(discountValue);
|