@react-pakistan/util-functions 1.24.65 → 1.24.67
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/README.md +6 -3
- package/api/stellar-solutions/app-user/index.d.ts +63 -14
- package/api/stellar-solutions/app-user/index.js +106 -52
- package/api/stellar-solutions/bank/index.d.ts +65 -16
- package/api/stellar-solutions/bank/index.js +115 -65
- package/api/stellar-solutions/branch/index.d.ts +64 -15
- package/api/stellar-solutions/branch/index.js +119 -65
- package/api/stellar-solutions/company/index.d.ts +58 -24
- package/api/stellar-solutions/company/index.js +106 -78
- package/api/stellar-solutions/company-report/index.d.ts +12 -5
- package/api/stellar-solutions/company-report/index.js +12 -7
- package/api/stellar-solutions/contact/index.d.ts +54 -20
- package/api/stellar-solutions/contact/index.js +109 -88
- package/api/stellar-solutions/currency/index.d.ts +63 -14
- package/api/stellar-solutions/currency/index.js +113 -61
- package/api/stellar-solutions/customer/index.d.ts +70 -28
- package/api/stellar-solutions/customer/index.js +131 -101
- package/api/stellar-solutions/expense/index.d.ts +58 -22
- package/api/stellar-solutions/expense/index.js +128 -92
- package/api/stellar-solutions/expense-category/index.d.ts +58 -22
- package/api/stellar-solutions/expense-category/index.js +125 -86
- package/api/stellar-solutions/lead/index.js +0 -1
- package/api/stellar-solutions/menu-order/index.d.ts +29 -7
- package/api/stellar-solutions/menu-order/index.js +74 -27
- package/api/stellar-solutions/payment/index.d.ts +62 -27
- package/api/stellar-solutions/payment/index.js +144 -123
- package/api/stellar-solutions/payment-mode/index.d.ts +44 -12
- package/api/stellar-solutions/payment-mode/index.js +115 -49
- package/api/stellar-solutions/preference/index.d.ts +14 -3
- package/api/stellar-solutions/preference/index.js +44 -14
- package/api/stellar-solutions/product/index.d.ts +48 -31
- package/api/stellar-solutions/product/index.js +153 -115
- package/api/stellar-solutions/product-category/index.d.ts +44 -27
- package/api/stellar-solutions/product-category/index.js +123 -87
- package/api/stellar-solutions/profile/index.d.ts +48 -17
- package/api/stellar-solutions/profile/index.js +124 -65
- package/api/stellar-solutions/quote-invoice/index.d.ts +67 -8
- package/api/stellar-solutions/quote-invoice/index.js +123 -57
- package/api/stellar-solutions/quote-invoice-report/index.d.ts +12 -5
- package/api/stellar-solutions/quote-invoice-report/index.js +10 -5
- package/api/stellar-solutions/tax/index.d.ts +46 -14
- package/api/stellar-solutions/tax/index.js +135 -63
- package/api/stellar-solutions/type.d.ts +178 -112
- package/api/stellar-solutions/type.js +60 -2
- package/constants/countries-timezones.js +0 -1
- package/constants/currencies.js +0 -1
- package/general/basic-get.js +22 -21
- package/general/basic-post.js +19 -18
- package/general/calculate-pages.js +3 -1
- package/general/check-even-odd-length.js +3 -2
- package/general/delete-image-from-private-supabase.js +0 -1
- package/general/delete-image-from-public-supabase.js +0 -1
- package/general/dynamic-page-limit.js +3 -2
- package/general/enum-to-text.js +7 -4
- package/general/fetch-data.js +0 -1
- package/general/fetch-supabase-image.js +0 -1
- package/general/fetch-supabase-private-assets.js +15 -14
- package/general/format-date.js +8 -8
- package/general/format-number.js +3 -2
- package/general/format-time.js +3 -2
- package/general/full-year-range.js +2 -2
- package/general/generate-blog-schema.d.ts +3 -3
- package/general/generate-blog-schema.js +20 -13
- package/general/generate-breadcrumb-schema.d.ts +4 -4
- package/general/generate-breadcrumb-schema.js +9 -10
- package/general/generate-faq-schema.d.ts +5 -5
- package/general/generate-faq-schema.js +18 -11
- package/general/generate-grid.js +0 -1
- package/general/generate-organization-schema.d.ts +3 -3
- package/general/generate-organization-schema.js +25 -18
- package/general/get-available-page-limit.js +2 -2
- package/general/get-calendar-dates.js +14 -3
- package/general/get-full-name.d.ts +1 -1
- package/general/get-number-of-days-in-month.d.ts +1 -1
- package/general/get-pathname.js +4 -1
- package/general/is-odd.js +1 -1
- package/general/is-previous-button-disabled.js +3 -1
- package/general/parse-frontmatter.js +0 -1
- package/general/remove-data-image-prefix.js +3 -2
- package/general/repeat-times.js +0 -1
- package/general/resolve-current-date.js +1 -2
- package/general/resolve-grid.js +3 -2
- package/general/slugify.js +11 -9
- package/general/text-to-enum.js +6 -1
- package/general/text-to-sentence-case.js +3 -1
- package/general/time-out.js +5 -4
- package/general/truncate-text.js +3 -1
- package/general/upload-blob-to-private-supabase.js +2 -2
- package/general/upload-blob-to-public-supabase.js +2 -2
- package/general/upload-image-to-private-supabase.js +2 -2
- package/general/upload-image-to-public-supabase.js +2 -2
- package/general/validate-email.js +1 -1
- package/hooks/use-fetch.js +11 -12
- package/hooks/use-module-entity.js +5 -6
- package/hooks/use-sticky.js +0 -1
- package/hooks/with-seo.d.ts +1 -1
- package/hooks/with-seo.js +3 -4
- package/local-storage/get-storage-value.js +0 -1
- package/package.json +22 -13
- package/setupTests.js +1 -2
- package/storybook/generate-sitemap.js +0 -1
- package/storybook/preview.js +1 -4
- package/storybook/react-design-story-script.js +0 -2
- package/storybook/react-emoji-collection.js +8 -6
- package/storybook/react-emoji-story-script.js +0 -2
- package/storybook/react-icon-collection.js +4 -3
- package/storybook/react-icon-story-script.js +0 -2
- package/storybook/react-logo-collection.js +4 -3
- package/storybook/react-logo-story-script.js +0 -2
- package/storybook/responsive-component.js +14 -7
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
3
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,127 +47,127 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deletePayment = exports.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
exports.deletePayment = exports.updatePayment = exports.unitPaymentById = exports.listPayment = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves payments with pagination and filtering
|
|
53
|
+
* @param {ListPaymentArgs} args - Object containing prisma client, pagination, and query options
|
|
54
|
+
* @returns {Promise<[number, Array<PaymentBE>]>} Tuple containing total count and array of payments
|
|
55
|
+
*/
|
|
56
|
+
var listPayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
+
var _c, count, payments;
|
|
58
|
+
var currentPage = _b.currentPage, _d = _b.include, include = _d === void 0 ? {} : _d, _e = _b.orderBy, orderBy = _e === void 0 ? { createdAt: 'desc' } : _e, pageLimit = _b.pageLimit, prisma = _b.prisma, _f = _b.queryWhere, queryWhere = _f === void 0 ? {} : _f;
|
|
59
|
+
return __generator(this, function (_g) {
|
|
60
|
+
switch (_g.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
if (currentPage < 1) {
|
|
63
|
+
throw new Error('Current page must be greater than or equal to 1');
|
|
64
|
+
}
|
|
65
|
+
if (pageLimit < 1) {
|
|
66
|
+
throw new Error('Page limit must be greater than or equal to 1');
|
|
67
|
+
}
|
|
68
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
69
|
+
prisma.payment.count({
|
|
70
|
+
where: queryWhere,
|
|
71
|
+
}),
|
|
72
|
+
prisma.payment.findMany({
|
|
73
|
+
orderBy: orderBy,
|
|
74
|
+
include: include,
|
|
75
|
+
where: queryWhere,
|
|
76
|
+
take: pageLimit,
|
|
77
|
+
skip: (currentPage - 1) * pageLimit,
|
|
78
|
+
}),
|
|
79
|
+
])];
|
|
51
80
|
case 1:
|
|
52
|
-
|
|
53
|
-
return [2 /*return*/, payments];
|
|
81
|
+
_c = _g.sent(), count = _c[0], payments = _c[1];
|
|
82
|
+
return [2 /*return*/, [count, payments]];
|
|
54
83
|
}
|
|
55
84
|
});
|
|
56
85
|
}); };
|
|
57
|
-
exports.
|
|
58
|
-
|
|
86
|
+
exports.listPayment = listPayment;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves a single payment by ID
|
|
89
|
+
* @param {UnitPaymentByIdArgs} args - Object containing prisma client, payment id, and optional query parameters
|
|
90
|
+
* @returns {Promise<PaymentBE | null>} Payment with optional relations if found, null otherwise
|
|
91
|
+
*/
|
|
92
|
+
var unitPaymentById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
59
93
|
var payment;
|
|
60
|
-
var id = _b.id, prisma = _b.prisma;
|
|
61
|
-
return __generator(this, function (
|
|
62
|
-
switch (
|
|
63
|
-
case 0:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
94
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
95
|
+
return __generator(this, function (_e) {
|
|
96
|
+
switch (_e.label) {
|
|
97
|
+
case 0:
|
|
98
|
+
if (!id) {
|
|
99
|
+
throw new Error('Payment ID is required');
|
|
100
|
+
}
|
|
101
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
102
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
103
|
+
}
|
|
104
|
+
return [4 /*yield*/, prisma.payment.findUnique({
|
|
105
|
+
where: __assign({ id: id }, queryWhere),
|
|
106
|
+
include: include || undefined,
|
|
107
|
+
})];
|
|
68
108
|
case 1:
|
|
69
|
-
payment =
|
|
109
|
+
payment = _e.sent();
|
|
70
110
|
return [2 /*return*/, payment];
|
|
71
111
|
}
|
|
72
112
|
});
|
|
73
113
|
}); };
|
|
74
|
-
exports.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
})];
|
|
109
|
-
case 1:
|
|
110
|
-
invoice = _c.sent();
|
|
111
|
-
return [4 /*yield*/, prisma.payment.findMany({
|
|
112
|
-
where: {
|
|
113
|
-
quoteInvoiceId: quoteInvoiceId,
|
|
114
|
-
},
|
|
115
|
-
include: {
|
|
116
|
-
quoteInvoice: true,
|
|
117
|
-
},
|
|
118
|
-
})];
|
|
119
|
-
case 2:
|
|
120
|
-
allPaymentsForInvoice = _c.sent();
|
|
121
|
-
calculateBalance = function () {
|
|
122
|
-
if (paymentType === 'PARTIAL_AMOUNT') {
|
|
123
|
-
return allPaymentsForInvoice && invoice.total - Number(amount) - allPaymentsForInvoice
|
|
124
|
-
.reduce(function (acc, _a) {
|
|
125
|
-
var paymentAmount = _a.amount;
|
|
126
|
-
return acc + paymentAmount;
|
|
127
|
-
}, 0);
|
|
128
|
-
}
|
|
129
|
-
return 0;
|
|
114
|
+
exports.unitPaymentById = unitPaymentById;
|
|
115
|
+
/**
|
|
116
|
+
* Creates or updates a payment using upsert
|
|
117
|
+
* @param {UpdatePaymentArgs} args - Object containing prisma client and payment data
|
|
118
|
+
* @returns {Promise<PaymentBE>} Created or updated payment
|
|
119
|
+
*/
|
|
120
|
+
var updatePayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
121
|
+
var paymentData, paymentId, payment;
|
|
122
|
+
var amount = _b.amount, attachment = _b.attachment, balance = _b.balance, currency = _b.currency, date = _b.date, description = _b.description, id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, paymentModeId = _b.paymentModeId, paymentType = _b.paymentType, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d, quoteInvoiceId = _b.quoteInvoiceId, ref = _b.ref;
|
|
123
|
+
return __generator(this, function (_e) {
|
|
124
|
+
switch (_e.label) {
|
|
125
|
+
case 0:
|
|
126
|
+
if (!amount ||
|
|
127
|
+
!currency ||
|
|
128
|
+
!date ||
|
|
129
|
+
!paymentModeId ||
|
|
130
|
+
!paymentType ||
|
|
131
|
+
!quoteInvoiceId) {
|
|
132
|
+
throw new Error('Amount, currency, date, payment mode ID, payment type, and quote invoice ID are required');
|
|
133
|
+
}
|
|
134
|
+
if (id && (queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
135
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
136
|
+
}
|
|
137
|
+
paymentData = {
|
|
138
|
+
amount: amount,
|
|
139
|
+
attachment: attachment || null,
|
|
140
|
+
balance: balance,
|
|
141
|
+
currency: currency,
|
|
142
|
+
date: date,
|
|
143
|
+
description: description || null,
|
|
144
|
+
paymentModeId: paymentModeId,
|
|
145
|
+
paymentType: paymentType,
|
|
146
|
+
quoteInvoiceId: quoteInvoiceId,
|
|
147
|
+
ref: ref || null,
|
|
130
148
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
amount: amount,
|
|
137
|
-
attachment: attachment,
|
|
138
|
-
date: date,
|
|
139
|
-
description: description,
|
|
140
|
-
mode: mode,
|
|
141
|
-
paymentType: paymentType,
|
|
142
|
-
quoteInvoiceId: quoteInvoiceId,
|
|
143
|
-
ref: ref,
|
|
144
|
-
},
|
|
145
|
-
create: {
|
|
146
|
-
amount: amount,
|
|
147
|
-
attachment: attachment,
|
|
148
|
-
balance: String(calculateBalance()),
|
|
149
|
-
currency: currency,
|
|
150
|
-
date: date,
|
|
151
|
-
description: description,
|
|
152
|
-
mode: mode,
|
|
153
|
-
paymentType: paymentType,
|
|
154
|
-
quoteInvoiceId: quoteInvoiceId,
|
|
155
|
-
ref: ref,
|
|
156
|
-
},
|
|
149
|
+
paymentId = id || (queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id);
|
|
150
|
+
if (!!paymentId) return [3 /*break*/, 2];
|
|
151
|
+
return [4 /*yield*/, prisma.payment.create({
|
|
152
|
+
data: paymentData,
|
|
153
|
+
include: include || undefined,
|
|
157
154
|
})];
|
|
155
|
+
case 1:
|
|
156
|
+
// Create new payment without specific ID
|
|
157
|
+
payment = _e.sent();
|
|
158
|
+
return [3 /*break*/, 4];
|
|
159
|
+
case 2: return [4 /*yield*/, prisma.payment.upsert({
|
|
160
|
+
where: __assign({ id: paymentId }, queryWhere),
|
|
161
|
+
update: paymentData,
|
|
162
|
+
create: __assign({ id: paymentId }, paymentData),
|
|
163
|
+
include: include || undefined,
|
|
164
|
+
})];
|
|
158
165
|
case 3:
|
|
159
|
-
|
|
160
|
-
|
|
166
|
+
// Upsert with provided ID
|
|
167
|
+
payment = _e.sent();
|
|
168
|
+
_e.label = 4;
|
|
169
|
+
case 4:
|
|
170
|
+
if (!(Number(balance) === 0)) return [3 /*break*/, 6];
|
|
161
171
|
return [4 /*yield*/, prisma.quoteInvoice.update({
|
|
162
172
|
where: {
|
|
163
173
|
id: quoteInvoiceId,
|
|
@@ -166,26 +176,37 @@ var postPayment = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
166
176
|
invoiceStatus: 'PAID',
|
|
167
177
|
},
|
|
168
178
|
})];
|
|
169
|
-
case
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
case
|
|
179
|
+
case 5:
|
|
180
|
+
_e.sent();
|
|
181
|
+
_e.label = 6;
|
|
182
|
+
case 6: return [2 /*return*/, payment];
|
|
173
183
|
}
|
|
174
184
|
});
|
|
175
185
|
}); };
|
|
176
|
-
exports.
|
|
186
|
+
exports.updatePayment = updatePayment;
|
|
187
|
+
/**
|
|
188
|
+
* Deletes a payment by ID
|
|
189
|
+
* @param {DeletePaymentArgs} args - Object containing prisma client, payment ID, and optional query parameters
|
|
190
|
+
* @returns {Promise<PaymentBE>} Deleted payment
|
|
191
|
+
*/
|
|
177
192
|
var deletePayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
178
193
|
var payment;
|
|
179
|
-
var id = _b.id, prisma = _b.prisma;
|
|
180
|
-
return __generator(this, function (
|
|
181
|
-
switch (
|
|
182
|
-
case 0:
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
194
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
195
|
+
return __generator(this, function (_e) {
|
|
196
|
+
switch (_e.label) {
|
|
197
|
+
case 0:
|
|
198
|
+
if (!id) {
|
|
199
|
+
throw new Error('Payment ID is required');
|
|
200
|
+
}
|
|
201
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
202
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
203
|
+
}
|
|
204
|
+
return [4 /*yield*/, prisma.payment.delete({
|
|
205
|
+
where: __assign({ id: id }, queryWhere),
|
|
206
|
+
include: include || undefined,
|
|
207
|
+
})];
|
|
187
208
|
case 1:
|
|
188
|
-
payment =
|
|
209
|
+
payment = _e.sent();
|
|
189
210
|
return [2 /*return*/, payment];
|
|
190
211
|
}
|
|
191
212
|
});
|
|
@@ -1,22 +1,54 @@
|
|
|
1
1
|
import { PaymentModeBE } from '../type';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type PrismaClient = any;
|
|
3
|
+
interface ListPaymentModeArgs {
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
include?: any;
|
|
6
|
+
orderBy?: any;
|
|
7
|
+
pageLimit?: number;
|
|
8
|
+
prisma: PrismaClient;
|
|
9
|
+
queryWhere?: any;
|
|
4
10
|
}
|
|
5
|
-
interface
|
|
11
|
+
interface UnitPaymentModeByIdArgs {
|
|
6
12
|
id: string;
|
|
7
|
-
|
|
13
|
+
include?: any;
|
|
14
|
+
prisma: PrismaClient;
|
|
15
|
+
queryWhere?: any;
|
|
8
16
|
}
|
|
9
|
-
interface
|
|
10
|
-
enabled:
|
|
17
|
+
interface UpdatePaymentModeArgs {
|
|
18
|
+
enabled: boolean;
|
|
11
19
|
id: string;
|
|
12
|
-
|
|
20
|
+
include?: any;
|
|
21
|
+
prisma: PrismaClient;
|
|
22
|
+
queryWhere?: any;
|
|
13
23
|
}
|
|
14
24
|
interface DeletePaymentModeArgs {
|
|
15
25
|
id: string;
|
|
16
|
-
|
|
26
|
+
include?: any;
|
|
27
|
+
prisma: PrismaClient;
|
|
28
|
+
queryWhere?: any;
|
|
17
29
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves a paginated list of payment modes
|
|
32
|
+
* @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
33
|
+
* @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
|
|
34
|
+
*/
|
|
35
|
+
export declare const listPaymentMode: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListPaymentModeArgs) => Promise<[number, Array<PaymentModeBE>]>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves a single payment mode by its ID
|
|
38
|
+
* @param {UnitPaymentModeByIdArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
39
|
+
* @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
|
|
40
|
+
*/
|
|
41
|
+
export declare const unitPaymentModeById: ({ id, include, prisma, queryWhere, }: UnitPaymentModeByIdArgs) => Promise<PaymentModeBE | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Updates a payment mode's enabled status
|
|
44
|
+
* @param {UpdatePaymentModeArgs} args - Object containing prisma client, payment mode ID, enabled status, and optional query parameters
|
|
45
|
+
* @returns {Promise<PaymentModeBE>} Updated payment mode
|
|
46
|
+
*/
|
|
47
|
+
export declare const updatePaymentMode: ({ enabled, id, include, prisma, queryWhere, }: UpdatePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
48
|
+
/**
|
|
49
|
+
* Deletes a payment mode by ID
|
|
50
|
+
* @param {DeletePaymentModeArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
51
|
+
* @returns {Promise<PaymentModeBE>} Deleted payment mode
|
|
52
|
+
*/
|
|
53
|
+
export declare const deletePaymentMode: ({ id, include, prisma, queryWhere, }: DeletePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
22
54
|
export {};
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
3
13
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
14
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
15
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -37,73 +47,129 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
47
|
}
|
|
38
48
|
};
|
|
39
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.deletePaymentMode = exports.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
exports.deletePaymentMode = exports.updatePaymentMode = exports.unitPaymentModeById = exports.listPaymentMode = void 0;
|
|
51
|
+
/**
|
|
52
|
+
* Retrieves a paginated list of payment modes
|
|
53
|
+
* @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
|
+
* @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
|
|
55
|
+
*/
|
|
56
|
+
var listPaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
+
var skip, _c, count, data;
|
|
58
|
+
var _d = _b.currentPage, currentPage = _d === void 0 ? 1 : _d, _e = _b.include, include = _e === void 0 ? {} : _e, _f = _b.orderBy, orderBy = _f === void 0 ? { createdAt: 'desc' } : _f, _g = _b.pageLimit, pageLimit = _g === void 0 ? 10 : _g, prisma = _b.prisma, _h = _b.queryWhere, queryWhere = _h === void 0 ? {} : _h;
|
|
59
|
+
return __generator(this, function (_j) {
|
|
60
|
+
switch (_j.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
if (currentPage < 1) {
|
|
63
|
+
throw new Error('Current page must be greater than or equal to 1');
|
|
64
|
+
}
|
|
65
|
+
if (pageLimit < 1) {
|
|
66
|
+
throw new Error('Page limit must be greater than or equal to 1');
|
|
67
|
+
}
|
|
68
|
+
skip = (currentPage - 1) * pageLimit;
|
|
69
|
+
return [4 /*yield*/, Promise.all([
|
|
70
|
+
prisma.paymentMode.count({
|
|
71
|
+
where: queryWhere,
|
|
72
|
+
}),
|
|
73
|
+
prisma.paymentMode.findMany({
|
|
74
|
+
include: include || null,
|
|
75
|
+
orderBy: orderBy,
|
|
76
|
+
skip: skip,
|
|
77
|
+
take: pageLimit,
|
|
78
|
+
where: queryWhere,
|
|
79
|
+
}),
|
|
80
|
+
])];
|
|
51
81
|
case 1:
|
|
52
|
-
|
|
53
|
-
return [2 /*return*/,
|
|
82
|
+
_c = _j.sent(), count = _c[0], data = _c[1];
|
|
83
|
+
return [2 /*return*/, [count, data]];
|
|
54
84
|
}
|
|
55
85
|
});
|
|
56
86
|
}); };
|
|
57
|
-
exports.
|
|
58
|
-
|
|
87
|
+
exports.listPaymentMode = listPaymentMode;
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves a single payment mode by its ID
|
|
90
|
+
* @param {UnitPaymentModeByIdArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
91
|
+
* @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
|
|
92
|
+
*/
|
|
93
|
+
var unitPaymentModeById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
59
94
|
var paymentMode;
|
|
60
|
-
var id = _b.id, prisma = _b.prisma;
|
|
61
|
-
return __generator(this, function (
|
|
62
|
-
switch (
|
|
63
|
-
case 0:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
95
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
96
|
+
return __generator(this, function (_e) {
|
|
97
|
+
switch (_e.label) {
|
|
98
|
+
case 0:
|
|
99
|
+
if (!id) {
|
|
100
|
+
throw new Error('Payment mode ID is required');
|
|
101
|
+
}
|
|
102
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
103
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
104
|
+
}
|
|
105
|
+
return [4 /*yield*/, prisma.paymentMode.findUnique({
|
|
106
|
+
include: include || null,
|
|
107
|
+
where: __assign({ id: id }, queryWhere),
|
|
108
|
+
})];
|
|
68
109
|
case 1:
|
|
69
|
-
paymentMode =
|
|
110
|
+
paymentMode = _e.sent();
|
|
70
111
|
return [2 /*return*/, paymentMode];
|
|
71
112
|
}
|
|
72
113
|
});
|
|
73
114
|
}); };
|
|
74
|
-
exports.
|
|
75
|
-
|
|
115
|
+
exports.unitPaymentModeById = unitPaymentModeById;
|
|
116
|
+
/**
|
|
117
|
+
* Updates a payment mode's enabled status
|
|
118
|
+
* @param {UpdatePaymentModeArgs} args - Object containing prisma client, payment mode ID, enabled status, and optional query parameters
|
|
119
|
+
* @returns {Promise<PaymentModeBE>} Updated payment mode
|
|
120
|
+
*/
|
|
121
|
+
var updatePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
76
122
|
var paymentMode;
|
|
77
|
-
var enabled = _b.enabled, id = _b.id, prisma = _b.prisma;
|
|
78
|
-
return __generator(this, function (
|
|
79
|
-
switch (
|
|
80
|
-
case 0:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
123
|
+
var enabled = _b.enabled, id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
124
|
+
return __generator(this, function (_e) {
|
|
125
|
+
switch (_e.label) {
|
|
126
|
+
case 0:
|
|
127
|
+
if (!id) {
|
|
128
|
+
throw new Error('Payment mode ID is required');
|
|
129
|
+
}
|
|
130
|
+
if (typeof enabled !== 'boolean') {
|
|
131
|
+
throw new Error('Enabled status must be a boolean');
|
|
132
|
+
}
|
|
133
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
134
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
135
|
+
}
|
|
136
|
+
return [4 /*yield*/, prisma.paymentMode.update({
|
|
137
|
+
include: include || null,
|
|
138
|
+
where: __assign({ id: id }, queryWhere),
|
|
139
|
+
data: {
|
|
140
|
+
enabled: enabled,
|
|
141
|
+
},
|
|
142
|
+
})];
|
|
88
143
|
case 1:
|
|
89
|
-
paymentMode =
|
|
144
|
+
paymentMode = _e.sent();
|
|
90
145
|
return [2 /*return*/, paymentMode];
|
|
91
146
|
}
|
|
92
147
|
});
|
|
93
148
|
}); };
|
|
94
|
-
exports.
|
|
149
|
+
exports.updatePaymentMode = updatePaymentMode;
|
|
150
|
+
/**
|
|
151
|
+
* Deletes a payment mode by ID
|
|
152
|
+
* @param {DeletePaymentModeArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
153
|
+
* @returns {Promise<PaymentModeBE>} Deleted payment mode
|
|
154
|
+
*/
|
|
95
155
|
var deletePaymentMode = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
96
156
|
var paymentMode;
|
|
97
|
-
var id = _b.id, prisma = _b.prisma;
|
|
98
|
-
return __generator(this, function (
|
|
99
|
-
switch (
|
|
100
|
-
case 0:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
157
|
+
var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
|
|
158
|
+
return __generator(this, function (_e) {
|
|
159
|
+
switch (_e.label) {
|
|
160
|
+
case 0:
|
|
161
|
+
if (!id) {
|
|
162
|
+
throw new Error('Payment mode ID is required');
|
|
163
|
+
}
|
|
164
|
+
if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
|
|
165
|
+
throw new Error('ID mismatch between parameter and queryWhere');
|
|
166
|
+
}
|
|
167
|
+
return [4 /*yield*/, prisma.paymentMode.delete({
|
|
168
|
+
include: include || null,
|
|
169
|
+
where: __assign({ id: id }, queryWhere),
|
|
170
|
+
})];
|
|
105
171
|
case 1:
|
|
106
|
-
paymentMode =
|
|
172
|
+
paymentMode = _e.sent();
|
|
107
173
|
return [2 /*return*/, paymentMode];
|
|
108
174
|
}
|
|
109
175
|
});
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { PreferenceBE } from '../type';
|
|
2
|
+
type PrismaClient = any;
|
|
2
3
|
interface GetPreferencesArgs {
|
|
3
|
-
prisma:
|
|
4
|
+
prisma: PrismaClient;
|
|
4
5
|
}
|
|
5
6
|
interface PostPreferenceArgs {
|
|
6
|
-
id
|
|
7
|
+
id?: string;
|
|
7
8
|
onboarding: boolean;
|
|
8
|
-
prisma:
|
|
9
|
+
prisma: PrismaClient;
|
|
9
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves all preferences with related data
|
|
13
|
+
* @param {GetPreferencesArgs} args - Object containing prisma client
|
|
14
|
+
* @returns {Promise<Array<PreferenceBE>>} Array of preferences with related entities (banks, branches, currencies, etc.)
|
|
15
|
+
*/
|
|
10
16
|
export declare const getPreferences: ({ prisma, }: GetPreferencesArgs) => Promise<Array<PreferenceBE>>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a new preference or updates an existing one
|
|
19
|
+
* @param {PostPreferenceArgs} args - Object containing prisma client, optional preference ID, and onboarding status
|
|
20
|
+
* @returns {Promise<PreferenceBE>} Created or updated preference
|
|
21
|
+
*/
|
|
11
22
|
export declare const postPreference: ({ prisma, id, onboarding, }: PostPreferenceArgs) => Promise<PreferenceBE>;
|
|
12
23
|
export {};
|