You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2838 lines
85 KiB
2838 lines
85 KiB
unit ufrmCentralBoletos;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, System.StrUtils, System.DateUtils,
|
|
System.UITypes, System.Math,
|
|
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, umstMaster, Vcl.ComCtrls, Vcl.StdCtrls,
|
|
Data.DB,
|
|
Datasnap.DBClient, Vcl.Grids, Vcl.DBGrids, Vcl.Buttons, System.JSON, MidasLib,
|
|
IdIOHandler,
|
|
IdIOHandlerSocket, IdIOHandlerStack, IdSSL, IdSSLOpenSSL, IdBaseComponent,
|
|
IdComponent, IdGlobal,
|
|
IdTCPConnection, IdTCPClient, IdHTTP, REST.Response.Adapter, rDBComponents,
|
|
Vcl.Mask, Vcl.DBCtrls, Vcl.Menus, IdCoder, IdCoder3to4, IdCoderMIME,
|
|
ZAbstractRODataset, ZDataset, Vcl.ExtCtrls, IdStack, IdException,
|
|
Vcl.CheckLst;
|
|
|
|
type
|
|
TMethod = (GET, POST);
|
|
|
|
TStringArray = array of string;
|
|
|
|
TfrmCentralBoletos = class(TmstMaster)
|
|
dtsBoletos: TDataSource;
|
|
IdHTTP: TIdHTTP;
|
|
IdSSLHandler: TIdSSLIOHandlerSocketOpenSSL;
|
|
tblDesc1: TClientDataSet;
|
|
dtsDesc1: TDataSource;
|
|
tblDesc2: TClientDataSet;
|
|
dtsDesc2: TDataSource;
|
|
tblDesc3: TClientDataSet;
|
|
dtsDesc3: TDataSource;
|
|
tblMulta: TClientDataSet;
|
|
dtsMulta: TDataSource;
|
|
tblMora: TClientDataSet;
|
|
dtsMora: TDataSource;
|
|
tblDesc1codigo: TStringField;
|
|
tblDesc1taxa: TFloatField;
|
|
tblDesc1valor: TCurrencyField;
|
|
tblDesc2codigo: TStringField;
|
|
tblDesc2taxa: TFloatField;
|
|
tblDesc2valor: TCurrencyField;
|
|
tblDesc3codigo: TStringField;
|
|
tblDesc3taxa: TFloatField;
|
|
tblDesc3valor: TCurrencyField;
|
|
tblMultacodigo: TStringField;
|
|
tblMultataxa: TFloatField;
|
|
tblMultavalor: TCurrencyField;
|
|
tblMultadata: TDateField;
|
|
tblMoracodigo: TStringField;
|
|
tblMorataxa: TFloatField;
|
|
tblMoravalor: TCurrencyField;
|
|
tblMoradata: TDateField;
|
|
pcBoletos: TPageControl;
|
|
tsPesquisa: TTabSheet;
|
|
gb_searchfilter: TGroupBox;
|
|
Label1: TLabel;
|
|
Label2: TLabel;
|
|
Label3: TLabel;
|
|
Label4: TLabel;
|
|
Label5: TLabel;
|
|
SpeedButton1: TSpeedButton;
|
|
cb_filtrosituacao: TComboBox;
|
|
cb_filtrotipodata: TComboBox;
|
|
dt_inicio: TDateTimePicker;
|
|
dt_fim: TDateTimePicker;
|
|
cb_filtroordem: TComboBox;
|
|
dbgrd_boletos: TDBGrid;
|
|
tsGeraBoleto: TTabSheet;
|
|
pum_download: TPopupMenu;
|
|
mnuDownload: TMenuItem;
|
|
SaveDialog: TSaveDialog;
|
|
IdDecoderMIME: TIdDecoderMIME;
|
|
MainMenu1: TMainMenu;
|
|
mnuCadastro: TMenuItem;
|
|
mnhGrupoBoletos: TMenuItem;
|
|
pum_incldel: TPopupMenu;
|
|
mnuIncluir: TMenuItem;
|
|
mnuRemover: TMenuItem;
|
|
N1: TMenuItem;
|
|
N2: TMenuItem;
|
|
mnuBaixarInter: TMenuItem;
|
|
mnuAcertos: TMenuItem;
|
|
mnuProtestado: TMenuItem;
|
|
mnuDevolucao: TMenuItem;
|
|
mnuProtestoAposBaixa: TMenuItem;
|
|
mnuPagoDireto: TMenuItem;
|
|
mnuSubstituicao: TMenuItem;
|
|
mnuFalta: TMenuItem;
|
|
mnuAPedidoCliente: TMenuItem;
|
|
mnuBaixarCob: TMenuItem;
|
|
rotblRepasseFase: TZReadOnlyQuery;
|
|
rotblRepasseFaseID_FASE: TIntegerField;
|
|
rotblRepasseFasePR_PRINCIPAL: TFloatField;
|
|
rotblRepasseFasePR_JUROS: TFloatField;
|
|
rotblRepasseFasePR_MULTA: TFloatField;
|
|
rotblRepasseFasePR_ENCARGOS: TFloatField;
|
|
rotblRepasseFasePR_CORRIGIDO: TFloatField;
|
|
rotblRepasseFaseMIN_ATRASO: TIntegerField;
|
|
rotblRepasseFaseMAX_ATRASO: TIntegerField;
|
|
rotblRepasseFaseID_REPASSE: TIntegerField;
|
|
rotblRepasseFaseID_ULTIMO_USUARIO: TIntegerField;
|
|
rotblRepasseFaseDT_HORA_ULTIMA_ATT: TDateTimeField;
|
|
tblPagador: TClientDataSet;
|
|
dtsPagador: TDataSource;
|
|
cdsBoletos: TClientDataSet;
|
|
DBMemo1: TDBMemo;
|
|
cdsBoletosnossoNumero: TWideStringField;
|
|
cdsBoletosseuNumero: TWideStringField;
|
|
cdsBoletospagador: TWideMemoField;
|
|
gbBoleto: TGroupBox;
|
|
cdsBoletossituacao: TWideStringField;
|
|
cdsBoletosdataVencimento: TDateField;
|
|
cdsBoletosdataHoraSituacao: TWideStringField;
|
|
pcPesquisaGerar: TPageControl;
|
|
TabSheet1: TTabSheet;
|
|
TabSheet2: TTabSheet;
|
|
btn_gerarbolunico: TButton;
|
|
gbPesquisa: TGroupBox;
|
|
edtPesquisa: TEdit;
|
|
rgTipoPesquisa: TRadioGroup;
|
|
DBGrid1: TDBGrid;
|
|
dtsHist: TDataSource;
|
|
spdbtnPesquisa: TSpeedButton;
|
|
DBGrid2: TDBGrid;
|
|
Label6: TLabel;
|
|
dtsPesquisa: TDataSource;
|
|
zroqryPesquisa: TZReadOnlyQuery;
|
|
zroqryPesquisaTX_NOME: TWideStringField;
|
|
zroqryPesquisaTX_DOCUMENTO: TWideStringField;
|
|
zroqryPesquisaID_DEVEDOR: TIntegerField;
|
|
GroupBox1: TGroupBox;
|
|
dbedtNomeDevBoleto: TDBEdit;
|
|
Label7: TLabel;
|
|
dbedtDocDevBoleto: TDBEdit;
|
|
Label8: TLabel;
|
|
dtsEmpresasTitulos: TDataSource;
|
|
zroqryEmpresasTitulos: TZReadOnlyQuery;
|
|
zroqryEmpresasTitulosID_EMPRESA: TIntegerField;
|
|
zroqryEmpresasTitulosTX_NOME: TWideStringField;
|
|
zroqryEmpresasTitulosTX_FANTASIA: TWideStringField;
|
|
zroqryEmpresasTitulosTX_CNPJ: TWideStringField;
|
|
zroqryEmpresasTitulosTX_IE: TWideStringField;
|
|
zroqryEmpresasTitulosTX_ENDERECO: TWideStringField;
|
|
zroqryEmpresasTitulosTX_COMPLEMENTO: TWideStringField;
|
|
zroqryEmpresasTitulosID_CIDADE: TIntegerField;
|
|
zroqryEmpresasTitulosTX_BAIRRO: TWideStringField;
|
|
zroqryEmpresasTitulosID_ESTADO: TIntegerField;
|
|
zroqryEmpresasTitulosTX_CEP: TWideStringField;
|
|
zroqryEmpresasTitulosTX_TELEFONE: TWideStringField;
|
|
zroqryEmpresasTitulosTX_EMAIL: TWideStringField;
|
|
zroqryEmpresasTitulosTX_WEBSITE: TWideStringField;
|
|
zroqryEmpresasTitulosNR_NUMERO: TIntegerField;
|
|
zroqryEmpresasTitulosTX_IM: TWideStringField;
|
|
zroqryEmpresasTitulosTL_OBSERVACOES: TWideMemoField;
|
|
zroqryEmpresasTitulosID_REPASSE: TIntegerField;
|
|
zroqryEmpresasTitulosTP_ENTRADA: TWideStringField;
|
|
zroqryEmpresasTitulosPR_MULTA: TFloatField;
|
|
zroqryEmpresasTitulosPR_JUROS: TFloatField;
|
|
zroqryEmpresasTitulosNR_PARCELAS: TIntegerField;
|
|
zroqryEmpresasTitulosPR_DESC_QUIT_PRIN: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_QUIT_JUROS: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_QUIT_MULTA: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_QUIT_IND_FIN: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_QUIT_COR: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_FINAN_PRIN: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_FINAN_JUROS: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_FINAN_MULTA: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_FINAN_IND_FIN: TFloatField;
|
|
zroqryEmpresasTitulosPR_DESC_FINAN_COR: TFloatField;
|
|
zroqryEmpresasTitulosPR_INDICADOR_FINANCEIRO: TFloatField;
|
|
zroqryEmpresasTitulosPR_JUROS_PARCELAR: TFloatField;
|
|
zroqryEmpresasTitulosPR_ENTRADA_MIN: TFloatField;
|
|
zroqryEmpresasTitulosPR_ENTRADA_MAX: TFloatField;
|
|
zroqryEmpresasTitulosTP_CHEQUE: TWideStringField;
|
|
zroqryEmpresasTitulosTP_CRED: TWideStringField;
|
|
zroqryEmpresasTitulosTP_DIN: TWideStringField;
|
|
zroqryEmpresasTitulosID_ULTIMO_USUARIO: TIntegerField;
|
|
zroqryEmpresasTitulosDT_HORA_ULTIMA_ATT: TDateTimeField;
|
|
zroqryEmpresasTitulosID_DEPARTAMENTO: TIntegerField;
|
|
zroqryEmpresasTitulosNR_JUROS: TFloatField;
|
|
zroqryEmpresasTitulosTP_JUROS: TWideStringField;
|
|
gbPagador: TGroupBox;
|
|
lblNomePagador: TLabel;
|
|
edtNomePagador: TEdit;
|
|
lblDocumentoPagador: TLabel;
|
|
edtDocumentoPagador: TEdit;
|
|
lblTipoPagador: TLabel;
|
|
cbTipoPagador: TComboBox;
|
|
lblEmailPagador: TLabel;
|
|
edtEmailPagador: TEdit;
|
|
lblEnderecoPagador: TLabel;
|
|
edtEnderecoPagador: TEdit;
|
|
edtNumeroPagador: TEdit;
|
|
lblNumeroPagador: TLabel;
|
|
lblComplementoPagador: TLabel;
|
|
edtComplementoPagador: TEdit;
|
|
lblBairroPagador: TLabel;
|
|
edtBairroPagador: TEdit;
|
|
lblCidadePagador: TLabel;
|
|
edtCidadePagador: TEdit;
|
|
lblUfPagador: TLabel;
|
|
edtUfPagador: TEdit;
|
|
lblCepPagador: TLabel;
|
|
edtCepPagador: TEdit;
|
|
lblDddPagador: TLabel;
|
|
edtDddPagador: TEdit;
|
|
lblTelefonePagador: TLabel;
|
|
edtTelefonePagador: TEdit;
|
|
gbDadosBoleto: TGroupBox;
|
|
lblSeuNumeroBoleto: TLabel;
|
|
edtSeuNumeroBoleto: TEdit;
|
|
lblVlNominalBoleto: TLabel;
|
|
edtVlNominalBoleto: TEdit;
|
|
dtpVencimentoBoleto: TDateTimePicker;
|
|
lblVencimentoBoleto: TLabel;
|
|
lblDiasCancelamentoBoleto: TLabel;
|
|
edtDiasCancelamentoBoleto: TEdit;
|
|
gbMensagemBoleto: TGroupBox;
|
|
Label49: TLabel;
|
|
Label50: TLabel;
|
|
Label51: TLabel;
|
|
Label52: TLabel;
|
|
Label57: TLabel;
|
|
edtLinha1Boleto: TEdit;
|
|
edtLinha2Boleto: TEdit;
|
|
edtLinha3Boleto: TEdit;
|
|
edtLinha4Boleto: TEdit;
|
|
edtLinha5Boleto: TEdit;
|
|
GroupBox2: TGroupBox;
|
|
Label34: TLabel;
|
|
Label35: TLabel;
|
|
Label36: TLabel;
|
|
cb_desc1: TComboBox;
|
|
edt_taxa1bol: TEdit;
|
|
edt_val1bol: TEdit;
|
|
dtp_desc1: TDateTimePicker;
|
|
GroupBox3: TGroupBox;
|
|
Label37: TLabel;
|
|
Label38: TLabel;
|
|
Label39: TLabel;
|
|
cb_desc2: TComboBox;
|
|
edt_taxa2bol: TEdit;
|
|
edt_val2bol: TEdit;
|
|
dtp_desc2: TDateTimePicker;
|
|
GroupBox4: TGroupBox;
|
|
Label40: TLabel;
|
|
Label41: TLabel;
|
|
Label42: TLabel;
|
|
cb_desc3: TComboBox;
|
|
edt_taxa3bol: TEdit;
|
|
edt_val3bol: TEdit;
|
|
dtp_desc3: TDateTimePicker;
|
|
GroupBox6: TGroupBox;
|
|
Label47: TLabel;
|
|
Label48: TLabel;
|
|
Label55: TLabel;
|
|
cb_morabol: TComboBox;
|
|
edt_taxamorabol: TEdit;
|
|
edt_vlmorabol: TEdit;
|
|
dtp_multa: TDateTimePicker;
|
|
GroupBox5: TGroupBox;
|
|
Label45: TLabel;
|
|
Label46: TLabel;
|
|
Label56: TLabel;
|
|
cb_multabol: TComboBox;
|
|
edt_taxamultabol: TEdit;
|
|
edt_vlmultabol: TEdit;
|
|
dtp_mora: TDateTimePicker;
|
|
gbBeneficiarioBoleto: TGroupBox;
|
|
Label14: TLabel;
|
|
edtNomeBeneficiario: TEdit;
|
|
Label15: TLabel;
|
|
edtDocumentoBeneficiario: TEdit;
|
|
Label16: TLabel;
|
|
cbTipoBeneficiario: TComboBox;
|
|
Label17: TLabel;
|
|
edtEnderecoBeneficiario: TEdit;
|
|
Label18: TLabel;
|
|
edtBairroBeneficiario: TEdit;
|
|
Label19: TLabel;
|
|
edtCidadeBeneficiario: TEdit;
|
|
Label20: TLabel;
|
|
edtUfBeneficiario: TEdit;
|
|
Label21: TLabel;
|
|
edtCepBeneficiario: TEdit;
|
|
dtsDevedor: TDataSource;
|
|
Label13: TLabel;
|
|
dblucbEndDevBoleto: TDBLookupComboBox;
|
|
Label9: TLabel;
|
|
dblucbTelDevBoleto: TDBLookupComboBox;
|
|
Label10: TLabel;
|
|
dblucbEmailDevBoleto: TDBLookupComboBox;
|
|
navPrincipal: TDBNavigator;
|
|
GroupBox7: TGroupBox;
|
|
Label11: TLabel;
|
|
Label12: TLabel;
|
|
Label22: TLabel;
|
|
Label23: TLabel;
|
|
Label24: TLabel;
|
|
dbEdtLinha1Boleto: TDBEdit;
|
|
dbEdtLinha2Boleto: TDBEdit;
|
|
dbEdtLinha3Boleto: TDBEdit;
|
|
dbEdtLinha4Boleto: TDBEdit;
|
|
dbEdtLinha5Boleto: TDBEdit;
|
|
btnPreparaBoleto: TButton;
|
|
GroupBox8: TGroupBox;
|
|
Label25: TLabel;
|
|
Label26: TLabel;
|
|
Label27: TLabel;
|
|
DBLookupComboBox5: TDBLookupComboBox;
|
|
DBEdit5: TDBEdit;
|
|
DBEdit6: TDBEdit;
|
|
DBEdit7: TDBEdit;
|
|
GroupBox9: TGroupBox;
|
|
Label28: TLabel;
|
|
Label29: TLabel;
|
|
Label30: TLabel;
|
|
DBLookupComboBox6: TDBLookupComboBox;
|
|
DBEdit8: TDBEdit;
|
|
DBEdit9: TDBEdit;
|
|
DBEdit10: TDBEdit;
|
|
GroupBox10: TGroupBox;
|
|
Label31: TLabel;
|
|
Label32: TLabel;
|
|
Label33: TLabel;
|
|
DBLookupComboBox7: TDBLookupComboBox;
|
|
DBEdit11: TDBEdit;
|
|
DBEdit14: TDBEdit;
|
|
DBEdit17: TDBEdit;
|
|
GroupBox11: TGroupBox;
|
|
Label43: TLabel;
|
|
Label44: TLabel;
|
|
Label53: TLabel;
|
|
DBLookupComboBox8: TDBLookupComboBox;
|
|
DBEdit12: TDBEdit;
|
|
DBEdit15: TDBEdit;
|
|
DBEdit18: TDBEdit;
|
|
GroupBox12: TGroupBox;
|
|
Label54: TLabel;
|
|
Label58: TLabel;
|
|
Label59: TLabel;
|
|
DBLookupComboBox9: TDBLookupComboBox;
|
|
DBEdit13: TDBEdit;
|
|
DBEdit16: TDBEdit;
|
|
DBEdit19: TDBEdit;
|
|
Label60: TLabel;
|
|
Label61: TLabel;
|
|
Label62: TLabel;
|
|
DBEdit20: TDBEdit;
|
|
DBEdit21: TDBEdit;
|
|
DBEdit22: TDBEdit;
|
|
Label63: TLabel;
|
|
DBEdit23: TDBEdit;
|
|
btnGerarBoleto: TButton;
|
|
btnFichaCliente: TButton;
|
|
GroupBox13: TGroupBox;
|
|
DBLookupComboBox10: TDBLookupComboBox;
|
|
DBGrid3: TDBGrid;
|
|
DBNavigator1: TDBNavigator;
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure SpeedButton1Click(Sender: TObject);
|
|
procedure dtsBoletosDataChange(Sender: TObject; Field: TField);
|
|
procedure dbgrd_boletosDrawColumnCell(Sender: TObject; const Rect: TRect;
|
|
DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
procedure mnuDownloadClick(Sender: TObject);
|
|
procedure dbgrd_boletosMouseUp(Sender: TObject; Button: TMouseButton;
|
|
Shift: TShiftState; X, Y: Integer);
|
|
procedure mnhGrupoBoletosClick(Sender: TObject);
|
|
procedure dbgrd_bolunicoMouseUp(Sender: TObject; Button: TMouseButton;
|
|
Shift: TShiftState; X, Y: Integer);
|
|
procedure btn_gerarbolunicoClick(Sender: TObject);
|
|
procedure mnuAcertosClick(Sender: TObject);
|
|
procedure mnuProtestadoClick(Sender: TObject);
|
|
procedure mnuDevolucaoClick(Sender: TObject);
|
|
procedure mnuProtestoAposBaixaClick(Sender: TObject);
|
|
procedure mnuPagoDiretoClick(Sender: TObject);
|
|
procedure mnuSubstituicaoClick(Sender: TObject);
|
|
procedure mnuFaltaClick(Sender: TObject);
|
|
procedure mnuAPedidoClienteClick(Sender: TObject);
|
|
procedure mnuBaixarCobClick(Sender: TObject);
|
|
procedure cdsBoletosAfterScroll(DataSet: TDataSet);
|
|
procedure spdbtnPesquisaClick(Sender: TObject);
|
|
procedure DBGrid2DblClick(Sender: TObject);
|
|
procedure cbSituacaoChange(Sender: TObject);
|
|
procedure btnPreparaBoletoClick(Sender: TObject);
|
|
procedure dtpVencimentoIniChange(Sender: TObject);
|
|
procedure dtpVencimentoFimChange(Sender: TObject);
|
|
procedure clbEmpresasTitulosClickCheck(Sender: TObject);
|
|
procedure dtsDevedorStateChange(Sender: TObject);
|
|
procedure DBEdit6KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit7KeyPress(Sender: TObject; var Key: Char);
|
|
procedure btnGerarBoletoClick(Sender: TObject);
|
|
procedure btnFichaClienteClick(Sender: TObject);
|
|
procedure DBNavigator1BeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
private
|
|
opcoes_situacao, opcoes_datatipo, opcoes_ordem: TStringList;
|
|
JSONBoletoUnico: TJSONObject;
|
|
vl_bol: currency;
|
|
function RequestJSON(URL: String; Body: TStringStream = nil): TJSONObject;
|
|
function POST2(URL: String; Body: TStringStream = nil): TJSONObject;
|
|
function RequestBase64(URL: String; Body: TStringStream = nil): string;
|
|
function SendJSON(URL: String; JSON: TJSONObject): string;
|
|
function ValidadorPagador: TStringArray;
|
|
function ValidadorDescontos: TStringArray;
|
|
function ValidadorMultaMora: TStringArray;
|
|
function ValidadorBeneficiado: TStringArray;
|
|
function ValidadorBoleto: TStringArray;
|
|
|
|
procedure JsonToDataset2(aDataset: TDataSet; aJSON: string);
|
|
|
|
procedure JsonToClientDataSetString(aDataset: TDataSet; aJSON: string);
|
|
procedure JsonArrayToDataset(aDataset: TDataSet; aJSON: TJSONArray);
|
|
|
|
procedure HorScrollBar(ListBox: TCheckListBox; MaxWidth: Integer);
|
|
procedure AdjustCheckListBox(ListBox: TCheckListBox);
|
|
|
|
procedure FiltrarTitulos;
|
|
|
|
function Request(Method: TMethod; URL: String; Body: TStringStream = nil)
|
|
: TJSONObject;
|
|
function JsonArrayToText(jObj: TJSONObject; strField: string): string;
|
|
|
|
{ Private declarations }
|
|
public
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmCentralBoletos: TfrmCentralBoletos;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem, ufrmGrupoBoletoEmpresas, ucadDevedores;
|
|
|
|
var
|
|
jsonBoletoBase: string = '{' + ' "pagador":{' + ' "cpfCnpj":"",' +
|
|
' "nome":"",' + ' "cep":"",' + ' "endereco":"",' +
|
|
' "numero":"",' + ' "complemento":"",' + ' "bairro":"",' +
|
|
' "cidade":"",' + ' "uf":"",' + ' "email":"",' +
|
|
' "ddd":"",' + ' "telefone":"",' + ' "tipoPessoa":""' +
|
|
' },' + ' "dataEmissao":"",' + ' "seuNumero":"",' +
|
|
' "dataLimite":"",' + ' "dataVencimento":"",' + ' "mensagem":{' +
|
|
' "linha1":"",' + ' "linha2":"",' + ' "linha3":"",' +
|
|
' "linha4":"",' + ' "linha5":""' + ' },' + ' "desconto1":{' +
|
|
' "codigoDesconto":"",' + ' "taxa":0,' + ' "valor":0,' +
|
|
' "data":""' + ' },' + ' "desconto2":{' +
|
|
' "codigoDesconto":"",' + ' "taxa":0,' + ' "valor":0,' +
|
|
' "data":""' + ' },' + ' "desconto3":{' +
|
|
' "codigoDesconto":"",' + ' "taxa":0,' + ' "valor":0,' +
|
|
' "data":""' + ' },' + ' "valorNominal":0,' +
|
|
' "valorAbatimento":0,' + ' "multa":{' + ' "codigoMulta":"",' +
|
|
' "valor":0,' + ' "taxa":0,' + ' "data":""' + ' },' +
|
|
' "mora":{' + ' "codigoMora":"",' + ' "valor":0,' +
|
|
' "taxa":0,' + ' "data":""' + ' },' +
|
|
' "cnpjCPFBeneficiario":"",' + ' "numDiasAgenda":""' + '}';
|
|
jsonBase: string =
|
|
'{"seuNumero": "", "valorNominal": 0, "dataVencimento": "", "numDiasAgenda": 0, '
|
|
+ '"pagador": {"cpfCnpj": "", "tipoPessoa": "", "nome": "", "endereco": "", "cidade": "", "uf": "", "cep": ""}, '
|
|
+ '"desconto1": {"codigoDesconto": "", "taxa": 0, "valor": 0}, ' +
|
|
'"desconto2": {"codigoDesconto": "", "taxa": 0, "valor": 0}, ' +
|
|
'"desconto3": {"codigoDesconto": "", "taxa": 0, "valor": 0}, ' + '"multa":{}'+'}';
|
|
|
|
situacoes: array [0 .. 6] of string = (
|
|
'A',
|
|
'AC',
|
|
'AB',
|
|
'AJ',
|
|
'B',
|
|
'QC',
|
|
'QB'
|
|
);
|
|
|
|
procedure TfrmCentralBoletos.AdjustCheckListBox(ListBox: TCheckListBox);
|
|
var
|
|
i, nMaxWidth, nItemWidth: Integer;
|
|
begin
|
|
// ajusta o checklistbox pra ter scroll horizontal
|
|
nMaxWidth := ListBox.ClientWidth;
|
|
for i := 0 to ListBox.Items.Count - 1 do
|
|
begin
|
|
nItemWidth := ListBox.Canvas.TextWidth(ListBox.Items[i]) + 20;
|
|
if (nItemWidth > nMaxWidth) then
|
|
nMaxWidth := nItemWidth;
|
|
end;
|
|
if (nMaxWidth > ListBox.ClientWidth) then
|
|
begin
|
|
ListBox.ScrollWidth := nMaxWidth;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.btn_gerarbolunicoClick(Sender: TObject);
|
|
var
|
|
pagador, mensagem, desc1, desc2, desc3, multa, mora, resposta: TJSONObject;
|
|
JSONPair: TJSONPair;
|
|
i: Integer;
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
|
|
if MessageDlg
|
|
('Por favor verifique se as datas para Multa e Mora estão preenchidas corretamente.'
|
|
+ ' Esses valor não são calculados automaticamente.' + ' Deseja continuar?',
|
|
mtWarning, [mbYes, mbNo], 0) = mrNo then
|
|
begin
|
|
abort;
|
|
end;
|
|
|
|
if ValidadorPagador[0] = 'False' then
|
|
begin
|
|
MessageDlg(ValidadorPagador[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
if ValidadorDescontos[0] = 'False' then
|
|
begin
|
|
MessageDlg(ValidadorDescontos[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
if ValidadorMultaMora[0] = 'False' then
|
|
begin
|
|
MessageDlg(ValidadorMultaMora[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
with dtmSystem do
|
|
begin
|
|
tblBoletos.Append;
|
|
|
|
// tblBoletosVL_NOMINAL.AsCurrency := StrToCurr(edt_valorboleto.Text);
|
|
// if edt_abatimentobol.Text <> '' then
|
|
// begin
|
|
// tblBoletosVL_ABATIMENTO.AsCurrency := StrToCurr(edt_abatimentobol.Text);
|
|
// end
|
|
// else
|
|
// begin
|
|
// tblBoletosVL_ABATIMENTO.AsCurrency := 0;
|
|
// end;
|
|
// tblBoletosDT_VENCIMENTO.AsDateTime := dt_vencbolunico.Date;
|
|
tblBoletos.POST;
|
|
// for i := 0 to dbgrd_bolunico.SelectedRows.Count - 1 do
|
|
// begin
|
|
// zroqryBolUnico.GotoBookmark
|
|
// (pointer(dbgrd_bolunico.SelectedRows.Items[i]));
|
|
// tblBoletoTitulos.Append;
|
|
// tblBoletoTitulosID_DEVEDOR.AsInteger :=
|
|
// zroqryBolUnicoID_DEVEDOR.AsInteger;
|
|
// tblBoletoTitulosID_TITULO.AsInteger := zroqryBolUnicoID_TITULO.AsInteger;
|
|
// tblBoletoTitulosID_BOLETO.AsInteger := tblBoletosID.AsInteger;
|
|
// tblBoletoTitulos.POST;
|
|
// end;
|
|
end;
|
|
|
|
try
|
|
JSONBoletoUnico := TJSONObject.ParseJSONValue(jsonBoletoBase)
|
|
as TJSONObject;
|
|
except
|
|
|
|
end;
|
|
|
|
JSONPair := JSONBoletoUnico.GET('seuNumero');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create
|
|
// (dtmSystem.tblBoletosNR_NOSSO_NUMERO.AsString);
|
|
|
|
JSONPair := JSONBoletoUnico.GET('cnpjCPFBeneficiario');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONString.create
|
|
(StringReplace(StringReplace(StringReplace(dtmSystem.tblEmpresaTX_CNPJ.
|
|
AsString, '.', '', [rfReplaceAll]), '-', '', [rfReplaceAll]), '/', '',
|
|
[rfReplaceAll]));
|
|
|
|
JSONPair := JSONBoletoUnico.GET('valorNominal');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONNumber.create
|
|
// (dtmSystem.tblBoletosVL_NOMINAL.AsString);
|
|
|
|
JSONPair := JSONBoletoUnico.GET('valorAbatimento');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONNumber.create
|
|
// (dtmSystem.tblBoletosVL_ABATIMENTO.AsString);
|
|
|
|
JSONPair := JSONBoletoUnico.GET('dataEmissao');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONString.create(FormatDateTime('yyyy-mm-dd', Date));
|
|
|
|
JSONPair := JSONBoletoUnico.GET('dataVencimento');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(FormatDateTime('yyyy-mm-dd',
|
|
// dtmSystem.tblBoletosDT_VENCIMENTO.AsDateTime));
|
|
|
|
JSONPair := JSONBoletoUnico.GET('numDiasAgenda');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(cb_agendabol.Text);
|
|
|
|
JSONPair := JSONBoletoUnico.GET('dataLimite');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(cb_dtlimitebol.Text);
|
|
|
|
pagador := JSONBoletoUnico.Values['pagador'] as TJSONObject;
|
|
JSONPair := pagador.GET('cnpjCpf');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_docbolunico.Text);
|
|
|
|
JSONPair := pagador.GET('tipoPessoa');
|
|
JSONPair.JsonValue.Free;
|
|
// if length(edt_docbolunico.Text) = 11 then
|
|
// begin
|
|
// JSONPair.JsonValue := TJSONString.create('FISICA');
|
|
// end
|
|
// else
|
|
// begin
|
|
// JSONPair.JsonValue := TJSONString.create('JURIDICA');
|
|
// end;
|
|
|
|
JSONPair := pagador.GET('nome');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_nomebolunico.Text);
|
|
|
|
JSONPair := pagador.GET('endereco');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_endbolunico.Text);
|
|
|
|
JSONPair := pagador.GET('numero');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_endnumbolunico.Text);
|
|
|
|
JSONPair := pagador.GET('complemento');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_compbolunico.Text);
|
|
|
|
JSONPair := pagador.GET('bairro');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_bairrobolunico.Text);
|
|
|
|
JSONPair := pagador.GET('cidade');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_cidadebolunico.Text);
|
|
|
|
JSONPair := pagador.GET('uf');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_estadobolunico.Text);
|
|
|
|
JSONPair := pagador.GET('cep');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_cepbolunico.Text);
|
|
|
|
JSONPair := pagador.GET('email');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_emailbolunico.Text);
|
|
|
|
JSONPair := pagador.GET('ddd');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_dddbolunico.Text);
|
|
|
|
JSONPair := pagador.GET('telefone');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_telbolunico.Text);
|
|
|
|
mensagem := JSONBoletoUnico.Values['mensagem'] as TJSONObject;
|
|
|
|
JSONPair := mensagem.GET('linha1');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_linha1bol.Text);
|
|
|
|
JSONPair := mensagem.GET('linha2');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_linha2bol.Text);
|
|
|
|
JSONPair := mensagem.GET('linha3');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_linha3bol.Text);
|
|
|
|
JSONPair := mensagem.GET('linha4');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_linha4bol.Text);
|
|
|
|
JSONPair := mensagem.GET('linha5');
|
|
JSONPair.JsonValue.Free;
|
|
// JSONPair.JsonValue := TJSONString.create(edt_linha5bol.Text);
|
|
|
|
desc1 := JSONBoletoUnico.Values['desconto1'] as TJSONObject;
|
|
|
|
JSONPair := desc1.GET('codigoDesconto');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONString.create(cb_desc1.Text);
|
|
|
|
JSONPair := desc1.GET('data');
|
|
JSONPair.JsonValue.Free;
|
|
if cb_desc1.ItemIndex = 0 then
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create('');
|
|
end
|
|
else
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create(FormatDateTime('yyyy-mm-dd',
|
|
dtp_desc1.Date));
|
|
end;
|
|
|
|
JSONPair := desc1.GET('taxa');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_taxa1bol.Text);
|
|
|
|
JSONPair := desc1.GET('valor');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_val1bol.Text);
|
|
|
|
desc2 := JSONBoletoUnico.Values['desconto2'] as TJSONObject;
|
|
|
|
JSONPair := desc2.GET('codigoDesconto');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONString.create(cb_desc2.Text);
|
|
|
|
JSONPair := desc2.GET('data');
|
|
JSONPair.JsonValue.Free;
|
|
if cb_desc2.ItemIndex = 0 then
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create('');
|
|
end
|
|
else
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create(FormatDateTime('yyyy-mm-dd',
|
|
dtp_desc2.Date));
|
|
end;
|
|
|
|
JSONPair := desc2.GET('taxa');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_taxa2bol.Text);
|
|
|
|
JSONPair := desc2.GET('valor');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_val2bol.Text);
|
|
|
|
desc3 := JSONBoletoUnico.Values['desconto3'] as TJSONObject;
|
|
|
|
JSONPair := desc3.GET('codigoDesconto');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONString.create(cb_desc3.Text);
|
|
|
|
JSONPair := desc3.GET('data');
|
|
JSONPair.JsonValue.Free;
|
|
if cb_desc3.ItemIndex = 0 then
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create('');
|
|
end
|
|
else
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create(FormatDateTime('yyyy-mm-dd',
|
|
dtp_desc3.Date));
|
|
end;
|
|
|
|
JSONPair := desc3.GET('taxa');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_taxa3bol.Text);
|
|
|
|
JSONPair := desc3.GET('valor');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_val3bol.Text);
|
|
|
|
multa := JSONBoletoUnico.Values['multa'] as TJSONObject;
|
|
|
|
JSONPair := multa.GET('codigoMulta');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONString.create(cb_multabol.Text);
|
|
|
|
JSONPair := multa.GET('data');
|
|
JSONPair.JsonValue.Free;
|
|
if cb_multabol.ItemIndex = 0 then
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create('');
|
|
end
|
|
else
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create(FormatDateTime('yyyy-mm-dd',
|
|
dtp_multa.Date));
|
|
end;
|
|
|
|
JSONPair := multa.GET('taxa');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_taxamultabol.Text);
|
|
|
|
JSONPair := multa.GET('valor');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_vlmultabol.Text);
|
|
|
|
mora := JSONBoletoUnico.Values['mora'] as TJSONObject;
|
|
|
|
JSONPair := mora.GET('codigoMora');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONString.create(cb_morabol.Text);
|
|
|
|
JSONPair := mora.GET('data');
|
|
JSONPair.JsonValue.Free;
|
|
if cb_morabol.ItemIndex = 2 then
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create('');
|
|
end
|
|
else
|
|
begin
|
|
JSONPair.JsonValue := TJSONString.create(FormatDateTime('yyyy-mm-dd',
|
|
dtp_mora.Date));
|
|
end;
|
|
|
|
JSONPair := mora.GET('taxa');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_taxamorabol.Text);
|
|
|
|
JSONPair := mora.GET('valor');
|
|
JSONPair.JsonValue.Free;
|
|
JSONPair.JsonValue := TJSONNumber.create(edt_vlmorabol.Text);
|
|
|
|
resp := SendJSON
|
|
('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos',
|
|
JSONBoletoUnico);
|
|
|
|
if resp = 'Error' then
|
|
begin
|
|
// while dtmSystem.tblBoletoTitulos.Locate('ID_BOLETO',
|
|
// dtmSystem.tblBoletosID.AsInteger, []) do
|
|
// begin
|
|
// dtmSystem.tblBoletoTitulos.DELETE;
|
|
// end;
|
|
dtmSystem.tblBoletos.DELETE;
|
|
dtmSystem.seqBoletos.BlockSize := -1;
|
|
dtmSystem.seqBoletos.GetNextValue;
|
|
dtmSystem.seqBoletos.BlockSize := 1;
|
|
end
|
|
else
|
|
begin
|
|
resposta := TJSONObject.ParseJSONValue(resp) as TJSONObject;
|
|
|
|
dtmSystem.tblBoletos.Edit;
|
|
// dtmSystem.tblBoletosCD_COD_BARRAS.AsString :=
|
|
// resposta.Values['codigoBarras'].Value;
|
|
// dtmSystem.tblBoletosCD_COD_BARRAS.AsString :=
|
|
// resposta.Values['linhaDigitavel'].Value;
|
|
// dtmSystem.tblBoletos.POST;
|
|
// Showmessage('Boleto de Nº ' + dtmSystem.tblBoletosNR_NOSSO_NUMERO.AsString +
|
|
// ' gerado com sucesso!'#13#10 +
|
|
// ' Aguarde aproximadamente por 5 minutos para poder consultá-lo.');
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.btnFichaClienteClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
cadDevedores := TcadDevedores.create(Self);
|
|
try
|
|
cadDevedores.ShowModal;
|
|
finally
|
|
cadDevedores.Free;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.btnGerarBoletoClick(Sender: TObject);
|
|
var
|
|
resValidador: TStringArray;
|
|
begin
|
|
inherited;
|
|
Screen.Cursor := crHourGlass;
|
|
SetLength(resValidador, 2);
|
|
resValidador := ValidadorPagador;
|
|
if resValidador[0] = 'False' then
|
|
begin
|
|
MessageDlg(resValidador[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
resValidador := ValidadorDescontos;
|
|
if resValidador[0] = 'False' then
|
|
begin
|
|
MessageDlg(resValidador[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
resValidador := ValidadorMultaMora;
|
|
if resValidador[0] = 'False' then
|
|
begin
|
|
MessageDlg(resValidador[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
resValidador := ValidadorBeneficiado;
|
|
if resValidador[0] = 'False' then
|
|
begin
|
|
MessageDlg(resValidador[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
resValidador := ValidadorBoleto;
|
|
if resValidador[0] = 'False' then
|
|
begin
|
|
MessageDlg(resValidador[1], mtError, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
if dtmSystem.tblDevEmpBoletos.IsEmpty then
|
|
begin
|
|
if MessageDlg('Este devedor não possui empresas vinculadas ao boleto.' +
|
|
' Não será possível vincular o boleto a títulos do Sistema. Deseja continuar?',
|
|
mtWarning, [mbYes, mbNo], 0) = mrNo then
|
|
begin
|
|
abort;
|
|
end;
|
|
end;
|
|
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.btnPreparaBoletoClick(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
docHelper: string;
|
|
selecionouAlgo: boolean;
|
|
vlNominal: currency;
|
|
begin
|
|
inherited;
|
|
// Showmessage(inttostr(dbgrdTitulos.SelectedRows.Count));
|
|
// for i := 0 to dbgrdTitulos.SelectedRows.Count - 1 do
|
|
// begin
|
|
// dbgrdTitulos.DataSource.DataSet.GotoBookmark
|
|
// (Pointer(dbgrdTitulos.SelectedRows.Items[i]));
|
|
// Showmessage(dbgrdTitulos.DataSource.DataSet.FieldByName
|
|
// ('tx_produto').AsString)
|
|
// end;
|
|
|
|
Screen.Cursor := crHourGlass;
|
|
|
|
// Zerando a página
|
|
|
|
edtNomePagador.Clear;
|
|
edtDocumentoPagador.Clear;
|
|
cbTipoPagador.ItemIndex := -1;
|
|
edtEmailPagador.Clear;
|
|
edtEnderecoPagador.Clear;
|
|
edtNumeroPagador.Clear;
|
|
edtComplementoPagador.Clear;
|
|
edtBairroPagador.Clear;
|
|
edtCidadePagador.Clear;
|
|
edtUfPagador.Clear;
|
|
edtCepPagador.Clear;
|
|
edtDddPagador.Clear;
|
|
edtTelefonePagador.Clear;
|
|
|
|
edtSeuNumeroBoleto.Clear;
|
|
edtVlNominalBoleto.Clear;
|
|
dtpVencimentoBoleto.Date := Date;
|
|
edtDiasCancelamentoBoleto.Text := '0';
|
|
cb_multabol.ItemIndex := -1;
|
|
cb_morabol.ItemIndex := -1;
|
|
cb_desc1.ItemIndex := -1;
|
|
cb_desc2.ItemIndex := -1;
|
|
cb_desc3.ItemIndex := -1;
|
|
edt_taxamultabol.Clear;
|
|
edt_taxamorabol.Clear;
|
|
edt_taxa1bol.Clear;
|
|
edt_taxa2bol.Clear;
|
|
edt_taxa3bol.Clear;
|
|
edt_vlmorabol.Clear;
|
|
edt_vlmultabol.Clear;
|
|
edt_val1bol.Clear;
|
|
edt_val2bol.Clear;
|
|
edt_val3bol.Clear;
|
|
dtp_mora.Date := Date;
|
|
dtp_multa.Date := Date;
|
|
dtp_desc1.Date := Date;
|
|
dtp_desc2.Date := Date;
|
|
dtp_desc3.Date := Date;
|
|
edtLinha1Boleto.Clear;
|
|
edtLinha2Boleto.Clear;
|
|
edtLinha3Boleto.Clear;
|
|
edtLinha4Boleto.Clear;
|
|
edtLinha5Boleto.Clear;
|
|
|
|
edtNomeBeneficiario.Clear;
|
|
edtDocumentoBeneficiario.Clear;
|
|
cbTipoBeneficiario.ItemIndex := -1;
|
|
edtEnderecoBeneficiario.Clear;
|
|
edtBairroBeneficiario.Clear;
|
|
edtCidadeBeneficiario.Clear;
|
|
edtUfBeneficiario.Clear;
|
|
edtCepBeneficiario.Clear;
|
|
|
|
with dtmSystem do
|
|
begin
|
|
try
|
|
try
|
|
edtNomePagador.Text := tblDevedoresTX_NOME.AsString;
|
|
cbTipoPagador.ItemIndex :=
|
|
IfThen(tblDevedoresTP_CLIENTE.AsString = 'F', 0, 1);
|
|
if tblDevedoresTP_CLIENTE.AsString = 'F' then
|
|
begin
|
|
docHelper := StringReplace(tblDevedoresCD_CPF.AsString, '.', '',
|
|
[rfReplaceAll]);
|
|
docHelper := StringReplace(docHelper, '-', '', [rfReplaceAll]);
|
|
docHelper := docHelper.PadLeft(14, '0');
|
|
end
|
|
else
|
|
begin
|
|
docHelper := StringReplace(tblDevedoresCD_CNPJ.AsString, '.', '',
|
|
[rfReplaceAll]);
|
|
docHelper := StringReplace(tblDevedoresCD_CNPJ.AsString, '-', '',
|
|
[rfReplaceAll]);
|
|
docHelper := StringReplace(tblDevedoresCD_CNPJ.AsString, '/', '',
|
|
[rfReplaceAll]);
|
|
end;
|
|
edtDocumentoPagador.Text := docHelper;
|
|
if not tblEmail.IsEmpty then
|
|
begin
|
|
edtEmailPagador.Text := tblEmailTX_EMAIL.AsString;
|
|
end
|
|
else
|
|
begin
|
|
edtEmailPagador.Text := '';
|
|
end;
|
|
if not tblEnderecos.IsEmpty then
|
|
begin
|
|
edtEnderecoPagador.Text := tblEnderecosTX_LOGRADOURO.AsString;
|
|
edtNumeroPagador.Text := tblEnderecosNR_NUMERO.AsString;
|
|
edtComplementoPagador.Text := tblEnderecosTX_COMPLEMENTO.AsString;
|
|
edtBairroPagador.Text := tblEnderecosTX_BAIRRO.AsString;
|
|
edtCidadePagador.Text := tblEnderecosTX_CIDADE.AsString;
|
|
edtUfPagador.Text := tblEnderecosTX_UF.AsString;
|
|
end
|
|
else
|
|
begin
|
|
edtEnderecoPagador.Clear;
|
|
edtNumeroPagador.Clear;
|
|
edtComplementoPagador.Clear;
|
|
edtBairroPagador.Clear;
|
|
edtCidadePagador.Clear;
|
|
edtUfPagador.Clear;
|
|
edtCepPagador.Clear;
|
|
end;
|
|
if not tblTelefones.IsEmpty then
|
|
begin
|
|
edtDddPagador.Text := tblTelefonesNR_DDD.AsString;
|
|
edtTelefonePagador.Text := tblTelefonesNR_NUMERO.AsString;
|
|
end
|
|
else
|
|
begin
|
|
edtDddPagador.Clear;
|
|
edtTelefonePagador.Clear;
|
|
end;
|
|
|
|
cb_multabol.ItemIndex := -1;
|
|
cb_morabol.ItemIndex := -1;
|
|
cb_desc1.ItemIndex := -1;
|
|
cb_desc2.ItemIndex := -1;
|
|
cb_desc3.ItemIndex := -1;
|
|
edt_taxamultabol.Clear;
|
|
edt_taxamorabol.Clear;
|
|
edt_taxa1bol.Clear;
|
|
edt_taxa2bol.Clear;
|
|
edt_taxa3bol.Clear;
|
|
edt_vlmorabol.Clear;
|
|
edt_vlmultabol.Clear;
|
|
edt_val1bol.Clear;
|
|
edt_val2bol.Clear;
|
|
edt_val3bol.Clear;
|
|
dtp_mora.Date := Date;
|
|
dtp_multa.Date := Date;
|
|
dtp_desc1.Date := Date;
|
|
dtp_desc2.Date := Date;
|
|
dtp_desc3.Date := Date;
|
|
|
|
edtLinha1Boleto.Clear;
|
|
edtLinha2Boleto.Clear;
|
|
edtLinha3Boleto.Clear;
|
|
edtLinha4Boleto.Clear;
|
|
edtLinha5Boleto.Clear;
|
|
|
|
edtNomeBeneficiario.Text := tblEmpresaTX_NOME.AsString;
|
|
edtDocumentoBeneficiario.Text := tblEmpresaTX_CNPJ.AsString;
|
|
cbTipoBeneficiario.ItemIndex := 1;
|
|
edtEnderecoBeneficiario.Text := tblEmpresaTX_ENDERECO.AsString;
|
|
edtBairroBeneficiario.Text := tblEmpresaTX_BAIRRO.AsString;
|
|
edtCidadeBeneficiario.Text := tblEmpresaTX_CIDADE.AsString;
|
|
edtUfBeneficiario.Text := tblEmpresaTX_UF.AsString;
|
|
edtCepBeneficiario.Text := tblEmpresaTX_CEP.AsString;
|
|
|
|
pcPesquisaGerar.TabIndex := 1;
|
|
except
|
|
|
|
end;
|
|
finally
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.cbSituacaoChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FiltrarTitulos;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.cdsBoletosAfterScroll(DataSet: TDataSet);
|
|
begin
|
|
inherited;
|
|
JsonToDataset2(tblPagador, Format('[%s]',
|
|
[cdsBoletos.FieldByName('pagador').AsString]));
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.clbEmpresasTitulosClickCheck(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FiltrarTitulos;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.DBEdit6KeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
inherited;
|
|
if not(Key in [#8, '0' .. '9',
|
|
System.SysUtils.FormatSettings.DecimalSeparator]) then
|
|
begin
|
|
Key := #0;
|
|
end
|
|
else if (Key = System.SysUtils.FormatSettings.DecimalSeparator) and
|
|
(Pos(Key, (Sender as TDBEdit).Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.DBEdit7KeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
inherited;
|
|
if not(Key in [#8, '0' .. '9',
|
|
System.SysUtils.FormatSettings.DecimalSeparator]) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.dbgrd_boletosDrawColumnCell(Sender: TObject;
|
|
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
begin
|
|
// case AnsiIndexStr(tblBoletossituacao.AsString, ['BAIXADO', 'PAGO']) of
|
|
// 0:
|
|
// dbgrd_boletos.Canvas.Brush.Color := $7AA0FF;
|
|
// 1:
|
|
// dbgrd_boletos.Canvas.Brush.Color := $FFF8F0;
|
|
// end;
|
|
// dbgrd_boletos.DefaultDrawColumnCell(Rect, DataCol, Column, State);
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.dbgrd_boletosMouseUp(Sender: TObject;
|
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|
var
|
|
Pt: TPoint;
|
|
Coord: TGridCoord;
|
|
begin
|
|
inherited;
|
|
Pt := dbgrd_boletos.ScreenToClient(Mouse.CursorPos);
|
|
Coord := dbgrd_boletos.MouseCoord(Pt.X, Pt.Y);
|
|
if (Coord.Y > 0) and not(cdsBoletos.IsEmpty) and (Button = mbRight) then
|
|
begin
|
|
pum_download.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.dbgrd_bolunicoMouseUp(Sender: TObject;
|
|
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
|
var
|
|
Pt: TPoint;
|
|
Coord: TGridCoord;
|
|
begin
|
|
inherited;
|
|
// Pt := dbgrd_bolunico.ScreenToClient(Mouse.CursorPos);
|
|
// Coord := dbgrd_bolunico.MouseCoord(Pt.X, Pt.Y);
|
|
// if (Coord.Y > 0) and not(zroqryBolUnico.IsEmpty) and (Button = mbRight) then
|
|
// begin
|
|
// pum_incldel.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.DBGrid2DblClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
with dtmSystem do
|
|
begin
|
|
Screen.Cursor := crHourGlass;
|
|
OpenOrRefresh(tblDevedores);
|
|
if tblDevedores.Locate('ID_DEVEDOR', zroqryPesquisaID_DEVEDOR.AsInteger, [])
|
|
then
|
|
begin
|
|
cdsHist.DisableControls;
|
|
|
|
if cdsHist.RecordCount > 10 then
|
|
begin
|
|
cdsHist.First;
|
|
cdsHist.DELETE;
|
|
end;
|
|
|
|
if not(cdsHist.Locate('TX_NOME', zroqryPesquisaTX_NOME.AsString,
|
|
[loCaseInsensitive, loPartialKey])) then
|
|
begin
|
|
cdsHist.Append;
|
|
cdsHisttx_nome.AsString := zroqryPesquisaTX_NOME.AsString;
|
|
cdsHistid_devedor.AsInteger := zroqryPesquisaID_DEVEDOR.AsInteger;
|
|
cdsHist.POST;
|
|
end;
|
|
|
|
cdsHist.EnableControls;
|
|
if not Assigned(dtsDevedor.DataSet) then
|
|
begin
|
|
dtsDevedor.DataSet := dtmSystem.tblDevedores;
|
|
end;
|
|
OpenOrRefresh(tblEnderecos);
|
|
OpenOrRefresh(tblTelefones);
|
|
OpenOrRefresh(tblEmail);
|
|
OpenOrRefresh(tblTitulos);
|
|
OpenOrRefresh(tblHistorico);
|
|
btnFichaCliente.Enabled := true;
|
|
end;
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.DBNavigator1BeforeAction(Sender: TObject;
|
|
Button: TNavigateBtn);
|
|
begin
|
|
inherited;
|
|
if Button = nbPost then
|
|
begin
|
|
dtmSystem.tblDevEmpBoletosID_DEVEDOR.AsInteger := dtmSystem.id_devedor;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.dtpVencimentoFimChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FiltrarTitulos;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.dtpVencimentoIniChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
FiltrarTitulos;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.dtsBoletosDataChange(Sender: TObject;
|
|
Field: TField);
|
|
begin
|
|
// if not tblBoletos.IsEmpty then
|
|
// begin
|
|
// if tblBoletosdesconto1.AsString <> '' then
|
|
// begin
|
|
// tblDesc1.ReadOnly := False;
|
|
// JsonToDataset2(tblDesc1, '[' + TJSONObject.ParseJSONValue
|
|
// (tblBoletosdesconto1.AsString).ToString + ']');
|
|
// tblDesc1.ReadOnly := True;
|
|
// end;
|
|
// if tblBoletosdesconto2.AsString <> '' then
|
|
// begin
|
|
// tblDesc2.ReadOnly := False;
|
|
// JsonToDataset2(tblDesc2, '[' + TJSONObject.ParseJSONValue
|
|
// (tblBoletosdesconto2.AsString).ToString + ']');
|
|
// tblDesc2.ReadOnly := True;
|
|
// end;
|
|
// if tblBoletosdesconto3.AsString <> '' then
|
|
// begin
|
|
// tblDesc3.ReadOnly := False;
|
|
// JsonToDataset2(tblDesc3, '[' + TJSONObject.ParseJSONValue
|
|
// (tblBoletosdesconto3.AsString).ToString + ']');
|
|
// tblDesc3.ReadOnly := True;
|
|
// end;
|
|
// if tblBoletosmulta.AsString <> '' then
|
|
// begin
|
|
// tblMulta.ReadOnly := False;
|
|
// JsonToDataset2(tblMulta, '[' + TJSONObject.ParseJSONValue
|
|
// (tblBoletosmulta.AsString).ToString + ']');
|
|
// tblMulta.ReadOnly := True;
|
|
// end;
|
|
// if tblBoletosmora.AsString <> '' then
|
|
// begin
|
|
// tblMora.ReadOnly := False;
|
|
// JsonToDataset2(tblMora, '[' + TJSONObject.ParseJSONValue
|
|
// (tblBoletosmora.AsString).ToString + ']');
|
|
// tblMora.ReadOnly := True;
|
|
// end;
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.dtsDevedorStateChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
dbedtNomeDevBoleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dbedtDocDevBoleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dblucbEndDevBoleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dblucbTelDevBoleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dblucbEmailDevBoleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dbEdtLinha1Boleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dbEdtLinha2Boleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dbEdtLinha3Boleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dbEdtLinha4Boleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
dbEdtLinha5Boleto.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
|
|
DBLookupComboBox5.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit6.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit5.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit7.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
|
|
DBLookupComboBox6.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit9.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit8.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit10.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
|
|
DBLookupComboBox7.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit11.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit14.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit17.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
|
|
DBLookupComboBox8.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit12.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit15.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit18.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
|
|
DBLookupComboBox9.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit13.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit16.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
DBEdit19.ReadOnly := not(dtsDevedor.DataSet.State in [dsEdit]);
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.FiltrarTitulos;
|
|
begin
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.FormCreate(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
vl_bol := 0;
|
|
opcoes_situacao := TStringList.create;
|
|
opcoes_situacao.Add('TODOS');
|
|
opcoes_situacao.Add('VENCIDOSAVENCER');
|
|
opcoes_situacao.Add('EXPIRADOS');
|
|
opcoes_situacao.Add('PAGOS');
|
|
opcoes_situacao.Add('TODOSBAIXADOS');
|
|
|
|
opcoes_datatipo := TStringList.create;
|
|
opcoes_datatipo.Add('VENCIMENTO');
|
|
opcoes_datatipo.Add('EMISSAO');
|
|
opcoes_datatipo.Add('SITUACAO');
|
|
|
|
opcoes_ordem := TStringList.create;
|
|
opcoes_ordem.Add('NOSSONUMERO');
|
|
opcoes_ordem.Add('SEUNUMERO');
|
|
opcoes_ordem.Add('DATAVENCIMENTO_ASC');
|
|
opcoes_ordem.Add('DATAVENCIMENTO_DSC');
|
|
opcoes_ordem.Add('NOMESACADO');
|
|
opcoes_ordem.Add('VALOR_ASC');
|
|
opcoes_ordem.Add('VALOR_DSC');
|
|
opcoes_ordem.Add('STATUS_ASC');
|
|
opcoes_ordem.Add('STATUS_DSC');
|
|
|
|
dt_inicio.Date := StartOfTheMonth(Date);
|
|
dt_fim.Date := EndOfTheMonth(Date);
|
|
// dt_vencbolunico.Date := Date;
|
|
// dtp_vencinbolunico.Date := StartOfTheMonth(Date);
|
|
// dtp_vencoutbolunico.Date := EndOfTheMonth(Date);
|
|
|
|
with dtmSystem do
|
|
begin
|
|
OpenOrRefresh(tblEstados);
|
|
OpenOrRefresh(tblCidades);
|
|
OpenOrRefreshRO(tblCidadesConsulta);
|
|
OpenOrRefresh(tblBoletos);
|
|
OpenOrRefresh(tblBoletoTitulos);
|
|
OpenOrRefresh(tblEmpresa);
|
|
OpenOrRefresh(tblDevEmpBoletos);
|
|
// dblucb_filtrobolunico.KeyValue := tblGrupoBoletosID_GRUPO.AsInteger;
|
|
end;
|
|
|
|
IdSSLHandler.SSLOptions.CertFile := dtmSystem.tblEmpresaPATH_CERT.AsString;
|
|
IdSSLHandler.SSLOptions.KeyFile := dtmSystem.tblEmpresaPATH_KEY.AsString;
|
|
IdSSLHandler.SSLOptions.RootCertFile :=
|
|
dtmSystem.tblEmpresaPATH_CERT.AsString;
|
|
GIdDefaultTextEncoding := encUTF8;
|
|
|
|
dtsDevedor.DataSet := nil;
|
|
|
|
// zroqryBolUnico.Open;
|
|
// zroqryEmails.Open;
|
|
// zroqryTelefones.Open;
|
|
// zroqryEnderecos.Open;
|
|
// pcGeraBoletos.TabIndex := 0;
|
|
pcBoletos.TabIndex := 0;
|
|
pcPesquisaGerar.TabIndex := 0;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.HorScrollBar(ListBox: TCheckListBox;
|
|
MaxWidth: Integer);
|
|
var
|
|
i, w: Integer;
|
|
begin
|
|
if MaxWidth = 0 then
|
|
SendMessage(ListBox.Handle, LB_SETHORIZONTALEXTENT, MaxWidth, 0)
|
|
else
|
|
begin
|
|
{ get largest item }
|
|
for i := 0 to ListBox.Items.Count - 1 do
|
|
with ListBox do
|
|
begin
|
|
w := Canvas.TextWidth(Items[i]);
|
|
if w > MaxWidth then
|
|
MaxWidth := w;
|
|
end;
|
|
SendMessage(ListBox.Handle, LB_SETHORIZONTALEXTENT,
|
|
MaxWidth + GetSystemMetrics(SM_CXFRAME), 0);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.JsonArrayToDataset(aDataset: TDataSet;
|
|
aJSON: TJSONArray);
|
|
var
|
|
vConv: TCustomJSONDataSetAdapter;
|
|
begin
|
|
if (aJSON.ToString = EmptyStr) then
|
|
begin
|
|
Exit;
|
|
end;
|
|
vConv := TCustomJSONDataSetAdapter.create(Nil);
|
|
try
|
|
vConv.DataSet := aDataset;
|
|
vConv.UpdateDataSet(aJSON);
|
|
finally
|
|
vConv.Free;
|
|
aJSON.Free;
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.JsonArrayToText(jObj: TJSONObject;
|
|
strField: string): string;
|
|
var
|
|
j: Integer;
|
|
begin
|
|
with jObj do
|
|
begin
|
|
with TStringList.create do
|
|
try
|
|
try
|
|
for j := 0 to Pred(GetValue<TJSONArray>(strField).Count) do
|
|
begin
|
|
Add(GetValue<TJSONArray>(strField).Items[j].ToJSON);
|
|
end;
|
|
Result := Text;
|
|
except
|
|
on E: Exception do
|
|
Result := GetValue<string>(strField);
|
|
end;
|
|
|
|
finally
|
|
Free;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.JsonToClientDataSetString(aDataset: TDataSet;
|
|
aJSON: string);
|
|
var
|
|
jObj: TJSONArray;
|
|
vConv: TCustomJSONDataSetAdapter;
|
|
begin
|
|
if (aJSON = EmptyStr) then
|
|
begin
|
|
Exit;
|
|
end;
|
|
jObj := TJSONObject.ParseJSONValue(aJSON) as TJSONArray;
|
|
vConv := TCustomJSONDataSetAdapter.create(Nil);
|
|
try
|
|
vConv.DataSet := aDataset;
|
|
vConv.UpdateDataSet(jObj);
|
|
finally
|
|
vConv.Free;
|
|
jObj.Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.JsonToDataset2(aDataset: TDataSet; aJSON: string);
|
|
var
|
|
jObj: TJSONArray;
|
|
vConv: TCustomJSONDataSetAdapter;
|
|
begin
|
|
if (aJSON = EmptyStr) then
|
|
begin
|
|
Exit;
|
|
end;
|
|
jObj := TJSONObject.ParseJSONValue(aJSON) as TJSONArray;
|
|
vConv := TCustomJSONDataSetAdapter.create(Nil);
|
|
try
|
|
vConv.DataSet := aDataset;
|
|
vConv.UpdateDataSet(jObj);
|
|
finally
|
|
vConv.Free;
|
|
jObj.Free;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnhGrupoBoletosClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
frmGrupoBoletoEmpresas := TfrmGrupoBoletoEmpresas.create(Self);
|
|
frmGrupoBoletoEmpresas.ShowModal;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuAcertosClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// cdsBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "ACERTOS"}') as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuAPedidoClienteClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "APEDIDODOCLIENTE"}')
|
|
// as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuBaixarCobClick(Sender: TObject);
|
|
var
|
|
total_recebido, nominal_boleto, recebido_rateio, help_pr, help_j, help_m,
|
|
help_cor: currency;
|
|
prct_rateio: double;
|
|
atraso, atraso_repasse: Integer;
|
|
mes, ano: string;
|
|
begin
|
|
inherited;
|
|
// if not dtmSystem.tblBoletos.Locate('NR_NOSSO_NUMERO',
|
|
// tblBoletosseuNumero.AsString, []) then
|
|
// begin
|
|
// Showmessage('Não foi possível encontrar o boleto desejado no sistema.');
|
|
// abort;
|
|
// end
|
|
// else
|
|
// begin
|
|
// with dtmSystem do
|
|
// begin
|
|
//
|
|
/// / total_recebido := tblBoletosvalorTotalRecebimento.AsCurrency;
|
|
/// / nominal_boleto := tblBoletosvalorNominal.AsCurrency;
|
|
//
|
|
// tblBoletoTitulos.First;
|
|
// while not tblBoletoTitulos.Eof do
|
|
// begin
|
|
// tblDevedores.Locate('ID_DEVEDOR',
|
|
// tblBoletoTitulosID_DEVEDOR.AsInteger, []);
|
|
// tblTitulos.Locate('ID_TITULO', tblBoletoTitulosID_TITULO.AsInteger, []);
|
|
// prct_rateio := ((tblTitulosVL_TITULO.AsCurrency * 100) /
|
|
// nominal_boleto) / 100;
|
|
// recebido_rateio := (prct_rateio * total_recebido);
|
|
//
|
|
// tblTitulos.Edit;
|
|
// tblTitulosVL_CORRIGIDO.AsCurrency := recebido_rateio;
|
|
// if recebido_rateio < tblTitulosVL_TITULO.AsCurrency then
|
|
// begin
|
|
// tblTitulosVL_DESC_PRINCIPAL.AsCurrency :=
|
|
// tblTitulosVL_TITULO.AsCurrency - recebido_rateio;
|
|
// end;
|
|
//
|
|
// if tblMultacodigo.AsString <> 'NAOTEMMULTA' then
|
|
// begin
|
|
/// / atraso := DaysBetween(tblBoletosdataPagtoBaixa.AsDateTime,
|
|
/// / IncDay(tblMultadata.AsDateTime, -1));
|
|
// if atraso > 0 then
|
|
// begin
|
|
// if tblMultacodigo.AsString = 'VALORFIXO' then
|
|
// begin
|
|
// tblTitulosVL_MULTA.AsCurrency :=
|
|
// (tblMultavalor.AsCurrency * prct_rateio);
|
|
// end
|
|
// else
|
|
// begin
|
|
// tblTitulosVL_MULTA.AsCurrency :=
|
|
// ((tblTitulosVL_TITULO.AsCurrency * tblMultataxa.AsFloat) / 100)
|
|
// * prct_rateio;
|
|
// end;
|
|
// end;
|
|
// end;
|
|
//
|
|
// if tblMoracodigo.AsString <> 'ISENTO' then
|
|
// begin
|
|
/// / atraso := DaysBetween(tblBoletosdataPagtoBaixa.AsDateTime,
|
|
/// / IncDay(tblMoradata.AsDateTime, -1));
|
|
// if atraso > 0 then
|
|
// begin
|
|
// if tblMoracodigo.AsString = 'VALORDIA' then
|
|
// begin
|
|
// tblTitulosVL_JUROS.AsCurrency :=
|
|
// (tblMoravalor.AsCurrency * atraso) * prct_rateio;
|
|
// end
|
|
// else
|
|
// begin
|
|
// tblTitulosVL_MULTA.AsCurrency :=
|
|
// ((tblTitulosVL_TITULO.AsCurrency * ((tblMultataxa.AsFloat / 30)
|
|
// / 100)) * atraso) * prct_rateio;
|
|
// end;
|
|
// end;
|
|
// end;
|
|
//
|
|
/// / mes := inttostr(strtoint(copy(FormatDateTime('yyyy-mm-dd',
|
|
/// / tblBoletosdataPagtoBaixa.AsDateTime), 6, 2)));
|
|
/// / ano := copy(FormatDateTime('yyyy-mm-dd',
|
|
/// / tblBoletosdataPagtoBaixa.AsDateTime), 1, 4);
|
|
/// /
|
|
/// / atraso_repasse := DaysBetween(tblBoletosdataPagtoBaixa.AsDateTime,
|
|
/// / tblTitulosDT_VENCIMENTO.AsDateTime);
|
|
//
|
|
// tblCHGEmpresa.Locate('ID_EMPRESA', tblTitulosID_EMPRESA.AsInteger, []);
|
|
//
|
|
// tblEmpresaRepasse.Locate('ID_MES;ID_ANO', VarArrayOf([mes, ano]), []);
|
|
//
|
|
// rotblRepasseFase.Close;
|
|
// rotblRepasseFase.SQL.Text :=
|
|
// 'select * from sys_repasses_fases where id_repasse = ' +
|
|
// QuotedStr(tblEmpresaRepasseID_ITEM.AsString) + ' and min_atraso <= '
|
|
// + inttostr(atraso_repasse) + ' and ' + inttostr(atraso_repasse) +
|
|
// ' <= max_atraso';
|
|
// rotblRepasseFase.Open;
|
|
//
|
|
// if not rotblRepasseFase.IsEmpty then
|
|
// begin
|
|
// help_pr := (rotblRepasseFasePR_PRINCIPAL.AsCurrency / 100);
|
|
// help_j := (rotblRepasseFasePR_JUROS.AsCurrency / 100);
|
|
// help_m := (rotblRepasseFasePR_MULTA.AsCurrency / 100);
|
|
// help_cor := (rotblRepasseFasePR_CORRIGIDO.AsCurrency / 100);
|
|
// end
|
|
// else
|
|
// begin
|
|
// help_pr := (dtmSystem.tblEmpresaRepassePR_PRINCIPAL.AsCurrency / 100);
|
|
// help_j := (dtmSystem.tblEmpresaRepassePR_JUROS.AsCurrency / 100);
|
|
// help_m := (dtmSystem.tblEmpresaRepassePR_MULTA.AsCurrency / 100);
|
|
// help_cor :=
|
|
// (dtmSystem.tblEmpresaRepassePR_CORRIGIDO.AsCurrency / 100);
|
|
// end;
|
|
//
|
|
// tblTitulosVL_REPASSE_PRIN.AsCurrency :=
|
|
// (tblTitulosVL_TITULO.AsCurrency -
|
|
// tblTitulosVL_DESC_PRINCIPAL.AsCurrency) * help_pr;
|
|
// tblTitulosVL_REPASSE_JUROS.AsCurrency :=
|
|
// tblTitulosVL_JUROS.AsCurrency * help_j;
|
|
// tblTitulosVL_REPASSE_MULTA.AsCurrency :=
|
|
// tblTitulosVL_MULTA.AsCurrency * help_m;
|
|
// tblTitulosVL_REPASSE_ENCARGOS.AsCurrency := 0;
|
|
// tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency :=
|
|
// tblTitulosVL_CORRIGIDO.AsCurrency * help_cor;
|
|
//
|
|
// tblTitulosTP_SITUACAO.AsString := 'QC';
|
|
// tblTitulosTP_PRESTACAO.AsString := 'N';
|
|
// tblTitulos.POST;
|
|
// tblHistorico.Append;
|
|
// tblHistoricoID_DEVEDOR.AsInteger := tblTitulosID_DEVEDOR.AsInteger;
|
|
// tblHistoricoID_COBRADOR.AsInteger := id_usuario;
|
|
// tblHistoricoDT_CONTATO.AsDateTime := Now;
|
|
// tblHistoricoTL_MEMO.AsString := 'Título ' +
|
|
// tblTitulosTX_PRODUTO.AsString + ' foi baixado pelo boleto de nº ' +
|
|
// tblBoletosseuNumero.AsString + '.';
|
|
// tblHistorico.POST;
|
|
// tblBoletoTitulos.Next;
|
|
// end;
|
|
// Showmessage('Títulos baixados com sucesso!');
|
|
// end;
|
|
// end;
|
|
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuDevolucaoClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "DEVOLUCAO"}') as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuDownloadClick(Sender: TObject);
|
|
var
|
|
Base64: string;
|
|
fileStream: TFileStream;
|
|
begin
|
|
inherited;
|
|
// try
|
|
// Base64 := RequestBase64
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/pdf');
|
|
// except
|
|
// on E: EIdHTTPProtocolException do
|
|
// Showmessage(IdHTTP.ResponseText + #13#10 + E.ErrorMessage)
|
|
// else
|
|
// showexception(exceptobject, exceptaddr);
|
|
// end;
|
|
|
|
if IdHTTP.ResponseCode <> 200 then
|
|
begin
|
|
Showmessage('Transação não pode ser inicada (' +
|
|
inttostr(IdHTTP.ResponseCode) + ').');
|
|
end
|
|
else
|
|
begin
|
|
with SaveDialog do
|
|
begin
|
|
Execute;
|
|
try
|
|
fileStream := TFileStream.create(FileName, fmCreate);
|
|
IdDecoderMIME.DecodeStream(Base64, fileStream);
|
|
Screen.Cursor := crHourGlass;
|
|
finally
|
|
fileStream.Free;
|
|
Screen.Cursor := crDefault;
|
|
FileName := '';
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuFaltaClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "FALTADESOLUCAO"}')
|
|
// as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuPagoDiretoClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "PAGODIRETOAOCLIENTE"}')
|
|
// as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuProtestadoClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "PROTESTADO"}') as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuProtestoAposBaixaClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "PROTESTOAPOSBAIXA"}')
|
|
// as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.mnuSubstituicaoClick(Sender: TObject);
|
|
var
|
|
resp: string;
|
|
begin
|
|
inherited;
|
|
// resp := SendJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos/' +
|
|
// tblBoletosnossoNumero.AsString + '/baixas',
|
|
// TJSONObject.ParseJSONValue('{"codigoBaixa": "SUBSTITUICAO"}')
|
|
// as TJSONObject);
|
|
// if resp <> 'Error' then
|
|
// begin
|
|
// Showmessage('Boleto Nº ' + tblBoletosseuNumero.AsString +
|
|
// ' baixado com sucesso!');
|
|
// end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.POST2(URL: String; Body: TStringStream)
|
|
: TJSONObject;
|
|
var
|
|
iDResponse: String;
|
|
begin
|
|
Screen.Cursor := crHourGlass;
|
|
try
|
|
iDResponse := IdHTTP.POST(URL, Body);
|
|
except
|
|
on E: EIdHTTPProtocolException do
|
|
Showmessage('Error on request: '#13#10 + E.Message);
|
|
end;
|
|
|
|
Result := TJSONObject.ParseJSONValue(iDResponse) as TJSONObject;
|
|
Screen.Cursor := crDefault;
|
|
|
|
end;
|
|
|
|
function TfrmCentralBoletos.Request(Method: TMethod; URL: String;
|
|
Body: TStringStream): TJSONObject;
|
|
var
|
|
bodyString: string;
|
|
jsonResponse: TJSONObject;
|
|
retry: boolean;
|
|
iDResponse: String;
|
|
SStrm: TStringStream;
|
|
begin
|
|
IdHTTP.IOHandler.DefStringEncoding := IndyTextEncoding_UTF8;
|
|
|
|
retry := true;
|
|
|
|
while retry do
|
|
begin
|
|
if IdHTTP.Request.CustomHeaders.Values['Authorization'] = '' then
|
|
begin
|
|
try
|
|
bodyString :=
|
|
Format('client_id=%s&client_secret=%s&scope=boleto-cobranca.read boleto-cobranca.write&grant_type=client_credentials',
|
|
[dtmSystem.tblEmpresaCLIENT_ID.AsString,
|
|
dtmSystem.tblEmpresaCLIENT_SECRET.AsString]);
|
|
|
|
iDResponse :=
|
|
IdHTTP.POST('https://cdpj.partners.bancointer.com.br/oauth/v2/token',
|
|
TStringStream.create(bodyString, TEncoding.UTF8));
|
|
|
|
jsonResponse := TJSONObject.ParseJSONValue(iDResponse) as TJSONObject;
|
|
if Assigned(jsonResponse) then
|
|
begin
|
|
IdHTTP.Request.CustomHeaders.Values['Authorization'] :=
|
|
Format('Bearer %s',
|
|
[jsonResponse.GetValue<string>('access_token')]);
|
|
end;
|
|
except
|
|
on E: Exception do
|
|
begin
|
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
|
retry := false;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
try
|
|
SStrm := TStringStream.create('', TEncoding.UTF8);
|
|
case Method of
|
|
GET:
|
|
begin
|
|
// iDResponse := IdHTTP.GET(URL + Format('?%s', [Body.DataString]));
|
|
IdHTTP.GET(URL + Format('?%s', [Body.DataString]), SStrm);
|
|
end;
|
|
POST:
|
|
begin
|
|
// iDResponse := IdHTTP.POST(URL, Body);
|
|
IdHTTP.POST(URL, Body, SStrm);
|
|
end;
|
|
end;
|
|
|
|
iDResponse := SStrm.DataString;
|
|
|
|
retry := false;
|
|
except
|
|
on E: EIdHTTPProtocolException do
|
|
begin
|
|
|
|
retry := false;
|
|
SStrm.Free;
|
|
Result := nil;
|
|
case E.ErrorCode of
|
|
400:
|
|
begin
|
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
|
end;
|
|
|
|
401:
|
|
begin
|
|
IdHTTP.Request.CustomHeaders.Values['Authorization'] := '';
|
|
retry := true;
|
|
end;
|
|
|
|
403:
|
|
begin
|
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
|
end;
|
|
|
|
500:
|
|
begin
|
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
|
|
|
raise Exception.create('500 - Erro ao processar a requisição!');
|
|
end;
|
|
else
|
|
begin
|
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
|
end;
|
|
end;
|
|
end;
|
|
on E: EIDSocketError do
|
|
begin
|
|
SStrm.Free;
|
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
|
retry := false;
|
|
Result := nil;
|
|
end;
|
|
on E: EIdConnClosedGracefully do
|
|
begin
|
|
SStrm.Free;
|
|
MessageDlg(E.Message, mtError, [mbOK], 0);
|
|
retry := false;
|
|
Result := nil;
|
|
end;
|
|
else
|
|
begin
|
|
SStrm.Free;
|
|
MessageDlg('Error não identificado.', mtError, [mbOK], 0);
|
|
retry := false;
|
|
Result := nil;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
if iDResponse <> '' then
|
|
begin
|
|
try
|
|
Result := TJSONObject.ParseJSONValue(iDResponse) as TJSONObject;
|
|
except
|
|
MessageDlg('Error não identificado.', mtError, [mbOK], 0);
|
|
Result := nil;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.RequestBase64(URL: String;
|
|
Body: TStringStream): string;
|
|
var
|
|
Response: TStringStream;
|
|
begin
|
|
Screen.Cursor := crHourGlass;
|
|
Response := TStringStream.create('', TEncoding.UTF8);
|
|
try
|
|
IdHTTP.GET(URL, Response);
|
|
except
|
|
on E: EIdHTTPProtocolException do
|
|
Showmessage('Error on request: '#13#10 + E.ErrorMessage);
|
|
end;
|
|
|
|
Result := Response.DataString;
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.RequestJSON(URL: String; Body: TStringStream)
|
|
: TJSONObject;
|
|
var
|
|
Response: TStringStream;
|
|
begin
|
|
Screen.Cursor := crHourGlass;
|
|
Response := TStringStream.create('', TEncoding.UTF8);
|
|
try
|
|
IdHTTP.GET(URL, Response);
|
|
except
|
|
on E: EIdHTTPProtocolException do
|
|
Showmessage('Error on request: '#13#10 + E.ErrorMessage);
|
|
end;
|
|
|
|
Result := TJSONObject.ParseJSONValue(Response.DataString) as TJSONObject;
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.SendJSON(URL: String; JSON: TJSONObject): string;
|
|
var
|
|
// JSONToReturn: TStringStream;
|
|
JSONToSend: TStringStream;
|
|
string_return: string;
|
|
begin
|
|
Screen.Cursor := crHourGlass;
|
|
|
|
try
|
|
JSONToSend := TStringStream.create(JSON.ToString, TEncoding.UTF8);
|
|
except
|
|
|
|
end;
|
|
// JSONToReturn := TStringStream.create('');
|
|
try
|
|
IdHTTP.Request.Accept := 'application/json';
|
|
IdHTTP.Request.CharSet := 'utf-8';
|
|
|
|
try
|
|
string_return := IdHTTP.POST(URL, JSONToSend);
|
|
Result := string_return;
|
|
except
|
|
on E: EIdHTTPProtocolException do
|
|
begin
|
|
Showmessage('Error on request: '#13#10 + E.ErrorMessage);
|
|
Result := 'Error';
|
|
end;
|
|
end;
|
|
finally
|
|
JSONToSend.Free;
|
|
end;
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.spdbtnPesquisaClick(Sender: TObject);
|
|
var
|
|
strPesquisa, strQuery, strHelpDoc: string;
|
|
begin
|
|
inherited;
|
|
Screen.Cursor := crHourGlass;
|
|
if Trim(edtPesquisa.Text) = '' then
|
|
begin
|
|
Screen.Cursor := crDefault;
|
|
abort;
|
|
end;
|
|
strPesquisa := Trim(edtPesquisa.Text);
|
|
strPesquisa := Ansiuppercase(StringReplace(strPesquisa, ' ', '%',
|
|
[rfReplaceAll]));
|
|
strQuery := 'select ID_DEVEDOR, TX_NOME, case when TP_CLIENTE = ''F'' ' +
|
|
'then CD_CPF when TP_CLIENTE = ''J'' then CD_CNPJ end as TX_DOCUMENTO from '
|
|
+ 'CHG_DEVEDORES where ';
|
|
case rgTipoPesquisa.ItemIndex of
|
|
0:
|
|
begin
|
|
strQuery := strQuery + 'upper(TX_NOME COLLATE WIN_PTBR) LIKE ' +
|
|
QuotedStr('%' + strPesquisa + '%');
|
|
end;
|
|
1:
|
|
begin
|
|
strPesquisa := StringReplace(strPesquisa, '.', '', [rfReplaceAll]);
|
|
strPesquisa := StringReplace(strPesquisa, '-', '', [rfReplaceAll]);
|
|
strPesquisa := StringReplace(strPesquisa, '/', '', [rfReplaceAll]);
|
|
if length(strPesquisa) < 14 then
|
|
begin
|
|
strHelpDoc := copy(strPesquisa, 1, 3) + '.' + copy(strPesquisa, 4, 3)
|
|
+ '.' + copy(strPesquisa, 7, 3) + '-' + RightStr(strPesquisa, 2);
|
|
strQuery := strQuery + 'CD_CPF like ' + QuotedStr(strHelpDoc);
|
|
end
|
|
else if length(strPesquisa) >= 14 then
|
|
begin
|
|
strHelpDoc := copy(strPesquisa, 1, 2) + '.' + copy(strPesquisa, 3, 3)
|
|
+ '.' + copy(strPesquisa, 6, 3) + '/' + copy(strPesquisa, 9, 4) +
|
|
'-' + RightStr(strPesquisa, 2);
|
|
strQuery := strQuery + 'CD_CNPJ like ' + QuotedStr(strHelpDoc);
|
|
end;
|
|
end;
|
|
end;
|
|
strQuery := strQuery + ' order by tx_nome';
|
|
zroqryPesquisa.Close;
|
|
zroqryPesquisa.SQL.Text := strQuery;
|
|
zroqryPesquisa.Open;
|
|
Application.ProcessMessages;
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
procedure TfrmCentralBoletos.SpeedButton1Click(Sender: TObject);
|
|
var
|
|
JSON: TJSONObject;
|
|
params, content: string;
|
|
begin
|
|
//
|
|
// Params := '?';
|
|
// Params := Params + 'filtrarPor=' + opcoes_situacao
|
|
// [cb_filtrosituacao.ItemIndex] + '&';
|
|
// Params := Params + 'dataInicial=' + FormatDateTime('yyyy-mm-dd',
|
|
// dt_inicio.Date) + '&';
|
|
// Params := Params + 'dataFinal=' + FormatDateTime('yyyy-mm-dd',
|
|
// dt_fim.Date) + '&';
|
|
// Params := Params + 'filtrarDataPor=' + opcoes_datatipo
|
|
// [cb_filtroordem.ItemIndex] + '&';
|
|
// // Params := Params + 'ordenarPor=NOMESACADO' + opcoes_ordem
|
|
// // [cb_filtrotipodata.ItemIndex];
|
|
// try
|
|
// JSON := RequestJSON
|
|
// ('https://apis.bancointer.com.br/openbanking/v1/certificado/boletos'
|
|
// + Params);
|
|
//
|
|
// except
|
|
// on E: EIdHTTPProtocolException do
|
|
// begin
|
|
// Showmessage(IdHTTP.ResponseText + #13#10 + E.ErrorMessage);
|
|
// Screen.Cursor := crDefault;
|
|
// end
|
|
// else
|
|
// begin
|
|
// showexception(exceptobject, exceptaddr);
|
|
// Screen.Cursor := crDefault;
|
|
// end;
|
|
// end;
|
|
//
|
|
// if IdHTTP.ResponseCode <> 200 then
|
|
// begin
|
|
// Showmessage('Transação não pode ser inicada (' +
|
|
// inttostr(IdHTTP.ResponseCode) + ').');
|
|
// end
|
|
// else
|
|
// begin
|
|
// tblBoletos.ReadOnly := False;
|
|
// Screen.Cursor := crHourGlass;
|
|
// JsonToDataset2(tblBoletos, JSON.GetValue<TJSONArray>('content').ToString);
|
|
// // if tblBoletos.IsEmpty then
|
|
// // begin
|
|
// // dbgrd_boletos.PopupMenu := nil;
|
|
// // end
|
|
// // else
|
|
// // begin
|
|
// // dbgrd_boletos.PopupMenu := pum_download;
|
|
// // end;
|
|
// Screen.Cursor := crDefault;
|
|
// tblBoletos.ReadOnly := True;
|
|
// end;
|
|
|
|
// try
|
|
// clientId := '9f0b9a45-8a50-4daa-beb8-e22edb7f44cb';
|
|
// clientSecret := '2377cb46-5fe9-41fc-818f-8cf11ab0f851';
|
|
// AnsiQuotedStr('client_id', '"');
|
|
// bodyString :=
|
|
// Format('client_id=%s&client_secret=%s&scope=boleto-cobranca.read&grant_type=client_credentials',
|
|
// [clientId, clientSecret]);
|
|
// // client_id=<clientId de sua aplicação>&client_secret=<clientSecret de sua aplicação>&scope=boleto-cobranca.read&grant_type=client_credentials
|
|
// // bodyString := Format('{%s:%s,%s:%s,%s:%s,%s:%s}',
|
|
// // [
|
|
// // AnsiQuotedStr('client_id', '"'), AnsiQuotedStr(clientId, '"'),
|
|
// // AnsiQuotedStr('client_secret', '"'), AnsiQuotedStr(clientSecret, '"'),
|
|
// // AnsiQuotedStr('scope', '"'), AnsiQuotedStr('boleto-cobranca.read', '"'),
|
|
// // AnsiQuotedStr('grant_type', '"'), AnsiQuotedStr('client_credentials', '"')
|
|
// // ]);
|
|
//
|
|
// JSON := POST('https://cdpj.partners.bancointer.com.br/oauth/v2/token',
|
|
// TStringStream.create(bodyString, TEncoding.UTF8));
|
|
// Showmessage(JSON.ToString);
|
|
// except
|
|
// on E: Exception do
|
|
// begin
|
|
// Showmessage(E.Message);
|
|
// end;
|
|
// end;
|
|
|
|
Screen.Cursor := crHourGlass;
|
|
try
|
|
params := Format('dataInicial=%s&',
|
|
[FormatDateTime('yyyy-mm-dd', dt_inicio.Date)]);
|
|
params := Format('%sdataFinal=%s', [params, FormatDateTime('yyyy-mm-dd',
|
|
dt_fim.Date)]);
|
|
|
|
JSON := Request(GET,
|
|
'https://cdpj.partners.bancointer.com.br/cobranca/v2/boletos',
|
|
TStringStream.create(params, TEncoding.UTF8));
|
|
|
|
JsonArrayToDataset(cdsBoletos, JSON.GetValue<TJSONArray>('content'));
|
|
finally
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.ValidadorBeneficiado: TStringArray;
|
|
begin
|
|
SetLength(Result, 2);
|
|
Result[0] := 'True';
|
|
Result[1] := '';
|
|
|
|
with dtmSystem do
|
|
begin
|
|
if Trim(tblEmpresaTX_NOME.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Nome do Beneficiário não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if Trim(tblEmpresaTX_CNPJ.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'CNPJ do Beneficiário não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if Trim(tblEmpresaTX_CEP.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'CEP do Beneficiário não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if Trim(tblEmpresaTX_ENDERECO.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Endereço (Logradouro) do Beneficiário não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if Trim(tblEmpresaTX_BAIRRO.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Bairro do Beneficiário não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if Trim(tblEmpresaTX_CIDADE.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Cidade do Beneficiário não pode estar vazia.';
|
|
Exit;
|
|
end;
|
|
if Trim(tblEmpresaTX_UF.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'UF do Beneficiário não pode estar vazia.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.ValidadorBoleto: TStringArray;
|
|
begin
|
|
SetLength(Result, 2);
|
|
Result[0] := 'True';
|
|
Result[1] := '';
|
|
|
|
with dtmSystem do
|
|
begin
|
|
if tblDevedoresVL_NOMINAL_BOLETO.AsFloat <= 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do Boleto não pode ser menor ou igual a 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIA_VENCIMENTO.AsInteger <= 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Dia do mês para o vencimento não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_AGENDA.AsInteger < 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Quantidade de dias para cancelamento automático do boleto não pode ser menor que 0.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.ValidadorDescontos: TStringArray;
|
|
begin
|
|
SetLength(Result, 2);
|
|
Result[0] := 'True';
|
|
Result[1] := '';
|
|
|
|
{ 1, 'NAOTEMDESCONTO'
|
|
2, 'VALORFIXODATAINFORMADA'
|
|
3, 'PERCENTUALDATAINFORMADA' }
|
|
|
|
with dtmSystem do
|
|
begin
|
|
if Trim(tblDevedoresTP_DESC_BOLETO_1.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Selecione o tipo de Desconto para o 1º Desconto.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
case tblDevedoresTP_DESC_BOLETO_1.AsInteger of
|
|
1:
|
|
begin
|
|
if tblDevedoresPR_DESC_BOLETO_1.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 1º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_DESC_BOLETO_1.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 1º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
if tblDevedoresPR_DESC_BOLETO_1.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 1º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_DESC_BOLETO_1.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 1º Desconto não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_DESC_BOLETO_1.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias antes do Vencimento para 1º Desconto não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
3:
|
|
begin
|
|
if tblDevedoresVL_DESC_BOLETO_1.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 1º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresPR_DESC_BOLETO_1.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 1º Desconto não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_DESC_BOLETO_1.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias antes do Vencimento para 1º Desconto não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Tipo de Desconto para 1º Desconto não existe.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
if Trim(tblDevedoresTP_DESC_BOLETO_2.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Selecione o tipo de Desconto para o 2º Desconto.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
case tblDevedoresTP_DESC_BOLETO_2.AsInteger of
|
|
1:
|
|
begin
|
|
if tblDevedoresPR_DESC_BOLETO_2.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 2º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_DESC_BOLETO_2.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 2º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
if tblDevedoresPR_DESC_BOLETO_2.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 2º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_DESC_BOLETO_2.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 2º Desconto não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_DESC_BOLETO_2.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias antes do Vencimento para 2º Desconto não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
3:
|
|
begin
|
|
if tblDevedoresVL_DESC_BOLETO_2.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 2º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresPR_DESC_BOLETO_2.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 2º Desconto não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_DESC_BOLETO_2.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias antes do Vencimento para 2º Desconto não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Tipo de Desconto para 2º Desconto não existe.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
if Trim(tblDevedoresTP_DESC_BOLETO_3.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Selecione o tipo de Desconto para o 3º Desconto.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
case tblDevedoresTP_DESC_BOLETO_3.AsInteger of
|
|
1:
|
|
begin
|
|
if tblDevedoresPR_DESC_BOLETO_3.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 3º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_DESC_BOLETO_3.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 3º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
if tblDevedoresPR_DESC_BOLETO_3.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 3º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_DESC_BOLETO_3.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 3º Desconto não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_DESC_BOLETO_3.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias antes do Vencimento para 3º Desconto não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
3:
|
|
begin
|
|
if tblDevedoresVL_DESC_BOLETO_3.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor do 3º Desconto deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresPR_DESC_BOLETO_3.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa do 3º Desconto não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_DESC_BOLETO_3.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias antes do Vencimento para 3º Desconto não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Tipo de Desconto para 3º Desconto não existe.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.ValidadorMultaMora: TStringArray;
|
|
begin
|
|
SetLength(Result, 2);
|
|
Result[0] := 'True';
|
|
Result[1] := '';
|
|
|
|
{ 1, 'NAOTEMMULTA'
|
|
2, 'VALORFIXO'
|
|
3, 'PERCENTUAL'
|
|
|
|
1, 'VALORDIA'
|
|
2, 'TAXAMENSAL'
|
|
3, 'ISENTO' }
|
|
|
|
with dtmSystem do
|
|
begin
|
|
if Trim(tblDevedoresTP_MULTA_BOLETO.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Selecione o tipo de Multa.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
case tblDevedoresTP_MULTA_BOLETO.AsInteger of
|
|
1:
|
|
begin
|
|
if tblDevedoresPR_MULTA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa da Multa deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_MULTA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor da Multa deve ser 0.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
if tblDevedoresPR_MULTA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa da Multa deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_MULTA_BOLETO.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor da Multa não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_MULTA_BOLETO.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias para Cobrar Multa não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
3:
|
|
begin
|
|
if tblDevedoresVL_MULTA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor da Multa deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresPR_MULTA_BOLETO.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa da Multa não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_DIAS_MULTA_BOLETO.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias para Cobrar Multa não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Tipo de Multa não existe.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if Trim(tblDevedoresTP_MULTA_BOLETO.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Selecione o tipo de Multa.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
case tblDevedoresTP_MULTA_BOLETO.AsInteger of
|
|
3:
|
|
begin
|
|
if tblDevedoresPR_MORA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa da Mora deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_MORA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor da Mora deve ser 0.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
1:
|
|
begin
|
|
if tblDevedoresPR_MORA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa da Mora deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresVL_MORA_BOLETO.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor da Mora não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_MORA_BOLETO.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias para Cobrar Mora não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
if tblDevedoresVL_MORA_BOLETO.AsFloat <> 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Valor da Mora deve ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresPR_MORA_BOLETO.AsFloat = 0 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Taxa da Mora não pode ser 0.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresNR_MORA_BOLETO.AsInteger < 1 then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] :=
|
|
'Qtd. de Dias para Cobrar Mora não pode ser menor que 1.';
|
|
Exit;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Tipo de Mora não existe.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
function TfrmCentralBoletos.ValidadorPagador: TStringArray;
|
|
begin
|
|
SetLength(Result, 2);
|
|
Result[0] := 'True';
|
|
Result[1] := '';
|
|
|
|
with dtmSystem do
|
|
begin
|
|
if Trim(tblDevedoresTX_NOME.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Nome do pagador não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if Trim(tblDevedoresCD_DOCUMENTO.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Documento do pagador não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if tblDevedoresID_ENDERECO_BOLETO.IsNull then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Escolha um endereço do pagador para utilizar no Boleto.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
if Trim(tblEnderecosTX_LOGRADOURO.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Endereço (Logradouro) do pagador não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
if tblEnderecosID_CIDADE.IsNull then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Endereço deve constar uma Cidade.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
if Trim(tblEnderecosTX_CIDADE.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Cidade do pagador não pode estar vazia.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
if tblEnderecosID_ESTADO.IsNull then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'Endereço deve constar uma UF.';
|
|
Exit;
|
|
end
|
|
else
|
|
begin
|
|
if Trim(tblEnderecosTX_UF.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'UF do pagador não pode estar vazia.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
if Trim(tblEnderecosTX_CEP.AsString) = '' then
|
|
begin
|
|
Result[0] := 'False';
|
|
Result[1] := 'CEP do pagador não pode estar vazio.';
|
|
Exit;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
// if edt_nomebolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'Nome do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end;
|
|
// if edt_docbolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'Documento do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end
|
|
// else if (length(edt_docbolunico.Text) <> 11) and
|
|
// (length(edt_docbolunico.Text) <> 14) then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'Documento do pagador inválido.';
|
|
// Exit;
|
|
// end;
|
|
// if edt_cepbolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'CEP do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end
|
|
// else if length(edt_cepbolunico.Text) <> 8 then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'CEP do pagador inválido.';
|
|
// Exit;
|
|
// end;
|
|
// if edt_endbolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'Endereço do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end;
|
|
// if edt_endnumbolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'Número do Endereço do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end;
|
|
// if edt_bairrobolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'Bairro do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end;
|
|
// if edt_cidadebolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'Cidade do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end;
|
|
// if edt_estadobolunico.Text = '' then
|
|
// begin
|
|
// Result[0] := 'False';
|
|
// Result[1] := 'UF do pagador não pode estar vazio.';
|
|
// Exit;
|
|
// end;
|
|
end;
|
|
|
|
end.
|