feat: template string
This commit is contained in:
parent
8d9ae538cf
commit
b022ff490b
1 changed files with 35 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { RequestWork } from 'src/stores/request-list';
|
||||||
import { formatNumberDecimal } from 'src/stores/utils';
|
import { formatNumberDecimal } from 'src/stores/utils';
|
||||||
|
|
||||||
const templates = {
|
const templates = {
|
||||||
|
|
@ -40,6 +41,40 @@ const templates = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'order-detail': {
|
||||||
|
converter: (context?: {
|
||||||
|
items: {
|
||||||
|
product: RequestWork['productService']['product'];
|
||||||
|
list: RequestWork[];
|
||||||
|
}[];
|
||||||
|
itemsDiscount?: {
|
||||||
|
productId: string;
|
||||||
|
discount?: number;
|
||||||
|
}[];
|
||||||
|
}) => {
|
||||||
|
return context?.items.flatMap((item) => {
|
||||||
|
const price = formatNumberDecimal(
|
||||||
|
item.product.serviceCharge -
|
||||||
|
(context.itemsDiscount?.find((v) => v.productId === item.product.id)
|
||||||
|
?.discount || 0),
|
||||||
|
);
|
||||||
|
|
||||||
|
const list = item.list.map((v, i) => {
|
||||||
|
const employee = v.request.employee;
|
||||||
|
const branch = v.request.quotation.customerBranch;
|
||||||
|
return (
|
||||||
|
`${i + 1}. ` +
|
||||||
|
`${employee.namePrefix}. ${employee.firstNameEN} ${employee.lastNameEN} `.toUpperCase() +
|
||||||
|
`(${branch.customer.customerType === 'PERS' ? `${branch.namePrefix}. ${branch.firstNameEN} ${branch.lastNameEN} `.toUpperCase() : branch.registerName})`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return [`- ${item.product.name} ราคา ${price} บาท`, '', ...list].join(
|
||||||
|
'<br />',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
type Template = typeof templates;
|
type Template = typeof templates;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue