My-Number String, Test Check Digit
My-Number String, Test Check Digit

Determines whether a My-Number string is valid. If valid, OK is logged. If invalid, the processing is abended to control with Error Boundary Event. My-Number is a 12-digit ID issued to all citizens and residents of Japan, including foreigners.

2020-04-27 (C) Questetra, Inc. (MIT License)
https://support.questetra.com/addons/my-number-string-test-check-digit/

Configs
  • A: Set MY-NUMBER String by Expression Language * #{EL}
Script
// Nashorn Script (engine type: 1)
// 
// Notes:
// To check the combined string, set it like "#{#q_strFirst8}#{#q_strLast4}"
//
// Notes (ja):
// 結合文字列を検査する場合は "#{#q_strFirst8}#{#q_strLast4}" のように設定します

// <根拠法>
// 行政手続における特定の個人を識別するための番号の利用等に関する法律
// の規定による通知カード及び個人番号カード並びに情報提供ネットワークシステム
// による特定個人情報の提供等に関する省令(平成26年総務省令第85号)
// https://www.cao.go.jp/bangouseido/pdf/syourei_26_85_20170529.pdf


//////// START "main()" ////////////////////////////////////////////////////////////////
main();
function main(){

//// == Config Retrieving / 工程コンフィグの参照 ==
const strA    = configs.get( "conf_StrA" )    + ""; // required
const reg12num = /^\d{12}$/;
if( ! reg12num.test( strA ) ){
  throw new Error( "\n AutomatedTask ConfigError:" +
                   " Config Date {A} is not a 12 digit number string \n" );
}


//// == Data Retrieving / ワークフローデータの参照 ==
// (nothing, except Expression Language config)


//// == Calculating / 演算 ==
let numSum = 0;
for( let i = 0; i < 5; i++){
  numSum += (11 - i - 5) * parseInt( strA.charAt(i) );
}
for( let i = 5; i < 11; i++){
  numSum += (11 - i + 1) * parseInt( strA.charAt(i) );
}
let numCheckdigit = 11 - numSum % 11;
if( numCheckdigit >= 10 ){ numCheckdigit = 0; }

if( parseInt( strA.charAt(11) ) === numCheckdigit ){
  engine.log( " AutomatedTask Check Digit: OK" );
}else{
  throw new Error( "\n AutomatedTask Error:" +
                   " This My-Number string {A} is invalid. \n" );
}


//// == ワークフローデータへの代入 / Data Updating ==
// (nothing, except Log)


} //////// END "main()" ////////////////////////////////////////////////////////////////

Download

Capture

Determines whether a My-Number string is valid. If valid, OK is logged. If invalid, the processing is abended to control with Error Boundary Event. My-Number is a 12-digit ID issued to all citizens and residents of Japan, including foreigners.

Notes

  1. To check the combined string, set it like “#{#q_strFirst8}#{#q_strLast4}”

See also

2 thoughts on “My-Number String, Test Check Digit”

  1. Pingback: Corporate-Number String, Test Check Digit – Questetra Support

  2. Pingback: String, Extract Substring – Questetra Support

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: