@react-pakistan/util-functions 1.24.67 → 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-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
|
@@ -47,35 +47,49 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.deleteMenuOrder = exports.
|
|
50
|
+
exports.deleteMenuOrder = exports.updateMenuOrder = exports.unitMenuOrderById = exports.listMenuOrder = void 0;
|
|
51
51
|
/**
|
|
52
|
-
* Retrieves
|
|
53
|
-
* @param {
|
|
54
|
-
* @returns {Promise<Array<MenuOrderBE
|
|
52
|
+
* Retrieves paginated menu orders with count
|
|
53
|
+
* @param {ListMenuOrderArgs} args - Object containing prisma client and pagination parameters
|
|
54
|
+
* @returns {Promise<[number, Array<MenuOrderBE>]>} Tuple of total count and menu orders array
|
|
55
55
|
*/
|
|
56
|
-
var
|
|
57
|
-
var menuOrders;
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
56
|
+
var listMenuOrder = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
+
var skip, _c, count, menuOrders;
|
|
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;
|
|
60
|
+
return __generator(this, function (_g) {
|
|
61
|
+
switch (_g.label) {
|
|
62
|
+
case 0:
|
|
63
|
+
if (currentPage < 1) {
|
|
64
|
+
throw new Error('Current page must be greater than 0');
|
|
65
|
+
}
|
|
66
|
+
if (pageLimit < 1) {
|
|
67
|
+
throw new Error('Page limit must be greater than 0');
|
|
68
|
+
}
|
|
69
|
+
skip = (currentPage - 1) * pageLimit;
|
|
70
|
+
return [4 /*yield*/, prisma.$transaction([
|
|
71
|
+
prisma.menuOrder.count(),
|
|
72
|
+
prisma.menuOrder.findMany({
|
|
73
|
+
orderBy: (_d = {},
|
|
74
|
+
_d[orderByColumn] = orderByDirection,
|
|
75
|
+
_d),
|
|
76
|
+
skip: skip,
|
|
77
|
+
take: pageLimit,
|
|
78
|
+
}),
|
|
79
|
+
])];
|
|
66
80
|
case 1:
|
|
67
|
-
|
|
68
|
-
return [2 /*return*/, menuOrders];
|
|
81
|
+
_c = _g.sent(), count = _c[0], menuOrders = _c[1];
|
|
82
|
+
return [2 /*return*/, [count, menuOrders]];
|
|
69
83
|
}
|
|
70
84
|
});
|
|
71
85
|
}); };
|
|
72
|
-
exports.
|
|
86
|
+
exports.listMenuOrder = listMenuOrder;
|
|
73
87
|
/**
|
|
74
88
|
* Retrieves a single menu order by ID
|
|
75
|
-
* @param {
|
|
89
|
+
* @param {UnitMenuOrderByIdArgs} args - Object containing prisma client and menu order id
|
|
76
90
|
* @returns {Promise<MenuOrderBE | null>} Menu order if found, null otherwise
|
|
77
91
|
*/
|
|
78
|
-
var
|
|
92
|
+
var unitMenuOrderById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
79
93
|
var menuOrder;
|
|
80
94
|
var id = _b.id, prisma = _b.prisma;
|
|
81
95
|
return __generator(this, function (_c) {
|
|
@@ -95,18 +109,21 @@ var getMenuOrderById = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
95
109
|
}
|
|
96
110
|
});
|
|
97
111
|
}); };
|
|
98
|
-
exports.
|
|
112
|
+
exports.unitMenuOrderById = unitMenuOrderById;
|
|
99
113
|
/**
|
|
100
|
-
*
|
|
101
|
-
* @param {
|
|
102
|
-
* @returns {Promise<MenuOrderBE>}
|
|
114
|
+
* Updates an existing menu order
|
|
115
|
+
* @param {UpdateMenuOrderArgs} args - Object containing prisma client and menu order data
|
|
116
|
+
* @returns {Promise<MenuOrderBE>} Updated menu order
|
|
103
117
|
*/
|
|
104
|
-
var
|
|
105
|
-
var menuOrderData,
|
|
118
|
+
var updateMenuOrder = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
119
|
+
var menuOrderData, menuOrder;
|
|
106
120
|
var id = _b.id, label = _b.label, order = _b.order, preferenceId = _b.preferenceId, prisma = _b.prisma;
|
|
107
121
|
return __generator(this, function (_c) {
|
|
108
122
|
switch (_c.label) {
|
|
109
123
|
case 0:
|
|
124
|
+
if (!id) {
|
|
125
|
+
throw new Error('Menu order ID is required');
|
|
126
|
+
}
|
|
110
127
|
if (!label || order === undefined || order === null || !preferenceId) {
|
|
111
128
|
throw new Error('Label, order, and preference ID are required');
|
|
112
129
|
}
|
|
@@ -115,7 +132,6 @@ var postMenuOrder = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
115
132
|
order: order,
|
|
116
133
|
preferenceId: preferenceId,
|
|
117
134
|
};
|
|
118
|
-
if (!id) return [3 /*break*/, 2];
|
|
119
135
|
return [4 /*yield*/, prisma.menuOrder.upsert({
|
|
120
136
|
where: {
|
|
121
137
|
id: id,
|
|
@@ -124,18 +140,12 @@ var postMenuOrder = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
124
140
|
create: __assign({ id: id }, menuOrderData),
|
|
125
141
|
})];
|
|
126
142
|
case 1:
|
|
127
|
-
menuOrder_1 = _c.sent();
|
|
128
|
-
return [2 /*return*/, menuOrder_1];
|
|
129
|
-
case 2: return [4 /*yield*/, prisma.menuOrder.create({
|
|
130
|
-
data: menuOrderData,
|
|
131
|
-
})];
|
|
132
|
-
case 3:
|
|
133
143
|
menuOrder = _c.sent();
|
|
134
144
|
return [2 /*return*/, menuOrder];
|
|
135
145
|
}
|
|
136
146
|
});
|
|
137
147
|
}); };
|
|
138
|
-
exports.
|
|
148
|
+
exports.updateMenuOrder = updateMenuOrder;
|
|
139
149
|
/**
|
|
140
150
|
* Deletes a menu order by ID
|
|
141
151
|
* @param {DeleteMenuOrderArgs} args - Object containing prisma client and menu order id
|
|
@@ -1,81 +1,64 @@
|
|
|
1
1
|
import { PaymentBE } from '../type';
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface ListPaymentArgs {
|
|
4
|
-
currentPage
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
pageLimit: number;
|
|
4
|
+
currentPage?: number;
|
|
5
|
+
includePaymentMode?: boolean;
|
|
6
|
+
includeQuoteInvoice?: boolean;
|
|
7
|
+
orderByColumn?: string;
|
|
8
|
+
orderByDirection?: 'asc' | 'desc';
|
|
9
|
+
pageLimit?: number;
|
|
12
10
|
prisma: PrismaClient;
|
|
13
|
-
queryWhere?: {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
};
|
|
16
11
|
}
|
|
17
12
|
interface UnitPaymentByIdArgs {
|
|
18
13
|
id: string;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
};
|
|
14
|
+
includePaymentMode?: boolean;
|
|
15
|
+
includeQuoteInvoice?: boolean;
|
|
22
16
|
prisma: PrismaClient;
|
|
23
|
-
queryWhere?: {
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
};
|
|
26
17
|
}
|
|
27
18
|
interface UpdatePaymentArgs {
|
|
28
19
|
amount: string;
|
|
29
|
-
attachment?: string;
|
|
30
|
-
balance
|
|
20
|
+
attachment?: string | null;
|
|
21
|
+
balance?: string | null;
|
|
31
22
|
currency: string;
|
|
32
23
|
date: string;
|
|
33
|
-
description?: string;
|
|
34
|
-
id
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
24
|
+
description?: string | null;
|
|
25
|
+
id: string;
|
|
26
|
+
includePaymentMode?: boolean;
|
|
27
|
+
includeQuoteInvoice?: boolean;
|
|
38
28
|
paymentModeId: string;
|
|
39
|
-
paymentType:
|
|
29
|
+
paymentType: string;
|
|
40
30
|
prisma: PrismaClient;
|
|
41
|
-
queryWhere?: {
|
|
42
|
-
[key: string]: any;
|
|
43
|
-
};
|
|
44
31
|
quoteInvoiceId: string;
|
|
45
|
-
ref?: string;
|
|
32
|
+
ref?: string | null;
|
|
46
33
|
}
|
|
47
34
|
interface DeletePaymentArgs {
|
|
48
35
|
id: string;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
36
|
+
includePaymentMode?: boolean;
|
|
37
|
+
includeQuoteInvoice?: boolean;
|
|
52
38
|
prisma: PrismaClient;
|
|
53
|
-
queryWhere?: {
|
|
54
|
-
[key: string]: any;
|
|
55
|
-
};
|
|
56
39
|
}
|
|
57
40
|
/**
|
|
58
|
-
* Retrieves
|
|
59
|
-
* @param {ListPaymentArgs} args - Object containing prisma client, pagination, and
|
|
41
|
+
* Retrieves a paginated list of payments
|
|
42
|
+
* @param {ListPaymentArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
60
43
|
* @returns {Promise<[number, Array<PaymentBE>]>} Tuple containing total count and array of payments
|
|
61
44
|
*/
|
|
62
|
-
export declare const listPayment: ({ currentPage,
|
|
45
|
+
export declare const listPayment: ({ currentPage, includePaymentMode, includeQuoteInvoice, orderByColumn, orderByDirection, pageLimit, prisma, }: ListPaymentArgs) => Promise<[number, Array<PaymentBE>]>;
|
|
63
46
|
/**
|
|
64
|
-
* Retrieves a single payment by ID
|
|
65
|
-
* @param {UnitPaymentByIdArgs} args - Object containing prisma client, payment
|
|
66
|
-
* @returns {Promise<PaymentBE | null>} Payment
|
|
47
|
+
* Retrieves a single payment by its ID
|
|
48
|
+
* @param {UnitPaymentByIdArgs} args - Object containing prisma client, payment ID, and optional query parameters
|
|
49
|
+
* @returns {Promise<PaymentBE | null>} Payment or null if not found
|
|
67
50
|
*/
|
|
68
|
-
export declare const unitPaymentById: ({ id,
|
|
51
|
+
export declare const unitPaymentById: ({ id, includePaymentMode, includeQuoteInvoice, prisma, }: UnitPaymentByIdArgs) => Promise<PaymentBE | null>;
|
|
69
52
|
/**
|
|
70
|
-
*
|
|
53
|
+
* Updates a payment using upsert
|
|
71
54
|
* @param {UpdatePaymentArgs} args - Object containing prisma client and payment data
|
|
72
|
-
* @returns {Promise<PaymentBE>}
|
|
55
|
+
* @returns {Promise<PaymentBE>} Updated payment
|
|
73
56
|
*/
|
|
74
|
-
export declare const updatePayment: ({ amount, attachment, balance, currency, date, description, id,
|
|
57
|
+
export declare const updatePayment: ({ amount, attachment, balance, currency, date, description, id, includePaymentMode, includeQuoteInvoice, paymentModeId, paymentType, prisma, quoteInvoiceId, ref, }: UpdatePaymentArgs) => Promise<PaymentBE>;
|
|
75
58
|
/**
|
|
76
59
|
* Deletes a payment by ID
|
|
77
|
-
* @param {DeletePaymentArgs} args - Object containing prisma client
|
|
60
|
+
* @param {DeletePaymentArgs} args - Object containing prisma client and payment ID
|
|
78
61
|
* @returns {Promise<PaymentBE>} Deleted payment
|
|
79
62
|
*/
|
|
80
|
-
export declare const deletePayment: ({ id,
|
|
63
|
+
export declare const deletePayment: ({ id, includePaymentMode, includeQuoteInvoice, prisma, }: DeletePaymentArgs) => Promise<PaymentBE>;
|
|
81
64
|
export {};
|
|
@@ -49,15 +49,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.deletePayment = exports.updatePayment = exports.unitPaymentById = exports.listPayment = void 0;
|
|
51
51
|
/**
|
|
52
|
-
* Retrieves
|
|
53
|
-
* @param {ListPaymentArgs} args - Object containing prisma client, pagination, and
|
|
52
|
+
* Retrieves a paginated list of payments
|
|
53
|
+
* @param {ListPaymentArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
54
54
|
* @returns {Promise<[number, Array<PaymentBE>]>} Tuple containing total count and array of payments
|
|
55
55
|
*/
|
|
56
56
|
var listPayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
57
|
-
var _c, count,
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
var include, orderBy, skip, where, _c, count, items;
|
|
58
|
+
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 ? 10 : _k, prisma = _b.prisma;
|
|
60
|
+
return __generator(this, function (_l) {
|
|
61
|
+
switch (_l.label) {
|
|
61
62
|
case 0:
|
|
62
63
|
if (currentPage < 1) {
|
|
63
64
|
throw new Error('Current page must be greater than or equal to 1');
|
|
@@ -65,45 +66,55 @@ var listPayment = function (_a) { return __awaiter(void 0, [_a], void 0, functio
|
|
|
65
66
|
if (pageLimit < 1) {
|
|
66
67
|
throw new Error('Page limit must be greater than or equal to 1');
|
|
67
68
|
}
|
|
69
|
+
include = {
|
|
70
|
+
paymentMode: includePaymentMode,
|
|
71
|
+
quoteInvoice: includeQuoteInvoice,
|
|
72
|
+
};
|
|
73
|
+
orderBy = (_d = {},
|
|
74
|
+
_d[orderByColumn] = orderByDirection,
|
|
75
|
+
_d);
|
|
76
|
+
skip = (currentPage - 1) * pageLimit;
|
|
77
|
+
where = {};
|
|
68
78
|
return [4 /*yield*/, prisma.$transaction([
|
|
69
79
|
prisma.payment.count({
|
|
70
|
-
where:
|
|
80
|
+
where: where,
|
|
71
81
|
}),
|
|
72
82
|
prisma.payment.findMany({
|
|
73
|
-
orderBy: orderBy,
|
|
74
83
|
include: include,
|
|
75
|
-
|
|
84
|
+
orderBy: orderBy,
|
|
85
|
+
skip: skip,
|
|
76
86
|
take: pageLimit,
|
|
77
|
-
|
|
87
|
+
where: where,
|
|
78
88
|
}),
|
|
79
89
|
])];
|
|
80
90
|
case 1:
|
|
81
|
-
_c =
|
|
82
|
-
return [2 /*return*/, [count,
|
|
91
|
+
_c = _l.sent(), count = _c[0], items = _c[1];
|
|
92
|
+
return [2 /*return*/, [count, items]];
|
|
83
93
|
}
|
|
84
94
|
});
|
|
85
95
|
}); };
|
|
86
96
|
exports.listPayment = listPayment;
|
|
87
97
|
/**
|
|
88
|
-
* Retrieves a single payment by ID
|
|
89
|
-
* @param {UnitPaymentByIdArgs} args - Object containing prisma client, payment
|
|
90
|
-
* @returns {Promise<PaymentBE | null>} Payment
|
|
98
|
+
* Retrieves a single payment by its ID
|
|
99
|
+
* @param {UnitPaymentByIdArgs} args - Object containing prisma client, payment ID, and optional query parameters
|
|
100
|
+
* @returns {Promise<PaymentBE | null>} Payment or null if not found
|
|
91
101
|
*/
|
|
92
102
|
var unitPaymentById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
93
|
-
var payment;
|
|
94
|
-
var id = _b.id, _c = _b.
|
|
103
|
+
var include, payment;
|
|
104
|
+
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;
|
|
95
105
|
return __generator(this, function (_e) {
|
|
96
106
|
switch (_e.label) {
|
|
97
107
|
case 0:
|
|
98
108
|
if (!id) {
|
|
99
109
|
throw new Error('Payment ID is required');
|
|
100
110
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
111
|
+
include = {
|
|
112
|
+
paymentMode: includePaymentMode,
|
|
113
|
+
quoteInvoice: includeQuoteInvoice,
|
|
114
|
+
};
|
|
104
115
|
return [4 /*yield*/, prisma.payment.findUnique({
|
|
105
|
-
|
|
106
|
-
|
|
116
|
+
include: include,
|
|
117
|
+
where: { id: id },
|
|
107
118
|
})];
|
|
108
119
|
case 1:
|
|
109
120
|
payment = _e.sent();
|
|
@@ -113,16 +124,19 @@ var unitPaymentById = function (_a) { return __awaiter(void 0, [_a], void 0, fun
|
|
|
113
124
|
}); };
|
|
114
125
|
exports.unitPaymentById = unitPaymentById;
|
|
115
126
|
/**
|
|
116
|
-
*
|
|
127
|
+
* Updates a payment using upsert
|
|
117
128
|
* @param {UpdatePaymentArgs} args - Object containing prisma client and payment data
|
|
118
|
-
* @returns {Promise<PaymentBE>}
|
|
129
|
+
* @returns {Promise<PaymentBE>} Updated payment
|
|
119
130
|
*/
|
|
120
131
|
var updatePayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
121
|
-
var
|
|
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.
|
|
132
|
+
var include, paymentData, payment;
|
|
133
|
+
var amount = _b.amount, attachment = _b.attachment, balance = _b.balance, currency = _b.currency, date = _b.date, description = _b.description, id = _b.id, _c = _b.includePaymentMode, includePaymentMode = _c === void 0 ? false : _c, _d = _b.includeQuoteInvoice, includeQuoteInvoice = _d === void 0 ? false : _d, paymentModeId = _b.paymentModeId, paymentType = _b.paymentType, prisma = _b.prisma, quoteInvoiceId = _b.quoteInvoiceId, ref = _b.ref;
|
|
123
134
|
return __generator(this, function (_e) {
|
|
124
135
|
switch (_e.label) {
|
|
125
136
|
case 0:
|
|
137
|
+
if (!id) {
|
|
138
|
+
throw new Error('Payment ID is required');
|
|
139
|
+
}
|
|
126
140
|
if (!amount ||
|
|
127
141
|
!currency ||
|
|
128
142
|
!date ||
|
|
@@ -131,9 +145,10 @@ var updatePayment = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
131
145
|
!quoteInvoiceId) {
|
|
132
146
|
throw new Error('Amount, currency, date, payment mode ID, payment type, and quote invoice ID are required');
|
|
133
147
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
148
|
+
include = {
|
|
149
|
+
paymentMode: includePaymentMode,
|
|
150
|
+
quoteInvoice: includeQuoteInvoice,
|
|
151
|
+
};
|
|
137
152
|
paymentData = {
|
|
138
153
|
amount: amount,
|
|
139
154
|
attachment: attachment || null,
|
|
@@ -146,64 +161,48 @@ var updatePayment = function (_a) { return __awaiter(void 0, [_a], void 0, funct
|
|
|
146
161
|
quoteInvoiceId: quoteInvoiceId,
|
|
147
162
|
ref: ref || null,
|
|
148
163
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
164
|
+
return [4 /*yield*/, prisma.payment.upsert({
|
|
165
|
+
create: __assign({ id: id }, paymentData),
|
|
166
|
+
include: include,
|
|
167
|
+
update: paymentData,
|
|
168
|
+
where: { id: id },
|
|
154
169
|
})];
|
|
155
170
|
case 1:
|
|
156
|
-
// Create new payment without specific ID
|
|
157
171
|
payment = _e.sent();
|
|
158
|
-
return [3 /*break*/,
|
|
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
|
-
})];
|
|
165
|
-
case 3:
|
|
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];
|
|
172
|
+
if (!(Number(balance) === 0)) return [3 /*break*/, 3];
|
|
171
173
|
return [4 /*yield*/, prisma.quoteInvoice.update({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
data: {
|
|
176
|
-
invoiceStatus: 'PAID',
|
|
177
|
-
},
|
|
174
|
+
data: { invoiceStatus: 'PAID' },
|
|
175
|
+
where: { id: quoteInvoiceId },
|
|
178
176
|
})];
|
|
179
|
-
case
|
|
177
|
+
case 2:
|
|
180
178
|
_e.sent();
|
|
181
|
-
_e.label =
|
|
182
|
-
case
|
|
179
|
+
_e.label = 3;
|
|
180
|
+
case 3: return [2 /*return*/, payment];
|
|
183
181
|
}
|
|
184
182
|
});
|
|
185
183
|
}); };
|
|
186
184
|
exports.updatePayment = updatePayment;
|
|
187
185
|
/**
|
|
188
186
|
* Deletes a payment by ID
|
|
189
|
-
* @param {DeletePaymentArgs} args - Object containing prisma client
|
|
187
|
+
* @param {DeletePaymentArgs} args - Object containing prisma client and payment ID
|
|
190
188
|
* @returns {Promise<PaymentBE>} Deleted payment
|
|
191
189
|
*/
|
|
192
190
|
var deletePayment = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
193
|
-
var payment;
|
|
194
|
-
var id = _b.id, _c = _b.
|
|
191
|
+
var include, payment;
|
|
192
|
+
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;
|
|
195
193
|
return __generator(this, function (_e) {
|
|
196
194
|
switch (_e.label) {
|
|
197
195
|
case 0:
|
|
198
196
|
if (!id) {
|
|
199
197
|
throw new Error('Payment ID is required');
|
|
200
198
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
199
|
+
include = {
|
|
200
|
+
paymentMode: includePaymentMode,
|
|
201
|
+
quoteInvoice: includeQuoteInvoice,
|
|
202
|
+
};
|
|
204
203
|
return [4 /*yield*/, prisma.payment.delete({
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
include: include,
|
|
205
|
+
where: { id: id },
|
|
207
206
|
})];
|
|
208
207
|
case 1:
|
|
209
208
|
payment = _e.sent();
|
|
@@ -2,53 +2,46 @@ import { PaymentModeBE } from '../type';
|
|
|
2
2
|
type PrismaClient = any;
|
|
3
3
|
interface ListPaymentModeArgs {
|
|
4
4
|
currentPage?: number;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
orderByColumn?: string;
|
|
6
|
+
orderByDirection?: 'asc' | 'desc';
|
|
7
7
|
pageLimit?: number;
|
|
8
8
|
prisma: PrismaClient;
|
|
9
|
-
queryWhere?: any;
|
|
10
9
|
}
|
|
11
10
|
interface UnitPaymentModeByIdArgs {
|
|
12
11
|
id: string;
|
|
13
|
-
include?: any;
|
|
14
12
|
prisma: PrismaClient;
|
|
15
|
-
queryWhere?: any;
|
|
16
13
|
}
|
|
17
14
|
interface UpdatePaymentModeArgs {
|
|
18
15
|
enabled: boolean;
|
|
19
16
|
id: string;
|
|
20
|
-
include?: any;
|
|
21
17
|
prisma: PrismaClient;
|
|
22
|
-
queryWhere?: any;
|
|
23
18
|
}
|
|
24
19
|
interface DeletePaymentModeArgs {
|
|
25
20
|
id: string;
|
|
26
|
-
include?: any;
|
|
27
21
|
prisma: PrismaClient;
|
|
28
|
-
queryWhere?: any;
|
|
29
22
|
}
|
|
30
23
|
/**
|
|
31
24
|
* Retrieves a paginated list of payment modes
|
|
32
25
|
* @param {ListPaymentModeArgs} args - Object containing prisma client, pagination, filtering, and ordering options
|
|
33
26
|
* @returns {Promise<[number, Array<PaymentModeBE>]>} Tuple containing total count and array of payment modes
|
|
34
27
|
*/
|
|
35
|
-
export declare const listPaymentMode: ({ currentPage,
|
|
28
|
+
export declare const listPaymentMode: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListPaymentModeArgs) => Promise<[number, Array<PaymentModeBE>]>;
|
|
36
29
|
/**
|
|
37
30
|
* Retrieves a single payment mode by its ID
|
|
38
31
|
* @param {UnitPaymentModeByIdArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
39
32
|
* @returns {Promise<PaymentModeBE | null>} Payment mode or null if not found
|
|
40
33
|
*/
|
|
41
|
-
export declare const unitPaymentModeById: ({ id,
|
|
34
|
+
export declare const unitPaymentModeById: ({ id, prisma, }: UnitPaymentModeByIdArgs) => Promise<PaymentModeBE | null>;
|
|
42
35
|
/**
|
|
43
36
|
* Updates a payment mode's enabled status
|
|
44
37
|
* @param {UpdatePaymentModeArgs} args - Object containing prisma client, payment mode ID, enabled status, and optional query parameters
|
|
45
38
|
* @returns {Promise<PaymentModeBE>} Updated payment mode
|
|
46
39
|
*/
|
|
47
|
-
export declare const updatePaymentMode: ({ enabled, id,
|
|
40
|
+
export declare const updatePaymentMode: ({ enabled, id, prisma, }: UpdatePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
48
41
|
/**
|
|
49
42
|
* Deletes a payment mode by ID
|
|
50
43
|
* @param {DeletePaymentModeArgs} args - Object containing prisma client, payment mode ID, and optional query parameters
|
|
51
44
|
* @returns {Promise<PaymentModeBE>} Deleted payment mode
|
|
52
45
|
*/
|
|
53
|
-
export declare const deletePaymentMode: ({ id,
|
|
46
|
+
export declare const deletePaymentMode: ({ id, prisma, }: DeletePaymentModeArgs) => Promise<PaymentModeBE>;
|
|
54
47
|
export {};
|