@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
@@ -1,21 +1,27 @@
1
1
  import { QuoteInvoiceBE } from '../type';
2
2
  type PrismaClient = any;
3
- interface GetQuotesInvoicesArgs {
3
+ interface ListQuoteInvoiceArgs {
4
+ currentPage?: number;
5
+ includeCompany?: boolean;
6
+ includeCustomer?: boolean;
7
+ includePayments?: boolean;
8
+ includeProducts?: boolean;
9
+ includeServices?: boolean;
10
+ orderByColumn?: string;
11
+ orderByDirection?: 'asc' | 'desc';
12
+ pageLimit?: number;
4
13
  prisma: PrismaClient;
5
14
  }
6
- interface GetQuoteInvoiceByIdArgs {
15
+ interface UnitQuoteInvoiceByIdArgs {
7
16
  id: string;
17
+ includeCompany?: boolean;
18
+ includeCustomer?: boolean;
19
+ includePayments?: boolean;
20
+ includeProducts?: boolean;
21
+ includeServices?: boolean;
8
22
  prisma: PrismaClient;
9
23
  }
10
- interface PostQuotesInvoicesArgs {
11
- currentPage: number;
12
- pageLimit: number;
13
- prisma: PrismaClient;
14
- queryWhere?: {
15
- [key: string]: any;
16
- };
17
- }
18
- interface PostQuoteInvoiceArgs {
24
+ interface UpdateQuoteInvoiceArgs {
19
25
  address?: string;
20
26
  category: string;
21
27
  city?: string;
@@ -30,6 +36,11 @@ interface PostQuoteInvoiceArgs {
30
36
  expiryDate: string;
31
37
  firstName?: string;
32
38
  id?: string;
39
+ includeCompany?: boolean;
40
+ includeCustomer?: boolean;
41
+ includePayments?: boolean;
42
+ includeProducts?: boolean;
43
+ includeServices?: boolean;
33
44
  invoiceStatus: string;
34
45
  lastName?: string;
35
46
  mode: 'Create' | 'Edit';
@@ -48,38 +59,37 @@ interface PostQuoteInvoiceArgs {
48
59
  total: string;
49
60
  }
50
61
  interface DeleteQuoteInvoiceArgs {
51
- prisma: PrismaClient;
52
62
  id: string;
63
+ includeCompany?: boolean;
64
+ includeCustomer?: boolean;
65
+ includePayments?: boolean;
66
+ includeProducts?: boolean;
67
+ includeServices?: boolean;
68
+ prisma: PrismaClient;
53
69
  }
54
70
  /**
55
- * Retrieves all quotes/invoices with related data
56
- * @param {GetQuotesInvoicesArgs} args - Object containing prisma client
57
- * @returns {Promise<Array<QuoteInvoiceBE>>} Array of quotes/invoices with related entities (company, customer, payments, products, services)
58
- */
59
- export declare const getQuotesInvoices: ({ prisma, }: GetQuotesInvoicesArgs) => Promise<Array<QuoteInvoiceBE>>;
60
- /**
61
- * Retrieves a quote/invoice by its ID with related data
62
- * @param {GetQuoteInvoiceByIdArgs} args - Object containing prisma client and quote/invoice ID
63
- * @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice with related entities or null if not found
71
+ * Retrieves a paginated list of quotes/invoices
72
+ * @param {ListQuoteInvoiceArgs} args - Object containing prisma client, pagination, filtering, and ordering options
73
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of quotes/invoices
64
74
  */
65
- export declare const getQuoteInvoiceById: ({ prisma, id, }: GetQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceBE | null>;
75
+ export declare const listQuoteInvoice: ({ currentPage, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, orderByColumn, orderByDirection, pageLimit, prisma, }: ListQuoteInvoiceArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
66
76
  /**
67
- * Retrieves paginated quotes/invoices with filtering
68
- * @param {PostQuotesInvoicesArgs} args - Object containing prisma client, pagination, and filtering options
69
- * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, quotes/invoices array]
77
+ * Retrieves a single quote/invoice by its ID
78
+ * @param {UnitQuoteInvoiceByIdArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
79
+ * @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice or null if not found
70
80
  */
71
- export declare const postQuotesInvoices: ({ currentPage, pageLimit, prisma, queryWhere, }: PostQuotesInvoicesArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
81
+ export declare const unitQuoteInvoiceById: ({ id, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, prisma, }: UnitQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceBE | null>;
72
82
  /**
73
- * Creates a new quote/invoice or updates an existing one
83
+ * Creates or updates a quote/invoice
74
84
  * Handles complex business logic including customer/company associations and service management
75
- * @param {PostQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice data
85
+ * @param {UpdateQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice data, and optional query parameters
76
86
  * @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
77
87
  */
78
- export declare const postQuoteInvoice: ({ address, category, city, companyId, country, currency, customerId, date, discount, discountUnit, email, expiryDate, firstName, id, invoiceStatus, lastName, mode, note, phone, prisma, products, quoteStatus, ref, services, subTotal, taxRate, total, }: PostQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
88
+ export declare const updateQuoteInvoice: ({ address, category, city, companyId, country, currency, customerId, date, discount, discountUnit, email, expiryDate, firstName, id, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, invoiceStatus, lastName, mode, note, phone, prisma, products, quoteStatus, ref, services, subTotal, taxRate, total, }: UpdateQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
79
89
  /**
80
90
  * Deletes a quote/invoice by ID
81
- * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice ID
91
+ * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
82
92
  * @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
83
93
  */
84
- export declare const deleteQuoteInvoice: ({ prisma, id, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
94
+ export declare const deleteQuoteInvoice: ({ id, includeCompany, includeCustomer, includePayments, includeProducts, includeServices, prisma, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
85
95
  export {};
@@ -47,125 +47,103 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  }
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.deleteQuoteInvoice = exports.postQuoteInvoice = exports.postQuotesInvoices = exports.getQuoteInvoiceById = exports.getQuotesInvoices = void 0;
50
+ exports.deleteQuoteInvoice = exports.updateQuoteInvoice = exports.unitQuoteInvoiceById = exports.listQuoteInvoice = void 0;
51
51
  /**
52
- * Retrieves all quotes/invoices with related data
53
- * @param {GetQuotesInvoicesArgs} args - Object containing prisma client
54
- * @returns {Promise<Array<QuoteInvoiceBE>>} Array of quotes/invoices with related entities (company, customer, payments, products, services)
52
+ * Retrieves a paginated list of quotes/invoices
53
+ * @param {ListQuoteInvoiceArgs} args - Object containing prisma client, pagination, filtering, and ordering options
54
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of quotes/invoices
55
55
  */
56
- var getQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
- var quotesInvoices;
58
- var prisma = _b.prisma;
59
- return __generator(this, function (_c) {
60
- switch (_c.label) {
61
- case 0: return [4 /*yield*/, prisma.quoteInvoice.findMany({
62
- orderBy: {
63
- createdAt: 'desc',
64
- },
65
- include: {
66
- company: true,
67
- customer: true,
68
- payments: true,
69
- products: true,
70
- services: true,
71
- },
72
- })];
56
+ var listQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
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.includeCompany, includeCompany = _f === void 0 ? false : _f, _g = _b.includeCustomer, includeCustomer = _g === void 0 ? false : _g, _h = _b.includePayments, includePayments = _h === void 0 ? false : _h, _j = _b.includeProducts, includeProducts = _j === void 0 ? false : _j, _k = _b.includeServices, includeServices = _k === void 0 ? false : _k, _l = _b.orderByColumn, orderByColumn = _l === void 0 ? 'createdAt' : _l, _m = _b.orderByDirection, orderByDirection = _m === void 0 ? 'desc' : _m, _o = _b.pageLimit, pageLimit = _o === void 0 ? 10 : _o, prisma = _b.prisma;
60
+ return __generator(this, function (_p) {
61
+ switch (_p.label) {
62
+ case 0:
63
+ if (currentPage < 1) {
64
+ throw new Error('Current page must be greater than or equal to 1');
65
+ }
66
+ if (pageLimit < 1) {
67
+ throw new Error('Page limit must be greater than or equal to 1');
68
+ }
69
+ include = {
70
+ company: includeCompany,
71
+ customer: includeCustomer,
72
+ payments: includePayments,
73
+ products: includeProducts,
74
+ services: includeServices,
75
+ };
76
+ orderBy = (_d = {},
77
+ _d[orderByColumn] = orderByDirection,
78
+ _d);
79
+ skip = (currentPage - 1) * pageLimit;
80
+ where = {};
81
+ return [4 /*yield*/, prisma.$transaction([
82
+ prisma.quoteInvoice.count({
83
+ where: where,
84
+ }),
85
+ prisma.quoteInvoice.findMany({
86
+ include: include,
87
+ orderBy: orderBy,
88
+ skip: skip,
89
+ take: pageLimit,
90
+ where: where,
91
+ }),
92
+ ])];
73
93
  case 1:
74
- quotesInvoices = _c.sent();
75
- return [2 /*return*/, quotesInvoices];
94
+ _c = _p.sent(), count = _c[0], items = _c[1];
95
+ return [2 /*return*/, [count, items]];
76
96
  }
77
97
  });
78
98
  }); };
79
- exports.getQuotesInvoices = getQuotesInvoices;
99
+ exports.listQuoteInvoice = listQuoteInvoice;
80
100
  /**
81
- * Retrieves a quote/invoice by its ID with related data
82
- * @param {GetQuoteInvoiceByIdArgs} args - Object containing prisma client and quote/invoice ID
83
- * @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice with related entities or null if not found
101
+ * Retrieves a single quote/invoice by its ID
102
+ * @param {UnitQuoteInvoiceByIdArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
103
+ * @returns {Promise<QuoteInvoiceBE | null>} Quote/invoice or null if not found
84
104
  */
85
- var getQuoteInvoiceById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
86
- var quoteInvoice;
87
- var prisma = _b.prisma, id = _b.id;
88
- return __generator(this, function (_c) {
89
- switch (_c.label) {
105
+ var unitQuoteInvoiceById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
106
+ var include, where, quoteInvoice;
107
+ var id = _b.id, _c = _b.includeCompany, includeCompany = _c === void 0 ? false : _c, _d = _b.includeCustomer, includeCustomer = _d === void 0 ? false : _d, _e = _b.includePayments, includePayments = _e === void 0 ? false : _e, _f = _b.includeProducts, includeProducts = _f === void 0 ? false : _f, _g = _b.includeServices, includeServices = _g === void 0 ? false : _g, prisma = _b.prisma;
108
+ return __generator(this, function (_h) {
109
+ switch (_h.label) {
90
110
  case 0:
91
111
  if (!id) {
92
112
  throw new Error('Quote/invoice ID is required');
93
113
  }
114
+ include = {
115
+ company: includeCompany,
116
+ customer: includeCustomer,
117
+ payments: includePayments,
118
+ products: includeProducts,
119
+ services: includeServices,
120
+ };
121
+ where = {
122
+ id: id,
123
+ };
94
124
  return [4 /*yield*/, prisma.quoteInvoice.findUnique({
95
- where: {
96
- id: id,
97
- },
98
- include: {
99
- company: true,
100
- customer: true,
101
- payments: true,
102
- products: true,
103
- services: true,
104
- },
125
+ include: include,
126
+ where: where,
105
127
  })];
106
128
  case 1:
107
- quoteInvoice = _c.sent();
129
+ quoteInvoice = _h.sent();
108
130
  return [2 /*return*/, quoteInvoice];
109
131
  }
110
132
  });
111
133
  }); };
112
- exports.getQuoteInvoiceById = getQuoteInvoiceById;
113
- /**
114
- * Retrieves paginated quotes/invoices with filtering
115
- * @param {PostQuotesInvoicesArgs} args - Object containing prisma client, pagination, and filtering options
116
- * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, quotes/invoices array]
117
- */
118
- var postQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
119
- var quotesInvoices;
120
- var _c = _b.currentPage, currentPage = _c === void 0 ? 1 : _c, _d = _b.pageLimit, pageLimit = _d === void 0 ? 10 : _d, prisma = _b.prisma, _e = _b.queryWhere, queryWhere = _e === void 0 ? {} : _e;
121
- return __generator(this, function (_f) {
122
- switch (_f.label) {
123
- case 0:
124
- if (currentPage < 1) {
125
- throw new Error('Current page must be greater than 0');
126
- }
127
- if (pageLimit < 1) {
128
- throw new Error('Page limit must be greater than 0');
129
- }
130
- return [4 /*yield*/, prisma.$transaction([
131
- prisma.quoteInvoice.count({
132
- where: queryWhere,
133
- }),
134
- prisma.quoteInvoice.findMany({
135
- orderBy: {
136
- createdAt: 'desc',
137
- },
138
- include: {
139
- company: true,
140
- customer: true,
141
- payments: true,
142
- products: true,
143
- services: true,
144
- },
145
- where: queryWhere,
146
- take: pageLimit,
147
- skip: (currentPage - 1) * pageLimit,
148
- }),
149
- ])];
150
- case 1:
151
- quotesInvoices = _f.sent();
152
- return [2 /*return*/, quotesInvoices];
153
- }
154
- });
155
- }); };
156
- exports.postQuotesInvoices = postQuotesInvoices;
134
+ exports.unitQuoteInvoiceById = unitQuoteInvoiceById;
157
135
  /**
158
- * Creates a new quote/invoice or updates an existing one
136
+ * Creates or updates a quote/invoice
159
137
  * Handles complex business logic including customer/company associations and service management
160
- * @param {PostQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice data
138
+ * @param {UpdateQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice data, and optional query parameters
161
139
  * @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
162
140
  */
163
- var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
164
- var quoteInvoice, mappedServices, foundQuoteInvoice, filteredEditServices, filteredCreateServices;
141
+ var updateQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
142
+ var include, quoteInvoice, mappedServices, where, foundQuoteInvoice, filteredEditServices, filteredCreateServices;
165
143
  var _c, _d;
166
- var address = _b.address, category = _b.category, city = _b.city, companyId = _b.companyId, country = _b.country, currency = _b.currency, customerId = _b.customerId, date = _b.date, discount = _b.discount, discountUnit = _b.discountUnit, email = _b.email, expiryDate = _b.expiryDate, firstName = _b.firstName, id = _b.id, invoiceStatus = _b.invoiceStatus, lastName = _b.lastName, mode = _b.mode, note = _b.note, phone = _b.phone, prisma = _b.prisma, products = _b.products, quoteStatus = _b.quoteStatus, ref = _b.ref, services = _b.services, subTotal = _b.subTotal, taxRate = _b.taxRate, total = _b.total;
167
- return __generator(this, function (_e) {
168
- switch (_e.label) {
144
+ var address = _b.address, category = _b.category, city = _b.city, companyId = _b.companyId, country = _b.country, currency = _b.currency, customerId = _b.customerId, date = _b.date, discount = _b.discount, discountUnit = _b.discountUnit, email = _b.email, expiryDate = _b.expiryDate, firstName = _b.firstName, id = _b.id, _e = _b.includeCompany, includeCompany = _e === void 0 ? false : _e, _f = _b.includeCustomer, includeCustomer = _f === void 0 ? false : _f, _g = _b.includePayments, includePayments = _g === void 0 ? false : _g, _h = _b.includeProducts, includeProducts = _h === void 0 ? false : _h, _j = _b.includeServices, includeServices = _j === void 0 ? false : _j, invoiceStatus = _b.invoiceStatus, lastName = _b.lastName, mode = _b.mode, note = _b.note, phone = _b.phone, prisma = _b.prisma, products = _b.products, quoteStatus = _b.quoteStatus, ref = _b.ref, services = _b.services, subTotal = _b.subTotal, taxRate = _b.taxRate, total = _b.total;
145
+ return __generator(this, function (_k) {
146
+ switch (_k.label) {
169
147
  case 0:
170
148
  if (!category ||
171
149
  !currency ||
@@ -185,6 +163,13 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
185
163
  if (mode !== 'Create' && mode !== 'Edit') {
186
164
  throw new Error('Mode must be either "Create" or "Edit"');
187
165
  }
166
+ include = {
167
+ company: includeCompany,
168
+ customer: includeCustomer,
169
+ payments: includePayments,
170
+ products: includeProducts,
171
+ services: includeServices,
172
+ };
188
173
  if (!(mode === 'Create')) return [3 /*break*/, 5];
189
174
  mappedServices = void 0;
190
175
  if (services === null || services === void 0 ? void 0 : services.length) {
@@ -208,13 +193,10 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
208
193
  },
209
194
  },
210
195
  })),
211
- include: {
212
- products: true,
213
- services: true,
214
- },
196
+ include: include,
215
197
  })];
216
198
  case 1:
217
- quoteInvoice = _e.sent();
199
+ quoteInvoice = _k.sent();
218
200
  return [4 /*yield*/, ((_c = products === null || products === void 0 ? void 0 : products.filter(function (product) { return product.id; })) === null || _c === void 0 ? void 0 : _c.forEach(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
219
201
  var _id = _b.id, quantity = _b.quantity;
220
202
  return __generator(this, function (_c) {
@@ -233,7 +215,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
233
215
  });
234
216
  }); }))];
235
217
  case 2:
236
- _e.sent();
218
+ _k.sent();
237
219
  return [3 /*break*/, 5];
238
220
  case 3: return [4 /*yield*/, prisma.quoteInvoice.create({
239
221
  data: __assign(__assign(__assign(__assign(__assign({ category: category }, (companyId && {
@@ -257,22 +239,24 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
257
239
  },
258
240
  },
259
241
  })),
242
+ include: include,
260
243
  })];
261
244
  case 4:
262
- quoteInvoice = _e.sent();
263
- _e.label = 5;
245
+ quoteInvoice = _k.sent();
246
+ _k.label = 5;
264
247
  case 5:
265
248
  if (!(mode === 'Edit')) return [3 /*break*/, 10];
266
249
  if (!id) {
267
250
  throw new Error('Quote/invoice ID is required for Edit mode');
268
251
  }
252
+ where = {
253
+ id: id,
254
+ };
269
255
  return [4 /*yield*/, prisma.quoteInvoice.findUnique({
270
- where: {
271
- id: id,
272
- },
256
+ where: where,
273
257
  })];
274
258
  case 6:
275
- foundQuoteInvoice = _e.sent();
259
+ foundQuoteInvoice = _k.sent();
276
260
  if (!foundQuoteInvoice) {
277
261
  throw new Error('Quote/invoice not found');
278
262
  }
@@ -317,43 +301,51 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
317
301
  data: filteredCreateServices,
318
302
  })];
319
303
  case 7:
320
- _e.sent();
321
- _e.label = 8;
304
+ _k.sent();
305
+ _k.label = 8;
322
306
  case 8: return [4 /*yield*/, prisma.quoteInvoice.update({
323
- where: {
324
- id: id,
325
- },
307
+ where: where,
326
308
  data: __assign(__assign({}, foundQuoteInvoice), { category: category, companyId: companyId || null, currency: currency, customerId: customerId || null, date: date, discount: discount || null, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }),
309
+ include: include,
327
310
  })];
328
311
  case 9:
329
- quoteInvoice = _e.sent();
330
- _e.label = 10;
312
+ quoteInvoice = _k.sent();
313
+ _k.label = 10;
331
314
  case 10: return [2 /*return*/, quoteInvoice];
332
315
  }
333
316
  });
334
317
  }); };
335
- exports.postQuoteInvoice = postQuoteInvoice;
318
+ exports.updateQuoteInvoice = updateQuoteInvoice;
336
319
  /**
337
320
  * Deletes a quote/invoice by ID
338
- * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice ID
321
+ * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client, quote/invoice ID, and optional query parameters
339
322
  * @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
340
323
  */
341
324
  var deleteQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
342
- var quoteInvoice;
343
- var prisma = _b.prisma, id = _b.id;
344
- return __generator(this, function (_c) {
345
- switch (_c.label) {
325
+ var include, where, quoteInvoice;
326
+ var id = _b.id, _c = _b.includeCompany, includeCompany = _c === void 0 ? false : _c, _d = _b.includeCustomer, includeCustomer = _d === void 0 ? false : _d, _e = _b.includePayments, includePayments = _e === void 0 ? false : _e, _f = _b.includeProducts, includeProducts = _f === void 0 ? false : _f, _g = _b.includeServices, includeServices = _g === void 0 ? false : _g, prisma = _b.prisma;
327
+ return __generator(this, function (_h) {
328
+ switch (_h.label) {
346
329
  case 0:
347
330
  if (!id) {
348
331
  throw new Error('Quote/invoice ID is required');
349
332
  }
333
+ include = {
334
+ company: includeCompany,
335
+ customer: includeCustomer,
336
+ payments: includePayments,
337
+ products: includeProducts,
338
+ services: includeServices,
339
+ };
340
+ where = {
341
+ id: id,
342
+ };
350
343
  return [4 /*yield*/, prisma.quoteInvoice.delete({
351
- where: {
352
- id: id,
353
- },
344
+ include: include,
345
+ where: where,
354
346
  })];
355
347
  case 1:
356
- quoteInvoice = _c.sent();
348
+ quoteInvoice = _h.sent();
357
349
  return [2 /*return*/, quoteInvoice];
358
350
  }
359
351
  });
@@ -1,22 +1,15 @@
1
1
  import { QuoteInvoiceBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface PostQuotesInvoicesReportArgs {
4
- include?: {
5
- [key: string]: any;
6
- };
7
- orderBy?: {
8
- [key: string]: any;
9
- };
4
+ orderByColumn?: string;
5
+ orderByDirection?: 'asc' | 'desc';
10
6
  prisma: PrismaClient;
11
- queryWhere?: {
12
- [key: string]: any;
13
- };
14
7
  }
15
8
  /**
16
- * Generates a report of all quotes/invoices with filtering and sorting (no pagination)
17
- * Returns all matching records for reporting purposes
18
- * @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client, filtering, including, and sorting options
19
- * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, all matching quotes/invoices array]
9
+ * Generates a report of all quotes/invoices with sorting (no pagination)
10
+ * Returns all records for reporting purposes
11
+ * @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client and sorting options
12
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of all quotes/invoices
20
13
  */
21
- export declare const postQuotesInvoicesReport: ({ include, orderBy, prisma, queryWhere, }: PostQuotesInvoicesReportArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
14
+ export declare const postQuotesInvoicesReport: ({ orderByColumn, orderByDirection, prisma, }: PostQuotesInvoicesReportArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
22
15
  export {};
@@ -38,29 +38,36 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.postQuotesInvoicesReport = void 0;
40
40
  /**
41
- * Generates a report of all quotes/invoices with filtering and sorting (no pagination)
42
- * Returns all matching records for reporting purposes
43
- * @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client, filtering, including, and sorting options
44
- * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple of [total count, all matching quotes/invoices array]
41
+ * Generates a report of all quotes/invoices with sorting (no pagination)
42
+ * Returns all records for reporting purposes
43
+ * @param {PostQuotesInvoicesReportArgs} args - Object containing prisma client and sorting options
44
+ * @returns {Promise<[number, Array<QuoteInvoiceBE>]>} Tuple containing total count and array of all quotes/invoices
45
45
  */
46
46
  var postQuotesInvoicesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
47
- var quotesInvoices;
48
- var _c = _b.include, include = _c === void 0 ? {} : _c, _d = _b.orderBy, orderBy = _d === void 0 ? { createdAt: 'desc' } : _d, prisma = _b.prisma, _e = _b.queryWhere, queryWhere = _e === void 0 ? {} : _e;
49
- return __generator(this, function (_f) {
50
- switch (_f.label) {
51
- case 0: return [4 /*yield*/, prisma.$transaction([
52
- prisma.quoteInvoice.count({
53
- where: queryWhere,
54
- }),
55
- prisma.quoteInvoice.findMany({
56
- include: include,
57
- orderBy: orderBy,
58
- where: queryWhere,
59
- }),
60
- ])];
47
+ var include, orderBy, where, _c, count, items;
48
+ var _d;
49
+ var _e = _b.orderByColumn, orderByColumn = _e === void 0 ? 'createdAt' : _e, _f = _b.orderByDirection, orderByDirection = _f === void 0 ? 'desc' : _f, prisma = _b.prisma;
50
+ return __generator(this, function (_g) {
51
+ switch (_g.label) {
52
+ case 0:
53
+ include = {};
54
+ orderBy = (_d = {},
55
+ _d[orderByColumn] = orderByDirection,
56
+ _d);
57
+ where = {};
58
+ return [4 /*yield*/, prisma.$transaction([
59
+ prisma.quoteInvoice.count({
60
+ where: where,
61
+ }),
62
+ prisma.quoteInvoice.findMany({
63
+ include: include,
64
+ orderBy: orderBy,
65
+ where: where,
66
+ }),
67
+ ])];
61
68
  case 1:
62
- quotesInvoices = _f.sent();
63
- return [2 /*return*/, quotesInvoices];
69
+ _c = _g.sent(), count = _c[0], items = _c[1];
70
+ return [2 /*return*/, [count, items]];
64
71
  }
65
72
  });
66
73
  }); };
@@ -2,58 +2,51 @@ import { TaxBE } from '../type';
2
2
  type PrismaClient = any;
3
3
  interface ListTaxArgs {
4
4
  currentPage?: number;
5
- include?: any;
6
- orderBy?: any;
5
+ orderByColumn?: string;
6
+ orderByDirection?: 'asc' | 'desc';
7
7
  pageLimit?: number;
8
8
  prisma: PrismaClient;
9
- queryWhere?: any;
10
9
  }
11
10
  interface UnitTaxByIdArgs {
12
11
  id: string;
13
- include?: any;
14
12
  prisma: PrismaClient;
15
- queryWhere?: any;
16
13
  }
17
14
  interface UpdateTaxArgs {
18
15
  description?: string;
19
16
  enabled: boolean;
20
17
  id: string;
21
- include?: any;
22
18
  isDefault: boolean;
23
19
  preferenceId: string;
24
20
  prisma: PrismaClient;
25
- queryWhere?: any;
26
21
  taxName: string;
27
22
  taxRate: string;
28
23
  }
29
24
  interface DeleteTaxArgs {
30
25
  id: string;
31
- include?: any;
32
26
  prisma: PrismaClient;
33
- queryWhere?: any;
34
27
  }
35
28
  /**
36
29
  * Retrieves a paginated list of taxes
37
- * @param {ListTaxArgs} args - Object containing prisma client, pagination, and filter options
38
- * @returns {Promise<[number, Array<TaxBE>]>} Tuple of [total count, tax array]
30
+ * @param {ListTaxArgs} args - Object containing prisma client, pagination, filtering, and ordering options
31
+ * @returns {Promise<[number, Array<TaxBE>]>} Tuple containing total count and array of taxes
39
32
  */
40
- export declare const listTax: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListTaxArgs) => Promise<[number, Array<TaxBE>]>;
33
+ export declare const listTax: ({ currentPage, orderByColumn, orderByDirection, pageLimit, prisma, }: ListTaxArgs) => Promise<[number, Array<TaxBE>]>;
41
34
  /**
42
35
  * Retrieves a single tax by its ID
43
- * @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional filters
36
+ * @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional query parameters
44
37
  * @returns {Promise<TaxBE | null>} Tax or null if not found
45
38
  */
46
- export declare const unitTaxById: ({ id, include, prisma, queryWhere, }: UnitTaxByIdArgs) => Promise<TaxBE | null>;
39
+ export declare const unitTaxById: ({ id, prisma, }: UnitTaxByIdArgs) => Promise<TaxBE | null>;
47
40
  /**
48
41
  * Creates or updates a tax
49
- * @param {UpdateTaxArgs} args - Object containing prisma client and tax data
42
+ * @param {UpdateTaxArgs} args - Object containing prisma client, tax data, and optional query parameters
50
43
  * @returns {Promise<TaxBE>} Created or updated tax
51
44
  */
52
- export declare const updateTax: ({ description, enabled, id, include, isDefault, preferenceId, prisma, queryWhere, taxName, taxRate, }: UpdateTaxArgs) => Promise<TaxBE>;
45
+ export declare const updateTax: ({ description, enabled, id, isDefault, preferenceId, prisma, taxName, taxRate, }: UpdateTaxArgs) => Promise<TaxBE>;
53
46
  /**
54
47
  * Deletes a tax by ID
55
- * @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional filters
48
+ * @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional query parameters
56
49
  * @returns {Promise<TaxBE>} Deleted tax
57
50
  */
58
- export declare const deleteTax: ({ id, include, prisma, queryWhere, }: DeleteTaxArgs) => Promise<TaxBE>;
51
+ export declare const deleteTax: ({ id, prisma, }: DeleteTaxArgs) => Promise<TaxBE>;
59
52
  export {};