@unimaze/billing 0.21.4 → 0.21.5
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/billing-lines/NewNewBillingLines.d.ts +1 -1
- package/lib/common/components/billing-lines/SingleBillingLine.js +15 -2
- package/lib/create-invoice/index.js +1 -1
- package/lib/utils/BillingLineUtility.d.ts +1 -1
- package/lib/utils/BillingLineUtility.js +4 -3
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ interface Props extends WrappedComponentProps {
|
|
|
8
8
|
outsideVatScope: boolean;
|
|
9
9
|
}
|
|
10
10
|
declare const BillingLinesWithIntl: React.ForwardRefExoticComponent<import("react-intl").Omit<Props, "intl"> & {
|
|
11
|
-
forwardedRef?: React.Ref<any
|
|
11
|
+
forwardedRef?: React.Ref<any> | undefined;
|
|
12
12
|
} & React.RefAttributes<any>> & {
|
|
13
13
|
WrappedComponent: React.ComponentType<Props>;
|
|
14
14
|
};
|
|
@@ -107,6 +107,14 @@ var SingleBillingLine = function (props) {
|
|
|
107
107
|
var _h = (0, react_1.useState)(false), isEditing = _h[0], setIsEditing = _h[1];
|
|
108
108
|
var invoiceLines = (0, Form_1.useWatch)(["invoice", "invoiceLines"], props.formInstance);
|
|
109
109
|
var width = (0, react_use_1.useWindowSize)().width;
|
|
110
|
+
(0, react_1.useEffect)(function () {
|
|
111
|
+
if (props.outsideVatScope) {
|
|
112
|
+
setTaxCatType(enums_1.AvailableTaxCategoryTypeEnum.OutsideTaxScope);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
setTaxCatType(enums_1.AvailableTaxCategoryTypeEnum.StandardRated);
|
|
116
|
+
}
|
|
117
|
+
}, [props.outsideVatScope]);
|
|
110
118
|
(0, react_1.useEffect)(function () {
|
|
111
119
|
if (width < 768) {
|
|
112
120
|
setIsMobile(true);
|
|
@@ -246,9 +254,14 @@ var SingleBillingLine = function (props) {
|
|
|
246
254
|
" ",
|
|
247
255
|
React.createElement(tooltip_1.default, { title: props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_taxCategoryType_title) })))),
|
|
248
256
|
React.createElement(antd_1.Col, { span: 12 },
|
|
249
|
-
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),
|
|
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), rules: [
|
|
258
|
+
{
|
|
259
|
+
pattern: /^\d+(\.\d+)?$/,
|
|
260
|
+
message: "Input must be number",
|
|
261
|
+
},
|
|
262
|
+
], index: index },
|
|
250
263
|
React.createElement(antd_1.Flex, { gap: "middle", align: "center" },
|
|
251
|
-
(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 })),
|
|
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 }), false, props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName].discountValue),
|
|
252
265
|
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)) }))))),
|
|
253
266
|
React.createElement(antd_1.Form.Item, __assign({}, formLayout_1.fullWidthInput),
|
|
254
267
|
React.createElement(antd_1.Tooltip, { title: addNewLinesTooltip },
|
|
@@ -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 ((_a = referenceIdentifierType[0]) === null || _a === void 0 ? void 0 : _a.code) ? !((_b = referenceIdentifierType[0]) === null || _b === void 0 ? void 0 : _b.value) : false;
|
|
256
|
+
return referenceIdentifierType ? ((_a = referenceIdentifierType[0]) === null || _a === void 0 ? void 0 : _a.code) ? !((_b = referenceIdentifierType[0]) === null || _b === void 0 ? void 0 : _b.value) : false : 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) => 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;
|
|
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,6 +33,7 @@ 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");
|
|
36
37
|
var billingLinesFieldsMetadata = function (formInstance) {
|
|
37
38
|
var billingLinesMetadata = formInstance.getFieldValue(["invoice", "invoiceLines"]);
|
|
38
39
|
return billingLinesMetadata.map(function (billingLine) {
|
|
@@ -72,7 +73,7 @@ var calculateTaxableAmount = function (discountValue, quantity, unitPriceAmount,
|
|
|
72
73
|
if (!quantity || !unitPriceAmount) {
|
|
73
74
|
return 0;
|
|
74
75
|
}
|
|
75
|
-
if (discountValue) {
|
|
76
|
+
if ((0, lodash_1.isNaN)(discountValue)) {
|
|
76
77
|
if (discountType === "PERCENTAGE") {
|
|
77
78
|
return quantity * unitPriceAmount * ((100 - parseFloat(discountValue)) / 100);
|
|
78
79
|
}
|
|
@@ -110,12 +111,12 @@ var generateTaxCategoryLabel = function (taxCategoryType, taxCategoryTypeTransla
|
|
|
110
111
|
return taxCategoryType ? "".concat(taxCategoryTypeTranslated, " (").concat((0, exports.calculateTaxPercentage)(taxCategoryType), "%)") : "";
|
|
111
112
|
};
|
|
112
113
|
exports.generateTaxCategoryLabel = generateTaxCategoryLabel;
|
|
113
|
-
var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile) {
|
|
114
|
+
var getCorrectInputNode = function (dataIdx, intl, placeholder, required, addonAfter, mobile, value) {
|
|
114
115
|
switch (dataIdx) {
|
|
115
116
|
case "quantity":
|
|
116
117
|
case "unitPriceAmount":
|
|
117
118
|
case "discountValue":
|
|
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 }));
|
|
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 }));
|
|
119
120
|
case "unitOfMeasure":
|
|
120
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) {
|
|
121
122
|
if (unitOfMeasure !== "Rec20" && unitOfMeasure !== "Rec21")
|