@react-pakistan/util-functions 1.24.18 → 1.24.19
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 (
|
|
137
|
-
switch (
|
|
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;
|
|
@@ -161,8 +161,8 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
161
161
|
},
|
|
162
162
|
})];
|
|
163
163
|
case 1:
|
|
164
|
-
quoteInvoice =
|
|
165
|
-
return [4 /*yield*/, (products === null || products === void 0 ? void 0 : products.forEach(function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
164
|
+
quoteInvoice = _e.sent();
|
|
165
|
+
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
166
|
var _id = _b.id, productQuantity = _b.productQuantity;
|
|
167
167
|
return __generator(this, function (_c) {
|
|
168
168
|
switch (_c.label) {
|
|
@@ -180,7 +180,7 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
180
180
|
});
|
|
181
181
|
}); }))];
|
|
182
182
|
case 2:
|
|
183
|
-
|
|
183
|
+
_e.sent();
|
|
184
184
|
return [3 /*break*/, 5];
|
|
185
185
|
case 3: return [4 /*yield*/, prisma.quoteInvoice.create({
|
|
186
186
|
data: {
|
|
@@ -218,28 +218,28 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
218
218
|
},
|
|
219
219
|
})];
|
|
220
220
|
case 4:
|
|
221
|
-
quoteInvoice =
|
|
222
|
-
|
|
221
|
+
quoteInvoice = _e.sent();
|
|
222
|
+
_e.label = 5;
|
|
223
223
|
case 5:
|
|
224
224
|
if (!(mode === 'Edit')) return [3 /*break*/, 12];
|
|
225
|
-
|
|
225
|
+
_e.label = 6;
|
|
226
226
|
case 6:
|
|
227
|
-
|
|
227
|
+
_e.trys.push([6, 11, , 12]);
|
|
228
228
|
return [4 /*yield*/, prisma.quoteInvoice.findUnique({
|
|
229
229
|
where: {
|
|
230
230
|
id: id,
|
|
231
231
|
},
|
|
232
232
|
})];
|
|
233
233
|
case 7:
|
|
234
|
-
foundQuoteInvoice =
|
|
234
|
+
foundQuoteInvoice = _e.sent();
|
|
235
235
|
filteredEditServices = services === null || services === void 0 ? void 0 : services.filter(function (_a) {
|
|
236
236
|
var _mode = _a.mode;
|
|
237
237
|
return _mode === 'Edit';
|
|
238
238
|
});
|
|
239
|
-
filteredCreateServices = (
|
|
239
|
+
filteredCreateServices = (_d = services === null || services === void 0 ? void 0 : services.filter(function (_a) {
|
|
240
240
|
var __mode = _a.mode;
|
|
241
241
|
return __mode === 'Create';
|
|
242
|
-
})) === null ||
|
|
242
|
+
})) === null || _d === void 0 ? void 0 : _d.map(function (item) {
|
|
243
243
|
var toReturn = __assign({}, item);
|
|
244
244
|
delete toReturn.mode;
|
|
245
245
|
return (__assign(__assign({}, toReturn), { quoteInvoiceId: id }));
|
|
@@ -273,8 +273,8 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
273
273
|
data: filteredCreateServices,
|
|
274
274
|
})];
|
|
275
275
|
case 8:
|
|
276
|
-
|
|
277
|
-
|
|
276
|
+
_e.sent();
|
|
277
|
+
_e.label = 9;
|
|
278
278
|
case 9: return [4 /*yield*/, prisma.quoteInvoice.update({
|
|
279
279
|
where: {
|
|
280
280
|
id: id,
|
|
@@ -282,10 +282,10 @@ var postQuoteInvoice = function (_a) { return __awaiter(void 0, [_a], void 0, fu
|
|
|
282
282
|
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
283
|
})];
|
|
284
284
|
case 10:
|
|
285
|
-
quoteInvoice =
|
|
285
|
+
quoteInvoice = _e.sent();
|
|
286
286
|
return [3 /*break*/, 12];
|
|
287
287
|
case 11:
|
|
288
|
-
err_1 =
|
|
288
|
+
err_1 = _e.sent();
|
|
289
289
|
console.log('err lib', err_1);
|
|
290
290
|
return [3 /*break*/, 12];
|
|
291
291
|
case 12: return [2 /*return*/, quoteInvoice];
|