NTN and STRN
import { analyzeNTN, validateNTN, validateSTRN } from 'pakdatakit/tax'
Checks the shape of a National Tax Number and a Sales Tax Registration Number. Individuals use their 13-digit CNIC as their NTN (since the Finance Act 2015). Companies and associations of persons have a 7-digit NTN, often written with an 8th check digit as 1234567-8.
analyzeNTN() Valid validateSTRN() Valid
- NTN type
- Business
- NTN formatted
- 1234567-8
Examples
Section titled “Examples”import { analyzeNTN, validateNTN, validateSTRN } from 'pakdatakit';
analyzeNTN('1234567-8');// → {// "type": "business",// "digits": "12345678",// "formatted": "1234567-8"// }
analyzeNTN('35202-1234567-1');// → {// "type": "individual",// "digits": "3520212345671",// "formatted": "35202-1234567-1"// }
validateNTN('12345');// → false
validateSTRN('12-34-5678-901-23');// → truefrom pakdatakit import analyze_ntn, validate_ntn, validate_strn
analyze_ntn('1234567-8')# → {# "type": "business",# "digits": "12345678",# "formatted": "1234567-8"# }
analyze_ntn('35202-1234567-1')# → {# "type": "individual",# "digits": "3520212345671",# "formatted": "35202-1234567-1"# }
validate_ntn('12345')# → False
validate_strn('12-34-5678-901-23')# → Trueimport 'package:pakdatakit/pakdatakit.dart';
analyzeNTN('1234567-8');// → {// "type": "business",// "digits": "12345678",// "formatted": "1234567-8"// }
analyzeNTN('35202-1234567-1');// → {// "type": "individual",// "digits": "3520212345671",// "formatted": "35202-1234567-1"// }
validateNTN('12345');// → false
validateSTRN('12-34-5678-901-23');// → trueusing PakDataKit;
Tax.AnalyzeNtn("1234567-8");// → {// "type": "business",// "digits": "12345678",// "formatted": "1234567-8"// }
Tax.AnalyzeNtn("35202-1234567-1");// → {// "type": "individual",// "digits": "3520212345671",// "formatted": "35202-1234567-1"// }
Tax.ValidateNtn("12345");// → false
Tax.ValidateStrn("12-34-5678-901-23");// → trueuse PakDataKit\Tax;
Tax::analyzeNtn('1234567-8');// → {// "type": "business",// "digits": "12345678",// "formatted": "1234567-8"// }
Tax::analyzeNtn('35202-1234567-1');// → {// "type": "individual",// "digits": "3520212345671",// "formatted": "35202-1234567-1"// }
Tax::validateNtn('12345');// → false
Tax::validateStrn('12-34-5678-901-23');// → trueReference
Section titled “Reference”analyzeNTN()
Section titled “analyzeNTN()”function analyzeNTN(ntn: string): NTNInfo | null;
type NTNType = 'individual' | 'business';
interface NTNInfo { type: NTNType; digits: string; // 7, 8 or 13 digits, without separators formatted: string; // 1234567-8, or #####-#######-# for a CNIC}Parameters. ntn: an NTN in any common format. A CNIC is read as an individual’s NTN; 7 digits, optionally followed by a check digit, as a business NTN.
Returns the type, the digits and a display form, or null when the format is not valid.
Caveats. FBR does not publish the check-digit algorithm, so the check digit is not verified.
Related: validateNTN(), CNIC.
validateNTN()
Section titled “validateNTN()”function validateNTN(ntn: string): boolean;Parameters. ntn: as for analyzeNTN().
Returns true when the format is valid: a CNIC for individuals, or 7 digits (optionally followed by a check digit) for businesses.
Related: analyzeNTN().
validateSTRN()
Section titled “validateSTRN()”function validateSTRN(strn: string): boolean;Parameters. strn: 13 digits, with optional spaces or dashes.
Returns true when the format is valid.
Caveats. FBR does not publish a check-digit algorithm or the meaning of the digit groups, so this validates the format only.
Related: Sales tax, FBR Digital Invoicing.
Related
Section titled “Related”- CNIC: the number individuals use as their NTN.
- Income tax and sales tax.
- API reference for
pakdatakit/tax.