refactor: combine payload

This commit is contained in:
Methapon Metanipat 2024-09-16 13:51:35 +07:00
parent 46c79d50ce
commit c7b5f91d31

View file

@ -51,24 +51,21 @@ export type CustomerCreate = {
status?: Status; status?: Status;
selectedImage?: string; selectedImage?: string;
branch: (( branch: {
| { // NOTE: About (Natural Person)
// NOTE: About (Natural Person) citizenId: string;
citizenId: string;
} // NOTE: About (Legal Entity)
| { legalPersonNo?: string;
// NOTE: About (Legal Entity) registerName?: string;
legalPersonNo: string; registerNameEN?: string;
registerName: string; registerDate?: Date;
registerNameEN: string; authorizedCapital?: string;
registerDate: Date; authorizedName?: string;
authorizedCapital: string; authorizedNameEN?: string;
authorizedName: string; customerName?: string;
authorizedNameEN: string;
} customerId?: string;
) & {
customerId: string;
customerName: string;
telephoneNo: string; telephoneNo: string;
@ -103,7 +100,7 @@ export type CustomerCreate = {
subDistrictId?: string | null; subDistrictId?: string | null;
districtId?: string | null; districtId?: string | null;
provinceId?: string | null; provinceId?: string | null;
})[]; }[];
}; };
export type CustomerUpdate = { export type CustomerUpdate = {
@ -267,7 +264,7 @@ export class CustomerController extends Controller {
); );
} }
const runningKey = `CUSTOMER_BRANCH_${company}_${"citizenId" in headoffice ? headoffice.citizenId : headoffice.legalPersonNo}`; const runningKey = `CUSTOMER_BRANCH_${company}_${headoffice.citizenId || headoffice.legalPersonNo}`;
const last = await tx.runningNo.upsert({ const last = await tx.runningNo.upsert({
where: { key: runningKey }, where: { key: runningKey },