refactor: add value
This commit is contained in:
parent
5fc9a9a6c6
commit
5f852b977b
1 changed files with 42 additions and 16 deletions
|
|
@ -16,7 +16,7 @@ export type ProductTree = {
|
||||||
amount: number;
|
amount: number;
|
||||||
serviceId?: string;
|
serviceId?: string;
|
||||||
service?: QuotationFull['productServiceList'][number]['service'];
|
service?: QuotationFull['productServiceList'][number]['service'];
|
||||||
workId: string;
|
workId?: string;
|
||||||
work?: QuotationFull['productServiceList'][number]['work'];
|
work?: QuotationFull['productServiceList'][number]['work'];
|
||||||
productId: string;
|
productId: string;
|
||||||
product: QuotationFull['productServiceList'][number]['product'];
|
product: QuotationFull['productServiceList'][number]['product'];
|
||||||
|
|
@ -26,6 +26,10 @@ export type ProductTree = {
|
||||||
|
|
||||||
export function quotationProductTree(
|
export function quotationProductTree(
|
||||||
list: {
|
list: {
|
||||||
|
vat: number;
|
||||||
|
pricePerUnit: number;
|
||||||
|
discount: number;
|
||||||
|
amount: number;
|
||||||
service?: QuotationFull['productServiceList'][number]['service'];
|
service?: QuotationFull['productServiceList'][number]['service'];
|
||||||
work?: QuotationFull['productServiceList'][number]['work'];
|
work?: QuotationFull['productServiceList'][number]['work'];
|
||||||
product: QuotationFull['productServiceList'][number]['product'];
|
product: QuotationFull['productServiceList'][number]['product'];
|
||||||
|
|
@ -50,7 +54,8 @@ export function quotationProductTree(
|
||||||
children: service.work.flatMap((work) => {
|
children: service.work.flatMap((work) => {
|
||||||
const mapper = (
|
const mapper = (
|
||||||
relation: (typeof work)['productOnWork'][number],
|
relation: (typeof work)['productOnWork'][number],
|
||||||
) => ({
|
): ProductTree[number] => {
|
||||||
|
return {
|
||||||
id: relation.product.id,
|
id: relation.product.id,
|
||||||
title: relation.product.name,
|
title: relation.product.name,
|
||||||
subtitle: relation.product.code,
|
subtitle: relation.product.code,
|
||||||
|
|
@ -61,10 +66,23 @@ export function quotationProductTree(
|
||||||
v.work?.id === work.id &&
|
v.work?.id === work.id &&
|
||||||
v.product.id === relation.product.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',
|
icon: 'mdi-shopping-outline',
|
||||||
bg: 'hsla(var(--teal-10-hsl)/0.1)',
|
bg: 'hsla(var(--teal-10-hsl)/0.1)',
|
||||||
fg: 'var(--teal-10)',
|
fg: 'var(--teal-10)',
|
||||||
});
|
};
|
||||||
|
};
|
||||||
|
|
||||||
if (!!work.name) {
|
if (!!work.name) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -95,6 +113,14 @@ export function quotationProductTree(
|
||||||
subtitle: current.product.code,
|
subtitle: current.product.code,
|
||||||
opened: true,
|
opened: true,
|
||||||
checked: 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',
|
icon: 'mdi-shopping-outline',
|
||||||
bg: 'hsla(var(--teal-10-hsl)/0.1)',
|
bg: 'hsla(var(--teal-10-hsl)/0.1)',
|
||||||
fg: 'var(--teal-10)',
|
fg: 'var(--teal-10)',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue