Corporate-Number String, Test Check Digit
Corporate-Number String, Test Check Digit

Determines whether a Corporate-Number string is valid. If valid, OK is logged. If invalid, the processing is abended to control with Error Boundary Event. The numbers are 13-digit IDs assigned to companies and other organizations registered in Japan.

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

Configs
  • A: Set Corporate-NUMBER String by Expression Language * #{EL}
Script
// Nashorn Script (engine type: 1)
// 
// Notes:
// About The Corporate Number
// https://www.houjin-bangou.nta.go.jp/en/setsumei/
// Corporate Number Search
// https://www.houjin-bangou.nta.go.jp/en/index.html
//
// Notes (ja):
// 法人番号とは
// https://www.houjin-bangou.nta.go.jp/setsumei/
// 法人番号検索
// https://www.houjin-bangou.nta.go.jp/

// <根拠法>
// 法人番号の指定等に関する省令(平成26年財務省令第70号)
// https://www.houjin-bangou.nta.go.jp/documents/houjinbangoushourei.pdf


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

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


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


//// == Calculating / 演算 ==
let numSum = 0;
numSum += parseInt( strA.charAt(1)  ) * 2; 
numSum += parseInt( strA.charAt(2)  ); 
numSum += parseInt( strA.charAt(3)  ) * 2; 
numSum += parseInt( strA.charAt(4)  ); 
numSum += parseInt( strA.charAt(5)  ) * 2; 
numSum += parseInt( strA.charAt(6)  ); 
numSum += parseInt( strA.charAt(7)  ) * 2; 
numSum += parseInt( strA.charAt(8)  ); 
numSum += parseInt( strA.charAt(9)  ) * 2; 
numSum += parseInt( strA.charAt(10) ); 
numSum += parseInt( strA.charAt(11) ) * 2; 
numSum += parseInt( strA.charAt(12) ); 

let numCheckdigit = 9 - numSum % 9;

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


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


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

Download

Capture

Determines whether a Corporate-Number string is valid. If valid, OK is logged. If invalid, the processing is abended to control with Error Boundary Event. The numbers are 13-digit IDs assigned to companies and other organizations registered in Japan.
Corporate Number algorithm

Notes

  1. About The Corporate Number
    1. https://www.houjin-bangou.nta.go.jp/en/setsumei/
  2. Corporate Number Search
    1. https://www.houjin-bangou.nta.go.jp/en/index.html

See also

1 thought on “Corporate-Number String, Test Check Digit”

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

Leave a Reply

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

%d bloggers like this: