@unimaze/billing 0.21.5 → 0.21.6
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/attachments/AttachmentModal.js +5 -2
- package/lib/common/components/billing-lines/SingleBillingLine.js +2 -7
- package/lib/common/components/invoice-preview/index.js +2 -1
- package/lib/common/components/supplier/index.js +1 -1
- package/lib/create-invoice/index.js +1 -1
- package/lib/utils/BillingLineUtility.d.ts +1 -1
- package/lib/utils/BillingLineUtility.js +3 -4
- package/lib/utils/IntlUtility.d.ts +1 -0
- package/lib/utils/IntlUtility.js +33 -10
- package/package.json +1 -1
|
@@ -115,7 +115,7 @@ var AttachmentModal = function (props) {
|
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
117
|
React.useEffect(function () {
|
|
118
|
-
var _isSaveAttachmentsDisabled = props.attachments.some(function (attachment) { return attachment.fieldValidation !== "success" || !attachment.description; });
|
|
118
|
+
var _isSaveAttachmentsDisabled = props.attachments.length > 0 ? props.attachments.some(function (attachment) { return attachment.fieldValidation !== "success" || !attachment.description; }) : true;
|
|
119
119
|
setIsSaveAttachmentsDisabled(_isSaveAttachmentsDisabled);
|
|
120
120
|
}, [props.attachments]);
|
|
121
121
|
var verifyAttachment = function (info, uploadSizeLimit, formInstance) {
|
|
@@ -191,7 +191,10 @@ var AttachmentModal = function (props) {
|
|
|
191
191
|
React.createElement(antd_1.Typography.Text, { type: attachment.file.status === "error" ? "danger" : undefined, style: { width: "100%" } }, attachment.file.name),
|
|
192
192
|
React.createElement(lib_1.Form.Item, { name: ["attachments", "file".concat(index + 1), "file"], initialValue: attachment.file, hidden: true }),
|
|
193
193
|
attachment.file.status === "uploading" ? (React.createElement(icons_1.LoadingOutlined, null)) : (React.createElement(antd_1.Typography.Text, { type: attachment.file.status === "error" ? "danger" : undefined },
|
|
194
|
-
React.createElement(icons_1.DeleteOutlined, { onClick: function () {
|
|
194
|
+
React.createElement(icons_1.DeleteOutlined, { onClick: function () {
|
|
195
|
+
props.formInstance.setFieldValue(["attachments", "file".concat(index + 1), "description"], "");
|
|
196
|
+
props.onRemove(attachment.file);
|
|
197
|
+
} })))),
|
|
195
198
|
attachment.fieldValidation === "success" && (React.createElement(lib_1.Form.Item, __assign({}, formLayout_1.fullWidthInput, { rules: [
|
|
196
199
|
{
|
|
197
200
|
required: true,
|
|
@@ -254,14 +254,9 @@ var SingleBillingLine = function (props) {
|
|
|
254
254
|
" ",
|
|
255
255
|
React.createElement(tooltip_1.default, { title: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_taxCategoryType_title) })))),
|
|
256
256
|
React.createElement(antd_1.Col, { span: 12 },
|
|
257
|
-
React.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.discountValue"], defaultIsRequired: false, fieldName: [fieldName, "discountValue"], defaultLabel: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount), verticalLabels: true, onlyLabelOnFirstInList: true, defaultLabelTooltip: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount_helpText),
|
|
258
|
-
{
|
|
259
|
-
pattern: /^\d+(\.\d+)?$/,
|
|
260
|
-
message: "Input must be number",
|
|
261
|
-
},
|
|
262
|
-
], index: index },
|
|
257
|
+
React.createElement(form_item_1.default, { className: "umz_noValidationMessage", receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["invoiceLines.discountValue"], defaultIsRequired: false, fieldName: [fieldName, "discountValue"], defaultLabel: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount), verticalLabels: true, onlyLabelOnFirstInList: true, defaultLabelTooltip: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount_helpText), index: index },
|
|
263
258
|
React.createElement(antd_1.Flex, { gap: "middle", align: "center" },
|
|
264
|
-
(0, BillingLineUtility_1.getCorrectInputNode)("discountValue", props.intl, props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount), (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.discountValue"], false), React.createElement(DiscountTypeSelector_1.default, { fieldName: fieldName, initialValue: discountType, onSelect: discountTypeSelectorOnSelectHandle, formInstance: props.formInstance })
|
|
259
|
+
(0, BillingLineUtility_1.getCorrectInputNode)("discountValue", props.intl, props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount), (0, RequirementsUtility_1.getFieldIsRequired)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.discountValue"], false), React.createElement(DiscountTypeSelector_1.default, { fieldName: fieldName, initialValue: discountType, onSelect: discountTypeSelectorOnSelectHandle, formInstance: props.formInstance })),
|
|
265
260
|
React.createElement(tooltip_1.default, { title: (0, RequirementsUtility_1.getFieldLabelTooltipOverride)(props.receiverRequirements, ReceiverRequirements_1.AvailableFields["invoiceLines.discountValue"], props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_discount_helpText)) }))))),
|
|
266
261
|
React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.fullWidthInput),
|
|
267
262
|
React.createElement(antd_1.Tooltip, { title: addNewLinesTooltip },
|
|
@@ -356,7 +356,8 @@ var InvoicePreview = function (props) {
|
|
|
356
356
|
react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" }, getPaymentMeansValue(props.form.getFieldValue(["invoice", "paymentMeans", "type"]))),
|
|
357
357
|
props.form.getFieldValue(["invoice", "paymentMeans", "domesticTransfer"]) && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
358
358
|
react_1.default.createElement(antd_1.Typography.Text, { type: "secondary" },
|
|
359
|
-
|
|
359
|
+
props.intl.formatMessage(payment_method_1.translationMessages.paymentMethod_labels_domesticTransfer_accountNo),
|
|
360
|
+
":",
|
|
360
361
|
" ",
|
|
361
362
|
props.form.getFieldValue([
|
|
362
363
|
"invoice",
|
|
@@ -252,7 +252,7 @@ var Supplier = function (props) {
|
|
|
252
252
|
required: true,
|
|
253
253
|
message: props.intl.formatMessage(form_item_2.translationMessages.formItem_required_errorMessage),
|
|
254
254
|
},
|
|
255
|
-
], normalize: formatIdentifierInput, validateTrigger: ["onBlur"] },
|
|
255
|
+
], normalize: formatIdentifierInput, validateTrigger: ["onBlur", "onChange"] },
|
|
256
256
|
React.createElement(__1.UmzInput, { receiverRequirements: props.receiverRequirements, receiverRequirementsKey: ReceiverRequirements_1.AvailableFields["supplier.identifier"], defaultPlaceholder: props.intl.formatMessage(exports.translationMessages.supplier_identifier), defaultIsRequired: true, disabled: isLoadingParticipantInfo, onChange: function (value) {
|
|
257
257
|
return debouncerSearch(props.rapiBaseUrl, props.rapiApiKey, value.target.value);
|
|
258
258
|
} })),
|
|
@@ -253,7 +253,7 @@ var CreateInvoiceConstructor = function (props) {
|
|
|
253
253
|
someRequiredFieldsEmpty = function () {
|
|
254
254
|
var _a, _b;
|
|
255
255
|
var referenceIdentifierType = form.getFieldValue(["invoice", "referenceIdentifiers"]);
|
|
256
|
-
return
|
|
256
|
+
return ((_a = referenceIdentifierType[0]) === null || _a === void 0 ? void 0 : _a.code) ? !((_b = referenceIdentifierType[0]) === null || _b === void 0 ? void 0 : _b.value) : false;
|
|
257
257
|
};
|
|
258
258
|
return [4 /*yield*/, form.validateFields(fieldPaths, { validateOnly: validateOnly || true })
|
|
259
259
|
.then(function () {
|
|
@@ -19,7 +19,7 @@ export declare const calculateTaxableAmount: (discountValue: string | null | und
|
|
|
19
19
|
export declare const calculateTaxAmount: (taxableAmount: number, taxPercentage: number) => number;
|
|
20
20
|
export declare const calculateTaxPercentage: (taxCategoryType: TaxCategoryTypeEnum | undefined) => number;
|
|
21
21
|
export declare const generateTaxCategoryLabel: (taxCategoryType: TaxCategoryTypeEnum | undefined, taxCategoryTypeTranslated: string) => string;
|
|
22
|
-
export declare const getCorrectInputNode: (dataIdx: keyof BillingLineMetadataOverride, intl: IntlShape, placeholder: string, required: boolean, addonAfter?: React.ReactNode, mobile?: boolean
|
|
22
|
+
export declare const getCorrectInputNode: (dataIdx: keyof BillingLineMetadataOverride, intl: IntlShape, placeholder: string, required: boolean, addonAfter?: React.ReactNode, mobile?: boolean) => React.ReactChild;
|
|
23
23
|
export declare const getTotals: (invoiceLines: BillingLineMetadataOverride[]) => Totals;
|
|
24
24
|
export declare const getTaxCategoryDisabled: (taxCategoryType: AvailableTaxCategoryTypeEnum, outsideVatScope: boolean) => boolean;
|
|
25
25
|
export declare const getFieldNames: (keys: string[], intl: IntlShape) => string[];
|
|
@@ -33,7 +33,6 @@ var CommonTranslations_1 = require("../common/components/CommonTranslations");
|
|
|
33
33
|
var ConversionUtility_1 = require("./ConversionUtility");
|
|
34
34
|
var enums_1 = require("../enums");
|
|
35
35
|
var NewBillingLines_1 = require("../common/components/billing-lines/NewBillingLines");
|
|
36
|
-
var lodash_1 = require("lodash");
|
|
37
36
|
var billingLinesFieldsMetadata = function (formInstance) {
|
|
38
37
|
var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
|
|
39
38
|
return billingLinesMetadata.map(function (billingLine) {
|
|
@@ -73,7 +72,7 @@ var calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount,
|
|
|
73
72
|
if (!quantity || !unitPriceAmount) {
|
|
74
73
|
return 0;
|
|
75
74
|
}
|
|
76
|
-
if (
|
|
75
|
+
if (discountValue) {
|
|
77
76
|
if (discountType === "PERCENTAGE") {
|
|
78
77
|
return quantity * unitPriceAmount * ((100 - parseFloat(discountValue)) / 100);
|
|
79
78
|
}
|
|
@@ -111,12 +110,12 @@ var generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTransla
|
|
|
111
110
|
return taxCategoryType ? "".concat(taxCategoryTypeTranslated, " (").concat((0, exports.calculateTaxPercentage)(taxCategoryType), "%)") : "";
|
|
112
111
|
};
|
|
113
112
|
exports.generateTaxCategoryLabel = generateTaxCategoryLabel;
|
|
114
|
-
var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile
|
|
113
|
+
var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile) {
|
|
115
114
|
switch (dataIdx) {
|
|
116
115
|
case "quantity":
|
|
117
116
|
case "unitPriceAmount":
|
|
118
117
|
case "discountValue":
|
|
119
|
-
return (react_1.default.createElement(antd_1.InputNumber, { prefix: required ? react_1.default.createElement(antd_1.Typography.Text, { type: "danger" }, "*") : null, step: 1, style: { width: "100%" }, placeholder: placeholder, addonAfter: addonAfter
|
|
118
|
+
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 }));
|
|
120
119
|
case "unitOfMeasure":
|
|
121
120
|
return (react_1.default.createElement(antd_1.Select, { popupMatchSelectWidth: false, placeholder: placeholder, style: { width: mobile ? 64 : "auto" } }, Object.keys(api_1.Units).map(function (unitOfMeasure) {
|
|
122
121
|
if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
|
|
@@ -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 };
|
package/lib/utils/IntlUtility.js
CHANGED
|
@@ -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":
|