@react-pakistan/util-functions 1.24.70 → 1.24.72
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 +11 -8
- package/api/stellar-solutions/bank/index.js +58 -20
- 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.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
|
|
@@ -46,32 +46,57 @@ 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.deleteTax = exports.updateTax = exports.unitTaxById = exports.listTax = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves a paginated list of taxes
|
|
53
63
|
* @param {ListTaxArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
64
|
* @returns {Promise<[number, Array<TaxBE>]>} Tuple containing total count and array of taxes
|
|
55
65
|
*/
|
|
56
66
|
var listTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy,
|
|
67
|
+
var include, orderBy, idSearchQuery, nameSearchQuery, emailSearchQuery, where, _c, count, items;
|
|
58
68
|
var _d;
|
|
59
|
-
var
|
|
69
|
+
var currentPage = _b.currentPage, _e = _b.includePreference, includePreference = _e === void 0 ? false : _e, _f = _b.orderByColumn, orderByColumn = _f === void 0 ? 'createdAt' : _f, _g = _b.orderByDirection, orderByDirection = _g === void 0 ? 'desc' : _g, pageLimit = _b.pageLimit, prisma = _b.prisma, _h = _b.searchQuery, searchQuery = _h === void 0 ? '' : _h;
|
|
60
70
|
return __generator(this, function (_j) {
|
|
61
71
|
switch (_j.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
|
-
include = {
|
|
79
|
+
include = {
|
|
80
|
+
preference: includePreference,
|
|
81
|
+
};
|
|
70
82
|
orderBy = (_d = {},
|
|
71
83
|
_d[orderByColumn] = orderByDirection,
|
|
72
84
|
_d);
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
emailSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
94
|
+
columnName: 'email',
|
|
95
|
+
fullText: searchQuery,
|
|
96
|
+
});
|
|
97
|
+
where = {
|
|
98
|
+
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), nameSearchQuery, true), emailSearchQuery, true),
|
|
99
|
+
};
|
|
75
100
|
return [4 /*yield*/, prisma.$transaction([
|
|
76
101
|
prisma.tax.count({
|
|
77
102
|
where: where,
|
|
@@ -79,7 +104,7 @@ var listTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_
|
|
|
79
104
|
prisma.tax.findMany({
|
|
80
105
|
include: include,
|
|
81
106
|
orderBy: orderBy,
|
|
82
|
-
skip:
|
|
107
|
+
skip: (currentPage - 1) * pageLimit,
|
|
83
108
|
take: pageLimit,
|
|
84
109
|
where: where,
|
|
85
110
|
}),
|
|
@@ -98,14 +123,16 @@ exports.listTax = listTax;
|
|
|
98
123
|
*/
|
|
99
124
|
var unitTaxById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
100
125
|
var include, where, tax;
|
|
101
|
-
var id = _b.id, prisma = _b.prisma;
|
|
102
|
-
return __generator(this, function (
|
|
103
|
-
switch (
|
|
126
|
+
var id = _b.id, _c = _b.includePreference, includePreference = _c === void 0 ? false : _c, prisma = _b.prisma;
|
|
127
|
+
return __generator(this, function (_d) {
|
|
128
|
+
switch (_d.label) {
|
|
104
129
|
case 0:
|
|
105
130
|
if (!id) {
|
|
106
131
|
throw new Error('Tax ID is required');
|
|
107
132
|
}
|
|
108
|
-
include = {
|
|
133
|
+
include = {
|
|
134
|
+
preference: includePreference,
|
|
135
|
+
};
|
|
109
136
|
where = {
|
|
110
137
|
id: id,
|
|
111
138
|
};
|
|
@@ -114,7 +141,7 @@ var unitTaxById = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
114
141
|
where: where,
|
|
115
142
|
})];
|
|
116
143
|
case 1:
|
|
117
|
-
tax =
|
|
144
|
+
tax = _d.sent();
|
|
118
145
|
return [2 /*return*/, tax];
|
|
119
146
|
}
|
|
120
147
|
});
|
|
@@ -126,7 +153,7 @@ exports.unitTaxById = unitTaxById;
|
|
|
126
153
|
* @returns {Promise<TaxBE>} Created or updated tax
|
|
127
154
|
*/
|
|
128
155
|
var updateTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
129
|
-
var taxData,
|
|
156
|
+
var taxData, where, tax;
|
|
130
157
|
var description = _b.description, enabled = _b.enabled, id = _b.id, isDefault = _b.isDefault, preferenceId = _b.preferenceId, prisma = _b.prisma, taxName = _b.taxName, taxRate = _b.taxRate;
|
|
131
158
|
return __generator(this, function (_c) {
|
|
132
159
|
switch (_c.label) {
|
|
@@ -157,13 +184,11 @@ var updateTax = function (_a) { return __awaiter(void 0, [_a], void 0, function
|
|
|
157
184
|
taxName: taxName,
|
|
158
185
|
taxRate: taxRate,
|
|
159
186
|
};
|
|
160
|
-
include = {};
|
|
161
187
|
where = {
|
|
162
188
|
id: id,
|
|
163
189
|
};
|
|
164
190
|
return [4 /*yield*/, prisma.tax.upsert({
|
|
165
191
|
create: __assign({ id: id }, taxData),
|
|
166
|
-
include: include,
|
|
167
192
|
update: taxData,
|
|
168
193
|
where: where,
|
|
169
194
|
})];
|
|
@@ -180,7 +205,7 @@ exports.updateTax = updateTax;
|
|
|
180
205
|
* @returns {Promise<TaxBE>} Deleted tax
|
|
181
206
|
*/
|
|
182
207
|
var deleteTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
183
|
-
var
|
|
208
|
+
var where, tax;
|
|
184
209
|
var id = _b.id, prisma = _b.prisma;
|
|
185
210
|
return __generator(this, function (_c) {
|
|
186
211
|
switch (_c.label) {
|
|
@@ -188,12 +213,10 @@ var deleteTax = function (_a) { return __awaiter(void 0, [_a], void 0, function
|
|
|
188
213
|
if (!id) {
|
|
189
214
|
throw new Error('Tax ID is required');
|
|
190
215
|
}
|
|
191
|
-
include = {};
|
|
192
216
|
where = {
|
|
193
217
|
id: id,
|
|
194
218
|
};
|
|
195
219
|
return [4 /*yield*/, prisma.tax.delete({
|
|
196
|
-
include: include,
|
|
197
220
|
where: where,
|
|
198
221
|
})];
|
|
199
222
|
case 1:
|