@appcorp/stellar-solutions-invoice-module 0.1.28 → 0.1.30
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/constants.d.ts +21 -8
- package/base-modules/invoice/constants.js +23 -10
- package/base-modules/invoice/context.js +10 -35
- package/base-modules/invoice/invoice.js +1 -1
- package/base-modules/invoice/validate.d.ts +76 -28
- package/base-modules/invoice/validate.js +42 -10
- package/package.json +2 -2
|
@@ -38,13 +38,26 @@ export declare const tableBodyCols: ({
|
|
|
38
38
|
key?: undefined;
|
|
39
39
|
expression?: undefined;
|
|
40
40
|
})[];
|
|
41
|
-
export declare const
|
|
42
|
-
|
|
41
|
+
export declare const validationErrors: {
|
|
42
|
+
companyId: string;
|
|
43
|
+
ref: string;
|
|
44
|
+
status: string;
|
|
45
|
+
date: string;
|
|
46
|
+
expiryDate: string;
|
|
47
|
+
note: string;
|
|
43
48
|
currency: string;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
total: string;
|
|
50
|
+
subTotal: string;
|
|
51
|
+
taxRate: string;
|
|
52
|
+
services: {
|
|
53
|
+
name: string;
|
|
54
|
+
description: string;
|
|
55
|
+
quantity: string;
|
|
56
|
+
price: string;
|
|
57
|
+
total: string;
|
|
58
|
+
};
|
|
59
|
+
products: {
|
|
60
|
+
id: string;
|
|
61
|
+
quantity: string;
|
|
62
|
+
};
|
|
50
63
|
};
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
var _a, _b, _c, _d, _e;
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
7
|
+
exports.validationErrors = exports.tableBodyCols = exports.INVOICE_API_ROUTES = exports.staticProductSection = exports.staticServiceSection = exports.staticPricingSection = exports.staticCustomerSection = exports.staticCompanySection = exports.toastErrors = exports.changeActionsMap = exports.handleSplitId = exports.pageLimit = void 0;
|
|
8
8
|
var react_1 = __importDefault(require("react"));
|
|
9
9
|
var util_functions_1 = require("@react-pakistan/util-functions");
|
|
10
10
|
var form_schema_1 = require("@appcorp/app-corp-vista/utils/form-schema");
|
|
@@ -550,13 +550,26 @@ exports.tableBodyCols = [
|
|
|
550
550
|
componentType: vista_table_type_1.VISTA_TABLE_CELL_TYPE.ACTIONS,
|
|
551
551
|
},
|
|
552
552
|
];
|
|
553
|
-
exports.
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
553
|
+
exports.validationErrors = {
|
|
554
|
+
companyId: 'Please select Company',
|
|
555
|
+
ref: 'Please enter ref',
|
|
556
|
+
status: 'Please select status',
|
|
557
|
+
date: 'Please select date',
|
|
558
|
+
expiryDate: 'Please select expire date',
|
|
559
|
+
note: 'Please enter a note',
|
|
560
|
+
currency: 'Please select currency',
|
|
561
|
+
total: 'Please enter net total',
|
|
562
|
+
subTotal: 'Please enter sub total',
|
|
563
|
+
taxRate: 'Please enter tax value',
|
|
564
|
+
services: {
|
|
565
|
+
name: 'Item is required',
|
|
566
|
+
description: 'Description is required',
|
|
567
|
+
quantity: 'Quantity is required',
|
|
568
|
+
price: 'Price is required',
|
|
569
|
+
total: 'Total price is required',
|
|
570
|
+
},
|
|
571
|
+
products: {
|
|
572
|
+
id: 'Please select a product',
|
|
573
|
+
quantity: 'Please enter Quantity',
|
|
574
|
+
},
|
|
562
575
|
};
|
|
@@ -113,6 +113,7 @@ var useInvoiceState = function () {
|
|
|
113
113
|
var companies = (0, context_2.useCompanyStateContext)().companies;
|
|
114
114
|
var debouncedQuery = (0, util_functions_1.useDebounce)(state.searchQuery, 800);
|
|
115
115
|
var listParams = {
|
|
116
|
+
category: types_1.QUOTE_INVOICE.INVOICE,
|
|
116
117
|
currentPage: state.currentPage,
|
|
117
118
|
pageLimit: state.pageLimit,
|
|
118
119
|
searchQuery: state.searchQuery,
|
|
@@ -122,7 +123,7 @@ var useInvoiceState = function () {
|
|
|
122
123
|
if (error) {
|
|
123
124
|
(0, generate_toast_1.generateToast)({
|
|
124
125
|
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
125
|
-
description: constants_1.
|
|
126
|
+
description: constants_1.toastErrors.fetchInvoiceError,
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
if (data === null || data === void 0 ? void 0 : data.items) {
|
|
@@ -161,13 +162,13 @@ var useInvoiceState = function () {
|
|
|
161
162
|
var data = _a.data, error = _a.error;
|
|
162
163
|
if (error) {
|
|
163
164
|
(0, generate_toast_1.generateToast)({
|
|
164
|
-
description: constants_1.
|
|
165
|
+
description: constants_1.toastErrors.networkError,
|
|
165
166
|
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
166
167
|
});
|
|
167
168
|
}
|
|
168
169
|
if (data) {
|
|
169
170
|
(0, generate_toast_1.generateToast)({
|
|
170
|
-
description: constants_1.
|
|
171
|
+
description: constants_1.toastErrors.networkError,
|
|
171
172
|
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
|
|
172
173
|
});
|
|
173
174
|
dispatch({
|
|
@@ -187,12 +188,13 @@ var useInvoiceState = function () {
|
|
|
187
188
|
var data = _a.data, error = _a.error;
|
|
188
189
|
if (error) {
|
|
189
190
|
(0, generate_toast_1.generateToast)({
|
|
190
|
-
description: constants_1.
|
|
191
|
+
description: constants_1.toastErrors.networkError,
|
|
191
192
|
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
195
|
if (data) {
|
|
195
|
-
var
|
|
196
|
+
var updatedServices = __spreadArray([], data.services, true).map(function (item) { return (__assign(__assign({}, item), { rowTotal: Number(item.quantity) * Number(item.price) })); });
|
|
197
|
+
var updatedData = __assign(__assign({}, data), { services: __spreadArray([], updatedServices, true) });
|
|
196
198
|
dispatch({
|
|
197
199
|
type: actions_1.INVOICE_ACTION_TYPES.SET_FORM,
|
|
198
200
|
payload: { form: updatedData },
|
|
@@ -210,13 +212,13 @@ var useInvoiceState = function () {
|
|
|
210
212
|
var data = _a.data, error = _a.error;
|
|
211
213
|
if (error) {
|
|
212
214
|
(0, generate_toast_1.generateToast)({
|
|
213
|
-
description: constants_1.
|
|
215
|
+
description: constants_1.toastErrors.networkError,
|
|
214
216
|
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
215
217
|
});
|
|
216
218
|
}
|
|
217
219
|
if (data) {
|
|
218
220
|
(0, generate_toast_1.generateToast)({
|
|
219
|
-
description: constants_1.
|
|
221
|
+
description: constants_1.toastErrors.networkError,
|
|
220
222
|
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.SUCCESS,
|
|
221
223
|
});
|
|
222
224
|
dispatch({
|
|
@@ -334,33 +336,6 @@ var useInvoiceState = function () {
|
|
|
334
336
|
body: JSON.stringify({ id: id }),
|
|
335
337
|
});
|
|
336
338
|
};
|
|
337
|
-
// const handleUploadImage = useCallback(async () => {
|
|
338
|
-
// const urls: string[] = [];
|
|
339
|
-
// if (state?.images?.some((u) => u.startsWith('blob:'))) {
|
|
340
|
-
// await Promise.all(state.images.map(async (url) => {
|
|
341
|
-
// const blob = await fetch(url).then((r) => r.blob());
|
|
342
|
-
// const webpBlob = await blobToWebP(blob, { quality: 1 });
|
|
343
|
-
// const { data } = await uploadBlobToPublicSupabase({
|
|
344
|
-
// blob: webpBlob,
|
|
345
|
-
// supabase: supabaseClient,
|
|
346
|
-
// fileRef: `products/${uuidv4()}.webp`,
|
|
347
|
-
// contentType: 'image/webp',
|
|
348
|
-
// upsert: true,
|
|
349
|
-
// });
|
|
350
|
-
// if (data) {
|
|
351
|
-
// urls.push(`${supabasePublicStorageUrl}/${data.path}`);
|
|
352
|
-
// }
|
|
353
|
-
// return urls;
|
|
354
|
-
// }));
|
|
355
|
-
// }
|
|
356
|
-
// if (urls.length) {
|
|
357
|
-
// dispatch({
|
|
358
|
-
// type: INVOICE_ACTION_TYPES.SET_INPUT_FIELD,
|
|
359
|
-
// payload: { key: 'images', value: urls },
|
|
360
|
-
// });
|
|
361
|
-
// }
|
|
362
|
-
// return urls;
|
|
363
|
-
// }, [state.images]);
|
|
364
339
|
var handleSubmit = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
365
340
|
var validationResult, validationErrors_1;
|
|
366
341
|
return __generator(this, function (_a) {
|
|
@@ -388,7 +363,7 @@ var useInvoiceState = function () {
|
|
|
388
363
|
}
|
|
389
364
|
catch (_b) {
|
|
390
365
|
(0, generate_toast_1.generateToast)({
|
|
391
|
-
description: constants_1.
|
|
366
|
+
description: constants_1.toastErrors.networkError,
|
|
392
367
|
variant: vista_notification_type_1.VISTA_NOTIFICATION_V1_VARIANT.ERROR,
|
|
393
368
|
});
|
|
394
369
|
}
|
|
@@ -83,7 +83,7 @@ var InvoicePage = function () {
|
|
|
83
83
|
];
|
|
84
84
|
var totalPagePerRecord = (0, util_functions_1.calculatePages)(count, pageLimit);
|
|
85
85
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
86
|
-
react_1.default.createElement(vista_table_v1_1.VistaTableV1, { currentPage: count, isNextDisabled: (0, util_functions_1.isNextButtonDisabled)(currentPage, totalPagePerRecord), isPreviousDisabled: (0, util_functions_1.isPreviousButtonDisabled)(currentPage),
|
|
86
|
+
react_1.default.createElement(vista_table_v1_1.VistaTableV1, { currentPage: count, handleNextOnClick: handleNextClick, handleOnSelect: handlePageLimit, handlePreviousOnClick: handlePreviousClick, handleSearchInput: searchOnChange, headerActions: headerActions, isNextDisabled: (0, util_functions_1.isNextButtonDisabled)(currentPage, totalPagePerRecord), isPreviousDisabled: (0, util_functions_1.isPreviousButtonDisabled)(currentPage), listOptions: (0, util_functions_1.getAvailablePageLimits)(count), loading: listLoading, nodeSelectKey: "pageLimit", pageLimit: pageLimit, rowActions: rowActions, searchDisabled: false, searchEnabled: true, searchId: "inventory-search", searchPlaceholder: "Enter ID or Name...", searchValue: searchQuery, selectKey1: "option", selectedItem: { option: String(pageLimit) }, tableBodyCols: constants_1.tableBodyCols, tableBodyRows: invoices, tableDescription: t('subTitle'), tableHeadItems: tableHeadItems, tableHeading: t('title'), totalPages: totalPagePerRecord }),
|
|
87
87
|
react_1.default.createElement(drawer_1.Drawer, { translationMap: translationMap }),
|
|
88
88
|
react_1.default.createElement(generate_toast_1.VistaToaster, null)));
|
|
89
89
|
};
|
|
@@ -1,36 +1,84 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const formValidation: z.ZodObject<{
|
|
3
|
-
|
|
3
|
+
companyId: z.ZodOptional<z.ZodString>;
|
|
4
|
+
ref: z.ZodString;
|
|
5
|
+
date: z.ZodString;
|
|
6
|
+
expiryDate: z.ZodString;
|
|
7
|
+
note: z.ZodOptional<z.ZodString>;
|
|
4
8
|
currency: z.ZodString;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
total: z.ZodString;
|
|
10
|
+
subTotal: z.ZodString;
|
|
11
|
+
taxRate: z.ZodString;
|
|
12
|
+
services: z.ZodArray<z.ZodObject<{
|
|
13
|
+
name: z.ZodOptional<z.ZodString>;
|
|
14
|
+
description: z.ZodOptional<z.ZodString>;
|
|
15
|
+
quantity: z.ZodOptional<z.ZodString>;
|
|
16
|
+
price: z.ZodOptional<z.ZodString>;
|
|
17
|
+
total: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
quantity?: string | undefined;
|
|
20
|
+
price?: string | undefined;
|
|
21
|
+
name?: string | undefined;
|
|
22
|
+
description?: string | undefined;
|
|
23
|
+
total?: string | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
quantity?: string | undefined;
|
|
26
|
+
price?: string | undefined;
|
|
27
|
+
name?: string | undefined;
|
|
28
|
+
description?: string | undefined;
|
|
29
|
+
total?: string | undefined;
|
|
30
|
+
}>, "many">;
|
|
31
|
+
products: z.ZodArray<z.ZodObject<{
|
|
32
|
+
productId: z.ZodOptional<z.ZodString>;
|
|
33
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
}, "strip", z.ZodTypeAny, {
|
|
35
|
+
productId?: string | undefined;
|
|
36
|
+
quantity?: number | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
productId?: string | undefined;
|
|
39
|
+
quantity?: number | undefined;
|
|
40
|
+
}>, "many">;
|
|
13
41
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
quantity: string;
|
|
15
|
-
name: string;
|
|
16
42
|
currency: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
date: string;
|
|
44
|
+
expiryDate: string;
|
|
45
|
+
products: {
|
|
46
|
+
productId?: string | undefined;
|
|
47
|
+
quantity?: number | undefined;
|
|
48
|
+
}[];
|
|
49
|
+
ref: string;
|
|
50
|
+
services: {
|
|
51
|
+
quantity?: string | undefined;
|
|
52
|
+
price?: string | undefined;
|
|
53
|
+
name?: string | undefined;
|
|
54
|
+
description?: string | undefined;
|
|
55
|
+
total?: string | undefined;
|
|
56
|
+
}[];
|
|
57
|
+
subTotal: string;
|
|
58
|
+
taxRate: string;
|
|
59
|
+
total: string;
|
|
60
|
+
companyId?: string | undefined;
|
|
61
|
+
note?: string | undefined;
|
|
24
62
|
}, {
|
|
25
|
-
quantity: string;
|
|
26
|
-
name: string;
|
|
27
63
|
currency: string;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
64
|
+
date: string;
|
|
65
|
+
expiryDate: string;
|
|
66
|
+
products: {
|
|
67
|
+
productId?: string | undefined;
|
|
68
|
+
quantity?: number | undefined;
|
|
69
|
+
}[];
|
|
70
|
+
ref: string;
|
|
71
|
+
services: {
|
|
72
|
+
quantity?: string | undefined;
|
|
73
|
+
price?: string | undefined;
|
|
74
|
+
name?: string | undefined;
|
|
75
|
+
description?: string | undefined;
|
|
76
|
+
total?: string | undefined;
|
|
77
|
+
}[];
|
|
78
|
+
subTotal: string;
|
|
79
|
+
taxRate: string;
|
|
80
|
+
total: string;
|
|
81
|
+
companyId?: string | undefined;
|
|
82
|
+
note?: string | undefined;
|
|
35
83
|
}>;
|
|
36
|
-
export type
|
|
84
|
+
export type InvoiceFormValidate = z.infer<typeof formValidation>;
|
|
@@ -3,15 +3,47 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.formValidation = void 0;
|
|
4
4
|
var zod_1 = require("zod");
|
|
5
5
|
var constants_1 = require("./constants");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
var services = zod_1.z.object({
|
|
7
|
+
name: zod_1.z.string().optional(),
|
|
8
|
+
// .nonempty(formErrors[DASHBOARD_DRAWERS_FORMS.INVOICE].itemsData.name),
|
|
9
9
|
description: zod_1.z.string().optional(),
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
quantity: zod_1.z.string().optional(),
|
|
11
|
+
// .nonempty(formErrors[DASHBOARD_DRAWERS_FORMS.INVOICE].itemsData.quantity),
|
|
12
|
+
price: zod_1.z.string().optional(),
|
|
13
|
+
// .nonempty(formErrors[DASHBOARD_DRAWERS_FORMS.INVOICE].itemsData.price),
|
|
14
|
+
total: zod_1.z.string().optional(),
|
|
15
|
+
// .nonempty(formErrors[DASHBOARD_DRAWERS_FORMS.INVOICE].itemsData.total),
|
|
16
|
+
});
|
|
17
|
+
var products = zod_1.z.object({
|
|
18
|
+
productId: zod_1.z.string().optional(),
|
|
19
|
+
// .nonempty(validationErrors.products.id),
|
|
20
|
+
quantity: zod_1.z.number().optional(),
|
|
21
|
+
// .min(
|
|
22
|
+
// 1,
|
|
23
|
+
// formErrors[DASHBOARD_DRAWERS_FORMS.INVOICE].products.productQuantity,
|
|
24
|
+
// ),
|
|
25
|
+
});
|
|
26
|
+
exports.formValidation = zod_1.z.object({
|
|
27
|
+
companyId: zod_1.z.string().optional(),
|
|
28
|
+
ref: zod_1.z.string().nonempty(constants_1.validationErrors.ref),
|
|
29
|
+
// invoiceStatus: z
|
|
30
|
+
// .string()
|
|
31
|
+
// .nonempty(formErrors[DASHBOARD_DRAWERS_FORMS.INVOICE].status),
|
|
32
|
+
date: zod_1.z.string().nonempty(constants_1.validationErrors.date),
|
|
33
|
+
expiryDate: zod_1.z
|
|
34
|
+
.string()
|
|
35
|
+
.nonempty(constants_1.validationErrors.expiryDate),
|
|
36
|
+
note: zod_1.z.string().optional(),
|
|
37
|
+
currency: zod_1.z
|
|
38
|
+
.string()
|
|
39
|
+
.nonempty(constants_1.validationErrors.currency),
|
|
40
|
+
total: zod_1.z.string().nonempty(constants_1.validationErrors.total),
|
|
41
|
+
subTotal: zod_1.z
|
|
42
|
+
.string()
|
|
43
|
+
.nonempty(constants_1.validationErrors.subTotal),
|
|
44
|
+
taxRate: zod_1.z
|
|
45
|
+
.string()
|
|
46
|
+
.nonempty(constants_1.validationErrors.taxRate),
|
|
47
|
+
services: zod_1.z.array(services),
|
|
48
|
+
products: zod_1.z.array(products),
|
|
17
49
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appcorp/stellar-solutions-invoice-module",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.30",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "yarn clean && yarn build:ts && cp package.json lib && cp README.md lib",
|
|
6
6
|
"build:next": "next build",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"dependencies": {},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@appcorp/app-corp-designs": "^0.4.79",
|
|
22
|
-
"@appcorp/app-corp-vista": "^0.2.
|
|
22
|
+
"@appcorp/app-corp-vista": "^0.2.26",
|
|
23
23
|
"@appcorp/stellar-solutions-company-module": "^0.1.16",
|
|
24
24
|
"@appcorp/stellar-solutions-modules": "^0.1.5",
|
|
25
25
|
"@appcorp/stellar-solutions-product-module": "^0.1.87",
|