@pairus/product-data 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/dist/index.d.mts +99 -15
- package/dist/index.d.ts +99 -15
- package/dist/index.js +59 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -110,8 +110,8 @@ console.log(trib.avisos_fiscais);
|
|
|
110
110
|
#### Saneamento Fiscal em Lote
|
|
111
111
|
```typescript
|
|
112
112
|
const lote = await client.fiscal.sanitize([
|
|
113
|
-
{
|
|
114
|
-
{
|
|
113
|
+
{ ncm: '22021000', xProd: 'Refrigerante Cola', id: 'SKU-001' },
|
|
114
|
+
{ ncm: '22030000', cest: '0302100', xProd: 'Cerveja Pilsen' },
|
|
115
115
|
]);
|
|
116
116
|
|
|
117
117
|
for (const item of lote.itens) {
|
|
@@ -277,6 +277,25 @@ const inut = await client.emissao.inutilizar({
|
|
|
277
277
|
console.log('Inutilização homologada:', inut.sucesso);
|
|
278
278
|
```
|
|
279
279
|
|
|
280
|
+
#### Consulta da Nota Emitida e Referência da Venda
|
|
281
|
+
Informe `referencia_externa` na emissão. Ela volta na resposta e em todo webhook, junto com `cnpj_emitente`, e localiza a nota mesmo quando a resposta da emissão se perdeu:
|
|
282
|
+
```typescript
|
|
283
|
+
const notas = await client.emissao.buscarPorReferencia('12345678000195', 'pedido-8841');
|
|
284
|
+
if (notas.length === 0) {
|
|
285
|
+
// nenhuma nota gravada para a venda: é seguro emitir
|
|
286
|
+
}
|
|
287
|
+
const nota = await client.emissao.consultar(notas[0].chave_acesso, { incluirXml: true });
|
|
288
|
+
const pdf = await client.emissao.baixarDanfe(nota.chave_acesso);
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
#### CSC da NFC-e
|
|
292
|
+
```typescript
|
|
293
|
+
const status = await client.empresas.configurarCsc('12345678000195', {
|
|
294
|
+
ambiente: 'producao', csc_id: '000001', csc_codigo: 'SEU_CSC_DA_SEFAZ',
|
|
295
|
+
});
|
|
296
|
+
console.log(status.producao.configurado); // o código nunca é devolvido
|
|
297
|
+
```
|
|
298
|
+
|
|
280
299
|
### 6. 📥 DF-e Inbound & Captura SEFAZ Nacional (Gestão de Compras)
|
|
281
300
|
|
|
282
301
|
Capture ativamente as notas fiscais emitidas por fornecedores contra o seu CNPJ via WebService `NFeDistribuicaoDFe` da SEFAZ Nacional, com controle incremental de NSU, descompactação automática de lotes `docZip` e Manifestação do Destinatário.
|
package/dist/index.d.mts
CHANGED
|
@@ -271,6 +271,8 @@ interface EmissaoNFeInput {
|
|
|
271
271
|
cnpj: string;
|
|
272
272
|
id_cadastro: string;
|
|
273
273
|
};
|
|
274
|
+
/** Identificador da venda no seu sistema; volta nos webhooks e localiza a nota em `buscarPorReferencia`. */
|
|
275
|
+
referencia_externa?: string;
|
|
274
276
|
[key: string]: any;
|
|
275
277
|
}
|
|
276
278
|
/** Opções de envio da emissão. */
|
|
@@ -301,6 +303,8 @@ interface EmissaoNFeResponse {
|
|
|
301
303
|
data_emissao?: string | null;
|
|
302
304
|
ambiente?: string;
|
|
303
305
|
tipo_documento?: string;
|
|
306
|
+
/** Identificador da venda informado na emissão. */
|
|
307
|
+
referencia_externa?: string | null;
|
|
304
308
|
autocura_aplicada?: boolean;
|
|
305
309
|
xml_autorizado_base64?: string | null;
|
|
306
310
|
danfe_pdf_base64?: string | null;
|
|
@@ -341,6 +345,48 @@ interface InutilizacaoInput {
|
|
|
341
345
|
/** '55' (NF-e) ou '65' (NFC-e). */
|
|
342
346
|
modelo?: '55' | '65' | 55 | 65;
|
|
343
347
|
}
|
|
348
|
+
/** Situação atual de uma nota emitida (`GET /v1/nfe/{chave}` e `GET /v1/nfe?referencia_externa=`). */
|
|
349
|
+
interface NotaEmitidaResponse {
|
|
350
|
+
chave_acesso: string;
|
|
351
|
+
tipo_documento?: 'NFE' | 'NFCE' | null;
|
|
352
|
+
serie?: number | null;
|
|
353
|
+
numero?: number | null;
|
|
354
|
+
/** 'AUTORIZADA', 'PENDENTE_RETORNO', 'CONTINGENCIA', 'CANCELADA', 'REJEITADA'... */
|
|
355
|
+
status_sefaz?: string | null;
|
|
356
|
+
cStat?: number | null;
|
|
357
|
+
xMotivo?: string | null;
|
|
358
|
+
protocolo?: string | null;
|
|
359
|
+
data_emissao?: string | null;
|
|
360
|
+
ambiente?: string | null;
|
|
361
|
+
cnpj_emitente?: string | null;
|
|
362
|
+
referencia_externa?: string | null;
|
|
363
|
+
valor_total?: number | null;
|
|
364
|
+
qrcode_url?: string | null;
|
|
365
|
+
substituida_por?: string | null;
|
|
366
|
+
chave_substituida?: string | null;
|
|
367
|
+
prazo_transmissao?: string | null;
|
|
368
|
+
/** procNFe em Base64, só com `incluirXml: true`. */
|
|
369
|
+
xml_autorizado_base64?: string | null;
|
|
370
|
+
}
|
|
371
|
+
/** Situação do CSC em um ambiente. O código nunca é devolvido pela API. */
|
|
372
|
+
interface CscAmbienteStatus {
|
|
373
|
+
configurado: boolean;
|
|
374
|
+
csc_id?: string | null;
|
|
375
|
+
}
|
|
376
|
+
/** Situação do CSC da NFC-e do estabelecimento (`/v1/empresas/{cnpj}/csc`). */
|
|
377
|
+
interface CscNFCeStatus {
|
|
378
|
+
cnpj: string;
|
|
379
|
+
producao: CscAmbienteStatus;
|
|
380
|
+
homologacao: CscAmbienteStatus;
|
|
381
|
+
}
|
|
382
|
+
/** CSC gerado no portal da SEFAZ da UF, por ambiente. */
|
|
383
|
+
interface CscNFCeInput {
|
|
384
|
+
ambiente: 'producao' | 'homologacao';
|
|
385
|
+
/** Identificador do CSC (ex: '000001'). */
|
|
386
|
+
csc_id: string;
|
|
387
|
+
/** Código do CSC (16 a 36 letras e números). */
|
|
388
|
+
csc_codigo: string;
|
|
389
|
+
}
|
|
344
390
|
|
|
345
391
|
declare class EmissaoResource extends BaseResource {
|
|
346
392
|
/**
|
|
@@ -367,6 +413,35 @@ declare class EmissaoResource extends BaseResource {
|
|
|
367
413
|
* Inutiliza uma faixa de numeração quebrada na SEFAZ (Ajuste SINIEF 07/05).
|
|
368
414
|
*/
|
|
369
415
|
inutilizar(params: InutilizacaoInput): Promise<EventoNFeResponse>;
|
|
416
|
+
/**
|
|
417
|
+
* Consulta a situação atual de uma NF-e ou NFC-e emitida pela sua conta.
|
|
418
|
+
*
|
|
419
|
+
* @param chaveAcesso Chave de 44 dígitos da nota
|
|
420
|
+
* @param options `incluirXml` traz o procNFe em Base64
|
|
421
|
+
*/
|
|
422
|
+
consultar(chaveAcesso: string, options?: {
|
|
423
|
+
incluirXml?: boolean;
|
|
424
|
+
}): Promise<NotaEmitidaResponse>;
|
|
425
|
+
/**
|
|
426
|
+
* Localiza as notas emitidas para uma venda pela `referencia_externa` informada na emissão.
|
|
427
|
+
* Lista vazia: nenhuma nota gravada para a venda, é seguro emitir.
|
|
428
|
+
*/
|
|
429
|
+
buscarPorReferencia(cnpjEmitente: string, referenciaExterna: string): Promise<NotaEmitidaResponse[]>;
|
|
430
|
+
/**
|
|
431
|
+
* Baixa o DANFE em PDF de uma nota emitida (na contingência ainda não transmitida, com a tarja).
|
|
432
|
+
*/
|
|
433
|
+
baixarDanfe(chaveAcesso: string): Promise<ArrayBuffer>;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Cadastro de empresas emitentes (CSC da NFC-e). */
|
|
437
|
+
declare class EmpresasResource extends BaseResource {
|
|
438
|
+
/**
|
|
439
|
+
* Grava o CSC da NFC-e do estabelecimento (gerado no portal da SEFAZ da UF).
|
|
440
|
+
* O estabelecimento precisa de certificado próprio na conta; o código nunca é devolvido.
|
|
441
|
+
*/
|
|
442
|
+
configurarCsc(cnpj: string, input: CscNFCeInput): Promise<CscNFCeStatus>;
|
|
443
|
+
/** Indica, por ambiente, se o CSC da NFC-e está configurado (sem devolver o código). */
|
|
444
|
+
consultarCsc(cnpj: string): Promise<CscNFCeStatus>;
|
|
370
445
|
}
|
|
371
446
|
|
|
372
447
|
/**
|
|
@@ -473,16 +548,22 @@ interface TaxPredictionData {
|
|
|
473
548
|
beneficio_fiscal?: string;
|
|
474
549
|
}
|
|
475
550
|
interface TaxPredictionItemInput {
|
|
551
|
+
/** Identificador do item no ERP, devolvido no resultado. */
|
|
552
|
+
id?: string;
|
|
476
553
|
xProd?: string;
|
|
477
554
|
gtin?: string;
|
|
478
555
|
ncm?: string;
|
|
479
556
|
cest?: string;
|
|
557
|
+
/** Substitui a `finalidade` do topo neste item. */
|
|
558
|
+
finalidade?: 'revenda' | 'consumo_final' | 'industrializacao';
|
|
480
559
|
}
|
|
481
560
|
interface TaxPredictionParams {
|
|
482
561
|
regimeTributario: 'simples_nacional' | 'lucro_presumido' | 'lucro_real' | string;
|
|
483
562
|
ufOrigem: string;
|
|
484
563
|
ufDestino?: string;
|
|
564
|
+
/** `revenda`: comprado para revender. `industrializacao`: fabricado pelo vendedor. `consumo_final`: o comprador usa e não revende. */
|
|
485
565
|
finalidade?: 'revenda' | 'consumo_final' | 'industrializacao' | string;
|
|
566
|
+
/** Se o comprador é contribuinte do ICMS (`false` na venda a pessoa física). */
|
|
486
567
|
destinatarioContribuinte?: boolean;
|
|
487
568
|
/** Alíquota de crédito de ICMS do Simples Nacional (pCredSN). */
|
|
488
569
|
aliquotaCreditoIcmsSn?: number;
|
|
@@ -496,6 +577,7 @@ interface TaxPredictionParams {
|
|
|
496
577
|
}
|
|
497
578
|
interface TaxPredictionItemResult {
|
|
498
579
|
item_index: number;
|
|
580
|
+
id?: string | null;
|
|
499
581
|
xProd?: string | null;
|
|
500
582
|
dados_tributarios: TaxPredictionData;
|
|
501
583
|
}
|
|
@@ -508,27 +590,28 @@ interface TaxPredictionResponse {
|
|
|
508
590
|
dados_tributarios?: TaxPredictionData | null;
|
|
509
591
|
resultados?: TaxPredictionItemResult[] | null;
|
|
510
592
|
}
|
|
511
|
-
/**
|
|
512
|
-
* Item do saneamento. A API exige `NCM`/`CEST` em maiúsculas; os nomes `ncm`, `cest`,
|
|
513
|
-
* `descricao` e `gtin` da 1.5 continuam aceitos e são convertidos pelo SDK.
|
|
514
|
-
*/
|
|
593
|
+
/** Item do saneamento, com os mesmos nomes do item da predição. `ncm` é obrigatório. */
|
|
515
594
|
interface FiscalSanitizeItemInput {
|
|
516
|
-
NCM?: string;
|
|
517
|
-
CEST?: string;
|
|
518
|
-
xProd?: string;
|
|
519
|
-
id?: string;
|
|
520
|
-
/** @deprecated Use `NCM`. */
|
|
521
595
|
ncm?: string;
|
|
522
|
-
/** @deprecated Use `CEST`. */
|
|
523
596
|
cest?: string;
|
|
597
|
+
xProd?: string;
|
|
598
|
+
gtin?: string;
|
|
599
|
+
id?: string;
|
|
600
|
+
/** @deprecated Use `ncm`. */
|
|
601
|
+
NCM?: string;
|
|
602
|
+
/** @deprecated Use `cest`. */
|
|
603
|
+
CEST?: string;
|
|
524
604
|
/** @deprecated Use `xProd`. */
|
|
525
605
|
descricao?: string;
|
|
526
|
-
|
|
527
|
-
|
|
606
|
+
}
|
|
607
|
+
interface FiscalSanitizeOptions {
|
|
608
|
+
/** UF de referência das alíquotas e da regra de ST. */
|
|
609
|
+
ufOrigem?: string;
|
|
528
610
|
}
|
|
529
611
|
interface FiscalSanitizeItemResult {
|
|
530
612
|
id?: string;
|
|
531
613
|
xProd?: string;
|
|
614
|
+
gtin?: string | null;
|
|
532
615
|
NCM_informado?: string;
|
|
533
616
|
CEST_informado?: string | null;
|
|
534
617
|
auditoria_fiscal: Record<string, any>;
|
|
@@ -548,9 +631,9 @@ declare class FiscalResource extends BaseResource {
|
|
|
548
631
|
predict(params: TaxPredictionParams): Promise<TaxPredictionResponse>;
|
|
549
632
|
/**
|
|
550
633
|
* Audita e higieniza uma lista de produtos em lote perante as tabelas fiscais vigentes.
|
|
551
|
-
* Cada item precisa de `
|
|
634
|
+
* Cada item precisa de `ncm`; `cest`, `xProd`, `gtin` e `id` são opcionais.
|
|
552
635
|
*/
|
|
553
|
-
sanitize(itens: FiscalSanitizeItemInput[]): Promise<FiscalSanitizeResponse>;
|
|
636
|
+
sanitize(itens: FiscalSanitizeItemInput[], opcoes?: FiscalSanitizeOptions): Promise<FiscalSanitizeResponse>;
|
|
554
637
|
}
|
|
555
638
|
|
|
556
639
|
interface EnderecoNFSeInput {
|
|
@@ -867,6 +950,7 @@ declare class PairusProductData {
|
|
|
867
950
|
readonly emissao: EmissaoResource;
|
|
868
951
|
readonly nfse: NFSeResource;
|
|
869
952
|
readonly dfe: DFeResource;
|
|
953
|
+
readonly empresas: EmpresasResource;
|
|
870
954
|
constructor(options?: PairusClientOptions);
|
|
871
955
|
}
|
|
872
956
|
|
|
@@ -897,4 +981,4 @@ declare class NetworkError extends PairusError {
|
|
|
897
981
|
constructor(message: string);
|
|
898
982
|
}
|
|
899
983
|
|
|
900
|
-
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, type CertificadoDFe, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, type EmissaoOptions, type EmissaoPagamentoInput, EmissaoResource, type EnderecoNFSeInput, type EnviarCertificadoDFeInput, type EnviarCertificadoDFeResponse, type EventoNFeResponse, FiscalResource, type FiscalSanitizeItemInput, type FiscalSanitizeItemResult, type FiscalSanitizeResponse, type FuelData, type IBSCBSData, type InutilizacaoInput, InvalidSignatureError, type ListarDocumentosDFeParams, type ListarDocumentosDFeResponse, type ManifestarDFeInput, type ManifestarDFeResponse, type NFSeEmissaoInput, type NFSeEmissaoResponse, NFSeResource, NetworkError, PairusAPIError, type PairusClientOptions, PairusError, PairusProductData, type PrestadorNFSeInput, type ProductDetails, type ProductEnrichedDetails, type ProductResponse, type ProductSearchResponse, type ProductSearchResultItem, ProductsResource, RateLimitError, type ReformaTributariaServicoInput, type RetencoesFederaisInput, type SelectiveTaxData, type ServicoNFSeInput, type SincronizarDFeInput, type SincronizarDFeResponse, type StatusCertificadoDFeResponse, type TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type TipoManifestacaoDFe, type TomadorNFSeInput, type WebhookEvent, Webhooks };
|
|
984
|
+
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, type CertificadoDFe, type CscAmbienteStatus, type CscNFCeInput, type CscNFCeStatus, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, type EmissaoOptions, type EmissaoPagamentoInput, EmissaoResource, EmpresasResource, type EnderecoNFSeInput, type EnviarCertificadoDFeInput, type EnviarCertificadoDFeResponse, type EventoNFeResponse, FiscalResource, type FiscalSanitizeItemInput, type FiscalSanitizeItemResult, type FiscalSanitizeOptions, type FiscalSanitizeResponse, type FuelData, type IBSCBSData, type InutilizacaoInput, InvalidSignatureError, type ListarDocumentosDFeParams, type ListarDocumentosDFeResponse, type ManifestarDFeInput, type ManifestarDFeResponse, type NFSeEmissaoInput, type NFSeEmissaoResponse, NFSeResource, NetworkError, type NotaEmitidaResponse, PairusAPIError, type PairusClientOptions, PairusError, PairusProductData, type PrestadorNFSeInput, type ProductDetails, type ProductEnrichedDetails, type ProductResponse, type ProductSearchResponse, type ProductSearchResultItem, ProductsResource, RateLimitError, type ReformaTributariaServicoInput, type RetencoesFederaisInput, type SelectiveTaxData, type ServicoNFSeInput, type SincronizarDFeInput, type SincronizarDFeResponse, type StatusCertificadoDFeResponse, type TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type TipoManifestacaoDFe, type TomadorNFSeInput, type WebhookEvent, Webhooks };
|
package/dist/index.d.ts
CHANGED
|
@@ -271,6 +271,8 @@ interface EmissaoNFeInput {
|
|
|
271
271
|
cnpj: string;
|
|
272
272
|
id_cadastro: string;
|
|
273
273
|
};
|
|
274
|
+
/** Identificador da venda no seu sistema; volta nos webhooks e localiza a nota em `buscarPorReferencia`. */
|
|
275
|
+
referencia_externa?: string;
|
|
274
276
|
[key: string]: any;
|
|
275
277
|
}
|
|
276
278
|
/** Opções de envio da emissão. */
|
|
@@ -301,6 +303,8 @@ interface EmissaoNFeResponse {
|
|
|
301
303
|
data_emissao?: string | null;
|
|
302
304
|
ambiente?: string;
|
|
303
305
|
tipo_documento?: string;
|
|
306
|
+
/** Identificador da venda informado na emissão. */
|
|
307
|
+
referencia_externa?: string | null;
|
|
304
308
|
autocura_aplicada?: boolean;
|
|
305
309
|
xml_autorizado_base64?: string | null;
|
|
306
310
|
danfe_pdf_base64?: string | null;
|
|
@@ -341,6 +345,48 @@ interface InutilizacaoInput {
|
|
|
341
345
|
/** '55' (NF-e) ou '65' (NFC-e). */
|
|
342
346
|
modelo?: '55' | '65' | 55 | 65;
|
|
343
347
|
}
|
|
348
|
+
/** Situação atual de uma nota emitida (`GET /v1/nfe/{chave}` e `GET /v1/nfe?referencia_externa=`). */
|
|
349
|
+
interface NotaEmitidaResponse {
|
|
350
|
+
chave_acesso: string;
|
|
351
|
+
tipo_documento?: 'NFE' | 'NFCE' | null;
|
|
352
|
+
serie?: number | null;
|
|
353
|
+
numero?: number | null;
|
|
354
|
+
/** 'AUTORIZADA', 'PENDENTE_RETORNO', 'CONTINGENCIA', 'CANCELADA', 'REJEITADA'... */
|
|
355
|
+
status_sefaz?: string | null;
|
|
356
|
+
cStat?: number | null;
|
|
357
|
+
xMotivo?: string | null;
|
|
358
|
+
protocolo?: string | null;
|
|
359
|
+
data_emissao?: string | null;
|
|
360
|
+
ambiente?: string | null;
|
|
361
|
+
cnpj_emitente?: string | null;
|
|
362
|
+
referencia_externa?: string | null;
|
|
363
|
+
valor_total?: number | null;
|
|
364
|
+
qrcode_url?: string | null;
|
|
365
|
+
substituida_por?: string | null;
|
|
366
|
+
chave_substituida?: string | null;
|
|
367
|
+
prazo_transmissao?: string | null;
|
|
368
|
+
/** procNFe em Base64, só com `incluirXml: true`. */
|
|
369
|
+
xml_autorizado_base64?: string | null;
|
|
370
|
+
}
|
|
371
|
+
/** Situação do CSC em um ambiente. O código nunca é devolvido pela API. */
|
|
372
|
+
interface CscAmbienteStatus {
|
|
373
|
+
configurado: boolean;
|
|
374
|
+
csc_id?: string | null;
|
|
375
|
+
}
|
|
376
|
+
/** Situação do CSC da NFC-e do estabelecimento (`/v1/empresas/{cnpj}/csc`). */
|
|
377
|
+
interface CscNFCeStatus {
|
|
378
|
+
cnpj: string;
|
|
379
|
+
producao: CscAmbienteStatus;
|
|
380
|
+
homologacao: CscAmbienteStatus;
|
|
381
|
+
}
|
|
382
|
+
/** CSC gerado no portal da SEFAZ da UF, por ambiente. */
|
|
383
|
+
interface CscNFCeInput {
|
|
384
|
+
ambiente: 'producao' | 'homologacao';
|
|
385
|
+
/** Identificador do CSC (ex: '000001'). */
|
|
386
|
+
csc_id: string;
|
|
387
|
+
/** Código do CSC (16 a 36 letras e números). */
|
|
388
|
+
csc_codigo: string;
|
|
389
|
+
}
|
|
344
390
|
|
|
345
391
|
declare class EmissaoResource extends BaseResource {
|
|
346
392
|
/**
|
|
@@ -367,6 +413,35 @@ declare class EmissaoResource extends BaseResource {
|
|
|
367
413
|
* Inutiliza uma faixa de numeração quebrada na SEFAZ (Ajuste SINIEF 07/05).
|
|
368
414
|
*/
|
|
369
415
|
inutilizar(params: InutilizacaoInput): Promise<EventoNFeResponse>;
|
|
416
|
+
/**
|
|
417
|
+
* Consulta a situação atual de uma NF-e ou NFC-e emitida pela sua conta.
|
|
418
|
+
*
|
|
419
|
+
* @param chaveAcesso Chave de 44 dígitos da nota
|
|
420
|
+
* @param options `incluirXml` traz o procNFe em Base64
|
|
421
|
+
*/
|
|
422
|
+
consultar(chaveAcesso: string, options?: {
|
|
423
|
+
incluirXml?: boolean;
|
|
424
|
+
}): Promise<NotaEmitidaResponse>;
|
|
425
|
+
/**
|
|
426
|
+
* Localiza as notas emitidas para uma venda pela `referencia_externa` informada na emissão.
|
|
427
|
+
* Lista vazia: nenhuma nota gravada para a venda, é seguro emitir.
|
|
428
|
+
*/
|
|
429
|
+
buscarPorReferencia(cnpjEmitente: string, referenciaExterna: string): Promise<NotaEmitidaResponse[]>;
|
|
430
|
+
/**
|
|
431
|
+
* Baixa o DANFE em PDF de uma nota emitida (na contingência ainda não transmitida, com a tarja).
|
|
432
|
+
*/
|
|
433
|
+
baixarDanfe(chaveAcesso: string): Promise<ArrayBuffer>;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** Cadastro de empresas emitentes (CSC da NFC-e). */
|
|
437
|
+
declare class EmpresasResource extends BaseResource {
|
|
438
|
+
/**
|
|
439
|
+
* Grava o CSC da NFC-e do estabelecimento (gerado no portal da SEFAZ da UF).
|
|
440
|
+
* O estabelecimento precisa de certificado próprio na conta; o código nunca é devolvido.
|
|
441
|
+
*/
|
|
442
|
+
configurarCsc(cnpj: string, input: CscNFCeInput): Promise<CscNFCeStatus>;
|
|
443
|
+
/** Indica, por ambiente, se o CSC da NFC-e está configurado (sem devolver o código). */
|
|
444
|
+
consultarCsc(cnpj: string): Promise<CscNFCeStatus>;
|
|
370
445
|
}
|
|
371
446
|
|
|
372
447
|
/**
|
|
@@ -473,16 +548,22 @@ interface TaxPredictionData {
|
|
|
473
548
|
beneficio_fiscal?: string;
|
|
474
549
|
}
|
|
475
550
|
interface TaxPredictionItemInput {
|
|
551
|
+
/** Identificador do item no ERP, devolvido no resultado. */
|
|
552
|
+
id?: string;
|
|
476
553
|
xProd?: string;
|
|
477
554
|
gtin?: string;
|
|
478
555
|
ncm?: string;
|
|
479
556
|
cest?: string;
|
|
557
|
+
/** Substitui a `finalidade` do topo neste item. */
|
|
558
|
+
finalidade?: 'revenda' | 'consumo_final' | 'industrializacao';
|
|
480
559
|
}
|
|
481
560
|
interface TaxPredictionParams {
|
|
482
561
|
regimeTributario: 'simples_nacional' | 'lucro_presumido' | 'lucro_real' | string;
|
|
483
562
|
ufOrigem: string;
|
|
484
563
|
ufDestino?: string;
|
|
564
|
+
/** `revenda`: comprado para revender. `industrializacao`: fabricado pelo vendedor. `consumo_final`: o comprador usa e não revende. */
|
|
485
565
|
finalidade?: 'revenda' | 'consumo_final' | 'industrializacao' | string;
|
|
566
|
+
/** Se o comprador é contribuinte do ICMS (`false` na venda a pessoa física). */
|
|
486
567
|
destinatarioContribuinte?: boolean;
|
|
487
568
|
/** Alíquota de crédito de ICMS do Simples Nacional (pCredSN). */
|
|
488
569
|
aliquotaCreditoIcmsSn?: number;
|
|
@@ -496,6 +577,7 @@ interface TaxPredictionParams {
|
|
|
496
577
|
}
|
|
497
578
|
interface TaxPredictionItemResult {
|
|
498
579
|
item_index: number;
|
|
580
|
+
id?: string | null;
|
|
499
581
|
xProd?: string | null;
|
|
500
582
|
dados_tributarios: TaxPredictionData;
|
|
501
583
|
}
|
|
@@ -508,27 +590,28 @@ interface TaxPredictionResponse {
|
|
|
508
590
|
dados_tributarios?: TaxPredictionData | null;
|
|
509
591
|
resultados?: TaxPredictionItemResult[] | null;
|
|
510
592
|
}
|
|
511
|
-
/**
|
|
512
|
-
* Item do saneamento. A API exige `NCM`/`CEST` em maiúsculas; os nomes `ncm`, `cest`,
|
|
513
|
-
* `descricao` e `gtin` da 1.5 continuam aceitos e são convertidos pelo SDK.
|
|
514
|
-
*/
|
|
593
|
+
/** Item do saneamento, com os mesmos nomes do item da predição. `ncm` é obrigatório. */
|
|
515
594
|
interface FiscalSanitizeItemInput {
|
|
516
|
-
NCM?: string;
|
|
517
|
-
CEST?: string;
|
|
518
|
-
xProd?: string;
|
|
519
|
-
id?: string;
|
|
520
|
-
/** @deprecated Use `NCM`. */
|
|
521
595
|
ncm?: string;
|
|
522
|
-
/** @deprecated Use `CEST`. */
|
|
523
596
|
cest?: string;
|
|
597
|
+
xProd?: string;
|
|
598
|
+
gtin?: string;
|
|
599
|
+
id?: string;
|
|
600
|
+
/** @deprecated Use `ncm`. */
|
|
601
|
+
NCM?: string;
|
|
602
|
+
/** @deprecated Use `cest`. */
|
|
603
|
+
CEST?: string;
|
|
524
604
|
/** @deprecated Use `xProd`. */
|
|
525
605
|
descricao?: string;
|
|
526
|
-
|
|
527
|
-
|
|
606
|
+
}
|
|
607
|
+
interface FiscalSanitizeOptions {
|
|
608
|
+
/** UF de referência das alíquotas e da regra de ST. */
|
|
609
|
+
ufOrigem?: string;
|
|
528
610
|
}
|
|
529
611
|
interface FiscalSanitizeItemResult {
|
|
530
612
|
id?: string;
|
|
531
613
|
xProd?: string;
|
|
614
|
+
gtin?: string | null;
|
|
532
615
|
NCM_informado?: string;
|
|
533
616
|
CEST_informado?: string | null;
|
|
534
617
|
auditoria_fiscal: Record<string, any>;
|
|
@@ -548,9 +631,9 @@ declare class FiscalResource extends BaseResource {
|
|
|
548
631
|
predict(params: TaxPredictionParams): Promise<TaxPredictionResponse>;
|
|
549
632
|
/**
|
|
550
633
|
* Audita e higieniza uma lista de produtos em lote perante as tabelas fiscais vigentes.
|
|
551
|
-
* Cada item precisa de `
|
|
634
|
+
* Cada item precisa de `ncm`; `cest`, `xProd`, `gtin` e `id` são opcionais.
|
|
552
635
|
*/
|
|
553
|
-
sanitize(itens: FiscalSanitizeItemInput[]): Promise<FiscalSanitizeResponse>;
|
|
636
|
+
sanitize(itens: FiscalSanitizeItemInput[], opcoes?: FiscalSanitizeOptions): Promise<FiscalSanitizeResponse>;
|
|
554
637
|
}
|
|
555
638
|
|
|
556
639
|
interface EnderecoNFSeInput {
|
|
@@ -867,6 +950,7 @@ declare class PairusProductData {
|
|
|
867
950
|
readonly emissao: EmissaoResource;
|
|
868
951
|
readonly nfse: NFSeResource;
|
|
869
952
|
readonly dfe: DFeResource;
|
|
953
|
+
readonly empresas: EmpresasResource;
|
|
870
954
|
constructor(options?: PairusClientOptions);
|
|
871
955
|
}
|
|
872
956
|
|
|
@@ -897,4 +981,4 @@ declare class NetworkError extends PairusError {
|
|
|
897
981
|
constructor(message: string);
|
|
898
982
|
}
|
|
899
983
|
|
|
900
|
-
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, type CertificadoDFe, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, type EmissaoOptions, type EmissaoPagamentoInput, EmissaoResource, type EnderecoNFSeInput, type EnviarCertificadoDFeInput, type EnviarCertificadoDFeResponse, type EventoNFeResponse, FiscalResource, type FiscalSanitizeItemInput, type FiscalSanitizeItemResult, type FiscalSanitizeResponse, type FuelData, type IBSCBSData, type InutilizacaoInput, InvalidSignatureError, type ListarDocumentosDFeParams, type ListarDocumentosDFeResponse, type ManifestarDFeInput, type ManifestarDFeResponse, type NFSeEmissaoInput, type NFSeEmissaoResponse, NFSeResource, NetworkError, PairusAPIError, type PairusClientOptions, PairusError, PairusProductData, type PrestadorNFSeInput, type ProductDetails, type ProductEnrichedDetails, type ProductResponse, type ProductSearchResponse, type ProductSearchResultItem, ProductsResource, RateLimitError, type ReformaTributariaServicoInput, type RetencoesFederaisInput, type SelectiveTaxData, type ServicoNFSeInput, type SincronizarDFeInput, type SincronizarDFeResponse, type StatusCertificadoDFeResponse, type TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type TipoManifestacaoDFe, type TomadorNFSeInput, type WebhookEvent, Webhooks };
|
|
984
|
+
export { AuthenticationError, type CancelamentoInput, type CancelamentoNFSeInput, type CancelamentoNFSeResponse, type CartaCorrecaoInput, type CertificadoDFe, type CscAmbienteStatus, type CscNFCeInput, type CscNFCeStatus, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, DFeResource, type DocumentoDFe, type EmissaoDestinatarioInput, type EmissaoItemInput, type EmissaoNFeInput, type EmissaoNFeResponse, type EmissaoOptions, type EmissaoPagamentoInput, EmissaoResource, EmpresasResource, type EnderecoNFSeInput, type EnviarCertificadoDFeInput, type EnviarCertificadoDFeResponse, type EventoNFeResponse, FiscalResource, type FiscalSanitizeItemInput, type FiscalSanitizeItemResult, type FiscalSanitizeOptions, type FiscalSanitizeResponse, type FuelData, type IBSCBSData, type InutilizacaoInput, InvalidSignatureError, type ListarDocumentosDFeParams, type ListarDocumentosDFeResponse, type ManifestarDFeInput, type ManifestarDFeResponse, type NFSeEmissaoInput, type NFSeEmissaoResponse, NFSeResource, NetworkError, type NotaEmitidaResponse, PairusAPIError, type PairusClientOptions, PairusError, PairusProductData, type PrestadorNFSeInput, type ProductDetails, type ProductEnrichedDetails, type ProductResponse, type ProductSearchResponse, type ProductSearchResultItem, ProductsResource, RateLimitError, type ReformaTributariaServicoInput, type RetencoesFederaisInput, type SelectiveTaxData, type ServicoNFSeInput, type SincronizarDFeInput, type SincronizarDFeResponse, type StatusCertificadoDFeResponse, type TaxPredictionData, type TaxPredictionItemInput, type TaxPredictionItemResult, type TaxPredictionParams, type TaxPredictionResponse, type TipoManifestacaoDFe, type TomadorNFSeInput, type WebhookEvent, Webhooks };
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
DEFAULT_TIMEOUT_MS: () => DEFAULT_TIMEOUT_MS,
|
|
37
37
|
DFeResource: () => DFeResource,
|
|
38
38
|
EmissaoResource: () => EmissaoResource,
|
|
39
|
+
EmpresasResource: () => EmpresasResource,
|
|
39
40
|
FiscalResource: () => FiscalResource,
|
|
40
41
|
InvalidSignatureError: () => InvalidSignatureError,
|
|
41
42
|
NFSeResource: () => NFSeResource,
|
|
@@ -125,7 +126,7 @@ var BaseResource = class {
|
|
|
125
126
|
const reqHeaders = {
|
|
126
127
|
"Accept": "application/json",
|
|
127
128
|
"X-API-Key": this.apiKey,
|
|
128
|
-
"User-Agent": "Pairus-NodeJS-SDK/1.
|
|
129
|
+
"User-Agent": "Pairus-NodeJS-SDK/1.17.0",
|
|
129
130
|
...options.headers || {}
|
|
130
131
|
};
|
|
131
132
|
const isFormData = typeof FormData !== "undefined" && options.body instanceof FormData;
|
|
@@ -196,7 +197,7 @@ var BaseResource = class {
|
|
|
196
197
|
const reqHeaders = {
|
|
197
198
|
"Accept": "*/*",
|
|
198
199
|
"X-API-Key": this.apiKey,
|
|
199
|
-
"User-Agent": "Pairus-NodeJS-SDK/1.
|
|
200
|
+
"User-Agent": "Pairus-NodeJS-SDK/1.17.0",
|
|
200
201
|
...options.headers || {}
|
|
201
202
|
};
|
|
202
203
|
let lastError = null;
|
|
@@ -255,7 +256,7 @@ var BaseResource = class {
|
|
|
255
256
|
const reqHeaders = {
|
|
256
257
|
"Accept": "*/*",
|
|
257
258
|
"X-API-Key": this.apiKey,
|
|
258
|
-
"User-Agent": "Pairus-NodeJS-SDK/1.
|
|
259
|
+
"User-Agent": "Pairus-NodeJS-SDK/1.17.0",
|
|
259
260
|
...options.headers || {}
|
|
260
261
|
};
|
|
261
262
|
let lastError = null;
|
|
@@ -503,6 +504,51 @@ var EmissaoResource = class extends BaseResource {
|
|
|
503
504
|
}
|
|
504
505
|
});
|
|
505
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* Consulta a situação atual de uma NF-e ou NFC-e emitida pela sua conta.
|
|
509
|
+
*
|
|
510
|
+
* @param chaveAcesso Chave de 44 dígitos da nota
|
|
511
|
+
* @param options `incluirXml` traz o procNFe em Base64
|
|
512
|
+
*/
|
|
513
|
+
async consultar(chaveAcesso, options) {
|
|
514
|
+
return this.request({
|
|
515
|
+
method: "GET",
|
|
516
|
+
path: `/v1/nfe/${chaveAcesso}`,
|
|
517
|
+
params: { incluir_xml: String(options?.incluirXml ?? false) }
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Localiza as notas emitidas para uma venda pela `referencia_externa` informada na emissão.
|
|
522
|
+
* Lista vazia: nenhuma nota gravada para a venda, é seguro emitir.
|
|
523
|
+
*/
|
|
524
|
+
async buscarPorReferencia(cnpjEmitente, referenciaExterna) {
|
|
525
|
+
return this.request({
|
|
526
|
+
method: "GET",
|
|
527
|
+
path: "/v1/nfe",
|
|
528
|
+
params: { cnpj_emitente: cnpjEmitente, referencia_externa: referenciaExterna }
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
/**
|
|
532
|
+
* Baixa o DANFE em PDF de uma nota emitida (na contingência ainda não transmitida, com a tarja).
|
|
533
|
+
*/
|
|
534
|
+
async baixarDanfe(chaveAcesso) {
|
|
535
|
+
return this.requestBinary({ method: "GET", path: `/v1/nfe/${chaveAcesso}/danfe` });
|
|
536
|
+
}
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
// src/resources/empresas.ts
|
|
540
|
+
var EmpresasResource = class extends BaseResource {
|
|
541
|
+
/**
|
|
542
|
+
* Grava o CSC da NFC-e do estabelecimento (gerado no portal da SEFAZ da UF).
|
|
543
|
+
* O estabelecimento precisa de certificado próprio na conta; o código nunca é devolvido.
|
|
544
|
+
*/
|
|
545
|
+
async configurarCsc(cnpj, input) {
|
|
546
|
+
return this.request({ method: "PUT", path: `/v1/empresas/${cnpj}/csc`, body: input });
|
|
547
|
+
}
|
|
548
|
+
/** Indica, por ambiente, se o CSC da NFC-e está configurado (sem devolver o código). */
|
|
549
|
+
async consultarCsc(cnpj) {
|
|
550
|
+
return this.request({ method: "GET", path: `/v1/empresas/${cnpj}/csc` });
|
|
551
|
+
}
|
|
506
552
|
};
|
|
507
553
|
|
|
508
554
|
// src/resources/fiscal.ts
|
|
@@ -526,10 +572,11 @@ function itemDeSaneamento(item) {
|
|
|
526
572
|
const { NCM, CEST, xProd, id, ncm, cest, descricao, gtin, ...extras } = item;
|
|
527
573
|
const convertido = {
|
|
528
574
|
...extras,
|
|
529
|
-
|
|
530
|
-
|
|
575
|
+
ncm: ncm ?? NCM,
|
|
576
|
+
cest: cest ?? CEST,
|
|
531
577
|
xProd: xProd ?? descricao,
|
|
532
|
-
|
|
578
|
+
gtin,
|
|
579
|
+
id
|
|
533
580
|
};
|
|
534
581
|
return Object.fromEntries(Object.entries(convertido).filter(([, v]) => v !== void 0 && v !== null));
|
|
535
582
|
}
|
|
@@ -566,13 +613,13 @@ var FiscalResource = class extends BaseResource {
|
|
|
566
613
|
}
|
|
567
614
|
/**
|
|
568
615
|
* Audita e higieniza uma lista de produtos em lote perante as tabelas fiscais vigentes.
|
|
569
|
-
* Cada item precisa de `
|
|
616
|
+
* Cada item precisa de `ncm`; `cest`, `xProd`, `gtin` e `id` são opcionais.
|
|
570
617
|
*/
|
|
571
|
-
async sanitize(itens) {
|
|
618
|
+
async sanitize(itens, opcoes = {}) {
|
|
572
619
|
return this.request({
|
|
573
620
|
method: "POST",
|
|
574
621
|
path: "/v2/fiscal/sanitize",
|
|
575
|
-
body: { itens: itens.map(itemDeSaneamento) }
|
|
622
|
+
body: { ...opcoes.ufOrigem ? { uf_origem: opcoes.ufOrigem } : {}, itens: itens.map(itemDeSaneamento) }
|
|
576
623
|
});
|
|
577
624
|
}
|
|
578
625
|
};
|
|
@@ -825,6 +872,7 @@ var PairusProductData = class {
|
|
|
825
872
|
emissao;
|
|
826
873
|
nfse;
|
|
827
874
|
dfe;
|
|
875
|
+
empresas;
|
|
828
876
|
constructor(options) {
|
|
829
877
|
const apiKey = options?.apiKey || (typeof process !== "undefined" ? process.env.PAIRUS_API_KEY : void 0);
|
|
830
878
|
if (!apiKey) {
|
|
@@ -840,6 +888,7 @@ var PairusProductData = class {
|
|
|
840
888
|
this.emissao = new EmissaoResource(apiKey, baseUrl, timeoutMs, maxRetries);
|
|
841
889
|
this.nfse = new NFSeResource(apiKey, baseUrl, timeoutMs, maxRetries);
|
|
842
890
|
this.dfe = new DFeResource(apiKey, baseUrl, timeoutMs, maxRetries);
|
|
891
|
+
this.empresas = new EmpresasResource(apiKey, baseUrl, timeoutMs, maxRetries);
|
|
843
892
|
}
|
|
844
893
|
};
|
|
845
894
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -850,6 +899,7 @@ var PairusProductData = class {
|
|
|
850
899
|
DEFAULT_TIMEOUT_MS,
|
|
851
900
|
DFeResource,
|
|
852
901
|
EmissaoResource,
|
|
902
|
+
EmpresasResource,
|
|
853
903
|
FiscalResource,
|
|
854
904
|
InvalidSignatureError,
|
|
855
905
|
NFSeResource,
|