diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 120a7fa5..6558f0ee 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -3302,10 +3302,7 @@ export class ProfileController extends Controller { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); @@ -3338,10 +3335,7 @@ export class ProfileController extends Controller { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; // else if(chkDigit === 11){ // chkDigit = cal % 10; // } @@ -3416,10 +3410,7 @@ export class ProfileController extends Controller { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); @@ -3484,10 +3475,7 @@ export class ProfileController extends Controller { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); @@ -5249,10 +5237,7 @@ export class ProfileController extends Controller { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index cdbac600..ac5523bb 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1891,10 +1891,7 @@ export class ProfileEmployeeController extends Controller { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); @@ -1983,10 +1980,7 @@ export class ProfileEmployeeController extends Controller { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; if (citizenIdDigits[12] !== chkDigit) { throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"); diff --git a/src/interfaces/extension.ts b/src/interfaces/extension.ts index c81e66c0..4a5dc5a3 100644 --- a/src/interfaces/extension.ts +++ b/src/interfaces/extension.ts @@ -275,10 +275,7 @@ class Extension { citizenIdDigits[10] * 3 + citizenIdDigits[11] * 2; const calStp2 = cal % 11; - let chkDigit = 11 - calStp2; - if (chkDigit >= 10) { - chkDigit = 0; - } + const chkDigit = (11 - calStp2) % 10; // if (citizenIdDigits[12] !== chkDigit) { // throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");