@react-pakistan/util-functions 1.23.15 → 1.23.17
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,10 +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
|
-
category,
|
|
86
|
+
data: Object.assign({ category,
|
|
86
87
|
companyId,
|
|
87
88
|
currency,
|
|
88
89
|
customerId,
|
|
@@ -90,14 +91,13 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
90
91
|
discount,
|
|
91
92
|
discountUnit,
|
|
92
93
|
expiryDate,
|
|
94
|
+
invoiceStatus,
|
|
93
95
|
note,
|
|
94
|
-
ref,
|
|
95
96
|
quoteStatus,
|
|
96
|
-
|
|
97
|
+
ref,
|
|
97
98
|
subTotal,
|
|
98
99
|
taxValue,
|
|
99
|
-
total,
|
|
100
|
-
createdAt }, (mappedServices && {
|
|
100
|
+
total }, (mappedServices && {
|
|
101
101
|
services: {
|
|
102
102
|
createMany: {
|
|
103
103
|
data: mappedServices,
|
|
@@ -118,11 +118,11 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
118
118
|
},
|
|
119
119
|
});
|
|
120
120
|
})));
|
|
121
|
+
// Parent customer creation flow
|
|
121
122
|
}
|
|
122
123
|
else {
|
|
123
124
|
quoteInvoice = yield prisma.quoteInvoice.create({
|
|
124
125
|
data: {
|
|
125
|
-
id,
|
|
126
126
|
category,
|
|
127
127
|
companyId,
|
|
128
128
|
currency,
|
|
@@ -131,14 +131,13 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
131
131
|
discount,
|
|
132
132
|
discountUnit,
|
|
133
133
|
expiryDate,
|
|
134
|
+
invoiceStatus,
|
|
134
135
|
note,
|
|
135
|
-
ref,
|
|
136
136
|
quoteStatus,
|
|
137
|
-
|
|
137
|
+
ref,
|
|
138
138
|
subTotal,
|
|
139
139
|
taxValue,
|
|
140
140
|
total,
|
|
141
|
-
createdAt,
|
|
142
141
|
customer: {
|
|
143
142
|
create: {
|
|
144
143
|
address,
|
|
@@ -159,6 +158,7 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
159
158
|
});
|
|
160
159
|
}
|
|
161
160
|
}
|
|
161
|
+
// Parent edit flow
|
|
162
162
|
if (mode === 'Edit') {
|
|
163
163
|
try {
|
|
164
164
|
const foundQuoteInvoice = yield prisma.quoteInvoice.findUnique({
|
|
@@ -200,41 +200,19 @@ const postQuoteInvoice = (_d) => __awaiter(void 0, [_d], void 0, function* ({ ad
|
|
|
200
200
|
customerId,
|
|
201
201
|
date,
|
|
202
202
|
expiryDate,
|
|
203
|
+
invoiceStatus,
|
|
203
204
|
note,
|
|
204
|
-
ref,
|
|
205
205
|
quoteStatus,
|
|
206
|
-
|
|
206
|
+
ref,
|
|
207
207
|
subTotal,
|
|
208
208
|
taxValue,
|
|
209
209
|
total }),
|
|
210
210
|
});
|
|
211
211
|
}
|
|
212
212
|
catch (err) {
|
|
213
|
-
|
|
213
|
+
console.log('err lib', err);
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
|
-
// if (quoteInvoice) {
|
|
217
|
-
// console.log('=>>>>>', quoteInvoice);
|
|
218
|
-
// // products.map(async (product) => {
|
|
219
|
-
// await prisma.quoteInvoice.update({
|
|
220
|
-
// where: {
|
|
221
|
-
// id: quoteInvoice.id,
|
|
222
|
-
// },
|
|
223
|
-
// data: {
|
|
224
|
-
// products: {
|
|
225
|
-
// connect: products,
|
|
226
|
-
// },
|
|
227
|
-
// // quoteInvoiceId: quoteInvoice?.id,
|
|
228
|
-
// // productId: product.id,
|
|
229
|
-
// // productQuantity: product.productQuantity,
|
|
230
|
-
// },
|
|
231
|
-
// include: {
|
|
232
|
-
// product: true,
|
|
233
|
-
// quoteInvoice: true,
|
|
234
|
-
// },
|
|
235
|
-
// // });
|
|
236
|
-
// });
|
|
237
|
-
// }
|
|
238
216
|
return quoteInvoice;
|
|
239
217
|
});
|
|
240
218
|
exports.postQuoteInvoice = postQuoteInvoice;
|