@unimaze/billing 0.21.33 → 0.21.34
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/NewBillingLines.js +13 -3
- package/lib/common/components/billing-lines/SingleBillingLine.d.ts +2 -0
- package/lib/common/components/billing-lines/SingleBillingLine.js +25 -17
- package/lib/utils/BillingLineUtility.d.ts +0 -1
- package/lib/utils/BillingLineUtility.js +1 -13
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ var react_intl_1 = require("react-intl");
|
|
|
41
41
|
var antd_1 = require("antd");
|
|
42
42
|
var RequirementsUtility_1 = require("../../../utils/RequirementsUtility");
|
|
43
43
|
var SingleBillingLine_1 = __importDefault(require("./SingleBillingLine"));
|
|
44
|
+
var enums_1 = require("../../../enums");
|
|
44
45
|
exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
45
46
|
billingLines_labels_addButton: {
|
|
46
47
|
id: "billingLines_labels_addButton",
|
|
@@ -173,11 +174,12 @@ exports.translationMessages = (0, react_intl_1.defineMessages)({
|
|
|
173
174
|
});
|
|
174
175
|
var BillingLines = function (props) {
|
|
175
176
|
var invoiceLinesForm = antd_1.Form.useForm()[0];
|
|
176
|
-
var _a = (0,
|
|
177
|
+
var _a = react_1.default.useState(), taxCatType = _a[0], setTaxCatType = _a[1];
|
|
178
|
+
var _b = (0, react_1.useState)({
|
|
177
179
|
invoice: {
|
|
178
180
|
invoiceLines: [{}],
|
|
179
181
|
}
|
|
180
|
-
}), formData =
|
|
182
|
+
}), formData = _b[0], setFormData = _b[1];
|
|
181
183
|
(0, react_1.useEffect)(function () {
|
|
182
184
|
if (!props.formInstance.getFieldValue(["invoice", "currencyCode"])) {
|
|
183
185
|
props.formInstance.setFieldsValue({
|
|
@@ -235,11 +237,19 @@ var BillingLines = function (props) {
|
|
|
235
237
|
var updatedList = lines.filter(function (_, index) { return index !== indexToRemove; });
|
|
236
238
|
updateAllForms(updatedList);
|
|
237
239
|
};
|
|
240
|
+
(0, react_1.useEffect)(function () {
|
|
241
|
+
if (props.outsideVatScope) {
|
|
242
|
+
setTaxCatType(enums_1.AvailableTaxCategoryTypeEnum.OutsideTaxScope);
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
setTaxCatType(enums_1.AvailableTaxCategoryTypeEnum.StandardRated);
|
|
246
|
+
}
|
|
247
|
+
}, [props.outsideVatScope]);
|
|
238
248
|
return (react_1.default.createElement(antd_1.Form, { form: invoiceLinesForm, initialValues: formData },
|
|
239
249
|
react_1.default.createElement(antd_1.Form.List, { name: ["invoice", "invoiceLines"] }, function (fields, _a) {
|
|
240
250
|
var add = _a.add, remove = _a.remove;
|
|
241
251
|
return (react_1.default.createElement(antd_1.Flex, { vertical: true, gap: 20 }, fields.map(function (field, index) {
|
|
242
|
-
return react_1.default.createElement(SingleBillingLine_1.default, { key: "".concat(index + "" + (field === null || field === void 0 ? void 0 : field.key)), fieldName: field.name, index: index, receiverRequirements: props.receiverRequirements, outsideVatScope: props.outsideVatScope, formInstance: invoiceLinesForm, handleAddNewLine: handeAddNewLine, remove: handleRemove });
|
|
252
|
+
return react_1.default.createElement(SingleBillingLine_1.default, { key: "".concat(index + "" + (field === null || field === void 0 ? void 0 : field.key)), fieldName: field.name, index: index, receiverRequirements: props.receiverRequirements, initialTaxCategory: taxCatType, outsideVatScope: props.outsideVatScope, formInstance: invoiceLinesForm, handleAddNewLine: handeAddNewLine, remove: handleRemove });
|
|
243
253
|
})));
|
|
244
254
|
})));
|
|
245
255
|
};
|
|
@@ -2,11 +2,13 @@ import * as React from "react";
|
|
|
2
2
|
import { WrappedComponentProps } from "react-intl";
|
|
3
3
|
import { NewReceiverRequirements } from "../../types/NewReceiverRequirements";
|
|
4
4
|
import { FormInstance } from "antd/es/form";
|
|
5
|
+
import { AvailableTaxCategoryTypeEnum } from "../../../enums";
|
|
5
6
|
interface Props extends WrappedComponentProps {
|
|
6
7
|
fieldName: any;
|
|
7
8
|
index: number;
|
|
8
9
|
receiverRequirements: NewReceiverRequirements;
|
|
9
10
|
outsideVatScope: boolean;
|
|
11
|
+
initialTaxCategory: AvailableTaxCategoryTypeEnum;
|
|
10
12
|
formInstance: FormInstance;
|
|
11
13
|
handleAddNewLine(index: number): void;
|
|
12
14
|
remove: (index: (number | number[])) => void;
|
|
@@ -96,27 +96,36 @@ var lodash_1 = require("lodash");
|
|
|
96
96
|
var Form_1 = require("antd/es/form/Form");
|
|
97
97
|
var react_use_1 = require("react-use");
|
|
98
98
|
var SingleBillingLine = function (props) {
|
|
99
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
99
100
|
var fieldName = props.fieldName, index = props.index, intl = props.intl;
|
|
100
|
-
var
|
|
101
|
-
var
|
|
102
|
-
var
|
|
103
|
-
var
|
|
104
|
-
var
|
|
105
|
-
var
|
|
106
|
-
var
|
|
107
|
-
var _h = (0, react_1.useState)(false), isEditing = _h[0], setIsEditing = _h[1];
|
|
101
|
+
var _m = React.useState(false), isMobile = _m[0], setIsMobile = _m[1];
|
|
102
|
+
var _o = React.useState(false), isCurrencyDisabled = _o[0], setIsCurrencyDisabled = _o[1];
|
|
103
|
+
var _p = React.useState(), taxCatType = _p[0], setTaxCatType = _p[1];
|
|
104
|
+
var _q = React.useState("PERCENTAGE"), discountType = _q[0], setDiscountType = _q[1];
|
|
105
|
+
var _r = (0, react_1.useState)(undefined), addNewLinesTooltip = _r[0], setAddNewLinesTooltip = _r[1];
|
|
106
|
+
var _s = React.useState(true), isSaveButtonDisabled = _s[0], setIsSaveButtonDisabled = _s[1];
|
|
107
|
+
var _t = (0, react_1.useState)(false), isEditing = _t[0], setIsEditing = _t[1];
|
|
108
108
|
var invoiceLines = (0, Form_1.useWatch)(["invoice", "invoiceLines"], props.formInstance);
|
|
109
109
|
var width = (0, react_use_1.useWindowSize)().width;
|
|
110
110
|
(0, react_1.useEffect)(function () {
|
|
111
|
-
if (props.
|
|
112
|
-
setTaxCatType(
|
|
113
|
-
(0, BillingLineUtility_1.assignTaxCategoryToAllLines)(props.formInstance, enums_1.AvailableTaxCategoryTypeEnum.OutsideTaxScope);
|
|
111
|
+
if (props.initialTaxCategory) {
|
|
112
|
+
setTaxCatType(props.initialTaxCategory);
|
|
114
113
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
}, [props.initialTaxCategory]);
|
|
115
|
+
(0, react_1.useEffect)(function () {
|
|
116
|
+
var _a;
|
|
117
|
+
if (taxCatType) {
|
|
118
|
+
props.formInstance.setFieldsValue({
|
|
119
|
+
invoice: {
|
|
120
|
+
invoiceLines: (_a = {},
|
|
121
|
+
_a[index] = {
|
|
122
|
+
taxCategoryType: taxCatType,
|
|
123
|
+
},
|
|
124
|
+
_a),
|
|
125
|
+
},
|
|
126
|
+
});
|
|
118
127
|
}
|
|
119
|
-
}, [
|
|
128
|
+
}, [taxCatType]);
|
|
120
129
|
(0, react_1.useEffect)(function () {
|
|
121
130
|
if (width < 768) {
|
|
122
131
|
setIsMobile(true);
|
|
@@ -132,7 +141,6 @@ var SingleBillingLine = function (props) {
|
|
|
132
141
|
var currentField = lines[fieldName];
|
|
133
142
|
if (currentField) {
|
|
134
143
|
setIsEditing(currentField.editing);
|
|
135
|
-
setField(currentField);
|
|
136
144
|
}
|
|
137
145
|
if ((lines === null || lines === void 0 ? void 0 : lines.length) === 1) {
|
|
138
146
|
setIsCurrencyDisabled(false);
|
|
@@ -272,6 +280,6 @@ var SingleBillingLine = function (props) {
|
|
|
272
280
|
props.intl.formatMessage(NewBillingLines_1.translationMessages.billingLines_labels_addButton))))));
|
|
273
281
|
return (React.createElement(React.Fragment, null, isEditing
|
|
274
282
|
? editingRender
|
|
275
|
-
: React.createElement(BillingLinePreview_1.default, { itemNo:
|
|
283
|
+
: React.createElement(BillingLinePreview_1.default, { itemNo: (_a = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _a === void 0 ? void 0 : _a.itemNo, name: (_b = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _b === void 0 ? void 0 : _b.name, discountValue: (_c = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _c === void 0 ? void 0 : _c.discountValue, discountType: (_d = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _d === void 0 ? void 0 : _d.discountType, taxCategoryType: (_e = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _e === void 0 ? void 0 : _e.taxCategoryType, currencyCode: (_f = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _f === void 0 ? void 0 : _f.currencyCode, onEdit: handleOnEdit, quantity: (_g = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _g === void 0 ? void 0 : _g.quantity, taxableAmount: (_h = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _h === void 0 ? void 0 : _h.taxableAmount, unitPriceAmount: (_j = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _j === void 0 ? void 0 : _j.unitPriceAmount, unit: (_k = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _k === void 0 ? void 0 : _k.unitPriceAmount, unitOfMeasure: (_l = props.formInstance.getFieldValue(["invoice", "invoiceLines"])[fieldName]) === null || _l === void 0 ? void 0 : _l.unitOfMeasure, onDelete: handleRemove })));
|
|
276
284
|
};
|
|
277
285
|
exports.default = (0, react_intl_1.injectIntl)(SingleBillingLine);
|
|
@@ -29,5 +29,4 @@ interface TaxDisplay {
|
|
|
29
29
|
export declare const combinedTaxesForLines: (invoiceLines: BillingLineMetadataOverride[]) => TaxDisplay[];
|
|
30
30
|
export declare const getUnitOfMeasureUnitLabel: (unitOfMeasure: any) => string;
|
|
31
31
|
export declare const getDiscountLabel: (discountValue: string, discountType: string, currencyCode: string, discountText: string) => string;
|
|
32
|
-
export declare const assignTaxCategoryToAllLines: (formInstance: FormInstance, taxToAssign: AvailableTaxCategoryTypeEnum) => void;
|
|
33
32
|
export {};
|
|
@@ -25,7 +25,7 @@ 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.
|
|
28
|
+
exports.getDiscountLabel = exports.getUnitOfMeasureUnitLabel = exports.combinedTaxesForLines = 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 mapi_1 = require("@unimaze/api-clients/lib/mapi");
|
|
30
30
|
var api_1 = require("@unimaze/api-clients/lib/mapi/api");
|
|
31
31
|
var react_1 = __importDefault(require("react"));
|
|
@@ -220,15 +220,3 @@ var getDiscountLabel = function (discountValue, discountType, currencyCode, disc
|
|
|
220
220
|
return "".concat(discountValue).concat(discountType === "PERCENTAGE" ? "%" : " ".concat(currencyCode), " ").concat(discountText);
|
|
221
221
|
};
|
|
222
222
|
exports.getDiscountLabel = getDiscountLabel;
|
|
223
|
-
var assignTaxCategoryToAllLines = function (formInstance, taxToAssign) {
|
|
224
|
-
var clonedLines = (0, lodash_1.cloneDeep)(formInstance.getFieldValue(["invoice", "invoiceLines"]));
|
|
225
|
-
clonedLines.forEach(function (line) {
|
|
226
|
-
line.taxCategoryType = taxToAssign;
|
|
227
|
-
});
|
|
228
|
-
formInstance.setFieldsValue({
|
|
229
|
-
invoice: {
|
|
230
|
-
invoiceLines: clonedLines,
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
exports.assignTaxCategoryToAllLines = assignTaxCategoryToAllLines;
|