@react-pakistan/util-functions 1.24.65 → 1.24.66

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 (110) hide show
  1. package/README.md +6 -3
  2. package/api/stellar-solutions/app-user/index.d.ts +63 -14
  3. package/api/stellar-solutions/app-user/index.js +106 -52
  4. package/api/stellar-solutions/bank/index.d.ts +65 -16
  5. package/api/stellar-solutions/bank/index.js +115 -65
  6. package/api/stellar-solutions/branch/index.d.ts +64 -15
  7. package/api/stellar-solutions/branch/index.js +119 -65
  8. package/api/stellar-solutions/company/index.d.ts +58 -24
  9. package/api/stellar-solutions/company/index.js +106 -78
  10. package/api/stellar-solutions/company-report/index.d.ts +12 -5
  11. package/api/stellar-solutions/company-report/index.js +12 -7
  12. package/api/stellar-solutions/contact/index.d.ts +54 -20
  13. package/api/stellar-solutions/contact/index.js +109 -88
  14. package/api/stellar-solutions/currency/index.d.ts +63 -14
  15. package/api/stellar-solutions/currency/index.js +113 -61
  16. package/api/stellar-solutions/customer/index.d.ts +70 -28
  17. package/api/stellar-solutions/customer/index.js +131 -101
  18. package/api/stellar-solutions/expense/index.d.ts +58 -22
  19. package/api/stellar-solutions/expense/index.js +128 -92
  20. package/api/stellar-solutions/expense-category/index.d.ts +58 -22
  21. package/api/stellar-solutions/expense-category/index.js +125 -86
  22. package/api/stellar-solutions/lead/index.js +0 -1
  23. package/api/stellar-solutions/menu-order/index.d.ts +29 -7
  24. package/api/stellar-solutions/menu-order/index.js +74 -27
  25. package/api/stellar-solutions/payment/index.d.ts +62 -27
  26. package/api/stellar-solutions/payment/index.js +144 -123
  27. package/api/stellar-solutions/payment-mode/index.d.ts +44 -12
  28. package/api/stellar-solutions/payment-mode/index.js +115 -49
  29. package/api/stellar-solutions/preference/index.d.ts +14 -3
  30. package/api/stellar-solutions/preference/index.js +44 -14
  31. package/api/stellar-solutions/product/index.d.ts +46 -31
  32. package/api/stellar-solutions/product/index.js +142 -113
  33. package/api/stellar-solutions/product-category/index.d.ts +44 -27
  34. package/api/stellar-solutions/product-category/index.js +123 -87
  35. package/api/stellar-solutions/profile/index.d.ts +48 -17
  36. package/api/stellar-solutions/profile/index.js +124 -65
  37. package/api/stellar-solutions/quote-invoice/index.d.ts +67 -8
  38. package/api/stellar-solutions/quote-invoice/index.js +123 -57
  39. package/api/stellar-solutions/quote-invoice-report/index.d.ts +12 -5
  40. package/api/stellar-solutions/quote-invoice-report/index.js +10 -5
  41. package/api/stellar-solutions/tax/index.d.ts +46 -14
  42. package/api/stellar-solutions/tax/index.js +135 -63
  43. package/api/stellar-solutions/type.d.ts +178 -112
  44. package/api/stellar-solutions/type.js +60 -2
  45. package/constants/countries-timezones.js +0 -1
  46. package/constants/currencies.js +0 -1
  47. package/general/basic-get.js +22 -21
  48. package/general/basic-post.js +19 -18
  49. package/general/calculate-pages.js +3 -1
  50. package/general/check-even-odd-length.js +3 -2
  51. package/general/delete-image-from-private-supabase.js +0 -1
  52. package/general/delete-image-from-public-supabase.js +0 -1
  53. package/general/dynamic-page-limit.js +3 -2
  54. package/general/enum-to-text.js +7 -4
  55. package/general/fetch-data.js +0 -1
  56. package/general/fetch-supabase-image.js +0 -1
  57. package/general/fetch-supabase-private-assets.js +15 -14
  58. package/general/format-date.js +8 -8
  59. package/general/format-number.js +3 -2
  60. package/general/format-time.js +3 -2
  61. package/general/full-year-range.js +2 -2
  62. package/general/generate-blog-schema.d.ts +3 -3
  63. package/general/generate-blog-schema.js +20 -13
  64. package/general/generate-breadcrumb-schema.d.ts +4 -4
  65. package/general/generate-breadcrumb-schema.js +9 -10
  66. package/general/generate-faq-schema.d.ts +5 -5
  67. package/general/generate-faq-schema.js +18 -11
  68. package/general/generate-grid.js +0 -1
  69. package/general/generate-organization-schema.d.ts +3 -3
  70. package/general/generate-organization-schema.js +25 -18
  71. package/general/get-available-page-limit.js +2 -2
  72. package/general/get-calendar-dates.js +14 -3
  73. package/general/get-full-name.d.ts +1 -1
  74. package/general/get-number-of-days-in-month.d.ts +1 -1
  75. package/general/get-pathname.js +4 -1
  76. package/general/is-odd.js +1 -1
  77. package/general/is-previous-button-disabled.js +3 -1
  78. package/general/parse-frontmatter.js +0 -1
  79. package/general/remove-data-image-prefix.js +3 -2
  80. package/general/repeat-times.js +0 -1
  81. package/general/resolve-current-date.js +1 -2
  82. package/general/resolve-grid.js +3 -2
  83. package/general/slugify.js +11 -9
  84. package/general/text-to-enum.js +6 -1
  85. package/general/text-to-sentence-case.js +3 -1
  86. package/general/time-out.js +5 -4
  87. package/general/truncate-text.js +3 -1
  88. package/general/upload-blob-to-private-supabase.js +2 -2
  89. package/general/upload-blob-to-public-supabase.js +2 -2
  90. package/general/upload-image-to-private-supabase.js +2 -2
  91. package/general/upload-image-to-public-supabase.js +2 -2
  92. package/general/validate-email.js +1 -1
  93. package/hooks/use-fetch.js +11 -12
  94. package/hooks/use-module-entity.js +5 -6
  95. package/hooks/use-sticky.js +0 -1
  96. package/hooks/with-seo.d.ts +1 -1
  97. package/hooks/with-seo.js +3 -4
  98. package/local-storage/get-storage-value.js +0 -1
  99. package/package.json +22 -13
  100. package/setupTests.js +1 -2
  101. package/storybook/generate-sitemap.js +0 -1
  102. package/storybook/preview.js +1 -4
  103. package/storybook/react-design-story-script.js +0 -2
  104. package/storybook/react-emoji-collection.js +8 -6
  105. package/storybook/react-emoji-story-script.js +0 -2
  106. package/storybook/react-icon-collection.js +4 -3
  107. package/storybook/react-icon-story-script.js +0 -2
  108. package/storybook/react-logo-collection.js +4 -3
  109. package/storybook/react-logo-story-script.js +0 -2
  110. package/storybook/responsive-component.js +14 -7
@@ -1,26 +1,85 @@
1
1
  import { QuoteInvoiceBE } from '../type';
2
+ type PrismaClient = any;
2
3
  interface GetQuotesInvoicesArgs {
3
- prisma: any;
4
+ prisma: PrismaClient;
4
5
  }
5
6
  interface GetQuoteInvoiceByIdArgs {
6
7
  id: string;
7
- prisma: any;
8
+ prisma: PrismaClient;
8
9
  }
9
10
  interface PostQuotesInvoicesArgs {
10
11
  currentPage: number;
11
12
  pageLimit: number;
12
- prisma: any;
13
- queryWhere: {
13
+ prisma: PrismaClient;
14
+ queryWhere?: {
14
15
  [key: string]: any;
15
16
  };
16
17
  }
18
+ interface PostQuoteInvoiceArgs {
19
+ address?: string;
20
+ category: string;
21
+ city?: string;
22
+ companyId?: string;
23
+ country?: string;
24
+ currency: string;
25
+ customerId?: string;
26
+ date: string;
27
+ discount?: string;
28
+ discountUnit: string;
29
+ email?: string;
30
+ expiryDate: string;
31
+ firstName?: string;
32
+ id?: string;
33
+ invoiceStatus: string;
34
+ lastName?: string;
35
+ mode: 'Create' | 'Edit';
36
+ note: string;
37
+ phone?: string;
38
+ prisma: PrismaClient;
39
+ products?: Array<{
40
+ id: string;
41
+ quantity: string;
42
+ }>;
43
+ quoteStatus: string;
44
+ ref: string;
45
+ services?: Array<any>;
46
+ subTotal: string;
47
+ taxRate: string;
48
+ total: string;
49
+ }
17
50
  interface DeleteQuoteInvoiceArgs {
18
- prisma: any;
51
+ prisma: PrismaClient;
19
52
  id: string;
20
53
  }
54
+ /**
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
+ */
21
59
  export declare const getQuotesInvoices: ({ prisma, }: GetQuotesInvoicesArgs) => Promise<Array<QuoteInvoiceBE>>;
22
- export declare const getQuoteInvoiceById: ({ prisma, id, }: GetQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceBE>;
23
- export declare const postQuotesInvoices: ({ currentPage, pageLimit, prisma, queryWhere, }: PostQuotesInvoicesArgs) => Promise<Array<QuoteInvoiceBE>>;
24
- 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, }: any) => Promise<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
64
+ */
65
+ export declare const getQuoteInvoiceById: ({ prisma, id, }: GetQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceBE | null>;
66
+ /**
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]
70
+ */
71
+ export declare const postQuotesInvoices: ({ currentPage, pageLimit, prisma, queryWhere, }: PostQuotesInvoicesArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
72
+ /**
73
+ * Creates a new quote/invoice or updates an existing one
74
+ * Handles complex business logic including customer/company associations and service management
75
+ * @param {PostQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice data
76
+ * @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
77
+ */
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>;
79
+ /**
80
+ * Deletes a quote/invoice by ID
81
+ * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice ID
82
+ * @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
83
+ */
25
84
  export declare const deleteQuoteInvoice: ({ prisma, id, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
26
85
  export {};
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any, no-restricted-globals, @typescript-eslint/array-type */
3
2
  var __assign = (this && this.__assign) || function () {
4
3
  __assign = Object.assign || function(t) {
5
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -49,6 +48,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
49
48
  };
50
49
  Object.defineProperty(exports, "__esModule", { value: true });
51
50
  exports.deleteQuoteInvoice = exports.postQuoteInvoice = exports.postQuotesInvoices = exports.getQuoteInvoiceById = exports.getQuotesInvoices = void 0;
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)
55
+ */
52
56
  var getQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
53
57
  var quotesInvoices;
54
58
  var prisma = _b.prisma;
@@ -73,23 +77,32 @@ var getQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, f
73
77
  });
74
78
  }); };
75
79
  exports.getQuotesInvoices = getQuotesInvoices;
80
+ /**
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
84
+ */
76
85
  var getQuoteInvoiceById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
77
86
  var quoteInvoice;
78
87
  var prisma = _b.prisma, id = _b.id;
79
88
  return __generator(this, function (_c) {
80
89
  switch (_c.label) {
81
- case 0: return [4 /*yield*/, prisma.quoteInvoice.findUnique({
82
- where: {
83
- id: id,
84
- },
85
- include: {
86
- company: true,
87
- customer: true,
88
- payments: true,
89
- products: true,
90
- services: true,
91
- },
92
- })];
90
+ case 0:
91
+ if (!id) {
92
+ throw new Error('Quote/invoice ID is required');
93
+ }
94
+ 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
+ },
105
+ })];
93
106
  case 1:
94
107
  quoteInvoice = _c.sent();
95
108
  return [2 /*return*/, quoteInvoice];
@@ -97,38 +110,56 @@ var getQuoteInvoiceById = function (_a) { return __awaiter(void 0, [_a], void 0,
97
110
  });
98
111
  }); };
99
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
+ */
100
118
  var postQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
101
119
  var quotesInvoices;
102
- var currentPage = _b.currentPage, pageLimit = _b.pageLimit, prisma = _b.prisma, queryWhere = _b.queryWhere;
103
- return __generator(this, function (_c) {
104
- switch (_c.label) {
105
- case 0: return [4 /*yield*/, prisma.$transaction([
106
- prisma.quoteInvoice.count({
107
- where: queryWhere,
108
- }),
109
- prisma.quoteInvoice.findMany({
110
- orderBy: {
111
- createdAt: 'desc',
112
- },
113
- include: {
114
- company: true,
115
- customer: true,
116
- payments: true,
117
- products: true,
118
- services: true,
119
- },
120
- where: queryWhere,
121
- take: pageLimit,
122
- skip: (currentPage - 1) * pageLimit,
123
- }),
124
- ])];
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
+ ])];
125
150
  case 1:
126
- quotesInvoices = _c.sent();
151
+ quotesInvoices = _f.sent();
127
152
  return [2 /*return*/, quotesInvoices];
128
153
  }
129
154
  });
130
155
  }); };
131
156
  exports.postQuotesInvoices = postQuotesInvoices;
157
+ /**
158
+ * Creates a new quote/invoice or updates an existing one
159
+ * Handles complex business logic including customer/company associations and service management
160
+ * @param {PostQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice data
161
+ * @returns {Promise<QuoteInvoiceBE>} Created or updated quote/invoice
162
+ */
132
163
  var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
133
164
  var quoteInvoice, mappedServices, foundQuoteInvoice, filteredEditServices, filteredCreateServices;
134
165
  var _c, _d;
@@ -136,6 +167,24 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
136
167
  return __generator(this, function (_e) {
137
168
  switch (_e.label) {
138
169
  case 0:
170
+ if (!category ||
171
+ !currency ||
172
+ !date ||
173
+ !discountUnit ||
174
+ !expiryDate ||
175
+ !invoiceStatus ||
176
+ !mode ||
177
+ !note ||
178
+ !quoteStatus ||
179
+ !ref ||
180
+ !subTotal ||
181
+ !taxRate ||
182
+ !total) {
183
+ throw new Error('Category, currency, date, discount unit, expiry date, invoice status, mode, note, quote status, ref, sub total, tax rate, and total are required');
184
+ }
185
+ if (mode !== 'Create' && mode !== 'Edit') {
186
+ throw new Error('Mode must be either "Create" or "Edit"');
187
+ }
139
188
  if (!(mode === 'Create')) return [3 /*break*/, 5];
140
189
  mappedServices = void 0;
141
190
  if (services === null || services === void 0 ? void 0 : services.length) {
@@ -152,7 +201,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
152
201
  companyId: companyId,
153
202
  })), { currency: currency }), (customerId && {
154
203
  customerId: customerId,
155
- })), { date: date, discount: discount, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }), (mappedServices && {
204
+ })), { date: date, discount: discount || null, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }), (mappedServices && {
156
205
  services: {
157
206
  createMany: {
158
207
  data: mappedServices,
@@ -187,31 +236,36 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
187
236
  _e.sent();
188
237
  return [3 /*break*/, 5];
189
238
  case 3: return [4 /*yield*/, prisma.quoteInvoice.create({
190
- data: __assign(__assign(__assign(__assign({ category: category }, (companyId && {
239
+ data: __assign(__assign(__assign(__assign(__assign({ category: category }, (companyId && {
191
240
  companyId: companyId,
192
241
  })), { currency: currency }), (customerId && {
193
242
  customerId: customerId,
194
- })), { date: date, discount: discount, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total, customer: {
243
+ })), { date: date, discount: discount || null, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total, customer: {
195
244
  create: {
196
- address: address,
197
- city: city,
198
- country: country,
199
- email: email,
200
- firstName: firstName,
201
- lastName: lastName,
202
- phone: phone,
245
+ address: address || '',
246
+ city: city || '',
247
+ country: country || '',
248
+ email: email || '',
249
+ firstName: firstName || '',
250
+ lastName: lastName || '',
251
+ phone: phone || '',
203
252
  },
204
- }, services: {
253
+ } }), (mappedServices && {
254
+ services: {
205
255
  createMany: {
206
256
  data: mappedServices,
207
257
  },
208
- } }),
258
+ },
259
+ })),
209
260
  })];
210
261
  case 4:
211
262
  quoteInvoice = _e.sent();
212
263
  _e.label = 5;
213
264
  case 5:
214
265
  if (!(mode === 'Edit')) return [3 /*break*/, 10];
266
+ if (!id) {
267
+ throw new Error('Quote/invoice ID is required for Edit mode');
268
+ }
215
269
  return [4 /*yield*/, prisma.quoteInvoice.findUnique({
216
270
  where: {
217
271
  id: id,
@@ -219,6 +273,9 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
219
273
  })];
220
274
  case 6:
221
275
  foundQuoteInvoice = _e.sent();
276
+ if (!foundQuoteInvoice) {
277
+ throw new Error('Quote/invoice not found');
278
+ }
222
279
  filteredEditServices = services === null || services === void 0 ? void 0 : services.filter(function (_a) {
223
280
  var _mode = _a.mode;
224
281
  return _mode === 'Edit';
@@ -229,7 +286,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
229
286
  })) === null || _d === void 0 ? void 0 : _d.map(function (item) {
230
287
  var toReturn = __assign({}, item);
231
288
  delete toReturn.mode;
232
- return (__assign(__assign({}, toReturn), { quoteInvoiceId: id }));
289
+ return __assign(__assign({}, toReturn), { quoteInvoiceId: id });
233
290
  });
234
291
  if (filteredEditServices === null || filteredEditServices === void 0 ? void 0 : filteredEditServices.length) {
235
292
  filteredEditServices === null || filteredEditServices === void 0 ? void 0 : filteredEditServices.map(function (item) { return __awaiter(void 0, void 0, void 0, function () {
@@ -256,7 +313,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
256
313
  }); });
257
314
  }
258
315
  if (!(filteredCreateServices === null || filteredCreateServices === void 0 ? void 0 : filteredCreateServices.length)) return [3 /*break*/, 8];
259
- return [4 /*yield*/, prisma.stellarService.createMany({
316
+ return [4 /*yield*/, prisma.service.createMany({
260
317
  data: filteredCreateServices,
261
318
  })];
262
319
  case 7:
@@ -266,7 +323,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
266
323
  where: {
267
324
  id: id,
268
325
  },
269
- data: __assign(__assign({}, foundQuoteInvoice), { category: category, companyId: companyId, currency: currency, customerId: customerId, date: date, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxRate: taxRate, total: total }),
326
+ 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 }),
270
327
  })];
271
328
  case 9:
272
329
  quoteInvoice = _e.sent();
@@ -276,16 +333,25 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
276
333
  });
277
334
  }); };
