@react-pakistan/util-functions 1.24.18 → 1.24.20

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.
@@ -131,10 +131,10 @@ var postQuotesInvoices = function (_a) { return __awaiter(void 0, [_a], void 0,
131
131
  exports.postQuotesInvoices = postQuotesInvoices;
132
132
  var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
133
133
  var quoteInvoice, mappedServices, foundQuoteInvoice, filteredEditServices, filteredCreateServices, err_1;
134
- var _c;
134
+ var _c, _d;
135
135
  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, taxValue = _b.taxValue, total = _b.total;
136
- return __generator(this, function (_d) {
137
- switch (_d.label) {
136
+ return __generator(this, function (_e) {
137
+ switch (_e.label) {
138
138
  case 0:
139
139
  if (!(mode === 'Create')) return [3 /*break*/, 5];
140
140
  mappedServices = void 0;
@@ -148,7 +148,11 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
148
148
  }
149
149
  if (!(customerId || companyId)) return [3 /*break*/, 3];
150
150
  return [4 /*yield*/, prisma.quoteInvoice.create({
151
- data: __assign({ category: category, companyId: companyId, currency: currency, customerId: customerId, date: date, discount: discount, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxValue: taxValue, total: total }, (mappedServices && {
151
+ data: __assign(__assign(__assign(__assign(__assign({ category: category }, (companyId && {
152
+ companyId: companyId,
153
+ })), { currency: currency }), (customerId && {
154
+ customerId: customerId,
155
+ })), { date: date, discount: discount, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxValue: taxValue, total: total }), (mappedServices && {
152
156
  services: {
153
157
  createMany: {
154
158
  data: mappedServices,
@@ -161,8 +165,8 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
161
165
  },
162
166
  })];
163
167
  case 1:
164
- quoteInvoice = _d.sent();
165
- return [4 /*yield*/, (products === null || products === void 0 ? void 0 : products.forEach(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
168
+ quoteInvoice = _e.sent();
169
+ return [4 /*yield*/, ((_c = products === null || products === void 0 ? void 0 : products.filter(function (product) { return product.productId; })) === null || _c === void 0 ? void 0 : _c.forEach(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
166
170
  var _id = _b.id, productQuantity = _b.productQuantity;
167
171
  return __generator(this, function (_c) {
168
172
  switch (_c.label) {
@@ -180,26 +184,14 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
180
184
  });
181
185
  }); }))];
182
186
  case 2:
183
- _d.sent();
187
+ _e.sent();
184
188
  return [3 /*break*/, 5];
185
189
  case 3: return [4 /*yield*/, prisma.quoteInvoice.create({
186
- data: {
187
- category: category,
190
+ data: __assign(__assign(__assign(__assign({ category: category }, (companyId && {
188
191
  companyId: companyId,
189
- currency: currency,
192
+ })), { currency: currency }), (customerId && {
190
193
  customerId: customerId,
191
- date: date,
192
- discount: discount,
193
- discountUnit: discountUnit,
194
- expiryDate: expiryDate,
195
- invoiceStatus: invoiceStatus,
196
- note: note,
197
- quoteStatus: quoteStatus,
198
- ref: ref,
199
- subTotal: subTotal,
200
- taxValue: taxValue,
201
- total: total,
202
- customer: {
194
+ })), { date: date, discount: discount, discountUnit: discountUnit, expiryDate: expiryDate, invoiceStatus: invoiceStatus, note: note, quoteStatus: quoteStatus, ref: ref, subTotal: subTotal, taxValue: taxValue, total: total, customer: {
203
195
  create: {
204
196
  address: address,
205
197
  city: city,
@@ -209,37 +201,35 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
209
201
  lastName: lastName,
210
202
  phone: phone,
211
203
  },
212
- },
213
- services: {
204
+ }, services: {
214
205
  createMany: {
215
206
  data: mappedServices,
216
207
  },
217
- },
218
- },
208
+ } }),
219
209
  })];
220
210
  case 4:
221
- quoteInvoice = _d.sent();
222
- _d.label = 5;
211
+ quoteInvoice = _e.sent();
212
+ _e.label = 5;
223
213
  case 5:
224
214
  if (!(mode === 'Edit')) return [3 /*break*/, 12];
225
- _d.label = 6;
215
+ _e.label = 6;
226
216
  case 6:
227
- _d.trys.push([6, 11, , 12]);
217
+ _e.trys.push([6, 11, , 12]);
228
218
  return [4 /*yield*/, prisma.quoteInvoice.findUnique({
229
219
  where: {
230
220
  id: id,
231
221
  },
232
222
  })];
233
223
  case 7:
234
- foundQuoteInvoice = _d.sent();
224
+ foundQuoteInvoice = _e.sent();
235
225
  filteredEditServices = services === null || services === void 0 ? void 0 : services.filter(function (_a) {
236
226
  var _mode = _a.mode;
237
227
  return _mode === 'Edit';
238
228
  });
239
- filteredCreateServices = (_c = services === null || services === void 0 ? void 0 : services.filter(function (_a) {
229
+ filteredCreateServices = (_d = services === null || services === void 0 ? void 0 : services.filter(function (_a) {
240
230
  var __mode = _a.mode;
241
231
  return __mode === 'Create';
242
- })) === null || _c === void 0 ? void 0 : _c.map(function (item) {
232
+ })) === null || _d === void 0 ? void 0 : _d.map(function (item) {
243
233
  var toReturn = __assign({}, item);
244
234
  delete toReturn.mode;
245
235
  return (__assign(__assign({}, toReturn), { quoteInvoiceId: id }));
@@ -273,8 +263,8 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
273
263
  data: filteredCreateServices,
274
264
  })];
275
265
  case 8:
276
- _d.sent();
277
- _d.label = 9;
266
+ _e.sent();
267
+ _e.label = 9;
278
268
  case 9: return [4 /*yield*/, prisma.quoteInvoice.update({
279
269
  where: {
280
270
  id: id,
@@ -282,10 +272,10 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
282
272
  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, taxValue: taxValue, total: total }),
283
273
  })];
284
274
  case 10:
285
- quoteInvoice = _d.sent();
275
+ quoteInvoice = _e.sent();
286
276
  return [3 /*break*/, 12];
287
277
  case 11:
288
- err_1 = _d.sent();
278
+ err_1 = _e.sent();
289
279
  console.log('err lib', err_1);
290
280
  return [3 /*break*/, 12];
291
281
  case 12: return [2 /*return*/, quoteInvoice];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-pakistan/util-functions",
3
- "version": "1.24.18",
3
+ "version": "1.24.20",
4
4
  "description": "A library of all util functions",
5
5
  "main": "index.js",
6
6
  "scripts": {