diff --git a/README.md b/README.md index 66445d6..835efe4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Pacote de integração com a [API v3 do ERP Bling](https://developer.bling.com.br) para Javascript/TypeScript. O mais completo existente. -Atualizado com a versão `v305` da API ([veja o registro de alterações](https://developer.bling.com.br/changelogs#2024-07-04)). +Atualizado com a versão `v306` da API ([veja o registro de alterações](https://developer.bling.com.br/changelogs#2024-08-16)). **Atenção**: a versão 5.0.0+ do `bling-erp-api` para Javascript/TypeScript utiliza a API v3 do Bling. Caso deseja utilizar a API v2 do Bling, diff --git a/src/entities/nfces/__tests__/create-response.ts b/src/entities/nfces/__tests__/create-response.ts index e78705b..e6a110f 100644 --- a/src/entities/nfces/__tests__/create-response.ts +++ b/src/entities/nfces/__tests__/create-response.ts @@ -101,7 +101,7 @@ export const createRequestBody = { }, volume: { quantidade: 5, - especie: 'Volumes', + especie: 1 as const, numero: '1', pesoBruto: 0.5, pesoLiquido: 0.35 diff --git a/src/entities/nfces/__tests__/find-response.ts b/src/entities/nfces/__tests__/find-response.ts index 7a7f77a..b3b480b 100644 --- a/src/entities/nfces/__tests__/find-response.ts +++ b/src/entities/nfces/__tests__/find-response.ts @@ -3,26 +3,26 @@ export default { id: 12345678, tipo: 1 as const, situacao: 1 as const, - numero: '6541', - dataEmissao: '2023-01-12 09:52:12', - dataOperacao: '2023-01-12 09:52:12', + numero: "6541", + dataEmissao: "2023-01-12 09:52:12", + dataOperacao: "2023-01-12 09:52:12", contato: { id: 12345678, - nome: 'Contato do Bling', - numeroDocumento: '30188025000121', - ie: '7364873393', - rg: '451838701', - telefone: '54 3771-7278', - email: 'pedrosilva@bling.com.br', + nome: "Contato do Bling", + numeroDocumento: "30188025000121", + ie: "7364873393", + rg: "451838701", + telefone: "54 3771-7278", + email: "pedrosilva@bling.com.br", endereco: { - endereco: 'Olavo Bilac', - numero: '914', - complemento: 'Sala 101', - bairro: 'Imigrante', - cep: '95702-000', - municipio: 'Bento Gonçalves', - uf: 'RS' as const, - pais: '' + endereco: "Olavo Bilac", + numero: "914", + complemento: "Sala 101", + bairro: "Imigrante", + cep: "95702-000", + municipio: "Bento Gonçalves", + uf: "RS" as const, + pais: "" } }, naturezaOperacao: { @@ -31,6 +31,37 @@ export default { loja: { id: 12345678 }, - serie: '1' + serie: 1, + valorNota: 10.3, + chaveAcesso: "string", + xml: "string", + linkDanfe: "string", + linkPDF: "string", + numeroPedidoLoja: "string", + transporte: { + fretePorConta: 0 as const, + transportador: { + nome: "Transportador", + numeroDocumento: "30188025000121" + }, + volumes: [ + { + id: 12345678 + } + ], + etiqueta: { + nome: "Transportador", + endereco: "Olavo Bilac", + numero: "914", + complemento: "Sala 101", + municipio: "Bento Gonçalves", + uf: "RS" as const, + cep: "95702-000", + bairro: "Imigrante" + } + }, + vendedor: { + id: 12345679 + } } } diff --git a/src/entities/nfces/__tests__/update-response.ts b/src/entities/nfces/__tests__/update-response.ts index 811dd57..0452b5f 100644 --- a/src/entities/nfces/__tests__/update-response.ts +++ b/src/entities/nfces/__tests__/update-response.ts @@ -101,7 +101,7 @@ export const updateRequestBody = { }, volume: { quantidade: 5, - especie: 'Volumes', + especie: 1 as const, numero: '1', pesoBruto: 0.5, pesoLiquido: 0.35 diff --git a/src/entities/nfces/interfaces/create.interface.ts b/src/entities/nfces/interfaces/create.interface.ts index be6bbc6..55f2c93 100644 --- a/src/entities/nfces/interfaces/create.interface.ts +++ b/src/entities/nfces/interfaces/create.interface.ts @@ -7,6 +7,7 @@ import ITipoPessoa from 'src/entities/@shared/types/tipoPessoa.type' import IUF from 'src/entities/@shared/types/uf.type' import { IFinalidadeNfce } from '../types/finalidade.type' import { ITipoNfce } from '../types/tipo.type' +import { IEspecie } from '../types/especie.type' export interface ICreateBody { tipo: ITipoNfce @@ -94,7 +95,7 @@ export interface ICreateBody { } volume?: { quantidade?: number - especie?: string + especie?: IEspecie numero?: string pesoBruto?: number pesoLiquido?: number diff --git a/src/entities/nfces/interfaces/find.interface.ts b/src/entities/nfces/interfaces/find.interface.ts index c7d8e9c..25f9fcc 100644 --- a/src/entities/nfces/interfaces/find.interface.ts +++ b/src/entities/nfces/interfaces/find.interface.ts @@ -1,6 +1,7 @@ import IUF from 'src/entities/@shared/types/uf.type' import { ISituacaoNfce } from '../types/situacao.type' import { ITipoNfce } from '../types/tipo.type' +import IFretePorConta from 'src/entities/@shared/types/frete-por-conta.type' export interface IFindParams { /** @@ -38,6 +39,33 @@ export interface IFindResponse { } naturezaOperacao?: { id: number } loja?: { id: number } - serie: string + serie: number + valorNota?: number + chaveAcesso?: string + xml?: string + linkDanfe?: string + linkPDF?: string + numeroPedidoLoja?: string + transporte?: { + fretePorConta?: IFretePorConta + transportador?: { + nome: string + numeroDocumento?: string + } + volumes?: { id?: number }[] + etiqueta?: { + nome?: string + endereco?: string + numero?: string + complemento?: string + municipio?: string + uf?: IUF + cep?: string + bairro?: string + } + } + vendedor?: { + id: number + } } } diff --git a/src/entities/nfces/interfaces/update.interface.ts b/src/entities/nfces/interfaces/update.interface.ts index b7c85a5..214b631 100644 --- a/src/entities/nfces/interfaces/update.interface.ts +++ b/src/entities/nfces/interfaces/update.interface.ts @@ -7,6 +7,7 @@ import ITipoPessoa from 'src/entities/@shared/types/tipoPessoa.type' import IUF from 'src/entities/@shared/types/uf.type' import { IFinalidadeNfce } from '../types/finalidade.type' import { ITipoNfce } from '../types/tipo.type' +import { IEspecie } from '../types/especie.type' export interface IUpdateParams { /** @@ -101,7 +102,7 @@ export interface IUpdateBody { } volume?: { quantidade?: number - especie?: string + especie?: IEspecie numero?: string pesoBruto?: number pesoLiquido?: number diff --git a/src/entities/nfces/types/especie.type.ts b/src/entities/nfces/types/especie.type.ts new file mode 100644 index 0000000..2b1242b --- /dev/null +++ b/src/entities/nfces/types/especie.type.ts @@ -0,0 +1,19 @@ +/** + * - `1`: Outro(s) + * - `2`: Volume(s) + * - `3`: Unidade(s) + * - `4`: Caixa(s) + * - `5`: Pacote(s) + * - `6`: Envelope(s) + * - `7`: Pallet(s) + * - `8`: Saco(s) + */ +export type IEspecie = + | 1 + | 2 + | 3 + | 4 + | 5 + | 6 + | 7 + | 8 diff --git a/src/entities/nfes/__tests__/create-response.ts b/src/entities/nfes/__tests__/create-response.ts index e78705b..e6a110f 100644 --- a/src/entities/nfes/__tests__/create-response.ts +++ b/src/entities/nfes/__tests__/create-response.ts @@ -101,7 +101,7 @@ export const createRequestBody = { }, volume: { quantidade: 5, - especie: 'Volumes', + especie: 1 as const, numero: '1', pesoBruto: 0.5, pesoLiquido: 0.35 diff --git a/src/entities/nfes/__tests__/find-response.ts b/src/entities/nfes/__tests__/find-response.ts index c07e9e5..b3b480b 100644 --- a/src/entities/nfes/__tests__/find-response.ts +++ b/src/entities/nfes/__tests__/find-response.ts @@ -3,26 +3,26 @@ export default { id: 12345678, tipo: 1 as const, situacao: 1 as const, - numero: '6541', - dataEmissao: '2023-01-12 09:52:12', - dataOperacao: '2023-01-12 09:52:12', + numero: "6541", + dataEmissao: "2023-01-12 09:52:12", + dataOperacao: "2023-01-12 09:52:12", contato: { id: 12345678, - nome: 'Contato do Bling', - numeroDocumento: '30188025000121', - ie: '7364873393', - rg: '451838701', - telefone: '54 3771-7278', - email: 'pedrosilva@bling.com.br', + nome: "Contato do Bling", + numeroDocumento: "30188025000121", + ie: "7364873393", + rg: "451838701", + telefone: "54 3771-7278", + email: "pedrosilva@bling.com.br", endereco: { - endereco: 'Olavo Bilac', - numero: '914', - complemento: 'Sala 101', - bairro: 'Imigrante', - cep: '95702-000', - municipio: 'Bento Gonçalves', - uf: 'RS' as const, - pais: '' + endereco: "Olavo Bilac", + numero: "914", + complemento: "Sala 101", + bairro: "Imigrante", + cep: "95702-000", + municipio: "Bento Gonçalves", + uf: "RS" as const, + pais: "" } }, naturezaOperacao: { @@ -32,15 +32,17 @@ export default { id: 12345678 }, serie: 1, - chaveAcesso: 'string', - xml: 'string', - linkDanfe: 'string', - linkPDF: 'string', + valorNota: 10.3, + chaveAcesso: "string", + xml: "string", + linkDanfe: "string", + linkPDF: "string", + numeroPedidoLoja: "string", transporte: { fretePorConta: 0 as const, transportador: { - nome: 'Transportador', - numeroDocumento: '30188025000121' + nome: "Transportador", + numeroDocumento: "30188025000121" }, volumes: [ { @@ -48,15 +50,18 @@ export default { } ], etiqueta: { - nome: 'Transportador', - endereco: 'Olavo Bilac', - numero: '914', - complemento: 'Sala 101', - municipio: 'Bento Gonçalves', - uf: 'RS' as const, - cep: '95702-000', - bairro: 'Imigrante' + nome: "Transportador", + endereco: "Olavo Bilac", + numero: "914", + complemento: "Sala 101", + municipio: "Bento Gonçalves", + uf: "RS" as const, + cep: "95702-000", + bairro: "Imigrante" } + }, + vendedor: { + id: 12345679 } } } diff --git a/src/entities/nfes/__tests__/update-response.ts b/src/entities/nfes/__tests__/update-response.ts index 811dd57..0452b5f 100644 --- a/src/entities/nfes/__tests__/update-response.ts +++ b/src/entities/nfes/__tests__/update-response.ts @@ -101,7 +101,7 @@ export const updateRequestBody = { }, volume: { quantidade: 5, - especie: 'Volumes', + especie: 1 as const, numero: '1', pesoBruto: 0.5, pesoLiquido: 0.35 diff --git a/src/entities/nfes/interfaces/create.interface.ts b/src/entities/nfes/interfaces/create.interface.ts index e8f12ad..8906537 100644 --- a/src/entities/nfes/interfaces/create.interface.ts +++ b/src/entities/nfes/interfaces/create.interface.ts @@ -7,6 +7,7 @@ import ITipoPessoa from 'src/entities/@shared/types/tipoPessoa.type' import IUF from 'src/entities/@shared/types/uf.type' import { IFinalidadeNfe } from '../types/finalidade.type' import { ITipoNfe } from '../types/tipo.type' +import { IEspecie } from '../types/especie.type' export interface ICreateBody { tipo: ITipoNfe @@ -94,7 +95,7 @@ export interface ICreateBody { } volume?: { quantidade?: number - especie?: string + especie?: IEspecie numero?: string pesoBruto?: number pesoLiquido?: number diff --git a/src/entities/nfes/interfaces/find.interface.ts b/src/entities/nfes/interfaces/find.interface.ts index d4c41f5..fe74ca9 100644 --- a/src/entities/nfes/interfaces/find.interface.ts +++ b/src/entities/nfes/interfaces/find.interface.ts @@ -44,6 +44,7 @@ export interface IFindResponse { xml?: string linkDanfe?: string linkPDF?: string + numeroPedidoLoja?: string transporte?: { fretePorConta?: IFretePorConta transportador?: { @@ -62,5 +63,8 @@ export interface IFindResponse { bairro?: string } } + vendedor?: { + id: number + } } } diff --git a/src/entities/nfes/interfaces/update.interface.ts b/src/entities/nfes/interfaces/update.interface.ts index 304c5e3..5fe50da 100644 --- a/src/entities/nfes/interfaces/update.interface.ts +++ b/src/entities/nfes/interfaces/update.interface.ts @@ -7,6 +7,7 @@ import ITipoPessoa from 'src/entities/@shared/types/tipoPessoa.type' import IUF from 'src/entities/@shared/types/uf.type' import { IFinalidadeNfe } from '../types/finalidade.type' import { ITipoNfe } from '../types/tipo.type' +import { IEspecie } from '../types/especie.type' export interface IUpdateParams { /** @@ -101,7 +102,7 @@ export interface IUpdateBody { } volume?: { quantidade?: number - especie?: string + especie?: IEspecie numero?: string pesoBruto?: number pesoLiquido?: number diff --git a/src/entities/nfes/types/especie.type.ts b/src/entities/nfes/types/especie.type.ts new file mode 100644 index 0000000..2b1242b --- /dev/null +++ b/src/entities/nfes/types/especie.type.ts @@ -0,0 +1,19 @@ +/** + * - `1`: Outro(s) + * - `2`: Volume(s) + * - `3`: Unidade(s) + * - `4`: Caixa(s) + * - `5`: Pacote(s) + * - `6`: Envelope(s) + * - `7`: Pallet(s) + * - `8`: Saco(s) + */ +export type IEspecie = + | 1 + | 2 + | 3 + | 4 + | 5 + | 6 + | 7 + | 8 diff --git a/src/entities/produtosFornecedores/interfaces/update.interface.ts b/src/entities/produtosFornecedores/interfaces/update.interface.ts index 2d224f4..d266c8a 100644 --- a/src/entities/produtosFornecedores/interfaces/update.interface.ts +++ b/src/entities/produtosFornecedores/interfaces/update.interface.ts @@ -12,7 +12,7 @@ export interface IUpdateBody { precoCompra?: number padrao?: boolean produto: { id: number } - fornecedor: { id: number } + fornecedor?: { id?: number } garantia?: number }