@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
|
@@ -64,11 +64,11 @@ var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
|
64
64
|
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple of [total count, array of companies]
|
|
65
65
|
*/
|
|
66
66
|
var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
67
|
-
var idSearchQuery, nameSearchQuery, emailSearchQuery, where,
|
|
68
|
-
var
|
|
69
|
-
var
|
|
70
|
-
return __generator(this, function (
|
|
71
|
-
switch (
|
|
67
|
+
var include, orderBy, idSearchQuery, nameSearchQuery, emailSearchQuery, where, _c, count, items;
|
|
68
|
+
var _d;
|
|
69
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includeContacts, includeContacts = _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) {
|
|
72
72
|
case 0:
|
|
73
73
|
if (!currentPage || currentPage < 1) {
|
|
74
74
|
throw new Error('Valid current page is required');
|
|
@@ -76,6 +76,13 @@ var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
76
76
|
if (!pageLimit || pageLimit < 1) {
|
|
77
77
|
throw new Error('Valid page limit is required');
|
|
78
78
|
}
|
|
79
|
+
include = {
|
|
80
|
+
contacts: includeContacts,
|
|
81
|
+
quotesInvoices: includeQuotesInvoices,
|
|
82
|
+
};
|
|
83
|
+
orderBy = (_d = {},
|
|
84
|
+
_d[orderByColumn] = orderByDirection,
|
|
85
|
+
_d);
|
|
79
86
|
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
80
87
|
columnName: 'id',
|
|
81
88
|
fullText: searchQuery,
|
|
@@ -96,17 +103,16 @@ var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
96
103
|
where: where,
|
|
97
104
|
}),
|
|
98
105
|
prisma.company.findMany({
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
_c),
|
|
106
|
+
include: include,
|
|
107
|
+
orderBy: orderBy,
|
|
102
108
|
skip: (currentPage - 1) * pageLimit,
|
|
103
109
|
take: pageLimit,
|
|
104
110
|
where: where,
|
|
105
111
|
}),
|
|
106
112
|
])];
|
|
107
113
|
case 1:
|
|
108
|
-
|
|
109
|
-
return [2 /*return*/,
|
|
114
|
+
_c = _m.sent(), count = _c[0], items = _c[1];
|
|
115
|
+
return [2 /*return*/, [count, items]];
|
|
110
116
|
}
|
|
111
117
|
});
|
|
112
118
|
}); };
|
|
@@ -117,21 +123,27 @@ exports.listCompany = listCompany;
|
|
|
117
123
|
* @returns {Promise<CompanyBE | null>} Company if found, null otherwise
|
|
118
124
|
*/
|
|
119
125
|
var unitCompanyById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
120
|
-
var company;
|
|
121
|
-
var id = _b.id, prisma = _b.prisma;
|
|
122
|
-
return __generator(this, function (
|
|
123
|
-
switch (
|
|
126
|
+
var include, where, company;
|
|
127
|
+
var id = _b.id, _c = _b.includeContacts, includeContacts = _c === void 0 ? false : _c, _d = _b.includeQuotesInvoices, includeQuotesInvoices = _d === void 0 ? false : _d, prisma = _b.prisma;
|
|
128
|
+
return __generator(this, function (_e) {
|
|
129
|
+
switch (_e.label) {
|
|
124
130
|
case 0:
|
|
125
131
|
if (!id) {
|
|
126
132
|
throw new Error('Company ID is required');
|
|
127
133
|
}
|
|
134
|
+
include = {
|
|
135
|
+
contacts: includeContacts,
|
|
136
|
+
quotesInvoices: includeQuotesInvoices,
|
|
137
|
+
};
|
|
138
|
+
where = {
|
|
139
|
+
id: id,
|
|
140
|
+
};
|
|
128
141
|
return [4 /*yield*/, prisma.company.findUnique({
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
},
|
|
142
|
+
include: include,
|
|
143
|
+
where: where,
|
|
132
144
|
})];
|
|
133
145
|
case 1:
|
|
134
|
-
company =
|
|
146
|
+
company = _e.sent();
|
|
135
147
|
return [2 /*return*/, company];
|
|
136
148
|
}
|
|
137
149
|
});
|
|
@@ -143,7 +155,7 @@ exports.unitCompanyById = unitCompanyById;
|
|
|
143
155
|
* @returns {Promise<CompanyBE>} Created or updated company
|
|
144
156
|
*/
|
|
145
157
|
var updateCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
146
|
-
var companyData, company;
|
|
158
|
+
var companyData, where, company;
|
|
147
159
|
var country = _b.country, email = _b.email, id = _b.id, name = _b.name, phone = _b.phone, prisma = _b.prisma, website = _b.website;
|
|
148
160
|
return __generator(this, function (_c) {
|
|
149
161
|
switch (_c.label) {
|
|
@@ -161,12 +173,13 @@ var updateCompany = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
161
173
|
phone: phone,
|
|
162
174
|
website: website || null,
|
|
163
175
|
};
|
|
176
|
+
where = {
|
|
177
|
+
id: id,
|
|
178
|
+
};
|
|
164
179
|
return [4 /*yield*/, prisma.company.upsert({
|
|
165
|
-
where: {
|
|
166
|
-
id: id,
|
|
167
|
-
},
|
|
168
|
-
update: companyData,
|
|
169
180
|
create: __assign({ id: id }, companyData),
|
|
181
|
+
update: companyData,
|
|
182
|
+
where: where,
|
|
170
183
|
})];
|
|
171
184
|
case 1:
|
|
172
185
|
company = _c.sent();
|
|
@@ -182,7 +195,7 @@ exports.updateCompany = updateCompany;
|
|
|
182
195
|
* @throws {Error} If company ID is not provided or company not found
|
|
183
196
|
*/
|
|
184
197
|
var deleteCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
185
|
-
var company;
|
|
198
|
+
var where, company;
|
|
186
199
|
var id = _b.id, prisma = _b.prisma;
|
|
187
200
|
return __generator(this, function (_c) {
|
|
188
201
|
switch (_c.label) {
|
|
@@ -190,10 +203,11 @@ var deleteCompany = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
190
203
|
if (!id) {
|
|
191
204
|
throw new Error('Company ID is required');
|
|
192
205
|
}
|
|
206
|
+
where = {
|
|
207
|
+
id: id,
|
|
208
|
+
};
|
|
193
209
|
return [4 /*yield*/, prisma.company.delete({
|
|
194
|
-
where:
|
|
195
|
-
id: id,
|
|
196
|
-
},
|
|
210
|
+
where: where,
|
|
197
211
|
})];
|
|
198
212
|
case 1:
|
|
199
213
|
company = _c.sent();
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { ContactBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListContactArgs {
|
|
4
|
-
currentPage
|
|
3
|
+
export interface ListContactArgs {
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
includeCompany?: boolean;
|
|
5
6
|
orderByColumn?: string;
|
|
6
7
|
orderByDirection?: 'asc' | 'desc';
|
|
7
|
-
pageLimit
|
|
8
|
+
pageLimit?: number;
|
|
8
9
|
prisma: PrismaClient;
|
|
10
|
+
searchQuery?: string;
|
|
9
11
|
}
|
|
10
|
-
interface UnitContactByIdArgs {
|
|
12
|
+
export interface UnitContactByIdArgs {
|
|
11
13
|
id: string;
|
|
14
|
+
includeCompany?: boolean;
|
|
12
15
|
prisma: PrismaClient;
|
|
13
16
|
}
|
|
14
|
-
interface UpdateContactArgs {
|
|
17
|
+
export interface UpdateContactArgs {
|
|
15
18
|
companyId: string;
|
|
16
19
|
country: string;
|
|
17
20
|
email: string;
|
|
@@ -21,7 +24,7 @@ interface UpdateContactArgs {
|
|
|
21
24
|
phone: string;
|
|
22
25
|
prisma: PrismaClient;
|
|
23
26
|
}
|
|
24
|
-
interface DeleteContactArgs {
|
|
27
|
+
export interface DeleteContactArgs {
|
|
25
28
|
id: string;
|
|
26
29
|
prisma: PrismaClient;
|
|
27
30
|
}
|
|
@@ -30,13 +33,13 @@ interface DeleteContactArgs {
|
|
|
30
33
|
* @param {ListContactArgs} args - Object containing prisma client, pagination, and query options
|
|
31
34
|
* @returns {Promise<[number, Array<ContactBE>]>} Tuple containing total count and array of contacts
|
|
32
35
|
*/
|
|
33
|
-
export declare const listContact: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListContactArgs) => Promise<[number, Array<ContactBE>]>;
|
|
36
|
+
export declare const listContact: ({ currentPage, includeCompany, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListContactArgs) => Promise<[number, Array<ContactBE>]>;
|
|
34
37
|
/**
|
|
35
38
|
* Retrieves a single contact by ID
|
|
36
39
|
* @param {UnitContactByIdArgs} args - Object containing prisma client and query where conditions
|
|
37
40
|
* @returns {Promise<ContactBE | null>} Contact if found, null otherwise
|
|
38
41
|
*/
|
|
39
|
-
export declare const unitContactById: ({
|
|
42
|
+
export declare const unitContactById: ({ id, includeCompany, prisma, }: UnitContactByIdArgs) => Promise<ContactBE | null>;
|
|
40
43
|
/**
|
|
41
44
|
* Creates or updates a contact
|
|
42
45
|
* @param {UpdateContactArgs} args - Object containing prisma client and contact data
|
|
@@ -49,5 +52,5 @@ export declare const updateContact: ({ prisma, id, companyId, country, email, fi
|
|
|
49
52
|
* @returns {Promise<ContactBE>} Deleted contact
|
|
50
53
|
* @throws {Error} If contact ID is not provided or contact not found
|
|
51
54
|
*/
|
|
52
|
-
export declare const deleteContact: ({
|
|
55
|
+
export declare const deleteContact: ({ id, prisma, }: DeleteContactArgs) => Promise<ContactBE>;
|
|
53
56
|
export {};
|
|
@@ -46,37 +46,76 @@ 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.deleteContact = exports.updateContact = exports.unitContactById = exports.listContact = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves contacts with pagination and filtering
|
|
53
63
|
* @param {ListContactArgs} args - Object containing prisma client, pagination, and query options
|
|
54
64
|
* @returns {Promise<[number, Array<ContactBE>]>} Tuple containing total count and array of contacts
|
|
55
65
|
*/
|
|
56
66
|
var listContact = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var _c, count,
|
|
67
|
+
var include, orderBy, idSearchQuery, firstNameSearchQuery, lastNameSearchQuery, emailSearchQuery, where, _c, count, items;
|
|
58
68
|
var _d;
|
|
59
|
-
var
|
|
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.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) {
|
|
73
|
+
if (!currentPage || currentPage < 1) {
|
|
64
74
|
throw new Error('Valid current page is required');
|
|
65
75
|
}
|
|
66
|
-
if (pageLimit < 1) {
|
|
76
|
+
if (!pageLimit || pageLimit < 1) {
|
|
67
77
|
throw new Error('Valid page limit is required');
|
|
68
78
|
}
|
|
79
|
+
include = {
|
|
80
|
+
company: includeCompany,
|
|
81
|
+
};
|
|
82
|
+
orderBy = (_d = {},
|
|
83
|
+
_d[orderByColumn] = orderByDirection,
|
|
84
|
+
_d);
|
|
85
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
86
|
+
columnName: 'id',
|
|
87
|
+
fullText: searchQuery,
|
|
88
|
+
});
|
|
89
|
+
firstNameSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
90
|
+
columnName: 'firstName',
|
|
91
|
+
fullText: searchQuery,
|
|
92
|
+
});
|
|
93
|
+
lastNameSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
94
|
+
columnName: 'lastName',
|
|
95
|
+
fullText: searchQuery,
|
|
96
|
+
});
|
|
97
|
+
emailSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
98
|
+
columnName: 'email',
|
|
99
|
+
fullText: searchQuery,
|
|
100
|
+
});
|
|
101
|
+
where = {
|
|
102
|
+
OR: __spreadArray(__spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), firstNameSearchQuery, true), lastNameSearchQuery, true), emailSearchQuery, true),
|
|
103
|
+
};
|
|
69
104
|
return [4 /*yield*/, prisma.$transaction([
|
|
70
|
-
prisma.contact.count(
|
|
105
|
+
prisma.contact.count({
|
|
106
|
+
where: where,
|
|
107
|
+
}),
|
|
71
108
|
prisma.contact.findMany({
|
|
72
|
-
|
|
109
|
+
include: include,
|
|
110
|
+
orderBy: orderBy,
|
|
73
111
|
take: pageLimit,
|
|
74
112
|
skip: (currentPage - 1) * pageLimit,
|
|
113
|
+
where: where,
|
|
75
114
|
}),
|
|
76
115
|
])];
|
|
77
116
|
case 1:
|
|
78
|
-
_c =
|
|
79
|
-
return [2 /*return*/, [count,
|
|
117
|
+
_c = _l.sent(), count = _c[0], items = _c[1];
|
|
118
|
+
return [2 /*return*/, [count, items]];
|
|
80
119
|
}
|
|
81
120
|
});
|
|
82
121
|
}); };
|
|
@@ -87,19 +126,26 @@ exports.listContact = listContact;
|
|
|
87
126
|
* @returns {Promise<ContactBE | null>} Contact if found, null otherwise
|
|
88
127
|
*/
|
|
89
128
|
var unitContactById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
90
|
-
var contact;
|
|
91
|
-
var
|
|
92
|
-
return __generator(this, function (
|
|
93
|
-
switch (
|
|
129
|
+
var include, where, contact;
|
|
130
|
+
var id = _b.id, _c = _b.includeCompany, includeCompany = _c === void 0 ? false : _c, prisma = _b.prisma;
|
|
131
|
+
return __generator(this, function (_d) {
|
|
132
|
+
switch (_d.label) {
|
|
94
133
|
case 0:
|
|
95
134
|
if (!id) {
|
|
96
135
|
throw new Error('Contact ID is required');
|
|
97
136
|
}
|
|
137
|
+
include = {
|
|
138
|
+
company: includeCompany,
|
|
139
|
+
};
|
|
140
|
+
where = {
|
|
141
|
+
id: id,
|
|
142
|
+
};
|
|
98
143
|
return [4 /*yield*/, prisma.contact.findUnique({
|
|
99
|
-
|
|
144
|
+
include: include,
|
|
145
|
+
where: where,
|
|
100
146
|
})];
|
|
101
147
|
case 1:
|
|
102
|
-
contact =
|
|
148
|
+
contact = _d.sent();
|
|
103
149
|
return [2 /*return*/, contact];
|
|
104
150
|
}
|
|
105
151
|
});
|
|
@@ -111,7 +157,7 @@ exports.unitContactById = unitContactById;
|
|
|
111
157
|
* @returns {Promise<ContactBE>} Created or updated contact
|
|
112
158
|
*/
|
|
113
159
|
var updateContact = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
114
|
-
var contactData, contact;
|
|
160
|
+
var contactData, where, contact;
|
|
115
161
|
var prisma = _b.prisma, id = _b.id, companyId = _b.companyId, country = _b.country, email = _b.email, firstName = _b.firstName, lastName = _b.lastName, phone = _b.phone;
|
|
116
162
|
return __generator(this, function (_c) {
|
|
117
163
|
switch (_c.label) {
|
|
@@ -130,10 +176,11 @@ var updateContact = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
130
176
|
lastName: lastName,
|
|
131
177
|
phone: phone,
|
|
132
178
|
};
|
|
179
|
+
where = { id: id };
|
|
133
180
|
return [4 /*yield*/, prisma.contact.upsert({
|
|
134
|
-
where: { id: id },
|
|
135
|
-
update: contactData,
|
|
136
181
|
create: __assign({ id: id }, contactData),
|
|
182
|
+
update: contactData,
|
|
183
|
+
where: where,
|
|
137
184
|
})];
|
|
138
185
|
case 1:
|
|
139
186
|
contact = _c.sent();
|
|
@@ -149,16 +196,17 @@ exports.updateContact = updateContact;
|
|
|
149
196
|
* @throws {Error} If contact ID is not provided or contact not found
|
|
150
197
|
*/
|
|
151
198
|
var deleteContact = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
152
|
-
var contact;
|
|
153
|
-
var
|
|
199
|
+
var where, contact;
|
|
200
|
+
var id = _b.id, prisma = _b.prisma;
|
|
154
201
|
return __generator(this, function (_c) {
|
|
155
202
|
switch (_c.label) {
|
|
156
203
|
case 0:
|
|
157
204
|
if (!id) {
|
|
158
205
|
throw new Error('Contact ID is required');
|
|
159
206
|
}
|
|
207
|
+
where = { id: id };
|
|
160
208
|
return [4 /*yield*/, prisma.contact.delete({
|
|
161
|
-
where:
|
|
209
|
+
where: where,
|
|
162
210
|
})];
|
|
163
211
|
case 1:
|
|
164
212
|
contact = _c.sent();
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { CurrencyBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListCurrencyArgs {
|
|
4
|
-
currentPage
|
|
3
|
+
export interface ListCurrencyArgs {
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
includePreference?: boolean;
|
|
5
6
|
orderByColumn?: string;
|
|
6
7
|
orderByDirection?: 'asc' | 'desc';
|
|
7
|
-
pageLimit
|
|
8
|
+
pageLimit?: number;
|
|
8
9
|
prisma: PrismaClient;
|
|
10
|
+
searchQuery?: string;
|
|
9
11
|
}
|
|
10
|
-
interface UnitCurrencyByIdArgs {
|
|
12
|
+
export interface UnitCurrencyByIdArgs {
|
|
11
13
|
id: string;
|
|
14
|
+
includePreference?: boolean;
|
|
12
15
|
prisma: PrismaClient;
|
|
13
16
|
}
|
|
14
|
-
interface UpdateCurrencyArgs {
|
|
17
|
+
export interface UpdateCurrencyArgs {
|
|
15
18
|
code: string;
|
|
16
19
|
enabled: boolean;
|
|
17
20
|
id: string;
|
|
@@ -20,7 +23,7 @@ interface UpdateCurrencyArgs {
|
|
|
20
23
|
preferenceId: string;
|
|
21
24
|
prisma: PrismaClient;
|
|
22
25
|
}
|
|
23
|
-
interface DeleteCurrencyArgs {
|
|
26
|
+
export interface DeleteCurrencyArgs {
|
|
24
27
|
id: string;
|
|
25
28
|
prisma: PrismaClient;
|
|
26
29
|
}
|
|
@@ -29,13 +32,13 @@ interface DeleteCurrencyArgs {
|
|
|
29
32
|
* @param {ListCurrencyArgs} args - Object containing prisma client, pagination, and query options
|
|
30
33
|
* @returns {Promise<[number, Array<CurrencyBE>]>} Tuple containing total count and array of currencies
|
|
31
34
|
*/
|
|
32
|
-
export declare const listCurrency: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListCurrencyArgs) => Promise<[number, Array<CurrencyBE>]>;
|
|
35
|
+
export declare const listCurrency: ({ currentPage, includePreference, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListCurrencyArgs) => Promise<[number, Array<CurrencyBE>]>;
|
|
33
36
|
/**
|
|
34
37
|
* Retrieves a single currency by ID
|
|
35
38
|
* @param {UnitCurrencyByIdArgs} args - Object containing prisma client and query where conditions
|
|
36
39
|
* @returns {Promise<CurrencyBE | null>} Currency if found, null otherwise
|
|
37
40
|
*/
|
|
38
|
-
export declare const unitCurrencyById: ({ id, prisma, }: UnitCurrencyByIdArgs) => Promise<CurrencyBE | null>;
|
|
41
|
+
export declare const unitCurrencyById: ({ id, includePreference, prisma, }: UnitCurrencyByIdArgs) => Promise<CurrencyBE | null>;
|
|
39
42
|
/**
|
|
40
43
|
* Creates or updates a currency
|
|
41
44
|
* @param {UpdateCurrencyArgs} args - Object containing prisma client and currency data
|
|
@@ -46,40 +46,68 @@ 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.deleteCurrency = exports.updateCurrency = exports.unitCurrencyById = exports.listCurrency = void 0;
|
|
60
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
51
61
|
/**
|
|
52
62
|
* Retrieves currencies with pagination and filtering
|
|
53
63
|
* @param {ListCurrencyArgs} args - Object containing prisma client, pagination, and query options
|
|
54
64
|
* @returns {Promise<[number, Array<CurrencyBE>]>} Tuple containing total count and array of currencies
|
|
55
65
|
*/
|
|
56
66
|
var listCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var
|
|
67
|
+
var orderBy, include, idSearchQuery, labelSearchQuery, where, _c, count, items;
|
|
58
68
|
var _d;
|
|
59
|
-
var
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
69
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includePreference, includePreference = _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) {
|
|
73
|
+
if (!currentPage || currentPage < 1) {
|
|
64
74
|
throw new Error('Valid current page is required');
|
|
65
75
|
}
|
|
66
|
-
if (pageLimit < 1) {
|
|
76
|
+
if (!pageLimit || pageLimit < 1) {
|
|
67
77
|
throw new Error('Valid page limit is required');
|
|
68
78
|
}
|
|
69
|
-
|
|
79
|
+
orderBy = (_d = {},
|
|
80
|
+
_d[orderByColumn] = orderByDirection,
|
|
81
|
+
_d);
|
|
82
|
+
include = {
|
|
83
|
+
preference: includePreference,
|
|
84
|
+
};
|
|
85
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
86
|
+
columnName: 'id',
|
|
87
|
+
fullText: searchQuery,
|
|
88
|
+
});
|
|
89
|
+
labelSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
90
|
+
columnName: 'label',
|
|
91
|
+
fullText: searchQuery,
|
|
92
|
+
});
|
|
93
|
+
where = {
|
|
94
|
+
OR: __spreadArray(__spreadArray([], idSearchQuery, true), labelSearchQuery, true),
|
|
95
|
+
};
|
|
70
96
|
return [4 /*yield*/, prisma.$transaction([
|
|
71
|
-
prisma.currency.count(
|
|
97
|
+
prisma.currency.count({
|
|
98
|
+
where: where,
|
|
99
|
+
}),
|
|
72
100
|
prisma.currency.findMany({
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
skip: skip,
|
|
101
|
+
include: include,
|
|
102
|
+
orderBy: orderBy,
|
|
103
|
+
skip: (currentPage - 1) * pageLimit,
|
|
77
104
|
take: pageLimit,
|
|
105
|
+
where: where,
|
|
78
106
|
}),
|
|
79
107
|
])];
|
|
80
108
|
case 1:
|
|
81
|
-
_c =
|
|
82
|
-
return [2 /*return*/, [count,
|
|
109
|
+
_c = _l.sent(), count = _c[0], items = _c[1];
|
|
110
|
+
return [2 /*return*/, [count, items]];
|
|
83
111
|
}
|
|
84
112
|
});
|
|
85
113
|
}); };
|
|
@@ -90,21 +118,26 @@ exports.listCurrency = listCurrency;
|
|
|
90
118
|
* @returns {Promise<CurrencyBE | null>} Currency if found, null otherwise
|
|
91
119
|
*/
|
|
92
120
|
var unitCurrencyById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
93
|
-
var currency;
|
|
94
|
-
var id = _b.id, prisma = _b.prisma;
|
|
95
|
-
return __generator(this, function (
|
|
96
|
-
switch (
|
|
121
|
+
var include, where, currency;
|
|
122
|
+
var id = _b.id, _c = _b.includePreference, includePreference = _c === void 0 ? false : _c, prisma = _b.prisma;
|
|
123
|
+
return __generator(this, function (_d) {
|
|
124
|
+
switch (_d.label) {
|
|
97
125
|
case 0:
|
|
98
126
|
if (!id) {
|
|
99
127
|
throw new Error('Currency ID is required');
|
|
100
128
|
}
|
|
129
|
+
include = {
|
|
130
|
+
preference: includePreference,
|
|
131
|
+
};
|
|
132
|
+
where = {
|
|
133
|
+
id: id,
|
|
134
|
+
};
|
|
101
135
|
return [4 /*yield*/, prisma.currency.findUnique({
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
},
|
|
136
|
+
include: include,
|
|
137
|
+
where: where,
|
|
105
138
|
})];
|
|
106
139
|
case 1:
|
|
107
|
-
currency =
|
|
140
|
+
currency = _d.sent();
|
|
108
141
|
return [2 /*return*/, currency];
|
|
109
142
|
}
|
|
110
143
|
});
|
|
@@ -116,7 +149,7 @@ exports.unitCurrencyById = unitCurrencyById;
|
|
|
116
149
|
* @returns {Promise<CurrencyBE>} Created or updated currency
|
|
117
150
|
*/
|
|
118
151
|
var updateCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
119
|
-
var currencyData, currency;
|
|
152
|
+
var currencyData, where, currency;
|
|
120
153
|
var code = _b.code, enabled = _b.enabled, id = _b.id, _c = _b.isDefault, isDefault = _c === void 0 ? false : _c, label = _b.label, preferenceId = _b.preferenceId, prisma = _b.prisma;
|
|
121
154
|
return __generator(this, function (_d) {
|
|
122
155
|
switch (_d.label) {
|
|
@@ -134,12 +167,13 @@ var updateCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
134
167
|
label: label,
|
|
135
168
|
preferenceId: preferenceId,
|
|
136
169
|
};
|
|
170
|
+
where = {
|
|
171
|
+
id: id,
|
|
172
|
+
};
|
|
137
173
|
return [4 /*yield*/, prisma.currency.upsert({
|
|
138
|
-
where: {
|
|
139
|
-
id: id,
|
|
140
|
-
},
|
|
141
|
-
update: currencyData,
|
|
142
174
|
create: __assign({ id: id }, currencyData),
|
|
175
|
+
update: currencyData,
|
|
176
|
+
where: where,
|
|
143
177
|
})];
|
|
144
178
|
case 1:
|
|
145
179
|
currency = _d.sent();
|
|
@@ -155,7 +189,7 @@ exports.updateCurrency = updateCurrency;
|
|
|
155
189
|
* @throws {Error} If currency ID is not provided or currency not found
|
|
156
190
|
*/
|
|
157
191
|
var deleteCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
158
|
-
var currency;
|
|
192
|
+
var where, currency;
|
|
159
193
|
var id = _b.id, prisma = _b.prisma;
|
|
160
194
|
return __generator(this, function (_c) {
|
|
161
195
|
switch (_c.label) {
|
|
@@ -163,10 +197,11 @@ var deleteCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
163
197
|
if (!id) {
|
|
164
198
|
throw new Error('Currency ID is required');
|
|
165
199
|
}
|
|
200
|
+
where = {
|
|
201
|
+
id: id,
|
|
202
|
+
};
|
|
166
203
|
return [4 /*yield*/, prisma.currency.delete({
|
|
167
|
-
where:
|
|
168
|
-
id: id,
|
|
169
|
-
},
|
|
204
|
+
where: where,
|
|
170
205
|
})];
|
|
171
206
|
case 1:
|
|
172
207
|
currency = _c.sent();
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { CustomerBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListCustomerArgs {
|
|
4
|
-
currentPage
|
|
3
|
+
export interface ListCustomerArgs {
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
includeQuotesInvoices?: boolean;
|
|
5
6
|
orderByColumn?: string;
|
|
6
7
|
orderByDirection?: 'asc' | 'desc';
|
|
7
|
-
pageLimit
|
|
8
|
+
pageLimit?: number;
|
|
8
9
|
prisma: PrismaClient;
|
|
10
|
+
searchQuery?: string;
|
|
9
11
|
}
|
|
10
|
-
interface UnitCustomerByIdArgs {
|
|
12
|
+
export interface UnitCustomerByIdArgs {
|
|
11
13
|
id: string;
|
|
14
|
+
includeQuotesInvoices?: boolean;
|
|
12
15
|
prisma: PrismaClient;
|
|
13
16
|
}
|
|
14
|
-
interface UnitCustomerByPhoneArgs {
|
|
17
|
+
export interface UnitCustomerByPhoneArgs {
|
|
18
|
+
includeQuotesInvoices?: boolean;
|
|
15
19
|
phone: string;
|
|
16
20
|
prisma: PrismaClient;
|
|
17
21
|
}
|
|
18
|
-
interface UpdateCustomerArgs {
|
|
22
|
+
export interface UpdateCustomerArgs {
|
|
19
23
|
address?: string;
|
|
20
24
|
city: string;
|
|
21
25
|
country: string;
|
|
@@ -26,7 +30,7 @@ interface UpdateCustomerArgs {
|
|
|
26
30
|
phone: string;
|
|
27
31
|
prisma: PrismaClient;
|
|
28
32
|
}
|
|
29
|
-
interface DeleteCustomerArgs {
|
|
33
|
+
export interface DeleteCustomerArgs {
|
|
30
34
|
id: string;
|
|
31
35
|
prisma: PrismaClient;
|
|
32
36
|
}
|
|
@@ -35,19 +39,19 @@ interface DeleteCustomerArgs {
|
|
|
35
39
|
* @param {ListCustomerArgs} args - Object containing prisma client, pagination, and query options
|
|
36
40
|
* @returns {Promise<[number, Array<CustomerBE>]>} Tuple containing total count and array of customers
|
|
37
41
|
*/
|
|
38
|
-
export declare const listCustomer: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListCustomerArgs) => Promise<[number, Array<CustomerBE>]>;
|
|
42
|
+
export declare const listCustomer: ({ currentPage, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListCustomerArgs) => Promise<[number, Array<CustomerBE>]>;
|
|
39
43
|
/**
|
|
40
44
|
* Retrieves a single customer by ID
|
|
41
45
|
* @param {UnitCustomerByIdArgs} args - Object containing prisma client and query where conditions
|
|
42
46
|
* @returns {Promise<CustomerBE | null>} Customer if found, null otherwise
|
|
43
47
|
*/
|
|
44
|
-
export declare const unitCustomerById: ({ id, prisma, }: UnitCustomerByIdArgs) => Promise<CustomerBE | null>;
|
|
48
|
+
export declare const unitCustomerById: ({ id, prisma, includeQuotesInvoices, }: UnitCustomerByIdArgs) => Promise<CustomerBE | null>;
|
|
45
49
|
/**
|
|
46
50
|
* Retrieves a single customer by phone number
|
|
47
51
|
* @param {UnitCustomerByPhoneArgs} args - Object containing prisma client and phone number
|
|
48
52
|
* @returns {Promise<CustomerBE | null>} Customer if found, null otherwise
|
|
49
53
|
*/
|
|
50
|
-
export declare const unitCustomerByPhone: ({ phone, prisma, }: UnitCustomerByPhoneArgs) => Promise<CustomerBE | null>;
|
|
54
|
+
export declare const unitCustomerByPhone: ({ includeQuotesInvoices, phone, prisma, }: UnitCustomerByPhoneArgs) => Promise<CustomerBE | null>;
|
|
51
55
|
/**
|
|
52
56
|
* Creates or updates a customer
|
|
53
57
|
* @param {UpdateCustomerArgs} args - Object containing prisma client and customer data
|