diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index be18cc8..866b93a 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -477,13 +477,15 @@ export class QuotationController extends Controller { const list = body.productServiceList.map((v, i) => { const p = product.find((p) => p.id === v.productId)!; - const price = body.agentPrice ? p.agentPrice : p.price; + + const originalPrice = body.agentPrice ? p.agentPrice : p.price; + const finalPriceWithVat = precisionRound( + originalPrice + (p.vatIncluded ? 0 : originalPrice * 1.07), + ); + + const price = finalPriceWithVat; const pricePerUnit = p.vatIncluded ? price / (1 + VAT_DEFAULT) : price; - const vat = p.calcVat - ? (pricePerUnit * (v.discount ? v.amount : 1) - (v.discount || 0)) * - VAT_DEFAULT * - (!v.discount ? v.amount : 1) - : 0; + const vat = p.calcVat ? (pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT : 0; return { order: i + 1, @@ -742,13 +744,16 @@ export class QuotationController extends Controller { const list = body.productServiceList?.map((v, i) => { const p = product.find((p) => p.id === v.productId)!; - const price = record.agentPrice ? p.agentPrice : p.price; + + const originalPrice = record.agentPrice ? p.agentPrice : p.price; + const finalPriceWithVat = precisionRound( + originalPrice + (p.vatIncluded ? 0 : originalPrice * 1.07), + ); + + const price = finalPriceWithVat; const pricePerUnit = p.vatIncluded ? price / (1 + VAT_DEFAULT) : price; - const vat = p.calcVat - ? (pricePerUnit * (v.discount ? v.amount : 1) - (v.discount || 0)) * - VAT_DEFAULT * - (!v.discount ? v.amount : 1) - : 0; + const vat = p.calcVat ? (pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT : 0; + return { order: i + 1, productId: v.productId,