@react-pakistan/util-functions 1.24.66 → 1.24.68
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/api/stellar-solutions/app-user/index.d.ts +8 -31
- package/api/stellar-solutions/app-user/index.js +26 -24
- package/api/stellar-solutions/bank/index.d.ts +9 -32
- package/api/stellar-solutions/bank/index.js +19 -25
- package/api/stellar-solutions/branch/index.d.ts +9 -32
- package/api/stellar-solutions/branch/index.js +19 -25
- package/api/stellar-solutions/company/index.d.ts +9 -32
- package/api/stellar-solutions/company/index.js +29 -27
- package/api/stellar-solutions/company-report/index.d.ts +5 -12
- package/api/stellar-solutions/company-report/index.js +23 -16
- package/api/stellar-solutions/contact/index.d.ts +8 -31
- package/api/stellar-solutions/contact/index.js +19 -25
- package/api/stellar-solutions/currency/index.d.ts +8 -31
- package/api/stellar-solutions/currency/index.js +30 -27
- package/api/stellar-solutions/customer/index.d.ts +9 -35
- package/api/stellar-solutions/customer/index.js +31 -30
- package/api/stellar-solutions/expense/index.d.ts +11 -32
- package/api/stellar-solutions/expense/index.js +41 -50
- package/api/stellar-solutions/expense-category/index.d.ts +13 -34
- package/api/stellar-solutions/expense-category/index.js +64 -52
- package/api/stellar-solutions/lead/index.d.ts +35 -19
- package/api/stellar-solutions/lead/index.js +117 -82
- package/api/stellar-solutions/menu-order/index.d.ts +19 -15
- package/api/stellar-solutions/menu-order/index.js +43 -33
- package/api/stellar-solutions/payment/index.d.ts +30 -47
- package/api/stellar-solutions/payment/index.js +64 -65
- package/api/stellar-solutions/payment-mode/index.d.ts +6 -13
- package/api/stellar-solutions/payment-mode/index.js +28 -46
- package/api/stellar-solutions/preference/index.d.ts +11 -9
- package/api/stellar-solutions/preference/index.js +30 -37
- package/api/stellar-solutions/product/index.d.ts +15 -13
- package/api/stellar-solutions/product/index.js +53 -44
- package/api/stellar-solutions/product-category/index.d.ts +10 -13
- package/api/stellar-solutions/product-category/index.js +58 -49
- package/api/stellar-solutions/profile/index.d.ts +6 -5
- package/api/stellar-solutions/profile/index.js +17 -18
- package/api/stellar-solutions/quote-invoice/index.d.ts +41 -31
- package/api/stellar-solutions/quote-invoice/index.js +116 -124
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +7 -14
- package/api/stellar-solutions/quote-invoice-report/index.js +27 -20
- package/api/stellar-solutions/tax/index.d.ts +11 -18
- package/api/stellar-solutions/tax/index.js +49 -40
- package/package.json +1 -1
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -55,7 +44,8 @@ exports.deletePaymentMode = exports.updatePaymentMode = exports.unitPaymentModeB
|
|
|
55
44
|
*/
|
|
56
45
|
var listPaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
46
|
var skip, _c, count, data;
|
|
58
|
-
var _d
|
|
47
|
+
var _d;
|
|
48
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.orderByColumn, orderByColumn = _f === void 0 ? 'createdAt' : _f, _g = _b.orderByDirection, orderByDirection = _g === void 0 ? 'desc' : _g, _h = _b.pageLimit, pageLimit = _h === void 0 ? 10 : _h, prisma = _b.prisma;
|
|
59
49
|
return __generator(this, function (_j) {
|
|
60
50
|
switch (_j.label) {
|
|
61
51
|
case 0:
|
|
@@ -66,16 +56,14 @@ var listPaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, fun
|
|
|
66
56
|
throw new Error('Page limit must be greater than or equal to 1');
|
|
67
57
|
}
|
|
68
58
|
skip = (currentPage - 1) * pageLimit;
|
|
69
|
-
return [4 /*yield*/,
|
|
70
|
-
prisma.paymentMode.count(
|
|
71
|
-
where: queryWhere,
|
|
72
|
-
}),
|
|
59
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
60
|
+
prisma.paymentMode.count(),
|
|
73
61
|
prisma.paymentMode.findMany({
|
|
74
|
-
|
|
75
|
-
|
|
62
|
+
orderBy: (_d = {},
|
|
63
|
+
_d[orderByColumn] = orderByDirection,
|
|
64
|
+
_d),
|
|
76
65
|
skip: skip,
|
|
77
66
|
take: pageLimit,
|
|
78
|
-
where: queryWhere,
|
|
79
67
|
}),
|
|
80
68
|
])];
|
|
81
69
|
case 1:
|
|
@@ -92,22 +80,20 @@ exports.listPaymentMode = listPaymentMode;
|
|
|
92
80
|
*/
|
|
93
81
|
var unitPaymentModeById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
94
82
|
var paymentMode;
|
|
95
|
-
var id = _b.id,
|
|
96
|
-
return __generator(this, function (
|
|
97
|
-
switch (
|
|
83
|
+
var id = _b.id, prisma = _b.prisma;
|
|
84
|
+
return __generator(this, function (_c) {
|
|
85
|
+
switch (_c.label) {
|
|
98
86
|
case 0:
|
|
99
87
|
if (!id) {
|
|
100
88
|
throw new Error('Payment mode ID is required');
|
|
101
89
|
}
|
|
102
|
-
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
103
|
-
throw new Error('ID mismatch between parameter and queryWhere');
|
|
104
|
-
}
|
|
105
90
|
return [4 /*yield*/, prisma.paymentMode.findUnique({
|
|
106
|
-
|
|
107
|
-
|
|
91
|
+
where: {
|
|
92
|
+
id: id,
|
|
93
|
+
},
|
|
108
94
|
})];
|
|
109
95
|
case 1:
|
|
110
|
-
paymentMode =
|
|
96
|
+
paymentMode = _c.sent();
|
|
111
97
|
return [2 /*return*/, paymentMode];
|
|
112
98
|
}
|
|
113
99
|
});
|
|
@@ -120,9 +106,9 @@ exports.unitPaymentModeById = unitPaymentModeById;
|
|
|
120
106
|
*/
|
|
121
107
|
var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
122
108
|
var paymentMode;
|
|
123
|
-
var enabled = _b.enabled, id = _b.id,
|
|
124
|
-
return __generator(this, function (
|
|
125
|
-
switch (
|
|
109
|
+
var enabled = _b.enabled, id = _b.id, prisma = _b.prisma;
|
|
110
|
+
return __generator(this, function (_c) {
|
|
111
|
+
switch (_c.label) {
|
|
126
112
|
case 0:
|
|
127
113
|
if (!id) {
|
|
128
114
|
throw new Error('Payment mode ID is required');
|
|
@@ -130,18 +116,16 @@ var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
130
116
|
if (typeof enabled !== 'boolean') {
|
|
131
117
|
throw new Error('Enabled status must be a boolean');
|
|
132
118
|
}
|
|
133
|
-
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
134
|
-
throw new Error('ID mismatch between parameter and queryWhere');
|
|
135
|
-
}
|
|
136
119
|
return [4 /*yield*/, prisma.paymentMode.update({
|
|
137
|
-
|
|
138
|
-
|
|
120
|
+
where: {
|
|
121
|
+
id: id,
|
|
122
|
+
},
|
|
139
123
|
data: {
|
|
140
124
|
enabled: enabled,
|
|
141
125
|
},
|
|
142
126
|
})];
|
|
143
127
|
case 1:
|
|
144
|
-
paymentMode =
|
|
128
|
+
paymentMode = _c.sent();
|
|
145
129
|
return [2 /*return*/, paymentMode];
|
|
146
130
|
}
|
|
147
131
|
});
|
|
@@ -154,22 +138,20 @@ exports.updatePaymentMode = updatePaymentMode;
|
|
|
154
138
|
*/
|
|
155
139
|
var deletePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
156
140
|
var paymentMode;
|
|
157
|
-
var id = _b.id,
|
|
158
|
-
return __generator(this, function (
|
|
159
|
-
switch (
|
|
141
|
+
var id = _b.id, prisma = _b.prisma;
|
|
142
|
+
return __generator(this, function (_c) {
|
|
143
|
+
switch (_c.label) {
|
|
160
144
|
case 0:
|
|
161
145
|
if (!id) {
|
|
162
146
|
throw new Error('Payment mode ID is required');
|
|
163
147
|
}
|
|
164
|
-
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
165
|
-
throw new Error('ID mismatch between parameter and queryWhere');
|
|
166
|
-
}
|
|
167
148
|
return [4 /*yield*/, prisma.paymentMode.delete({
|
|
168
|
-
|
|
169
|
-
|
|
149
|
+
where: {
|
|
150
|
+
id: id,
|
|
151
|
+
},
|
|
170
152
|
})];
|
|
171
153
|
case 1:
|
|
172
|
-
paymentMode =
|
|
154
|
+
paymentMode = _c.sent();
|
|
173
155
|
return [2 /*return*/, paymentMode];
|
|
174
156
|
}
|
|
175
157
|
});
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { PreferenceBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface GetPreferencesArgs {
|
|
4
|
+
orderByColumn?: string;
|
|
5
|
+
orderByDirection?: 'asc' | 'desc';
|
|
4
6
|
prisma: PrismaClient;
|
|
5
7
|
}
|
|
6
8
|
interface PostPreferenceArgs {
|
|
7
|
-
id
|
|
9
|
+
id: string;
|
|
8
10
|
onboarding: boolean;
|
|
9
11
|
prisma: PrismaClient;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
|
-
* Retrieves all preferences
|
|
13
|
-
* @param {GetPreferencesArgs} args - Object containing prisma client
|
|
14
|
-
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
14
|
+
* Retrieves all preferences
|
|
15
|
+
* @param {GetPreferencesArgs} args - Object containing prisma client and ordering options
|
|
16
|
+
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
15
17
|
*/
|
|
16
|
-
export declare const getPreferences: ({ prisma, }: GetPreferencesArgs) => Promise<Array<PreferenceBE>>;
|
|
18
|
+
export declare const getPreferences: ({ orderByColumn, orderByDirection, prisma, }: GetPreferencesArgs) => Promise<Array<PreferenceBE>>;
|
|
17
19
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param {PostPreferenceArgs} args - Object containing prisma client,
|
|
20
|
-
* @returns {Promise<PreferenceBE>}
|
|
20
|
+
* Updates a preference using upsert
|
|
21
|
+
* @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
|
|
22
|
+
* @returns {Promise<PreferenceBE>} Updated preference
|
|
21
23
|
*/
|
|
22
|
-
export declare const postPreference: ({
|
|
24
|
+
export declare const postPreference: ({ id, onboarding, prisma, }: PostPreferenceArgs) => Promise<PreferenceBE>;
|
|
23
25
|
export {};
|
|
@@ -49,67 +49,60 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.postPreference = exports.getPreferences = void 0;
|
|
51
51
|
/**
|
|
52
|
-
* Retrieves all preferences
|
|
53
|
-
* @param {GetPreferencesArgs} args - Object containing prisma client
|
|
54
|
-
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
52
|
+
* Retrieves all preferences
|
|
53
|
+
* @param {GetPreferencesArgs} args - Object containing prisma client and ordering options
|
|
54
|
+
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
55
55
|
*/
|
|
56
56
|
var getPreferences = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var preferences;
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
})];
|
|
57
|
+
var include, orderBy, where, preferences;
|
|
58
|
+
var _c;
|
|
59
|
+
var _d = _b.orderByColumn, orderByColumn = _d === void 0 ? 'createdAt' : _d, _e = _b.orderByDirection, orderByDirection = _e === void 0 ? 'desc' : _e, prisma = _b.prisma;
|
|
60
|
+
return __generator(this, function (_f) {
|
|
61
|
+
switch (_f.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
include = {};
|
|
64
|
+
orderBy = (_c = {},
|
|
65
|
+
_c[orderByColumn] = orderByDirection,
|
|
66
|
+
_c);
|
|
67
|
+
where = {};
|
|
68
|
+
return [4 /*yield*/, prisma.preference.findMany({
|
|
69
|
+
include: include,
|
|
70
|
+
orderBy: orderBy,
|
|
71
|
+
where: where,
|
|
72
|
+
})];
|
|
74
73
|
case 1:
|
|
75
|
-
preferences =
|
|
74
|
+
preferences = _f.sent();
|
|
76
75
|
return [2 /*return*/, preferences];
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
}); };
|
|
80
79
|
exports.getPreferences = getPreferences;
|
|
81
80
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @param {PostPreferenceArgs} args - Object containing prisma client,
|
|
84
|
-
* @returns {Promise<PreferenceBE>}
|
|
81
|
+
* Updates a preference using upsert
|
|
82
|
+
* @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
|
|
83
|
+
* @returns {Promise<PreferenceBE>} Updated preference
|
|
85
84
|
*/
|
|
86
85
|
var postPreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
87
|
-
var preferenceData,
|
|
88
|
-
var
|
|
86
|
+
var preferenceData, preference;
|
|
87
|
+
var id = _b.id, onboarding = _b.onboarding, prisma = _b.prisma;
|
|
89
88
|
return __generator(this, function (_c) {
|
|
90
89
|
switch (_c.label) {
|
|
91
90
|
case 0:
|
|
91
|
+
if (!id) {
|
|
92
|
+
throw new Error('Preference ID is required');
|
|
93
|
+
}
|
|
92
94
|
if (typeof onboarding !== 'boolean') {
|
|
93
95
|
throw new Error('Onboarding status must be a boolean');
|
|
94
96
|
}
|
|
95
97
|
preferenceData = {
|
|
96
98
|
onboarding: onboarding,
|
|
97
99
|
};
|
|
98
|
-
if (!id) return [3 /*break*/, 2];
|
|
99
100
|
return [4 /*yield*/, prisma.preference.upsert({
|
|
100
|
-
where: {
|
|
101
|
-
id: id,
|
|
102
|
-
},
|
|
103
|
-
update: preferenceData,
|
|
104
101
|
create: __assign({ id: id }, preferenceData),
|
|
102
|
+
update: preferenceData,
|
|
103
|
+
where: { id: id },
|
|
105
104
|
})];
|
|
106
105
|
case 1:
|
|
107
|
-
preference_1 = _c.sent();
|
|
108
|
-
return [2 /*return*/, preference_1];
|
|
109
|
-
case 2: return [4 /*yield*/, prisma.preference.create({
|
|
110
|
-
data: preferenceData,
|
|
111
|
-
})];
|
|
112
|
-
case 3:
|
|
113
106
|
preference = _c.sent();
|
|
114
107
|
return [2 /*return*/, preference];
|
|
115
108
|
}
|
|
@@ -2,17 +2,18 @@ import { ProductBE } from '../type';
|
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface ListProductArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
includeProductCategory?: boolean;
|
|
6
|
+
includeQuotesInvoices?: boolean;
|
|
7
|
+
orderByColumn?: string;
|
|
8
|
+
orderByDirection?: 'asc' | 'desc';
|
|
7
9
|
pageLimit?: number;
|
|
8
10
|
prisma: PrismaClient;
|
|
9
|
-
queryWhere?: any;
|
|
10
11
|
}
|
|
11
12
|
interface UnitProductByIdArgs {
|
|
12
13
|
id: string;
|
|
13
|
-
|
|
14
|
+
includeProductCategory?: boolean;
|
|
15
|
+
includeQuotesInvoices?: boolean;
|
|
14
16
|
prisma: PrismaClient;
|
|
15
|
-
queryWhere?: any;
|
|
16
17
|
}
|
|
17
18
|
interface UpdateProductArgs {
|
|
18
19
|
buyPrice: string;
|
|
@@ -20,43 +21,44 @@ interface UpdateProductArgs {
|
|
|
20
21
|
description?: string;
|
|
21
22
|
id: string;
|
|
22
23
|
image?: string;
|
|
23
|
-
name: string;
|
|
24
24
|
include?: any;
|
|
25
|
+
includeProductCategory?: boolean;
|
|
26
|
+
includeQuotesInvoices?: boolean;
|
|
27
|
+
name: string;
|
|
25
28
|
prisma: PrismaClient;
|
|
26
29
|
productCategoryId: string;
|
|
27
30
|
quantity: string;
|
|
28
|
-
queryWhere?: any;
|
|
29
31
|
ref?: string;
|
|
30
32
|
salePrice: string;
|
|
31
33
|
}
|
|
32
34
|
interface DeleteProductArgs {
|
|
33
35
|
id: string;
|
|
34
|
-
|
|
36
|
+
includeProductCategory?: boolean;
|
|
37
|
+
includeQuotesInvoices?: boolean;
|
|
35
38
|
prisma: PrismaClient;
|
|
36
|
-
queryWhere?: any;
|
|
37
39
|
}
|
|
38
40
|
/**
|
|
39
41
|
* Retrieves a paginated list of products
|
|
40
42
|
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
41
43
|
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
42
44
|
*/
|
|
43
|
-
export declare const listProduct: ({ currentPage,
|
|
45
|
+
export declare const listProduct: ({ currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
44
46
|
/**
|
|
45
47
|
* Retrieves a single product by its ID
|
|
46
48
|
* @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
47
49
|
* @returns {Promise<ProductBE | null>} Product or null if not found
|
|
48
50
|
*/
|
|
49
|
-
export declare const unitProductById: ({ id,
|
|
51
|
+
export declare const unitProductById: ({ id, includeProductCategory, includeQuotesInvoices, prisma, }: UnitProductByIdArgs) => Promise<ProductBE | null>;
|
|
50
52
|
/**
|
|
51
53
|
* Creates or updates a product
|
|
52
54
|
* @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
|
|
53
55
|
* @returns {Promise<ProductBE>} Created or updated product
|
|
54
56
|
*/
|
|
55
|
-
export declare const updateProduct: ({ buyPrice, currency, description, id, image,
|
|
57
|
+
export declare const updateProduct: ({ buyPrice, currency, description, id, image, includeProductCategory, includeQuotesInvoices, name, prisma, productCategoryId, quantity, ref, salePrice, }: UpdateProductArgs) => Promise<ProductBE>;
|
|
56
58
|
/**
|
|
57
59
|
* Deletes a product by ID
|
|
58
60
|
* @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
59
61
|
* @returns {Promise<ProductBE>} Deleted product
|
|
60
62
|
*/
|
|
61
|
-
export declare const deleteProduct: ({ id,
|
|
63
|
+
export declare const deleteProduct: ({ id, includeProductCategory, includeQuotesInvoices, prisma, }: DeleteProductArgs) => Promise<ProductBE>;
|
|
62
64
|
export {};
|
|
@@ -54,13 +54,11 @@ exports.deleteProduct = exports.updateProduct = exports.unitProductById = export
|
|
|
54
54
|
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
55
55
|
*/
|
|
56
56
|
var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var skip, _c, count,
|
|
58
|
-
var _d
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
return __generator(this, function (_j) {
|
|
63
|
-
switch (_j.label) {
|
|
57
|
+
var include, orderBy, skip, where, _c, count, items;
|
|
58
|
+
var _d;
|
|
59
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeProductCategory, includeProductCategory = _f === void 0 ? false : _f, _g = _b.includeQuotesInvoices, includeQuotesInvoices = _g === void 0 ? false : _g, _h = _b.orderByColumn, orderByColumn = _h === void 0 ? 'createdAt' : _h, _j = _b.orderByDirection, orderByDirection = _j === void 0 ? 'desc' : _j, _k = _b.pageLimit, pageLimit = _k === void 0 ? 10 : _k, prisma = _b.prisma;
|
|
60
|
+
return __generator(this, function (_l) {
|
|
61
|
+
switch (_l.label) {
|
|
64
62
|
case 0:
|
|
65
63
|
if (currentPage < 1) {
|
|
66
64
|
throw new Error('Current page must be greater than or equal to 1');
|
|
@@ -68,22 +66,30 @@ var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
68
66
|
if (pageLimit < 1) {
|
|
69
67
|
throw new Error('Page limit must be greater than or equal to 1');
|
|
70
68
|
}
|
|
69
|
+
include = {
|
|
70
|
+
productCategory: includeProductCategory,
|
|
71
|
+
quotesInvoices: includeQuotesInvoices,
|
|
72
|
+
};
|
|
73
|
+
orderBy = (_d = {},
|
|
74
|
+
_d[orderByColumn] = orderByDirection,
|
|
75
|
+
_d);
|
|
71
76
|
skip = (currentPage - 1) * pageLimit;
|
|
72
|
-
|
|
77
|
+
where = {};
|
|
78
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
73
79
|
prisma.product.count({
|
|
74
|
-
where:
|
|
80
|
+
where: where,
|
|
75
81
|
}),
|
|
76
82
|
prisma.product.findMany({
|
|
77
|
-
include: include
|
|
83
|
+
include: include,
|
|
78
84
|
orderBy: orderBy,
|
|
79
85
|
skip: skip,
|
|
80
86
|
take: pageLimit,
|
|
81
|
-
where:
|
|
87
|
+
where: where,
|
|
82
88
|
}),
|
|
83
89
|
])];
|
|
84
90
|
case 1:
|
|
85
|
-
_c =
|
|
86
|
-
return [2 /*return*/, [count,
|
|
91
|
+
_c = _l.sent(), count = _c[0], items = _c[1];
|
|
92
|
+
return [2 /*return*/, [count, items]];
|
|
87
93
|
}
|
|
88
94
|
});
|
|
89
95
|
}); };
|
|
@@ -94,23 +100,24 @@ exports.listProduct = listProduct;
|
|
|
94
100
|
* @returns {Promise<ProductBE | null>} Product or null if not found
|
|
95
101
|
*/
|
|
96
102
|
var unitProductById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
97
|
-
var product;
|
|
98
|
-
var id = _b.id, _c = _b.
|
|
99
|
-
productCategory: true,
|
|
100
|
-
quotesInvoices: true,
|
|
101
|
-
} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
103
|
+
var include, where, product;
|
|
104
|
+
var id = _b.id, _c = _b.includeProductCategory, includeProductCategory = _c === void 0 ? false : _c, _d = _b.includeQuotesInvoices, includeQuotesInvoices = _d === void 0 ? false : _d, prisma = _b.prisma;
|
|
102
105
|
return __generator(this, function (_e) {
|
|
103
106
|
switch (_e.label) {
|
|
104
107
|
case 0:
|
|
105
108
|
if (!id) {
|
|
106
109
|
throw new Error('Product ID is required');
|
|
107
110
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
include = {
|
|
112
|
+
productCategory: includeProductCategory,
|
|
113
|
+
quotesInvoices: includeQuotesInvoices,
|
|
114
|
+
};
|
|
115
|
+
where = {
|
|
116
|
+
id: id,
|
|
117
|
+
};
|
|
111
118
|
return [4 /*yield*/, prisma.product.findUnique({
|
|
112
|
-
include: include
|
|
113
|
-
where:
|
|
119
|
+
include: include,
|
|
120
|
+
where: where,
|
|
114
121
|
})];
|
|
115
122
|
case 1:
|
|
116
123
|
product = _e.sent();
|
|
@@ -125,11 +132,8 @@ exports.unitProductById = unitProductById;
|
|
|
125
132
|
* @returns {Promise<ProductBE>} Created or updated product
|
|
126
133
|
*/
|
|
127
134
|
var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
128
|
-
var productData, product;
|
|
129
|
-
var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image, _c = _b.
|
|
130
|
-
productCategory: true,
|
|
131
|
-
quotesInvoices: true,
|
|
132
|
-
} : _c, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d, ref = _b.ref, salePrice = _b.salePrice;
|
|
135
|
+
var productData, include, where, product;
|
|
136
|
+
var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image, _c = _b.includeProductCategory, includeProductCategory = _c === void 0 ? true : _c, _d = _b.includeQuotesInvoices, includeQuotesInvoices = _d === void 0 ? true : _d, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, ref = _b.ref, salePrice = _b.salePrice;
|
|
133
137
|
return __generator(this, function (_e) {
|
|
134
138
|
switch (_e.label) {
|
|
135
139
|
case 0:
|
|
@@ -144,9 +148,6 @@ var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
144
148
|
!salePrice) {
|
|
145
149
|
throw new Error('Buy price, currency, name, product category ID, quantity, and sale price are required');
|
|
146
150
|
}
|
|
147
|
-
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
148
|
-
throw new Error('ID mismatch between parameter and queryWhere');
|
|
149
|
-
}
|
|
150
151
|
productData = {
|
|
151
152
|
buyPrice: buyPrice,
|
|
152
153
|
currency: currency,
|
|
@@ -158,11 +159,18 @@ var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
158
159
|
ref: ref || null,
|
|
159
160
|
salePrice: salePrice,
|
|
160
161
|
};
|
|
162
|
+
include = {
|
|
163
|
+
productCategory: includeProductCategory,
|
|
164
|
+
quotesInvoices: includeQuotesInvoices,
|
|
165
|
+
};
|
|
166
|
+
where = {
|
|
167
|
+
id: id,
|
|
168
|
+
};
|
|
161
169
|
return [4 /*yield*/, prisma.product.upsert({
|
|
162
|
-
include: include || null,
|
|
163
|
-
where: __assign({ id: id }, queryWhere),
|
|
164
|
-
update: productData,
|
|
165
170
|
create: __assign({ id: id }, productData),
|
|
171
|
+
include: include,
|
|
172
|
+
update: productData,
|
|
173
|
+
where: where,
|
|
166
174
|
})];
|
|
167
175
|
case 1:
|
|
168
176
|
product = _e.sent();
|
|
@@ -177,23 +185,24 @@ exports.updateProduct = updateProduct;
|
|
|
177
185
|
* @returns {Promise<ProductBE>} Deleted product
|
|
178
186
|
*/
|
|
179
187
|
var deleteProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
180
|
-
var product;
|
|
181
|
-
var id = _b.id, _c = _b.
|
|
182
|
-
productCategory: true,
|
|
183
|
-
quotesInvoices: true,
|
|
184
|
-
} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
188
|
+
var include, where, product;
|
|
189
|
+
var id = _b.id, _c = _b.includeProductCategory, includeProductCategory = _c === void 0 ? true : _c, _d = _b.includeQuotesInvoices, includeQuotesInvoices = _d === void 0 ? true : _d, prisma = _b.prisma;
|
|
185
190
|
return __generator(this, function (_e) {
|
|
186
191
|
switch (_e.label) {
|
|
187
192
|
case 0:
|
|
188
193
|
if (!id) {
|
|
189
194
|
throw new Error('Product ID is required');
|
|
190
195
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
196
|
+
include = {
|
|
197
|
+
productCategory: includeProductCategory,
|
|
198
|
+
quotesInvoices: includeQuotesInvoices,
|
|
199
|
+
};
|
|
200
|
+
where = {
|
|
201
|
+
id: id,
|
|
202
|
+
};
|
|
194
203
|
return [4 /*yield*/, prisma.product.delete({
|
|
195
|
-
include: include
|
|
196
|
-
where:
|
|
204
|
+
include: include,
|
|
205
|
+
where: where,
|
|
197
206
|
})];
|
|
198
207
|
case 1:
|
|
199
208
|
product = _e.sent();
|
|
@@ -2,54 +2,51 @@ import { ProductCategoryBE } from '../type';
|
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface ListProductCategoryArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
includeProducts?: boolean;
|
|
6
|
+
orderByColumn?: string;
|
|
7
|
+
orderByDirection?: 'asc' | 'desc';
|
|
7
8
|
pageLimit?: number;
|
|
8
9
|
prisma: PrismaClient;
|
|
9
|
-
queryWhere?: any;
|
|
10
10
|
}
|
|
11
11
|
interface UnitProductCategoryByIdArgs {
|
|
12
12
|
id: string;
|
|
13
|
-
|
|
13
|
+
includeProducts?: boolean;
|
|
14
14
|
prisma: PrismaClient;
|
|
15
|
-
queryWhere?: any;
|
|
16
15
|
}
|
|
17
16
|
interface UpdateProductCategoryArgs {
|
|
18
17
|
description?: string;
|
|
19
18
|
id: string;
|
|
20
|
-
|
|
19
|
+
includeProducts?: boolean;
|
|
21
20
|
name: string;
|
|
22
21
|
prisma: PrismaClient;
|
|
23
|
-
queryWhere?: any;
|
|
24
22
|
}
|
|
25
23
|
interface DeleteProductCategoryArgs {
|
|
26
24
|
id: string;
|
|
27
|
-
|
|
25
|
+
includeProducts?: boolean;
|
|
28
26
|
prisma: PrismaClient;
|
|
29
|
-
queryWhere?: any;
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
32
29
|
* Retrieves a paginated list of product categories
|
|
33
30
|
* @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
34
31
|
* @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
|
|
35
32
|
*/
|
|
36
|
-
export declare const listProductCategory: ({ currentPage,
|
|
33
|
+
export declare const listProductCategory: ({ currentPage, includeProducts, orderByColumn, orderByDirection, pageLimit, prisma, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryBE>]>;
|
|
37
34
|
/**
|
|
38
35
|
* Retrieves a single product category by its ID
|
|
39
36
|
* @param {UnitProductCategoryByIdArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
40
37
|
* @returns {Promise<ProductCategoryBE | null>} Product category or null if not found
|
|
41
38
|
*/
|
|
42
|
-
export declare const unitProductCategoryById: ({ id,
|
|
39
|
+
export declare const unitProductCategoryById: ({ id, includeProducts, prisma, }: UnitProductCategoryByIdArgs) => Promise<ProductCategoryBE | null>;
|
|
43
40
|
/**
|
|
44
41
|
* Creates or updates a product category
|
|
45
42
|
* @param {UpdateProductCategoryArgs} args - Object containing prisma client, product category data, and optional query parameters
|
|
46
43
|
* @returns {Promise<ProductCategoryBE>} Created or updated product category
|
|
47
44
|
*/
|
|
48
|
-
export declare const updateProductCategory: ({ description, id,
|
|
45
|
+
export declare const updateProductCategory: ({ description, id, includeProducts, name, prisma, }: UpdateProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
49
46
|
/**
|
|
50
47
|
* Deletes a product category by ID
|
|
51
48
|
* @param {DeleteProductCategoryArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
52
49
|
* @returns {Promise<ProductCategoryBE>} Deleted product category
|
|
53
50
|
*/
|
|
54
|
-
export declare const deleteProductCategory: ({ id,
|
|
51
|
+
export declare const deleteProductCategory: ({ id, includeProducts, prisma, }: DeleteProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
55
52
|
export {};
|