change: branch code now have 5 digit

This commit is contained in:
Methapon Metanipat 2024-08-26 13:15:23 +07:00
parent a312b797c7
commit 2d056d3b56

View file

@ -180,9 +180,9 @@ export class BranchController extends Controller {
) {
const where = {
AND: {
zipCode,
headOfficeId: headOfficeId ?? (filter === "head" || tree ? null : undefined),
NOT: { headOfficeId: filter === "sub" && !headOfficeId ? null : undefined },
zipCode,
},
OR: [
{ nameEN: { contains: query } },
@ -323,7 +323,7 @@ export class BranchController extends Controller {
if (last.value === 1) {
const exist = await tx.branch.findFirst({
where: { code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(6, "0")}` },
where: { code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(5, "0")}` },
});
if (exist)
throw new HttpError(
@ -352,7 +352,7 @@ export class BranchController extends Controller {
data: {
...rest,
statusOrder: +(rest.status === "INACTIVE"),
code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(6, "0")}`,
code: `${code?.toLocaleUpperCase()}${`${last.value - 1}`.padStart(5, "0")}`,
bank: bank ? { createMany: { data: bank } } : undefined,
isHeadOffice: !headOfficeId,
contact: {