278
335
  exports.postQuoteInvoice = postQuoteInvoice;
336
+ /**
337
+ * Deletes a quote/invoice by ID
338
+ * @param {DeleteQuoteInvoiceArgs} args - Object containing prisma client and quote/invoice ID
339
+ * @returns {Promise<QuoteInvoiceBE>} Deleted quote/invoice
340
+ */
279
341
  var deleteQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
280
342
  var quoteInvoice;
281
343
  var prisma = _b.prisma, id = _b.id;
282
344
  return __generator(this, function (_c) {
283
345
  switch (_c.label) {
284
- case 0: return [4 /*yield*/, prisma.quoteInvoice.delete({
285
- where: {
286
- id: id,
287
- },
288
- })];
346
+ case 0:
347
+ if (!id) {
348
+ throw new Error('Quote/invoice ID is required');
349
+ }
350
+ return [4 /*yield*/, prisma.quoteInvoice.delete({
351
+ where: {
352
+ id: id,
353
+ },
354
+ })];
289
355
  case 1:
290
356
  quoteInvoice = _c.sent();
291
357
  return [2 /*return*/, quoteInvoice];
@@ -1,15 +1,22 @@
1
1
  import { QuoteInvoiceBE } from '../type';
2
+ type PrismaClient = any;
2
3
  interface PostQuotesInvoicesReportArgs {
3
- include: {
4
+ include?: {
4
5
  [key: string]: any;
5
6
  };
6
- orderBy: {
7
+ orderBy?: {
7
8
  [key: string]: any;
8
9
  };
9
- prisma: any;
10
- queryWhere: {
10
+ prisma: PrismaClient;
11
+ queryWhere?: {
11
12
  [key: string]: any;
12
13
  };
13
14
  }
14
- export declare const postQuotesInvoicesReport: ({ include, orderBy, prisma, queryWhere, }: PostQuotesInvoicesReportArgs) => Promise<Array<QuoteInvoiceBE>>;
15
+ /**
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]
20
+ */
21
+ export declare const postQuotesInvoicesReport: ({ include, orderBy, prisma, queryWhere, }: PostQuotesInvoicesReportArgs) => Promise<[number, Array<QuoteInvoiceBE>]>;
15
22
  export {};
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/no-explicit-any, no-restricted-globals, @typescript-eslint/array-type */
3
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -38,11 +37,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
38
37
  };
39
38
  Object.defineProperty(exports, "__esModule", { value: true });
40
39
  exports.postQuotesInvoicesReport = void 0;
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]
45
+ */
41
46
  var postQuotesInvoicesReport = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
42
47
  var quotesInvoices;
43
- var include = _b.include, orderBy = _b.orderBy, prisma = _b.prisma, queryWhere = _b.queryWhere;
44
- return __generator(this, function (_c) {
45
- switch (_c.label) {
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) {
46
51
  case 0: return [4 /*yield*/, prisma.$transaction([
47
52
  prisma.quoteInvoice.count({
48
53
  where: queryWhere,
@@ -54,7 +59,7 @@ var postQuotesInvoicesReport = function (_a) { return __awaiter(void 0, [_a], vo
54
59
  }),
55
60
  ])];
56
61
  case 1:
57
- quotesInvoices = _c.sent();
62
+ quotesInvoices = _f.sent();
58
63
  return [2 /*return*/, quotesInvoices];
59
64
  }
60
65
  });
@@ -1,27 +1,59 @@
1
1
  import { TaxBE } from '../type';
2
- interface GetTaxesArgs {
3
- prisma: any;
2
+ type PrismaClient = any;
3
+ interface ListTaxArgs {
4
+ currentPage?: number;
5
+ include?: any;
6
+ orderBy?: any;
7
+ pageLimit?: number;
8
+ prisma: PrismaClient;
9
+ queryWhere?: any;
4
10
  }
5
- interface GetTaxByIdArgs {
11
+ interface UnitTaxByIdArgs {
6
12
  id: string;
7
- prisma: any;
13
+ include?: any;
14
+ prisma: PrismaClient;
15
+ queryWhere?: any;
8
16
  }
9
- interface PostTaxArgs {
10
- description: string;
11
- enabled: string;
17
+ interface UpdateTaxArgs {
18
+ description?: string;
19
+ enabled: boolean;
12
20
  id: string;
13
- isDefault: string;
21
+ include?: any;
22
+ isDefault: boolean;
14
23
  preferenceId: string;
24
+ prisma: PrismaClient;
25
+ queryWhere?: any;
15
26
  taxName: string;
16
27
  taxRate: string;
17
- prisma: any;
18
28
  }
19
29
  interface DeleteTaxArgs {
20
- prisma: any;
21
30
  id: string;
31
+ include?: any;
32
+ prisma: PrismaClient;
33
+ queryWhere?: any;
22
34
  }
23
- export declare const getTaxes: ({ prisma, }: GetTaxesArgs) => Promise<Array<TaxBE>>;
24
- export declare const getTaxById: ({ prisma, id, }: GetTaxByIdArgs) => Promise<TaxBE>;
25
- export declare const postTax: ({ description, enabled, id, isDefault, preferenceId, prisma, taxName, taxRate, }: PostTaxArgs) => Promise<Array<TaxBE>>;
26
- export declare const deleteTax: ({ prisma, id, }: DeleteTaxArgs) => Promise<TaxBE>;
35
+ /**
36
+ * 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]
39
+ */
40
+ export declare const listTax: ({ currentPage, include, orderBy, pageLimit, prisma, queryWhere, }: ListTaxArgs) => Promise<[number, Array<TaxBE>]>;
41
+ /**
42
+ * Retrieves a single tax by its ID
43
+ * @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional filters
44
+ * @returns {Promise<TaxBE | null>} Tax or null if not found
45
+ */
46
+ export declare const unitTaxById: ({ id, include, prisma, queryWhere, }: UnitTaxByIdArgs) => Promise<TaxBE | null>;
47
+ /**
48
+ * Creates or updates a tax
49
+ * @param {UpdateTaxArgs} args - Object containing prisma client and tax data
50
+ * @returns {Promise<TaxBE>} Created or updated tax
51
+ */
52
+ export declare const updateTax: ({ description, enabled, id, include, isDefault, preferenceId, prisma, queryWhere, taxName, taxRate, }: UpdateTaxArgs) => Promise<TaxBE>;
53
+ /**
54
+ * Deletes a tax by ID
55
+ * @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional filters
56
+ * @returns {Promise<TaxBE>} Deleted tax
57
+ */
58
+ export declare const deleteTax: ({ id, include, prisma, queryWhere, }: DeleteTaxArgs) => Promise<TaxBE>;
27
59
  export {};