Server IP : 150.95.80.236 / Your IP : 3.144.2.48 Web Server : Apache System : Linux host-150-95-80-236 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64 User : social-telecare ( 10000) PHP Version : 7.4.33 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/vhosts/pcu.in.th/uat.pcu.in.th/demo15/src/plugins/formvalidation/dist/es6/validators/vat/ |
Upload File : |
export default function t(t){let e=t;if(/^ES[0-9A-Z][0-9]{7}[0-9A-Z]$/.test(e)){e=e.substr(2)}if(!/^[0-9A-Z][0-9]{7}[0-9A-Z]$/.test(e)){return{meta:{},valid:false}}const s=t=>{const e=parseInt(t.substr(0,8),10);return`${"TRWAGMYFPDXBNJZSQVHLCKE"[e%23]}`===t.substr(8,1)};const r=t=>{const e=["XYZ".indexOf(t.charAt(0)),t.substr(1)].join("");const s="TRWAGMYFPDXBNJZSQVHLCKE"[parseInt(e,10)%23];return`${s}`===t.substr(8,1)};const n=t=>{const e=t.charAt(0);let s;if("KLM".indexOf(e)!==-1){s=parseInt(t.substr(1,8),10);s="TRWAGMYFPDXBNJZSQVHLCKE"[s%23];return`${s}`===t.substr(8,1)}else if("ABCDEFGHJNPQRSUVW".indexOf(e)!==-1){const e=[2,1,2,1,2,1,2];let s=0;let r=0;for(let n=0;n<7;n++){r=parseInt(t.charAt(n+1),10)*e[n];if(r>9){r=Math.floor(r/10)+r%10}s+=r}s=10-s%10;if(s===10){s=0}return`${s}`===t.substr(8,1)||"JABCDEFGHI"[s]===t.substr(8,1)}return false};const a=e.charAt(0);if(/^[0-9]$/.test(a)){return{meta:{type:"DNI"},valid:s(e)}}else if(/^[XYZ]$/.test(a)){return{meta:{type:"NIE"},valid:r(e)}}else{return{meta:{type:"CIF"},valid:n(e)}}}