@react-pakistan/util-functions 1.24.70 → 1.24.73
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 -7
- package/api/stellar-solutions/app-user/index.js +60 -24
- package/api/stellar-solutions/bank/index.d.ts +14 -11
- package/api/stellar-solutions/bank/index.js +60 -22
- package/api/stellar-solutions/branch/index.d.ts +11 -8
- package/api/stellar-solutions/branch/index.js +61 -17
- package/api/stellar-solutions/company/index.d.ts +12 -8
- package/api/stellar-solutions/company/index.js +41 -27
- package/api/stellar-solutions/company-report/index.d.ts +1 -1
- package/api/stellar-solutions/contact/index.d.ts +12 -9
- package/api/stellar-solutions/contact/index.js +70 -22
- package/api/stellar-solutions/currency/index.d.ts +11 -8
- package/api/stellar-solutions/currency/index.js +66 -31
- package/api/stellar-solutions/customer/index.d.ts +14 -10
- package/api/stellar-solutions/customer/index.js +80 -35
- package/api/stellar-solutions/expense/index.d.ts +8 -7
- package/api/stellar-solutions/expense/index.js +77 -29
- package/api/stellar-solutions/expense-category/index.d.ts +8 -9
- package/api/stellar-solutions/expense-category/index.js +45 -30
- package/api/stellar-solutions/lead/index.d.ts +6 -5
- package/api/stellar-solutions/lead/index.js +46 -28
- package/api/stellar-solutions/menu-order/index.d.ts +11 -8
- package/api/stellar-solutions/menu-order/index.js +56 -29
- package/api/stellar-solutions/payment/index.d.ts +9 -8
- package/api/stellar-solutions/payment/index.js +56 -39
- package/api/stellar-solutions/payment-mode/index.d.ts +13 -7
- package/api/stellar-solutions/payment-mode/index.js +65 -33
- package/api/stellar-solutions/preference/index.d.ts +4 -4
- package/api/stellar-solutions/preference/index.js +11 -11
- package/api/stellar-solutions/product/index.d.ts +9 -12
- package/api/stellar-solutions/product/index.js +45 -32
- package/api/stellar-solutions/product-category/index.d.ts +8 -9
- package/api/stellar-solutions/product-category/index.js +45 -30
- package/api/stellar-solutions/quote-invoice/index.d.ts +9 -8
- package/api/stellar-solutions/quote-invoice/index.js +40 -25
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +1 -1
- package/api/stellar-solutions/tax/index.d.ts +9 -6
- package/api/stellar-solutions/tax/index.js +44 -21
- package/package.json +1 -1
|
@@ -46,25 +46,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.deleteProduct = exports.updateProduct = exports.unitProductById = exports.listProduct = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves a paginated list of products
|
|
53
63
|
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
64
|
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
55
65
|
*/
|
|
56
66
|
var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy,
|
|
67
|
+
var include, orderBy, idSearchQuery, nameSearchQuery, refSearchQuery, where, _c, count, items;
|
|
58
68
|
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 ?
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
69
|
+
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 ? 5 : _k, prisma = _b.prisma, _l = _b.searchQuery, searchQuery = _l === void 0 ? '' : _l;
|
|
70
|
+
return __generator(this, function (_m) {
|
|
71
|
+
switch (_m.label) {
|
|
62
72
|
case 0:
|
|
63
|
-
if (currentPage < 1) {
|
|
64
|
-
throw new Error('
|
|
73
|
+
if (!currentPage || currentPage < 1) {
|
|
74
|
+
throw new Error('Valid current page is required');
|
|
65
75
|
}
|
|
66
|
-
if (pageLimit < 1) {
|
|
67
|
-
throw new Error('
|
|
76
|
+
if (!pageLimit || pageLimit < 1) {
|
|
77
|
+
throw new Error('Valid page limit is required');
|
|
68
78
|
}
|
|
69
79
|
include = {
|
|
70
80
|
productCategory: includeProductCategory,
|
|
@@ -73,8 +83,21 @@ var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
73
83
|
orderBy = (_d = {},
|
|
74
84
|
_d[orderByColumn] = orderByDirection,
|
|
75
85
|
_d);
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
87
|
+
columnName: 'id',
|
|
88
|
+
fullText: searchQuery,
|
|
89
|
+
});
|
|
90
|
+
nameSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
91
|
+
columnName: 'name',
|
|
92
|
+
fullText: searchQuery,
|
|
93
|
+
});
|
|
94
|
+
refSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
95
|
+
columnName: 'ref',
|
|
96
|
+
fullText: searchQuery,
|
|
97
|
+
});
|
|
98
|
+
where = {
|
|
99
|
+
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), refSearchQuery, true),
|
|
100
|
+
};
|
|
78
101
|
return [4 /*yield*/, prisma.$transaction([
|
|
79
102
|
prisma.product.count({
|
|
80
103
|
where: where,
|
|
@@ -82,13 +105,13 @@ var listProduct = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
82
105
|
prisma.product.findMany({
|
|
83
106
|
include: include,
|
|
84
107
|
orderBy: orderBy,
|
|
85
|
-
skip:
|
|
108
|
+
skip: (currentPage - 1) * pageLimit,
|
|
86
109
|
take: pageLimit,
|
|
87
110
|
where: where,
|
|
88
111
|
}),
|
|
89
112
|
])];
|
|
90
113
|
case 1:
|
|
91
|
-
_c =
|
|
114
|
+
_c = _m.sent(), count = _c[0], items = _c[1];
|
|
92
115
|
return [2 /*return*/, [count, items]];
|
|
93
116
|
}
|
|
94
117
|
});
|
|
@@ -132,10 +155,10 @@ exports.unitProductById = unitProductById;
|
|
|
132
155
|
* @returns {Promise<ProductBE>} Created or updated product
|
|
133
156
|
*/
|
|
134
157
|
var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
135
|
-
var productData,
|
|
136
|
-
var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image,
|
|
137
|
-
return __generator(this, function (
|
|
138
|
-
switch (
|
|
158
|
+
var productData, where, product;
|
|
159
|
+
var buyPrice = _b.buyPrice, currency = _b.currency, description = _b.description, id = _b.id, image = _b.image, name = _b.name, prisma = _b.prisma, productCategoryId = _b.productCategoryId, quantity = _b.quantity, ref = _b.ref, salePrice = _b.salePrice;
|
|
160
|
+
return __generator(this, function (_c) {
|
|
161
|
+
switch (_c.label) {
|
|
139
162
|
case 0:
|
|
140
163
|
if (!id) {
|
|
141
164
|
throw new Error('Product ID is required');
|
|
@@ -159,21 +182,16 @@ var updateProduct = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
159
182
|
ref: ref || null,
|
|
160
183
|
salePrice: salePrice,
|
|
161
184
|
};
|
|
162
|
-
include = {
|
|
163
|
-
productCategory: includeProductCategory,
|
|
164
|
-
quotesInvoices: includeQuotesInvoices,
|
|
165
|
-
};
|
|
166
185
|
where = {
|
|
167
186
|
id: id,
|
|
168
187
|
};
|
|
169
188
|
return [4 /*yield*/, prisma.product.upsert({
|
|
170
189
|
create: __assign({ id: id }, productData),
|
|
171
|
-
include: include,
|
|
172
190
|
update: productData,
|
|
173
191
|
where: where,
|
|
174
192
|
})];
|
|
175
193
|
case 1:
|
|
176
|
-
product =
|
|
194
|
+
product = _c.sent();
|
|
177
195
|
return [2 /*return*/, product];
|
|
178
196
|
}
|
|
179
197
|
});
|
|
@@ -185,27 +203,22 @@ exports.updateProduct = updateProduct;
|
|
|
185
203
|
* @returns {Promise<ProductBE>} Deleted product
|
|
186
204
|
*/
|
|
187
205
|
var deleteProduct = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
188
|
-
var
|
|
189
|
-
var id = _b.id,
|
|
190
|
-
return __generator(this, function (
|
|
191
|
-
switch (
|
|
206
|
+
var where, product;
|
|
207
|
+
var id = _b.id, prisma = _b.prisma;
|
|
208
|
+
return __generator(this, function (_c) {
|
|
209
|
+
switch (_c.label) {
|
|
192
210
|
case 0:
|
|
193
211
|
if (!id) {
|
|
194
212
|
throw new Error('Product ID is required');
|
|
195
213
|
}
|
|
196
|
-
include = {
|
|
197
|
-
productCategory: includeProductCategory,
|
|
198
|
-
quotesInvoices: includeQuotesInvoices,
|
|
199
|
-
};
|
|
200
214
|
where = {
|
|
201
215
|
id: id,
|
|
202
216
|
};
|
|
203
217
|
return [4 /*yield*/, prisma.product.delete({
|
|
204
|
-
include: include,
|
|
205
218
|
where: where,
|
|
206
219
|
})];
|
|
207
220
|
case 1:
|
|
208
|
-
product =
|
|
221
|
+
product = _c.sent();
|
|
209
222
|
return [2 /*return*/, product];
|
|
210
223
|
}
|
|
211
224
|
});
|
|
@@ -1,28 +1,27 @@
|
|
|
1
1
|
import { ProductCategoryBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListProductCategoryArgs {
|
|
3
|
+
export interface ListProductCategoryArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
5
|
includeProducts?: boolean;
|
|
6
6
|
orderByColumn?: string;
|
|
7
7
|
orderByDirection?: 'asc' | 'desc';
|
|
8
8
|
pageLimit?: number;
|
|
9
9
|
prisma: PrismaClient;
|
|
10
|
+
searchQuery?: string;
|
|
10
11
|
}
|
|
11
|
-
interface UnitProductCategoryByIdArgs {
|
|
12
|
+
export interface UnitProductCategoryByIdArgs {
|
|
12
13
|
id: string;
|
|
13
14
|
includeProducts?: boolean;
|
|
14
15
|
prisma: PrismaClient;
|
|
15
16
|
}
|
|
16
|
-
interface UpdateProductCategoryArgs {
|
|
17
|
+
export interface UpdateProductCategoryArgs {
|
|
17
18
|
description?: string;
|
|
18
19
|
id: string;
|
|
19
|
-
includeProducts?: boolean;
|
|
20
20
|
name: string;
|
|
21
21
|
prisma: PrismaClient;
|
|
22
22
|
}
|
|
23
|
-
interface DeleteProductCategoryArgs {
|
|
23
|
+
export interface DeleteProductCategoryArgs {
|
|
24
24
|
id: string;
|
|
25
|
-
includeProducts?: boolean;
|
|
26
25
|
prisma: PrismaClient;
|
|
27
26
|
}
|
|
28
27
|
/**
|
|
@@ -30,7 +29,7 @@ interface DeleteProductCategoryArgs {
|
|
|
30
29
|
* @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
31
30
|
* @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
|
|
32
31
|
*/
|
|
33
|
-
export declare const listProductCategory: ({ currentPage, includeProducts, orderByColumn, orderByDirection, pageLimit, prisma, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryBE>]>;
|
|
32
|
+
export declare const listProductCategory: ({ currentPage, includeProducts, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListProductCategoryArgs) => Promise<[number, Array<ProductCategoryBE>]>;
|
|
34
33
|
/**
|
|
35
34
|
* Retrieves a single product category by its ID
|
|
36
35
|
* @param {UnitProductCategoryByIdArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
@@ -42,11 +41,11 @@ export declare const unitProductCategoryById: ({ id, includeProducts, prisma, }:
|
|
|
42
41
|
* @param {UpdateProductCategoryArgs} args - Object containing prisma client, product category data, and optional query parameters
|
|
43
42
|
* @returns {Promise<ProductCategoryBE>} Created or updated product category
|
|
44
43
|
*/
|
|
45
|
-
export declare const updateProductCategory: ({ description, id,
|
|
44
|
+
export declare const updateProductCategory: ({ description, id, name, prisma, }: UpdateProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
46
45
|
/**
|
|
47
46
|
* Deletes a product category by ID
|
|
48
47
|
* @param {DeleteProductCategoryArgs} args - Object containing prisma client, product category ID, and optional query parameters
|
|
49
48
|
* @returns {Promise<ProductCategoryBE>} Deleted product category
|
|
50
49
|
*/
|
|
51
|
-
export declare const deleteProductCategory: ({ id,
|
|
50
|
+
export declare const deleteProductCategory: ({ id, prisma, }: DeleteProductCategoryArgs) => Promise<ProductCategoryBE>;
|
|
52
51
|
export {};
|
|
@@ -46,25 +46,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.deleteProductCategory = exports.updateProductCategory = exports.unitProductCategoryById = exports.listProductCategory = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves a paginated list of product categories
|
|
53
63
|
* @param {ListProductCategoryArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
64
|
* @returns {Promise<[number, Array<ProductCategoryBE>]>} Tuple containing total count and array of product categories
|
|
55
65
|
*/
|
|
56
66
|
var listProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy,
|
|
67
|
+
var include, orderBy, idSearchQuery, nameSearchQuery, descriptionSearchQuery, where, _c, count, items;
|
|
58
68
|
var _d;
|
|
59
|
-
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeProducts, includeProducts = _f === void 0 ? false : _f, _g = _b.orderByColumn, orderByColumn = _g === void 0 ? 'createdAt' : _g, _h = _b.orderByDirection, orderByDirection = _h === void 0 ? 'desc' : _h, _j = _b.pageLimit, pageLimit = _j === void 0 ?
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
69
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeProducts, includeProducts = _f === void 0 ? false : _f, _g = _b.orderByColumn, orderByColumn = _g === void 0 ? 'createdAt' : _g, _h = _b.orderByDirection, orderByDirection = _h === void 0 ? 'desc' : _h, _j = _b.pageLimit, pageLimit = _j === void 0 ? 5 : _j, prisma = _b.prisma, _k = _b.searchQuery, searchQuery = _k === void 0 ? '' : _k;
|
|
70
|
+
return __generator(this, function (_l) {
|
|
71
|
+
switch (_l.label) {
|
|
62
72
|
case 0:
|
|
63
|
-
if (currentPage < 1) {
|
|
64
|
-
throw new Error('
|
|
73
|
+
if (!currentPage || currentPage < 1) {
|
|
74
|
+
throw new Error('Valid current page is required');
|
|
65
75
|
}
|
|
66
|
-
if (pageLimit < 1) {
|
|
67
|
-
throw new Error('
|
|
76
|
+
if (!pageLimit || pageLimit < 1) {
|
|
77
|
+
throw new Error('Valid page limit is required');
|
|
68
78
|
}
|
|
69
79
|
include = {
|
|
70
80
|
products: includeProducts,
|
|
@@ -72,8 +82,21 @@ var listProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
72
82
|
orderBy = (_d = {},
|
|
73
83
|
_d[orderByColumn] = orderByDirection,
|
|
74
84
|
_d);
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
86
|
+
columnName: 'id',
|
|
87
|
+
fullText: searchQuery,
|
|
88
|
+
});
|
|
89
|
+
nameSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
90
|
+
columnName: 'name',
|
|
91
|
+
fullText: searchQuery,
|
|
92
|
+
});
|
|
93
|
+
descriptionSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
94
|
+
columnName: 'description',
|
|
95
|
+
fullText: searchQuery,
|
|
96
|
+
});
|
|
97
|
+
where = {
|
|
98
|
+
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), descriptionSearchQuery, true),
|
|
99
|
+
};
|
|
77
100
|
return [4 /*yield*/, prisma.$transaction([
|
|
78
101
|
prisma.productCategory.count({
|
|
79
102
|
where: where,
|
|
@@ -81,13 +104,13 @@ var listProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0,
|
|
|
81
104
|
prisma.productCategory.findMany({
|
|
82
105
|
include: include,
|
|
83
106
|
orderBy: orderBy,
|
|
84
|
-
skip:
|
|
107
|
+
skip: (currentPage - 1) * pageLimit,
|
|
85
108
|
take: pageLimit,
|
|
86
109
|
where: where,
|
|
87
110
|
}),
|
|
88
111
|
])];
|
|
89
112
|
case 1:
|
|
90
|
-
_c =
|
|
113
|
+
_c = _l.sent(), count = _c[0], items = _c[1];
|
|
91
114
|
return [2 /*return*/, [count, items]];
|
|
92
115
|
}
|
|
93
116
|
});
|
|
@@ -130,10 +153,10 @@ exports.unitProductCategoryById = unitProductCategoryById;
|
|
|
130
153
|
* @returns {Promise<ProductCategoryBE>} Created or updated product category
|
|
131
154
|
*/
|
|
132
155
|
var updateProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
133
|
-
var productCategoryData,
|
|
134
|
-
var description = _b.description, id = _b.id,
|
|
135
|
-
return __generator(this, function (
|
|
136
|
-
switch (
|
|
156
|
+
var productCategoryData, where, productCategory;
|
|
157
|
+
var description = _b.description, id = _b.id, name = _b.name, prisma = _b.prisma;
|
|
158
|
+
return __generator(this, function (_c) {
|
|
159
|
+
switch (_c.label) {
|
|
137
160
|
case 0:
|
|
138
161
|
if (!id) {
|
|
139
162
|
throw new Error('Product category ID is required');
|
|
@@ -145,20 +168,16 @@ var updateProductCategory = function (_a) { return __awaiter(void 0, [_a], void
|
|
|
145
168
|
description: description || null,
|
|
146
169
|
name: name,
|
|
147
170
|
};
|
|
148
|
-
include = {
|
|
149
|
-
products: includeProducts,
|
|
150
|
-
};
|
|
151
171
|
where = {
|
|
152
172
|
id: id,
|
|
153
173
|
};
|
|
154
174
|
return [4 /*yield*/, prisma.productCategory.upsert({
|
|
155
175
|
create: __assign({ id: id }, productCategoryData),
|
|
156
|
-
include: include,
|
|
157
176
|
update: productCategoryData,
|
|
158
177
|
where: where,
|
|
159
178
|
})];
|
|
160
179
|
case 1:
|
|
161
|
-
productCategory =
|
|
180
|
+
productCategory = _c.sent();
|
|
162
181
|
return [2 /*return*/, productCategory];
|
|
163
182
|
}
|
|
164
183
|
});
|
|
@@ -170,26 +189,22 @@ exports.updateProductCategory = updateProductCategory;
|
|
|
170
189
|
* @returns {Promise<ProductCategoryBE>} Deleted product category
|
|
171
190
|
*/
|
|
172
191
|
var deleteProductCategory = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
173
|
-
var
|
|
174
|
-
var id = _b.id,
|
|
175
|
-
return __generator(this, function (
|
|
176
|
-
switch (
|
|
192
|
+
var where, productCategory;
|
|
193
|
+
var id = _b.id, prisma = _b.prisma;
|
|
194
|
+
return __generator(this, function (_c) {
|
|
195
|
+
switch (_c.label) {
|
|
177
196
|
case 0:
|
|
178
197
|
if (!id) {
|
|
179
198
|
throw new Error('Product category ID is required');
|
|
180
199
|
}
|
|
181
|
-
include = {
|
|
182
|
-
products: includeProducts,
|
|
183
|
-
};
|
|
184
200
|
where = {
|
|
185
201
|
id: id,
|
|
186
202
|
};
|
|
187
203
|
return [4 /*yield*/, prisma.productCategory.delete({
|
|
188
|
-
include: include,
|
|
189
204
|
where: where,
|
|
190
205
|
})];
|
|
191
206
|
case 1:
|
|
192
|
-
productCategory =
|
|
207
|
+
productCategory = _c.sent();
|
|
193
208
|
return [2 /*return*/, productCategory];
|
|
194
209
|
}
|
|
195
210
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { QuoteInvoiceBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListQuoteInvoiceArgs {
|
|
3
|
+
export interface ListQuoteInvoiceArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
5
|
includeCompany?: boolean;
|
|
6
6
|
includeCustomer?: boolean;
|
|
@@ -11,17 +11,18 @@ interface ListQuoteInvoiceArgs {
|
|
|
11
11
|
orderByDirection?: 'asc' | 'desc';
|
|
12
12
|
pageLimit?: number;
|
|
13
13
|
prisma: PrismaClient;
|
|
14
|
+
searchQuery?: string;
|
|
14
15
|
}
|
|
15
|
-
interface UnitQuoteInvoiceByIdArgs {
|
|
16
|
+
export interface UnitQuoteInvoiceByIdArgs {
|
|
16
17
|
id: string;
|
|
18
|
+
prisma: PrismaClient;
|
|
17
19
|
includeCompany?: boolean;
|
|
18
20
|
includeCustomer?: boolean;
|
|
19
21
|
includePayments?: boolean;
|
|
20
22
|
includeProducts?: boolean;
|
|
21
23
|
includeServices?: boolean;
|
|
22
|
-
prisma: PrismaClient;
|
|
23
24
|
}
|
|
24
|
-
interface UpdateQuoteInvoiceArgs {
|
|
25
|
+
export interface UpdateQuoteInvoiceArgs {
|
|
25
26
|
address?: string;
|
|
26
27
|
category: string;
|
|
27
28
|
city?: string;
|
|
@@ -58,21 +59,21 @@ interface UpdateQuoteInvoiceArgs {
|
|
|
58
59
|
taxRate: string;
|
|
59
60
|
total: string;
|
|
60
61
|
}
|
|
61
|
-
interface DeleteQuoteInvoiceArgs {
|
|
62
|
+
export interface DeleteQuoteInvoiceArgs {
|
|
62
63
|
id: string;
|
|
64
|
+
prisma: PrismaClient;
|
|
63
65
|
includeCompany?: boolean;
|
|
64
66
|
includeCustomer?: boolean;
|
|
65
67
|
includePayments?: boolean;
|
|
66
68
|
includeProducts?: boolean;
|
|
67
69
|
includeServices?: boolean;
|
|
68
|
-
prisma: PrismaClient;
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* Retrieves a paginated list of quotes/invoices
|
|
72
73
|
* @param {ListQuoteInvoiceArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
73
74
|
* @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of quotes/invoices
|
|
74
75
|
*/
|
|
75
|
-
export declare const listQuoteInvoice: ({ currentPage, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, orderByColumn, orderByDirection, pageLimit, prisma, }: ListQuoteInvoiceArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
|
|
76
|
+
export declare const listQuoteInvoice: ({ currentPage, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListQuoteInvoiceArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
|
|
76
77
|
/**
|
|
77
78
|
* Retrieves a single quote/invoice by its ID
|
|
78
79
|
* @param {UnitQuoteInvoiceByIdArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
|
|
@@ -91,5 +92,5 @@ export declare const updateQuoteInvoice: ({ address, category, city, companyId,
|
|
|
91
92
|
* @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
|
|
92
93
|
* @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
|
|
93
94
|
*/
|
|
94
|
-
export declare const deleteQuoteInvoice: ({ id,
|
|
95
|
+
export declare const deleteQuoteInvoice: ({ id, prisma, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
|
|
95
96
|
export {};
|
|
@@ -46,25 +46,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
46
46
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
50
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
51
|
+
if (ar || !(i in from)) {
|
|
52
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
53
|
+
ar[i] = from[i];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
57
|
+
};
|
|
49
58
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
59
|
exports.deleteQuoteInvoice = exports.updateQuoteInvoice = exports.unitQuoteInvoiceById = exports.listQuoteInvoice = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves a paginated list of quotes/invoices
|
|
53
63
|
* @param {ListQuoteInvoiceArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
64
|
* @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of quotes/invoices
|
|
55
65
|
*/
|
|
56
66
|
var listQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy,
|
|
67
|
+
var include, orderBy, idSearchQuery, noteSearchQuery, refSearchQuery, where, _c, count, items;
|
|
58
68
|
var _d;
|
|
59
|
-
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeCompany, includeCompany = _f === void 0 ? false : _f, _g = _b.includeCustomer, includeCustomer = _g === void 0 ? false : _g, _h = _b.includePayments, includePayments = _h === void 0 ? false : _h, _j = _b.includeProducts, includeProducts = _j === void 0 ? false : _j, _k = _b.includeServices, includeServices = _k === void 0 ? false : _k, _l = _b.orderByColumn, orderByColumn = _l === void 0 ? 'createdAt' : _l, _m = _b.orderByDirection, orderByDirection = _m === void 0 ? 'desc' : _m, _o = _b.pageLimit, pageLimit = _o === void 0 ?
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
69
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeCompany, includeCompany = _f === void 0 ? false : _f, _g = _b.includeCustomer, includeCustomer = _g === void 0 ? false : _g, _h = _b.includePayments, includePayments = _h === void 0 ? false : _h, _j = _b.includeProducts, includeProducts = _j === void 0 ? false : _j, _k = _b.includeServices, includeServices = _k === void 0 ? false : _k, _l = _b.orderByColumn, orderByColumn = _l === void 0 ? 'createdAt' : _l, _m = _b.orderByDirection, orderByDirection = _m === void 0 ? 'desc' : _m, _o = _b.pageLimit, pageLimit = _o === void 0 ? 5 : _o, prisma = _b.prisma, _p = _b.searchQuery, searchQuery = _p === void 0 ? '' : _p;
|
|
70
|
+
return __generator(this, function (_q) {
|
|
71
|
+
switch (_q.label) {
|
|
62
72
|
case 0:
|
|
63
|
-
if (currentPage < 1) {
|
|
64
|
-
throw new Error('
|
|
73
|
+
if (!currentPage || currentPage < 1) {
|
|
74
|
+
throw new Error('Valid current page is required');
|
|
65
75
|
}
|
|
66
|
-
if (pageLimit < 1) {
|
|
67
|
-
throw new Error('
|
|
76
|
+
if (!pageLimit || pageLimit < 1) {
|
|
77
|
+
throw new Error('Valid page limit is required');
|
|
68
78
|
}
|
|
69
79
|
include = {
|
|
70
80
|
company: includeCompany,
|
|
@@ -76,8 +86,21 @@ var listQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
76
86
|
orderBy = (_d = {},
|
|
77
87
|
_d[orderByColumn] = orderByDirection,
|
|
78
88
|
_d);
|
|
79
|
-
|
|
80
|
-
|
|
89
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
90
|
+
columnName: 'id',
|
|
91
|
+
fullText: searchQuery,
|
|
92
|
+
});
|
|
93
|
+
noteSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
94
|
+
columnName: 'note',
|
|
95
|
+
fullText: searchQuery,
|
|
96
|
+
});
|
|
97
|
+
refSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
98
|
+
columnName: 'ref',
|
|
99
|
+
fullText: searchQuery,
|
|
100
|
+
});
|
|
101
|
+
where = {
|
|
102
|
+
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), noteSearchQuery, true), refSearchQuery, true),
|
|
103
|
+
};
|
|
81
104
|
return [4 /*yield*/, prisma.$transaction([
|
|
82
105
|
prisma.quoteInvoice.count({
|
|
83
106
|
where: where,
|
|
@@ -85,13 +108,13 @@ var listQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
85
108
|
prisma.quoteInvoice.findMany({
|
|
86
109
|
include: include,
|
|
87
110
|
orderBy: orderBy,
|
|
88
|
-
skip:
|
|
111
|
+
skip: (currentPage - 1) * pageLimit,
|
|
89
112
|
take: pageLimit,
|
|
90
113
|
where: where,
|
|
91
114
|
}),
|
|
92
115
|
])];
|
|
93
116
|
case 1:
|
|
94
|
-
_c =
|
|
117
|
+
_c = _q.sent(), count = _c[0], items = _c[1];
|
|
95
118
|
return [2 /*return*/, [count, items]];
|
|
96
119
|
}
|
|
97
120
|
});
|
|
@@ -322,30 +345,22 @@ exports.updateQuoteInvoice = updateQuoteInvoice;
|
|
|
322
345
|
* @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
|
|
323
346
|
*/
|
|
324
347
|
var deleteQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
325
|
-
var
|
|
326
|
-
var id = _b.id,
|
|
327
|
-
return __generator(this, function (
|
|
328
|
-
switch (
|
|
348
|
+
var where, quoteInvoice;
|
|
349
|
+
var id = _b.id, prisma = _b.prisma;
|
|
350
|
+
return __generator(this, function (_c) {
|
|
351
|
+
switch (_c.label) {
|
|
329
352
|
case 0:
|
|
330
353
|
if (!id) {
|
|
331
354
|
throw new Error('Quote/invoice ID is required');
|
|
332
355
|
}
|
|
333
|
-
include = {
|
|
334
|
-
company: includeCompany,
|
|
335
|
-
customer: includeCustomer,
|
|
336
|
-
payments: includePayments,
|
|
337
|
-
products: includeProducts,
|
|
338
|
-
services: includeServices,
|
|
339
|
-
};
|
|
340
356
|
where = {
|
|
341
357
|
id: id,
|
|
342
358
|
};
|
|
343
359
|
return [4 /*yield*/, prisma.quoteInvoice.delete({
|
|
344
|
-
include: include,
|
|
345
360
|
where: where,
|
|
346
361
|
})];
|
|
347
362
|
case 1:
|
|
348
|
-
quoteInvoice =
|
|
363
|
+
quoteInvoice = _c.sent();
|
|
349
364
|
return [2 /*return*/, quoteInvoice];
|
|
350
365
|
}
|
|
351
366
|
});
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { TaxBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListTaxArgs {
|
|
3
|
+
export interface ListTaxArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
|
+
includePreference?: boolean;
|
|
5
6
|
orderByColumn?: string;
|
|
6
7
|
orderByDirection?: 'asc' | 'desc';
|
|
7
8
|
pageLimit?: number;
|
|
8
9
|
prisma: PrismaClient;
|
|
10
|
+
searchQuery?: string;
|
|
9
11
|
}
|
|
10
|
-
interface UnitTaxByIdArgs {
|
|
12
|
+
export interface UnitTaxByIdArgs {
|
|
11
13
|
id: string;
|
|
14
|
+
includePreference?: boolean;
|
|
12
15
|
prisma: PrismaClient;
|
|
13
16
|
}
|
|
14
|
-
interface UpdateTaxArgs {
|
|
17
|
+
export interface UpdateTaxArgs {
|
|
15
18
|
description?: string;
|
|
16
19
|
enabled: boolean;
|
|
17
20
|
id: string;
|
|
@@ -21,7 +24,7 @@ interface UpdateTaxArgs {
|
|
|
21
24
|
taxName: string;
|
|
22
25
|
taxRate: string;
|
|
23
26
|
}
|
|
24
|
-
interface DeleteTaxArgs {
|
|
27
|
+
export interface DeleteTaxArgs {
|
|
25
28
|
id: string;
|
|
26
29
|
prisma: PrismaClient;
|
|
27
30
|
}
|
|
@@ -30,13 +33,13 @@ interface DeleteTaxArgs {
|
|
|
30
33
|
* @param {ListTaxArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
31
34
|
* @returns {Promise<[number, Array<TaxBE>]>} Tuple containing total count and array of taxes
|
|
32
35
|
*/
|
|
33
|
-
export declare const listTax: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListTaxArgs) => Promise<[number, Array<TaxBE>]>;
|
|
36
|
+
export declare const listTax: ({ currentPage, includePreference, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListTaxArgs) => Promise<[number, Array<TaxBE>]>;
|
|
34
37
|
/**
|
|
35
38
|
* Retrieves a single tax by its ID
|
|
36
39
|
* @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional query parameters
|
|
37
40
|
* @returns {Promise<TaxBE | null>} Tax or null if not found
|
|
38
41
|
*/
|
|
39
|
-
export declare const unitTaxById: ({ id, prisma, }: UnitTaxByIdArgs) => Promise<TaxBE | null>;
|
|
42
|
+
export declare const unitTaxById: ({ id, includePreference, prisma, }: UnitTaxByIdArgs) => Promise<TaxBE | null>;
|
|
40
43
|
/**
|
|
41
44
|
* Creates or updates a tax
|
|
42
45
|
* @param {UpdateTaxArgs} args - Object containing prisma client, tax data, and optional query parameters
|