feat: update status of headoffice so it cannot be delete
This commit is contained in:
parent
1d68cc2d61
commit
03d25219c1
1 changed files with 12 additions and 1 deletions
|
|
@ -333,7 +333,8 @@ export class CustomerBranchController extends Controller {
|
|||
|
||||
const record = await prisma.$transaction(
|
||||
async (tx) => {
|
||||
const headofficeCode = customer.branch.at(0)?.code.slice(0, -3);
|
||||
const headoffice = customer.branch.at(0);
|
||||
const headofficeCode = headoffice?.code.slice(0, -3);
|
||||
|
||||
let runningKey = "";
|
||||
|
||||
|
|
@ -354,6 +355,16 @@ export class CustomerBranchController extends Controller {
|
|||
update: { value: { increment: 1 } },
|
||||
});
|
||||
|
||||
if (headoffice) {
|
||||
await tx.customerBranch.updateMany({
|
||||
where: {
|
||||
id: headoffice.id,
|
||||
status: "CREATED",
|
||||
},
|
||||
data: { status: "ACTIVE" },
|
||||
});
|
||||
}
|
||||
|
||||
return await tx.customerBranch.create({
|
||||
include: {
|
||||
province: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue