Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit ProcessadorNfe;
- interface
- uses AcbrNfe,Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.SvcMgr, Vcl.Dialogs,
- ServicesCore, FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Error, FireDAC.UI.Intf, FireDAC.Phys.Intf,
- FireDAC.Stan.Def, FireDAC.Stan.Pool, FireDAC.Stan.Async, FireDAC.Phys, FireDAC.VCLUI.Wait, FireDAC.Stan.Param,
- FireDAC.DatS, FireDAC.DApt.Intf, FireDAC.DApt, Data.DB, FireDAC.Comp.DataSet, FireDAC.Comp.Client, Datasnap.DBClient;
- type TGrupoNfeIDArray = array of string;
- type TGrupoEmitArray = Array of String;
- Type TgrupoDestArray = Array Of String;
- type TGrupoNfeId = TGrupoNfeIDArray;
- type TGrupoEmit = TGrupoEmitArray;
- type TGrupoDest = TgrupoDestArray;
- type TReadStringObjofArquive = packed class
- public
- FTGrupoNfeId: TGrupoNfeId;
- FTGrupoEmit: TGrupoEmit;
- FTGrupoDest: TGrupoDest;
- end;
- type TProcessadorNfe = class( TReadStringObjofArquive )
- private
- {Private declaration}
- FAcbrNfe: TACBrNFe;
- FDatasetNfe: TDataset;
- FArquivo: Ansistring;
- FPatchSalvar: string;
- FDatasetItensNfe: TDataset;
- function SaveXmltoFolder(const Patch: string): Boolean;
- procedure StringOftoGrupoNfeId;
- procedure StringOftoGrupoEmit;
- procedure CreateDatasettoNfe( const aNfe: TAcbrNfe );
- protected
- {Protected declaration}
- public
- {Public declaration declaration}
- procedure AfterConstruction; override;
- procedure BeforeDestruction; override;
- procedure MontaDadosNfetoGrupoNfeId( acbrNfe: TAcbrNfe );
- function Salvar: Boolean;
- constructor Create( AcbrNfe: TAcbrNfe; const Arquivo: AnsiString ); (*Metodos do Constructor*)
- destructor Destroy; override;
- published
- {Protected declaration}
- property PatchSalvar : string read FPatchSalvar write FPatchSalvar;
- property DatasetNfe: TDataset read FDatasetNfe;
- property DatasetItensNfe: TDataset read FDatasetItensNfe;
- end;
- implementation
- { TProcessadorNfe }
- procedure TProcessadorNfe.AfterConstruction;
- begin
- inherited AfterConstruction;
- end;
- procedure TProcessadorNfe.BeforeDestruction;
- begin
- inherited BeforeDestruction;
- end;
- constructor TProcessadorNfe.Create( AcbrNfe: TAcbrNfe; const Arquivo: AnsiString );
- begin
- FAcbrNfe := AcbrNfe;
- FArquivo := Arquivo;
- end;
- procedure TProcessadorNfe.CreateDatasettoNfe( const aNfe: TAcbrNfe );
- var T: TclientDataset;
- begin
- T:= TClientDataSet.Create(nil);
- T.Close;
- T.FieldDefs.Clear;
- T.FieldDefs.add('CODIGO',ftInteger);
- T.FieldDefs.add('NOME',ftString,50);
- T.CreateDataSet;
- FDatasetNfe.Assign(T);
- end;
- destructor TProcessadorNfe.Destroy;
- begin
- inherited Destroy;
- end;
- procedure TProcessadorNfe.MontaDadosNfetoGrupoNfeId(acbrNfe: TAcbrNfe);
- begin
- StringOftoGrupoNfeId;
- StringOftoGrupoEmit;
- with acbrNfe.NotasFiscais.Add do
- begin
- NFe.infNFe.ID := FTGrupoNfeId[0];
- NFe.Ide.nNF := FTGrupoNfeId[1].ToInteger;
- NFe.infNFe.Versao := FTGrupoNfeId[2].ToInteger;
- NFE.Emit.xNome := FTGrupoEmit[0];
- NFE.Emit.xFant := FTGrupoEmit[1];
- NFE.Emit.IE := FTGrupoEmit[2];
- NFE.Emit.CNPJCPF := FTGrupoEmit[3];
- end;
- end;
- function TProcessadorNfe.Salvar: Boolean;
- begin
- result := ( (not trim(FPatchSalvar).IsEmpty) and ( SaveXmltoFolder(FPatchSalvar)));
- end;
- function TProcessadorNfe.SaveXmltoFolder(const Patch: string): Boolean;
- begin
- FAcbrNfe.NotasFiscais.GravarXML(Patch);
- end;
- procedure TProcessadorNfe.StringOftoGrupoEmit;
- begin
- // aqui está a toda a logica, onde você vai começar a desmembrar sua string e colocar em cada grupo
- // pertencente
- FTGrupoEmit := ['EMPRESA EMISSORA LTDA ME','FANTASIA DA EMPRESA','NPJ','IE' ];
- end;
- procedure TProcessadorNfe.StringOftoGrupoNfeId;
- begin
- // aqui está a toda a logica, onde você vai começar a desmembrar sua string e colocar em cada grupo
- // pertencente
- FTGrupoNfeId := [ '00000000000000000000000000000000000000000000' ];
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement