/** * Value object representation of an RFC. */ export default class Rfc { /** Generic representation of an RFC (some use cases include to invoice without RFC) */ static readonly RFC_GENERIC = "XAXX010101000"; /** Foreign representation of RFC (used on foreign parties that does not have mexican RFC) */ static readonly RFC_FOREIGN = "XEXX010101000"; static readonly DISALLOW_GENERIC = 1; static readonly DISALLOW_FOREIGN = 2; private readonly rfc; private readonly length; /** Contains calculated checksum */ private checksum; /** Contains calculated integer representation */ private serial; private constructor(); /** * Parse a string and return a new Rfc instance, otherwise will throw an exception. * * @param rfc - * @throws InvalidExpressionToParseException */ static parse(rfc: string): Rfc; /** * Parse a string, if unable to parse will return NULL. * * @param rfc - */ static parseOrNull(rfc: string): Rfc | null; /** * Method to create the object if and only you already thrust the contents. * * @param rfc - */ static unparsed(rfc: string): Rfc; /** * Create a Rfc object based on its numeric representation. * * @param serial - * @throws InvalidIntegerToConvertException */ static fromSerial(serial: number): Rfc; static newGeneric(): Rfc; static newForeign(): Rfc; static isValid(value: string, flags?: number): boolean; static checkIsValid(value: string, flags?: number): void; static obtainDate(rfc: string): number; /** * Return the rfc content, remember that it is a multibyte string */ getRfc(): string; /** * Return true if the RFC corresponds to a "Persona FĂ­sica" */ isFisica(): boolean; /** * Return true if the RFC corresponds to a "Persona Moral" */ isMoral(): boolean; /** * Return true if the RFC corresponds to a generic local RFC */ isGeneric(): boolean; /** * Return true if the RFC corresponds to a generic foreign RFC */ isForeign(): boolean; /** * Calculates the checksum of the RFC. * Be aware that there are some valid RFC with invalid checksum. */ calculateChecksum(): string; /** * Return true if the last character of the RFC is the sma as the calculated checksum. * Be aware that there are some valid RFC with invalid checksum. */ doesCheckSumMatch(): boolean; /** * Calculates the serial number (integer representation) of the RFC */ calculateSerial(): number; toString(): string; toLocaleString(): string; toJSON(): string; }