feat: add bank to branch payload (optional)
This commit is contained in:
parent
ef1f404779
commit
3e4709d8ff
3 changed files with 41 additions and 2 deletions
|
|
@ -42,6 +42,12 @@ type BranchCreate = {
|
|||
longitude: string;
|
||||
latitude: string;
|
||||
|
||||
bank?: {
|
||||
bankName: string;
|
||||
accountName: string;
|
||||
accountNumber: string;
|
||||
}[];
|
||||
|
||||
subDistrictId?: string | null;
|
||||
districtId?: string | null;
|
||||
provinceId?: string | null;
|
||||
|
|
@ -68,6 +74,12 @@ type BranchUpdate = {
|
|||
districtId?: string | null;
|
||||
provinceId?: string | null;
|
||||
headOfficeId?: string | null;
|
||||
|
||||
bank?: {
|
||||
bankName: string;
|
||||
accountName: string;
|
||||
accountNumber: string;
|
||||
}[];
|
||||
};
|
||||
|
||||
function lineImageLoc(id: string) {
|
||||
|
|
@ -273,7 +285,7 @@ export class BranchController extends Controller {
|
|||
"relationHQNotFound",
|
||||
);
|
||||
|
||||
const { provinceId, districtId, subDistrictId, headOfficeId, contact, ...rest } = body;
|
||||
const { provinceId, districtId, subDistrictId, headOfficeId, bank, contact, ...rest } = body;
|
||||
|
||||
const year = new Date().getFullYear();
|
||||
|
||||
|
|
@ -306,6 +318,7 @@ export class BranchController extends Controller {
|
|||
...rest,
|
||||
statusOrder: +(rest.status === "INACTIVE"),
|
||||
code,
|
||||
bank: bank ? { createMany: { data: bank } } : undefined,
|
||||
isHeadOffice: !headOfficeId,
|
||||
province: { connect: provinceId ? { id: provinceId } : undefined },
|
||||
district: { connect: districtId ? { id: districtId } : undefined },
|
||||
|
|
@ -401,7 +414,7 @@ export class BranchController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
const { provinceId, districtId, subDistrictId, headOfficeId, contact, ...rest } = body;
|
||||
const { provinceId, districtId, subDistrictId, headOfficeId, bank, contact, ...rest } = body;
|
||||
|
||||
const branch = await prisma.branch.findUnique({
|
||||
include: {
|
||||
|
|
@ -431,6 +444,7 @@ export class BranchController extends Controller {
|
|||
...rest,
|
||||
statusOrder: +(rest.status === "INACTIVE"),
|
||||
isHeadOffice: headOfficeId !== undefined ? headOfficeId === null : undefined,
|
||||
bank: bank ? { deleteMany: {}, createMany: { data: bank } } : undefined,
|
||||
province: {
|
||||
connect: provinceId ? { id: provinceId } : undefined,
|
||||
disconnect: provinceId === null || undefined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue