feat: send remark to flowaccount
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
This commit is contained in:
parent
86db927efe
commit
eda0edbd29
1 changed files with 41 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
|||
import prisma from "../db";
|
||||
import config from "../config.json";
|
||||
import { CustomerType, PayCondition } from "@prisma/client";
|
||||
import { convertTemplate } from "../utils/string-template";
|
||||
import { htmlToText } from "html-to-text";
|
||||
|
||||
if (!process.env.FLOW_ACCOUNT_URL) throw new Error("Require FLOW_ACCOUNT_URL");
|
||||
if (!process.env.FLOW_ACCOUNT_CLIENT_ID) throw new Error("Require FLOW_ACCOUNT_CLIENT_ID");
|
||||
|
|
@ -232,6 +234,29 @@ const flowAccount = {
|
|||
installments: true,
|
||||
quotation: {
|
||||
include: {
|
||||
paySplit: true,
|
||||
worker: {
|
||||
select: {
|
||||
employee: {
|
||||
select: {
|
||||
employeePassport: {
|
||||
select: {
|
||||
number: true,
|
||||
},
|
||||
orderBy: {
|
||||
expireDate: "desc",
|
||||
},
|
||||
take: 1,
|
||||
},
|
||||
namePrefix: true,
|
||||
firstName: true,
|
||||
lastName: true,
|
||||
firstNameEN: true,
|
||||
lastNameEN: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
registeredBranch: {
|
||||
include: {
|
||||
province: true,
|
||||
|
|
@ -326,6 +351,22 @@ const flowAccount = {
|
|||
? data.installments.reduce((a, c) => a + c.amount, 0)
|
||||
: quotation.finalPrice,
|
||||
|
||||
remarks: htmlToText(
|
||||
convertTemplate(quotation.remark ?? "", {
|
||||
"quotation-payment": {
|
||||
paymentType: quotation?.payCondition || "Full",
|
||||
amount: quotation.finalPrice,
|
||||
installments: quotation?.paySplit,
|
||||
},
|
||||
"quotation-labor": {
|
||||
name: quotation.worker.map(
|
||||
(v, i) =>
|
||||
`${i + 1}. ` +
|
||||
`${v.employee.employeePassport.length !== 0 ? v.employee.employeePassport[0].number + "_" : ""}${v.employee.namePrefix}. ${v.employee.firstNameEN ? `${v.employee.firstNameEN} ${v.employee.lastNameEN}` : `${v.employee.firstName} ${v.employee.lastName}`} `.toUpperCase(),
|
||||
),
|
||||
},
|
||||
}),
|
||||
),
|
||||
items: product.map((v) => ({
|
||||
type: ProductAndServiceType.ProductNonInv,
|
||||
name: v.product.name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue