feat: detect if agent price

This commit is contained in:
Methapon Metanipat 2024-10-04 13:31:29 +07:00
parent 66f3188f42
commit 3857de8d2b

View file

@ -62,6 +62,8 @@ type QuotationCreate = {
urgent?: boolean;
agentPrice?: boolean;
productServiceList: {
serviceId?: string;
workId?: string;
@ -325,7 +327,9 @@ export class QuotationController extends Controller {
productId: v.productId,
workId: v.workId,
serviceId: v.serviceId,
pricePerUnit: v.pricePerUnit || product.find((p) => p.id === v.productId)?.price || 0,
pricePerUnit:
product.find((p) => p.id === v.productId)?.[body.agentPrice ? "agentPrice" : "price"] ||
0,
amount: v.amount,
discount: v.discount || 0,
vat: v.vat || VAT_DEFAULT,
@ -518,7 +522,9 @@ export class QuotationController extends Controller {
productId: v.productId,
workId: v.workId,
serviceId: v.serviceId,
pricePerUnit: v.pricePerUnit || product.find((p) => p.id === v.productId)?.price || 0,
pricePerUnit:
product.find((p) => p.id === v.productId)?.[record.agentPrice ? "agentPrice" : "price"] ||
0,
amount: v.amount,
discount: v.discount || 0,
vat: v.vat || VAT_DEFAULT,