@react-pakistan/util-functions 1.24.67 → 1.24.69

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.
Files changed (41) hide show
  1. package/api/stellar-solutions/app-user/index.d.ts +8 -31
  2. package/api/stellar-solutions/app-user/index.js +26 -24
  3. package/api/stellar-solutions/bank/index.d.ts +9 -32
  4. package/api/stellar-solutions/bank/index.js +19 -25
  5. package/api/stellar-solutions/branch/index.d.ts +9 -32
  6. package/api/stellar-solutions/branch/index.js +19 -25
  7. package/api/stellar-solutions/company/index.d.ts +9 -32
  8. package/api/stellar-solutions/company/index.js +29 -27
  9. package/api/stellar-solutions/company-report/index.d.ts +5 -12
  10. package/api/stellar-solutions/company-report/index.js +23 -16
  11. package/api/stellar-solutions/contact/index.d.ts +8 -31
  12. package/api/stellar-solutions/contact/index.js +19 -25
  13. package/api/stellar-solutions/currency/index.d.ts +8 -31
  14. package/api/stellar-solutions/currency/index.js +30 -27
  15. package/api/stellar-solutions/customer/index.d.ts +9 -35
  16. package/api/stellar-solutions/customer/index.js +31 -30
  17. package/api/stellar-solutions/expense/index.d.ts +11 -32
  18. package/api/stellar-solutions/expense/index.js +41 -50
  19. package/api/stellar-solutions/expense-category/index.d.ts +13 -34
  20. package/api/stellar-solutions/expense-category/index.js +64 -52
  21. package/api/stellar-solutions/lead/index.d.ts +35 -19
  22. package/api/stellar-solutions/lead/index.js +117 -82
  23. package/api/stellar-solutions/menu-order/index.d.ts +19 -15
  24. package/api/stellar-solutions/menu-order/index.js +43 -33
  25. package/api/stellar-solutions/payment/index.d.ts +30 -47
  26. package/api/stellar-solutions/payment/index.js +64 -65
  27. package/api/stellar-solutions/payment-mode/index.d.ts +6 -13
  28. package/api/stellar-solutions/payment-mode/index.js +28 -46
  29. package/api/stellar-solutions/preference/index.d.ts +11 -9
  30. package/api/stellar-solutions/preference/index.js +38 -42
  31. package/api/stellar-solutions/product-category/index.d.ts +10 -13
  32. package/api/stellar-solutions/product-category/index.js +58 -49
  33. package/api/stellar-solutions/profile/index.d.ts +6 -5
  34. package/api/stellar-solutions/profile/index.js +17 -18
  35. package/api/stellar-solutions/quote-invoice/index.d.ts +41 -31
  36. package/api/stellar-solutions/quote-invoice/index.js +116 -124
  37. package/api/stellar-solutions/quote-invoice-report/index.d.ts +7 -14
  38. package/api/stellar-solutions/quote-invoice-report/index.js +27 -20
  39. package/api/stellar-solutions/tax/index.d.ts +11 -18
  40. package/api/stellar-solutions/tax/index.js +49 -40
  41. package/package.json +1 -1
@@ -2,31 +2,16 @@ import { CustomerBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListCustomerArgs {
4
4
  currentPage: number;
5
- include?: {
6
- [key: string]: any;
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 UnitCustomerByIdArgs {
18
- include?: {
19
- [key: string]: any;
20
- };
11
+ id: string;
21
12
  prisma: PrismaClient;
22
- queryWhere: {
23
- [key: string]: any;
24
- };
25
13
  }
26
14
  interface UnitCustomerByPhoneArgs {
27
- include?: {
28
- [key: string]: any;
29
- };
30
15
  phone: string;
31
16
  prisma: PrismaClient;
32
17
  }
@@ -37,54 +22,43 @@ interface UpdateCustomerArgs {
37
22
  email?: string;
38
23
  firstName: string;
39
24
  id: string;
40
- include?: {
41
- [key: string]: any;
42
- };
43
25
  lastName: string;
44
26
  phone: string;
45
27
  prisma: PrismaClient;
46
- queryWhere: {
47
- [key: string]: any;
48
- };
49
28
  }
50
29
  interface DeleteCustomerArgs {
51
- include?: {
52
- [key: string]: any;
53
- };
30
+ id: string;
54
31
  prisma: PrismaClient;
55
- queryWhere: {
56
- [key: string]: any;
57
- };
58
32
  }
59
33
  /**
60
34
  * Retrieves customers with pagination and filtering
61
35
  * @param {ListCustomerArgs} args - Object containing prisma client, pagination, and query options
62
36
  * @returns {Promise<[number, Array<CustomerBE>]>} Tuple containing total count and array of customers
63
37
  */
64
- export declare const listCustomer: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListCustomerArgs) => Promise<[number, Array<CustomerBE>]>;
38
+ export declare const listCustomer: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListCustomerArgs) => Promise<[number, Array<CustomerBE>]>;
65
39
  /**
66
40
  * Retrieves a single customer by ID
67
41
  * @param {UnitCustomerByIdArgs} args - Object containing prisma client and query where conditions
68
42
  * @returns {Promise<CustomerBE | null>} Customer if found, null otherwise
69
43
  */
70
- export declare const unitCustomerById: ({ prisma, queryWhere, include, }: UnitCustomerByIdArgs) => Promise<CustomerBE | null>;
44
+ export declare const unitCustomerById: ({ id, prisma, }: UnitCustomerByIdArgs) => Promise<CustomerBE | null>;
71
45
  /**
72
46
  * Retrieves a single customer by phone number
73
47
  * @param {UnitCustomerByPhoneArgs} args - Object containing prisma client and phone number
74
48
  * @returns {Promise<CustomerBE | null>} Customer if found, null otherwise
75
49
  */
76
- export declare const unitCustomerByPhone: ({ prisma, phone, include, }: UnitCustomerByPhoneArgs) => Promise<CustomerBE | null>;
50
+ export declare const unitCustomerByPhone: ({ phone, prisma, }: UnitCustomerByPhoneArgs) => Promise<CustomerBE | null>;
77
51
  /**
78
52
  * Creates or updates a customer
79
53
  * @param {UpdateCustomerArgs} args - Object containing prisma client and customer data
80
54
  * @returns {Promise<CustomerBE>} Created or updated customer
81
55
  */
82
- export declare const updateCustomer: ({ prisma, id, queryWhere, address, city, country, email, firstName, lastName, phone, include, }: UpdateCustomerArgs) => Promise<CustomerBE>;
56
+ export declare const updateCustomer: ({ address, city, country, email, firstName, id, lastName, phone, prisma, }: UpdateCustomerArgs) => Promise<CustomerBE>;
83
57
  /**
84
58
  * Deletes a customer by ID
85
59
  * @param {DeleteCustomerArgs} args - Object containing prisma client and query where conditions
86
60
  * @returns {Promise<CustomerBE>} Deleted customer
87
61
  * @throws {Error} If customer ID is not provided or customer not found
88
62
  */
89
- export declare const deleteCustomer: ({ prisma, queryWhere, include, }: DeleteCustomerArgs) => Promise<CustomerBE>;
63
+ export declare const deleteCustomer: ({ id, prisma, }: DeleteCustomerArgs) => Promise<CustomerBE>;
90
64
  export {};
@@ -55,7 +55,8 @@ exports.deleteCustomer = exports.updateCustomer = exports.unitCustomerByPhone =
55
55
  */
56
56
  var listCustomer = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
57
  var _c, count, customers;
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;
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,11 @@ var listCustomer = function (_a) { return __awaiter(void 0, [_a], void 0, functi
66
67
  throw new Error('Valid page limit is required');
67
68
  }
68
69
  return [4 /*yield*/, prisma.$transaction([
69
- prisma.customer.count({
70
- where: queryWhere,
71
- }),
70
+ prisma.customer.count(),
72
71
  prisma.customer.findMany({
73
- orderBy: orderBy,
74
- include: include,
75
- where: queryWhere,
72
+ orderBy: (_d = {},
73
+ _d[orderByColumn] = orderByDirection,
74
+ _d),
76
75
  take: pageLimit,
77
76
  skip: (currentPage - 1) * pageLimit,
78
77
  }),
@@ -91,19 +90,20 @@ exports.listCustomer = listCustomer;
91
90
  */
92
91
  var unitCustomerById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
93
92
  var customer;
94
- var prisma = _b.prisma, queryWhere = _b.queryWhere, _c = _b.include, include = _c === void 0 ? {} : _c;
95
- return __generator(this, function (_d) {
96
- switch (_d.label) {
93
+ var id = _b.id, prisma = _b.prisma;
94
+ return __generator(this, function (_c) {
95
+ switch (_c.label) {
97
96
  case 0:
98
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
97
+ if (!id) {
99
98
  throw new Error('Customer ID is required');
100
99
  }
101
100
  return [4 /*yield*/, prisma.customer.findUnique({
102
- include: include,
103
- where: queryWhere,
101
+ where: {
102
+ id: id,
103
+ },
104
104
  })];
105
105
  case 1:
106
- customer = _d.sent();
106
+ customer = _c.sent();
107
107
  return [2 /*return*/, customer];
108
108
  }
109
109
  });
@@ -116,21 +116,20 @@ exports.unitCustomerById = unitCustomerById;
116
116
  */
117
117
  var unitCustomerByPhone = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
118
118
  var customer;
119
- var prisma = _b.prisma, phone = _b.phone, _c = _b.include, include = _c === void 0 ? {} : _c;
120
- return __generator(this, function (_d) {
121
- switch (_d.label) {
119
+ var phone = _b.phone, prisma = _b.prisma;
120
+ return __generator(this, function (_c) {
121
+ switch (_c.label) {
122
122
  case 0:
123
123
  if (!phone) {
124
124
  throw new Error('Phone number is required');
125
125
  }
126
126
  return [4 /*yield*/, prisma.customer.findUnique({
127
- include: include,
128
127
  where: {
129
128
  phone: phone,
130
129
  },
131
130
  })];
132
131
  case 1:
133
- customer = _d.sent();
132
+ customer = _c.sent();
134
133
  return [2 /*return*/, customer];
135
134
  }
136
135
  });
@@ -143,11 +142,11 @@ exports.unitCustomerByPhone = unitCustomerByPhone;
143
142
  */
144
143
  var updateCustomer = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
145
144
  var customerData, customer;
146
- var prisma = _b.prisma, id = _b.id, queryWhere = _b.queryWhere, address = _b.address, city = _b.city, country = _b.country, email = _b.email, firstName = _b.firstName, lastName = _b.lastName, phone = _b.phone, include = _b.include;
145
+ var address = _b.address, city = _b.city, country = _b.country, email = _b.email, firstName = _b.firstName, id = _b.id, lastName = _b.lastName, phone = _b.phone, prisma = _b.prisma;
147
146
  return __generator(this, function (_c) {
148
147
  switch (_c.label) {
149
148
  case 0:
150
- if (!id || !(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
149
+ if (!id) {
151
150
  throw new Error('Customer ID is required');
152
151
  }
153
152
  if (!city || !country || !firstName || !lastName || !phone) {
@@ -163,10 +162,11 @@ var updateCustomer = function (_a) { return __awaiter(void 0, [_a], void 0, func
163
162
  phone: phone,
164
163
  };
165
164
  return [4 /*yield*/, prisma.customer.upsert({
166
- where: queryWhere,
165
+ where: {
166
+ id: id,
167
+ },
167
168
  update: customerData,
168
169
  create: __assign({ id: id }, customerData),
169
- include: include,
170
170
  })];
171
171
  case 1:
172
172
  customer = _c.sent();
@@ -183,19 +183,20 @@ exports.updateCustomer = updateCustomer;
183
183
  */
184
184
  var deleteCustomer = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
185
185
  var customer;
186
- var prisma = _b.prisma, queryWhere = _b.queryWhere, _c = _b.include, include = _c === void 0 ? {} : _c;
187
- return __generator(this, function (_d) {
188
- switch (_d.label) {
186
+ var id = _b.id, prisma = _b.prisma;
187
+ return __generator(this, function (_c) {
188
+ switch (_c.label) {
189
189
  case 0:
190
- if (!(queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id)) {
190
+ if (!id) {
191
191
  throw new Error('Customer ID is required');
192
192
  }
193
193
  return [4 /*yield*/, prisma.customer.delete({
194
- include: include,
195
- where: queryWhere,
194
+ where: {
195
+ id: id,
196
+ },
196
197
  })];
197
198
  case 1:
198
- customer = _d.sent();
199
+ customer = _c.sent();
199
200
  return [2 /*return*/, customer];
200
201
  }
201
202
  });
@@ -2,77 +2,56 @@ import { ExpenseBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListExpenseArgs {
4
4
  currentPage: number;
5
- include?: {
6
- [key: string]: any;
7
- };
8
- orderBy?: {
9
- [key: string]: any;
10
- };
5
+ includeExpenseCategory?: boolean;
6
+ orderByColumn?: string;
7
+ orderByDirection?: 'asc' | 'desc';
11
8
  pageLimit: number;
12
9
  prisma: PrismaClient;
13
- queryWhere?: {
14
- [key: string]: any;
15
- };
16
10
  }
17
11
  interface UnitExpenseByIdArgs {
18
12
  id: string;
19
- include?: {
20
- [key: string]: any;
21
- };
13
+ includeExpenseCategory?: boolean;
22
14
  prisma: PrismaClient;
23
- queryWhere?: {
24
- [key: string]: any;
25
- };
26
15
  }
27
16
  interface UpdateExpenseArgs {
28
17
  currency: string;
29
18
  description: string;
30
19
  expenseCategoryId: string;
31
- id?: string;
32
- include?: {
33
- [key: string]: any;
34
- };
20
+ id: string;
21
+ includeExpenseCategory?: boolean;
35
22
  name: string;
36
23
  prisma: PrismaClient;
37
- queryWhere?: {
38
- [key: string]: any;
39
- };
40
24
  ref?: string;
41
25
  total: string;
42
26
  }
43
27
  interface DeleteExpenseArgs {
44
28
  id: string;
45
- include?: {
46
- [key: string]: any;
47
- };
29
+ includeExpenseCategory?: boolean;
48
30
  prisma: PrismaClient;
49
- queryWhere?: {
50
- [key: string]: any;
51
- };
52
31
  }
53
32
  /**
54
33
  * Retrieves expenses with pagination and filtering
55
34
  * @param {ListExpenseArgs} args - Object containing prisma client, pagination, and query options
56
35
  * @returns {Promise<[number, Array<ExpenseBE>]>} Tuple containing total count and array of expenses
57
36
  */
58
- export declare const listExpense: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListExpenseArgs) => Promise<[number, Array<ExpenseBE>]>;
37
+ export declare const listExpense: ({ currentPage, includeExpenseCategory, orderByColumn, orderByDirection, pageLimit, prisma, }: ListExpenseArgs) => Promise<[number, Array<ExpenseBE>]>;
59
38
  /**
60
39
  * Retrieves a single expense by ID
61
40
  * @param {UnitExpenseByIdArgs} args - Object containing prisma client, expense id, and optional query parameters
62
41
  * @returns {Promise<ExpenseBE | null>} Expense with optional relations if found, null otherwise
63
42
  */
64
- export declare const unitExpenseById: ({ id, include, prisma, queryWhere, }: UnitExpenseByIdArgs) => Promise<ExpenseBE | null>;
43
+ export declare const unitExpenseById: ({ id, includeExpenseCategory, prisma, }: UnitExpenseByIdArgs) => Promise<ExpenseBE | null>;
65
44
  /**
66
45
  * Creates or updates an expense using upsert
67
46
  * @param {UpdateExpenseArgs} args - Object containing prisma client and expense data
68
47
  * @returns {Promise<ExpenseBE>} Created or updated expense
69
48
  */
70
- export declare const updateExpense: ({ currency, description, expenseCategoryId, id, include, name, prisma, queryWhere, ref, total, }: UpdateExpenseArgs) => Promise<ExpenseBE>;
49
+ export declare const updateExpense: ({ currency, description, expenseCategoryId, id, includeExpenseCategory, name, prisma, ref, total, }: UpdateExpenseArgs) => Promise<ExpenseBE>;
71
50
  /**
72
51
  * Deletes an expense by ID
73
52
  * @param {DeleteExpenseArgs} args - Object containing prisma client, expense id, and optional query parameters
74
53
  * @returns {Promise<ExpenseBE>} Deleted expense
75
54
  * @throws {Error} If expense ID is not provided or expense not found
76
55
  */
77
- export declare const deleteExpense: ({ id, include, prisma, queryWhere, }: DeleteExpenseArgs) => Promise<ExpenseBE>;
56
+ export declare const deleteExpense: ({ id, includeExpenseCategory, prisma, }: DeleteExpenseArgs) => Promise<ExpenseBE>;
78
57
  export {};
@@ -55,9 +55,10 @@ exports.deleteExpense = exports.updateExpense = exports.unitExpenseById = export
55
55
  */
56
56
  var listExpense = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
57
  var _c, count, expenses;
58
- var currentPage = _b.currentPage, _d = _b.include, include = _d === void 0 ? { expenseCategory: true } : _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) {
58
+ var _d;
59
+ var currentPage = _b.currentPage, _e = _b.includeExpenseCategory, includeExpenseCategory = _e === void 0 ? false : _e, _f = _b.orderByColumn, orderByColumn = _f === void 0 ? 'createdAt' : _f, _g = _b.orderByDirection, orderByDirection = _g === void 0 ? 'desc' : _g, pageLimit = _b.pageLimit, prisma = _b.prisma;
60
+ return __generator(this, function (_h) {
61
+ switch (_h.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');
@@ -66,19 +67,18 @@ var listExpense = function (_a) { return __awaiter(void 0, [_a], void 0, functio
66
67
  throw new Error('Page limit must be greater than or equal to 1');
67
68
  }
68
69
  return [4 /*yield*/, prisma.$transaction([
69
- prisma.expense.count({
70
- where: queryWhere,
71
- }),
70
+ prisma.expense.count(),
72
71
  prisma.expense.findMany({
73
- orderBy: orderBy,
74
- include: include,
75
- where: queryWhere,
72
+ orderBy: (_d = {},
73
+ _d[orderByColumn] = orderByDirection,
74
+ _d),
75
+ include: includeExpenseCategory ? { expenseCategory: true } : undefined,
76
76
  take: pageLimit,
77
77
  skip: (currentPage - 1) * pageLimit,
78
78
  }),
79
79
  ])];
80
80
  case 1:
81
- _c = _g.sent(), count = _c[0], expenses = _c[1];
81
+ _c = _h.sent(), count = _c[0], expenses = _c[1];
82
82
  return [2 /*return*/, [count, expenses]];
83
83
  }
84
84
  });
@@ -91,22 +91,21 @@ exports.listExpense = listExpense;
91
91
  */
92
92
  var unitExpenseById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
93
93
  var expense;
94
- var id = _b.id, _c = _b.include, include = _c === void 0 ? { expenseCategory: true } : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
95
- return __generator(this, function (_e) {
96
- switch (_e.label) {
94
+ var id = _b.id, _c = _b.includeExpenseCategory, includeExpenseCategory = _c === void 0 ? false : _c, prisma = _b.prisma;
95
+ return __generator(this, function (_d) {
96
+ switch (_d.label) {
97
97
  case 0:
98
98
  if (!id) {
99
99
  throw new Error('Expense ID is required');
100
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
101
  return [4 /*yield*/, prisma.expense.findUnique({
105
- where: __assign({ id: id }, queryWhere),
106
- include: include || undefined,
102
+ where: {
103
+ id: id,
104
+ },
105
+ include: includeExpenseCategory ? { expenseCategory: true } : undefined,
107
106
  })];
108
107
  case 1:
109
- expense = _e.sent();
108
+ expense = _d.sent();
110
109
  return [2 /*return*/, expense];
111
110
  }
112
111
  });
@@ -118,17 +117,17 @@ exports.unitExpenseById = unitExpenseById;
118
117
  * @returns {Promise<ExpenseBE>} Created or updated expense
119
118
  */
120
119
  var updateExpense = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
121
- var expenseData, expenseId, expense_1, expense;
122
- var currency = _b.currency, description = _b.description, expenseCategoryId = _b.expenseCategoryId, id = _b.id, _c = _b.include, include = _c === void 0 ? { expenseCategory: true } : _c, name = _b.name, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d, ref = _b.ref, total = _b.total;
123
- return __generator(this, function (_e) {
124
- switch (_e.label) {
120
+ var expenseData, expense;
121
+ var currency = _b.currency, description = _b.description, expenseCategoryId = _b.expenseCategoryId, id = _b.id, _c = _b.includeExpenseCategory, includeExpenseCategory = _c === void 0 ? true : _c, name = _b.name, prisma = _b.prisma, ref = _b.ref, total = _b.total;
122
+ return __generator(this, function (_d) {
123
+ switch (_d.label) {
125
124
  case 0:
125
+ if (!id) {
126
+ throw new Error('Expense ID is required');
127
+ }
126
128
  if (!currency || !description || !expenseCategoryId || !name || !total) {
127
129
  throw new Error('Currency, description, expense category ID, name, and total are required');
128
130
  }
129
- if (id && (queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
130
- throw new Error('ID mismatch between parameter and queryWhere');
131
- }
132
131
  expenseData = {
133
132
  currency: currency,
134
133
  description: description,
@@ -137,23 +136,16 @@ var updateExpense = function (_a) { return __awaiter(void 0, [_a], void 0, funct
137
136
  ref: ref || null,
138
137
  total: total,
139
138
  };
140
- expenseId = id || (queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id);
141
- if (!!expenseId) return [3 /*break*/, 2];
142
- return [4 /*yield*/, prisma.expense.create({
143
- data: expenseData,
144
- include: include || undefined,
139
+ return [4 /*yield*/, prisma.expense.upsert({
140
+ where: {
141
+ id: id,
142
+ },
143
+ update: expenseData,
144
+ create: __assign({ id: id }, expenseData),
145
+ include: includeExpenseCategory ? { expenseCategory: true } : undefined,
145
146
  })];
146
147
  case 1:
147
- expense_1 = _e.sent();
148
- return [2 /*return*/, expense_1];
149
- case 2: return [4 /*yield*/, prisma.expense.upsert({
150
- where: __assign({ id: expenseId }, queryWhere),
151
- update: expenseData,
152
- create: __assign({ id: expenseId }, expenseData),
153
- include: include || undefined,
154
- })];
155
- case 3:
156
- expense = _e.sent();
148
+ expense = _d.sent();
157
149
  return [2 /*return*/, expense];
158
150
  }
159
151
  });
@@ -167,22 +159,21 @@ exports.updateExpense = updateExpense;
167
159
  */
168
160
  var deleteExpense = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
169
161
  var expense;
170
- var id = _b.id, _c = _b.include, include = _c === void 0 ? { expenseCategory: true } : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
171
- return __generator(this, function (_e) {
172
- switch (_e.label) {
162
+ var id = _b.id, _c = _b.includeExpenseCategory, includeExpenseCategory = _c === void 0 ? true : _c, prisma = _b.prisma;
163
+ return __generator(this, function (_d) {
164
+ switch (_d.label) {
173
165
  case 0:
174
166
  if (!id) {
175
167
  throw new Error('Expense ID is required');
176
168
  }
177
- if ((queryWhere === null || queryWhere === void 0 ? void 0 : queryWhere.id) && queryWhere.id !== id) {
178
- throw new Error('ID mismatch between parameter and queryWhere');
179
- }
180
169
  return [4 /*yield*/, prisma.expense.delete({
181
- where: __assign({ id: id }, queryWhere),
182
- include: include || undefined,
170
+ where: {
171
+ id: id,
172
+ },
173
+ include: includeExpenseCategory ? { expenseCategory: true } : undefined,
183
174
  })];
184
175
  case 1:
185
- expense = _e.sent();
176
+ expense = _d.sent();
186
177
  return [2 /*return*/, expense];
187
178
  }
188
179
  });
@@ -1,75 +1,54 @@
1
1
  import { ExpenseCategoryBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListExpenseCategoryArgs {
4
- currentPage: number;
5
- include?: {
6
- [key: string]: any;
7
- };
8
- orderBy?: {
9
- [key: string]: any;
10
- };
11
- pageLimit: number;
4
+ currentPage?: number;
5
+ includeExpenses?: boolean;
6
+ orderByColumn?: string;
7
+ orderByDirection?: 'asc' | 'desc';
8
+ pageLimit?: number;
12
9
  prisma: PrismaClient;
13
- queryWhere?: {
14
- [key: string]: any;
15
- };
16
10
  }
17
11
  interface UnitExpenseCategoryByIdArgs {
18
12
  id: string;
19
- include?: {
20
- [key: string]: any;
21
- };
13
+ includeExpenses?: boolean;
22
14
  prisma: PrismaClient;
23
- queryWhere?: {
24
- [key: string]: any;
25
- };
26
15
  }
27
16
  interface UpdateExpenseCategoryArgs {
28
17
  color: string;
29
18
  description?: string;
30
- id?: string;
31
- include?: {
32
- [key: string]: any;
33
- };
19
+ id: string;
20
+ includeExpenses?: boolean;
34
21
  name: string;
35
22
  prisma: PrismaClient;
36
- queryWhere?: {
37
- [key: string]: any;
38
- };
39
23
  }
40
24
  interface DeleteExpenseCategoryArgs {
41
25
  id: string;
42
- include?: {
43
- [key: string]: any;
44
- };
26
+ includeExpenses?: boolean;
45
27
  prisma: PrismaClient;
46
- queryWhere?: {
47
- [key: string]: any;
48
- };
49
28
  }
50
29
  /**
51
30
  * Retrieves expense categories with pagination and filtering
52
31
  * @param {ListExpenseCategoryArgs} args - Object containing prisma client, pagination, and query options
53
32
  * @returns {Promise<[number, Array<ExpenseCategoryBE>]>} Tuple containing total count and array of expense categories
54
33
  */
55
- export declare const listExpenseCategory: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListExpenseCategoryArgs) => Promise<[number, Array<ExpenseCategoryBE>]>;
34
+ export declare const listExpenseCategory: ({ currentPage, includeExpenses, orderByColumn, orderByDirection, pageLimit, prisma, }: ListExpenseCategoryArgs) => Promise<[number, Array<ExpenseCategoryBE>]>;
56
35
  /**
57
36
  * Retrieves a single expense category by ID
58
37
  * @param {UnitExpenseCategoryByIdArgs} args - Object containing prisma client, expense category id, and optional query parameters
59
38
  * @returns {Promise<ExpenseCategoryBE | null>} Expense category with optional relations if found, null otherwise
60
39
  */
61
- export declare const unitExpenseCategoryById: ({ id, include, prisma, queryWhere, }: UnitExpenseCategoryByIdArgs) => Promise<ExpenseCategoryBE | null>;
40
+ export declare const unitExpenseCategoryById: ({ id, includeExpenses, prisma, }: UnitExpenseCategoryByIdArgs) => Promise<ExpenseCategoryBE | null>;
62
41
  /**
63
42
  * Creates or updates an expense category using upsert
64
43
  * @param {UpdateExpenseCategoryArgs} args - Object containing prisma client and expense category data
65
44
  * @returns {Promise<ExpenseCategoryBE>} Created or updated expense category
66
45
  */
67
- export declare const updateExpenseCategory: ({ color, description, id, include, name, prisma, queryWhere, }: UpdateExpenseCategoryArgs) => Promise<ExpenseCategoryBE>;
46
+ export declare const updateExpenseCategory: ({ color, description, id, includeExpenses, name, prisma, }: UpdateExpenseCategoryArgs) => Promise<ExpenseCategoryBE>;
68
47
  /**
69
48
  * Deletes an expense category by ID
70
49
  * @param {DeleteExpenseCategoryArgs} args - Object containing prisma client, expense category id, and optional query parameters
71
50
  * @returns {Promise<ExpenseCategoryBE>} Deleted expense category
72
51
  * @throws {Error} If expense category ID is not provided or expense category not found
73
52
  */
74
- export declare const deleteExpenseCategory: ({ id, include, prisma, queryWhere, }: DeleteExpenseCategoryArgs) => Promise<ExpenseCategoryBE>;
53
+ export declare const deleteExpenseCategory: ({ id, includeExpenses, prisma, }: DeleteExpenseCategoryArgs) => Promise<ExpenseCategoryBE>;
75
54
  export {};