@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,36 @@ 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.deletePayment = exports.updatePayment = exports.unitPaymentById = exports.listPayment = void 0;
|
|
60
|
+
var general_1 = require("../../../general");
|
|
61
|
+
var type_1 = require("../type");
|
|
51
62
|
/**
|
|
52
63
|
* Retrieves a paginated list of payments
|
|
53
64
|
* @param {ListPaymentArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
65
|
* @returns {Promise<[number, Array<PaymentBE>]>} Tuple containing total count and array of payments
|
|
55
66
|
*/
|
|
56
67
|
var listPayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy,
|
|
68
|
+
var include, orderBy, idSearchQuery, descriptionSearchQuery, refSearchQuery, where, _c, count, items;
|
|
58
69
|
var _d;
|
|
59
|
-
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includePaymentMode, includePaymentMode = _f === void 0 ? false : _f, _g = _b.includeQuoteInvoice, includeQuoteInvoice = _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 (
|
|
70
|
+
var _e = _b.currentPage, currentPage = _e === void 0 ? 1 : _e, _f = _b.includePaymentMode, includePaymentMode = _f === void 0 ? false : _f, _g = _b.includeQuoteInvoice, includeQuoteInvoice = _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;
|
|
71
|
+
return __generator(this, function (_m) {
|
|
72
|
+
switch (_m.label) {
|
|
62
73
|
case 0:
|
|
63
|
-
if (currentPage < 1) {
|
|
64
|
-
throw new Error('
|
|
74
|
+
if (!currentPage || currentPage < 1) {
|
|
75
|
+
throw new Error('Valid current page is required');
|
|
65
76
|
}
|
|
66
|
-
if (pageLimit < 1) {
|
|
67
|
-
throw new Error('
|
|
77
|
+
if (!pageLimit || pageLimit < 1) {
|
|
78
|
+
throw new Error('Valid page limit is required');
|
|
68
79
|
}
|
|
69
80
|
include = {
|
|
70
81
|
paymentMode: includePaymentMode,
|
|
@@ -73,8 +84,21 @@ var listPayment = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
73
84
|
orderBy = (_d = {},
|
|
74
85
|
_d[orderByColumn] = orderByDirection,
|
|
75
86
|
_d);
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
idSearchQuery = (0, general_1.multiPartSearch)({
|
|
88
|
+
columnName: 'id',
|
|
89
|
+
fullText: searchQuery,
|
|
90
|
+
});
|
|
91
|
+
descriptionSearchQuery = (0, general_1.multiPartSearch)({
|
|
92
|
+
columnName: 'description',
|
|
93
|
+
fullText: searchQuery,
|
|
94
|
+
});
|
|
95
|
+
refSearchQuery = (0, general_1.multiPartSearch)({
|
|
96
|
+
columnName: 'ref',
|
|
97
|
+
fullText: searchQuery,
|
|
98
|
+
});
|
|
99
|
+
where = {
|
|
100
|
+
OR: __spreadArray(__spreadArray(__spreadArray([], idSearchQuery, true), descriptionSearchQuery, true), refSearchQuery, true),
|
|
101
|
+
};
|
|
78
102
|
return [4 /*yield*/, prisma.$transaction([
|
|
79
103
|
prisma.payment.count({
|
|
80
104
|
where: where,
|
|
@@ -82,13 +106,13 @@ var listPayment = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
82
106
|
prisma.payment.findMany({
|
|
83
107
|
include: include,
|
|
84
108
|
orderBy: orderBy,
|
|
85
|
-
skip:
|
|
109
|
+
skip: (currentPage - 1) * pageLimit,
|
|
86
110
|
take: pageLimit,
|
|
87
111
|
where: where,
|
|
88
112
|
}),
|
|
89
113
|
])];
|
|
90
114
|
case 1:
|
|
91
|
-
_c =
|
|
115
|
+
_c = _m.sent(), count = _c[0], items = _c[1];
|
|
92
116
|
return [2 /*return*/, [count, items]];
|
|
93
117
|
}
|
|
94
118
|
});
|
|
@@ -100,7 +124,7 @@ exports.listPayment = listPayment;
|
|
|
100
124
|
* @returns {Promise<PaymentBE | null>} Payment or null if not found
|
|
101
125
|
*/
|
|
102
126
|
var unitPaymentById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
103
|
-
var include, payment;
|
|
127
|
+
var include, where, payment;
|
|
104
128
|
var id = _b.id, _c = _b.includePaymentMode, includePaymentMode = _c === void 0 ? false : _c, _d = _b.includeQuoteInvoice, includeQuoteInvoice = _d === void 0 ? false : _d, prisma = _b.prisma;
|
|
105
129
|
return __generator(this, function (_e) {
|
|
106
130
|
switch (_e.label) {
|
|
@@ -112,9 +136,10 @@ var unitPaymentById = function (_a) { return __awaiter(void 0, [_a], void 0, fun
|
|
|
112
136
|
paymentMode: includePaymentMode,
|
|
113
137
|
quoteInvoice: includeQuoteInvoice,
|
|
114
138
|
};
|
|
139
|
+
where = { id: id };
|
|
115
140
|
return [4 /*yield*/, prisma.payment.findUnique({
|
|
116
141
|
include: include,
|
|
117
|
-
where:
|
|
142
|
+
where: where,
|
|
118
143
|
})];
|
|
119
144
|
case 1:
|
|
120
145
|
payment = _e.sent();
|
|
@@ -129,10 +154,10 @@ exports.unitPaymentById = unitPaymentById;
|
|
|
129
154
|
* @returns {Promise<PaymentBE>} Updated payment
|
|
130
155
|
*/
|
|
131
156
|
var updatePayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
132
|
-
var
|
|
133
|
-
var amount = _b.amount, attachment = _b.attachment, balance = _b.balance, currency = _b.currency, date = _b.date, description = _b.description, id = _b.id,
|
|
134
|
-
return __generator(this, function (
|
|
135
|
-
switch (
|
|
157
|
+
var paymentData, where, payment;
|
|
158
|
+
var amount = _b.amount, attachment = _b.attachment, balance = _b.balance, currency = _b.currency, date = _b.date, description = _b.description, id = _b.id, paymentModeId = _b.paymentModeId, paymentType = _b.paymentType, prisma = _b.prisma, quoteInvoiceId = _b.quoteInvoiceId, ref = _b.ref;
|
|
159
|
+
return __generator(this, function (_c) {
|
|
160
|
+
switch (_c.label) {
|
|
136
161
|
case 0:
|
|
137
162
|
if (!id) {
|
|
138
163
|
throw new Error('Payment ID is required');
|
|
@@ -145,10 +170,6 @@ var updatePayment = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
145
170
|
!quoteInvoiceId) {
|
|
146
171
|
throw new Error('Amount, currency, date, payment mode ID, payment type, and quote invoice ID are required');
|
|
147
172
|
}
|
|
148
|
-
include = {
|
|
149
|
-
paymentMode: includePaymentMode,
|
|
150
|
-
quoteInvoice: includeQuoteInvoice,
|
|
151
|
-
};
|
|
152
173
|
paymentData = {
|
|
153
174
|
amount: amount,
|
|
154
175
|
attachment: attachment || null,
|
|
@@ -161,22 +182,22 @@ var updatePayment = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
161
182
|
quoteInvoiceId: quoteInvoiceId,
|
|
162
183
|
ref: ref || null,
|
|
163
184
|
};
|
|
185
|
+
where = { id: id };
|
|
164
186
|
return [4 /*yield*/, prisma.payment.upsert({
|
|
165
187
|
create: __assign({ id: id }, paymentData),
|
|
166
|
-
include: include,
|
|
167
188
|
update: paymentData,
|
|
168
|
-
where:
|
|
189
|
+
where: where,
|
|
169
190
|
})];
|
|
170
191
|
case 1:
|
|
171
|
-
payment =
|
|
192
|
+
payment = _c.sent();
|
|
172
193
|
if (!(Number(balance) === 0)) return [3 /*break*/, 3];
|
|
173
194
|
return [4 /*yield*/, prisma.quoteInvoice.update({
|
|
174
|
-
data: { invoiceStatus:
|
|
195
|
+
data: { invoiceStatus: type_1.INVOICE_STATUS.PAID },
|
|
175
196
|
where: { id: quoteInvoiceId },
|
|
176
197
|
})];
|
|
177
198
|
case 2:
|
|
178
|
-
|
|
179
|
-
|
|
199
|
+
_c.sent();
|
|
200
|
+
_c.label = 3;
|
|
180
201
|
case 3: return [2 /*return*/, payment];
|
|
181
202
|
}
|
|
182
203
|
});
|
|
@@ -188,24 +209,20 @@ exports.updatePayment = updatePayment;
|
|
|
188
209
|
* @returns {Promise<PaymentBE>} Deleted payment
|
|
189
210
|
*/
|
|
190
211
|
var deletePayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
191
|
-
var
|
|
192
|
-
var id = _b.id,
|
|
193
|
-
return __generator(this, function (
|
|
194
|
-
switch (
|
|
212
|
+
var where, payment;
|
|
213
|
+
var id = _b.id, prisma = _b.prisma;
|
|
214
|
+
return __generator(this, function (_c) {
|
|
215
|
+
switch (_c.label) {
|
|
195
216
|
case 0:
|
|
196
217
|
if (!id) {
|
|
197
218
|
throw new Error('Payment ID is required');
|
|
198
219
|
}
|
|
199
|
-
|
|
200
|
-
paymentMode: includePaymentMode,
|
|
201
|
-
quoteInvoice: includeQuoteInvoice,
|
|
202
|
-
};
|
|
220
|
+
where = { id: id };
|
|
203
221
|
return [4 /*yield*/, prisma.payment.delete({
|
|
204
|
-
|
|
205
|
-
where: { id: id },
|
|
222
|
+
where: where,
|
|
206
223
|
})];
|
|
207
224
|
case 1:
|
|
208
|
-
payment =
|
|
225
|
+
payment = _c.sent();
|
|
209
226
|
return [2 /*return*/, payment];
|
|
210
227
|
}
|
|
211
228
|
});
|
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { PaymentModeBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListPaymentModeArgs {
|
|
3
|
+
export interface ListPaymentModeArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
|
+
includePayments?: boolean;
|
|
6
|
+
includePreference?: boolean;
|
|
5
7
|
orderByColumn?: string;
|
|
6
8
|
orderByDirection?: 'asc' | 'desc';
|
|
7
9
|
pageLimit?: number;
|
|
8
10
|
prisma: PrismaClient;
|
|
11
|
+
searchQuery?: string;
|
|
9
12
|
}
|
|
10
|
-
interface UnitPaymentModeByIdArgs {
|
|
13
|
+
export interface UnitPaymentModeByIdArgs {
|
|
14
|
+
includePayments?: boolean;
|
|
11
15
|
id: string;
|
|
16
|
+
includePreference?: boolean;
|
|
12
17
|
prisma: PrismaClient;
|
|
13
18
|
}
|
|
14
|
-
interface UpdatePaymentModeArgs {
|
|
19
|
+
export interface UpdatePaymentModeArgs {
|
|
15
20
|
enabled: boolean;
|
|
21
|
+
isDefault: boolean;
|
|
16
22
|
id: string;
|
|
17
23
|
prisma: PrismaClient;
|
|
18
24
|
}
|
|
19
|
-
interface DeletePaymentModeArgs {
|
|
25
|
+
export interface DeletePaymentModeArgs {
|
|
20
26
|
id: string;
|
|
21
27
|
prisma: PrismaClient;
|
|
22
28
|
}
|
|
@@ -25,19 +31,19 @@ interface DeletePaymentModeArgs {
|
|
|
25
31
|
* @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
26
32
|
* @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
|
|
27
33
|
*/
|
|
28
|
-
export declare const listPaymentMode: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListPaymentModeArgs) => Promise<[number, Array<PaymentModeBE>]>;
|
|
34
|
+
export declare const listPaymentMode: ({ currentPage, includePayments, includePreference, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListPaymentModeArgs) => Promise<[number, Array<PaymentModeBE>]>;
|
|
29
35
|
/**
|
|
30
36
|
* Retrieves a single payment mode by its ID
|
|
31
37
|
* @param {UnitPaymentModeByIdArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
32
38
|
* @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
|
|
33
39
|
*/
|
|
34
|
-
export declare const unitPaymentModeById: ({ id, prisma, }: UnitPaymentModeByIdArgs) => Promise<PaymentModeBE | null>;
|
|
40
|
+
export declare const unitPaymentModeById: ({ id, includePayments, includePreference, prisma, }: UnitPaymentModeByIdArgs) => Promise<PaymentModeBE | null>;
|
|
35
41
|
/**
|
|
36
42
|
* Updates a payment mode's enabled status
|
|
37
43
|
* @param {UpdatePaymentModeArgs} args - Object containing prisma client, payment mode ID, enabled status, and optional query parameters
|
|
38
44
|
* @returns {Promise<PaymentModeBE>} Updated payment mode
|
|
39
45
|
*/
|
|
40
|
-
export declare const updatePaymentMode: ({ enabled, id, prisma, }: UpdatePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
46
|
+
export declare const updatePaymentMode: ({ enabled, isDefault, id, prisma, }: UpdatePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
41
47
|
/**
|
|
42
48
|
* Deletes a payment mode by ID
|
|
43
49
|
* @param {DeletePaymentModeArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
@@ -35,40 +35,69 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
39
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
40
|
+
if (ar || !(i in from)) {
|
|
41
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
42
|
+
ar[i] = from[i];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
46
|
+
};
|
|
38
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
48
|
exports.deletePaymentMode = exports.updatePaymentMode = exports.unitPaymentModeById = exports.listPaymentMode = void 0;
|
|
49
|
+
var multi_part_search_1 = require("../../../general/multi-part-search");
|
|
40
50
|
/**
|
|
41
51
|
* Retrieves a paginated list of payment modes
|
|
42
52
|
* @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
43
53
|
* @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
|
|
44
54
|
*/
|
|
45
55
|
var listPaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
46
|
-
var
|
|
56
|
+
var include, orderBy, idSearchQuery, labelSearchQuery, where, _c, count, items;
|
|
47
57
|
var _d;
|
|
48
|
-
var
|
|
49
|
-
return __generator(this, function (
|
|
50
|
-
switch (
|
|
58
|
+
var currentPage = _b.currentPage, _e = _b.includePayments, includePayments = _e === void 0 ? false : _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, pageLimit = _b.pageLimit, prisma = _b.prisma, _j = _b.searchQuery, searchQuery = _j === void 0 ? '' : _j;
|
|
59
|
+
return __generator(this, function (_k) {
|
|
60
|
+
switch (_k.label) {
|
|
51
61
|
case 0:
|
|
52
|
-
if (currentPage < 1) {
|
|
53
|
-
throw new Error('
|
|
62
|
+
if (!currentPage || currentPage < 1) {
|
|
63
|
+
throw new Error('Valid current page is required');
|
|
54
64
|
}
|
|
55
|
-
if (pageLimit < 1) {
|
|
56
|
-
throw new Error('
|
|
65
|
+
if (!pageLimit || pageLimit < 1) {
|
|
66
|
+
throw new Error('Valid page limit is required');
|
|
57
67
|
}
|
|
58
|
-
|
|
68
|
+
include = {
|
|
69
|
+
payments: includePayments,
|
|
70
|
+
preference: includePreference,
|
|
71
|
+
};
|
|
72
|
+
orderBy = (_d = {},
|
|
73
|
+
_d[orderByColumn] = orderByDirection,
|
|
74
|
+
_d);
|
|
75
|
+
idSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
76
|
+
columnName: 'id',
|
|
77
|
+
fullText: searchQuery,
|
|
78
|
+
});
|
|
79
|
+
labelSearchQuery = (0, multi_part_search_1.multiPartSearch)({
|
|
80
|
+
columnName: 'label',
|
|
81
|
+
fullText: searchQuery,
|
|
82
|
+
});
|
|
83
|
+
where = {
|
|
84
|
+
OR: __spreadArray(__spreadArray([], idSearchQuery, true), labelSearchQuery, true),
|
|
85
|
+
};
|
|
59
86
|
return [4 /*yield*/, prisma.$transaction([
|
|
60
|
-
prisma.paymentMode.count(
|
|
87
|
+
prisma.paymentMode.count({
|
|
88
|
+
where: where,
|
|
89
|
+
}),
|
|
61
90
|
prisma.paymentMode.findMany({
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
skip: skip,
|
|
91
|
+
include: include,
|
|
92
|
+
orderBy: orderBy,
|
|
93
|
+
skip: (currentPage - 1) * pageLimit,
|
|
66
94
|
take: pageLimit,
|
|
95
|
+
where: where,
|
|
67
96
|
}),
|
|
68
97
|
])];
|
|
69
98
|
case 1:
|
|
70
|
-
_c =
|
|
71
|
-
return [2 /*return*/, [count,
|
|
99
|
+
_c = _k.sent(), count = _c[0], items = _c[1];
|
|
100
|
+
return [2 /*return*/, [count, items]];
|
|
72
101
|
}
|
|
73
102
|
});
|
|
74
103
|
}); };
|
|
@@ -79,21 +108,25 @@ exports.listPaymentMode = listPaymentMode;
|
|
|
79
108
|
* @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
|
|
80
109
|
*/
|
|
81
110
|
var unitPaymentModeById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
82
|
-
var paymentMode;
|
|
83
|
-
var id = _b.id, prisma = _b.prisma;
|
|
84
|
-
return __generator(this, function (
|
|
85
|
-
switch (
|
|
111
|
+
var include, where, paymentMode;
|
|
112
|
+
var id = _b.id, _c = _b.includePayments, includePayments = _c === void 0 ? false : _c, _d = _b.includePreference, includePreference = _d === void 0 ? false : _d, prisma = _b.prisma;
|
|
113
|
+
return __generator(this, function (_e) {
|
|
114
|
+
switch (_e.label) {
|
|
86
115
|
case 0:
|
|
87
116
|
if (!id) {
|
|
88
117
|
throw new Error('Payment mode ID is required');
|
|
89
118
|
}
|
|
119
|
+
include = {
|
|
120
|
+
payments: includePayments,
|
|
121
|
+
preference: includePreference,
|
|
122
|
+
};
|
|
123
|
+
where = { id: id };
|
|
90
124
|
return [4 /*yield*/, prisma.paymentMode.findUnique({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
125
|
+
include: include,
|
|
126
|
+
where: where,
|
|
94
127
|
})];
|
|
95
128
|
case 1:
|
|
96
|
-
paymentMode =
|
|
129
|
+
paymentMode = _e.sent();
|
|
97
130
|
return [2 /*return*/, paymentMode];
|
|
98
131
|
}
|
|
99
132
|
});
|
|
@@ -105,8 +138,8 @@ exports.unitPaymentModeById = unitPaymentModeById;
|
|
|
105
138
|
* @returns {Promise<PaymentModeBE>} Updated payment mode
|
|
106
139
|
*/
|
|
107
140
|
var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
108
|
-
var paymentMode;
|
|
109
|
-
var enabled = _b.enabled, id = _b.id, prisma = _b.prisma;
|
|
141
|
+
var where, paymentMode;
|
|
142
|
+
var enabled = _b.enabled, isDefault = _b.isDefault, id = _b.id, prisma = _b.prisma;
|
|
110
143
|
return __generator(this, function (_c) {
|
|
111
144
|
switch (_c.label) {
|
|
112
145
|
case 0:
|
|
@@ -116,13 +149,13 @@ var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
116
149
|
if (typeof enabled !== 'boolean') {
|
|
117
150
|
throw new Error('Enabled status must be a boolean');
|
|
118
151
|
}
|
|
152
|
+
where = { id: id };
|
|
119
153
|
return [4 /*yield*/, prisma.paymentMode.update({
|
|
120
|
-
where: {
|
|
121
|
-
id: id,
|
|
122
|
-
},
|
|
123
154
|
data: {
|
|
124
155
|
enabled: enabled,
|
|
156
|
+
isDefault: isDefault,
|
|
125
157
|
},
|
|
158
|
+
where: where,
|
|
126
159
|
})];
|
|
127
160
|
case 1:
|
|
128
161
|
paymentMode = _c.sent();
|
|
@@ -137,7 +170,7 @@ exports.updatePaymentMode = updatePaymentMode;
|
|
|
137
170
|
* @returns {Promise<PaymentModeBE>} Deleted payment mode
|
|
138
171
|
*/
|
|
139
172
|
var deletePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
140
|
-
var paymentMode;
|
|
173
|
+
var where, paymentMode;
|
|
141
174
|
var id = _b.id, prisma = _b.prisma;
|
|
142
175
|
return __generator(this, function (_c) {
|
|
143
176
|
switch (_c.label) {
|
|
@@ -145,10 +178,9 @@ var deletePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, f
|
|
|
145
178
|
if (!id) {
|
|
146
179
|
throw new Error('Payment mode ID is required');
|
|
147
180
|
}
|
|
181
|
+
where = { id: id };
|
|
148
182
|
return [4 /*yield*/, prisma.paymentMode.delete({
|
|
149
|
-
where:
|
|
150
|
-
id: id,
|
|
151
|
-
},
|
|
183
|
+
where: where,
|
|
152
184
|
})];
|
|
153
185
|
case 1:
|
|
154
186
|
paymentMode = _c.sent();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { PreferenceBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface
|
|
3
|
+
export interface ListPreferencesArgs {
|
|
4
4
|
orderByColumn?: string;
|
|
5
5
|
orderByDirection?: 'asc' | 'desc';
|
|
6
6
|
prisma: PrismaClient;
|
|
7
7
|
}
|
|
8
|
-
interface PostPreferenceArgs {
|
|
8
|
+
export interface PostPreferenceArgs {
|
|
9
9
|
id: string;
|
|
10
10
|
onboarding: boolean;
|
|
11
11
|
prisma: PrismaClient;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Retrieves all preferences
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
|
|
16
16
|
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
17
17
|
*/
|
|
18
|
-
export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }:
|
|
18
|
+
export declare const listPreference: ({ orderByColumn, orderByDirection, prisma, }: ListPreferencesArgs) => Promise<Array<PreferenceBE>>;
|
|
19
19
|
/**
|
|
20
20
|
* Updates a preference using upsert
|
|
21
21
|
* @param {PostPreferenceArgs} args - Object containing prisma client, preference ID, and onboarding status
|
|
@@ -50,20 +50,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
50
50
|
exports.updatePreference = exports.listPreference = void 0;
|
|
51
51
|
/**
|
|
52
52
|
* Retrieves all preferences
|
|
53
|
-
* @param {
|
|
53
|
+
* @param {ListPreferencesArgs} args - Object containing prisma client and ordering options
|
|
54
54
|
* @returns {Promise<Array<PreferenceBE>>} Array of preferences
|
|
55
55
|
*/
|
|
56
56
|
var listPreference = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var include, orderBy, where,
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
-
return __generator(this, function (
|
|
61
|
-
switch (
|
|
57
|
+
var include, orderBy, where, _c, count, items;
|
|
58
|
+
var _d;
|
|
59
|
+
var _e = _b.orderByColumn, orderByColumn = _e === void 0 ? 'createdAt' : _e, _f = _b.orderByDirection, orderByDirection = _f === void 0 ? 'desc' : _f, prisma = _b.prisma;
|
|
60
|
+
return __generator(this, function (_g) {
|
|
61
|
+
switch (_g.label) {
|
|
62
62
|
case 0:
|
|
63
63
|
include = {};
|
|
64
|
-
orderBy = (
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
orderBy = (_d = {},
|
|
65
|
+
_d[orderByColumn] = orderByDirection,
|
|
66
|
+
_d);
|
|
67
67
|
where = {};
|
|
68
68
|
return [4 /*yield*/, prisma.preference.findMany({
|
|
69
69
|
include: include,
|
|
@@ -71,8 +71,8 @@ var listPreference = function (_a) { return __awaiter(void 0, [_a], void 0, func
|
|
|
71
71
|
where: where,
|
|
72
72
|
})];
|
|
73
73
|
case 1:
|
|
74
|
-
|
|
75
|
-
return [2 /*return*/,
|
|
74
|
+
_c = _g.sent(), count = _c[0], items = _c[1];
|
|
75
|
+
return [2 /*return*/, [count, items]];
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
}); };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProductBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
|
-
interface ListProductArgs {
|
|
3
|
+
export interface ListProductArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
5
|
includeProductCategory?: boolean;
|
|
6
6
|
includeQuotesInvoices?: boolean;
|
|
@@ -8,22 +8,21 @@ interface ListProductArgs {
|
|
|
8
8
|
orderByDirection?: 'asc' | 'desc';
|
|
9
9
|
pageLimit?: number;
|
|
10
10
|
prisma: PrismaClient;
|
|
11
|
+
searchQuery?: string;
|
|
11
12
|
}
|
|
12
|
-
interface UnitProductByIdArgs {
|
|
13
|
+
export interface UnitProductByIdArgs {
|
|
13
14
|
id: string;
|
|
15
|
+
prisma: PrismaClient;
|
|
14
16
|
includeProductCategory?: boolean;
|
|
15
17
|
includeQuotesInvoices?: boolean;
|
|
16
|
-
prisma: PrismaClient;
|
|
17
18
|
}
|
|
18
|
-
interface UpdateProductArgs {
|
|
19
|
+
export interface UpdateProductArgs {
|
|
19
20
|
buyPrice: string;
|
|
20
21
|
currency: string;
|
|
21
22
|
description?: string;
|
|
22
23
|
id: string;
|
|
23
24
|
image?: string;
|
|
24
25
|
include?: any;
|
|
25
|
-
includeProductCategory?: boolean;
|
|
26
|
-
includeQuotesInvoices?: boolean;
|
|
27
26
|
name: string;
|
|
28
27
|
prisma: PrismaClient;
|
|
29
28
|
productCategoryId: string;
|
|
@@ -31,10 +30,8 @@ interface UpdateProductArgs {
|
|
|
31
30
|
ref?: string;
|
|
32
31
|
salePrice: string;
|
|
33
32
|
}
|
|
34
|
-
interface DeleteProductArgs {
|
|
33
|
+
export interface DeleteProductArgs {
|
|
35
34
|
id: string;
|
|
36
|
-
includeProductCategory?: boolean;
|
|
37
|
-
includeQuotesInvoices?: boolean;
|
|
38
35
|
prisma: PrismaClient;
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
@@ -42,7 +39,7 @@ interface DeleteProductArgs {
|
|
|
42
39
|
* @param {ListProductArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
43
40
|
* @returns {Promise<[number, Array<ProductBE>]>} Tuple containing total count and array of products
|
|
44
41
|
*/
|
|
45
|
-
export declare const listProduct: ({ currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
42
|
+
export declare const listProduct: ({ currentPage, includeProductCategory, includeQuotesInvoices, orderByColumn, orderByDirection, pageLimit, prisma, searchQuery, }: ListProductArgs) => Promise<[number, Array<ProductBE>]>;
|
|
46
43
|
/**
|
|
47
44
|
* Retrieves a single product by its ID
|
|
48
45
|
* @param {UnitProductByIdArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
@@ -54,11 +51,11 @@ export declare const unitProductById: ({ id, includeProductCategory, includeQuot
|
|
|
54
51
|
* @param {UpdateProductArgs} args - Object containing prisma client, product data, and optional query parameters
|
|
55
52
|
* @returns {Promise<ProductBE>} Created or updated product
|
|
56
53
|
*/
|
|
57
|
-
export declare const updateProduct: ({ buyPrice, currency, description, id, image,
|
|
54
|
+
export declare const updateProduct: ({ buyPrice, currency, description, id, image, name, prisma, productCategoryId, quantity, ref, salePrice, }: UpdateProductArgs) => Promise<ProductBE>;
|
|
58
55
|
/**
|
|
59
56
|
* Deletes a product by ID
|
|
60
57
|
* @param {DeleteProductArgs} args - Object containing prisma client, product ID, and optional query parameters
|
|
61
58
|
* @returns {Promise<ProductBE>} Deleted product
|
|
62
59
|
*/
|
|
63
|
-
export declare const deleteProduct: ({ id,
|
|
60
|
+
export declare const deleteProduct: ({ id, prisma, }: DeleteProductArgs) => Promise<ProductBE>;
|
|
64
61
|
export {};
|