@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
@@ -50,12 +50,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
50
50
  exports.deleteTax = exports.updateTax = exports.unitTaxById = exports.listTax = void 0;
51
51
  /**
52
52
  * Retrieves a paginated list of taxes
53
- * @param {ListTaxArgs} args - Object containing prisma client, pagination, and filter options
54
- * @returns {Promise<[number, Array<TaxBE>]>} Tuple of [total count, tax array]
53
+ * @param {ListTaxArgs} args - Object containing prisma client, pagination, filtering, and ordering options
54
+ * @returns {Promise<[number, Array<TaxBE>]>} Tuple containing total count and array of taxes
55
55
  */
56
56
  var listTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
57
- var skip, _c, count, data;
58
- var _d = _b.currentPage, currentPage = _d === void 0 ? 1 : _d, _e = _b.include, include = _e === void 0 ? {} : _e, _f = _b.orderBy, orderBy = _f === void 0 ? { createdAt: 'desc' } : _f, _g = _b.pageLimit, pageLimit = _g === void 0 ? 10 : _g, prisma = _b.prisma, _h = _b.queryWhere, queryWhere = _h === void 0 ? {} : _h;
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.orderByColumn, orderByColumn = _f === void 0 ? 'createdAt' : _f, _g = _b.orderByDirection, orderByDirection = _g === void 0 ? 'desc' : _g, _h = _b.pageLimit, pageLimit = _h === void 0 ? 10 : _h, prisma = _b.prisma;
59
60
  return __generator(this, function (_j) {
60
61
  switch (_j.label) {
61
62
  case 0:
@@ -65,49 +66,55 @@ var listTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_
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
+ orderBy = (_d = {},
71
+ _d[orderByColumn] = orderByDirection,
72
+ _d);
68
73
  skip = (currentPage - 1) * pageLimit;
69
- return [4 /*yield*/, Promise.all([
74
+ where = {};
75
+ return [4 /*yield*/, prisma.$transaction([
70
76
  prisma.tax.count({
71
- where: queryWhere,
77
+ where: where,
72
78
  }),
73
79
  prisma.tax.findMany({
74
80
  include: include,
75
81
  orderBy: orderBy,
76
82
  skip: skip,
77
83
  take: pageLimit,
78
- where: queryWhere,
84
+ where: where,
79
85
  }),
80
86
  ])];
81
87
  case 1:
82
- _c = _j.sent(), count = _c[0], data = _c[1];
83
- return [2 /*return*/, [count, data]];
88
+ _c = _j.sent(), count = _c[0], items = _c[1];
89
+ return [2 /*return*/, [count, items]];
84
90
  }
85
91
  });
86
92
  }); };
87
93
  exports.listTax = listTax;
88
94
  /**
89
95
  * Retrieves a single tax by its ID
90
- * @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional filters
96
+ * @param {UnitTaxByIdArgs} args - Object containing prisma client, tax ID, and optional query parameters
91
97
  * @returns {Promise<TaxBE | null>} Tax or null if not found
92
98
  */
93
99
  var unitTaxById = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
