@react-pakistan/util-functions 1.23.16 → 1.23.18
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.
|
@@ -54,6 +54,6 @@ interface DeleteQuoteInvoiceArgs {
|
|
|
54
54
|
export declare const getQuotesInvoices: ({ prisma, }: GetQuotesInvoicesArgs) => Promise<Array<QuoteInvoiceBE>>;
|
|
55
55
|
export declare const getQuoteInvoiceById: ({ prisma, id, }: GetQuoteInvoiceByIdArgs) => Promise<QuoteInvoiceBE>;
|
|
56
56
|
export declare const postQuotesInvoices: ({ currentPage, pageLimit, prisma, queryWhere, }: PostQuotesInvoicesArgs) => Promise<Array<QuoteInvoiceBE>>;
|
|
57
|
-
export declare const postQuoteInvoice: ({ address, category, city, companyId, country,
|
|
57
|
+
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, taxValue, total, }: PostQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
|
|
58
58
|
export declare const deleteQuoteInvoice: ({ prisma, id, }: DeleteQuoteInvoiceArgs) => Promise<QuoteInvoiceBE>;
|
|
59
59
|
export {};
|
|
@@ -67,9 +67,10 @@ const postQuotesInvoices = (_c) => __awaiter(void 0, [_c], void 0, function* ({
|
|
|
67
67
|
return quotesInvoices;
|
|
68
68
|
});
|
|
69
69
|
exports.postQuotesInvoices = postQuotesInvoices;
|
|
70
|
-
const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ address, category, city, companyId, country,
|
|
70
|
+
const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ 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, taxValue, total, }) {
|
|
71
71
|
var _e;
|
|
72
72
|
let quoteInvoice;
|
|
73
|
+
// Parent create flow
|
|
73
74
|
if (mode === 'Create') {
|
|
74
75
|
let mappedServices;
|
|
75
76
|
if (services === null || services === void 0 ? void 0 : services.length) {
|
|
@@ -79,11 +80,10 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
79
80
|
return itemToReturn;
|
|
80
81
|
});
|
|
81
82
|
}
|
|
83
|
+
// Parent customer or company flow
|
|
82
84
|
if (customerId || companyId) {
|
|
83
85
|
quoteInvoice = yield prisma.quoteInvoice.create({
|
|
84
|
-
data: Object.assign({
|
|
85
|
-
// id,
|
|
86
|
-
category,
|
|
86
|
+
data: Object.assign({ category,
|
|
87
87
|
companyId,
|
|
88
88
|
currency,
|
|
89
89
|
customerId,
|
|
@@ -91,14 +91,13 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
91
91
|
discount,
|
|
92
92
|
discountUnit,
|
|
93
93
|
expiryDate,
|
|
94
|
+
invoiceStatus,
|
|
94
95
|
note,
|
|
95
|
-
ref,
|
|
96
96
|
quoteStatus,
|
|
97
|
-
|
|
97
|
+
ref,
|
|
98
98
|
subTotal,
|
|
99
99
|
taxValue,
|
|
100
|
-
total,
|
|
101
|
-
createdAt }, (mappedServices && {
|
|
100
|
+
total }, (mappedServices && {
|
|
102
101
|
services: {
|
|
103
102
|
createMany: {
|
|
104
103
|
data: mappedServices,
|
|
@@ -119,11 +118,11 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
119
118
|
},
|
|
120
119
|
});
|
|
121
120
|
})));
|
|
121
|
+
// Parent customer creation flow
|
|
122
122
|
}
|
|
123
123
|
else {
|
|
124
124
|
quoteInvoice = yield prisma.quoteInvoice.create({
|
|
125
125
|
data: {
|
|
126
|
-
// id,
|
|
127
126
|
category,
|
|
128
127
|
companyId,
|
|
129
128
|
currency,
|
|
@@ -132,14 +131,13 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
132
131
|
discount,
|
|
133
132
|
discountUnit,
|
|
134
133
|
expiryDate,
|
|
134
|
+
invoiceStatus,
|
|
135
135
|
note,
|
|
136
|
-
ref,
|
|
137
136
|
quoteStatus,
|
|
138
|
-
|
|
137
|
+
ref,
|
|
139
138
|
subTotal,
|
|
140
139
|
taxValue,
|
|
141
140
|
total,
|
|
142
|
-
createdAt,
|
|
143
141
|
customer: {
|
|
144
142
|
create: {
|
|
145
143
|
address,
|
|
@@ -160,6 +158,7 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
160
158
|
});
|
|
161
159
|
}
|
|
162
160
|
}
|
|
161
|
+
// Parent edit flow
|
|
163
162
|
if (mode === 'Edit') {
|
|
164
163
|
try {
|
|
165
164
|
const foundQuoteInvoice = yield prisma.quoteInvoice.findUnique({
|
|
@@ -173,24 +172,28 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
173
172
|
delete toReturn.mode;
|
|
174
173
|
return (Object.assign(Object.assign({}, toReturn), { quoteInvoiceId: id }));
|
|
175
174
|
});
|
|
176
|
-
filteredEditServices === null || filteredEditServices === void 0 ? void 0 : filteredEditServices.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
175
|
+
if (filteredEditServices === null || filteredEditServices === void 0 ? void 0 : filteredEditServices.length) {
|
|
176
|
+
filteredEditServices === null || filteredEditServices === void 0 ? void 0 : filteredEditServices.map((item) => __awaiter(void 0, void 0, void 0, function* () {
|
|
177
|
+
yield prisma.stellarService.update({
|
|
178
|
+
where: {
|
|
179
|
+
id: item.id,
|
|
180
|
+
},
|
|
181
|
+
data: {
|
|
182
|
+
description: item.description,
|
|
183
|
+
name: item.name,
|
|
184
|
+
price: item.price,
|
|
185
|
+
quantity: item.quantity,
|
|
186
|
+
quoteInvoiceId: item.quoteInvoiceId,
|
|
187
|
+
total: item.total,
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}));
|
|
191
|
+
}
|
|
192
|
+
if (filteredCreateServices === null || filteredCreateServices === void 0 ? void 0 : filteredCreateServices.length) {
|
|
193
|
+
yield prisma.stellarService.createMany({
|
|
194
|
+
data: filteredCreateServices,
|
|
189
195
|
});
|
|
190
|
-
}
|
|
191
|
-
yield prisma.stellarService.createMany({
|
|
192
|
-
data: filteredCreateServices,
|
|
193
|
-
});
|
|
196
|
+
}
|
|
194
197
|
quoteInvoice = yield prisma.quoteInvoice.update({
|
|
195
198
|
where: {
|
|
196
199
|
id,
|
|
@@ -201,41 +204,19 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
201
204
|
customerId,
|
|
202
205
|
date,
|
|
203
206
|
expiryDate,
|
|
207
|
+
invoiceStatus,
|
|
204
208
|
note,
|
|
205
|
-
ref,
|
|
206
209
|
quoteStatus,
|
|
207
|
-
|
|
210
|
+
ref,
|
|
208
211
|
subTotal,
|
|
209
212
|
taxValue,
|
|
210
213
|
total }),
|
|
211
214
|
});
|
|
212
215
|
}
|
|
213
216
|
catch (err) {
|
|
214
|
-
|
|
217
|
+
console.log('err lib', err);
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
|
-
// if (quoteInvoice) {
|
|
218
|
-
// console.log('=>>>>>', quoteInvoice);
|
|
219
|
-
// // products.map(async (product) => {
|
|
220
|
-
// await prisma.quoteInvoice.update({
|
|
221
|
-
// where: {
|
|
222
|
-
// id: quoteInvoice.id,
|
|
223
|
-
// },
|
|
224
|
-
// data: {
|
|
225
|
-
// products: {
|
|
226
|
-
// connect: products,
|
|
227
|
-
// },
|
|
228
|
-
// // quoteInvoiceId: quoteInvoice?.id,
|
|
229
|
-
// // productId: product.id,
|
|
230
|
-
// // productQuantity: product.productQuantity,
|
|
231
|
-
// },
|
|
232
|
-
// include: {
|
|
233
|
-
// product: true,
|
|
234
|
-
// quoteInvoice: true,
|
|
235
|
-
// },
|
|
236
|
-
// // });
|
|
237
|
-
// });
|
|
238
|
-
// }
|
|
239
220
|
return quoteInvoice;
|
|
240
221
|
});
|
|
241
222
|
exports.postQuoteInvoice = postQuoteInvoice;
|