@appcorp/stellar-solutions-invoice-module 0.1.7 → 0.1.9
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 +31 -7
- package/base-modules/invoice/actions.js +2 -0
- package/base-modules/invoice/add-service-product-section.js +6 -6
- package/base-modules/invoice/calculate-total.d.ts +5 -0
- package/base-modules/invoice/calculate-total.js +23 -0
- package/base-modules/invoice/constants.js +15 -15
- package/base-modules/invoice/context.js +168 -22
- package/base-modules/invoice/products-form-elements.d.ts +0 -4
- package/base-modules/invoice/products-form-elements.js +32 -41
- package/base-modules/invoice/products-form-section.js +19 -3
- package/base-modules/invoice/reducer.js +19 -3
- package/base-modules/invoice/services-form-elements.d.ts +0 -4
- package/base-modules/invoice/services-form-elements.js +38 -41
- package/base-modules/invoice/services-form-section.js +12 -3
- package/base-modules/invoice/types.d.ts +17 -1
- package/base-modules/invoice/validate.d.ts +6 -6
- package/package.json +1 -1
|
@@ -22,7 +22,9 @@ export declare enum INVOICE_ACTION_TYPES {
|
|
|
22
22
|
SET_DRAWER = "SET_DRAWER",
|
|
23
23
|
SET_COUNT = "SET_COUNT",
|
|
24
24
|
SET_FORM = "SET_FORM",
|
|
25
|
-
SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON"
|
|
25
|
+
SET_DISABLE_SAVE_BUTTON = "SET_DISABLE_SAVE_BUTTON",
|
|
26
|
+
SET_TOTAL_DISCOUNT = "SET_TOTAL_DISCOUNT",
|
|
27
|
+
SET_TOTAL_TAX = "SET_TOTAL_TAX"
|
|
26
28
|
}
|
|
27
29
|
export type InvoiceUpdateFieldAction = {
|
|
28
30
|
type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD;
|
|
@@ -93,23 +95,33 @@ export type InvoiceToggleLoadingAction = {
|
|
|
93
95
|
};
|
|
94
96
|
export type InvoiceAddItemServiceAction = {
|
|
95
97
|
type: INVOICE_ACTION_TYPES.ADD_ITEM_SERVICE;
|
|
96
|
-
payload:
|
|
98
|
+
payload: {
|
|
99
|
+
services: Service[];
|
|
100
|
+
};
|
|
97
101
|
};
|
|
98
102
|
export type InvoiceAddItemProductAction = {
|
|
99
103
|
type: INVOICE_ACTION_TYPES.ADD_ITEM_PRODUCT;
|
|
100
|
-
payload:
|
|
104
|
+
payload: {
|
|
105
|
+
products: Product[];
|
|
106
|
+
};
|
|
101
107
|
};
|
|
102
108
|
export type InvoiceDeleteItemProductAction = {
|
|
103
109
|
type: INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT;
|
|
104
|
-
payload:
|
|
110
|
+
payload: {
|
|
111
|
+
products: Product[];
|
|
112
|
+
};
|
|
105
113
|
};
|
|
106
114
|
export type InvoiceDeleteItemServiceAction = {
|
|
107
115
|
type: INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE;
|
|
108
|
-
payload:
|
|
116
|
+
payload: {
|
|
117
|
+
services: Service[];
|
|
118
|
+
};
|
|
109
119
|
};
|
|
110
120
|
export type InvoiceSetDiscountUnitAction = {
|
|
111
121
|
type: INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT;
|
|
112
|
-
payload:
|
|
122
|
+
payload: {
|
|
123
|
+
discountUnit: string;
|
|
124
|
+
};
|
|
113
125
|
};
|
|
114
126
|
export type InvoiceSetCustomerDataAction = {
|
|
115
127
|
type: INVOICE_ACTION_TYPES.SET_CUSTOMER_DATA;
|
|
@@ -131,4 +143,16 @@ export type InvoiceSetFormAction = {
|
|
|
131
143
|
form: InvoiceTypeBE;
|
|
132
144
|
};
|
|
133
145
|
};
|
|
134
|
-
export type
|
|
146
|
+
export type InvoiceSetTotalDiscountAction = {
|
|
147
|
+
type: INVOICE_ACTION_TYPES.SET_TOTAL_DISCOUNT;
|
|
148
|
+
payload: {
|
|
149
|
+
totalDiscount: string;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export type InvoiceSetTotalTaxAction = {
|
|
153
|
+
type: INVOICE_ACTION_TYPES.SET_TOTAL_TAX;
|
|
154
|
+
payload: {
|
|
155
|
+
totalTax: string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
export type InvoiceActions = InvoiceAddItemProductAction | InvoiceAddItemServiceAction | InvoiceClearErrorAction | InvoiceDeleteItemProductAction | InvoiceDeleteItemServiceAction | InvoiceResetFormAction | InvoiceSetButtonDisableAction | InvoiceSetCurrentPageAction | InvoiceSetCustomerDataAction | InvoiceSetDiscountUnitAction | InvoiceSetErrorsAction | InvoiceSetFormLoadingAction | InvoiceSetInvoicesAction | InvoiceSetInvoiceFormAction | InvoiceSetIsInvoiceApiSuccessAction | InvoiceSetMaxPageLimitAction | InvoiceSetSearchQueryAction | InvoiceUpdateFieldAction | InvoiceToggleLoadingAction | InvoiceSetDrawerAction | InvoiceSetCountAction | InvoiceSetFormAction | InvoiceSetTotalDiscountAction | InvoiceSetTotalTaxAction;
|
|
@@ -26,4 +26,6 @@ var INVOICE_ACTION_TYPES;
|
|
|
26
26
|
INVOICE_ACTION_TYPES["SET_COUNT"] = "SET_COUNT";
|
|
27
27
|
INVOICE_ACTION_TYPES["SET_FORM"] = "SET_FORM";
|
|
28
28
|
INVOICE_ACTION_TYPES["SET_DISABLE_SAVE_BUTTON"] = "SET_DISABLE_SAVE_BUTTON";
|
|
29
|
+
INVOICE_ACTION_TYPES["SET_TOTAL_DISCOUNT"] = "SET_TOTAL_DISCOUNT";
|
|
30
|
+
INVOICE_ACTION_TYPES["SET_TOTAL_TAX"] = "SET_TOTAL_TAX";
|
|
29
31
|
})(INVOICE_ACTION_TYPES || (exports.INVOICE_ACTION_TYPES = INVOICE_ACTION_TYPES = {}));
|
|
@@ -5,17 +5,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AddServiceProductSection = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
|
-
|
|
8
|
+
var context_1 = require("./context");
|
|
9
9
|
var AddServiceProductSection = function () {
|
|
10
|
-
|
|
10
|
+
var _a = (0, context_1.useInvoiceStateContext)(), handleAddItemService = _a.handleAddItemService, handleAddItemProduct = _a.handleAddItemProduct;
|
|
11
11
|
return (react_1.default.createElement("div", { className: "rounded-md border border-dashed border-gray-900 py-[15px] dark:border-white" },
|
|
12
12
|
react_1.default.createElement("div", { className: "flex items-center justify-center gap-2" },
|
|
13
13
|
react_1.default.createElement("div", { className: "flex gap-2" },
|
|
14
14
|
react_1.default.createElement("p", null, "Add a")),
|
|
15
|
-
react_1.default.createElement("button", {
|
|
16
|
-
react_1.default.createElement("p", { className: "cursor-pointer hover:underline" }, "Service")),
|
|
15
|
+
react_1.default.createElement("button", { className: "flex w-fit items-center gap-4", onClick: handleAddItemService, type: "button" },
|
|
16
|
+
react_1.default.createElement("p", { className: "cursor-pointer hover:underline font-bold" }, "Service")),
|
|
17
17
|
react_1.default.createElement("div", { className: "" }, "or"),
|
|
18
|
-
react_1.default.createElement("button", {
|
|
19
|
-
react_1.default.createElement("p", { className: "cursor-pointer hover:underline" }, "Product")))));
|
|
18
|
+
react_1.default.createElement("button", { className: "flex w-fit items-center gap-4", onClick: handleAddItemProduct, type: "button" },
|
|
19
|
+
react_1.default.createElement("p", { className: "cursor-pointer hover:underline font-bold" }, "Product")))));
|
|
20
20
|
};
|
|
21
21
|
exports.AddServiceProductSection = AddServiceProductSection;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.calculateTotal = void 0;
|
|
4
|
+
var calculateTotal = function (subtotal, tax, discountUnit, discount) {
|
|
5
|
+
var subtotalValue = parseFloat(subtotal || '0');
|
|
6
|
+
var taxValue = ((subtotalValue * parseFloat(tax)) / 100).toFixed(2);
|
|
7
|
+
var discountType = discountUnit;
|
|
8
|
+
var discountValue = parseFloat(discount || '0');
|
|
9
|
+
var discountedAmount = discountType === 'percentage-value'
|
|
10
|
+
? (subtotalValue * discountValue) / 100
|
|
11
|
+
: discountValue;
|
|
12
|
+
var totalTaxValue = taxValue;
|
|
13
|
+
var totalDiscountValue = discountedAmount;
|
|
14
|
+
var total = (subtotalValue +
|
|
15
|
+
parseFloat(taxValue) -
|
|
16
|
+
discountedAmount).toFixed(2);
|
|
17
|
+
return {
|
|
18
|
+
totalTaxValue: totalTaxValue,
|
|
19
|
+
totalDiscountValue: totalDiscountValue,
|
|
20
|
+
total: total,
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
exports.calculateTotal = calculateTotal;
|
|
@@ -30,7 +30,6 @@ exports.toastErrors = {
|
|
|
30
30
|
exports.staticCompanySection = (_a = {},
|
|
31
31
|
_a[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1] = [
|
|
32
32
|
{
|
|
33
|
-
disabled: true,
|
|
34
33
|
enabled: true,
|
|
35
34
|
error: '',
|
|
36
35
|
handleOnChange: function () { return void 0; },
|
|
@@ -38,6 +37,7 @@ exports.staticCompanySection = (_a = {},
|
|
|
38
37
|
label: 'Ref',
|
|
39
38
|
order: 6,
|
|
40
39
|
placeholder: '',
|
|
40
|
+
readOnly: true,
|
|
41
41
|
required: true,
|
|
42
42
|
type: 'text',
|
|
43
43
|
value: '',
|
|
@@ -132,7 +132,7 @@ exports.staticPricingSection = (_b = {},
|
|
|
132
132
|
error: '',
|
|
133
133
|
handleOnChange: function () { return void 0; },
|
|
134
134
|
id: 'subTotal',
|
|
135
|
-
label: '',
|
|
135
|
+
label: 'Sub Total',
|
|
136
136
|
order: 1,
|
|
137
137
|
placeholder: '0.00',
|
|
138
138
|
required: false,
|
|
@@ -144,7 +144,7 @@ exports.staticPricingSection = (_b = {},
|
|
|
144
144
|
error: '',
|
|
145
145
|
handleOnChange: function () { return void 0; },
|
|
146
146
|
id: 'discount',
|
|
147
|
-
label: '',
|
|
147
|
+
label: 'Discount',
|
|
148
148
|
order: 3,
|
|
149
149
|
placeholder: '0.00',
|
|
150
150
|
required: false,
|
|
@@ -152,40 +152,40 @@ exports.staticPricingSection = (_b = {},
|
|
|
152
152
|
value: '',
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
|
-
disabled: true,
|
|
156
155
|
enabled: true,
|
|
157
156
|
error: '',
|
|
158
157
|
handleOnChange: function () { return void 0; },
|
|
159
|
-
id: '
|
|
160
|
-
label: '',
|
|
158
|
+
id: 'totalDiscount',
|
|
159
|
+
label: 'After Discount',
|
|
161
160
|
order: 4,
|
|
162
|
-
placeholder: '',
|
|
161
|
+
placeholder: '0.00',
|
|
162
|
+
readOnly: true,
|
|
163
163
|
required: false,
|
|
164
164
|
type: 'text',
|
|
165
165
|
value: '',
|
|
166
166
|
},
|
|
167
167
|
{
|
|
168
|
-
disabled: true,
|
|
169
168
|
enabled: true,
|
|
170
169
|
error: '',
|
|
171
170
|
handleOnChange: function () { return void 0; },
|
|
172
|
-
id: '
|
|
173
|
-
label: '',
|
|
171
|
+
id: 'totalTax',
|
|
172
|
+
label: 'After Tax',
|
|
174
173
|
order: 6,
|
|
175
|
-
placeholder: '',
|
|
174
|
+
placeholder: '0.00',
|
|
175
|
+
readOnly: true,
|
|
176
176
|
required: false,
|
|
177
177
|
type: 'text',
|
|
178
178
|
value: '',
|
|
179
179
|
},
|
|
180
180
|
{
|
|
181
|
-
disabled: true,
|
|
182
181
|
enabled: true,
|
|
183
182
|
error: '',
|
|
184
183
|
handleOnChange: function () { return void 0; },
|
|
185
184
|
id: 'total',
|
|
186
|
-
label: '',
|
|
185
|
+
label: 'Total',
|
|
187
186
|
order: 7,
|
|
188
|
-
placeholder: '
|
|
187
|
+
placeholder: '0.00',
|
|
188
|
+
readOnly: true,
|
|
189
189
|
required: false,
|
|
190
190
|
type: 'text',
|
|
191
191
|
value: '',
|
|
@@ -391,7 +391,7 @@ exports.staticProductSection = (_d = {},
|
|
|
391
391
|
],
|
|
392
392
|
_d);
|
|
393
393
|
exports.INVOICE_API_ROUTES = {
|
|
394
|
-
INVOICES: '/api/quotes-invoices',
|
|
394
|
+
INVOICES: process.env.NODE_ENV === 'production' ? '/api/quotes-invoices' : 'https://stellar-solutions-pattern.vercel.app/api/quotes-invoices',
|
|
395
395
|
INVOICE: '/api/quote-invoice',
|
|
396
396
|
INVOICE_BY_ID: '/api/quote-invoice/quote-invoice-by-id',
|
|
397
397
|
};
|
|
@@ -105,6 +105,7 @@ var calculate_subtotal_1 = require("./calculate-subtotal");
|
|
|
105
105
|
var context_1 = require("@appcorp/stellar-solutions-product-module/base-modules/product/context");
|
|
106
106
|
var context_2 = require("@appcorp/stellar-solutions-company-module/base-modules/company/context");
|
|
107
107
|
var date_fns_1 = require("date-fns");
|
|
108
|
+
var calculate_total_1 = require("./calculate-total");
|
|
108
109
|
var useInvoiceState = function () {
|
|
109
110
|
var _a = (0, react_1.useReducer)(reducer_1.invoiceReducer, reducer_1.initialInvoiceState), state = _a[0], dispatch = _a[1];
|
|
110
111
|
var products = (0, context_1.useProductStateContext)().products;
|
|
@@ -237,6 +238,58 @@ var useInvoiceState = function () {
|
|
|
237
238
|
state.currentPage,
|
|
238
239
|
state.pageLimit,
|
|
239
240
|
]);
|
|
241
|
+
(0, react_1.useEffect)(function () {
|
|
242
|
+
var _a = (0, calculate_total_1.calculateTotal)(state.subTotal, state.taxValue, state.discountUnit, state.discount), totalTaxValue = _a.totalTaxValue, total = _a.total, totalDiscountValue = _a.totalDiscountValue;
|
|
243
|
+
// setTotalTax(totalTaxValue);
|
|
244
|
+
// setTotalDiscount(totalDiscountValue);
|
|
245
|
+
dispatch({
|
|
246
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
247
|
+
payload: {
|
|
248
|
+
key: 'total',
|
|
249
|
+
value: total,
|
|
250
|
+
},
|
|
251
|
+
});
|
|
252
|
+
dispatch({
|
|
253
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_TOTAL_TAX,
|
|
254
|
+
payload: { totalTax: totalTaxValue },
|
|
255
|
+
});
|
|
256
|
+
dispatch({
|
|
257
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_TOTAL_DISCOUNT,
|
|
258
|
+
payload: { totalDiscount: String(totalDiscountValue) },
|
|
259
|
+
});
|
|
260
|
+
}, [
|
|
261
|
+
state.discountUnit,
|
|
262
|
+
state.discount,
|
|
263
|
+
state.subTotal,
|
|
264
|
+
state.taxValue,
|
|
265
|
+
]);
|
|
266
|
+
var handleAddItemService = function () {
|
|
267
|
+
var newItem = {
|
|
268
|
+
mode: 'Create',
|
|
269
|
+
name: '',
|
|
270
|
+
description: '',
|
|
271
|
+
quantity: '1',
|
|
272
|
+
price: '',
|
|
273
|
+
rowTotal: '',
|
|
274
|
+
};
|
|
275
|
+
dispatch({
|
|
276
|
+
type: actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_SERVICE,
|
|
277
|
+
payload: { services: __spreadArray(__spreadArray([], state.services, true), [newItem], false) },
|
|
278
|
+
});
|
|
279
|
+
};
|
|
280
|
+
var handleAddItemProduct = function () {
|
|
281
|
+
var newItem = {
|
|
282
|
+
mode: 'Create',
|
|
283
|
+
productId: '',
|
|
284
|
+
quantity: 1,
|
|
285
|
+
price: '',
|
|
286
|
+
rowTotal: '',
|
|
287
|
+
};
|
|
288
|
+
dispatch({
|
|
289
|
+
type: actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_PRODUCT,
|
|
290
|
+
payload: { products: __spreadArray(__spreadArray([], state.products, true), [newItem], false) },
|
|
291
|
+
});
|
|
292
|
+
};
|
|
240
293
|
var handleCreate = function (text) {
|
|
241
294
|
if (text === 'company') {
|
|
242
295
|
dispatch({
|
|
@@ -436,6 +489,23 @@ var useInvoiceState = function () {
|
|
|
436
489
|
payload: { key: 'products', value: updatedItems },
|
|
437
490
|
});
|
|
438
491
|
}, [state.services, state.products, products]);
|
|
492
|
+
var handlePriceTypeChange = function (k, v) {
|
|
493
|
+
dispatch({
|
|
494
|
+
type: actions_1.INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT,
|
|
495
|
+
payload: { discountUnit: v },
|
|
496
|
+
});
|
|
497
|
+
// if (e.target.value === 'Percentage(%)') {
|
|
498
|
+
// invoiceDispatch({
|
|
499
|
+
// type: INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT,
|
|
500
|
+
// payload: '%',
|
|
501
|
+
// });
|
|
502
|
+
// } else {
|
|
503
|
+
// invoiceDispatch({
|
|
504
|
+
// type: INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT,
|
|
505
|
+
// payload: '',
|
|
506
|
+
// });
|
|
507
|
+
// }
|
|
508
|
+
};
|
|
439
509
|
// const handleSelectInputChange = useCallback(async (key: string, value: string) => {
|
|
440
510
|
// const response = await fetch(INVOICE_CATEGORY_API_ROUTES.INVOICE_CATEGORIES, {
|
|
441
511
|
// method: API_METHODS.POST,
|
|
@@ -548,51 +618,113 @@ var useInvoiceState = function () {
|
|
|
548
618
|
return elements;
|
|
549
619
|
}, [state, handleChange, companies]);
|
|
550
620
|
var dynamicPricingFormElements = (0, react_1.useMemo)(function () {
|
|
621
|
+
var _a, _b, _c, _d, _e, _f;
|
|
551
622
|
var elements = __assign({}, constants_1.staticPricingSection);
|
|
623
|
+
var textElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
624
|
+
if (textElements) {
|
|
625
|
+
textElements[0].value = state.subTotal;
|
|
626
|
+
textElements[0].error = (_b = state.errors) === null || _b === void 0 ? void 0 : _b.subTotal;
|
|
627
|
+
textElements[0].handleOnChange = handleChange;
|
|
628
|
+
textElements[1].value = state.discount;
|
|
629
|
+
textElements[1].error = (_c = state.errors) === null || _c === void 0 ? void 0 : _c.discount;
|
|
630
|
+
textElements[1].handleOnChange = handleChange;
|
|
631
|
+
textElements[2].value = state.totalDiscount ? String(state.totalDiscount) : '0';
|
|
632
|
+
textElements[3].value = isNaN(Number(state.totalTax)) ? '0' : state.totalTax;
|
|
633
|
+
textElements[4].value = isNaN(Number(state.total))
|
|
634
|
+
? '0'
|
|
635
|
+
: String(state.total);
|
|
636
|
+
textElements[4].error = (_d = state.errors) === null || _d === void 0 ? void 0 : _d.total;
|
|
637
|
+
textElements[4].handleOnChange = handleChange;
|
|
638
|
+
}
|
|
639
|
+
var comboboxElements = (_e = elements[form_schema_1.VISTA_FORM_ELEMENTS.COMBOBOX_V1]) === null || _e === void 0 ? void 0 : _e.sort(function (a, b) { return a.order - b.order; });
|
|
640
|
+
if (comboboxElements) {
|
|
641
|
+
comboboxElements[0].selectedItem = { taxName: state.taxValue };
|
|
642
|
+
comboboxElements[0].listItems = [];
|
|
643
|
+
}
|
|
644
|
+
var radioElements = (_f = elements[form_schema_1.VISTA_FORM_ELEMENTS.RADIO_V1]) === null || _f === void 0 ? void 0 : _f.sort(function (a, b) { return a.order - b.order; });
|
|
645
|
+
if (radioElements) {
|
|
646
|
+
radioElements[0].selectedValue = state.discountUnit;
|
|
647
|
+
radioElements[0].handleOnChange = handlePriceTypeChange;
|
|
648
|
+
}
|
|
552
649
|
return elements;
|
|
553
|
-
}, []);
|
|
650
|
+
}, [handleChange, state]);
|
|
651
|
+
var handleDeleteServiceRow = function (i) {
|
|
652
|
+
if (state.services.length > 1) {
|
|
653
|
+
var res = state.services.splice(i, 1);
|
|
654
|
+
dispatch({
|
|
655
|
+
type: actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE,
|
|
656
|
+
payload: { services: __spreadArray([], res, true) },
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
var handleDeleteProductRow = function (i) {
|
|
661
|
+
if (state.products.length > 1) {
|
|
662
|
+
var res = state.products.splice(i, 1);
|
|
663
|
+
dispatch({
|
|
664
|
+
type: actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT,
|
|
665
|
+
payload: { products: __spreadArray([], res, true) },
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
};
|
|
554
669
|
var dynamicServiceFormElements = (0, react_1.useMemo)(function () {
|
|
555
|
-
var _a, _b;
|
|
556
670
|
var elements = __assign({}, constants_1.staticServiceSection);
|
|
557
|
-
var
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
671
|
+
var servicesElements = state.services.map(function () { return (__assign({}, elements)); });
|
|
672
|
+
servicesElements === null || servicesElements === void 0 ? void 0 : servicesElements.map(function (element, i) {
|
|
673
|
+
var _a, _b;
|
|
674
|
+
var textInputElements = (_a = element[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
675
|
+
if (textInputElements) {
|
|
676
|
+
textInputElements[0].value = state.services[i].name;
|
|
561
677
|
textInputElements[0].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
562
678
|
index: i,
|
|
563
679
|
key: k,
|
|
564
680
|
value: v,
|
|
565
681
|
}); };
|
|
566
|
-
|
|
567
|
-
textInputElements[1].value = state.services[0].description;
|
|
682
|
+
textInputElements[1].value = state.services[i].description;
|
|
568
683
|
textInputElements[1].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
569
684
|
index: i,
|
|
570
685
|
key: k,
|
|
571
686
|
value: v,
|
|
572
687
|
}); };
|
|
573
|
-
|
|
574
|
-
textInputElements[2].value = state.services[0].quantity;
|
|
688
|
+
textInputElements[2].value = state.services[i].quantity;
|
|
575
689
|
textInputElements[2].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
576
690
|
index: i,
|
|
577
691
|
key: k,
|
|
578
692
|
value: v,
|
|
579
693
|
}); };
|
|
580
|
-
|
|
581
|
-
textInputElements[3].value = state.services[0].price;
|
|
694
|
+
textInputElements[3].value = state.services[i].price;
|
|
582
695
|
textInputElements[3].handleOnChange = function (k, v) { return handleItemChangeServices({
|
|
583
696
|
index: i,
|
|
584
697
|
key: k,
|
|
585
698
|
value: v,
|
|
586
699
|
}); };
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
700
|
+
textInputElements[4].value = state.services[i].rowTotal;
|
|
701
|
+
}
|
|
702
|
+
// state.services?.forEach((service, i) => {
|
|
703
|
+
// textInputElements[i].error = state.errors[id];
|
|
704
|
+
// textInputElements[i].error = state.errors[id];
|
|
705
|
+
// textInputElements[i].error = state.errors[id];
|
|
706
|
+
// textInputElements[i].error = state.errors[id];
|
|
707
|
+
// textInputElements[i].error = state.errors[id];
|
|
708
|
+
var buttonElements = (_b = element[form_schema_1.VISTA_FORM_ELEMENTS.BUTTON_V1]) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return a.order - b.order; });
|
|
709
|
+
if (buttonElements) {
|
|
710
|
+
// state.services?.forEach((service, i) => {
|
|
711
|
+
buttonElements[0].handleOnClick = function () {
|
|
712
|
+
if (state.services.length > 1) {
|
|
713
|
+
var res = state.services.splice(i, 1);
|
|
714
|
+
dispatch({
|
|
715
|
+
type: actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE,
|
|
716
|
+
payload: { services: __spreadArray([], res, true) },
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
// });
|
|
721
|
+
}
|
|
722
|
+
});
|
|
723
|
+
// }
|
|
724
|
+
return servicesElements;
|
|
593
725
|
}, [state.services, handleItemChangeServices]);
|
|
594
726
|
var dynamicProductFormElements = (0, react_1.useMemo)(function () {
|
|
595
|
-
var _a, _b, _c, _d;
|
|
727
|
+
var _a, _b, _c, _d, _e, _f;
|
|
596
728
|
var elements = __assign({}, constants_1.staticProductSection);
|
|
597
729
|
var textInputElements = (_a = elements[form_schema_1.VISTA_FORM_ELEMENTS.TEXT_INPUT_V1]) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
598
730
|
if (textInputElements) {
|
|
@@ -621,6 +753,20 @@ var useInvoiceState = function () {
|
|
|
621
753
|
};
|
|
622
754
|
});
|
|
623
755
|
}
|
|
756
|
+
var buttonElements = (_e = elements[form_schema_1.VISTA_FORM_ELEMENTS.BUTTON_V1]) === null || _e === void 0 ? void 0 : _e.sort(function (a, b) { return a.order - b.order; });
|
|
757
|
+
if (buttonElements) {
|
|
758
|
+
(_f = state.products) === null || _f === void 0 ? void 0 : _f.forEach(function (product, i) {
|
|
759
|
+
buttonElements[0].handleOnClick = function () {
|
|
760
|
+
if (state.products.length > 1) {
|
|
761
|
+
var res = state.products.splice(i, 1);
|
|
762
|
+
dispatch({
|
|
763
|
+
type: actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT,
|
|
764
|
+
payload: { products: __spreadArray([], res, true) },
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
});
|
|
769
|
+
}
|
|
624
770
|
return elements;
|
|
625
771
|
}, [state, handleItemChangeProducts, products]);
|
|
626
772
|
var headerActions = [
|
|
@@ -653,11 +799,11 @@ var useInvoiceState = function () {
|
|
|
653
799
|
];
|
|
654
800
|
return __assign(__assign({}, state), { byIdError: byIdError, byIdLoading: byIdLoading, clearSearch: clearSearch, closeDrawer: closeDrawer, deleteError: deleteError, deleteLoading: deleteLoading, dispatch: dispatch, dynamicCompanyFormElements: dynamicCompanyFormElements, dynamicPricingFormElements: dynamicPricingFormElements, dynamicProductFormElements: dynamicProductFormElements, dynamicServiceFormElements: dynamicServiceFormElements, handleChange: handleChange, handleNextClick: handleNextClick, handlePageLimit: handlePageLimit, handlePreviousClick: handlePreviousClick, handleSubmit: handleSubmit,
|
|
655
801
|
// handleUploadImage,
|
|
656
|
-
headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, updateError: updateError, updateLoading: updateLoading });
|
|
802
|
+
headerActions: headerActions, listError: listError, listFetchNow: listFetchNow, listLoading: listLoading, rowActions: rowActions, searchOnChange: searchOnChange, updateError: updateError, updateLoading: updateLoading, handleAddItemService: handleAddItemService, handleAddItemProduct: handleAddItemProduct, handleItemChangeServices: handleItemChangeServices, handleDeleteServiceRow: handleDeleteServiceRow, handleItemChangeProducts: handleItemChangeProducts, handleDeleteProductRow: handleDeleteProductRow });
|
|
657
803
|
};
|
|
658
|
-
exports.InvoiceStateContext = (0, react_1.createContext)(__assign(__assign({}, reducer_1.initialInvoiceState), { byIdError: undefined, byIdLoading: false, clearSearch: function () { return void 0; }, closeDrawer: function () { return void 0; }, deleteError: undefined, deleteLoading: false, dispatch: function () { return void 0; }, dynamicCompanyFormElements: {}, dynamicPricingFormElements: {}, dynamicProductFormElements: {}, dynamicServiceFormElements:
|
|
804
|
+
exports.InvoiceStateContext = (0, react_1.createContext)(__assign(__assign({}, reducer_1.initialInvoiceState), { byIdError: undefined, byIdLoading: false, clearSearch: function () { return void 0; }, closeDrawer: function () { return void 0; }, deleteError: undefined, deleteLoading: false, dispatch: function () { return void 0; }, dynamicCompanyFormElements: {}, dynamicPricingFormElements: {}, dynamicProductFormElements: {}, dynamicServiceFormElements: [], handleChange: function () { return void 0; }, handleNextClick: function () { return void 0; }, handlePageLimit: function () { return void 0; }, handlePreviousClick: function () { return void 0; }, handleSubmit: function () { return void 0; },
|
|
659
805
|
// handleUploadImage: () => void 0,
|
|
660
|
-
headerActions: [], listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, rowActions: [], searchOnChange: function () { return void 0; }, updateError: undefined, updateLoading: false }));
|
|
806
|
+
headerActions: [], listError: undefined, listFetchNow: function () { return void 0; }, listLoading: false, rowActions: [], searchOnChange: function () { return void 0; }, updateError: undefined, updateLoading: false, handleAddItemService: function () { return void 0; }, handleAddItemProduct: function () { return void 0; }, handleItemChangeServices: function () { return void 0; }, handleDeleteServiceRow: function () { return void 0; }, handleItemChangeProducts: function () { return void 0; }, handleDeleteProductRow: function () { return void 0; } }));
|
|
661
807
|
var InvoiceStateContextProvider = function (_a) {
|
|
662
808
|
var children = _a.children;
|
|
663
809
|
var state = useInvoiceState();
|
|
@@ -1,41 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}); });
|
|
34
|
-
})) === null || _a === void 0 ? void 0 : _a.sort(function (a, b) { return a.order - b.order; });
|
|
35
|
-
return (react_1.default.createElement("div", { className: "grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] gap-4" }, elementsArray === null || elementsArray === void 0 ? void 0 : elementsArray.map(function (_a, index) {
|
|
36
|
-
var key = _a.key, Component = _a.Component, props = _a.props;
|
|
37
|
-
return (react_1.default.createElement("div", { key: "".concat(key, "-").concat(index), className: props.className },
|
|
38
|
-
react_1.default.createElement(Component, __assign({}, props, row))));
|
|
39
|
-
})));
|
|
40
|
-
};
|
|
41
|
-
exports.renderProductsFormElements = renderProductsFormElements;
|
|
1
|
+
// /* eslint-disable */
|
|
2
|
+
// import React from 'react';
|
|
3
|
+
// import { vistaFormSchema } from '@appcorp/app-corp-vista/utils/form-schema';
|
|
4
|
+
// import { VistaFormElements } from '@appcorp/app-corp-vista/type/vista-form-elements';
|
|
5
|
+
// import { Product } from './types';
|
|
6
|
+
// export const renderProductsFormElements = (
|
|
7
|
+
// elementProps: VistaFormElements,
|
|
8
|
+
// row: Product,
|
|
9
|
+
// ) => {
|
|
10
|
+
// const elementsArray = Object.entries(vistaFormSchema)
|
|
11
|
+
// .flatMap(([key, config]) => {
|
|
12
|
+
// const Component = config;
|
|
13
|
+
// return (elementProps[key as keyof VistaFormElements] || [])
|
|
14
|
+
// ?.filter((props: any) => props.enabled)
|
|
15
|
+
// ?.map((props: any) => ({
|
|
16
|
+
// Component,
|
|
17
|
+
// key,
|
|
18
|
+
// order: props.order,
|
|
19
|
+
// props,
|
|
20
|
+
// }));
|
|
21
|
+
// })
|
|
22
|
+
// ?.sort((a, b) => a.order - b.order);
|
|
23
|
+
// return (
|
|
24
|
+
// <div className="grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] gap-4">
|
|
25
|
+
// {elementsArray?.map(({ key, Component, props }, index) => (
|
|
26
|
+
// <div key={`${key}-${index}`} className={props.className}>
|
|
27
|
+
// <Component {...props} {...row} />
|
|
28
|
+
// </div>
|
|
29
|
+
// ))}
|
|
30
|
+
// </div>
|
|
31
|
+
// );
|
|
32
|
+
// };
|
|
@@ -7,11 +7,27 @@ exports.ProductsSection = void 0;
|
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
8
|
var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
|
|
9
9
|
var context_1 = require("./context");
|
|
10
|
-
var
|
|
10
|
+
var vista_text_input_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-text-input-v1");
|
|
11
|
+
var vista_button_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-button-v1/vista-button-v1");
|
|
12
|
+
var solid_1 = require("@heroicons/react/24/solid");
|
|
13
|
+
var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
|
|
14
|
+
var vista_combobox_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-combobox-v1/vista-combobox-v1");
|
|
15
|
+
var context_2 = require("@appcorp/stellar-solutions-product-module/base-modules/product/context");
|
|
11
16
|
var ProductsSection = function () {
|
|
12
|
-
var _a = (0, context_1.useInvoiceStateContext)(),
|
|
17
|
+
var _a = (0, context_1.useInvoiceStateContext)(), products = _a.products, handleItemChangeProducts = _a.handleItemChangeProducts, handleDeleteServiceRow = _a.handleDeleteServiceRow;
|
|
18
|
+
var productList = (0, context_2.useProductStateContext)().products;
|
|
13
19
|
return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
|
|
14
20
|
react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Products" }),
|
|
15
|
-
products.map(function (row, index) { return (react_1.default.createElement("div", { key: index
|
|
21
|
+
products.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' },
|
|
22
|
+
react_1.default.createElement("div", { className: 'col-span-2' },
|
|
23
|
+
react_1.default.createElement(vista_combobox_v1_1.VistaComboboxV1, { handleInputOnChange: function (k, v) { return handleItemChangeProducts({
|
|
24
|
+
index: index,
|
|
25
|
+
key: k,
|
|
26
|
+
value: v
|
|
27
|
+
}); }, handleOnBlur: function () { return void 0; }, handleOnChange: function () { return void 0; }, label: "Product", listItems: productList, nodeQueryKey: '', nodeSelectKey: 'productId', query: '', selectKey1: 'name', selectedItem: { id: products[index].productId } })),
|
|
28
|
+
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' }),
|
|
29
|
+
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' }),
|
|
30
|
+
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 }),
|
|
31
|
+
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 }))); })));
|
|
16
32
|
};
|
|
17
33
|
exports.ProductsSection = ProductsSection;
|
|
@@ -66,13 +66,15 @@ exports.initialInvoiceState = {
|
|
|
66
66
|
ref: '',
|
|
67
67
|
searchQuery: '',
|
|
68
68
|
subTotal: '',
|
|
69
|
-
taxValue: '',
|
|
69
|
+
taxValue: '17',
|
|
70
70
|
total: '',
|
|
71
|
+
totalDiscount: '',
|
|
72
|
+
totalTax: '',
|
|
71
73
|
services: [
|
|
72
74
|
{
|
|
73
75
|
mode: 'Create',
|
|
74
|
-
name: '',
|
|
75
|
-
description: '',
|
|
76
|
+
name: 'n1',
|
|
77
|
+
description: '1',
|
|
76
78
|
quantity: '1',
|
|
77
79
|
price: '',
|
|
78
80
|
rowTotal: '',
|
|
@@ -139,6 +141,20 @@ function invoiceReducer(state, action) {
|
|
|
139
141
|
// ...state,
|
|
140
142
|
// modal: action.payload.modal,
|
|
141
143
|
// };
|
|
144
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_DISCOUNT_UNIT:
|
|
145
|
+
return __assign(__assign({}, state), { discountUnit: action.payload.discountUnit });
|
|
146
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_TOTAL_DISCOUNT:
|
|
147
|
+
return __assign(__assign({}, state), { totalDiscount: action.payload.totalDiscount });
|
|
148
|
+
case actions_1.INVOICE_ACTION_TYPES.SET_TOTAL_TAX:
|
|
149
|
+
return __assign(__assign({}, state), { totalTax: action.payload.totalTax });
|
|
150
|
+
case actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_SERVICE:
|
|
151
|
+
return __assign(__assign({}, state), { services: __spreadArray([], action.payload.services, true) });
|
|
152
|
+
case actions_1.INVOICE_ACTION_TYPES.ADD_ITEM_PRODUCT:
|
|
153
|
+
return __assign(__assign({}, state), { products: __spreadArray([], action.payload.products, true) });
|
|
154
|
+
case actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_SERVICE:
|
|
155
|
+
return __assign(__assign({}, state), { services: __spreadArray([], action.payload.services, true) });
|
|
156
|
+
case actions_1.INVOICE_ACTION_TYPES.DELETE_ITEM_PRODUCT:
|
|
157
|
+
return __assign(__assign({}, state), { products: __spreadArray([], action.payload.products, true) });
|
|
142
158
|
default:
|
|
143
159
|
return state;
|
|
144
160
|
}
|
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
})));
|
|
40
|
-
};
|
|
41
|
-
exports.renderServicesFormElements = renderServicesFormElements;
|
|
1
|
+
// /* eslint-disable */
|
|
2
|
+
// import React from 'react';
|
|
3
|
+
// import { vistaFormSchema } from '@appcorp/app-corp-vista/utils/form-schema';
|
|
4
|
+
// import { Service } from './types';
|
|
5
|
+
// import { VistaFormElements } from '@appcorp/app-corp-vista/type/vista-form-elements';
|
|
6
|
+
// export const renderServicesFormElements = (
|
|
7
|
+
// elementProps: VistaFormElements,
|
|
8
|
+
// row: Service,
|
|
9
|
+
// ) => {
|
|
10
|
+
// const elementsArray = Object.entries(vistaFormSchema)
|
|
11
|
+
// .flatMap(([key, config]) => {
|
|
12
|
+
// const Component = config;
|
|
13
|
+
// return (elementProps[key as keyof VistaFormElements] || [])
|
|
14
|
+
// ?.filter((props: any) => props.enabled)
|
|
15
|
+
// ?.map((props: any) => ({
|
|
16
|
+
// Component,
|
|
17
|
+
// key,
|
|
18
|
+
// order: props.order,
|
|
19
|
+
// props,
|
|
20
|
+
// }));
|
|
21
|
+
// })
|
|
22
|
+
// ?.sort((a, b) => a.order - b.order);
|
|
23
|
+
// return (
|
|
24
|
+
// <div className="grid grid-cols-[17.5%_17.5%_17.5%_17.5%_17.5%_auto] gap-4">
|
|
25
|
+
// {elementsArray?.map(({ key, Component, props }, index) => {
|
|
26
|
+
// // console.log('_>>', props);
|
|
27
|
+
// return (
|
|
28
|
+
// <div key={`${key}-${index}`} className={props.className}>
|
|
29
|
+
// <Component
|
|
30
|
+
// {...props}
|
|
31
|
+
// {...row}
|
|
32
|
+
// value={row[props.id as keyof Service]}
|
|
33
|
+
// />
|
|
34
|
+
// </div>
|
|
35
|
+
// )})}
|
|
36
|
+
// </div>
|
|
37
|
+
// );
|
|
38
|
+
// };
|
|
@@ -6,12 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ServicesSection = void 0;
|
|
7
7
|
var react_1 = __importDefault(require("react"));
|
|
8
8
|
var vista_vertical_divider_v4_1 = require("@appcorp/app-corp-vista/molecules/vista-vertical-divider-v4");
|
|
9
|
+
var vista_text_input_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-text-input-v1");
|
|
10
|
+
var vista_button_v1_1 = require("@appcorp/app-corp-vista/molecules/vista-button-v1/vista-button-v1");
|
|
11
|
+
var vista_button_type_1 = require("@appcorp/app-corp-vista/type/vista-button-type");
|
|
12
|
+
var solid_1 = require("@heroicons/react/24/solid");
|
|
9
13
|
var context_1 = require("./context");
|
|
10
|
-
var services_form_elements_1 = require("./services-form-elements");
|
|
11
14
|
var ServicesSection = function () {
|
|
12
|
-
var _a = (0, context_1.useInvoiceStateContext)(), services = _a.services,
|
|
15
|
+
var _a = (0, context_1.useInvoiceStateContext)(), services = _a.services, handleItemChangeServices = _a.handleItemChangeServices, handleDeleteServiceRow = _a.handleDeleteServiceRow;
|
|
13
16
|
return (react_1.default.createElement("div", { className: "flex flex-col gap-4" },
|
|
14
17
|
react_1.default.createElement(vista_vertical_divider_v4_1.VistaVerticalDividerV4, { label: "Services" }),
|
|
15
|
-
services.map(function (row, index) { return (react_1.default.createElement("div", { key: index
|
|
18
|
+
services.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: services[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: services[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: services[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: services[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: services[index].rowTotal, type: 'number', readOnly: true }),
|
|
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 }))); })));
|
|
16
25
|
};
|
|
17
26
|
exports.ServicesSection = ServicesSection;
|
|
@@ -15,8 +15,22 @@ export interface InvoiceContextType {
|
|
|
15
15
|
dynamicCompanyFormElements: VistaFormElements;
|
|
16
16
|
dynamicPricingFormElements: VistaFormElements;
|
|
17
17
|
dynamicProductFormElements: VistaFormElements;
|
|
18
|
-
dynamicServiceFormElements: VistaFormElements;
|
|
18
|
+
dynamicServiceFormElements: VistaFormElements[];
|
|
19
|
+
handleAddItemProduct: () => void;
|
|
20
|
+
handleAddItemService: () => void;
|
|
19
21
|
handleChange: (field: string, value: string | number | number[]) => void;
|
|
22
|
+
handleDeleteProductRow: (i: number) => void;
|
|
23
|
+
handleDeleteServiceRow: (i: number) => void;
|
|
24
|
+
handleItemChangeProducts: ({ index, key, value }: {
|
|
25
|
+
index: number;
|
|
26
|
+
key: keyof Product;
|
|
27
|
+
value: string | number;
|
|
28
|
+
}) => void;
|
|
29
|
+
handleItemChangeServices: ({ index, key, value }: {
|
|
30
|
+
index: number;
|
|
31
|
+
key: keyof Service;
|
|
32
|
+
value: string | number;
|
|
33
|
+
}) => void;
|
|
20
34
|
handleNextClick: () => void;
|
|
21
35
|
handlePageLimit: (node: string, value: object) => void;
|
|
22
36
|
handlePreviousClick: () => void;
|
|
@@ -129,6 +143,8 @@ export interface InvoiceState extends Omit<InvoiceTypeBE, 'createdAt' | 'updated
|
|
|
129
143
|
email: string;
|
|
130
144
|
city: string;
|
|
131
145
|
address: string;
|
|
146
|
+
totalTax: string;
|
|
147
|
+
totalDiscount: string;
|
|
132
148
|
}
|
|
133
149
|
export interface FetchInvoicesArgs {
|
|
134
150
|
currentPage: number;
|
|
@@ -11,25 +11,25 @@ export declare const formValidation: z.ZodObject<{
|
|
|
11
11
|
ref: z.ZodOptional<z.ZodString>;
|
|
12
12
|
salePrice: z.ZodString;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
currency: string;
|
|
15
|
-
name: string;
|
|
16
14
|
quantity: string;
|
|
15
|
+
name: string;
|
|
16
|
+
currency: string;
|
|
17
17
|
buyPrice: string;
|
|
18
18
|
productCategoryId: string;
|
|
19
19
|
salePrice: string;
|
|
20
|
-
ref?: string | undefined;
|
|
21
20
|
description?: string | undefined;
|
|
21
|
+
ref?: string | undefined;
|
|
22
22
|
images?: string[] | undefined;
|
|
23
23
|
product?: string | undefined;
|
|
24
24
|
}, {
|
|
25
|
-
currency: string;
|
|
26
|
-
name: string;
|
|
27
25
|
quantity: string;
|
|
26
|
+
name: string;
|
|
27
|
+
currency: string;
|
|
28
28
|
buyPrice: string;
|
|
29
29
|
productCategoryId: string;
|
|
30
30
|
salePrice: string;
|
|
31
|
-
ref?: string | undefined;
|
|
32
31
|
description?: string | undefined;
|
|
32
|
+
ref?: string | undefined;
|
|
33
33
|
images?: string[] | undefined;
|
|
34
34
|
product?: string | undefined;
|
|
35
35
|
}>;
|