7vsdk-pessoas 1.0.21 → 1.0.24

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.
@@ -1,5 +1,5 @@
1
1
  import { UfRequest, UfResponse } from "7vdomain";
2
- import { CrudClientBase } from "7vsdk-usuarios";
2
+ import { CrudClientBase } from "../base";
3
3
  export declare class UfClient extends CrudClientBase<UfRequest, UfResponse> {
4
4
  constructor(Url: string, tokenJwt: string);
5
5
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UfClient = void 0;
4
- const _7vsdk_usuarios_1 = require("7vsdk-usuarios");
5
- class UfClient extends _7vsdk_usuarios_1.CrudClientBase {
4
+ const base_1 = require("../base");
5
+ class UfClient extends base_1.CrudClientBase {
6
6
  constructor(Url, tokenJwt) {
7
7
  super(Url, "api/endereco/uf", tokenJwt);
8
8
  }
@@ -7,9 +7,6 @@ class PessoaClient extends CrudClientBase_js_1.CrudClientBase {
7
7
  if (typeof urlOrServer === 'string') {
8
8
  super(urlOrServer, '/api/pessoa', tokenJwt);
9
9
  }
10
- else {
11
- super(urlOrServer.Url, '/api/pessoa', tokenJwt);
12
- }
13
10
  }
14
11
  async postarPessoa(nome, sexo) {
15
12
  return this.postAsync({ Nome: nome, Sexo: sexo });
@@ -1,7 +1,6 @@
1
1
  import type { PessoaCnpjRequest, PessoaCnpjResponse } from "7vdomain";
2
2
  import { CrudClientBase } from "../base/CrudClientBase.js";
3
- export declare class PessoaCnpjClient extends CrudClientBase<PessoaCnpjResponse, PessoaCnpjRequest> {
4
- constructor(server: {
5
- Url: string;
6
- }, tokenJwt: string);
3
+ export declare class PessoaCnpjClient extends CrudClientBase<PessoaCnpjRequest, PessoaCnpjResponse> {
4
+ constructor(Url: string, tokenJwt: string);
5
+ postarPessoaCnpj(pessoaId: number, numero: string, ie: string, regimeTributario: number, lucroReal: boolean, industria: boolean): Promise<PessoaCnpjResponse>;
7
6
  }
@@ -3,8 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PessoaCnpjClient = void 0;
4
4
  const CrudClientBase_js_1 = require("../base/CrudClientBase.js");
5
5
  class PessoaCnpjClient extends CrudClientBase_js_1.CrudClientBase {
6
- constructor(server, tokenJwt) {
7
- super(server.Url, "api/pessoa/cnpj", tokenJwt);
6
+ constructor(Url, tokenJwt) {
7
+ super(Url, "api/pessoa/cnpj", tokenJwt);
8
+ }
9
+ async postarPessoaCnpj(pessoaId, numero, ie, regimeTributario, lucroReal, industria) {
10
+ const request = {
11
+ Ie: ie,
12
+ Numero: numero,
13
+ PessoaId: pessoaId,
14
+ RegimeTributario: regimeTributario,
15
+ LucroReal: lucroReal,
16
+ Industria: industria
17
+ };
18
+ return await this.postAsync(request);
8
19
  }
9
20
  }
10
21
  exports.PessoaCnpjClient = PessoaCnpjClient;
@@ -1,16 +1,14 @@
1
- import { EmpresaRequest, EmpresaResponse } from "7vdomain";
1
+ import { EmpresaRequest, EmpresaResponse, EnderecoRequest, PessoaTelefoneRequest } from "7vdomain";
2
2
  import { CrudClientBase } from "../base";
3
- interface IEmpresaSdk {
4
- criarEmpresa(request: EmpresaRequest): Promise<EmpresaResponse>;
5
- pegarEmpresa(id: number): Promise<EmpresaResponse>;
6
- deletarEmpresa(id: number): Promise<void>;
7
- pegarEmpresaPaginacao(page: number, size: number): Promise<EmpresaResponse[]>;
8
- }
9
- export declare class EmpresaSdk extends CrudClientBase<EmpresaRequest, EmpresaResponse> implements IEmpresaSdk {
3
+ export declare class EmpresaSdk extends CrudClientBase<EmpresaRequest, EmpresaResponse> {
4
+ private pessoaSdk;
5
+ private enderecoSdk;
6
+ private pessoaCnpj;
10
7
  constructor(Url: string, tokenJwt: string);
11
- criarEmpresa(request: EmpresaRequest): Promise<EmpresaResponse>;
12
- pegarEmpresa(id: number): Promise<EmpresaResponse>;
13
- deletarEmpresa(id: number): Promise<void>;
14
- pegarEmpresaPaginacao(page: number, size: number): Promise<EmpresaResponse[]>;
8
+ criarEmpresaRoot(cnpj: string, ie: string, regimeTributario: number, razaoSocial: string, lucroReal: boolean, industria: boolean): Promise<void>;
9
+ incluirEmpresaRootCompleto(cnpj: string, razaoSocial: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>;
10
+ incluirClientePj(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string): Promise<void>;
11
+ incluirClientePjCompleto(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>;
12
+ incluirClientePf(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string): Promise<void>;
13
+ incluirClientePfCompleto(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>;
15
14
  }
16
- export {};
@@ -2,21 +2,30 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EmpresaSdk = void 0;
4
4
  const base_1 = require("../base");
5
+ const pessoas_1 = require("../pessoas");
6
+ const EnderecoCidadeClient_1 = require("../enderecos/EnderecoCidadeClient");
5
7
  class EmpresaSdk extends base_1.CrudClientBase {
6
8
  constructor(Url, tokenJwt) {
7
9
  super(Url, "portal-contador/empresa", tokenJwt);
10
+ this.pessoaSdk = new pessoas_1.PessoaClient(this.baseUrl, this.tokenJwt);
11
+ this.enderecoSdk = new EnderecoCidadeClient_1.EnderecoCidadeClient(this.baseUrl, this.tokenJwt);
12
+ this.pessoaCnpj = new pessoas_1.PessoaCnpjClient(this.baseUrl, this.tokenJwt);
8
13
  }
9
- async criarEmpresa(request) {
10
- return await this.postAsync(request);
14
+ async criarEmpresaRoot(cnpj, ie, regimeTributario, razaoSocial, lucroReal, industria) {
15
+ if (regimeTributario < 1 || regimeTributario > 3)
16
+ throw new Error("Regime tributário inválido. Use 1 para Simples Nacional, 2 para Lucro Presumido ou 3 para Lucro Real.");
17
+ const pessoaMandou = await this.pessoaSdk.postarPessoa(razaoSocial, "I");
18
+ await this.pessoaCnpj.postarPessoaCnpj(pessoaMandou.PessoaId, cnpj, ie, regimeTributario, lucroReal, industria);
11
19
  }
12
- async pegarEmpresa(id) {
13
- return await this.getAsync(id);
20
+ async incluirEmpresaRootCompleto(cnpj, razaoSocial, endereco, telefones) {
14
21
  }
15
- async deletarEmpresa(id) {
16
- return await this.deleteAsync(id);
22
+ async incluirClientePj(cnpjPai, cnpjFilho, razaoSocialFilho) {
17
23
  }
18
- async pegarEmpresaPaginacao(page, size) {
19
- return await this.getPagedAsync(page, size);
24
+ async incluirClientePjCompleto(cnpjPai, cnpjFilho, razaoSocialFilho, endereco, telefones) {
25
+ }
26
+ async incluirClientePf(cnpjPai, cpfFilho, nomeCompletoFilho) {
27
+ }
28
+ async incluirClientePfCompleto(cnpjPai, cpfFilho, nomeCompletoFilho, endereco, telefones) {
20
29
  }
21
30
  }
22
31
  exports.EmpresaSdk = EmpresaSdk;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "7vsdk-pessoas",
3
- "version": "1.0.21",
3
+ "version": "1.0.24",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -3,6 +3,7 @@ import type { ResultDto } from "7vdomain";
3
3
  // essa classe base pode ser reutilizada para qualquer cliente CRUD
4
4
 
5
5
  export abstract class CrudClientBase<TRequest, TResponse> {
6
+
6
7
  protected baseUrl: string;
7
8
  protected endpointBase: string;
8
9
  protected tokenJwt?: string;
@@ -1,5 +1,5 @@
1
1
  import { UfRequest, UfResponse } from "7vdomain";
2
- import { CrudClientBase } from "7vsdk-usuarios";
2
+ import { CrudClientBase } from "../base";
3
3
 
4
4
  export class UfClient extends CrudClientBase<UfRequest, UfResponse>
5
5
  {
@@ -20,16 +20,12 @@ implements IPessoaClient
20
20
  {
21
21
  if (typeof urlOrServer === 'string') {
22
22
  super(urlOrServer, '/api/pessoa', tokenJwt);
23
- } else {
24
- super(urlOrServer.Url, '/api/pessoa', tokenJwt);
25
23
  }
26
24
  }
27
25
 
28
26
  async postarPessoa(nome: string, sexo: string): Promise<PessoaResponse> {
29
27
  return this.postAsync({ Nome: nome, Sexo: sexo } as PessoaRequest);
30
28
  }
31
-
32
-
33
29
  async pegarPessoa(id: number): Promise<PessoaResponse> {
34
30
  return await this.getAsync(id);
35
31
  }
@@ -1,8 +1,22 @@
1
1
  import type { PessoaCnpjRequest, PessoaCnpjResponse } from "7vdomain";
2
2
  import { CrudClientBase } from "../base/CrudClientBase.js";
3
3
 
4
- export class PessoaCnpjClient extends CrudClientBase<PessoaCnpjResponse, PessoaCnpjRequest> {
5
- constructor(server: { Url: string }, tokenJwt: string) {
6
- super(server.Url, "api/pessoa/cnpj", tokenJwt);
4
+ export class PessoaCnpjClient extends CrudClientBase<PessoaCnpjRequest, PessoaCnpjResponse> {
5
+ constructor(Url: string, tokenJwt: string) {
6
+ super(Url, "api/pessoa/cnpj", tokenJwt);
7
+ }
8
+
9
+ async postarPessoaCnpj(pessoaId: number, numero: string, ie: string, regimeTributario: number, lucroReal: boolean, industria: boolean): Promise<PessoaCnpjResponse> {
10
+ const request: PessoaCnpjRequest = {
11
+ Ie: ie,
12
+ Numero: numero,
13
+ PessoaId: pessoaId,
14
+ RegimeTributario: regimeTributario,
15
+ LucroReal: lucroReal,
16
+ Industria: industria
17
+ };
18
+ return await this.postAsync(request);
7
19
  }
8
20
  }
21
+
22
+
@@ -1,42 +1,48 @@
1
- import { EmpresaRequest, EmpresaResponse } from "7vdomain";
1
+ import { EmpresaRequest, EmpresaResponse, EnderecoRequest, PessoaResponse, PessoaTelefoneRequest } from "7vdomain";
2
2
  import { CrudClientBase } from "../base";
3
-
4
- interface IEmpresaSdk
5
- {
6
- criarEmpresa(request: EmpresaRequest): Promise<EmpresaResponse>;
7
- pegarEmpresa(id: number): Promise<EmpresaResponse>;
8
- deletarEmpresa(id: number): Promise<void>;
9
- pegarEmpresaPaginacao(page: number, size: number): Promise<EmpresaResponse[]>;
10
- }
3
+ import { PessoaClient, PessoaCnpjClient } from "../pessoas";
4
+ import { EnderecoCidadeClient } from "../enderecos/EnderecoCidadeClient";
11
5
 
12
6
  export class EmpresaSdk extends CrudClientBase<EmpresaRequest, EmpresaResponse>
13
- implements IEmpresaSdk
14
7
  {
8
+ private pessoaSdk: PessoaClient = new PessoaClient(this.baseUrl, this.tokenJwt!);
9
+ private enderecoSdk: EnderecoCidadeClient = new EnderecoCidadeClient(this.baseUrl, this.tokenJwt!);
10
+ private pessoaCnpj: PessoaCnpjClient = new PessoaCnpjClient(this.baseUrl, this.tokenJwt!);
11
+
15
12
  constructor(Url: string, tokenJwt: string) {
16
13
  super(Url, "portal-contador/empresa", tokenJwt);
17
14
  }
18
15
 
19
- async criarEmpresa(request: EmpresaRequest): Promise<EmpresaResponse> {
20
-
21
- return await this.postAsync(request);
22
-
16
+ async criarEmpresaRoot(cnpj: string, ie: string, regimeTributario: number, razaoSocial: string, lucroReal: boolean, industria: boolean): Promise<void>
17
+ {
18
+ if(regimeTributario < 1 || regimeTributario > 3)
19
+ throw new Error("Regime tributário inválido. Use 1 para Simples Nacional, 2 para Lucro Presumido ou 3 para Lucro Real.");
20
+ const pessoaMandou: PessoaResponse = await this.pessoaSdk.postarPessoa(razaoSocial, "I");
21
+ await this.pessoaCnpj.postarPessoaCnpj(pessoaMandou.PessoaId, cnpj, ie, regimeTributario, lucroReal, industria);
23
22
  }
24
23
 
25
- async pegarEmpresa(id: number): Promise<EmpresaResponse> {
24
+ async incluirEmpresaRootCompleto(cnpj: string, razaoSocial: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
25
+ {
26
+
27
+ }
26
28
 
27
- return await this.getAsync(id);
29
+ async incluirClientePj(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string): Promise<void>
30
+ {
28
31
 
29
32
  }
30
33
 
31
- async deletarEmpresa(id: number): Promise<void> {
34
+ async incluirClientePjCompleto(cnpjPai: string, cnpjFilho: string, razaoSocialFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
35
+ {
32
36
 
33
- return await this.deleteAsync(id);
37
+ }
34
38
 
35
- }
39
+ async incluirClientePf(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string): Promise<void>
40
+ {
36
41
 
37
- async pegarEmpresaPaginacao(page: number, size: number): Promise<EmpresaResponse[]> {
42
+ }
38
43
 
39
- return await this.getPagedAsync(page, size);
44
+ async incluirClientePfCompleto(cnpjPai: string, cpfFilho: string, nomeCompletoFilho: string, endereco: EnderecoRequest[], telefones: PessoaTelefoneRequest[]): Promise<void>
45
+ {
40
46
 
41
- }
47
+ }
42
48
  }
@@ -1 +0,0 @@
1
- {"root":["../src/index.ts","../src/clients/index.ts","../src/clients/base/crudclientbase.ts","../src/clients/base/index.ts","../src/clients/enderecos/enderecobairroclient.ts","../src/clients/enderecos/enderecocidadeclient.ts","../src/clients/enderecos/enderecosdk.ts","../src/clients/enderecos/ufclient.ts","../src/clients/enderecos/index.ts","../src/clients/pessoas/pessoaclient.ts","../src/clients/pessoas/pessoacnpjclient.ts","../src/clients/pessoas/pessoacpfclient.ts","../src/clients/pessoas/pessoaemailclient.ts","../src/clients/pessoas/pessoaenderecoclient.ts","../src/clients/pessoas/pessoanascimentoclient.ts","../src/clients/pessoas/pessoanecessidadeespecial.ts","../src/clients/pessoas/pessoaprocedimentoclient.ts","../src/clients/pessoas/pessoarelacaoclient.ts","../src/clients/pessoas/pessoarelacaogrupoclient.ts","../src/clients/pessoas/pessoarelacaotipoclient.ts","../src/clients/pessoas/pessoatelefoneclient.ts","../src/clients/pessoas/pessoatipoclient.ts","../src/clients/pessoas/index.ts","../src/clients/portalcontador/empresasdk.ts","../src/clients/portalcontador/impostoestadualsdk.ts","../src/clients/portalcontador/impostofederalsdk.ts","../src/clients/portalcontador/index.ts"],"version":"5.9.3"}