implementado typescript 7
This commit is contained in:
parent
cd4ea4d36b
commit
e9a323f18c
80 changed files with 5711 additions and 2455 deletions
|
|
@ -1,48 +1,55 @@
|
|||
"use strict";
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var zDocumento_exports = {};
|
||||
__export(zDocumento_exports, {
|
||||
zDocCnpj: () => zDocCnpj,
|
||||
zDocCpf: () => zDocCpf,
|
||||
zDocumento: () => zDocumento
|
||||
});
|
||||
module.exports = __toCommonJS(zDocumento_exports);
|
||||
var import_zod = __toESM(require("zod"));
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.zDocumento = exports.zDocCpf = exports.zDocCnpj = void 0;
|
||||
const zod_1 = __importDefault(require("zod"));
|
||||
/**
|
||||
Resumo – CNPJ Alfanumérico (vigência a partir de julho de 2026)
|
||||
|
||||
A Receita Federal passará a emitir CNPJs alfanuméricos para novas empresas a partir de julho de 2026. O objetivo é ampliar a quantidade de combinações disponíveis e evitar o esgotamento dos números atuais.
|
||||
|
||||
O que muda?
|
||||
O CNPJ continuará com 14 caracteres.
|
||||
Os 12 primeiros caracteres poderão conter letras (A-Z) e números (0-9).
|
||||
Os 2 dígitos verificadores finais continuarão sendo numéricos.
|
||||
Exemplo ilustrativo:
|
||||
Atual: 00.000.000/0001-00
|
||||
Novo: A1.B2C.3D4/EF56-78
|
||||
Quem será afetado?
|
||||
Empresas já existentes não terão seus CNPJs alterados.
|
||||
A mudança vale apenas para novas inscrições realizadas a partir de julho de 2026.
|
||||
*/
|
||||
const regexCnpjNumerico = /^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/;
|
||||
/**
|
||||
Como ler o novo CNPJ (estrutura)
|
||||
|
||||
Tomando como exemplo um CNPJ alfanumérico fictício:
|
||||
|
||||
12.ABC.345/0001-67
|
||||
|
||||
Como ler:
|
||||
|
||||
12.ABC.345 é a raiz (identificação da empresa)
|
||||
0001 é o sufixo (estabelecimento, geralmente “0001” para matriz)
|
||||
67 são os dígitos verificadores numéricos
|
||||
|
||||
Pontos de atenção:
|
||||
|
||||
Letras maiúsculas (não há diferenciação entre maiúscula e minúscula no sistema, mas convenção é maiúscula)
|
||||
Não usar caracteres especiais: só letras de A a Z e números de 0 a 9
|
||||
Pontos, barra e hífen mantidos como antes
|
||||
|
||||
*/
|
||||
const regexCnpjAlfanumerico = /^[A-Z0-9]{2}\.[A-Z0-9]{3}\.[A-Z0-9]{3}\/[A-Z0-9]{4}-\d{2}$/i;
|
||||
const yyyymm = Number((/* @__PURE__ */ new Date()).toISOString().slice(0, 7).replace("-", ""));
|
||||
const zDocCnpj = import_zod.default.string().regex(yyyymm < 202407 ? regexCnpjNumerico : regexCnpjAlfanumerico).describe("Documento (CNPJ) no formato XX.XXX.XXX/XXXX-XX");
|
||||
const zDocCpf = import_zod.default.string().regex(/^\d{3}\.\d{3}\.\d{3}-\d{2}$/).describe("Documento (CPF) no formato XXX.XXX.XXX-XX");
|
||||
const zDocumento = zDocCpf.or(zDocCnpj).describe("CPF ou CNPJ");
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
zDocCnpj,
|
||||
zDocCpf,
|
||||
zDocumento
|
||||
});
|
||||
const yyyymm = Number(new Date().toISOString().slice(0, 7).replace("-", ""));
|
||||
exports.zDocCnpj = zod_1.default
|
||||
.string()
|
||||
.regex(yyyymm < 202407 ? regexCnpjNumerico : regexCnpjAlfanumerico)
|
||||
.describe("Documento (CNPJ) no formato XX.XXX.XXX/XXXX-XX");
|
||||
exports.zDocCpf = zod_1.default
|
||||
.string()
|
||||
.regex(/^\d{3}\.\d{3}\.\d{3}-\d{2}$/)
|
||||
.describe("Documento (CPF) no formato XXX.XXX.XXX-XX");
|
||||
exports.zDocumento = exports.zDocCpf.or(exports.zDocCnpj).describe("CPF ou CNPJ");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue