@react-pakistan/util-functions 1.24.66 → 1.24.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/stellar-solutions/app-user/index.d.ts +8 -31
- package/api/stellar-solutions/app-user/index.js +26 -24
- package/api/stellar-solutions/bank/index.d.ts +9 -32
- package/api/stellar-solutions/bank/index.js +19 -25
- package/api/stellar-solutions/branch/index.d.ts +9 -32
- package/api/stellar-solutions/branch/index.js +19 -25
- package/api/stellar-solutions/company/index.d.ts +9 -32
- package/api/stellar-solutions/company/index.js +29 -27
- package/api/stellar-solutions/company-report/index.d.ts +5 -12
- package/api/stellar-solutions/company-report/index.js +23 -16
- package/api/stellar-solutions/contact/index.d.ts +8 -31
- package/api/stellar-solutions/contact/index.js +19 -25
- package/api/stellar-solutions/currency/index.d.ts +8 -31
- package/api/stellar-solutions/currency/index.js +30 -27
- package/api/stellar-solutions/customer/index.d.ts +9 -35
- package/api/stellar-solutions/customer/index.js +31 -30
- package/api/stellar-solutions/expense/index.d.ts +11 -32
- package/api/stellar-solutions/expense/index.js +41 -50
- package/api/stellar-solutions/expense-category/index.d.ts +13 -34
- package/api/stellar-solutions/expense-category/index.js +64 -52
- package/api/stellar-solutions/lead/index.d.ts +35 -19
- package/api/stellar-solutions/lead/index.js +117 -82
- package/api/stellar-solutions/menu-order/index.d.ts +19 -15
- package/api/stellar-solutions/menu-order/index.js +43 -33
- package/api/stellar-solutions/payment/index.d.ts +30 -47
- package/api/stellar-solutions/payment/index.js +64 -65
- package/api/stellar-solutions/payment-mode/index.d.ts +6 -13
- package/api/stellar-solutions/payment-mode/index.js +28 -46
- package/api/stellar-solutions/preference/index.d.ts +11 -9
- package/api/stellar-solutions/preference/index.js +30 -37
- package/api/stellar-solutions/product/index.d.ts +15 -13
- package/api/stellar-solutions/product/index.js +53 -44
- package/api/stellar-solutions/product-category/index.d.ts +10 -13
- package/api/stellar-solutions/product-category/index.js +58 -49
- package/api/stellar-solutions/profile/index.d.ts +6 -5
- package/api/stellar-solutions/profile/index.js +17 -18
- package/api/stellar-solutions/quote-invoice/index.d.ts +41 -31
- package/api/stellar-solutions/quote-invoice/index.js +116 -124
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +7 -14
- package/api/stellar-solutions/quote-invoice-report/index.js +27 -20
- package/api/stellar-solutions/tax/index.d.ts +11 -18
- package/api/stellar-solutions/tax/index.js +49 -40
- package/package.json +1 -1
|
@@ -55,7 +55,8 @@ exports.deleteCompany = exports.updateCompany = exports.unitCompanyById = export
|
|
|
55
55
|
*/
|
|
56
56
|
var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
57
|
var companies;
|
|
58
|
-
var
|
|
58
|
+
var _c;
|
|
59
|
+
var currentPage = _b.currentPage, _d = _b.orderByColumn, orderByColumn = _d === void 0 ? 'createdAt' : _d, _e = _b.orderByDirection, orderByDirection = _e === void 0 ? 'desc' : _e, pageLimit = _b.pageLimit, prisma = _b.prisma;
|
|
59
60
|
return __generator(this, function (_f) {
|
|
60
61
|
switch (_f.label) {
|
|
61
62
|
case 0:
|
|
@@ -66,15 +67,13 @@ var listCompany = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
66
67
|
throw new Error('Valid page limit is required');
|
|
67
68
|
}
|
|
68
69
|
return [4 /*yield*/, prisma.$transaction([
|
|
69
|
-
prisma.company.count(
|
|
70
|
-
where: queryWhere,
|
|
71
|
-
}),
|
|
70
|
+
prisma.company.count(),
|
|
72
71
|
prisma.company.findMany({
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
orderBy: (_c = {},
|
|
73
|
+
_c[orderByColumn] = orderByDirection,
|
|
74
|
+
_c),
|
|
75
75
|
skip: (currentPage - 1) * pageLimit,
|
|
76
76
|
take: pageLimit,
|
|
77
|
-
where: queryWhere,
|
|
78
77
|
}),
|
|
79
78
|
])];
|
|
80
79
|
case 1:
|
|
@@ -91,19 +90,20 @@ exports.listCompany = listCompany;
|
|
|
91
90
|
*/
|
|
92
91
|
var unitCompanyById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
93
92
|
var company;
|
|
94
|
-
var
|
|
95
|
-
return __generator(this, function (
|
|
96
|
-
switch (
|
|
93
|
+
var id = _b.id, prisma = _b.prisma;
|
|
94
|
+
return __generator(this, function (_c) {
|
|
95
|
+
switch (_c.label) {
|
|
97
96
|
case 0:
|
|
98
|
-
if (!
|
|
97
|
+
if (!id) {
|
|
99
98
|
throw new Error('Company ID is required');
|
|
100
99
|
}
|
|
101
100
|
return [4 /*yield*/, prisma.company.findUnique({
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
where: {
|
|
102
|
+
id: id,
|
|
103
|
+
},
|
|
104
104
|
})];
|
|
105
105
|
case 1:
|
|
106
|
-
company =
|
|
106
|
+
company = _c.sent();
|
|
107
107
|
return [2 /*return*/, company];
|
|
108
108
|
}
|
|
109
109
|
});
|
|
@@ -116,16 +116,16 @@ exports.unitCompanyById = unitCompanyById;
|
|
|
116
116
|
*/
|
|
117
117
|
var updateCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
118
|
var companyData, company;
|
|
119
|
-
var country = _b.country, email = _b.email, id = _b.id,
|
|
119
|
+
var country = _b.country, email = _b.email, id = _b.id, name = _b.name, phone = _b.phone, prisma = _b.prisma, website = _b.website;
|
|
120
120
|
return __generator(this, function (_c) {
|
|
121
121
|
switch (_c.label) {
|
|
122
122
|
case 0:
|
|
123
|
+
if (!id) {
|
|
124
|
+
throw new Error('Company ID is required');
|
|
125
|
+
}
|
|
123
126
|
if (!country || !email || !name || !phone) {
|
|
124
127
|
throw new Error('Country, email, name, and phone are required');
|
|
125
128
|
}
|
|
126
|
-
if (!id || !(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
|
|
127
|
-
throw new Error('Company ID is required');
|
|
128
|
-
}
|
|
129
129
|
companyData = {
|
|
130
130
|
country: country,
|
|
131
131
|
email: email,
|
|
@@ -134,10 +134,11 @@ var updateCompany = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
134
134
|
website: website || null,
|
|
135
135
|
};
|
|
136
136
|
return [4 /*yield*/, prisma.company.upsert({
|
|
137
|
-
where:
|
|
137
|
+
where: {
|
|
138
|
+
id: id,
|
|
139
|
+
},
|
|
138
140
|
update: companyData,
|
|
139
141
|
create: __assign({ id: id }, companyData),
|
|
140
|
-
include: include,
|
|
141
142
|
})];
|
|
142
143
|
case 1:
|
|
143
144
|
company = _c.sent();
|
|
@@ -154,19 +155,20 @@ exports.updateCompany = updateCompany;
|
|
|
154
155
|
*/
|
|
155
156
|
var deleteCompany = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
156
157
|
var company;
|
|
157
|
-
var
|
|
158
|
-
return __generator(this, function (
|
|
159
|
-
switch (
|
|
158
|
+
var id = _b.id, prisma = _b.prisma;
|
|
159
|
+
return __generator(this, function (_c) {
|
|
160
|
+
switch (_c.label) {
|
|
160
161
|
case 0:
|
|
161
|
-
if (!
|
|
162
|
+
if (!id) {
|
|
162
163
|
throw new Error('Company ID is required');
|
|
163
164
|
}
|
|
164
165
|
return [4 /*yield*/, prisma.company.delete({
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
where: {
|
|
167
|
+
id: id,
|
|
168
|
+
},
|
|
167
169
|
})];
|
|
168
170
|
case 1:
|
|
169
|
-
company =
|
|
171
|
+
company = _c.sent();
|
|
170
172
|
return [2 /*return*/, company];
|
|
171
173
|
}
|
|
172
174
|
});
|
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
import { CompanyBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface PostCompaniesReportArgs {
|
|
4
|
+
orderByColumn?: string;
|
|
5
|
+
orderByDirection?: 'asc' | 'desc';
|
|
4
6
|
prisma: PrismaClient;
|
|
5
|
-
queryWhere?: {
|
|
6
|
-
[key: string]: any;
|
|
7
|
-
};
|
|
8
|
-
include?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
orderBy?: {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
};
|
|
14
7
|
}
|
|
15
8
|
/**
|
|
16
9
|
* Retrieves companies report data with count and full list
|
|
17
10
|
* This is typically used for generating reports without pagination
|
|
18
|
-
* @param {PostCompaniesReportArgs} args - Object containing prisma client and
|
|
19
|
-
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple containing total count and array of all
|
|
11
|
+
* @param {PostCompaniesReportArgs} args - Object containing prisma client and ordering options
|
|
12
|
+
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple containing total count and array of all companies
|
|
20
13
|
*/
|
|
21
|
-
export declare const postCompaniesReport: ({
|
|
14
|
+
export declare const postCompaniesReport: ({ orderByColumn, orderByDirection, prisma, }: PostCompaniesReportArgs) => Promise<[number, Array<CompanyBE>]>;
|
|
22
15
|
export {};
|
|
@@ -40,27 +40,34 @@ exports.postCompaniesReport = void 0;
|
|
|
40
40
|
/**
|
|
41
41
|
* Retrieves companies report data with count and full list
|
|
42
42
|
* This is typically used for generating reports without pagination
|
|
43
|
-
* @param {PostCompaniesReportArgs} args - Object containing prisma client and
|
|
44
|
-
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple containing total count and array of all
|
|
43
|
+
* @param {PostCompaniesReportArgs} args - Object containing prisma client and ordering options
|
|
44
|
+
* @returns {Promise<[number, Array<CompanyBE>]>} Tuple containing total count and array of all companies
|
|
45
45
|
*/
|
|
46
46
|
var postCompaniesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
47
|
-
var _c, count,
|
|
48
|
-
var
|
|
47
|
+
var include, orderBy, where, _c, count, items;
|
|
48
|
+
var _d;
|
|
49
|
+
var _e = _b.orderByColumn, orderByColumn = _e === void 0 ? 'createdAt' : _e, _f = _b.orderByDirection, orderByDirection = _f === void 0 ? 'desc' : _f, prisma = _b.prisma;
|
|
49
50
|
return __generator(this, function (_g) {
|
|
50
51
|
switch (_g.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
case 0:
|
|
53
|
+
include = {};
|
|
54
|
+
orderBy = (_d = {},
|
|
55
|
+
_d[orderByColumn] = orderByDirection,
|
|
56
|
+
_d);
|
|
57
|
+
where = {};
|
|
58
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
59
|
+
prisma.company.count({
|
|
60
|
+
where: where,
|
|
61
|
+
}),
|
|
62
|
+
prisma.company.findMany({
|
|
63
|
+
include: include,
|
|
64
|
+
orderBy: orderBy,
|
|
65
|
+
where: where,
|
|
66
|
+
}),
|
|
67
|
+
])];
|
|
61
68
|
case 1:
|
|
62
|
-
_c = _g.sent(), count = _c[0],
|
|
63
|
-
return [2 /*return*/, [count,
|
|
69
|
+
_c = _g.sent(), count = _c[0], items = _c[1];
|
|
70
|
+
return [2 /*return*/, [count, items]];
|
|
64
71
|
}
|
|
65
72
|
});
|
|
66
73
|
}); };
|
|
@@ -2,26 +2,14 @@ import { ContactBE } from '../type';
|
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface ListContactArgs {
|
|
4
4
|
currentPage: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
orderBy?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
5
|
+
orderByColumn?: string;
|
|
6
|
+
orderByDirection?: 'asc' | 'desc';
|
|
11
7
|
pageLimit: number;
|
|
12
8
|
prisma: PrismaClient;
|
|
13
|
-
queryWhere?: {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
};
|
|
16
9
|
}
|
|
17
10
|
interface UnitContactByIdArgs {
|
|
18
|
-
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
11
|
+
id: string;
|
|
21
12
|
prisma: PrismaClient;
|
|
22
|
-
queryWhere: {
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
};
|
|
25
13
|
}
|
|
26
14
|
interface UpdateContactArgs {
|
|
27
15
|
companyId: string;
|
|
@@ -29,48 +17,37 @@ interface UpdateContactArgs {
|
|
|
29
17
|
email: string;
|
|
30
18
|
firstName: string;
|
|
31
19
|
id: string;
|
|
32
|
-
include?: {
|
|
33
|
-
[key: string]: any;
|
|
34
|
-
};
|
|
35
20
|
lastName: string;
|
|
36
21
|
phone: string;
|
|
37
22
|
prisma: PrismaClient;
|
|
38
|
-
queryWhere: {
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
};
|
|
41
23
|
}
|
|
42
24
|
interface DeleteContactArgs {
|
|
43
|
-
|
|
44
|
-
[key: string]: any;
|
|
45
|
-
};
|
|
25
|
+
id: string;
|
|
46
26
|
prisma: PrismaClient;
|
|
47
|
-
queryWhere: {
|
|
48
|
-
[key: string]: any;
|
|
49
|
-
};
|
|
50
27
|
}
|
|
51
28
|
/**
|
|
52
29
|
* Retrieves contacts with pagination and filtering
|
|
53
30
|
* @param {ListContactArgs} args - Object containing prisma client, pagination, and query options
|
|
54
31
|
* @returns {Promise<[number, Array<ContactBE>]>} Tuple containing total count and array of contacts
|
|
55
32
|
*/
|
|
56
|
-
export declare const listContact: ({ currentPage,
|
|
33
|
+
export declare const listContact: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListContactArgs) => Promise<[number, Array<ContactBE>]>;
|
|
57
34
|
/**
|
|
58
35
|
* Retrieves a single contact by ID
|
|
59
36
|
* @param {UnitContactByIdArgs} args - Object containing prisma client and query where conditions
|
|
60
37
|
* @returns {Promise<ContactBE | null>} Contact if found, null otherwise
|
|
61
38
|
*/
|
|
62
|
-
export declare const unitContactById: ({ prisma,
|
|
39
|
+
export declare const unitContactById: ({ prisma, id, }: UnitContactByIdArgs) => Promise<ContactBE | null>;
|
|
63
40
|
/**
|
|
64
41
|
* Creates or updates a contact
|
|
65
42
|
* @param {UpdateContactArgs} args - Object containing prisma client and contact data
|
|
66
43
|
* @returns {Promise<ContactBE>} Created or updated contact
|
|
67
44
|
*/
|
|
68
|
-
export declare const updateContact: ({ prisma, id,
|
|
45
|
+
export declare const updateContact: ({ prisma, id, companyId, country, email, firstName, lastName, phone, }: UpdateContactArgs) => Promise<ContactBE>;
|
|
69
46
|
/**
|
|
70
47
|
* Deletes a contact by ID
|
|
71
48
|
* @param {DeleteContactArgs} args - Object containing prisma client and query where conditions
|
|
72
49
|
* @returns {Promise<ContactBE>} Deleted contact
|
|
73
50
|
* @throws {Error} If contact ID is not provided or contact not found
|
|
74
51
|
*/
|
|
75
|
-
export declare const deleteContact: ({ prisma,
|
|
52
|
+
export declare const deleteContact: ({ prisma, id, }: DeleteContactArgs) => Promise<ContactBE>;
|
|
76
53
|
export {};
|
|
@@ -55,7 +55,8 @@ exports.deleteContact = exports.updateContact = exports.unitContactById = export
|
|
|
55
55
|
*/
|
|
56
56
|
var listContact = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
57
|
var _c, count, contacts;
|
|
58
|
-
var
|
|
58
|
+
var _d;
|
|
59
|
+
var currentPage = _b.currentPage, _e = _b.orderByColumn, orderByColumn = _e === void 0 ? 'createdAt' : _e, _f = _b.orderByDirection, orderByDirection = _f === void 0 ? 'desc' : _f, pageLimit = _b.pageLimit, prisma = _b.prisma;
|
|
59
60
|
return __generator(this, function (_g) {
|
|
60
61
|
switch (_g.label) {
|
|
61
62
|
case 0:
|
|
@@ -66,13 +67,9 @@ var listContact = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
66
67
|
throw new Error('Valid page limit is required');
|
|
67
68
|
}
|
|
68
69
|
return [4 /*yield*/, prisma.$transaction([
|
|
69
|
-
prisma.contact.count(
|
|
70
|
-
where: queryWhere,
|
|
71
|
-
}),
|
|
70
|
+
prisma.contact.count(),
|
|
72
71
|
prisma.contact.findMany({
|
|
73
|
-
orderBy:
|
|
74
|
-
include: include,
|
|
75
|
-
where: queryWhere,
|
|
72
|
+
orderBy: (_d = {}, _d[orderByColumn] = orderByDirection, _d),
|
|
76
73
|
take: pageLimit,
|
|
77
74
|
skip: (currentPage - 1) * pageLimit,
|
|
78
75
|
}),
|
|
@@ -91,19 +88,18 @@ exports.listContact = listContact;
|
|
|
91
88
|
*/
|
|
92
89
|
var unitContactById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
93
90
|
var contact;
|
|
94
|
-
var prisma = _b.prisma,
|
|
95
|
-
return __generator(this, function (
|
|
96
|
-
switch (
|
|
91
|
+
var prisma = _b.prisma, id = _b.id;
|
|
92
|
+
return __generator(this, function (_c) {
|
|
93
|
+
switch (_c.label) {
|
|
97
94
|
case 0:
|
|
98
|
-
if (!
|
|
95
|
+
if (!id) {
|
|
99
96
|
throw new Error('Contact ID is required');
|
|
100
97
|
}
|
|
101
98
|
return [4 /*yield*/, prisma.contact.findUnique({
|
|
102
|
-
|
|
103
|
-
where: queryWhere,
|
|
99
|
+
where: { id: id },
|
|
104
100
|
})];
|
|
105
101
|
case 1:
|
|
106
|
-
contact =
|
|
102
|
+
contact = _c.sent();
|
|
107
103
|
return [2 /*return*/, contact];
|
|
108
104
|
}
|
|
109
105
|
});
|
|
@@ -116,11 +112,11 @@ exports.unitContactById = unitContactById;
|
|
|
116
112
|
*/
|
|
117
113
|
var updateContact = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
114
|
var contactData, contact;
|
|
119
|
-
var prisma = _b.prisma, id = _b.id,
|
|
115
|
+
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;
|
|
120
116
|
return __generator(this, function (_c) {
|
|
121
117
|
switch (_c.label) {
|
|
122
118
|
case 0:
|
|
123
|
-
if (!id
|
|
119
|
+
if (!id) {
|
|
124
120
|
throw new Error('Contact ID is required');
|
|
125
121
|
}
|
|
126
122
|
if (!companyId || !country || !email || !firstName || !lastName || !phone) {
|
|
@@ -135,10 +131,9 @@ var updateContact = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
135
131
|
phone: phone,
|
|
136
132
|
};
|
|
137
133
|
return [4 /*yield*/, prisma.contact.upsert({
|
|
138
|
-
where:
|
|
134
|
+
where: { id: id },
|
|
139
135
|
update: contactData,
|
|
140
136
|
create: __assign({ id: id }, contactData),
|
|
141
|
-
include: include,
|
|
142
137
|
})];
|
|
143
138
|
case 1:
|
|
144
139
|
contact = _c.sent();
|
|
@@ -155,19 +150,18 @@ exports.updateContact = updateContact;
|
|
|
155
150
|
*/
|
|
156
151
|
var deleteContact = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
157
152
|
var contact;
|
|
158
|
-
var prisma = _b.prisma,
|
|
159
|
-
return __generator(this, function (
|
|
160
|
-
switch (
|
|
153
|
+
var prisma = _b.prisma, id = _b.id;
|
|
154
|
+
return __generator(this, function (_c) {
|
|
155
|
+
switch (_c.label) {
|
|
161
156
|
case 0:
|
|
162
|
-
if (!
|
|
157
|
+
if (!id) {
|
|
163
158
|
throw new Error('Contact ID is required');
|
|
164
159
|
}
|
|
165
160
|
return [4 /*yield*/, prisma.contact.delete({
|
|
166
|
-
|
|
167
|
-
where: queryWhere,
|
|
161
|
+
where: { id: id },
|
|
168
162
|
})];
|
|
169
163
|
case 1:
|
|
170
|
-
contact =
|
|
164
|
+
contact = _c.sent();
|
|
171
165
|
return [2 /*return*/, contact];
|
|
172
166
|
}
|
|
173
167
|
});
|
|
@@ -2,74 +2,51 @@ import { CurrencyBE } from '../type';
|
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface ListCurrencyArgs {
|
|
4
4
|
currentPage: number;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
8
|
-
orderBy?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
5
|
+
orderByColumn?: string;
|
|
6
|
+
orderByDirection?: 'asc' | 'desc';
|
|
11
7
|
pageLimit: number;
|
|
12
8
|
prisma: PrismaClient;
|
|
13
|
-
queryWhere?: {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
};
|
|
16
9
|
}
|
|
17
10
|
interface UnitCurrencyByIdArgs {
|
|
18
|
-
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
11
|
+
id: string;
|
|
21
12
|
prisma: PrismaClient;
|
|
22
|
-
queryWhere: {
|
|
23
|
-
[key: string]: any;
|
|
24
|
-
};
|
|
25
13
|
}
|
|
26
14
|
interface UpdateCurrencyArgs {
|
|
27
15
|
code: string;
|
|
28
16
|
enabled: boolean;
|
|
29
17
|
id: string;
|
|
30
|
-
include?: {
|
|
31
|
-
[key: string]: any;
|
|
32
|
-
};
|
|
33
18
|
isDefault?: boolean;
|
|
34
19
|
label: string;
|
|
35
20
|
preferenceId: string;
|
|
36
21
|
prisma: PrismaClient;
|
|
37
|
-
queryWhere: {
|
|
38
|
-
[key: string]: any;
|
|
39
|
-
};
|
|
40
22
|
}
|
|
41
23
|
interface DeleteCurrencyArgs {
|
|
42
|
-
|
|
43
|
-
[key: string]: any;
|
|
44
|
-
};
|
|
24
|
+
id: string;
|
|
45
25
|
prisma: PrismaClient;
|
|
46
|
-
queryWhere: {
|
|
47
|
-
[key: string]: any;
|
|
48
|
-
};
|
|
49
26
|
}
|
|
50
27
|
/**
|
|
51
28
|
* Retrieves currencies with pagination and filtering
|
|
52
29
|
* @param {ListCurrencyArgs} args - Object containing prisma client, pagination, and query options
|
|
53
30
|
* @returns {Promise<[number, Array<CurrencyBE>]>} Tuple containing total count and array of currencies
|
|
54
31
|
*/
|
|
55
|
-
export declare const listCurrency: ({ currentPage,
|
|
32
|
+
export declare const listCurrency: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListCurrencyArgs) => Promise<[number, Array<CurrencyBE>]>;
|
|
56
33
|
/**
|
|
57
34
|
* Retrieves a single currency by ID
|
|
58
35
|
* @param {UnitCurrencyByIdArgs} args - Object containing prisma client and query where conditions
|
|
59
36
|
* @returns {Promise<CurrencyBE | null>} Currency if found, null otherwise
|
|
60
37
|
*/
|
|
61
|
-
export declare const unitCurrencyById: ({
|
|
38
|
+
export declare const unitCurrencyById: ({ id, prisma, }: UnitCurrencyByIdArgs) => Promise<CurrencyBE | null>;
|
|
62
39
|
/**
|
|
63
40
|
* Creates or updates a currency
|
|
64
41
|
* @param {UpdateCurrencyArgs} args - Object containing prisma client and currency data
|
|
65
42
|
* @returns {Promise<CurrencyBE>} Created or updated currency
|
|
66
43
|
*/
|
|
67
|
-
export declare const updateCurrency: ({ code, enabled, id, isDefault, label, preferenceId, prisma,
|
|
44
|
+
export declare const updateCurrency: ({ code, enabled, id, isDefault, label, preferenceId, prisma, }: UpdateCurrencyArgs) => Promise<CurrencyBE>;
|
|
68
45
|
/**
|
|
69
46
|
* Deletes a currency by ID
|
|
70
47
|
* @param {DeleteCurrencyArgs} args - Object containing prisma client and query where conditions
|
|
71
48
|
* @returns {Promise<CurrencyBE>} Deleted currency
|
|
72
49
|
* @throws {Error} If currency ID is not provided or currency not found
|
|
73
50
|
*/
|
|
74
|
-
export declare const deleteCurrency: ({
|
|
51
|
+
export declare const deleteCurrency: ({ id, prisma, }: DeleteCurrencyArgs) => Promise<CurrencyBE>;
|
|
75
52
|
export {};
|
|
@@ -54,8 +54,9 @@ exports.deleteCurrency = exports.updateCurrency = exports.unitCurrencyById = exp
|
|
|
54
54
|
* @returns {Promise<[number, Array<CurrencyBE>]>} Tuple containing total count and array of currencies
|
|
55
55
|
*/
|
|
56
56
|
var listCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var _c, count, currencies;
|
|
58
|
-
var
|
|
57
|
+
var skip, _c, count, currencies;
|
|
58
|
+
var _d;
|
|
59
|
+
var currentPage = _b.currentPage, _e = _b.orderByColumn, orderByColumn = _e === void 0 ? 'createdAt' : _e, _f = _b.orderByDirection, orderByDirection = _f === void 0 ? 'desc' : _f, pageLimit = _b.pageLimit, prisma = _b.prisma;
|
|
59
60
|
return __generator(this, function (_g) {
|
|
60
61
|
switch (_g.label) {
|
|
61
62
|
case 0:
|
|
@@ -65,16 +66,15 @@ var listCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, functi
|
|
|
65
66
|
if (pageLimit < 1) {
|
|
66
67
|
throw new Error('Valid page limit is required');
|
|
67
68
|
}
|
|
69
|
+
skip = (currentPage - 1) * pageLimit;
|
|
68
70
|
return [4 /*yield*/, prisma.$transaction([
|
|
69
|
-
prisma.currency.count(
|
|
70
|
-
where: queryWhere,
|
|
71
|
-
}),
|
|
71
|
+
prisma.currency.count(),
|
|
72
72
|
prisma.currency.findMany({
|
|
73
|
-
orderBy:
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
orderBy: (_d = {},
|
|
74
|
+
_d[orderByColumn] = orderByDirection,
|
|
75
|
+
_d),
|
|
76
|
+
skip: skip,
|
|
76
77
|
take: pageLimit,
|
|
77
|
-
skip: (currentPage - 1) * pageLimit,
|
|
78
78
|
}),
|
|
79
79
|
])];
|
|
80
80
|
case 1:
|
|
@@ -91,19 +91,20 @@ exports.listCurrency = listCurrency;
|
|
|
91
91
|
*/
|
|
92
92
|
var unitCurrencyById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
93
93
|
var currency;
|
|
94
|
-
var
|
|
95
|
-
return __generator(this, function (
|
|
96
|
-
switch (
|
|
94
|
+
var id = _b.id, prisma = _b.prisma;
|
|
95
|
+
return __generator(this, function (_c) {
|
|
96
|
+
switch (_c.label) {
|
|
97
97
|
case 0:
|
|
98
|
-
if (!
|
|
98
|
+
if (!id) {
|
|
99
99
|
throw new Error('Currency ID is required');
|
|
100
100
|
}
|
|
101
101
|
return [4 /*yield*/, prisma.currency.findUnique({
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
where: {
|
|
103
|
+
id: id,
|
|
104
|
+
},
|
|
104
105
|
})];
|
|
105
106
|
case 1:
|
|
106
|
-
currency =
|
|
107
|
+
currency = _c.sent();
|
|
107
108
|
return [2 /*return*/, currency];
|
|
108
109
|
}
|
|
109
110
|
});
|
|
@@ -116,11 +117,11 @@ exports.unitCurrencyById = unitCurrencyById;
|
|
|
116
117
|
*/
|
|
117
118
|
var updateCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
118
119
|
var currencyData, currency;
|
|
119
|
-
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
|
|
120
|
+
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;
|
|
120
121
|
return __generator(this, function (_d) {
|
|
121
122
|
switch (_d.label) {
|
|
122
123
|
case 0:
|
|
123
|
-
if (!id
|
|
124
|
+
if (!id) {
|
|
124
125
|
throw new Error('Currency ID is required');
|
|
125
126
|
}
|
|
126
127
|
if (!code || !label || !preferenceId) {
|
|
@@ -134,10 +135,11 @@ var updateCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
134
135
|
preferenceId: preferenceId,
|
|
135
136
|
};
|
|
136
137
|
return [4 /*yield*/, prisma.currency.upsert({
|
|
137
|
-
where:
|
|
138
|
+
where: {
|
|
139
|
+
id: id,
|
|
140
|
+
},
|
|
138
141
|
update: currencyData,
|
|
139
142
|
create: __assign({ id: id }, currencyData),
|
|
140
|
-
include: include,
|
|
141
143
|
})];
|
|
142
144
|
case 1:
|
|
143
145
|
currency = _d.sent();
|
|
@@ -154,19 +156,20 @@ exports.updateCurrency = updateCurrency;
|
|
|
154
156
|
*/
|
|
155
157
|
var deleteCurrency = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
156
158
|
var currency;
|
|
157
|
-
var
|
|
158
|
-
return __generator(this, function (
|
|
159
|
-
switch (
|
|
159
|
+
var id = _b.id, prisma = _b.prisma;
|
|
160
|
+
return __generator(this, function (_c) {
|
|
161
|
+
switch (_c.label) {
|
|
160
162
|
case 0:
|
|
161
|
-
if (!
|
|
163
|
+
if (!id) {
|
|
162
164
|
throw new Error('Currency ID is required');
|
|
163
165
|
}
|
|
164
166
|
return [4 /*yield*/, prisma.currency.delete({
|
|
165
|
-
|
|
166
|
-
|
|
167
|
+
where: {
|
|
168
|
+
id: id,
|
|
169
|
+
},
|
|
167
170
|
})];
|
|
168
171
|
case 1:
|
|
169
|
-
currency =
|
|
172
|
+
currency = _c.sent();
|
|
170
173
|
return [2 /*return*/, currency];
|
|
171
174
|
}
|
|
172
175
|
});
|