Argentina CUIT utilities based on a wikipedia post
This is a no-depenencies package
if you are using Yarn:
yarn add @frani/cuit
if you are using NPM:
npm i @frani/cuit
how get a CUIT based on DNI:
const cuit = require("@frani/cuit");
const cuitNumber = cuit.getCUITbyDNI("20300400");
console.log(cuitNumber); // 20203004002
be default it take it is from a Masculine gender person, you can modify that using:
const cuit = require("@frani/cuit");
const cuitNumber = cuit.getCUITbyDNI("20300400", "F");
console.log(cuitNumber); // 27203004007
if you read the wiki post, you there is some exception when generate some CUIT, here an example:
const cuit = require("@frani/cuit");
const cuitNumber = cuit.getCUITbyDNI("20300404", "F");
console.log(cuitNumber); // 23203004044
instead of start with 27 (as normal for Femenine), it starts with 23
const cuit = require("@frani/cuit");
const isValid = cuit.validateCuit("23203004044");
console.log(isValid); // true
const cuit = require("@frani/cuit");
const formatted = cuit.format("23203004044");
console.log(formatted); // "23-20300404-4"
const formatted = cuit.format("23203004044", ".");
console.log(formatted); // "23.20300404.4"
const formatted = cuit.format("23-20300404-4", "");
console.log(formatted); // "23203004044"