Skip to content

Commit

Permalink
feat: atualizar para v306
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreBellas committed Oct 4, 2024
1 parent e787b4b commit ca64f7c
Show file tree
Hide file tree
Showing 16 changed files with 170 additions and 60 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/entities/nfces/__tests__/create-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const createRequestBody = {
},
volume: {
quantidade: 5,
especie: 'Volumes',
especie: 1 as const,
numero: '1',
pesoBruto: 0.5,
pesoLiquido: 0.35
Expand Down
67 changes: 49 additions & 18 deletions src/entities/nfces/__tests__/find-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]',
nome: "Contato do Bling",
numeroDocumento: "30188025000121",
ie: "7364873393",
rg: "451838701",
telefone: "54 3771-7278",
email: "[email protected]",
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: {
Expand All @@ -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
}
}
}
2 changes: 1 addition & 1 deletion src/entities/nfces/__tests__/update-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const updateRequestBody = {
},
volume: {
quantidade: 5,
especie: 'Volumes',
especie: 1 as const,
numero: '1',
pesoBruto: 0.5,
pesoLiquido: 0.35
Expand Down
3 changes: 2 additions & 1 deletion src/entities/nfces/interfaces/create.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,7 +95,7 @@ export interface ICreateBody {
}
volume?: {
quantidade?: number
especie?: string
especie?: IEspecie
numero?: string
pesoBruto?: number
pesoLiquido?: number
Expand Down
30 changes: 29 additions & 1 deletion src/entities/nfces/interfaces/find.interface.ts
Original file line number Diff line number Diff line change
@@ -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 {
/**
Expand Down Expand Up @@ -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
}
}
}
3 changes: 2 additions & 1 deletion src/entities/nfces/interfaces/update.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -101,7 +102,7 @@ export interface IUpdateBody {
}
volume?: {
quantidade?: number
especie?: string
especie?: IEspecie
numero?: string
pesoBruto?: number
pesoLiquido?: number
Expand Down
19 changes: 19 additions & 0 deletions src/entities/nfces/types/especie.type.ts
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/entities/nfes/__tests__/create-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const createRequestBody = {
},
volume: {
quantidade: 5,
especie: 'Volumes',
especie: 1 as const,
numero: '1',
pesoBruto: 0.5,
pesoLiquido: 0.35
Expand Down
67 changes: 36 additions & 31 deletions src/entities/nfes/__tests__/find-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]',
nome: "Contato do Bling",
numeroDocumento: "30188025000121",
ie: "7364873393",
rg: "451838701",
telefone: "54 3771-7278",
email: "[email protected]",
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: {
Expand All @@ -32,31 +32,36 @@ 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: [
{
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'
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
}
}
}
2 changes: 1 addition & 1 deletion src/entities/nfes/__tests__/update-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const updateRequestBody = {
},
volume: {
quantidade: 5,
especie: 'Volumes',
especie: 1 as const,
numero: '1',
pesoBruto: 0.5,
pesoLiquido: 0.35
Expand Down
3 changes: 2 additions & 1 deletion src/entities/nfes/interfaces/create.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -94,7 +95,7 @@ export interface ICreateBody {
}
volume?: {
quantidade?: number
especie?: string
especie?: IEspecie
numero?: string
pesoBruto?: number
pesoLiquido?: number
Expand Down
4 changes: 4 additions & 0 deletions src/entities/nfes/interfaces/find.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface IFindResponse {
xml?: string
linkDanfe?: string
linkPDF?: string
numeroPedidoLoja?: string
transporte?: {
fretePorConta?: IFretePorConta
transportador?: {
Expand All @@ -62,5 +63,8 @@ export interface IFindResponse {
bairro?: string
}
}
vendedor?: {
id: number
}
}
}
3 changes: 2 additions & 1 deletion src/entities/nfes/interfaces/update.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -101,7 +102,7 @@ export interface IUpdateBody {
}
volume?: {
quantidade?: number
especie?: string
especie?: IEspecie
numero?: string
pesoBruto?: number
pesoLiquido?: number
Expand Down
19 changes: 19 additions & 0 deletions src/entities/nfes/types/especie.type.ts
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface IUpdateBody {
precoCompra?: number
padrao?: boolean
produto: { id: number }
fornecedor: { id: number }
fornecedor?: { id?: number }
garantia?: number
}

Expand Down

0 comments on commit ca64f7c

Please sign in to comment.