diff --git a/src/pages/05_quotation/utils.ts b/src/pages/05_quotation/utils.ts index 41a6c31e..faeb61ea 100644 --- a/src/pages/05_quotation/utils.ts +++ b/src/pages/05_quotation/utils.ts @@ -16,7 +16,7 @@ export type ProductTree = { amount: number; serviceId?: string; service?: QuotationFull['productServiceList'][number]['service']; - workId: string; + workId?: string; work?: QuotationFull['productServiceList'][number]['work']; productId: string; product: QuotationFull['productServiceList'][number]['product']; @@ -26,6 +26,10 @@ export type ProductTree = { export function quotationProductTree( list: { + vat: number; + pricePerUnit: number; + discount: number; + amount: number; service?: QuotationFull['productServiceList'][number]['service']; work?: QuotationFull['productServiceList'][number]['work']; product: QuotationFull['productServiceList'][number]['product']; @@ -50,21 +54,35 @@ export function quotationProductTree( children: service.work.flatMap((work) => { const mapper = ( relation: (typeof work)['productOnWork'][number], - ) => ({ - id: relation.product.id, - title: relation.product.name, - subtitle: relation.product.code, - opened: true, - checked: !!list.find( - (v) => - v.service?.id === service.id && - v.work?.id === work.id && - v.product.id === relation.product.id, - ), - icon: 'mdi-shopping-outline', - bg: 'hsla(var(--teal-10-hsl)/0.1)', - fg: 'var(--teal-10)', - }); + ): ProductTree[number] => { + return { + id: relation.product.id, + title: relation.product.name, + subtitle: relation.product.code, + opened: true, + checked: !!list.find( + (v) => + v.service?.id === service.id && + v.work?.id === work.id && + v.product.id === relation.product.id, + ), + value: { + vat: current.vat, + pricePerUnit: current.pricePerUnit, + discount: current.discount, + amount: current.amount, + serviceId: service.id, + service: service, + workId: work.id, + work: work, + productId: relation.product.id, + product: relation.product, + }, + icon: 'mdi-shopping-outline', + bg: 'hsla(var(--teal-10-hsl)/0.1)', + fg: 'var(--teal-10)', + }; + }; if (!!work.name) { return { @@ -95,6 +113,14 @@ export function quotationProductTree( subtitle: current.product.code, opened: true, checked: true, + value: { + vat: current.vat, + pricePerUnit: current.pricePerUnit, + discount: current.discount, + amount: current.amount, + productId: current.product.id, + product: current.product, + }, icon: 'mdi-shopping-outline', bg: 'hsla(var(--teal-10-hsl)/0.1)', fg: 'var(--teal-10)',