@appcorp/stellar-solutions-invoice-module 0.1.51 → 0.1.52
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/base-modules/invoice/actions.d.ts +11 -10
- package/base-modules/invoice/context.js +48 -45
- package/base-modules/invoice/products-form-section.js +6 -6
- package/base-modules/invoice/reducer.js +10 -8
- package/base-modules/invoice/services-form-section.js +7 -7
- package/base-modules/invoice/types.d.ts +32 -39
- package/base-modules/invoice/types.js +16 -31
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ProductTypeBE } from '@appcorp/stellar-solutions-product-module/base-modules/product/types';
|
|
2
|
-
import {
|
|
2
|
+
import { DISCOUNT_UNIT, INVOICE_DRAWER, InvoiceState, QuoteInvoiceTypeBE, Product, Service } from './types';
|
|
3
3
|
import { TaxTypeBE } from '@appcorp/stellar-solutions-modules/global-modules/preferences/types';
|
|
4
4
|
import { CompanyTypeBE } from '@appcorp/stellar-solutions-company-module/base-modules/company/types';
|
|
5
|
+
import { CustomerTypeBE } from '@appcorp/stellar-solutions-company-module/base-modules/customer/types';
|
|
5
6
|
export declare enum INVOICE_ACTION_TYPES {
|
|
6
7
|
ADD_ITEM_PRODUCT = "ADD_ITEM_PRODUCT",
|
|
7
8
|
ADD_ITEM_SERVICE = "ADD_ITEM_SERVICE",
|
|
@@ -38,7 +39,7 @@ export declare enum INVOICE_ACTION_TYPES {
|
|
|
38
39
|
export type InvoiceUpdateFieldAction = {
|
|
39
40
|
type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD;
|
|
40
41
|
payload: {
|
|
41
|
-
key: keyof
|
|
42
|
+
key: keyof QuoteInvoiceTypeBE | 'servicesList' | 'productsList';
|
|
42
43
|
value: string | string[] | boolean | number | number[] | Service[] | Product[];
|
|
43
44
|
};
|
|
44
45
|
};
|
|
@@ -87,7 +88,7 @@ export type InvoiceSetSearchQueryAction = {
|
|
|
87
88
|
export type InvoiceSetInvoicesAction = {
|
|
88
89
|
type: INVOICE_ACTION_TYPES.SET_INVOICES;
|
|
89
90
|
payload: {
|
|
90
|
-
invoices:
|
|
91
|
+
invoices: QuoteInvoiceTypeBE[];
|
|
91
92
|
};
|
|
92
93
|
};
|
|
93
94
|
export type InvoiceSetCountAction = {
|
|
@@ -98,7 +99,7 @@ export type InvoiceSetCountAction = {
|
|
|
98
99
|
};
|
|
99
100
|
export type InvoiceSetInvoiceFormAction = {
|
|
100
101
|
type: INVOICE_ACTION_TYPES.SET_INVOICE_FORM;
|
|
101
|
-
payload:
|
|
102
|
+
payload: QuoteInvoiceTypeBE;
|
|
102
103
|
};
|
|
103
104
|
export type InvoiceToggleLoadingAction = {
|
|
104
105
|
type: INVOICE_ACTION_TYPES.SET_SKELTON_LOADING;
|
|
@@ -107,25 +108,25 @@ export type InvoiceToggleLoadingAction = {
|
|
|
107
108
|
export type InvoiceAddItemServiceAction = {
|
|
108
109
|
type: INVOICE_ACTION_TYPES.ADD_ITEM_SERVICE;
|
|
109
110
|
payload: {
|
|
110
|
-
|
|
111
|
+
servicesList: Service[];
|
|
111
112
|
};
|
|
112
113
|
};
|
|
113
114
|
export type InvoiceAddItemProductAction = {
|
|
114
115
|
type: INVOICE_ACTION_TYPES.ADD_ITEM_PRODUCT;
|
|
115
116
|
payload: {
|
|
116
|
-
|
|
117
|
+
productsList: Product[];
|
|
117
118
|
};
|
|
118
119
|
};
|
|
119
120
|
export type InvoiceDeleteItemProductAction = {
|
|
120
121
|
type: INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT;
|
|
121
122
|
payload: {
|
|
122
|
-
|
|
123
|
+
productsList: Product[];
|
|
123
124
|
};
|
|
124
125
|
};
|
|
125
126
|
export type InvoiceDeleteItemServiceAction = {
|
|
126
127
|
type: INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE;
|
|
127
128
|
payload: {
|
|
128
|
-
|
|
129
|
+
servicesList: Service[];
|
|
129
130
|
};
|
|
130
131
|
};
|
|
131
132
|
export type InvoiceSetDiscountUnitAction = {
|
|
@@ -151,7 +152,7 @@ export type InvoiceSetDrawerAction = {
|
|
|
151
152
|
export type InvoiceSetFormAction = {
|
|
152
153
|
type: INVOICE_ACTION_TYPES.SET_FORM;
|
|
153
154
|
payload: {
|
|
154
|
-
form:
|
|
155
|
+
form: QuoteInvoiceTypeBE;
|
|
155
156
|
};
|
|
156
157
|
};
|
|
157
158
|
export type InvoiceSetAfterDiscountAction = {
|
|
@@ -175,7 +176,7 @@ export type InvoiceSetFormToRenderAction = {
|
|
|
175
176
|
export type InvoiceSetProductsListAction = {
|
|
176
177
|
type: INVOICE_ACTION_TYPES.SET_PRODUCTS_LIST;
|
|
177
178
|
payload: {
|
|
178
|
-
|
|
179
|
+
list: ProductTypeBE[];
|
|
179
180
|
};
|
|
180
181
|
};
|
|
181
182
|
export type InvoiceSetCompaniesListAction = {
|
|
@@ -153,28 +153,31 @@ var useInvoiceState = function () {
|
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
|
-
var updateParams = (0, react_1.useMemo)(function () {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
156
|
+
var updateParams = (0, react_1.useMemo)(function () {
|
|
157
|
+
var _a;
|
|
158
|
+
return ({
|
|
159
|
+
category: state.category,
|
|
160
|
+
companyId: state.companyId,
|
|
161
|
+
currency: state.currency,
|
|
162
|
+
customerId: state.customerId,
|
|
163
|
+
date: state.date,
|
|
164
|
+
discount: (_a = state === null || state === void 0 ? void 0 : state.discount) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
165
|
+
discountUnit: state.discountUnit,
|
|
166
|
+
expiryDate: state.expiryDate,
|
|
167
|
+
id: state.id,
|
|
168
|
+
invoiceStatus: state.invoiceStatus,
|
|
169
|
+
mode: state.mode,
|
|
170
|
+
note: state.note.trim(),
|
|
171
|
+
phone: state.phone,
|
|
172
|
+
products: state.products,
|
|
173
|
+
quoteStatus: state.quoteStatus,
|
|
174
|
+
ref: state.ref,
|
|
175
|
+
services: state.services,
|
|
176
|
+
subTotal: state.subTotal,
|
|
177
|
+
taxRate: state.taxRate,
|
|
178
|
+
total: state.total,
|
|
179
|
+
});
|
|
180
|
+
}, [state]);
|
|
178
181
|
var updateCallback = function (_a) {
|
|
179
182
|
var data = _a.data, error = _a.error;
|
|
180
183
|
if (error) {
|
|
@@ -316,7 +319,7 @@ var useInvoiceState = function () {
|
|
|
316
319
|
if (data === null || data === void 0 ? void 0 : data.items) {
|
|
317
320
|
dispatch({
|
|
318
321
|
type: actions_1.INVOICE_ACTION_TYPES.SET_PRODUCTS_LIST,
|
|
319
|
-
payload: {
|
|
322
|
+
payload: { list: data.items },
|
|
320
323
|
});
|
|
321
324
|
}
|
|
322
325
|
return [2 /*return*/];
|
|
@@ -411,7 +414,7 @@ var useInvoiceState = function () {
|
|
|
411
414
|
}); })();
|
|
412
415
|
}, [debouncedTaxList]);
|
|
413
416
|
(0, react_1.useEffect)(function () {
|
|
414
|
-
var _a = (0, calculate_total_1.calculateTotal)(state.subTotal, state.taxRate, state.discountUnit, state.discount), afterDiscount = _a.afterDiscount, tax = _a.tax, total = _a.total;
|
|
417
|
+
var _a = (0, calculate_total_1.calculateTotal)(state.subTotal, state.taxRate, state.discountUnit, state.discount || '0'), afterDiscount = _a.afterDiscount, tax = _a.tax, total = _a.total;
|
|
415
418
|
dispatch({
|
|
416
419
|
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
417
420
|
payload: {
|
|
@@ -444,7 +447,7 @@ var useInvoiceState = function () {
|
|
|
444
447
|
};
|
|
445
448
|
dispatch({
|
|
446
449
|
type: actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_SERVICE,
|
|
447
|
-
payload: {
|
|
450
|
+
payload: { servicesList: __spreadArray(__spreadArray([], state.servicesList, true), [newItem], false) },
|
|
448
451
|
});
|
|
449
452
|
};
|
|
450
453
|
var handleAddItemProduct = function () {
|
|
@@ -457,7 +460,7 @@ var useInvoiceState = function () {
|
|
|
457
460
|
};
|
|
458
461
|
dispatch({
|
|
459
462
|
type: actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_PRODUCT,
|
|
460
|
-
payload: {
|
|
463
|
+
payload: { productsList: __spreadArray(__spreadArray([], state.productsList, true), [newItem], false) },
|
|
461
464
|
});
|
|
462
465
|
};
|
|
463
466
|
var handleCreate = function (text) {
|
|
@@ -498,7 +501,7 @@ var useInvoiceState = function () {
|
|
|
498
501
|
schema: validate_1.formValidation,
|
|
499
502
|
successCallback: function () {
|
|
500
503
|
updateFetchNow(undefined, {
|
|
501
|
-
body: JSON.stringify(__assign(__assign({}, updateParams), { products:
|
|
504
|
+
body: JSON.stringify(__assign(__assign({}, updateParams), { products: state.getProducts.filter(function (item) { return item.id; }), services: state.servicesList.filter(function (item) { return item.name; }), currency: updateParams.currency || defaultCurrency.code, taxRate: updateParams.taxRate || defaultTax.taxRate })),
|
|
502
505
|
});
|
|
503
506
|
},
|
|
504
507
|
errorCallback: function (e) {
|
|
@@ -508,7 +511,7 @@ var useInvoiceState = function () {
|
|
|
508
511
|
});
|
|
509
512
|
},
|
|
510
513
|
});
|
|
511
|
-
}, [updateFetchNow, updateParams, defaultCurrency, defaultTax]);
|
|
514
|
+
}, [updateFetchNow, updateParams, defaultCurrency, defaultTax, state.getProducts, state.servicesList]);
|
|
512
515
|
var handleChange = (0, react_1.useCallback)(function (key, value) {
|
|
513
516
|
var _a;
|
|
514
517
|
if (key === 'phone') {
|
|
@@ -564,13 +567,13 @@ var useInvoiceState = function () {
|
|
|
564
567
|
var handleItemChangeServices = (0, react_1.useCallback)(function (_a) {
|
|
565
568
|
var _b;
|
|
566
569
|
var index = _a.index, key = _a.key, value = _a.value;
|
|
567
|
-
var updatedItems = __spreadArray([], state.
|
|
570
|
+
var updatedItems = __spreadArray([], state.servicesList, true);
|
|
568
571
|
updatedItems[index] = __assign(__assign({}, updatedItems[index]), (_b = {}, _b[key] = value, _b.mode = updatedItems[index].mode === 'Create' ? 'Create' : 'Edit', _b));
|
|
569
572
|
var quantity = parseFloat(updatedItems[index].quantity) || 0;
|
|
570
573
|
var price = parseFloat(updatedItems[index].price) || 0;
|
|
571
574
|
var rowTotal = (quantity * price).toFixed(2);
|
|
572
575
|
updatedItems[index].rowTotal = rowTotal;
|
|
573
|
-
var allProducts = state.
|
|
576
|
+
var allProducts = state.productsList;
|
|
574
577
|
var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(updatedItems, allProducts);
|
|
575
578
|
dispatch({
|
|
576
579
|
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
@@ -578,21 +581,21 @@ var useInvoiceState = function () {
|
|
|
578
581
|
});
|
|
579
582
|
dispatch({
|
|
580
583
|
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
581
|
-
payload: { key: '
|
|
584
|
+
payload: { key: 'servicesList', value: updatedItems },
|
|
582
585
|
});
|
|
583
|
-
}, [state.
|
|
586
|
+
}, [state.productsList, state.servicesList]);
|
|
584
587
|
var handleItemChangeProducts = (0, react_1.useCallback)(function (_a) {
|
|
585
588
|
var _b, _c, _d;
|
|
586
589
|
var _e;
|
|
587
590
|
var index = _a.index, key = _a.key, value = _a.value;
|
|
588
|
-
var updatedItems = __spreadArray([], state.
|
|
591
|
+
var updatedItems = __spreadArray([], state.productsList, true);
|
|
589
592
|
if (key === 'id' && typeof value === 'string') {
|
|
590
|
-
var matchingProduct = (_e = state.
|
|
593
|
+
var matchingProduct = (_e = state.getProducts) === null || _e === void 0 ? void 0 : _e.find(function (product) { return product.id === value; });
|
|
591
594
|
if (matchingProduct) {
|
|
592
595
|
var quantity = parseFloat(String(updatedItems[index].quantity)) || 0;
|
|
593
596
|
var rowTotal = (quantity * parseFloat(matchingProduct.salePrice)).toFixed(2);
|
|
594
597
|
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));
|
|
595
|
-
var allServices = state.
|
|
598
|
+
var allServices = state.servicesList;
|
|
596
599
|
var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(allServices, updatedItems);
|
|
597
600
|
dispatch({
|
|
598
601
|
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
@@ -609,7 +612,7 @@ var useInvoiceState = function () {
|
|
|
609
612
|
var price = parseFloat(updatedItems[index].price) || 0;
|
|
610
613
|
var rowTotal = (quantity * price).toFixed(2);
|
|
611
614
|
updatedItems[index] = __assign(__assign({}, updatedItems[index]), { rowTotal: rowTotal });
|
|
612
|
-
var allServices = state.
|
|
615
|
+
var allServices = state.servicesList;
|
|
613
616
|
var subtotal = (0, calculate_subtotal_1.calculateSubtotal)(allServices, updatedItems);
|
|
614
617
|
dispatch({
|
|
615
618
|
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
@@ -618,9 +621,9 @@ var useInvoiceState = function () {
|
|
|
618
621
|
}
|
|
619
622
|
dispatch({
|
|
620
623
|
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
621
|
-
payload: { key: '
|
|
624
|
+
payload: { key: 'productsList', value: updatedItems },
|
|
622
625
|
});
|
|
623
|
-
}, [state.
|
|
626
|
+
}, [state.servicesList, state.productsList, state.getProducts]);
|
|
624
627
|
var handlePriceTypeChange = function (k, v) {
|
|
625
628
|
dispatch({
|
|
626
629
|
type: actions_1.INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT,
|
|
@@ -777,7 +780,7 @@ var useInvoiceState = function () {
|
|
|
777
780
|
textElements[0].value = state.subTotal;
|
|
778
781
|
textElements[0].error = (_b = state.errors) === null || _b === void 0 ? void 0 : _b.subTotal;
|
|
779
782
|
textElements[0].handleOnChange = handleChange;
|
|
780
|
-
textElements[1].value = state.discount;
|
|
783
|
+
textElements[1].value = state.discount || '0';
|
|
781
784
|
textElements[1].error = (_c = state.errors) === null || _c === void 0 ? void 0 : _c.discount;
|
|
782
785
|
textElements[1].handleOnChange = handleChange;
|
|
783
786
|
textElements[2].value = state.afterDiscount ? String(state.afterDiscount) : '0';
|
|
@@ -804,20 +807,20 @@ var useInvoiceState = function () {
|
|
|
804
807
|
return elements;
|
|
805
808
|
}, [handleChange, state, taxes, defaultTax]);
|
|
806
809
|
var handleDeleteServiceRow = function (i) {
|
|
807
|
-
if (state.
|
|
808
|
-
var res = state.
|
|
810
|
+
if (state.servicesList.length > 1) {
|
|
811
|
+
var res = state.servicesList.splice(i, 1);
|
|
809
812
|
dispatch({
|
|
810
813
|
type: actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE,
|
|
811
|
-
payload: {
|
|
814
|
+
payload: { servicesList: __spreadArray([], res, true) },
|
|
812
815
|
});
|
|
813
816
|
}
|
|
814
817
|
};
|
|
815
818
|
var handleDeleteProductRow = function (i) {
|
|
816
|
-
if (state.
|
|
817
|
-
var res = state.
|
|
819
|
+
if (state.productsList.length > 1) {
|
|
820
|
+
var res = state.productsList.splice(i, 1);
|
|
818
821
|
dispatch({
|
|
819
822
|
type: actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT,
|
|
820
|
-
payload: {
|
|
823
|
+
payload: { productsList: __spreadArray([], res, true) },
|
|
821
824
|
});
|
|
822
825
|
}
|
|
823
826
|
};
|
|
@@ -24,10 +24,10 @@ var solid_1 = require("@heroicons/react/24/solid");
|
|
|
24
24
|
var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
|
|
25
25
|
var vista_combobox_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-combobox-v1/vista-combobox-v1");
|
|
26
26
|
var ProductsSection = function () {
|
|
27
|
-
var _a = (0, context_1.useInvoiceStateContext)(),
|
|
27
|
+
var _a = (0, context_1.useInvoiceStateContext)(), handleChange = _a.handleChange, handleDeleteServiceRow = _a.handleDeleteServiceRow, handleItemChangeProducts = _a.handleItemChangeProducts, productsList = _a.productsList, getProducts = _a.getProducts;
|
|
28
28
|
return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
|
|
29
29
|
react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Products" }),
|
|
30
|
-
|
|
30
|
+
productsList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: 'grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] items-end justify-between gap-4' },
|
|
31
31
|
react_1.default.createElement("div", { className: 'col-span-2' },
|
|
32
32
|
react_1.default.createElement(vista_combobox_v1_1.VistaComboboxV1, { handleOnChange: function (k, v) {
|
|
33
33
|
var val = __assign({}, v);
|
|
@@ -36,10 +36,10 @@ var ProductsSection = function () {
|
|
|
36
36
|
key: k,
|
|
37
37
|
value: val.id,
|
|
38
38
|
});
|
|
39
|
-
}, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems:
|
|
40
|
-
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(
|
|
41
|
-
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:
|
|
42
|
-
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:
|
|
39
|
+
}, handleOnBlur: handleChange, handleInputOnChange: handleChange, label: "Product", listItems: getProducts, nodeQueryKey: 'productQuery', nodeSelectKey: 'id', query: '', selectKey1: 'name', selectedItem: { id: productsList[index].id } })),
|
|
40
|
+
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(productsList[index].quantity), type: 'text' }),
|
|
41
|
+
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: productsList[index].price, type: 'number' }),
|
|
42
|
+
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: productsList[index].rowTotal, type: 'number', readOnly: true }),
|
|
43
43
|
react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { className: 'flex justify-center items-end', handleOnClick: function () { return handleDeleteServiceRow(index); }, icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON }))); })));
|
|
44
44
|
};
|
|
45
45
|
exports.ProductsSection = ProductsSection;
|
|
@@ -34,6 +34,7 @@ exports.initialInvoiceState = {
|
|
|
34
34
|
count: 0,
|
|
35
35
|
countryQuery: '',
|
|
36
36
|
currency: '',
|
|
37
|
+
services: [],
|
|
37
38
|
customer: {
|
|
38
39
|
address: '',
|
|
39
40
|
city: '',
|
|
@@ -60,6 +61,7 @@ exports.initialInvoiceState = {
|
|
|
60
61
|
invoiceStatus: types_1.INVOICE_STATUS.UNPAID,
|
|
61
62
|
invoices: [],
|
|
62
63
|
loading: true,
|
|
64
|
+
getProducts: [],
|
|
63
65
|
modal: null,
|
|
64
66
|
mode: 'Create',
|
|
65
67
|
netTotal: '',
|
|
@@ -67,7 +69,6 @@ exports.initialInvoiceState = {
|
|
|
67
69
|
pageLimit: constants_1.pageLimit,
|
|
68
70
|
payments: [],
|
|
69
71
|
phone: '',
|
|
70
|
-
productsList: [],
|
|
71
72
|
companiesList: [],
|
|
72
73
|
productQuery: '',
|
|
73
74
|
quoteStatus: types_1.QUOTE_STATUS.DRAFT,
|
|
@@ -79,6 +80,7 @@ exports.initialInvoiceState = {
|
|
|
79
80
|
taxQuery: '',
|
|
80
81
|
taxes: [],
|
|
81
82
|
total: '',
|
|
83
|
+
products: [],
|
|
82
84
|
company: {
|
|
83
85
|
name: '',
|
|
84
86
|
country: '',
|
|
@@ -89,7 +91,7 @@ exports.initialInvoiceState = {
|
|
|
89
91
|
email: '',
|
|
90
92
|
website: '',
|
|
91
93
|
},
|
|
92
|
-
|
|
94
|
+
servicesList: [
|
|
93
95
|
{
|
|
94
96
|
mode: 'Create',
|
|
95
97
|
name: '',
|
|
@@ -99,7 +101,7 @@ exports.initialInvoiceState = {
|
|
|
99
101
|
rowTotal: '',
|
|
100
102
|
},
|
|
101
103
|
],
|
|
102
|
-
|
|
104
|
+
productsList: [
|
|
103
105
|
{
|
|
104
106
|
mode: 'Create',
|
|
105
107
|
price: '',
|
|
@@ -150,15 +152,15 @@ function invoiceReducer(state, action) {
|
|
|
150
152
|
case actions_1.INVOICE_ACTION_TYPES.SET_TAX:
|
|
151
153
|
return __assign(__assign({}, state), { tax: action.payload.tax });
|
|
152
154
|
case actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_SERVICE:
|
|
153
|
-
return __assign(__assign({}, state), {
|
|
155
|
+
return __assign(__assign({}, state), { servicesList: __spreadArray([], action.payload.servicesList, true) });
|
|
154
156
|
case actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_PRODUCT:
|
|
155
|
-
return __assign(__assign({}, state), {
|
|
157
|
+
return __assign(__assign({}, state), { productsList: __spreadArray([], action.payload.productsList, true) });
|
|
156
158
|
case actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE:
|
|
157
|
-
return __assign(__assign({}, state), {
|
|
159
|
+
return __assign(__assign({}, state), { servicesList: __spreadArray([], action.payload.servicesList, true) });
|
|
158
160
|
case actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT:
|
|
159
|
-
return __assign(__assign({}, state), { products: __spreadArray([], action.payload.products, true) });
|
|
160
|
-
case actions_1.INVOICE_ACTION_TYPES.SET_PRODUCTS_LIST:
|
|
161
161
|
return __assign(__assign({}, state), { productsList: __spreadArray([], action.payload.productsList, true) });
|
|
162
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_PRODUCTS_LIST:
|
|
163
|
+
return __assign(__assign({}, state), { getProducts: __spreadArray([], action.payload.list, true) });
|
|
162
164
|
case actions_1.INVOICE_ACTION_TYPES.SET_CUSTOMER:
|
|
163
165
|
return __assign(__assign({}, state), { customerId: state.customerId, customer: __assign(__assign({}, state.customer), action.payload.customer) });
|
|
164
166
|
case actions_1.INVOICE_ACTION_TYPES.SET_CUSTOMER_FORM:
|
|
@@ -12,15 +12,15 @@ var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-typ
|
|
|
12
12
|
var solid_1 = require("@heroicons/react/24/solid");
|
|
13
13
|
var context_1 = require("./context");
|
|
14
14
|
var ServicesSection = function () {
|
|
15
|
-
var _a = (0, context_1.useInvoiceStateContext)(),
|
|
15
|
+
var _a = (0, context_1.useInvoiceStateContext)(), servicesList = _a.servicesList, handleItemChangeServices = _a.handleItemChangeServices, handleDeleteServiceRow = _a.handleDeleteServiceRow;
|
|
16
16
|
return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
|
|
17
17
|
react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Services" }),
|
|
18
|
-
|
|
19
|
-
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'name', label: 'Service Name', placeholder: 'Service Name', value:
|
|
20
|
-
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'description', label: 'Service Description', placeholder: 'Service Description', value:
|
|
21
|
-
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value:
|
|
22
|
-
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value:
|
|
23
|
-
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value:
|
|
18
|
+
servicesList.map(function (row, index) { return (react_1.default.createElement("div", { key: index, className: 'grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] items-end justify-between gap-4' },
|
|
19
|
+
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'name', label: 'Service Name', placeholder: 'Service Name', value: servicesList[index].name, type: 'text' }),
|
|
20
|
+
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'description', label: 'Service Description', placeholder: 'Service Description', value: servicesList[index].description, type: 'text' }),
|
|
21
|
+
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'quantity', label: 'Quantity', placeholder: '1', value: servicesList[index].quantity, type: 'number' }),
|
|
22
|
+
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'price', label: 'Price', placeholder: '0.00', value: servicesList[index].price, type: 'number' }),
|
|
23
|
+
react_1.default.createElement(vista_text_input_v1_1.VistaTextInputV1, { handleOnChange: function (k, v) { return handleItemChangeServices({ index: index, key: k, value: v }); }, id: 'rowTotal', label: 'Row Total', placeholder: '0.00', value: servicesList[index].rowTotal, type: 'number', readOnly: true }),
|
|
24
24
|
react_1.default.createElement(vista_button_v1_1.VistaButtonV1, { className: 'flex justify-center items-end', handleOnClick: function () { return handleDeleteServiceRow(index); }, icon: react_1.default.createElement(solid_1.TrashIcon, { className: "size-6" }), variant: vista_button_type_1.VISTA_BUTTON_VARIANT.ICON }))); })));
|
|
25
25
|
};
|
|
26
26
|
exports.ServicesSection = ServicesSection;
|
|
@@ -7,6 +7,7 @@ import { InvoiceActions } from './actions';
|
|
|
7
7
|
import { ProductTypeBE } from '@appcorp/stellar-solutions-product-module/base-modules/product/types';
|
|
8
8
|
import { ContactTypeBE } from '@appcorp/stellar-solutions-company-module/base-modules/contact/types';
|
|
9
9
|
import { TaxTypeBE } from '@appcorp/stellar-solutions-modules/global-modules/preferences/types';
|
|
10
|
+
import { CustomerTypeBE } from '@appcorp/stellar-solutions-company-module/base-modules/customer/types';
|
|
10
11
|
export interface InvoiceContextType {
|
|
11
12
|
byIdError?: Error;
|
|
12
13
|
byIdLoading: boolean;
|
|
@@ -62,22 +63,11 @@ export interface Service {
|
|
|
62
63
|
mode: 'Create' | 'Edit' | '';
|
|
63
64
|
rowTotal: string;
|
|
64
65
|
}
|
|
65
|
-
export interface CustomerTypeBE {
|
|
66
|
-
address?: string;
|
|
67
|
-
city: string;
|
|
68
|
-
country: string;
|
|
69
|
-
createdAt: string;
|
|
70
|
-
email?: string;
|
|
71
|
-
firstName: string;
|
|
72
|
-
id: string;
|
|
73
|
-
invoices?: InvoiceTypeBE[];
|
|
74
|
-
lastName: string;
|
|
75
|
-
phone: string;
|
|
76
|
-
updatedAt: string;
|
|
77
|
-
}
|
|
78
66
|
export declare enum PAYMENT_MODE {
|
|
79
67
|
}
|
|
80
68
|
export declare enum PAYMENT_TYPE {
|
|
69
|
+
FULL_AMOUNT = "FULL_AMOUNT",
|
|
70
|
+
PARTIAL_AMOUNT = "PARTIAL_AMOUNT"
|
|
81
71
|
}
|
|
82
72
|
export interface PaymentTypeBE {
|
|
83
73
|
amount: string;
|
|
@@ -90,12 +80,23 @@ export interface PaymentTypeBE {
|
|
|
90
80
|
id: string;
|
|
91
81
|
mode: PAYMENT_MODE;
|
|
92
82
|
paymentType: PAYMENT_TYPE;
|
|
93
|
-
quoteInvoice:
|
|
83
|
+
quoteInvoice: QuoteInvoiceTypeBE;
|
|
94
84
|
quoteInvoiceId: string;
|
|
95
85
|
ref?: string;
|
|
96
86
|
updatedAt: string;
|
|
97
87
|
}
|
|
98
|
-
export interface
|
|
88
|
+
export interface ServiceTypeBE {
|
|
89
|
+
createdAt: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
id: string;
|
|
92
|
+
name: string;
|
|
93
|
+
price: string;
|
|
94
|
+
quantity: string;
|
|
95
|
+
quoteInvoice?: QuoteInvoiceTypeBE;
|
|
96
|
+
quoteInvoiceId?: string;
|
|
97
|
+
updatedAt: string;
|
|
98
|
+
}
|
|
99
|
+
export interface QuoteInvoiceTypeBE {
|
|
99
100
|
category: QUOTE_INVOICE_CATEGORY;
|
|
100
101
|
company?: CompanyTypeBE;
|
|
101
102
|
companyId?: string;
|
|
@@ -104,24 +105,32 @@ export interface InvoiceTypeBE {
|
|
|
104
105
|
customer?: CustomerTypeBE;
|
|
105
106
|
customerId?: string;
|
|
106
107
|
date: string;
|
|
107
|
-
discount
|
|
108
|
+
discount?: string;
|
|
108
109
|
discountUnit: DISCOUNT_UNIT;
|
|
109
110
|
expiryDate: string;
|
|
110
111
|
id: string;
|
|
111
112
|
invoiceStatus: INVOICE_STATUS;
|
|
112
113
|
note: string;
|
|
113
114
|
payments: PaymentTypeBE[];
|
|
114
|
-
products:
|
|
115
|
+
products: QuoteInvoiceProduct[];
|
|
115
116
|
quoteStatus: QUOTE_STATUS;
|
|
116
117
|
ref: string;
|
|
117
|
-
services:
|
|
118
|
+
services: ServiceTypeBE[];
|
|
118
119
|
subTotal: string;
|
|
119
120
|
taxRate: string;
|
|
120
121
|
total: string;
|
|
121
122
|
updatedAt: string;
|
|
122
123
|
}
|
|
123
|
-
export interface
|
|
124
|
+
export interface QuoteInvoiceProduct {
|
|
125
|
+
quoteInvoiceId: string;
|
|
126
|
+
productId: string;
|
|
127
|
+
product: ProductTypeBE;
|
|
128
|
+
quoteInvoice: QuoteInvoiceTypeBE;
|
|
129
|
+
quantity: string;
|
|
130
|
+
}
|
|
131
|
+
export interface InvoiceState extends Omit<QuoteInvoiceTypeBE, 'createdAt' | 'updatedAt'> {
|
|
124
132
|
afterDiscount: string;
|
|
133
|
+
companiesList: CompanyTypeBE[];
|
|
125
134
|
companyQuery: string;
|
|
126
135
|
contactsList: ContactTypeBE[];
|
|
127
136
|
count: number;
|
|
@@ -134,7 +143,7 @@ export interface InvoiceState extends Omit<InvoiceTypeBE, 'createdAt' | 'updated
|
|
|
134
143
|
errors: {
|
|
135
144
|
[key: string]: string;
|
|
136
145
|
};
|
|
137
|
-
invoices:
|
|
146
|
+
invoices: QuoteInvoiceTypeBE[];
|
|
138
147
|
loading: boolean;
|
|
139
148
|
modal: null | PRODUCT_MODAL;
|
|
140
149
|
mode: 'Create' | 'Edit';
|
|
@@ -142,13 +151,13 @@ export interface InvoiceState extends Omit<InvoiceTypeBE, 'createdAt' | 'updated
|
|
|
142
151
|
pageLimit: number;
|
|
143
152
|
phone: string;
|
|
144
153
|
productQuery: string;
|
|
145
|
-
|
|
146
|
-
productsList: ProductTypeBE[];
|
|
147
|
-
companiesList: CompanyTypeBE[];
|
|
154
|
+
productsList: Product[];
|
|
148
155
|
searchQuery: string;
|
|
156
|
+
servicesList: Service[];
|
|
149
157
|
tax: string;
|
|
150
158
|
taxQuery: string;
|
|
151
159
|
taxes: TaxTypeBE[];
|
|
160
|
+
getProducts: ProductTypeBE[];
|
|
152
161
|
}
|
|
153
162
|
export interface FetchInvoicesArgs {
|
|
154
163
|
currentPage: number;
|
|
@@ -166,22 +175,6 @@ export declare enum QUOTE_INVOICE_CATEGORY {
|
|
|
166
175
|
QUOTE = "QUOTE",
|
|
167
176
|
INVOICE = "INVOICE"
|
|
168
177
|
}
|
|
169
|
-
export declare enum CURRENCY {
|
|
170
|
-
AUD = "AUD",
|
|
171
|
-
BHD = "BHD",
|
|
172
|
-
CAD = "CAD",
|
|
173
|
-
CNY = "CNY",
|
|
174
|
-
EUR = "EUR",
|
|
175
|
-
GBP = "GBP",
|
|
176
|
-
JOD = "JOD",
|
|
177
|
-
JPY = "JPY",
|
|
178
|
-
KWD = "KWD",
|
|
179
|
-
MYR = "MYR",
|
|
180
|
-
OMR = "OMR",
|
|
181
|
-
PKR = "PKR",
|
|
182
|
-
SAR = "SAR",
|
|
183
|
-
USD = "USD"
|
|
184
|
-
}
|
|
185
178
|
export declare enum INVOICE_STATUS {
|
|
186
179
|
UNPAID = "UNPAID",
|
|
187
180
|
PAID = "PAID"
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DISCOUNT_UNIT = exports.QUOTE_STATUS = exports.INVOICE_STATUS = exports.
|
|
3
|
+
exports.DISCOUNT_UNIT = exports.QUOTE_STATUS = exports.INVOICE_STATUS = exports.QUOTE_INVOICE_CATEGORY = exports.PRODUCT_MODAL = exports.INVOICE_DRAWER = exports.PAYMENT_TYPE = exports.PAYMENT_MODE = void 0;
|
|
4
|
+
// export interface CustomerTypeBE {
|
|
5
|
+
// address?: string;
|
|
6
|
+
// city: string;
|
|
7
|
+
// country: string;
|
|
8
|
+
// createdAt: string;
|
|
9
|
+
// email?: string;
|
|
10
|
+
// firstName: string;
|
|
11
|
+
// id: string;
|
|
12
|
+
// invoices?: InvoiceTypeBE[];
|
|
13
|
+
// lastName: string;
|
|
14
|
+
// phone: string;
|
|
15
|
+
// updatedAt: string;
|
|
16
|
+
// }
|
|
4
17
|
var PAYMENT_MODE;
|
|
5
18
|
(function (PAYMENT_MODE) {
|
|
6
19
|
})(PAYMENT_MODE || (exports.PAYMENT_MODE = PAYMENT_MODE = {}));
|
|
7
20
|
var PAYMENT_TYPE;
|
|
8
21
|
(function (PAYMENT_TYPE) {
|
|
22
|
+
PAYMENT_TYPE["FULL_AMOUNT"] = "FULL_AMOUNT";
|
|
23
|
+
PAYMENT_TYPE["PARTIAL_AMOUNT"] = "PARTIAL_AMOUNT";
|
|
9
24
|
})(PAYMENT_TYPE || (exports.PAYMENT_TYPE = PAYMENT_TYPE = {}));
|
|
10
25
|
var INVOICE_DRAWER;
|
|
11
26
|
(function (INVOICE_DRAWER) {
|
|
@@ -21,23 +36,6 @@ var QUOTE_INVOICE_CATEGORY;
|
|
|
21
36
|
QUOTE_INVOICE_CATEGORY["QUOTE"] = "QUOTE";
|
|
22
37
|
QUOTE_INVOICE_CATEGORY["INVOICE"] = "INVOICE";
|
|
23
38
|
})(QUOTE_INVOICE_CATEGORY || (exports.QUOTE_INVOICE_CATEGORY = QUOTE_INVOICE_CATEGORY = {}));
|
|
24
|
-
var CURRENCY;
|
|
25
|
-
(function (CURRENCY) {
|
|
26
|
-
CURRENCY["AUD"] = "AUD";
|
|
27
|
-
CURRENCY["BHD"] = "BHD";
|
|
28
|
-
CURRENCY["CAD"] = "CAD";
|
|
29
|
-
CURRENCY["CNY"] = "CNY";
|
|
30
|
-
CURRENCY["EUR"] = "EUR";
|
|
31
|
-
CURRENCY["GBP"] = "GBP";
|
|
32
|
-
CURRENCY["JOD"] = "JOD";
|
|
33
|
-
CURRENCY["JPY"] = "JPY";
|
|
34
|
-
CURRENCY["KWD"] = "KWD";
|
|
35
|
-
CURRENCY["MYR"] = "MYR";
|
|
36
|
-
CURRENCY["OMR"] = "OMR";
|
|
37
|
-
CURRENCY["PKR"] = "PKR";
|
|
38
|
-
CURRENCY["SAR"] = "SAR";
|
|
39
|
-
CURRENCY["USD"] = "USD";
|
|
40
|
-
})(CURRENCY || (exports.CURRENCY = CURRENCY = {}));
|
|
41
39
|
var INVOICE_STATUS;
|
|
42
40
|
(function (INVOICE_STATUS) {
|
|
43
41
|
INVOICE_STATUS["UNPAID"] = "UNPAID";
|
|
@@ -56,16 +54,3 @@ var DISCOUNT_UNIT;
|
|
|
56
54
|
DISCOUNT_UNIT["FIXED_VALUE"] = "FIXED_VALUE";
|
|
57
55
|
DISCOUNT_UNIT["PERCENTAGE_VALUE"] = "PERCENTAGE_VALUE";
|
|
58
56
|
})(DISCOUNT_UNIT || (exports.DISCOUNT_UNIT = DISCOUNT_UNIT = {}));
|
|
59
|
-
// export interface CustomerTypeBE {
|
|
60
|
-
// address?: string;
|
|
61
|
-
// city: string;
|
|
62
|
-
// country: string;
|
|
63
|
-
// createdAt: string;
|
|
64
|
-
// email?: string;
|
|
65
|
-
// firstName: string;
|
|
66
|
-
// id: string;
|
|
67
|
-
// invoices?: InvoiceTypeBE[]
|
|
68
|
-
// lastName: string;
|
|
69
|
-
// phone: string;
|
|
70
|
-
// updatedAt: string;
|
|
71
|
-
// }
|
package/package.json
CHANGED