94
- var tax;
95
- var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
96
- return __generator(this, function (_e) {
97
- switch (_e.label) {
100
+ var include, where, tax;
101
+ var id = _b.id, prisma = _b.prisma;
102
+ return __generator(this, function (_c) {
103
+ switch (_c.label) {
98
104
  case 0:
99
105
  if (!id) {
100
106
  throw new Error('Tax ID is required');
101
107
  }
102
- if (queryWhere.id && queryWhere.id !== id) {
103
- throw new Error('ID mismatch between parameter and queryWhere');
104
- }
108
+ include = {};
109
+ where = {
110
+ id: id,
111
+ };
105
112
  return [4 /*yield*/, prisma.tax.findUnique({
106
113
  include: include,
107
- where: __assign({ id: id }, queryWhere),
114
+ where: where,
108
115
  })];
109
116
  case 1:
110
- tax = _e.sent();
117
+ tax = _c.sent();
111
118
  return [2 /*return*/, tax];
112
119
  }
113
120
  });
@@ -115,14 +122,14 @@ var unitTaxById = function (_a) { return __awaiter(void 0, [_a], void 0, functio
115
122
  exports.unitTaxById = unitTaxById;
116
123
  /**
117
124
  * Creates or updates a tax
118
- * @param {UpdateTaxArgs} args - Object containing prisma client and tax data
125
+ * @param {UpdateTaxArgs} args - Object containing prisma client, tax data, and optional query parameters
119
126
  * @returns {Promise<TaxBE>} Created or updated tax
120
127
  */
121
128
  var updateTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
122
- var taxData, tax;
123
- var description = _b.description, enabled = _b.enabled, id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, isDefault = _b.isDefault, preferenceId = _b.preferenceId, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d, taxName = _b.taxName, taxRate = _b.taxRate;
124
- return __generator(this, function (_e) {
125
- switch (_e.label) {
129
+ var taxData, include, where, tax;
130
+ var description = _b.description, enabled = _b.enabled, id = _b.id, isDefault = _b.isDefault, preferenceId = _b.preferenceId, prisma = _b.prisma, taxName = _b.taxName, taxRate = _b.taxRate;
131
+ return __generator(this, function (_c) {
132
+ switch (_c.label) {
126
133
  case 0:
127
134
  if (!id) {
128
135
  throw new Error('Tax ID is required');
@@ -142,9 +149,6 @@ var updateTax = function (_a) { return __awaiter(void 0, [_a], void 0, function
142
149
  if (typeof isDefault !== 'boolean') {
143
150
  throw new Error('Is default must be a boolean');
144
151
  }
145
- if (queryWhere.id && queryWhere.id !== id) {
146
- throw new Error('ID mismatch between parameter and queryWhere');
147
- }
148
152
  taxData = {
149
153
  description: description || null,
150
154
  enabled: enabled,
@@ -153,14 +157,18 @@ var updateTax = function (_a) { return __awaiter(void 0, [_a], void 0, function
153
157
  taxName: taxName,
154
158
  taxRate: taxRate,
155
159
  };
160
+ include = {};
161
+ where = {
162
+ id: id,
163
+ };
156
164
  return [4 /*yield*/, prisma.tax.upsert({
165
+ create: __assign({ id: id }, taxData),
157
166
  include: include,
158
- where: __assign({ id: id }, queryWhere),
159
167
  update: taxData,
160
- create: __assign({ id: id }, taxData),
168
+ where: where,
161
169
  })];
162
170
  case 1:
163
- tax = _e.sent();
171
+ tax = _c.sent();
164
172
  return [2 /*return*/, tax];
165
173
  }
166
174
  });
@@ -168,27 +176,28 @@ var updateTax = function (_a) { return __awaiter(void 0, [_a], void 0, function
168
176
  exports.updateTax = updateTax;
169
177
  /**
170
178
  * Deletes a tax by ID
171
- * @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional filters
179
+ * @param {DeleteTaxArgs} args - Object containing prisma client, tax ID, and optional query parameters
172
180
  * @returns {Promise<TaxBE>} Deleted tax
173
181
  */
174
182
  var deleteTax = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
175
- var tax;
176
- var id = _b.id, _c = _b.include, include = _c === void 0 ? {} : _c, prisma = _b.prisma, _d = _b.queryWhere, queryWhere = _d === void 0 ? {} : _d;
177
- return __generator(this, function (_e) {
178
- switch (_e.label) {
183
+ var include, where, tax;
184
+ var id = _b.id, prisma = _b.prisma;
185
+ return __generator(this, function (_c) {
186
+ switch (_c.label) {
179
187
  case 0:
180
188
  if (!id) {
181
189
  throw new Error('Tax ID is required');
182
190
  }
183
- if (queryWhere.id && queryWhere.id !== id) {
184
- throw new Error('ID mismatch between parameter and queryWhere');
185
- }
191
+ include = {};
192
+ where = {
193
+ id: id,
194
+ };
186
195
  return [4 /*yield*/, prisma.tax.delete({
187
196
  include: include,
188
- where: __assign({ id: id }, queryWhere),
197
+ where: where,
189
198
  })];
190
199
  case 1:
191
- tax = _e.sent();
200
+ tax = _c.sent();
192
201
  return [2 /*return*/, tax];
193
202
  }
194
203
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.24.67",
3
+ "version": "1.24.69",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {