diff --git a/src/controllers/quotation-controller.ts b/src/controllers/quotation-controller.ts index 628d259..90f8a11 100644 --- a/src/controllers/quotation-controller.ts +++ b/src/controllers/quotation-controller.ts @@ -340,7 +340,7 @@ export class QuotationController extends Controller { const currentWork = currentService.work.find((d) => d.id === c.id); - if (!currentWork) return []; // should not possible + if (!currentWork) return []; // additional will get stripped return { id: currentWork.id, @@ -352,11 +352,13 @@ export class QuotationController extends Controller { if (!currentProduct) return []; // should not possible - price.totalPrice += currentProduct.price; - price.totalDiscount += Math.round(currentProduct.price * e.discount * 100) / 100; + price.totalPrice += currentProduct.price * e.amount; + price.totalDiscount += + Math.round(currentProduct.price * e.amount * e.discount * 100) / 100; price.totalVat += Math.round( - (currentProduct.price - currentProduct.price * e.discount) * + (currentProduct.price * e.amount - + currentProduct.price * e.amount * e.discount) * (e.vat === undefined ? 0.07 : e.vat) * 100, ) / 100; @@ -373,9 +375,6 @@ export class QuotationController extends Controller { }); const quotation = await tx.quotation.create({ - include: { - service: true, - }, data: { ...rest, statusOrder: +(rest.status === "INACTIVE"),