fix: do not create if not select any product
This commit is contained in:
parent
5ca704f5ce
commit
86d21e4a23
1 changed files with 21 additions and 11 deletions
|
|
@ -196,7 +196,16 @@ export class QuotationPayment extends Controller {
|
||||||
update: { value: { increment: quotation.worker.length } },
|
update: { value: { increment: quotation.worker.length } },
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
create: quotation.worker.map((v, i) => ({
|
create: quotation.worker.flatMap((v, i) => {
|
||||||
|
const productEmployee = quotation.productServiceList.flatMap((item) =>
|
||||||
|
item.worker.findIndex((w) => w.employeeId === v.employeeId) !== -1
|
||||||
|
? { productServiceId: item.id }
|
||||||
|
: [],
|
||||||
|
);
|
||||||
|
|
||||||
|
if (productEmployee.length <= 0) return [];
|
||||||
|
|
||||||
|
return {
|
||||||
code: `TR${year}${month}${(lastRequest.value - quotation.worker.length + i + 1).toString().padStart(6, "0")}`,
|
code: `TR${year}${month}${(lastRequest.value - quotation.worker.length + i + 1).toString().padStart(6, "0")}`,
|
||||||
employeeId: v.employeeId,
|
employeeId: v.employeeId,
|
||||||
requestWork: {
|
requestWork: {
|
||||||
|
|
@ -206,7 +215,8 @@ export class QuotationPayment extends Controller {
|
||||||
: [],
|
: [],
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
})),
|
};
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
})(),
|
})(),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue