diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 2cc73fe..8ad88b5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1103,10 +1103,16 @@ model Product { price Float agentPrice Float serviceCharge Float - vatIncluded Boolean? expenseType String? - calcVat Boolean @default(true) + vatIncluded Boolean @default(true) + calcVat Boolean @default(true) + + agentPriceVatIncluded Boolean? @default(true) + agentPriceCalcVat Boolean? @default(true) + + serviceChargeVatIncluded Boolean? @default(true) + serviceChargeCalcVat Boolean? @default(true) status Status @default(CREATED) statusOrder Int @default(0) diff --git a/src/controllers/04-product-controller.ts b/src/controllers/04-product-controller.ts index 2ed9a88..b73bd3a 100644 --- a/src/controllers/04-product-controller.ts +++ b/src/controllers/04-product-controller.ts @@ -58,6 +58,10 @@ type ProductCreate = { serviceCharge: number; vatIncluded?: boolean; calcVat?: boolean; + agentPriceVatIncluded?: boolean; + agentPriceCalcVat?: boolean; + serviceChargeVatIncluded?: boolean; + serviceChargeCalcVat?: boolean; expenseType?: string; selectedImage?: string; shared?: boolean; @@ -77,6 +81,10 @@ type ProductUpdate = { remark?: string; vatIncluded?: boolean; calcVat?: boolean; + agentPriceVatIncluded?: boolean; + agentPriceCalcVat?: boolean; + serviceChargeVatIncluded?: boolean; + serviceChargeCalcVat?: boolean; expenseType?: string; selectedImage?: string; shared?: boolean; diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index 4224e45..447e12a 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -478,9 +478,11 @@ export class QuotationController extends Controller { const list = body.productServiceList.map((v, i) => { const p = product.find((p) => p.id === v.productId)!; + const vatIncluded = body.agentPrice ? p.agentPriceVatIncluded : p.vatIncluded; + const originalPrice = body.agentPrice ? p.agentPrice : p.price; const finalPriceWithVat = precisionRound( - originalPrice + (p.vatIncluded ? 0 : originalPrice * VAT_DEFAULT), + originalPrice + (vatIncluded ? 0 : originalPrice * VAT_DEFAULT), ); const price = finalPriceWithVat; @@ -743,9 +745,11 @@ export class QuotationController extends Controller { const list = body.productServiceList?.map((v, i) => { const p = product.find((p) => p.id === v.productId)!; + const vatIncluded = record.agentPrice ? p.agentPriceVatIncluded : p.vatIncluded; + const originalPrice = record.agentPrice ? p.agentPrice : p.price; const finalPriceWithVat = precisionRound( - originalPrice + (p.vatIncluded ? 0 : originalPrice * VAT_DEFAULT), + originalPrice + (vatIncluded ? 0 : originalPrice * VAT_DEFAULT), ); const price = finalPriceWithVat;