feat: generate quotation code
This commit is contained in:
parent
f88e149318
commit
88559480b7
1 changed files with 16 additions and 1 deletions
|
|
@ -391,11 +391,26 @@ export class QuotationController extends Controller {
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
const currentMonth = new Date().getMonth() + 1;
|
||||||
|
const currentDate = new Date().getDate();
|
||||||
|
|
||||||
|
const lastQuotation = await tx.runningNo.upsert({
|
||||||
|
where: {
|
||||||
|
key: `QUOTATION_${currentYear.toString().padStart(2, "0")}${currentMonth.toString().padStart(2, "0")}${currentDate.toString().padStart(2, "0")}`,
|
||||||
|
},
|
||||||
|
create: {
|
||||||
|
key: `QUOTATION_${currentYear.toString().padStart(2, "0")}${currentMonth.toString().padStart(2, "0")}${currentDate.toString().padStart(2, "0")}`,
|
||||||
|
value: 1,
|
||||||
|
},
|
||||||
|
update: { value: { increment: 1 } },
|
||||||
|
});
|
||||||
|
|
||||||
const quotation = await tx.quotation.create({
|
const quotation = await tx.quotation.create({
|
||||||
data: {
|
data: {
|
||||||
...rest,
|
...rest,
|
||||||
statusOrder: +(rest.status === "INACTIVE"),
|
statusOrder: +(rest.status === "INACTIVE"),
|
||||||
code: "",
|
code: `${currentYear.toString().padStart(2, "0")}${currentMonth.toString().padStart(2, "0")}${currentDate.toString().padStart(2, "0")}${lastQuotation.value.toString().padStart(4, "0")}`,
|
||||||
worker: {
|
worker: {
|
||||||
createMany: {
|
createMany: {
|
||||||
data: sortedEmployeeId.map((v, i) => ({
|
data: sortedEmployeeId.map((v, i) => ({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue