feat: add more notification
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 9s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 9s
This commit is contained in:
parent
c2b4602290
commit
f88b25a52a
2 changed files with 35 additions and 1 deletions
|
|
@ -219,6 +219,16 @@ export class InvoiceController extends Controller {
|
||||||
quotationStatus: "PaymentInProcess",
|
quotationStatus: "PaymentInProcess",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await tx.notification.create({
|
||||||
|
data: {
|
||||||
|
title: "ใบแจ้งหนี้ใหม่ / New Invoice",
|
||||||
|
detail: "รหัส / code : " + record.code,
|
||||||
|
registeredBranchId: record.registeredBranchId,
|
||||||
|
groupReceiver: { create: { name: "accountant" } },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return await tx.invoice.create({
|
return await tx.invoice.create({
|
||||||
data: {
|
data: {
|
||||||
quotationId: body.quotationId,
|
quotationId: body.quotationId,
|
||||||
|
|
|
||||||
|
|
@ -679,6 +679,7 @@ export class QuotationController extends Controller {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
productServiceList: true,
|
||||||
},
|
},
|
||||||
where: { id: quotationId, isDebitNote: false },
|
where: { id: quotationId, isDebitNote: false },
|
||||||
});
|
});
|
||||||
|
|
@ -850,7 +851,20 @@ export class QuotationController extends Controller {
|
||||||
finalPrice: 0,
|
finalPrice: 0,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
const changed = list
|
||||||
|
? record.productServiceList.some(
|
||||||
|
(lhs) =>
|
||||||
|
!list?.find((rhs) => {
|
||||||
|
return (
|
||||||
|
lhs.serviceId === rhs.serviceId &&
|
||||||
|
lhs.workId === rhs.workId &&
|
||||||
|
lhs.productId === rhs.productId &&
|
||||||
|
lhs.discount === rhs.discount &&
|
||||||
|
lhs.pricePerUnit === rhs.pricePerUnit
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
: false;
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
tx.service.updateMany({
|
tx.service.updateMany({
|
||||||
where: { id: { in: ids.service }, status: Status.CREATED },
|
where: { id: { in: ids.service }, status: Status.CREATED },
|
||||||
|
|
@ -860,6 +874,16 @@ export class QuotationController extends Controller {
|
||||||
where: { id: { in: ids.product }, status: Status.CREATED },
|
where: { id: { in: ids.product }, status: Status.CREATED },
|
||||||
data: { status: Status.ACTIVE },
|
data: { status: Status.ACTIVE },
|
||||||
}),
|
}),
|
||||||
|
changed &&
|
||||||
|
tx.notification.create({
|
||||||
|
data: {
|
||||||
|
title: "ใบเสนอราคามัการเปลี่ยนแปลง / Quotation Detail Changes",
|
||||||
|
detail:
|
||||||
|
"รหัส / code : " + record.code + " มีการเปลี่ยนแปลงของสินค้า / Product Updated",
|
||||||
|
registeredBranchId: record.registeredBranchId,
|
||||||
|
groupReceiver: { create: [{ name: "sale" }, { name: "head_of_sale" }] },
|
||||||
|
},
|
||||||
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return await tx.quotation.update({
|
return await tx.quotation.update({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue