fix: wrong length slice

This commit is contained in:
Methapon Metanipat 2024-08-27 09:56:33 +07:00
parent c2171c33ad
commit 95d657f7e2

View file

@ -300,7 +300,7 @@ export class BranchController extends Controller {
const { provinceId, districtId, subDistrictId, headOfficeId, bank, contact, code, ...rest } = const { provinceId, districtId, subDistrictId, headOfficeId, bank, contact, code, ...rest } =
body; body;
if (headOfficeId && head && head.code.slice(0, -6) !== code) { if (headOfficeId && head && head.code.slice(0, -5) !== code) {
throw new HttpError( throw new HttpError(
HttpStatus.BAD_REQUEST, HttpStatus.BAD_REQUEST,
"Headoffice code not match with branch code", "Headoffice code not match with branch code",
@ -572,7 +572,7 @@ export class BranchController extends Controller {
if (record.isHeadOffice) { if (record.isHeadOffice) {
await tx.runningNo.delete({ await tx.runningNo.delete({
where: { where: {
key: `MAIN_BRANCH_${record.code.slice(0, -6)}`, key: `MAIN_BRANCH_${record.code.slice(0, -5)}`,
}, },
}); });
} }