@appcorp/stellar-solutions-invoice-module 0.1.34 → 0.1.36
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.
|
@@ -198,7 +198,7 @@ var useInvoiceState = function () {
|
|
|
198
198
|
delete item.quoteInvoiceId;
|
|
199
199
|
return (__assign(__assign({}, item), { rowTotal: Number(item.quantity) * Number(item.price) }));
|
|
200
200
|
});
|
|
201
|
-
var updatedProducts = __spreadArray([], data.products, true).map(function (item) { return (__assign({}, item)); });
|
|
201
|
+
var updatedProducts = __spreadArray([], data.products, true).map(function (item) { return (__assign(__assign({}, item), { price: item.product.salePrice, id: item.productId, quantity: item.quantity, rowTotal: parseFloat(item.product.salePrice) * parseInt(item.quantity) })); });
|
|
202
202
|
var updatedData = __assign(__assign({}, data), { mode: 'Edit', companyId: data.company.id, services: __spreadArray([], updatedServices, true), products: __spreadArray([], updatedProducts, true) });
|
|
203
203
|
console.log('_>>', updatedData);
|
|
204
204
|
if ((_b = updatedData === null || updatedData === void 0 ? void 0 : updatedData.company) === null || _b === void 0 ? void 0 : _b.name) {
|
|
@@ -307,10 +307,10 @@ var useInvoiceState = function () {
|
|
|
307
307
|
};
|
|
308
308
|
var handleAddItemProduct = function () {
|
|
309
309
|
var newItem = {
|
|
310
|
+
id: '',
|
|
310
311
|
mode: 'Create',
|
|
311
|
-
productId: '',
|
|
312
|
-
quantity: '1',
|
|
313
312
|
price: '',
|
|
313
|
+
quantity: '1',
|
|
314
314
|
rowTotal: '',
|
|
315
315
|
};
|
|
316
316
|
dispatch({
|
|
@@ -465,11 +465,11 @@ var useInvoiceState = function () {
|
|
|
465
465
|
var _b, _c, _d;
|
|
466
466
|
var index = _a.index, key = _a.key, value = _a.value;
|
|
467
467
|
var updatedItems = __spreadArray([], state.products, true);
|
|
468
|
-
if (key === '
|
|
468
|
+
if (key === 'id' && typeof value === 'string') {
|
|
469
469
|
var matchingProduct = products === null || products === void 0 ? void 0 : products.find(function (product) { return product.id === value; });
|
|
470
470
|
if (matchingProduct) {
|
|
471
471
|
var quantity = parseFloat(String(updatedItems[index].quantity)) || 0;
|
|
472
|
-
var rowTotal = (quantity *
|
|
472
|
+
var rowTotal = (quantity * parseFloat(matchingProduct.salePrice)).toFixed(2);
|
|
473
473
|
updatedItems[index] = __assign(__assign({}, updatedItems[index]), (_b = {}, _b[key] = value, _b.price = matchingProduct.salePrice, _b.mode = updatedItems[index].mode === 'Create' ? 'Create' : 'Edit', _b.rowTotal = rowTotal, _b));
|
|
474
474
|
var allServices = state.services;
|
|
475
475
|
var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(allServices, updatedItems);
|
|
@@ -38,7 +38,7 @@ var ProductsSection = function () {
|
|
|
38
38
|
key: k,
|
|
39
39
|
value: val.id,
|
|
40
40
|
});
|
|
41
|
-
}, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: productList, nodeQueryKey: 'productQuery', nodeSelectKey: '
|
|
41
|
+
}, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: productList, nodeQueryKey: 'productQuery', nodeSelectKey: 'id', query: '', selectKey1: 'name', selectedItem: { id: products[index].id } })),
|
|
42
42
|
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value: String(products[index].quantity), type: 'text' }),
|
|
43
43
|
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value: products[index].price, type: 'number' }),
|
|
44
44
|
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeProducts({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value: products[index].rowTotal, type: 'number', readOnly: true }),
|
|
@@ -44,10 +44,10 @@ export interface InvoiceContextType {
|
|
|
44
44
|
updateLoading: boolean;
|
|
45
45
|
}
|
|
46
46
|
export interface Product {
|
|
47
|
-
|
|
48
|
-
quantity: string;
|
|
49
|
-
price: string;
|
|
47
|
+
id: string;
|
|
50
48
|
mode: 'Create' | 'Edit' | '';
|
|
49
|
+
price: string;
|
|
50
|
+
quantity: string;
|
|
51
51
|
rowTotal: string;
|
|
52
52
|
}
|
|
53
53
|
export interface Service {
|
|
@@ -16,14 +16,14 @@ export declare const formValidation: z.ZodObject<{
|
|
|
16
16
|
price: z.ZodOptional<z.ZodString>;
|
|
17
17
|
total: z.ZodOptional<z.ZodString>;
|
|
18
18
|
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
quantity?: string | undefined;
|
|
20
19
|
price?: string | undefined;
|
|
20
|
+
quantity?: string | undefined;
|
|
21
21
|
name?: string | undefined;
|
|
22
22
|
description?: string | undefined;
|
|
23
23
|
total?: string | undefined;
|
|
24
24
|
}, {
|
|
25
|
-
quantity?: string | undefined;
|
|
26
25
|
price?: string | undefined;
|
|
26
|
+
quantity?: string | undefined;
|
|
27
27
|
name?: string | undefined;
|
|
28
28
|
description?: string | undefined;
|
|
29
29
|
total?: string | undefined;
|
|
@@ -32,24 +32,24 @@ export declare const formValidation: z.ZodObject<{
|
|
|
32
32
|
productId: z.ZodOptional<z.ZodString>;
|
|
33
33
|
quantity: z.ZodOptional<z.ZodString>;
|
|
34
34
|
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
productId?: string | undefined;
|
|
36
35
|
quantity?: string | undefined;
|
|
37
|
-
}, {
|
|
38
36
|
productId?: string | undefined;
|
|
37
|
+
}, {
|
|
39
38
|
quantity?: string | undefined;
|
|
39
|
+
productId?: string | undefined;
|
|
40
40
|
}>, "many">;
|
|
41
41
|
}, "strip", z.ZodTypeAny, {
|
|
42
42
|
currency: string;
|
|
43
43
|
date: string;
|
|
44
44
|
expiryDate: string;
|
|
45
45
|
products: {
|
|
46
|
-
productId?: string | undefined;
|
|
47
46
|
quantity?: string | undefined;
|
|
47
|
+
productId?: string | undefined;
|
|
48
48
|
}[];
|
|
49
49
|
ref: string;
|
|
50
50
|
services: {
|
|
51
|
-
quantity?: string | undefined;
|
|
52
51
|
price?: string | undefined;
|
|
52
|
+
quantity?: string | undefined;
|
|
53
53
|
name?: string | undefined;
|
|
54
54
|
description?: string | undefined;
|
|
55
55
|
total?: string | undefined;
|
|
@@ -64,13 +64,13 @@ export declare const formValidation: z.ZodObject<{
|
|
|
64
64
|
date: string;
|
|
65
65
|
expiryDate: string;
|
|
66
66
|
products: {
|
|
67
|
-
productId?: string | undefined;
|
|
68
67
|
quantity?: string | undefined;
|
|
68
|
+
productId?: string | undefined;
|
|
69
69
|
}[];
|
|
70
70
|
ref: string;
|
|
71
71
|
services: {
|
|
72
|
-
quantity?: string | undefined;
|
|
73
72
|
price?: string | undefined;
|
|
73
|
+
quantity?: string | undefined;
|
|
74
74
|
name?: string | undefined;
|
|
75
75
|
description?: string | undefined;
|
|
76
76
|
total?: string | undefined;
|