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.
6578 lines
205 KiB
6578 lines
205 KiB
unit ucadDevedores;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
|
|
umstCadastro, Data.DB, Vcl.ExtCtrls, Vcl.DBCtrls, Vcl.StdCtrls, Vcl.Mask,
|
|
Vcl.ComCtrls, Vcl.Grids, Vcl.DBGrids, ACBrBase, ACBrSocket, ACBrCEP,
|
|
rDBComponents, System.ImageList, Vcl.ImgList, Vcl.Buttons, Clipbrd,
|
|
Vcl.CheckLst, System.UITypes, Vcl.Menus, StrUtils, DBDateTimePicker,
|
|
ZAbstractRODataset, ZAbstractDataset, ZDataset, DateUtils, System.Math,
|
|
RLReport;
|
|
|
|
type
|
|
THackDBNavigator = class(TDBNavigator)
|
|
end;
|
|
|
|
type
|
|
TStringDynArray = array of string;
|
|
|
|
type
|
|
TcadDevedores = class(TmstCadastro)
|
|
tabEndereco: TTabSheet;
|
|
tabTel: TTabSheet;
|
|
dbedt_nome: TDBEdit;
|
|
dbedt_cpfcnpj: TDBEdit;
|
|
lbl_nome: TLabel;
|
|
lbl_cpfcnpj: TLabel;
|
|
lbl_datacad: TLabel;
|
|
dbgrd_enderecos: TDBGrid;
|
|
dbedt_logradouro: TDBEdit;
|
|
dbedt_num: TDBEdit;
|
|
lbl_logradouro: TLabel;
|
|
lbl_num: TLabel;
|
|
dbrg_situacao: TDBRadioGroup;
|
|
dtsEnderecos: TDataSource;
|
|
dtsTelefones: TDataSource;
|
|
tabTitulos: TTabSheet;
|
|
Panel1: TPanel;
|
|
dbrgrp_tpdevedor: TDBRadioGroup;
|
|
dbmem_obs: TDBMemo;
|
|
lbl_obs: TLabel;
|
|
dbedt_comp: TDBEdit;
|
|
lbl_comp: TLabel;
|
|
Panel2: TPanel;
|
|
lbl_tpend: TLabel;
|
|
lbl_situacao: TLabel;
|
|
lbl_cep: TLabel;
|
|
dbedt_cep: TDBEdit;
|
|
lbl_bairro: TLabel;
|
|
dbedt_bairro: TDBEdit;
|
|
lbl_cidade: TLabel;
|
|
lbl_uf: TLabel;
|
|
dblucmbox_uf: TDBLookupComboBox;
|
|
dbedt_tel: TDBEdit;
|
|
lbl_tel: TLabel;
|
|
Panel3: TPanel;
|
|
dbrg_sittel: TDBRadioGroup;
|
|
lbl_sittel: TLabel;
|
|
Panel4: TPanel;
|
|
dbrg_tipotel: TDBRadioGroup;
|
|
lbl_tipo: TLabel;
|
|
dbgrd_tel: TDBGrid;
|
|
dbmem_tel: TDBMemo;
|
|
lbl_obstel: TLabel;
|
|
lbl_desctel: TLabel;
|
|
dbedt_desctel: TDBEdit;
|
|
lbl_tit: TLabel;
|
|
dbedit_produto: TDBEdit;
|
|
lbl_dataent: TLabel;
|
|
lbl_datavenc: TLabel;
|
|
lbl_vltit: TLabel;
|
|
dbedt_vltit: TDBEdit;
|
|
Panel5: TPanel;
|
|
dbrg_tit: TDBRadioGroup;
|
|
lbl_sittit: TLabel;
|
|
tabHist: TTabSheet;
|
|
dbgrd_historico: TDBGrid;
|
|
lbl_tppessoa: TLabel;
|
|
ImageList1: TImageList;
|
|
lbl_ref: TLabel;
|
|
Panel6: TPanel;
|
|
dbrg_ref: TDBRadioGroup;
|
|
Panel7: TPanel;
|
|
dbrg_tpend: TDBRadioGroup;
|
|
Panel8: TPanel;
|
|
Panel9: TPanel;
|
|
btn_clearmemo: TButton;
|
|
Panel10: TPanel;
|
|
rdbdt_entrada: TrDBDateTimePicker;
|
|
rDBDateTimePicker1: TrDBDateTimePicker;
|
|
dbedt_codemp: TDBEdit;
|
|
lbl_cddevedor: TLabel;
|
|
pnl_cor1: TPanel;
|
|
pnl_color2: TPanel;
|
|
pnl_color3: TPanel;
|
|
pnl_color4: TPanel;
|
|
pnl_color5: TPanel;
|
|
pnl_color6: TPanel;
|
|
pnl_color7: TPanel;
|
|
GroupBox1: TGroupBox;
|
|
navenderecos: TDBNavigator;
|
|
dblucmbox_cidade: TDBLookupComboBox;
|
|
navtelefones: TDBNavigator;
|
|
dtsTitulos: TDataSource;
|
|
dtsCidades: TDataSource;
|
|
dtsUF: TDataSource;
|
|
MainMenu1: TMainMenu;
|
|
Cadastro1: TMenuItem;
|
|
Importao1: TMenuItem;
|
|
lbl_coddev: TLabel;
|
|
dbedt_coddev: TDBEdit;
|
|
lbl_nomepai: TLabel;
|
|
dbedt_nomepai: TDBEdit;
|
|
dbedt_nomemae: TDBEdit;
|
|
lbl_nomemae: TLabel;
|
|
dbedt_rg: TDBEdit;
|
|
lbl_rg: TLabel;
|
|
lbl_dtnasc: TLabel;
|
|
lbl_idade: TLabel;
|
|
dbcbx_tpcheque: TDBCheckBox;
|
|
lbl_banco: TLabel;
|
|
dbedt_banco: TDBEdit;
|
|
pnl_cheque: TPanel;
|
|
lbl_nrcheque: TLabel;
|
|
dbedt_nrcheque: TDBEdit;
|
|
lbl_motivo: TLabel;
|
|
dbedt_motivo: TDBEdit;
|
|
lbl_tpdespesa: TLabel;
|
|
PopupMenu1: TPopupMenu;
|
|
Copiar1: TMenuItem;
|
|
lbl_email: TLabel;
|
|
dbedt_email: TDBEdit;
|
|
Panel11: TPanel;
|
|
dbrg_confirmado: TDBRadioGroup;
|
|
lbl_confirmado: TLabel;
|
|
navHistorico: TDBNavigator;
|
|
dtsHistorico: TDataSource;
|
|
tabCalculos: TTabSheet;
|
|
lbl_beneficiarioscalculo: TLabel;
|
|
clb_beneficiarioscalculo: TCheckListBox;
|
|
dtsqryConsulta: TDataSource;
|
|
qryConsulta: TZQuery;
|
|
dtsListaTitulos: TDataSource;
|
|
lv_titulos: TListView;
|
|
dtp_atrasorecalc: TDateTimePicker;
|
|
lbl_datapgmnto: TLabel;
|
|
dbgrd_listtitulos: TDBGrid;
|
|
lbl_somatitulos: TLabel;
|
|
edt_somatitulos: TEdit;
|
|
lbl_vlaquitar: TLabel;
|
|
edt_vlaquitar: TEdit;
|
|
lbl_somajuros: TLabel;
|
|
edt_somajuros: TEdit;
|
|
lbl_somaentrada: TLabel;
|
|
edt_somaentrada: TEdit;
|
|
lbl_somamulta: TLabel;
|
|
edt_somamulta: TEdit;
|
|
lbl_parcelamento: TLabel;
|
|
edt_nrparcelas: TEdit;
|
|
up_nrparcelas: TUpDown;
|
|
lbl_somaindicador: TLabel;
|
|
edt_somaindicador: TEdit;
|
|
lbl_extras: TLabel;
|
|
edt_extras: TEdit;
|
|
cb_nmulta: TCheckBox;
|
|
lbl_desctot: TLabel;
|
|
edt_desctot: TEdit;
|
|
lbl_protocolo1: TLabel;
|
|
edt_protocolo1: TEdit;
|
|
lv_parcelas: TListView;
|
|
pcDescontos: TPageControl;
|
|
tabQuitar: TTabSheet;
|
|
tabParcelar: TTabSheet;
|
|
gb_descontosquit: TGroupBox;
|
|
lbl_indquitar: TLabel;
|
|
lbl_principalquitar: TLabel;
|
|
lbl_multasquitar: TLabel;
|
|
lbl_jurosquitar: TLabel;
|
|
edt_indquitar: TEdit;
|
|
edt_principalquitar: TEdit;
|
|
edt_multasquitar: TEdit;
|
|
up_encquitar: TUpDown;
|
|
up_principalquitar: TUpDown;
|
|
up_multasquitar: TUpDown;
|
|
edt_jurosquitar: TEdit;
|
|
up_jurosquitar: TUpDown;
|
|
cb_descquit: TCheckBox;
|
|
gb_descontospar: TGroupBox;
|
|
lbl_indparcelas: TLabel;
|
|
lbl_jurosparcelas: TLabel;
|
|
lbl_multasparcelas: TLabel;
|
|
lbl_principalparcelas: TLabel;
|
|
edt_indparcelas: TEdit;
|
|
edt_jurosparcelas: TEdit;
|
|
edt_multasparcelas: TEdit;
|
|
edt_principalparcelas: TEdit;
|
|
up_encparcelas: TUpDown;
|
|
up_jurosparcelas: TUpDown;
|
|
up_multasparcelas: TUpDown;
|
|
up_principalparcelas: TUpDown;
|
|
cb_descpar: TCheckBox;
|
|
Label4: TLabel;
|
|
cb_formapag: TComboBox;
|
|
btn_protocolo: TButton;
|
|
btn_fechamento: TButton;
|
|
queryListaTitulos: TZQuery;
|
|
queryListaTitulosID_TITULO: TIntegerField;
|
|
queryListaTitulosID_DEVEDOR: TIntegerField;
|
|
queryListaTitulosID_EMPRESA: TIntegerField;
|
|
queryListaTitulosTX_PRODUTO: TWideStringField;
|
|
queryListaTitulosVL_TITULO: TCurrencyField;
|
|
queryListaTitulosDT_ENTRADA: TDateTimeField;
|
|
queryListaTitulosDT_VENCIMENTO: TDateTimeField;
|
|
queryListaTitulosDT_ATRASO: TIntegerField;
|
|
queryListaTitulosTP_SITUACAO: TWideStringField;
|
|
queryListaTitulosCD_DEVEDOR: TWideStringField;
|
|
queryListaTitulosNOME_EMPRESA: TStringField;
|
|
queryListaTitulosVL_ENTRADA: TCurrencyField;
|
|
queryListaTitulosPR_JUROS: TFloatField;
|
|
queryListaTitulosVL_JUROS: TCurrencyField;
|
|
queryListaTitulosPR_MULTA: TFloatField;
|
|
queryListaTitulosVL_MULTA: TCurrencyField;
|
|
queryListaTitulosVL_ENCARGOS: TCurrencyField;
|
|
queryListaTitulosVL_CORRIGIDO: TCurrencyField;
|
|
queryListaTitulosPR_INDICADOR: TFloatField;
|
|
queryListaTitulosVL_INDICADOR: TCurrencyField;
|
|
queryListaTitulosPR_QUITACAO_INDICADOR: TFloatField;
|
|
queryListaTitulosVL_DESC_QUIT_IND: TCurrencyField;
|
|
queryListaTitulosPR_QUITACAO_PRINCIPAL: TFloatField;
|
|
queryListaTitulosVL_DESC_QUIT_PRIN: TCurrencyField;
|
|
queryListaTitulosPR_QUITACAO_MULTA: TFloatField;
|
|
queryListaTitulosVL_DESC_QUIT_MULTA: TCurrencyField;
|
|
queryListaTitulosPR_QUITACAO_JUROS: TFloatField;
|
|
queryListaTitulosVL_DESC_QUIT_JUROS: TCurrencyField;
|
|
queryListaTitulosPR_PARCELA_INDICADOR: TFloatField;
|
|
queryListaTitulosVL_DESC_PAR_IND: TCurrencyField;
|
|
queryListaTitulosPR_PARCELA_PRINCIPAL: TFloatField;
|
|
queryListaTitulosVL_DESC_PAR_PRIN: TCurrencyField;
|
|
queryListaTitulosPR_PARCELA_MULTA: TFloatField;
|
|
queryListaTitulosVL_DESC_PAR_MULTA: TCurrencyField;
|
|
queryListaTitulosPR_PARCELA_JUROS: TFloatField;
|
|
queryListaTitulosVL_DESC_PAR_JUROS: TCurrencyField;
|
|
queryListaTitulosNR_PARCELAS: TIntegerField;
|
|
queryListaTitulosVL_DESPESA: TCurrencyField;
|
|
queryListaTitulosTP_DESPESA: TWideStringField;
|
|
queryListaTitulosVL_INDICES: TCurrencyField;
|
|
tabFechamento: TTabSheet;
|
|
lbl_dtcobranca: TLabel;
|
|
dtp_diaagendamento: TDateTimePicker;
|
|
lbl_horacobranca: TLabel;
|
|
dtp_horaagendamento: TDateTimePicker;
|
|
lbl_protocolo: TLabel;
|
|
edt_protocolo: TEdit;
|
|
lbl_cobradoragendado: TLabel;
|
|
dblucb_cobradoragendar: TDBLookupComboBox;
|
|
btn_recalc: TButton;
|
|
lbl_tfonte: TLabel;
|
|
edt_fontememo: TEdit;
|
|
up_fontememo: TUpDown;
|
|
cb_negritomemo: TCheckBox;
|
|
mb_fechamento: TMemo;
|
|
lbl_providencias: TLabel;
|
|
dbgrd_providencias: TDBGrid;
|
|
lbl_prov: TLabel;
|
|
edt_prov: TEdit;
|
|
btn_concluir: TButton;
|
|
dbgrd_resumohist: TDBGrid;
|
|
copiar_conteudo: TMenuItem;
|
|
dtsCobrador: TDataSource;
|
|
queryCobradores: TZQuery;
|
|
queryCobradoresID_USUARIO: TIntegerField;
|
|
queryCobradoresTX_NOME: TWideStringField;
|
|
dtsProvidencias: TDataSource;
|
|
queryHelper: TZQuery;
|
|
dtsHelper: TDataSource;
|
|
dtsHistAgenda: TDataSource;
|
|
ROqryHistAgenda: TZReadOnlyQuery;
|
|
queryListaTitulosVL_PARCELA: TCurrencyField;
|
|
queryListaTitulosPR_JUROS_CHEQUE: TFloatField;
|
|
dbgrd_devedoreslist: TDBGrid;
|
|
queryListaTitulosVL_EXTRAS: TCurrencyField;
|
|
dtsCHGEmpresa: TDataSource;
|
|
dtsIndicadorFinanceiro: TDataSource;
|
|
dtsEmpresa: TDataSource;
|
|
lbl_maxindquit: TLabel;
|
|
lbl_maxprinquit: TLabel;
|
|
lbl_maxmultaquit: TLabel;
|
|
lbl_maxjurosquit: TLabel;
|
|
lbl_maxindpar: TLabel;
|
|
lbl_maxprinpar: TLabel;
|
|
lbl_maxmultapar: TLabel;
|
|
lbl_maxjurospar: TLabel;
|
|
lbl_maxpar: TLabel;
|
|
popmnu_incluir: TPopupMenu;
|
|
mnu_incluir: TMenuItem;
|
|
mnuretirar: TMenuItem;
|
|
queryListaTitulosPR_QUITACAO_COR: TFloatField;
|
|
queryListaTitulosPR_PARCELA_COR: TFloatField;
|
|
cb_desc_par_cor: TCheckBox;
|
|
cb_desc_quit_cor: TCheckBox;
|
|
edt_corquitar: TEdit;
|
|
ud_corquitar: TUpDown;
|
|
edt_corpar: TEdit;
|
|
ud_corpar: TUpDown;
|
|
lbl_maxparcor: TLabel;
|
|
lbl_maxquitcor: TLabel;
|
|
cb_agendar: TCheckBox;
|
|
DBEdit2: TDBEdit;
|
|
Label1: TLabel;
|
|
DBEdit3: TDBEdit;
|
|
Label2: TLabel;
|
|
lbl_ddd: TLabel;
|
|
dbedt_ddd: TDBEdit;
|
|
dblucb_providencia: TDBLookupComboBox;
|
|
Label3: TLabel;
|
|
edt_excentrada: TEdit;
|
|
cbx_excentrada: TCheckBox;
|
|
edt_prentrada: TEdit;
|
|
Label5: TLabel;
|
|
ud_entrada: TUpDown;
|
|
lbl_minentrada: TLabel;
|
|
lbl_maxentrada: TLabel;
|
|
queryListaTitulosPR_ENTRADA_MIN: TFloatField;
|
|
queryListaTitulosPR_ENTRADA_MAX: TFloatField;
|
|
queryListaTitulosPR_ENTRADA: TFloatField;
|
|
Label6: TLabel;
|
|
dtp_agendadatahist: TDateTimePicker;
|
|
Label7: TLabel;
|
|
dtp_agendahorahist: TDateTimePicker;
|
|
Label8: TLabel;
|
|
dblucb_agendacobhist: TDBLookupComboBox;
|
|
cb_agendahist: TCheckBox;
|
|
dbmemo_box: TDBMemo;
|
|
queryListaTitulosVL_PRINCIPAL: TCurrencyField;
|
|
dbmem_titobs: TDBMemo;
|
|
Label9: TLabel;
|
|
mnuFichatitulos: TMenuItem;
|
|
btn_relacaodivida: TButton;
|
|
mnu_fichahist: TMenuItem;
|
|
cbx_txextra: TCheckBox;
|
|
edt_txextra: TEdit;
|
|
btntelefones: TButton;
|
|
rdbdt_pag: TrDBDateTimePicker;
|
|
lbl_dtpag: TLabel;
|
|
navEmail: TDBNavigator;
|
|
dtsEmail: TDataSource;
|
|
dbgrd_email: TDBGrid;
|
|
DBEdit4: TDBEdit;
|
|
pnl_devedores: TPanel;
|
|
pnl_email: TPanel;
|
|
qryCampanha: TZReadOnlyQuery;
|
|
btn_cancelar: TButton;
|
|
dbgrd_tit: TDBGrid;
|
|
navtitulos: TDBNavigator;
|
|
cbx_exjurosparcelar: TCheckBox;
|
|
edt_excjurosparcela: TEdit;
|
|
dbdtp_dtcad: TDBDateTimePicker;
|
|
dbdtp_dtnasc: TDBDateTimePicker;
|
|
ACBrCEP1: TACBrCEP;
|
|
DBGrid1: TDBGrid;
|
|
Label16: TLabel;
|
|
lbl_dtrecibo: TLabel;
|
|
queryListaTitulosVL_DESC_IND: TCurrencyField;
|
|
queryListaTitulosVL_DESC_PRIN: TCurrencyField;
|
|
queryListaTitulosVL_DESC_MULTA: TCurrencyField;
|
|
queryListaTitulosVL_DESC_JUROS: TCurrencyField;
|
|
pnl_contatos: TPanel;
|
|
Label15: TLabel;
|
|
dblbl_contatos: TDBText;
|
|
zroqryProvAgend: TZReadOnlyQuery;
|
|
Panel12: TPanel;
|
|
DBRadioGroup1: TDBRadioGroup;
|
|
Label10: TLabel;
|
|
rdbdt_recibo: TrDBDateTimePicker;
|
|
ppmnuQuebraAcordo: TPopupMenu;
|
|
mnuQuebraAcordo: TMenuItem;
|
|
ZReadOnlyQuery1: TZReadOnlyQuery;
|
|
ZReadOnlyQuery1ID_ITEM: TIntegerField;
|
|
ZReadOnlyQuery1ID_ACORDO: TIntegerField;
|
|
ZReadOnlyQuery1ID_PARCELA: TIntegerField;
|
|
ZReadOnlyQuery1ID_ORIGINAL: TIntegerField;
|
|
ZReadOnlyQuery1ID_DEVEDOR: TIntegerField;
|
|
queryListaTitulosNR_JUROS: TCurrencyField;
|
|
queryListaTitulosTP_JUROS: TStringField;
|
|
dbedt_protocolo: TDBEdit;
|
|
Label11: TLabel;
|
|
cp_telddd: TMenuItem;
|
|
cp_tel: TMenuItem;
|
|
Label12: TLabel;
|
|
DBLookupComboBox1: TDBLookupComboBox;
|
|
tabBoletos: TTabSheet;
|
|
DBLookupComboBox2: TDBLookupComboBox;
|
|
Label13: TLabel;
|
|
Label14: TLabel;
|
|
DBLookupComboBox3: TDBLookupComboBox;
|
|
DBLookupComboBox4: TDBLookupComboBox;
|
|
Label17: TLabel;
|
|
gbMensagemBoleto: TGroupBox;
|
|
Label49: TLabel;
|
|
Label50: TLabel;
|
|
Label51: TLabel;
|
|
Label52: TLabel;
|
|
Label57: TLabel;
|
|
dbEdtLinha1Boleto: TDBEdit;
|
|
dbEdtLinha2Boleto: TDBEdit;
|
|
dbEdtLinha3Boleto: TDBEdit;
|
|
dbEdtLinha4Boleto: TDBEdit;
|
|
dbEdtLinha5Boleto: TDBEdit;
|
|
GroupBox3: TGroupBox;
|
|
Label34: TLabel;
|
|
Label35: TLabel;
|
|
GroupBox4: TGroupBox;
|
|
Label37: TLabel;
|
|
Label38: TLabel;
|
|
GroupBox5: TGroupBox;
|
|
Label40: TLabel;
|
|
Label41: TLabel;
|
|
GroupBox7: TGroupBox;
|
|
Label45: TLabel;
|
|
Label46: TLabel;
|
|
DBLookupComboBox5: TDBLookupComboBox;
|
|
DBEdit5: TDBEdit;
|
|
DBEdit6: TDBEdit;
|
|
DBEdit7: TDBEdit;
|
|
Label18: TLabel;
|
|
GroupBox6: TGroupBox;
|
|
Label19: TLabel;
|
|
Label20: TLabel;
|
|
Label21: TLabel;
|
|
DBLookupComboBox6: TDBLookupComboBox;
|
|
DBEdit8: TDBEdit;
|
|
DBEdit9: TDBEdit;
|
|
DBEdit10: TDBEdit;
|
|
DBLookupComboBox7: TDBLookupComboBox;
|
|
DBLookupComboBox8: TDBLookupComboBox;
|
|
DBLookupComboBox9: TDBLookupComboBox;
|
|
DBEdit11: TDBEdit;
|
|
DBEdit12: TDBEdit;
|
|
DBEdit13: TDBEdit;
|
|
DBEdit14: TDBEdit;
|
|
DBEdit15: TDBEdit;
|
|
DBEdit16: TDBEdit;
|
|
Label22: TLabel;
|
|
DBEdit17: TDBEdit;
|
|
DBEdit18: TDBEdit;
|
|
Label23: TLabel;
|
|
DBEdit19: TDBEdit;
|
|
Label24: TLabel;
|
|
Label25: TLabel;
|
|
DBEdit20: TDBEdit;
|
|
Label26: TLabel;
|
|
DBEdit21: TDBEdit;
|
|
Label27: TLabel;
|
|
DBEdit22: TDBEdit;
|
|
Label28: TLabel;
|
|
DBEdit23: TDBEdit;
|
|
GroupBox8: TGroupBox;
|
|
DBLookupComboBox10: TDBLookupComboBox;
|
|
DBGrid2: TDBGrid;
|
|
DBNavigator1: TDBNavigator;
|
|
procedure dbedt_cepKeyPress(Sender: TObject; var Key: Char);
|
|
procedure FormCreate(Sender: TObject);
|
|
procedure FormShow(Sender: TObject);
|
|
procedure dtsDBDataChange(Sender: TObject; Field: TField);
|
|
procedure btn_clearmemoClick(Sender: TObject);
|
|
procedure navPrincipalBeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
procedure ACBrCEP1BuscaEfetuada(Sender: TObject);
|
|
procedure clb_empresasClickCheck(Sender: TObject);
|
|
procedure dbgrd_titCellClick(Column: TColumn);
|
|
procedure dbgrd_titDrawColumnCell(Sender: TObject; const Rect: TRect;
|
|
DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
procedure Copiar1Click(Sender: TObject);
|
|
procedure clb_empresasMouseMove(Sender: TObject; Shift: TShiftState;
|
|
X, Y: Integer);
|
|
procedure dbgrd_titMouseMove(Sender: TObject; Shift: TShiftState;
|
|
X, Y: Integer);
|
|
procedure dbgrd_historicoDblClick(Sender: TObject);
|
|
procedure dtsEnderecosDataChange(Sender: TObject; Field: TField);
|
|
procedure dtsTitulosDataChange(Sender: TObject; Field: TField);
|
|
procedure navtitulosBeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
procedure dtsUFDataChange(Sender: TObject; Field: TField);
|
|
procedure dtsCidadesDataChange(Sender: TObject; Field: TField);
|
|
procedure FormClose(Sender: TObject; var Action: TCloseAction);
|
|
procedure Importao1Click(Sender: TObject);
|
|
procedure dbcbx_tpchequeClick(Sender: TObject);
|
|
procedure dtsDBStateChange(Sender: TObject);
|
|
procedure dtsEnderecosStateChange(Sender: TObject);
|
|
procedure dtsTelefonesStateChange(Sender: TObject);
|
|
procedure dtsTitulosStateChange(Sender: TObject);
|
|
procedure PopupMenu1Popup(Sender: TObject);
|
|
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
|
procedure dtsHistoricoStateChange(Sender: TObject);
|
|
procedure clb_beneficiarioscalculoClickCheck(Sender: TObject);
|
|
procedure queryListaTitulosCalcFields(DataSet: TDataSet);
|
|
procedure pcClientesChange(Sender: TObject);
|
|
procedure cb_nmultaClick(Sender: TObject);
|
|
procedure edt_nrparcelasChange(Sender: TObject);
|
|
procedure dtp_atrasorecalcChange(Sender: TObject);
|
|
procedure cb_descquitClick(Sender: TObject);
|
|
procedure cb_descparClick(Sender: TObject);
|
|
procedure cb_formapagChange(Sender: TObject);
|
|
procedure edt_indquitarChange(Sender: TObject);
|
|
procedure edt_principalquitarChange(Sender: TObject);
|
|
procedure edt_multasquitarChange(Sender: TObject);
|
|
procedure edt_jurosquitarChange(Sender: TObject);
|
|
procedure edt_indparcelasChange(Sender: TObject);
|
|
procedure edt_principalparcelasChange(Sender: TObject);
|
|
procedure edt_multasparcelasChange(Sender: TObject);
|
|
procedure edt_jurosparcelasChange(Sender: TObject);
|
|
procedure lv_titulosChange(Sender: TObject; Item: TListItem;
|
|
Change: TItemChange);
|
|
procedure dtp_diaagendamentoChange(Sender: TObject);
|
|
procedure pcClientesChanging(Sender: TObject; var AllowChange: Boolean);
|
|
procedure btn_protocoloClick(Sender: TObject);
|
|
procedure btn_fechamentoClick(Sender: TObject);
|
|
procedure copiar_conteudoClick(Sender: TObject);
|
|
procedure btn_recalcClick(Sender: TObject);
|
|
procedure dtp_horaagendamentoChange(Sender: TObject);
|
|
procedure dtsCobradorDataChange(Sender: TObject; Field: TField);
|
|
procedure edt_fontememoExit(Sender: TObject);
|
|
procedure edt_fontememoKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
procedure up_fontememoClick(Sender: TObject; Button: TUDBtnType);
|
|
procedure cb_negritomemoClick(Sender: TObject);
|
|
procedure dbgrd_providenciasDblClick(Sender: TObject);
|
|
procedure btn_concluirClick(Sender: TObject);
|
|
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|
procedure navenderecosBeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
procedure navtelefonesBeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
procedure mnuretirarClick(Sender: TObject);
|
|
procedure mnu_incluirClick(Sender: TObject);
|
|
procedure edt_nrparcelasExit(Sender: TObject);
|
|
procedure lv_titulosItemChecked(Sender: TObject; Item: TListItem);
|
|
procedure dbgrd_telDrawColumnCell(Sender: TObject; const Rect: TRect;
|
|
DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
procedure dbgrd_enderecosDrawColumnCell(Sender: TObject; const Rect: TRect;
|
|
DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
procedure dbgrd_titTitleClick(Column: TColumn);
|
|
procedure dbgrd_enderecosTitleClick(Column: TColumn);
|
|
procedure dbgrd_telTitleClick(Column: TColumn);
|
|
procedure dbgrd_historicoTitleClick(Column: TColumn);
|
|
procedure dbgrd_listtitulosTitleClick(Column: TColumn);
|
|
procedure dbgrd_resumohistTitleClick(Column: TColumn);
|
|
procedure cb_desc_quit_corClick(Sender: TObject);
|
|
procedure edt_corquitarChange(Sender: TObject);
|
|
procedure cb_desc_par_corClick(Sender: TObject);
|
|
procedure edt_corparChange(Sender: TObject);
|
|
procedure cb_agendarClick(Sender: TObject);
|
|
procedure navHistoricoBeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
procedure cbx_excentradaClick(Sender: TObject);
|
|
procedure edt_excentradaChange(Sender: TObject);
|
|
procedure edt_excentradaKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_prentradaChange(Sender: TObject);
|
|
procedure cb_agendahistClick(Sender: TObject);
|
|
procedure lv_titulosColumnClick(Sender: TObject; Column: TListColumn);
|
|
procedure lv_titulosCompare(Sender: TObject; Item1, Item2: TListItem;
|
|
Data: Integer; var Compare: Integer);
|
|
procedure edt_indparcelasKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_principalparcelasKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_multasparcelasKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_jurosparcelasKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_corparKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_indquitarKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_principalquitarKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_multasquitarKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_jurosquitarKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_corquitarKeyPress(Sender: TObject; var Key: Char);
|
|
procedure mnuFichatitulosClick(Sender: TObject);
|
|
procedure btn_relacaodividaClick(Sender: TObject);
|
|
procedure mnu_fichahistClick(Sender: TObject);
|
|
procedure cbx_txextraClick(Sender: TObject);
|
|
procedure edt_txextraChange(Sender: TObject);
|
|
procedure edt_txextraKeyPress(Sender: TObject; var Key: Char);
|
|
procedure btntelefonesClick(Sender: TObject);
|
|
procedure dtsEmailStateChange(Sender: TObject);
|
|
procedure btn_cancelarClick(Sender: TObject);
|
|
procedure edt_excjurosparcelaChange(Sender: TObject);
|
|
procedure edt_excjurosparcelaKeyPress(Sender: TObject; var Key: Char);
|
|
procedure cbx_exjurosparcelarClick(Sender: TObject);
|
|
procedure Panel1Enter(Sender: TObject);
|
|
procedure dbedt_cpfcnpjKeyPress(Sender: TObject; var Key: Char);
|
|
procedure dbrg_tipotelClick(Sender: TObject);
|
|
procedure dtsTelefonesDataChange(Sender: TObject; Field: TField);
|
|
procedure mnuQuebraAcordoClick(Sender: TObject);
|
|
procedure cp_teldddClick(Sender: TObject);
|
|
procedure cp_telClick(Sender: TObject);
|
|
procedure DBEdit5KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit6KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit9KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit11KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit12KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit13KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit7KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit10KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit17KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit18KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit19KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit20KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit21KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit22KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBEdit23KeyPress(Sender: TObject; var Key: Char);
|
|
procedure DBNavigator1BeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
private
|
|
old_id: Integer;
|
|
old_id_tit: Integer;
|
|
ColumnToSort: Integer;
|
|
ficha_dev: Boolean;
|
|
id_emps_dev: array of Integer;
|
|
procedure SetupHackedNavigator(const Navigator: TDBNavigator;
|
|
const Glyphs: TImageList; S: string; size: Integer);
|
|
procedure CriarLista;
|
|
procedure Att_campos;
|
|
procedure CalcValorParcelas;
|
|
procedure AdjustCheckListBox;
|
|
procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
|
|
procedure CalcPrice;
|
|
procedure ChecaPermissoes;
|
|
function CalculaIdade(Birthday, CurrentDate: TDate): Integer;
|
|
function FindSubcontrolAtPos(AControl: TControl;
|
|
AScreenPos, AClientPos: TPoint): TControl;
|
|
function FindControlAtPos(AScreenPos: TPoint): TControl;
|
|
// function EscreveTitulos(): TStringDynArray;
|
|
{ Private declarations }
|
|
public
|
|
posi: TPoint;
|
|
parcelamento: array of currency;
|
|
data_parcelas: array of TDate;
|
|
nome_cobrador: string;
|
|
dia_agendado: string;
|
|
hora_agendado: string;
|
|
clpbrd: string;
|
|
pagina: Integer;
|
|
pesquisa: Integer;
|
|
estado_db: Boolean;
|
|
importou: Boolean;
|
|
fechamento: string;
|
|
antes: TTime;
|
|
qtde_titulos: Integer;
|
|
id_emp: Integer;
|
|
str_titulos: string;
|
|
selected_id_chg_empresa: Integer;
|
|
str_tit: array of Integer;
|
|
id_emp_calc: Integer;
|
|
ids_tits_calc: array of Boolean;
|
|
imp: Boolean;
|
|
// cbl_hints : array of string;
|
|
// prevIndex : integer;
|
|
{ Public declarations }
|
|
function gerar_protocolo(id_devedor: string): string;
|
|
end;
|
|
|
|
var
|
|
cadDevedores: TcadDevedores;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem, ufrmMemoBox, uimpDevedores, ufrmCobranca,
|
|
ufrmEfetuarCobranca, ufrmFechamentoDevedor, ufrmLiberaPermissao, urelDados,
|
|
ufrmFichaTitulos, urelFichaDivida, urelHistorico, uconfFichaHistorico;
|
|
|
|
// no form show eu monto o checklistbox com as empresas que o devedor tem titulos em aberto
|
|
// que fica na aba cálculos. Lá, ao selecionar a empresa eu filtro os títulos e mostro no listview
|
|
// usando esses títulos (querylistatitulos) eu faço todos os cálculos para juros, multa, etc
|
|
// dentro do oncalc da query e em algumas funções como Att_campos e CalcValorParcelas
|
|
// o mesmo processo ocorre nas janelas da frmEfetuarCobranca e frmAtendimento, com pequenas diferenças
|
|
|
|
procedure TcadDevedores.AdjustCheckListBox;
|
|
var
|
|
i, nMaxWidth, nItemWidth: Integer;
|
|
begin
|
|
// ajusta o checklistbox pra ter scroll horizontal
|
|
// nMaxWidth := clb_empresas.ClientWidth;
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// nItemWidth := clb_empresas.Canvas.TextWidth(clb_empresas.Items[i]) + 20;
|
|
// if (nItemWidth > nMaxWidth) then
|
|
// nMaxWidth := nItemWidth;
|
|
// end;
|
|
// if (nMaxWidth > clb_empresas.ClientWidth) then
|
|
// begin
|
|
// clb_empresas.ScrollWidth := nMaxWidth;
|
|
// end;
|
|
end;
|
|
|
|
procedure TcadDevedores.Att_campos;
|
|
var
|
|
soma_nominal, soma_encargos, soma_corrigido, soma_entrada, soma_juros,
|
|
soma_multas, soma_indicador { desc_fixo, acr_fixo, soma_indices }
|
|
: currency;
|
|
i, n_parcelas, quit_ind, quit_prin, quit_multa, quit_juros, parc_ind,
|
|
parc_prin, parc_multa, parc_juros, quit_cor, par_cor, minentrada,
|
|
maxentrada: Integer;
|
|
begin
|
|
// atualiza os valores a serem mostrados nos edits
|
|
soma_nominal := 0.00;
|
|
soma_encargos := 0.00;
|
|
soma_corrigido := 0.00;
|
|
soma_entrada := 0.00;
|
|
soma_juros := 0.00;
|
|
soma_multas := 0.00;
|
|
soma_indicador := 0.00;
|
|
// soma_indices := 0.00;
|
|
|
|
n_parcelas := 0;
|
|
|
|
quit_ind := 0;
|
|
quit_prin := 0;
|
|
quit_multa := 0;
|
|
quit_juros := 0;
|
|
quit_cor := 0;
|
|
|
|
minentrada := 0;
|
|
maxentrada := 0;
|
|
|
|
parc_ind := 0;
|
|
parc_prin := 0;
|
|
parc_multa := 0;
|
|
parc_juros := 0;
|
|
par_cor := 0;
|
|
queryListaTitulos.DisableControls;
|
|
for i := 0 to lv_titulos.Items.Count - 1 do
|
|
begin
|
|
if lv_titulos.Items.Item[i].Checked then
|
|
begin
|
|
queryListaTitulos.RecNo := i + 1;
|
|
soma_nominal := soma_nominal + queryListaTitulosVL_TITULO.AsCurrency;
|
|
soma_encargos := soma_encargos + queryListaTitulosVL_ENCARGOS.AsCurrency;
|
|
soma_corrigido := soma_corrigido + queryListaTitulosVL_CORRIGIDO.
|
|
AsCurrency;
|
|
soma_entrada := soma_entrada + queryListaTitulosVL_ENTRADA.AsCurrency;
|
|
soma_juros := soma_juros + queryListaTitulosVL_JUROS.AsCurrency;
|
|
soma_multas := soma_multas + queryListaTitulosVL_MULTA.AsCurrency;
|
|
soma_indicador := soma_indicador + queryListaTitulosVL_INDICADOR.
|
|
AsCurrency;
|
|
// soma_indices := soma_indices + queryListaTitulosVL_INDICES.AsCurrency;
|
|
if n_parcelas < (queryListaTitulosNR_PARCELAS.AsInteger) then
|
|
begin
|
|
n_parcelas := queryListaTitulosNR_PARCELAS.AsInteger;
|
|
end;
|
|
|
|
if minentrada < (queryListaTitulosPR_ENTRADA_MIN.AsInteger) then
|
|
begin
|
|
minentrada := queryListaTitulosPR_ENTRADA_MIN.AsInteger;
|
|
end;
|
|
// edt_prentrada.Text := inttostr(minentrada);
|
|
if maxentrada < (queryListaTitulosPR_ENTRADA_MAX.AsInteger) then
|
|
begin
|
|
maxentrada := queryListaTitulosPR_ENTRADA_MAX.AsInteger;
|
|
end;
|
|
|
|
if quit_ind < (queryListaTitulosPR_QUITACAO_INDICADOR.AsInteger) then
|
|
begin
|
|
quit_ind := queryListaTitulosPR_QUITACAO_INDICADOR.AsInteger;
|
|
end;
|
|
if quit_prin < (queryListaTitulosPR_QUITACAO_PRINCIPAL.AsInteger) then
|
|
begin
|
|
quit_prin := queryListaTitulosPR_QUITACAO_PRINCIPAL.AsInteger;
|
|
end;
|
|
if quit_multa < (queryListaTitulosPR_QUITACAO_MULTA.AsInteger) then
|
|
begin
|
|
quit_multa := queryListaTitulosPR_QUITACAO_MULTA.AsInteger;
|
|
end;
|
|
if quit_juros < (queryListaTitulosPR_QUITACAO_JUROS.AsInteger) then
|
|
begin
|
|
quit_juros := queryListaTitulosPR_QUITACAO_JUROS.AsInteger;
|
|
end;
|
|
if quit_cor < (queryListaTitulosPR_QUITACAO_COR.AsInteger) then
|
|
begin
|
|
quit_cor := queryListaTitulosPR_QUITACAO_COR.AsInteger;
|
|
end;
|
|
|
|
if parc_ind < (queryListaTitulosPR_PARCELA_INDICADOR.AsInteger) then
|
|
begin
|
|
parc_ind := queryListaTitulosPR_PARCELA_INDICADOR.AsInteger;
|
|
end;
|
|
if parc_prin < (queryListaTitulosPR_PARCELA_PRINCIPAL.AsInteger) then
|
|
begin
|
|
parc_prin := queryListaTitulosPR_PARCELA_PRINCIPAL.AsInteger;
|
|
end;
|
|
if parc_multa < (queryListaTitulosPR_PARCELA_MULTA.AsInteger) then
|
|
begin
|
|
parc_multa := queryListaTitulosPR_PARCELA_MULTA.AsInteger;
|
|
end;
|
|
if parc_juros < (queryListaTitulosPR_PARCELA_JUROS.AsInteger) then
|
|
begin
|
|
parc_juros := queryListaTitulosPR_PARCELA_JUROS.AsInteger;
|
|
end;
|
|
if par_cor < (queryListaTitulosPR_PARCELA_COR.AsInteger) then
|
|
begin
|
|
par_cor := queryListaTitulosPR_PARCELA_COR.AsInteger;
|
|
end;
|
|
end;
|
|
end;
|
|
// queryListaTitulos.First;
|
|
queryListaTitulos.EnableControls;
|
|
edt_somatitulos.Text := CurrToStrF(soma_nominal, ffCurrency, 2,
|
|
dtmSystem.CusFmt);
|
|
// edt_indices.Text := CurrToStrF(soma_indices, ffCurrency, 2, dtmSystem.CusFmt);
|
|
edt_extras.Text := CurrToStrF(soma_encargos, ffCurrency, 2, dtmSystem.CusFmt);
|
|
// if cbx_txextra.Checked then
|
|
// begin
|
|
// soma_corrigido := soma_corrigido + StrToCurr(edt_txextra.Text);
|
|
// end;
|
|
edt_vlaquitar.Text := CurrToStrF(soma_corrigido, ffCurrency, 2,
|
|
dtmSystem.CusFmt);
|
|
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
edt_somaentrada.Text := CurrToStrF(StrToCurr(edt_excentrada.Text),
|
|
ffCurrency, 2, dtmSystem.CusFmt);
|
|
end
|
|
else
|
|
begin
|
|
edt_somaentrada.Text := CurrToStrF(soma_entrada, ffCurrency, 2,
|
|
dtmSystem.CusFmt);
|
|
end;
|
|
{ end; }
|
|
edt_somaindicador.Text := CurrToStrF(soma_indicador, ffCurrency, 2,
|
|
dtmSystem.CusFmt);
|
|
edt_somamulta.Text := CurrToStrF(soma_multas, ffCurrency, 2,
|
|
dtmSystem.CusFmt);
|
|
edt_somajuros.Text := CurrToStrF(soma_juros, ffCurrency, 2, dtmSystem.CusFmt);
|
|
up_nrparcelas.Max := n_parcelas;
|
|
lbl_maxpar.Caption := 'Máx: ' + inttostr(n_parcelas);
|
|
|
|
ud_entrada.Min := minentrada;
|
|
ud_entrada.Max := maxentrada;
|
|
lbl_minentrada.Caption := 'Min: ' + inttostr(minentrada) + '%';
|
|
lbl_maxentrada.Caption := 'Máx: ' + inttostr(maxentrada) + '%';
|
|
|
|
up_encquitar.Max := quit_ind;
|
|
lbl_maxindquit.Caption := 'Máx: ' + inttostr(quit_ind) + '%';
|
|
up_principalquitar.Max := quit_prin;
|
|
lbl_maxprinquit.Caption := 'Máx: ' + inttostr(quit_prin) + '%';
|
|
up_multasquitar.Max := quit_multa;
|
|
lbl_maxmultaquit.Caption := 'Máx: ' + inttostr(quit_multa) + '%';
|
|
up_jurosquitar.Max := quit_juros;
|
|
lbl_maxjurosquit.Caption := 'Máx: ' + inttostr(quit_juros) + '%';
|
|
ud_corquitar.Max := quit_cor;
|
|
lbl_maxquitcor.Caption := 'Máx: ' + inttostr(quit_cor) + '%';
|
|
|
|
up_encparcelas.Max := parc_ind;
|
|
lbl_maxindpar.Caption := 'Máx: ' + inttostr(parc_ind) + '%';
|
|
up_principalparcelas.Max := parc_prin;
|
|
lbl_maxprinpar.Caption := 'Máx: ' + inttostr(parc_prin) + '%';
|
|
up_multasparcelas.Max := parc_multa;
|
|
lbl_maxmultapar.Caption := 'Máx: ' + inttostr(parc_multa) + '%';
|
|
up_jurosparcelas.Max := parc_juros;
|
|
lbl_maxjurospar.Caption := 'Máx: ' + inttostr(parc_juros) + '%';
|
|
ud_corpar.Max := par_cor;
|
|
lbl_maxparcor.Caption := 'Máx: ' + inttostr(par_cor) + '%';
|
|
end;
|
|
|
|
procedure TcadDevedores.btntelefonesClick(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
dtsTelefones.DataSet.First;
|
|
i := 1;
|
|
while not dtsTelefones.DataSet.Eof do
|
|
begin
|
|
if dtsTelefones.DataSet.FieldByName('TP_ATIVO').AsString <> 'N' then
|
|
begin
|
|
dbmemo_box.lines.Add('Telefone nº' + inttostr(i) + ': (' +
|
|
dtsTelefones.DataSet.FieldByName('nr_ddd').AsString + ')' +
|
|
dtsTelefones.DataSet.FieldByName('nr_numero').AsString);
|
|
Inc(i, 1);
|
|
end;
|
|
dtsTelefones.DataSet.Next;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.btn_cancelarClick(Sender: TObject);
|
|
begin
|
|
cb_formapag.ItemIndex := 0;
|
|
edt_prov.Text := '';
|
|
edt_protocolo1.Text := '';
|
|
edt_protocolo1.Text := '';
|
|
edt_nrparcelas.Text := '0';
|
|
edt_nrparcelas.OnChange(self);
|
|
cb_agendar.Checked := false;
|
|
btn_protocolo.Enabled := True;
|
|
clb_beneficiarioscalculo.Enabled := True;
|
|
lv_titulos.Enabled := True;
|
|
edt_nrparcelas.Enabled := True;
|
|
up_nrparcelas.Enabled := True;
|
|
cb_nmulta.Enabled := True;
|
|
dtp_atrasorecalc.Enabled := True;
|
|
cb_descquit.Enabled := True;
|
|
cb_descpar.Enabled := True;
|
|
pcClientes.TabIndex := 0;
|
|
fechamento := 'olhando';
|
|
end;
|
|
|
|
procedure TcadDevedores.btn_clearmemoClick(Sender: TObject);
|
|
begin
|
|
dbmem_tel.lines.Clear;
|
|
end;
|
|
|
|
procedure TcadDevedores.btn_concluirClick(Sender: TObject);
|
|
// var
|
|
// nao_marcou: Boolean;
|
|
// i{, id_emp}: Integer;
|
|
// count_titulos: Integer;
|
|
// str_titulos: string;
|
|
begin
|
|
|
|
if not dtmSystem.tblProvidencias.Active then
|
|
begin
|
|
dtmSystem.tblProvidencias.Open;
|
|
end;
|
|
if edt_prov.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor selecione uma providência.', mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
with zroqryProvAgend do
|
|
begin
|
|
SQL.Clear;
|
|
SQL.Add('select * from chg_providencias where tp_forcaagenda = ' +
|
|
QuotedStr('Sim') + ' and id_providencia = ' +
|
|
dtmSystem.tblProvidenciasID_PROVIDENCIA.AsString);
|
|
Open;
|
|
end;
|
|
if (zroqryProvAgend.RecordCount = 1) and (cb_agendar.Checked = false) then
|
|
begin
|
|
MessageDlg
|
|
('Esta providência exige que você agende o devedor. Por favor agende-o.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
if (dblucb_cobradoragendar.keyvalue < 0) and (cb_agendar.Checked = True) then
|
|
begin
|
|
MessageDlg
|
|
('Por favor selecione um cobrador para qual será agendada a cobrança.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
if (cb_agendar.Checked = True) then
|
|
begin
|
|
if MessageDlg('Este acionamento possui um agendamento. Deseja continuar?',
|
|
mtWarning, mbYesNo, 0) = mrNo then
|
|
begin
|
|
abort;
|
|
end;
|
|
if (dtp_horaagendamento.Time < Timeof(Now)) and
|
|
(dtp_diaagendamento.Date <= dateof(Now)) then
|
|
begin
|
|
MessageDlg
|
|
('Você está selecionando um horário para agendamento menor que a hora atual. Por favor verifique o horário do agendamento.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
end;
|
|
// queryListaDevedores.RecNo := recno_devedor;
|
|
if not dtmSystem.tblHistorico.Active then
|
|
begin
|
|
dtmSystem.tblHistorico.Open;
|
|
end;
|
|
if not dtmSystem.tblAgenda.Active then
|
|
begin
|
|
dtmSystem.tblAgenda.Open;
|
|
end;
|
|
if not dtmSystem.tblProtocolo.Active then
|
|
begin
|
|
dtmSystem.tblProtocolo.Open;
|
|
end;
|
|
if dtmSystem.tblProvidencias.ControlsDisabled then
|
|
begin
|
|
dtmSystem.tblProvidencias.EnableControls;
|
|
end;
|
|
cb_formapag.ItemIndex := 0;
|
|
// count_titulos := 0;
|
|
|
|
edt_nrparcelas.Text := '0';
|
|
edt_nrparcelas.OnChange(self);
|
|
|
|
// nao_marcou := true;
|
|
|
|
dtmSystem.tblProvidencias.Locate('TX_NOME', edt_prov.Text, []);
|
|
edt_prov.Text := '';
|
|
// verifica se o cara cobrado era de uma agenda
|
|
dtmSystem.tblAgenda.Refresh;
|
|
while dtmSystem.tblAgenda.Locate('ID_DEVEDOR;TP_SITUACAO',
|
|
VarArrayOf([dtsDB.DataSet.FieldByName('ID_DEVEDOR').AsInteger, 'A']), []
|
|
) = True do
|
|
begin
|
|
dtmSystem.tblAgenda.Edit;
|
|
dtmSystem.tblAgendaTP_SITUACAO.AsString := 'B';
|
|
dtmSystem.tblAgenda.Post;
|
|
end;
|
|
|
|
// for i := 0 to lv_titulos.Items.Count - 1 do
|
|
// begin
|
|
// if lv_titulos.Items[i].Checked then
|
|
// begin
|
|
// queryListaTitulos.RecNo := i + 1;
|
|
//
|
|
// nao_marcou := false;
|
|
// // end;
|
|
// str_titulos := str_titulos + queryListaTitulosID_TITULO.AsString + ';';
|
|
// id_emp := queryListaTitulosID_EMPRESA.AsInteger;
|
|
// Inc(count_titulos);
|
|
// end;
|
|
// end;
|
|
|
|
// with dtmSystem do
|
|
// begin
|
|
// tblCampanhaDevedores.Filtered := false;
|
|
// while tblCampanhaDevedores.Locate('ID_DEVEDOR',
|
|
// dtsDevedores.DataSet.FieldByName('ID_DEVEDOR').AsInteger, []) do
|
|
// begin
|
|
// // dtmSystem.tblCampanhaDevedores.Edit;
|
|
// // dtmSystem.tblCampanhaDevedoresTP_ESTADO.AsString := 'C';
|
|
// // // Saiu da campanha por agendamento
|
|
// // dtmSystem.tblCampanhaDevedoresTP_COBRANDO.AsInteger := -1;
|
|
// // dtmSystem.tblCampanhaDevedores.Post;
|
|
// dtmSystem.tblCampanhaDevedores.Delete;
|
|
// end;
|
|
// end;
|
|
dtmSystem.ZSQLProcessor1.Script.Text :=
|
|
'delete from chg_campanhas_devedores where id_devedor = ' +
|
|
QuotedStr(dtmSystem.dtsDevedores.DataSet.FieldByName('ID_DEVEDOR')
|
|
.AsString);
|
|
dtmSystem.ZSQLProcessor1.Execute;
|
|
|
|
// abre um novo histórico com a providencia selecionada e o texto montado
|
|
dtmSystem.tblHistorico.Append;
|
|
dtmSystem.tblHistoricoID_DEVEDOR.AsString :=
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString;
|
|
dtmSystem.tblHistoricoID_TITULOS.AsString := str_titulos;
|
|
dtmSystem.tblHistoricoID_PROVIDENCIA.AsString :=
|
|
dtmSystem.tblProvidenciasID_PROVIDENCIA.AsString;
|
|
dtmSystem.tblHistoricoDT_CONTATO.AsDateTime := Now;
|
|
dtmSystem.tblHistoricoCD_PROTOCOLO.AsString := edt_protocolo.Text;
|
|
dtmSystem.tblHistoricoTL_MEMO.AsString := mb_fechamento.Text;
|
|
dtmSystem.tblHistorico.Post;
|
|
if cb_agendar.Checked then // agenda pra outro cobrador
|
|
begin
|
|
|
|
dtp_diaagendamentoChange(self);
|
|
dtp_horaagendamentoChange(self);
|
|
// dtsCobradorDataChange(self,queryCobradores.FieldByName('TX_NOME'));
|
|
|
|
with dtmSystem do
|
|
begin
|
|
tblAgenda.Append;
|
|
tblAgendaID_COBRADOR.AsInteger := dblucb_cobradoragendar.keyvalue;
|
|
tblAgendaID_DEVEDOR.AsInteger :=
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsInteger;
|
|
tblAgendaDT_AGENDADA.AsDateTime := dtp_diaagendamento.Date;
|
|
tblAgendaHR_AGENDADA.AsDateTime := dtp_horaagendamento.Time;
|
|
tblAgendaDT_QUE_AGENDOU.AsDateTime := Now;
|
|
tblAgendaQUEM_AGENDOU.AsInteger := dtmSystem.id_usuario;
|
|
tblAgenda.Post;
|
|
end;
|
|
|
|
end;
|
|
{ dtmSystem.tblProtocolo.Append;
|
|
// preciso revisar protocolo pra usar no atendimento
|
|
// não preciso mais
|
|
dtmSystem.tblProtocoloCD_PROTOCOLO.AsString := edt_protocolo.Text;
|
|
// guardava aqui o que cobrador selecionou na tela
|
|
dtmSystem.tblProtocoloQNT_TITULOS.AsInteger := qtde_titulos;
|
|
// pra agilizar no atendimento
|
|
dtmSystem.tblProtocoloID_EMPRESA.AsInteger := id_emp;
|
|
dtmSystem.tblProtocoloID_TITULOS.AsString := str_titulos;
|
|
dtmSystem.tblProtocoloID_DEVEDOR.AsString :=
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString;
|
|
dtmSystem.tblProtocoloVL_ENTRADA.AsCurrency :=
|
|
StrToCurr(StringReplace(copy(edt_somaentrada.Text, 4,
|
|
Length(edt_somaentrada.Text) - 3), '.', '',
|
|
[rfReplaceAll, rfIgnoreCase]));
|
|
dtmSystem.tblProtocoloPR_ENTRADA.AsFloat := strtofloat(edt_prentrada.Text);
|
|
dtmSystem.tblProtocoloVL_JUROS.AsCurrency :=
|
|
StrToCurr(StringReplace(copy(edt_somajuros.Text, 4,
|
|
Length(edt_somajuros.Text) - 3), '.', '', [rfReplaceAll, rfIgnoreCase]));
|
|
// if cb_nmulta.Checked then
|
|
// begin
|
|
// dtmSystem.tblProtocoloVL_MULTA.AsCurrency := 0;
|
|
// end
|
|
// else
|
|
// begin
|
|
dtmSystem.tblProtocoloVL_MULTA.AsCurrency :=
|
|
StrToCurr(StringReplace(copy(edt_somamulta.Text, 4,
|
|
Length(edt_somamulta.Text) - 3), '.', '', [rfReplaceAll, rfIgnoreCase]));
|
|
// end;
|
|
dtmSystem.tblProtocoloVL_INDICADOR.AsCurrency :=
|
|
StrToCurr(StringReplace(copy(edt_somaindicador.Text, 4,
|
|
Length(edt_somaindicador.Text) - 3), '.', '',
|
|
[rfReplaceAll, rfIgnoreCase]));
|
|
dtmSystem.tblProtocoloVL_CORRIGIDO.AsCurrency :=
|
|
StrToCurr(StringReplace(copy(edt_vlaquitar.Text, 4,
|
|
Length(edt_vlaquitar.Text) - 3), '.', '', [rfReplaceAll, rfIgnoreCase]));
|
|
if cb_descquit.Checked then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_QUIT.AsString := 'S';
|
|
end
|
|
else
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_QUIT.AsString := 'N';
|
|
end;
|
|
if cb_desc_quit_cor.Enabled then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_QUIT_COR.AsString := 'S';
|
|
end
|
|
else
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_QUIT_COR.AsString := 'N';
|
|
end;
|
|
dtmSystem.tblProtocoloPR_QUIT_JUROS.AsFloat :=
|
|
strtofloat(edt_jurosquitar.Text);
|
|
dtmSystem.tblProtocoloPR_QUIT_MULTA.AsFloat :=
|
|
strtofloat(edt_multasquitar.Text);
|
|
dtmSystem.tblProtocoloPR_QUIT_INDICADOR.AsFloat :=
|
|
strtofloat(edt_indquitar.Text);
|
|
dtmSystem.tblProtocoloPR_QUIT_PRINCIPAL.AsFloat :=
|
|
strtofloat(edt_principalquitar.Text);
|
|
dtmSystem.tblProtocoloPR_QUIT_COR.AsFloat := strtofloat(edt_corquitar.Text);
|
|
if cb_descpar.Checked then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_PAR.AsString := 'S';
|
|
end
|
|
else
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_PAR.AsString := 'N';
|
|
end;
|
|
if cb_desc_par_cor.Enabled then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_PAR_COR.AsString := 'S';
|
|
end
|
|
else
|
|
begin
|
|
dtmSystem.tblProtocoloTP_DESC_PAR_COR.AsString := 'N';
|
|
end;
|
|
dtmSystem.tblProtocoloPR_PARCELAR_JUROS.AsFloat :=
|
|
strtofloat(edt_jurosparcelas.Text);
|
|
dtmSystem.tblProtocoloPR_PARCELAR_MULTA.AsFloat :=
|
|
strtofloat(edt_multasparcelas.Text);
|
|
dtmSystem.tblProtocoloPR_PARCELAR_INDICADOR.AsFloat :=
|
|
strtofloat(edt_indparcelas.Text);
|
|
dtmSystem.tblProtocoloPR_PARCELAR_PRINCIPAL.AsFloat :=
|
|
strtofloat(edt_principalparcelas.Text);
|
|
dtmSystem.tblProtocoloPR_PARCELAR_COR.AsFloat :=
|
|
strtofloat(edt_corpar.Text);
|
|
dtmSystem.tblProtocoloNR_PARCELAS.AsInteger :=
|
|
strtoint(edt_nrparcelas.Text);
|
|
dtmSystem.tblProtocoloDT_PROTOCOLO.AsDateTime := dtp_atrasorecalc.Date;
|
|
if cb_formapag.Text = 'Dinheiro' then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_PAG.AsString := 'DI';
|
|
end;
|
|
if cb_formapag.Text = 'Cheque' then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_PAG.AsString := 'CQ';
|
|
end;
|
|
if cb_formapag.Text = 'Débito' then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_PAG.AsString := 'DB';
|
|
end;
|
|
if cb_formapag.Text = 'Crédito' then
|
|
begin
|
|
dtmSystem.tblProtocoloTP_PAG.AsString := 'CR';
|
|
end;
|
|
dtmSystem.tblProtocolo.Post; }
|
|
|
|
// if nao_marcou then
|
|
// begin
|
|
// dtmSystem.tblHistorico.Edit;
|
|
// dtmSystem.tblHistoricoID_PROVIDENCIA.AsString :=
|
|
// dtmSystem.tblProvidenciasID_PROVIDENCIA.AsString;
|
|
// dtmSystem.tblHistoricoDT_CONTATO.AsDateTime := Now;
|
|
// dtmSystem.tblHistoricoCD_PROTOCOLO.AsString := edt_protocolo.Text;
|
|
// dtmSystem.tblHistoricoTL_MEMO.AsString := mb_fechamento.Text;
|
|
//
|
|
// dtmSystem.tblHistorico.Post;
|
|
// end;
|
|
|
|
dtp_agendadatahist.Date := Date;
|
|
dtp_agendahorahist.Time := Timeof(Now);
|
|
dtp_diaagendamento.Date := Date;
|
|
dtp_horaagendamento.Date := Timeof(Now);
|
|
|
|
cb_agendar.Checked := false;
|
|
btn_protocolo.Enabled := True;
|
|
clb_beneficiarioscalculo.Enabled := True;
|
|
lv_titulos.Enabled := True;
|
|
edt_nrparcelas.Enabled := True;
|
|
up_nrparcelas.Enabled := True;
|
|
cb_nmulta.Enabled := True;
|
|
dtp_atrasorecalc.Enabled := True;
|
|
cb_descquit.Enabled := True;
|
|
cb_descpar.Enabled := True;
|
|
pcClientes.TabIndex := 0;
|
|
fechamento := 'olhando';
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.btn_fechamentoClick(Sender: TObject);
|
|
var
|
|
selecionado: Boolean;
|
|
i { , h, k } : Integer;
|
|
// titulos: array of string;
|
|
begin
|
|
selecionado := false;
|
|
for i := 0 to lv_titulos.Items.Count - 1 do
|
|
begin
|
|
if lv_titulos.Items[i].Checked = True then
|
|
begin
|
|
selecionado := True;
|
|
end;
|
|
end;
|
|
if selecionado = True then
|
|
begin
|
|
dtmSystem.tblProvidencias.Open;
|
|
// clb_beneficiarioscalculo.Enabled := false;
|
|
// lv_titulos.Enabled := false;
|
|
// edt_nrparcelas.Enabled := false;
|
|
// up_nrparcelas.Enabled := false;
|
|
// cb_nmulta.Enabled := false;
|
|
// dtp_atrasorecalc.Enabled := false;
|
|
// cb_descquit.Enabled := false;
|
|
// cb_descpar.Enabled := false;
|
|
//
|
|
// if btn_protocolo.Enabled then
|
|
// begin
|
|
// edt_protocolo.Text :=
|
|
// gerar_protocolo(dtmSystem.tblDevedoresID_DEVEDOR.AsString);
|
|
// edt_protocolo1.Text := edt_protocolo.Text;
|
|
// btn_protocolo.Enabled := false;
|
|
// end;
|
|
//
|
|
// fechamento := 'fechamento';
|
|
// pcClientes.TabIndex := 6;
|
|
// mb_fechamento.SetFocus;
|
|
//
|
|
// mb_fechamento.Clear;
|
|
//
|
|
// mb_fechamento.Lines.Add('Cobrador: ' + dtmSystem.tx_usuario);
|
|
// mb_fechamento.Lines.Add('');
|
|
// mb_fechamento.Lines.Add(DateToStr(Date) + ' - ' + TimeToStr(Time));
|
|
// mb_fechamento.Lines.Add('');
|
|
//
|
|
// if not dtmSystem.tblTelefones.Active then
|
|
// begin
|
|
// dtmSystem.tblTelefones.Open;
|
|
// end;
|
|
// dtmSystem.tblTelefones.First;
|
|
// h := 1;
|
|
// while not dtmSystem.tblTelefones.Eof do
|
|
// begin
|
|
// mb_fechamento.Lines.Add('Telefone nº' + inttostr(h) + ': ' +
|
|
// dtmSystem.tblTelefonesNR_NUMERO.AsString + ' - Situação: ');
|
|
// dtmSystem.tblTelefones.Next;
|
|
// Inc(h);
|
|
// end;
|
|
// // dtmSystem.tblTelefones.Close;
|
|
// // mb_fechamento.Lines.Add('');
|
|
// // mb_fechamento.Lines.Add(dtmSystem.tblDevedoresTX_NOME.AsString +
|
|
// // ' retornou a ligação.');
|
|
// // mb_fechamento.Lines.Add('');
|
|
//
|
|
// setlength(titulos, Length(EscreveTitulos()));
|
|
// for k := 0 to Length(titulos) - 1 do
|
|
// begin
|
|
// titulos[k] := EscreveTitulos()[k];
|
|
// end;
|
|
// if Length(titulos) > 1 then
|
|
// begin
|
|
// mb_fechamento.Lines.Add('Foram cobrados os títulos:');
|
|
// mb_fechamento.Lines.Add('');
|
|
// end
|
|
// else
|
|
// begin
|
|
// mb_fechamento.Lines.Add('Foi cobrado o título:');
|
|
// mb_fechamento.Lines.Add('');
|
|
// end;
|
|
// for i := 0 to Length(titulos) - 1 do
|
|
// begin
|
|
// mb_fechamento.Lines.Add(titulos[i]);
|
|
// end;
|
|
// mb_fechamento.Lines.Add('');
|
|
// mb_fechamento.Lines.Add('');
|
|
// mb_fechamento.Lines.Add('ADICIONAR TIPO DE NEGOCIAÇÃO MANUALMENTE.');
|
|
// mb_fechamento.Lines.Add('');
|
|
// mb_fechamento.Lines.Add('');
|
|
// // mb_fechamento.Lines.Add('Forma de pagamento:');
|
|
// // mb_fechamento.Lines.Add('Data para pagamento: ' +
|
|
// // DateToStr(dtp_atrasorecalc.Date));
|
|
// // mb_fechamento.Lines.Add('Valor total corrigido: ' +
|
|
// // edt_vlaquitar.Text + '.');
|
|
// // mb_fechamento.Lines.Add('Valor total nominal: ' +
|
|
// // edt_somatitulos.Text + '.');
|
|
// // if cb_nmulta.Checked then
|
|
// // begin
|
|
// // mb_fechamento.Lines.Add('Não foi cobrado multa.');
|
|
// // end
|
|
// // else
|
|
// // begin
|
|
// // mb_fechamento.Lines.Add('Valor total da multa: ' +
|
|
// // edt_somamulta.Text + '.');
|
|
// // end;
|
|
// // mb_fechamento.Lines.Add('Valor total de juros: ' +
|
|
// // edt_somajuros.Text + '.');
|
|
// // mb_fechamento.Lines.Add('Valor total de encargos: ' +
|
|
// // edt_somaindicador.Text + '.');
|
|
// // if cb_descquit.Checked then
|
|
// // begin
|
|
// // mb_fechamento.Lines.Add
|
|
// // ('Foi concedido descontos conforme a seguir: (QUITAÇÃO)');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre principal: ' +
|
|
// // edt_principalquitar.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre multa: ' +
|
|
// // edt_multasquitar.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre juros: ' +
|
|
// // edt_jurosquitar.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre encargos: ' +
|
|
// // edt_indquitar.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre encargos: ' +
|
|
// // edt_corquitar.Text + '%.')
|
|
// // end;
|
|
// // mb_fechamento.Lines.Add('Forma de Pagamento sugerida: ' + cb_formapag.Text);
|
|
// // mb_fechamento.Lines.Add('');
|
|
// // mb_fechamento.Lines.Add('Quantidade de parcelas: ' +
|
|
// // edt_nrparcelas.Text + '.');
|
|
// // copiar_conteudoClick(Copiar1);
|
|
// // mb_fechamento.Lines.Add(clpbrd);
|
|
// // if cb_descpar.Checked then
|
|
// // begin
|
|
// // mb_fechamento.Lines.Add
|
|
// // ('Foi concedido descontos conforme a seguir: (PARCELAMENTO)');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre principal: ' +
|
|
// // edt_principalparcelas.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre multa: ' +
|
|
// // edt_multasparcelas.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre juros: ' +
|
|
// // edt_jurosparcelas.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre encargos: ' +
|
|
// // edt_indparcelas.Text + '%.');
|
|
// // mb_fechamento.Lines.Add('Porcentagem sobre encargos: ' +
|
|
// // edt_corpar.Text + '%.');
|
|
// // end;
|
|
// // mb_fechamento.Lines.Add('Forma de Pagamento sugerida: ' + cb_formapag.Text);
|
|
with TfrmFechamentoDevedor.Create(self) do
|
|
begin
|
|
ShowModal;
|
|
if ModalResult = mrOk then
|
|
begin
|
|
fechamento := 'fechamento';
|
|
pcClientes.TabIndex := 6;
|
|
btn_protocoloClick(self);
|
|
mb_fechamento.SetFocus;
|
|
end;
|
|
end;
|
|
|
|
end
|
|
else
|
|
begin
|
|
MessageDlg
|
|
('Por favor selecione um título primeiro para realizar o fechamento.',
|
|
mtWarning, [mbOK], 0);
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.btn_protocoloClick(Sender: TObject);
|
|
begin
|
|
if edt_protocolo.Text = '' then
|
|
begin
|
|
edt_protocolo.Text := gerar_protocolo
|
|
(dtmSystem.tblDevedoresID_DEVEDOR.AsString);
|
|
edt_protocolo1.Text := edt_protocolo.Text;
|
|
btn_protocolo.Enabled := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.btn_recalcClick(Sender: TObject);
|
|
begin
|
|
// zera algumas variáveis e coisas usadas no cálculo e no fechamento
|
|
dia_agendado := '__/__/____';
|
|
hora_agendado := '__:__';
|
|
nome_cobrador := '__________';
|
|
pcClientes.TabIndex := 5;
|
|
clb_beneficiarioscalculo.Enabled := True;
|
|
lv_titulos.Enabled := True;
|
|
edt_nrparcelas.Enabled := True;
|
|
up_nrparcelas.Enabled := True;
|
|
cb_nmulta.Enabled := True;
|
|
dtp_atrasorecalc.Enabled := True;
|
|
cb_descquit.Enabled := True;
|
|
cb_descpar.Enabled := True;
|
|
cb_agendar.Checked := false;
|
|
end;
|
|
|
|
procedure TcadDevedores.btn_relacaodividaClick(Sender: TObject);
|
|
var
|
|
i, j: Integer;
|
|
str_filter: string;
|
|
begin
|
|
if queryListaTitulos.IsEmpty then
|
|
begin
|
|
MessageDlg('Por favor selecione uma empresa.', mtWarning, [mbOK], 0);
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
ficha_dev := True;
|
|
str_filter := '';
|
|
queryListaTitulos.DisableControls;
|
|
for j := 0 to Length(str_tit) - 1 do
|
|
begin
|
|
// queryListaTitulos.RecNo := str_tit[j];
|
|
str_filter := str_filter + 'ID_TITULO = ' + inttostr(str_tit[j]) + ' OR ';
|
|
end;
|
|
queryListaTitulos.EnableControls;
|
|
if Length(str_tit) > 0 then
|
|
begin
|
|
setlength(str_filter, Length(str_filter) - 3);
|
|
queryListaTitulos.Filtered := false;
|
|
queryListaTitulos.Filter := str_filter;
|
|
queryListaTitulos.Filtered := True;
|
|
end;
|
|
relFichaDivida := TrelFichaDivida.Create(self);
|
|
with relFichaDivida do
|
|
begin
|
|
form := 'devedor';
|
|
RLLabel7.Caption := RLLabel7.Caption + DateToStr(dtp_atrasorecalc.Date);
|
|
RLLabel7.left := floor(frbnd_dados.Width / 2) - floor(RLLabel7.Width / 2);
|
|
if cb_descquit.Checked then
|
|
begin
|
|
frlbl_tipodesc.Caption := 'Desconto concedido ao quitar.';
|
|
RLBand4.Visible := false;
|
|
if cb_nmulta.Checked then
|
|
begin
|
|
frlbl_descmulta.Caption := 'Desc. Multa: 100%';
|
|
end
|
|
else
|
|
begin
|
|
frlbl_descmulta.Caption := 'Desc. Multa: ' +
|
|
edt_multasquitar.Text + '%';
|
|
end;
|
|
frlbl_descind.Caption := 'Desc. Ind. Fin.: ' + edt_indquitar.Text + '%';
|
|
frlbl_descprin.Caption := 'Desc. Principal: ' +
|
|
edt_principalquitar.Text + '%';
|
|
frlbl_descjuros.Caption := 'Desc. Juros: ' + edt_jurosquitar.Text + '%';
|
|
if cb_desc_quit_cor.Checked then
|
|
begin
|
|
frlbl_desccorrigido.Caption := 'Desc. Corrigido: ' +
|
|
edt_corquitar.Text + '%';
|
|
end
|
|
else
|
|
begin
|
|
frlbl_desccorrigido.Caption := '';
|
|
end;
|
|
end;
|
|
if cb_descpar.Checked then
|
|
begin
|
|
frlbl_tipodesc.Caption := 'Desconto concedido ao parcelar.';
|
|
RLBand1.Visible := false;
|
|
RLBand2.Visible := false;
|
|
RLBand3.Visible := false;
|
|
if cb_nmulta.Checked then
|
|
begin
|
|
frlbl_descmulta.Caption := 'Desc. Multa: 100%';
|
|
end
|
|
else
|
|
begin
|
|
frlbl_descmulta.Caption := 'Desc. Multa: ' +
|
|
edt_multasparcelas.Text + '%';
|
|
end;
|
|
frlbl_descind.Caption := 'Desc. Ind. Fin.: ' +
|
|
edt_indparcelas.Text + '%';
|
|
frlbl_descprin.Caption := 'Desc. Principal: ' +
|
|
edt_principalparcelas.Text + '%';
|
|
frlbl_descjuros.Caption := 'Desc. Juros: ' +
|
|
edt_jurosparcelas.Text + '%';
|
|
if cb_desc_par_cor.Checked then
|
|
begin
|
|
frlbl_desccorrigido.Caption := 'Desc. Corrigido: ' +
|
|
edt_corpar.Text + '%';
|
|
end
|
|
else
|
|
begin
|
|
frlbl_desccorrigido.Caption := '';
|
|
end;
|
|
end;
|
|
if not(cb_descquit.Checked) and not(cb_descpar.Checked) then
|
|
begin
|
|
RLBand5.Visible := false;
|
|
frlbl_tipodesc.Caption := '';
|
|
end;
|
|
j := 0;
|
|
if Length(str_tit) = 0 then
|
|
begin
|
|
mnu_incluir.OnClick(self);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
setlength(lbl_parcelas, strtoint(copy(lbl_maxpar.Caption, 6,
|
|
Length(lbl_maxpar.Caption) - 5)));
|
|
for i := 0 to strtoint(copy(lbl_maxpar.Caption, 6,
|
|
Length(lbl_maxpar.Caption) - 5)) - 1 do
|
|
begin
|
|
edt_nrparcelas.Text := inttostr(i + 1);
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
lbl_parcelas[i] := TRLLabel.Create(relFichaDivida);
|
|
RLBand4.Height := 60 + (22 * (i div 4));
|
|
lbl_parcelas[i].Top := 44 + (22 * (i div 4));
|
|
lbl_parcelas[i].Caption := inttostr(i + 1) + 'x ' +
|
|
CurrToStrF(parcelamento[0], ffCurrency, 2, dtmSystem.CusFmt);
|
|
lbl_parcelas[i].Parent := RLBand4;
|
|
lbl_parcelas[i].left := j * 200;
|
|
Inc(j, 1);
|
|
if j = 4 then
|
|
begin
|
|
j := 0;
|
|
end;
|
|
|
|
end;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
frlbl_entrada.Caption := frlbl_entrada.Caption + edt_somaentrada.Text;
|
|
end
|
|
else
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_ENTRADA.AsString = 'PA' then
|
|
begin
|
|
frlbl_entrada.Caption := frlbl_entrada.Caption +
|
|
'Mesmo valor da parcela';
|
|
end
|
|
else
|
|
begin
|
|
frlbl_entrada.Caption := frlbl_entrada.Caption + edt_somaentrada.Text;
|
|
end;
|
|
end;
|
|
edt_nrparcelas.Text := inttostr(0);
|
|
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
RLReport1.Preview();
|
|
queryListaTitulos.Filtered := false;
|
|
mnuretirar.OnClick(self);
|
|
setlength(str_tit, 0);
|
|
end;
|
|
ficha_dev := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.CalcPrice;
|
|
var
|
|
valor, juros, parcela, par_extra: currency;
|
|
dividendo: double;
|
|
qtd: Integer;
|
|
begin
|
|
qtd := strtoint(edt_nrparcelas.Text);
|
|
if dtmSystem.tblPrCartao.Locate('NR_PARCELA', qtd, []) then
|
|
begin
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblPrCartaoPR_JUROS.AsFloat /
|
|
100), qtd))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) / qtd;
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end
|
|
else
|
|
begin
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PO' then
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblPrCartaoPR_JUROS.AsFloat /
|
|
100), qtd))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) / qtd;
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end
|
|
else
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100),
|
|
qtd + 1))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) / (qtd + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_PARCELA.AsCurrency := 0;
|
|
raise Exception.Create
|
|
('Não existe % de juros para quantidade de parcelas selecionada. Por favor contate o administrador.');
|
|
end;
|
|
|
|
{ if cbx_excentrada.Checked then
|
|
begin
|
|
case strtoint(edt_nrparcelas.Text) of
|
|
1:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat /
|
|
100), strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
2, 3:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED3.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED3.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
4, 5, 6:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED6.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED6.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
7, 8, 9, 10, 11, 12:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED12.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED12.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PO' then
|
|
begin
|
|
case strtoint(edt_nrparcelas.Text) of
|
|
1:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat /
|
|
100), strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
2, 3:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED3.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED3.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
4, 5, 6:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED6.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED6.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
7, 8, 9, 10, 11, 12:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED12.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED12.AsFloat /
|
|
100), strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
case strtoint(edt_nrparcelas.Text) of
|
|
1:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat /
|
|
100), strtoint(edt_nrparcelas.Text) + 1))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text) + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
|
|
end;
|
|
2, 3:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED3.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED3.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text) + 1))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text) + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
|
|
end;
|
|
4, 5, 6:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED6.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED6.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text) + 1))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text) + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
|
|
end;
|
|
7, 8, 9, 10, 11, 12:
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2);
|
|
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblEmpresaPR_CRED12.AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CRED12.AsFloat /
|
|
100), strtoint(edt_nrparcelas.Text) + 1))));
|
|
|
|
parcela := ((valor * juros) / dividendo);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text) + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end; }
|
|
|
|
end;
|
|
|
|
function TcadDevedores.CalculaIdade(Birthday, CurrentDate: TDate): Integer;
|
|
var
|
|
Month, Day, Year, CurrentYear, CurrentMonth, CurrentDay: Word;
|
|
begin
|
|
DecodeDate(Birthday, Year, Month, Day);
|
|
DecodeDate(CurrentDate, CurrentYear, CurrentMonth, CurrentDay);
|
|
if (Year = CurrentYear) and (Month = CurrentMonth) and (Day = CurrentDay) then
|
|
begin
|
|
Result := 0;
|
|
end
|
|
else
|
|
begin
|
|
Result := CurrentYear - Year;
|
|
if (Month > CurrentMonth) then
|
|
Dec(Result)
|
|
else
|
|
begin
|
|
if Month = CurrentMonth then
|
|
if (Day > CurrentDay) then
|
|
Dec(Result);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.CalcValorParcelas;
|
|
var
|
|
i, j, k, Y: Integer;
|
|
data_helper: TDate;
|
|
dia_antes, dia_depois, mes, ano: Word;
|
|
begin
|
|
// Cálculo do valor de cada parcela e seu respectivo vencimento
|
|
setlength(parcelamento, 0);
|
|
lv_parcelas.Clear;
|
|
if strtoint(edt_nrparcelas.Text) >= 1 then
|
|
begin
|
|
setlength(parcelamento, strtoint(edt_nrparcelas.Text));
|
|
// queryListaTitulos.DisableControls;
|
|
for i := 0 to lv_titulos.Items.Count - 1 do
|
|
begin
|
|
if lv_titulos.Items[i].Checked then
|
|
begin
|
|
queryListaTitulos.RecNo := i + 1;
|
|
for j := 0 to strtoint(edt_nrparcelas.Text) - 1 do
|
|
begin
|
|
parcelamento[j] := parcelamento[j] +
|
|
queryListaTitulosVL_PARCELA.AsCurrency;
|
|
end;
|
|
end;
|
|
end;
|
|
// queryListaTitulos.EnableControls;
|
|
lv_parcelas.Items.Add;
|
|
lv_parcelas.Items[0].Caption := 'Entrada';
|
|
{ if cb_nmulta.Checked then
|
|
begin
|
|
lv_parcelas.Items[0].SubItems.Add(CurrToStrF(valor_entrada, ffCurrency, 2,
|
|
dtmSystem.CusFmt));
|
|
end
|
|
else
|
|
begin }
|
|
lv_parcelas.Items[0].SubItems.Add(edt_somaentrada.Text);
|
|
// end;
|
|
|
|
for k := 0 to Length(parcelamento) - 1 do
|
|
begin
|
|
lv_parcelas.Items.Add;
|
|
lv_parcelas.Items[k + 1].Caption := 'Parcela nº ' + inttostr(k + 1);
|
|
lv_parcelas.Items[k + 1].SubItems.Add(CurrToStrF(parcelamento[k],
|
|
ffCurrency, 2, dtmSystem.CusFmt));
|
|
end;
|
|
setlength(data_parcelas, strtoint(edt_nrparcelas.Text) + 1);
|
|
data_helper := dtp_atrasorecalc.Date;
|
|
DecodeDate(dtp_atrasorecalc.Date, ano, mes, dia_antes);
|
|
for Y := 0 to strtoint(edt_nrparcelas.Text) do
|
|
begin
|
|
data_parcelas[Y] := data_helper;
|
|
data_helper := IncMonth(data_helper);
|
|
DecodeDate(data_helper, ano, mes, dia_depois);
|
|
if (mes = 3) and (dia_antes = 29) and (dia_depois = 28) then
|
|
begin
|
|
data_helper := IncDay(data_helper);
|
|
end;
|
|
if (mes = 3) and (dia_antes = 30) and (dia_depois = 28) then
|
|
begin
|
|
data_helper := IncDay(data_helper, 2);
|
|
end;
|
|
if (mes = 3) and (dia_antes = 31) and (dia_depois = 28) then
|
|
begin
|
|
data_helper := IncDay(data_helper, 3);
|
|
end;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
lv_parcelas.Clear;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.cbx_excentradaClick(Sender: TObject);
|
|
begin
|
|
edt_excentrada.Enabled := cbx_excentrada.Enabled;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.cbx_exjurosparcelarClick(Sender: TObject);
|
|
begin
|
|
edt_excjurosparcela.Enabled := cbx_exjurosparcelar.Enabled;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.cbx_txextraClick(Sender: TObject);
|
|
begin
|
|
edt_txextra.Enabled := cbx_txextra.Checked;
|
|
if not cbx_txextra.Checked then
|
|
begin
|
|
edt_txextra.Text := '0,00';
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_agendahistClick(Sender: TObject);
|
|
begin
|
|
dtp_agendadatahist.Enabled := cb_agendahist.Checked;
|
|
dtp_agendahorahist.Enabled := cb_agendahist.Checked;
|
|
dblucb_agendacobhist.Enabled := cb_agendahist.Checked;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_agendarClick(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
dtp_diaagendamento.Enabled := cb_agendar.Checked;
|
|
dtp_horaagendamento.Enabled := cb_agendar.Checked;
|
|
dblucb_cobradoragendar.Enabled := cb_agendar.Checked;
|
|
if cb_agendar.Checked then
|
|
begin
|
|
mb_fechamento.lines.Add
|
|
('Foi agendado para o dia __/__/____ para o cobrador __________ no horário de atendimento __:__.');
|
|
for i := 0 to mb_fechamento.lines.Count - 1 do
|
|
if AnsiContainsStr(mb_fechamento.lines[i], 'Foi agendado para o dia') then
|
|
begin
|
|
mb_fechamento.lines[i] := StringReplace(mb_fechamento.lines[i],
|
|
dia_agendado, FormatDateTime('dd/mm/yyyy', dtp_diaagendamento.Date),
|
|
[rfReplaceAll, rfIgnoreCase]);
|
|
end;
|
|
dia_agendado := FormatDateTime('dd/mm/yyyy', dtp_diaagendamento.Date);
|
|
for i := 0 to mb_fechamento.lines.Count - 1 do
|
|
if AnsiContainsStr(mb_fechamento.lines[i], hora_agendado) then
|
|
begin
|
|
mb_fechamento.lines[i] := StringReplace(mb_fechamento.lines[i],
|
|
hora_agendado, FormatDateTime('t', dtp_horaagendamento.Date),
|
|
[rfReplaceAll, rfIgnoreCase]);
|
|
end;
|
|
hora_agendado := FormatDateTime('t', dtp_horaagendamento.Date);
|
|
end
|
|
else
|
|
begin
|
|
for i := 0 to mb_fechamento.lines.Count - 1 do
|
|
if AnsiContainsStr(mb_fechamento.lines[i], 'Foi agendado para o dia') then
|
|
begin
|
|
dia_agendado := '__/__/____';
|
|
hora_agendado := '__:__';
|
|
nome_cobrador := '__________';
|
|
mb_fechamento.lines.Delete(i);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_descparClick(Sender: TObject);
|
|
begin
|
|
if cb_descpar.Checked then
|
|
begin
|
|
cb_descquit.Checked := false;
|
|
gb_descontospar.Enabled := True;
|
|
gb_descontosquit.Enabled := false;
|
|
cb_desc_quit_cor.Checked := false;
|
|
end
|
|
else
|
|
begin
|
|
gb_descontospar.Enabled := false;
|
|
end;
|
|
if not gb_descontospar.Enabled then
|
|
begin
|
|
edt_indparcelas.Text := '0';
|
|
edt_principalparcelas.Text := '0';
|
|
edt_multasparcelas.Text := '0';
|
|
edt_jurosparcelas.Text := '0';
|
|
edt_corpar.Text := '0';
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_descquitClick(Sender: TObject);
|
|
begin
|
|
if cb_descquit.Checked then
|
|
begin
|
|
cb_descpar.Checked := false;
|
|
gb_descontosquit.Enabled := True;
|
|
gb_descontospar.Enabled := false;
|
|
edt_nrparcelas.Text := '0';
|
|
cb_desc_par_cor.Checked := false;
|
|
end
|
|
else
|
|
begin
|
|
gb_descontosquit.Enabled := false;
|
|
end;
|
|
|
|
if not gb_descontosquit.Enabled then
|
|
begin
|
|
edt_indquitar.Text := '0';
|
|
edt_principalquitar.Text := '0';
|
|
edt_multasquitar.Text := '0';
|
|
edt_jurosquitar.Text := '0';
|
|
edt_corquitar.Text := '0';
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_desc_par_corClick(Sender: TObject);
|
|
begin
|
|
if cb_desc_par_cor.Checked then
|
|
begin
|
|
edt_indparcelas.Text := '0';
|
|
edt_principalparcelas.Text := '0';
|
|
edt_multasparcelas.Text := '0';
|
|
edt_jurosparcelas.Text := '0';
|
|
edt_corquitar.Text := '0';
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_desc_quit_corClick(Sender: TObject);
|
|
begin
|
|
if cb_descquit.Checked then
|
|
begin
|
|
edt_indquitar.Text := '0';
|
|
edt_principalquitar.Text := '0';
|
|
edt_multasquitar.Text := '0';
|
|
edt_jurosquitar.Text := '0';
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_formapagChange(Sender: TObject);
|
|
begin
|
|
{ if { (cb_formapag.ItemIndex = 0) or (cb_formapag.ItemIndex = 1) then
|
|
begin
|
|
edt_nrparcelas.Text := '0';
|
|
// edt_nrparcelas.OnChange;
|
|
end; }
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_negritomemoClick(Sender: TObject);
|
|
begin
|
|
if cb_negritomemo.Checked then
|
|
begin
|
|
mb_fechamento.Font.Style := mb_fechamento.Font.Style + [fsbold];
|
|
end
|
|
else
|
|
begin
|
|
mb_fechamento.Font.Style := mb_fechamento.Font.Style - [fsbold];
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.cb_nmultaClick(Sender: TObject);
|
|
begin
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.ChecaPermissoes;
|
|
begin
|
|
with dtmSystem do
|
|
begin
|
|
// if perm_caddev then
|
|
// begin
|
|
navPrincipal.Enabled := VerificarPermissao('CBR.02.01.01.01');
|
|
|
|
if VerificarPermissao('CBR.02.01.01.01.01') then
|
|
begin
|
|
navPrincipal.VisibleButtons := navPrincipal.VisibleButtons + [nbDelete];
|
|
end
|
|
else
|
|
begin
|
|
navPrincipal.VisibleButtons := navPrincipal.VisibleButtons - [nbDelete];
|
|
end;
|
|
|
|
navEmail.Enabled := VerificarPermissao('CBR.02.01.01.06');
|
|
if not VerificarPermissao('CBR.02.01.01.06.01') then
|
|
navEmail.VisibleButtons := navEmail.VisibleButtons - [nbInsert];
|
|
if not VerificarPermissao('CBR.02.01.01.06.02') then
|
|
navEmail.VisibleButtons := navEmail.VisibleButtons - [nbEdit];
|
|
if not VerificarPermissao('CBR.02.01.01.06.03') then
|
|
navEmail.VisibleButtons := navEmail.VisibleButtons - [nbDelete];
|
|
|
|
navenderecos.Enabled := VerificarPermissao('CBR.02.01.01.02');
|
|
if not VerificarPermissao('CBR.02.01.01.02.01') then
|
|
navenderecos.VisibleButtons := navenderecos.VisibleButtons - [nbInsert];
|
|
if not VerificarPermissao('CBR.02.01.01.02.02') then
|
|
navenderecos.VisibleButtons := navenderecos.VisibleButtons - [nbEdit];
|
|
if not VerificarPermissao('CBR.02.01.01.02.03') then
|
|
navenderecos.VisibleButtons := navenderecos.VisibleButtons - [nbDelete];
|
|
|
|
navtelefones.Enabled := VerificarPermissao('CBR.02.01.01.03');
|
|
if not VerificarPermissao('CBR.02.01.01.03.01') then
|
|
navtelefones.VisibleButtons := navtelefones.VisibleButtons - [nbInsert];
|
|
if not VerificarPermissao('CBR.02.01.01.03.02') then
|
|
navtelefones.VisibleButtons := navtelefones.VisibleButtons - [nbEdit];
|
|
if not VerificarPermissao('CBR.02.01.01.03.03') then
|
|
navtelefones.VisibleButtons := navtelefones.VisibleButtons - [nbDelete];
|
|
|
|
navtitulos.Enabled := VerificarPermissao('CBR.02.01.01.04');
|
|
if not VerificarPermissao('CBR.02.01.01.04.01') then
|
|
navtitulos.VisibleButtons := navtitulos.VisibleButtons - [nbInsert];
|
|
if not VerificarPermissao('CBR.02.01.01.04.02') then
|
|
navtitulos.VisibleButtons := navtitulos.VisibleButtons - [nbEdit];
|
|
if not VerificarPermissao('CBR.02.01.01.04.03') then
|
|
navtitulos.VisibleButtons := navtitulos.VisibleButtons - [nbDelete];
|
|
|
|
navHistorico.Enabled := VerificarPermissao('CBR.02.01.01.05');
|
|
if not VerificarPermissao('CBR.02.01.01.05.01') then
|
|
navHistorico.VisibleButtons := navHistorico.VisibleButtons - [nbInsert];
|
|
if not VerificarPermissao('CBR.02.01.01.05.02') then
|
|
navHistorico.VisibleButtons := navHistorico.VisibleButtons - [nbEdit];
|
|
if not VerificarPermissao('CBR.02.01.01.05.03') then
|
|
navHistorico.VisibleButtons := navHistorico.VisibleButtons - [nbDelete];
|
|
|
|
tabQuitar.Enabled := VerificarPermissao('CBR.02.01.02.01.01');
|
|
tabParcelar.Enabled := VerificarPermissao('CBR.02.01.02.01.02');
|
|
cb_nmulta.Enabled := VerificarPermissao('CBR.02.01.02.02');
|
|
cbx_txextra.Enabled := VerificarPermissao('CBR.02.01.02.03');
|
|
cbx_excentrada.Enabled := VerificarPermissao('CBR.02.01.02.04');
|
|
perm_caddev := false;
|
|
// end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.clb_beneficiarioscalculoClickCheck(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
n_marcou: Boolean;
|
|
begin
|
|
// sempre só poder ter uma empresa marcada e cria a lista de títulos dela que o devedor tem
|
|
n_marcou := True;
|
|
with TCheckListBox(Sender) do
|
|
begin
|
|
if Checked[ItemIndex] then
|
|
begin
|
|
n_marcou := false;
|
|
Items.beginupdate;
|
|
id_emp_calc := ItemIndex;
|
|
for i := 0 to Items.Count - 1 do
|
|
if i = ItemIndex then
|
|
begin
|
|
continue;
|
|
end
|
|
else
|
|
begin
|
|
Checked[i] := false;
|
|
end;
|
|
Items.EndUpdate;
|
|
// lv_titulos.PopupMenu := popmnu_incluir;
|
|
end
|
|
else
|
|
begin
|
|
for i := 0 to Items.Count - 1 do
|
|
if Checked[i] = True then
|
|
begin
|
|
n_marcou := false;
|
|
id_emp_calc := i;
|
|
end;
|
|
// lv_titulos.PopupMenu := nil;
|
|
end;
|
|
end;
|
|
if n_marcou then
|
|
begin
|
|
lv_titulos.Clear;
|
|
id_emp_calc := -1;
|
|
setlength(ids_tits_calc, 0);
|
|
end
|
|
else
|
|
begin
|
|
CriarLista;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.clb_empresasClickCheck(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
// if clb_empresas.Checked[clb_empresas.ItemIndex] then
|
|
// begin
|
|
// clb_empresas.Items.beginupdate;
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// if i = clb_empresas.ItemIndex then
|
|
// begin
|
|
// dtmSystem.tblCHGEmpresa.Locate('TX_NOME', clb_empresas.Items[i], []);
|
|
// // clb_empresas.Selected[i] := True;
|
|
// selected_id_chg_empresa := dtmSystem.tblCHGEmpresaID_EMPRESA.AsInteger;
|
|
// continue;
|
|
// end
|
|
// else
|
|
// begin
|
|
// clb_empresas.Checked[i] := false;
|
|
// // clb_empresas.Selected[i] := false;
|
|
// end;
|
|
// end;
|
|
// clb_empresas.Items.EndUpdate;
|
|
// end;
|
|
end;
|
|
|
|
procedure TcadDevedores.clb_empresasMouseMove(Sender: TObject;
|
|
Shift: TShiftState; X, Y: Integer);
|
|
// var
|
|
// index: integer;
|
|
begin
|
|
// pega as hints na array de hints e mostra a do item que o mouse está em cima
|
|
{ index := clb_empresas.ItemAtPos(point(X, Y), true);
|
|
if index <> -1 then
|
|
begin
|
|
clb_empresas.Hint := cbl_hints[index];
|
|
end
|
|
else
|
|
begin
|
|
clb_empresas.Hint := '';
|
|
end;
|
|
if index <> prevIndex then
|
|
begin
|
|
Application.CancelHint;
|
|
end;
|
|
prevIndex := index; }
|
|
end;
|
|
|
|
procedure TcadDevedores.Copiar1Click(Sender: TObject);
|
|
var
|
|
Control: TControl;
|
|
begin
|
|
// usa duas funções que achei na net pra pegar o controle na pos do mouse pra poder copiar o conteúdo dele mesmo desabilitado
|
|
Control := FindControlAtPos(posi);
|
|
if Control is TDBEdit then
|
|
begin
|
|
Clipboard.AsText := (Control as TDBEdit).Text;
|
|
end;
|
|
if Control is TDBLookupComboBox then
|
|
begin
|
|
Clipboard.AsText := (Control as TDBLookupComboBox).Text;
|
|
end;
|
|
if Control is TrDBDateTimePicker then
|
|
begin
|
|
Clipboard.AsText := FormatDateTime('dd/mm/yyyy',
|
|
(Control as TrDBDateTimePicker).Date);
|
|
end;
|
|
if Control is TDBMemo then
|
|
begin
|
|
(Control as TDBMemo).SelectAll;
|
|
(Control as TDBMemo).CopyToClipboard;
|
|
end;
|
|
if Control is TListView then
|
|
begin
|
|
if Control.Name = 'lv_parcelas' then
|
|
begin
|
|
copiar_conteudoClick(Copiar1);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.copiar_conteudoClick(Sender: TObject);
|
|
var
|
|
nomes, valores: array of string;
|
|
spaces: string;
|
|
i, j, tam, Count: Integer;
|
|
k: Integer;
|
|
begin
|
|
clpbrd := '';
|
|
// copia o conteúdo do listview que contém os dados de parcelamento
|
|
if lv_parcelas.Items.Count > 0 then
|
|
begin
|
|
setlength(nomes, lv_parcelas.Items.Count);
|
|
setlength(valores, lv_parcelas.Items.Count);
|
|
for i := 0 to lv_parcelas.Items.Count - 1 do
|
|
begin
|
|
nomes[i] := lv_parcelas.Items.Item[i].Caption + ':';
|
|
valores[i] := lv_parcelas.Items.Item[i].SubItems[0];
|
|
end;
|
|
end;
|
|
|
|
for j := 0 to lv_parcelas.Items.Count - 1 do
|
|
begin
|
|
tam := Length(nomes[j]) + Length(valores[j]);
|
|
Count := 32 - tam;
|
|
spaces := '';
|
|
for k := 0 to Count - 1 do
|
|
begin
|
|
spaces := spaces + ' ';
|
|
end;
|
|
if j = 0 then
|
|
begin
|
|
clpbrd := clpbrd + nomes[j] + spaces + valores[j] +
|
|
' para ser pago até dia: ' + FormatDateTime('dd/mm/yyyy',
|
|
data_parcelas[0]) + sLineBreak;
|
|
end
|
|
else
|
|
begin
|
|
if copy(valores[0], 4, Length(valores[0]) - 3) = '0,00' then
|
|
begin
|
|
clpbrd := clpbrd + nomes[j] + spaces + valores[j] +
|
|
' para ser pago até dia: ' + FormatDateTime('dd/mm/yyyy',
|
|
data_parcelas[j - 1]) + sLineBreak;
|
|
end
|
|
else
|
|
begin
|
|
clpbrd := clpbrd + nomes[j] + spaces + valores[j] +
|
|
' para ser pago até dia: ' + FormatDateTime('dd/mm/yyyy',
|
|
data_parcelas[j { - 1 } ]) + sLineBreak;
|
|
end;
|
|
end;
|
|
end;
|
|
if Sender is TMenuItem then
|
|
begin
|
|
Clipboard.AsText := clpbrd;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.cp_telClick(Sender: TObject);
|
|
begin
|
|
Clipboard.AsText := dbedt_tel.Text;
|
|
end;
|
|
|
|
procedure TcadDevedores.cp_teldddClick(Sender: TObject);
|
|
begin
|
|
Clipboard.AsText := dbedt_ddd.Text + ' ' + dbedt_tel.Text;
|
|
end;
|
|
|
|
procedure TcadDevedores.CriarLista;
|
|
var
|
|
h: Integer;
|
|
nMaxWidth: Integer;
|
|
i: Integer;
|
|
nItemWidth: Integer;
|
|
marcou: Boolean;
|
|
begin
|
|
{ if queryListaTitulos.Connection = nil then
|
|
// BACALHAU, NÃO TEM EXPLICAÇÃO. SÓ FUNCIONA.
|
|
begin
|
|
exit;
|
|
end; }
|
|
// qtde_titulos := 0;
|
|
dtmSystem.tblCHGEmpresa.Open;
|
|
marcou := false;
|
|
// clb_beneficiarioscalculo.Clear;
|
|
for h := 0 to clb_beneficiarioscalculo.Items.Count - 1 do
|
|
begin
|
|
if clb_beneficiarioscalculo.Checked[h] then
|
|
begin
|
|
dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA', id_emps_dev[h], []);
|
|
marcou := True;
|
|
end;
|
|
end;
|
|
nMaxWidth := clb_beneficiarioscalculo.ClientWidth;
|
|
for i := 0 to clb_beneficiarioscalculo.Items.Count - 1 do
|
|
begin
|
|
nItemWidth := clb_beneficiarioscalculo.Canvas.TextWidth
|
|
(clb_beneficiarioscalculo.Items[i]) + 20;
|
|
if (nItemWidth > nMaxWidth) then
|
|
nMaxWidth := nItemWidth;
|
|
end;
|
|
if (nMaxWidth > clb_beneficiarioscalculo.ClientWidth) then
|
|
begin
|
|
clb_beneficiarioscalculo.ScrollWidth := nMaxWidth;
|
|
end;
|
|
|
|
if marcou then
|
|
begin
|
|
queryListaTitulos.SQL.Clear;
|
|
queryListaTitulos.SQL.Text :=
|
|
'select * from (select * from chg_titulos where id_devedor = ' +
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString +
|
|
') where (tp_situacao = ''A'' or tp_situacao = ''AC'') and' +
|
|
'(id_empresa = ' + dtmSystem.tblCHGEmpresaID_EMPRESA.AsString + ')' +
|
|
' order by DT_VENCIMENTO, VL_TITULO';
|
|
queryListaTitulos.Open;
|
|
queryListaTitulos.First;
|
|
|
|
lv_titulos.Clear;
|
|
// queryListaTitulos.DisableControls;
|
|
while not queryListaTitulos.Eof do
|
|
begin
|
|
dtmSystem.tblFaixas.Filter := '(DT_INICIO < ' +
|
|
queryListaTitulosDT_ATRASO.AsString + ')and(DT_FINAL > ' +
|
|
queryListaTitulosDT_ATRASO.AsString + ')';
|
|
dtmSystem.tblFaixas.Filtered := True;
|
|
dtmSystem.tblFaixas.Open;
|
|
dtmSystem.tblPoliticas.Open;
|
|
dtmSystem.tblPoliticas.Locate('ID_POLITICA',
|
|
dtmSystem.tblFaixasID_POLITICA.AsString, []);
|
|
with lv_titulos.Items.Add do
|
|
begin
|
|
SubItems.Add(queryListaTitulos.FieldByName('NOME_EMPRESA').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('TX_PRODUTO').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('DT_VENCIMENTO').AsString);
|
|
SubItems.Add(CurrToStrF(queryListaTitulos.FieldByName('VL_TITULO')
|
|
.AsCurrency, ffCurrency, 2, dtmSystem.CusFmt));
|
|
SubItems.Add(queryListaTitulos.FieldByName('CD_DEVEDOR').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('NR_PARCELAS').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('DT_ENTRADA').AsString);
|
|
end;
|
|
lv_titulos.Column[0].Alignment := TAlignment.taCenter;
|
|
dtmSystem.tblFaixas.Filtered := false;
|
|
queryListaTitulos.Next;
|
|
end;
|
|
end;
|
|
|
|
// queryListaTitulos.First;
|
|
// queryListaTitulos.EnableControls;
|
|
edt_nrparcelas.Text := '0';
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.ACBrCEP1BuscaEfetuada(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
|
|
// resultado da busca de CEP
|
|
for i := 0 to ACBrCEP1.Enderecos.Count - 1 do
|
|
begin
|
|
dbedt_logradouro.Text := ACBrCEP1.Enderecos[i].Tipo_Logradouro + ' ' +
|
|
ACBrCEP1.Enderecos[i].Logradouro;
|
|
dbedt_comp.Text := ACBrCEP1.Enderecos[i].Complemento;
|
|
dbedt_bairro.Text := ACBrCEP1.Enderecos[i].Bairro;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbcbx_tpchequeClick(Sender: TObject);
|
|
begin
|
|
pnl_cheque.Enabled := dbcbx_tpcheque.Checked;
|
|
end;
|
|
|
|
procedure TcadDevedores.DBEdit10KeyPress(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 TcadDevedores.DBEdit11KeyPress(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 TcadDevedores.DBEdit12KeyPress(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 TcadDevedores.DBEdit13KeyPress(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 TcadDevedores.DBEdit17KeyPress(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 TcadDevedores.DBEdit18KeyPress(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 TcadDevedores.DBEdit19KeyPress(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 TcadDevedores.DBEdit20KeyPress(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 TcadDevedores.DBEdit21KeyPress(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 TcadDevedores.DBEdit22KeyPress(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 TcadDevedores.DBEdit23KeyPress(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 TcadDevedores.DBEdit5KeyPress(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 TcadDevedores.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 TcadDevedores.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 TcadDevedores.DBEdit9KeyPress(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 TcadDevedores.dbedt_cepKeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
|
|
// faz a busca por CEP de pressionar enter no edit de CEP
|
|
if (Key = #13) then
|
|
begin
|
|
ACBrCEP1.BuscarPorCEP(dbedt_cep.Text);
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbedt_cpfcnpjKeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
inherited;
|
|
if dtmSystem.tblDevedoresTP_CLIENTE.AsString = '' then
|
|
begin
|
|
MessageDlg('Por favor escolha o tipo de devedor.', mtWarning, [mbOK], 0);
|
|
Key := #0;
|
|
end;
|
|
if (dtmSystem.tblDevedoresTP_CLIENTE.AsString = 'F') then
|
|
begin
|
|
if not(Key in [#8, '0' .. '9', '.', '-']) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
if (dtmSystem.tblDevedoresTP_CLIENTE.AsString = 'J') then
|
|
begin
|
|
if not(Key in [#8, '0' .. '9', '.', '-', '/']) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_enderecosDrawColumnCell(Sender: TObject;
|
|
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
begin
|
|
case AnsiIndexStr(dtmSystem.tblEnderecos.FieldByName('TP_ATIVO').AsString,
|
|
['S', 'N']) of
|
|
0:
|
|
dbgrd_enderecos.Canvas.Brush.Color := clGreen;
|
|
1:
|
|
dbgrd_enderecos.Canvas.Brush.Color := $0000FF;
|
|
end;
|
|
// end;
|
|
dbgrd_enderecos.DefaultDrawColumnCell(Rect, DataCol, Column, State);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_enderecosTitleClick(Column: TColumn);
|
|
begin
|
|
dtmSystem.OrganizaPorColuna(dtmSystem.tblEnderecos, Column);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_historicoDblClick(Sender: TObject);
|
|
begin
|
|
// if dbgrd_historico.SelectedIndex = 2 then
|
|
// begin
|
|
// with TfrmMemoBox.Create(self) do
|
|
// begin
|
|
// Show;
|
|
// end;
|
|
// end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_historicoTitleClick(Column: TColumn);
|
|
begin
|
|
dtmSystem.OrganizaPorColuna(dtmSystem.tblHistorico, Column);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_listtitulosTitleClick(Column: TColumn);
|
|
begin
|
|
dtmSystem.OrganizaPorColuna(queryListaTitulos, Column);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_providenciasDblClick(Sender: TObject);
|
|
var
|
|
pt: TPoint;
|
|
coord: TGridCoord;
|
|
clickheader: Integer;
|
|
begin
|
|
pt := dbgrd_providencias.ScreenToClient(Mouse.CursorPos);
|
|
coord := dbgrd_providencias.MouseCoord(pt.X, pt.Y);
|
|
clickheader := coord.Y;
|
|
if clickheader > 0 then
|
|
begin
|
|
if LeftStr(mb_fechamento.lines[mb_fechamento.lines.Count - 1], 3) = 'Pro'
|
|
then
|
|
begin
|
|
mb_fechamento.lines[mb_fechamento.lines.Count - 1] :=
|
|
'Providência tomada: ' + dtmSystem.tblProvidenciasTX_NOME.
|
|
AsString + '.';
|
|
end
|
|
else
|
|
begin
|
|
mb_fechamento.lines.Add('Providência tomada: ' +
|
|
dtmSystem.tblProvidenciasTX_NOME.AsString + '.');
|
|
end;
|
|
edt_prov.Text := dtmSystem.tblProvidenciasTX_NOME.AsString;
|
|
// if dtmSystem.tblProvidenciasID_PROVIDENCIA.AsInteger = 1 then
|
|
// begin
|
|
// dtp_diaagendamento.Enabled := true;
|
|
// dtp_horaagendamento.Enabled := true;
|
|
// dblucb_cobradoragendar.Enabled := true;
|
|
// end
|
|
// else
|
|
// begin
|
|
// dtp_diaagendamento.Enabled := false;
|
|
// dtp_horaagendamento.Enabled := false;
|
|
// dblucb_cobradoragendar.Enabled := false;
|
|
// end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_resumohistTitleClick(Column: TColumn);
|
|
begin
|
|
dtmSystem.OrganizaPorColuna(dtmSystem.tblHistorico, Column);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_telDrawColumnCell(Sender: TObject;
|
|
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
begin
|
|
case AnsiIndexStr(dtmSystem.tblTelefones.FieldByName('TP_ATIVO').AsString,
|
|
['S', 'N']) of
|
|
0:
|
|
dbgrd_tel.Canvas.Brush.Color := clGreen;
|
|
1:
|
|
dbgrd_tel.Canvas.Brush.Color := $0000FF;
|
|
end;
|
|
// end;
|
|
dbgrd_tel.DefaultDrawColumnCell(Rect, DataCol, Column, State);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_telTitleClick(Column: TColumn);
|
|
begin
|
|
dtmSystem.OrganizaPorColuna(dtmSystem.tblTelefones, Column);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_titCellClick(Column: TColumn);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// dtmSystem.tblCHGEmpresa.Locate('TX_NOME', clb_empresas.Items[i], []);
|
|
// if dtmSystem.tblTitulosID_EMPRESA.AsString = dtmSystem.
|
|
// tblCHGEmpresaID_EMPRESA.AsString then
|
|
// begin
|
|
// clb_empresas.Checked[i] := True;
|
|
// // clb_empresas.Selected[i] := True;
|
|
// end
|
|
// else
|
|
// begin
|
|
// clb_empresas.Checked[i] := false;
|
|
// // clb_empresas.Selected[i] := false;
|
|
// end;
|
|
// end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_titDrawColumnCell(Sender: TObject;
|
|
const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
|
|
begin
|
|
|
|
case AnsiIndexStr(dtmSystem.tblTitulos.FieldByName('TP_SITUACAO').AsString,
|
|
['A', 'AC', 'AB', 'AJ', 'B', 'QC', 'QB']) of
|
|
0:
|
|
dbgrd_tit.Canvas.Brush.Color := clWhite;
|
|
1:
|
|
dbgrd_tit.Canvas.Brush.Color := $0000D7FF;
|
|
2:
|
|
dbgrd_tit.Canvas.Brush.Color := $002FFFAD;
|
|
3:
|
|
dbgrd_tit.Canvas.Brush.Color := clMoneyGreen;
|
|
4:
|
|
dbgrd_tit.Canvas.Brush.Color := clRed;
|
|
5:
|
|
dbgrd_tit.Canvas.Brush.Color := $00EBCE87;
|
|
6:
|
|
dbgrd_tit.Canvas.Brush.Color := $00E16941;
|
|
end;
|
|
// end;
|
|
dbgrd_tit.DefaultDrawColumnCell(Rect, DataCol, Column, State);
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_titMouseMove(Sender: TObject; Shift: TShiftState;
|
|
X, Y: Integer);
|
|
var
|
|
Cell: TGridCoord;
|
|
begin
|
|
|
|
Cell := dbgrd_tit.MouseCoord(X, Y);
|
|
// if cell.Y > 0 then
|
|
// begin
|
|
// dbgrd_tit.Hint := 'AAAAAAA';
|
|
// end else
|
|
// begin
|
|
// dbgrd_tit.Hint := '';
|
|
// end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbgrd_titTitleClick(Column: TColumn);
|
|
begin
|
|
inherited;
|
|
dtmSystem.OrganizaPorColuna(dtmSystem.tblTitulos, Column);
|
|
end;
|
|
|
|
procedure TcadDevedores.DBNavigator1BeforeAction(Sender: TObject; Button: TNavigateBtn);
|
|
begin
|
|
inherited;
|
|
if Button = nbPost then
|
|
begin
|
|
dtmSystem.tblDevEmpBoletosID_DEVEDOR.AsInteger := dtmSystem.id_devedor;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dbrg_tipotelClick(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if dbrg_tipotel.ItemIndex = 1 then
|
|
begin
|
|
DBRadioGroup1.Enabled := True;
|
|
end
|
|
else
|
|
begin
|
|
DBRadioGroup1.Enabled := false;
|
|
DBRadioGroup1.ItemIndex := -1;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtp_atrasorecalcChange(Sender: TObject);
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtp_diaagendamentoChange(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
if pcClientes.ActivePageIndex = 6 then
|
|
begin
|
|
for i := 0 to mb_fechamento.lines.Count - 1 do
|
|
if AnsiContainsStr(mb_fechamento.lines[i], 'Foi agendado para o dia') then
|
|
begin
|
|
mb_fechamento.lines[i] := StringReplace(mb_fechamento.lines[i],
|
|
dia_agendado, FormatDateTime('dd/mm/yyyy', dtp_diaagendamento.Date),
|
|
[rfReplaceAll, rfIgnoreCase]);
|
|
end;
|
|
dia_agendado := FormatDateTime('dd/mm/yyyy', dtp_diaagendamento.Date);
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtp_horaagendamentoChange(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
if pcClientes.ActivePageIndex = 6 then
|
|
begin
|
|
for i := 0 to mb_fechamento.lines.Count - 1 do
|
|
if AnsiContainsStr(mb_fechamento.lines[i], hora_agendado) then
|
|
begin
|
|
mb_fechamento.lines[i] := StringReplace(mb_fechamento.lines[i],
|
|
hora_agendado, FormatDateTime('t', dtp_horaagendamento.Date),
|
|
[rfReplaceAll, rfIgnoreCase]);
|
|
end;
|
|
hora_agendado := FormatDateTime('t', dtp_horaagendamento.Date);
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsCidadesDataChange(Sender: TObject; Field: TField);
|
|
begin
|
|
if (dtmSystem.tblEnderecosID_CIDADE.AsVariant >= 0) then
|
|
begin
|
|
dblucmbox_cidade.keyvalue := dtmSystem.tblEnderecosID_CIDADE.AsVariant;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsCobradorDataChange(Sender: TObject; Field: TField);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
if pcClientes.ActivePageIndex = 6 then
|
|
begin
|
|
for i := 0 to mb_fechamento.lines.Count - 1 do
|
|
if AnsiContainsStr(mb_fechamento.lines[i], 'para o cobrador') then
|
|
begin
|
|
mb_fechamento.lines[i] := StringReplace(mb_fechamento.lines[i],
|
|
nome_cobrador, queryCobradoresTX_NOME.AsString,
|
|
[rfReplaceAll, rfIgnoreCase]);
|
|
nome_cobrador := queryCobradoresTX_NOME.AsString;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsDBDataChange(Sender: TObject; Field: TField);
|
|
var
|
|
new_id: Integer;
|
|
i: Integer;
|
|
begin
|
|
// seta que valor vai ser mostrado no edit
|
|
with dtmSystem do
|
|
begin
|
|
if tblDevedoresTP_CLIENTE.AsString = 'F' then
|
|
begin
|
|
dbedt_cpfcnpj.DataField := 'CD_CPF';
|
|
end;
|
|
if tblDevedoresTP_CLIENTE.AsString = 'J' then
|
|
begin
|
|
dbedt_cpfcnpj.DataField := 'CD_CNPJ';
|
|
end;
|
|
end;
|
|
|
|
// stbStatus.Panels[0].Text := 'Entradas: ' +
|
|
// inttostr(dtsDB.DataSet.RecordCount) + '.';
|
|
|
|
if dtmSystem.tblDevedoresDT_NASC.AsString <> '' then
|
|
begin
|
|
lbl_idade.Caption := 'Idade: ' +
|
|
inttostr(CalculaIdade(dtmSystem.tblDevedoresDT_NASC.AsDateTime, Date));
|
|
end
|
|
else
|
|
begin
|
|
lbl_idade.Caption := 'Idade: ';
|
|
end;
|
|
|
|
new_id := dtmSystem.tblDevedoresID_DEVEDOR.AsInteger;
|
|
if (old_id <> new_id) and ((self.Active) or (importou)) and
|
|
not(dtsDB.State in [dsInsert]) then
|
|
begin
|
|
id_emp_calc := -1;
|
|
for i := 0 to Length(ids_tits_calc) - 1 do
|
|
begin
|
|
ids_tits_calc[i] := false;
|
|
end;
|
|
btn_protocolo.Enabled := True;
|
|
edt_protocolo.Text := '';
|
|
edt_protocolo1.Text := '';
|
|
// cb_agendahist.Checked := false;
|
|
dtp_agendadatahist.Enabled := false;
|
|
// dtp_agendadatahist.Date := Date;
|
|
dtp_agendahorahist.Enabled := false;
|
|
// dtp_agendahorahist.Time := Timeof(Now);
|
|
dblucb_agendacobhist.Enabled := false;
|
|
cb_agendar.Checked := false;
|
|
importou := false;
|
|
dia_agendado := '__/__/____';
|
|
hora_agendado := '__:__';
|
|
nome_cobrador := '__________';
|
|
old_id := new_id;
|
|
if qryConsulta.Connection = nil then
|
|
// BACALHAU, NÃO TEM EXPLICAÇÃO. SÓ FUNCIONA.
|
|
begin
|
|
exit;
|
|
end;
|
|
old_id_tit := -1;
|
|
clb_beneficiarioscalculo.Clear;
|
|
|
|
if (dtmSystem.tblDevedores.RecordCount > 0) and
|
|
(not(dtsDB.State in [dsInsert])) then
|
|
begin
|
|
qryConsulta.SQL.Clear;
|
|
qryConsulta.SQL.Text := 'select * from chg_empresas where id_empresa in '
|
|
+ '(select id_empresa from chg_titulos' +
|
|
' where (tp_situacao = ''A'' or tp_situacao = ''AC'') and (id_devedor = '
|
|
+ dtmSystem.tblDevedoresID_DEVEDOR.AsString + '))';
|
|
|
|
if not(qryConsulta.Active) then
|
|
begin
|
|
qryConsulta.Open;
|
|
end;
|
|
qryConsulta.First;
|
|
setlength(id_emps_dev, qryConsulta.RecordCount);
|
|
while not qryConsulta.Eof do
|
|
begin
|
|
clb_beneficiarioscalculo.Items.Add(qryConsulta.FieldByName('TX_NOME')
|
|
.AsString);
|
|
id_emps_dev[qryConsulta.RecNo - 1] :=
|
|
qryConsulta.FieldByName('ID_EMPRESA').AsInteger;
|
|
qryConsulta.Next;
|
|
end;
|
|
end;
|
|
pcDescontos.TabIndex := 0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsDBStateChange(Sender: TObject);
|
|
begin
|
|
pnl_devedores.Enabled := (dtsDB.State in [dsEdit, dsInsert]);
|
|
tabBoletos.Enabled := (dtsDB.State in [dsEdit, dsInsert]);
|
|
|
|
navEmail.Enabled := not(dtsDB.State in [dsEdit, dsInsert]);
|
|
navenderecos.Enabled := not(dtsDB.State in [dsEdit, dsInsert]);
|
|
navtelefones.Enabled := not(dtsDB.State in [dsEdit, dsInsert]);
|
|
navtitulos.Enabled := not(dtsDB.State in [dsEdit, dsInsert]);
|
|
navHistorico.Enabled := not(dtsDB.State in [dsEdit, dsInsert]);
|
|
tabCalculos.Enabled := not(dtsDB.State in [dsEdit, dsInsert]);
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsEmailStateChange(Sender: TObject);
|
|
begin
|
|
pnl_email.Enabled := (dtsEmail.State in [dsInsert, dsEdit]);
|
|
navPrincipal.Enabled := not(dtsEmail.State in [dsInsert, dsEdit]);
|
|
navenderecos.Enabled := not(dtsEmail.State in [dsInsert, dsEdit]);
|
|
navtelefones.Enabled := not(dtsEmail.State in [dsInsert, dsEdit]);
|
|
navtitulos.Enabled := not(dtsEmail.State in [dsInsert, dsEdit]);
|
|
navHistorico.Enabled := not(dtsEmail.State in [dsInsert, dsEdit]);
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsEnderecosDataChange(Sender: TObject; Field: TField);
|
|
begin
|
|
if (dtmSystem.tblEnderecosID_ESTADO.AsVariant >= 0) then
|
|
begin
|
|
dblucmbox_uf.keyvalue := dtmSystem.tblEstadosID_ESTADO.AsVariant;
|
|
end;
|
|
|
|
if (dtmSystem.tblEnderecosID_CIDADE.AsVariant >= 0) then
|
|
begin
|
|
dblucmbox_cidade.keyvalue := dtmSystem.tblCidadesID_CIDADE.AsVariant;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsEnderecosStateChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
Panel8.Enabled := dtsEnderecos.State in [dsEdit, dsInsert];
|
|
navEmail.Enabled := not(dtsEnderecos.State in [dsEdit, dsInsert]);
|
|
navPrincipal.Enabled := not(dtsEnderecos.State in [dsEdit, dsInsert]);
|
|
navtelefones.Enabled := not(dtsEnderecos.State in [dsEdit, dsInsert]);
|
|
navtitulos.Enabled := not(dtsEnderecos.State in [dsEdit, dsInsert]);
|
|
navHistorico.Enabled := not(dtsEnderecos.State in [dsEdit, dsInsert]);
|
|
tabCalculos.Enabled := not(dtsEnderecos.State in [dsEdit, dsInsert]);
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsHistoricoStateChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
dbgrd_historico.ReadOnly := dtsHistorico.State in [dsEdit, dsInsert];
|
|
btntelefones.Enabled := dtsHistorico.State in [dsEdit, dsInsert];
|
|
dbmemo_box.ReadOnly := not(dtsHistorico.State in [dsInsert, dsEdit]);
|
|
dblucb_providencia.Enabled := dtsHistorico.State in [dsEdit, dsInsert];
|
|
navPrincipal.Enabled := not(dtsHistorico.State in [dsEdit, dsInsert]);
|
|
navEmail.Enabled := not(dtsHistorico.State in [dsEdit, dsInsert]);
|
|
navenderecos.Enabled := not(dtsHistorico.State in [dsEdit, dsInsert]);
|
|
navtelefones.Enabled := not(dtsHistorico.State in [dsEdit, dsInsert]);
|
|
navtitulos.Enabled := not(dtsHistorico.State in [dsEdit, dsInsert]);
|
|
tabCalculos.Enabled := not(dtsHistorico.State in [dsEdit, dsInsert]);
|
|
if dtsHistorico.State in [dsInsert] then
|
|
begin
|
|
dtsHistorico.DataSet.FieldByName('CD_PROTOCOLO').AsString :=
|
|
dtmSystem.gerarProtocolo(dtsDB.DataSet.FieldByName('ID_DEVEDOR')
|
|
.AsString);
|
|
edt_protocolo.Text := gerar_protocolo
|
|
(dtmSystem.tblDevedoresID_DEVEDOR.AsString);
|
|
edt_protocolo1.Text := edt_protocolo.Text;
|
|
btn_protocolo.Enabled := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsTelefonesDataChange(Sender: TObject; Field: TField);
|
|
begin
|
|
inherited;
|
|
if dbrg_tipotel.ItemIndex = 1 then
|
|
begin
|
|
DBRadioGroup1.Enabled := True;
|
|
end
|
|
else
|
|
begin
|
|
DBRadioGroup1.Enabled := false;
|
|
DBRadioGroup1.ItemIndex := -1;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsTelefonesStateChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
Panel9.Enabled := dtsTelefones.State in [dsEdit, dsInsert];
|
|
navPrincipal.Enabled := not(dtsTelefones.State in [dsEdit, dsInsert]);
|
|
navEmail.Enabled := not(dtsTelefones.State in [dsEdit, dsInsert]);
|
|
navenderecos.Enabled := not(dtsTelefones.State in [dsEdit, dsInsert]);
|
|
navtitulos.Enabled := not(dtsTelefones.State in [dsEdit, dsInsert]);
|
|
navHistorico.Enabled := not(dtsTelefones.State in [dsEdit, dsInsert]);
|
|
tabCalculos.Enabled := not(dtsTelefones.State in [dsEdit, dsInsert]);
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsTitulosDataChange(Sender: TObject; Field: TField);
|
|
var
|
|
i, new_id_tit: Integer;
|
|
begin
|
|
pnl_cheque.Enabled := dbcbx_tpcheque.Checked;
|
|
new_id_tit := dtmSystem.tblTitulosID_TITULO.AsInteger;
|
|
if old_id_tit <> new_id_tit then
|
|
begin
|
|
old_id_tit := new_id_tit;
|
|
// clb_empresas.Items.beginupdate;
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// clb_empresas.Checked[i] := false;
|
|
// // clb_empresas.Selected[i] := false;
|
|
// end;
|
|
// clb_empresas.Items.EndUpdate;
|
|
// if dtmSystem.tblTitulosID_EMPRESA.AsString = '' then
|
|
// begin
|
|
// selected_id_chg_empresa := -1;
|
|
// end
|
|
// else
|
|
// begin
|
|
// dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA',
|
|
// dtmSystem.tblTitulosID_EMPRESA.AsInteger, []);
|
|
// selected_id_chg_empresa := dtmSystem.tblCHGEmpresaID_EMPRESA.AsInteger;
|
|
// if clb_empresas.Items.IndexOf(dtmSystem.tblCHGEmpresaTX_NOME.AsString) > -1
|
|
// then
|
|
// begin
|
|
// clb_empresas.Checked
|
|
// [clb_empresas.Items.IndexOf
|
|
// (dtmSystem.tblCHGEmpresaTX_NOME.AsString)] := True;
|
|
// // clb_empresas.Selected
|
|
// // [clb_empresas.Items.IndexOf(dtmSystem.tblCHGEmpresaTX_NOME.
|
|
// // AsString)] := True;
|
|
// end;
|
|
// end;
|
|
//
|
|
// if dtsTitulos.DataSet.State in [dsBrowse] then
|
|
// begin
|
|
// // zroQueryAcordos.SQL.Text :=
|
|
// // 'select * from sys_acordos where id_original = ' +
|
|
// // dtsTitulos.DataSet.FieldByName('id_titulo').AsString;
|
|
// // zroQueryAcordos.Open;
|
|
// end;
|
|
|
|
end;
|
|
|
|
// if not(dtsTitulos.DataSet.State in [dsEdit, dsInsert]) then
|
|
// begin
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// clb_empresas.ItemEnabled[i] := false;
|
|
// end;
|
|
// end
|
|
// else
|
|
// begin
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// clb_empresas.ItemEnabled[i] := True;
|
|
// end;
|
|
// end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsTitulosStateChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
Panel10.Enabled := dtsTitulos.State in [dsEdit, dsInsert];
|
|
// dbmem_titobs.Enabled := dtsTitulos.State in [dsEdit, dsInsert];
|
|
dbmem_titobs.ReadOnly := not(dtsTitulos.State in [dsEdit, dsInsert]);
|
|
navPrincipal.Enabled := not(dtsTitulos.State in [dsEdit, dsInsert]);
|
|
navEmail.Enabled := not(dtsTitulos.State in [dsEdit, dsInsert]);
|
|
navenderecos.Enabled := not(dtsTitulos.State in [dsEdit, dsInsert]);
|
|
navtelefones.Enabled := not(dtsTitulos.State in [dsEdit, dsInsert]);
|
|
navHistorico.Enabled := not(dtsTitulos.State in [dsEdit, dsInsert]);
|
|
tabCalculos.Enabled := not(dtsTitulos.State in [dsEdit, dsInsert]);
|
|
end;
|
|
|
|
procedure TcadDevedores.dtsUFDataChange(Sender: TObject; Field: TField);
|
|
begin
|
|
|
|
if (dtmSystem.tblEnderecosID_ESTADO.AsVariant >= 0) then
|
|
begin
|
|
dblucmbox_uf.keyvalue := dtmSystem.tblEstadosID_ESTADO.AsVariant;
|
|
end;
|
|
if (dtmSystem.tblEnderecosID_CIDADE.AsVariant >= 0) then
|
|
begin
|
|
dblucmbox_cidade.keyvalue := dtmSystem.tblCidadesID_CIDADE.AsVariant;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_excjurosparcelaChange(Sender: TObject);
|
|
begin
|
|
if Length(edt_excjurosparcela.Text) < 1 then
|
|
begin
|
|
edt_excjurosparcela.Text := '0';
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_excjurosparcelaKeyPress(Sender: TObject;
|
|
var Key: Char);
|
|
begin
|
|
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, edt_excjurosparcela.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_corparChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
try
|
|
if (strtofloat(edt_corpar.Text) > -1) and (queryListaTitulos.Active) and
|
|
(edt_corpar.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_corpar.Text) >
|
|
strtoint(copy(lbl_maxparcor.Caption, 6, Length(lbl_maxparcor.Caption) -
|
|
1 - 5)) then
|
|
begin
|
|
edt_corpar.Text := copy(lbl_maxparcor.Caption, 6,
|
|
Length(lbl_maxparcor.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if ud_corpar.Max = 0 then
|
|
begin
|
|
edt_corpar.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_corparKeyPress(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, edt_corpar.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_corquitarChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
try
|
|
if (strtofloat(edt_corquitar.Text) > -1) and (queryListaTitulos.Active) and
|
|
(edt_corquitar.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_corquitar.Text) >
|
|
strtoint(copy(lbl_maxquitcor.Caption, 6, Length(lbl_maxquitcor.Caption)
|
|
- 1 - 5)) then
|
|
begin
|
|
edt_corquitar.Text := copy(lbl_maxquitcor.Caption, 6,
|
|
Length(lbl_maxquitcor.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if ud_corquitar.Max = 0 then
|
|
begin
|
|
edt_corquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_corquitarKeyPress(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, edt_corquitar.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_excentradaChange(Sender: TObject);
|
|
begin
|
|
if Length(edt_excentrada.Text) < 1 then
|
|
begin
|
|
edt_excentrada.Text := '0';
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_excentradaKeyPress(Sender: TObject; var Key: Char);
|
|
begin
|
|
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, edt_excentrada.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_fontememoExit(Sender: TObject);
|
|
begin
|
|
if strtoint(edt_fontememo.Text) < 8 then
|
|
begin
|
|
edt_fontememo.Text := '8';
|
|
mb_fechamento.Font.size := 8;
|
|
end;
|
|
if strtoint(edt_fontememo.Text) > 72 then
|
|
begin
|
|
edt_fontememo.Text := '72';
|
|
mb_fechamento.Font.size := 72;
|
|
end;
|
|
|
|
mb_fechamento.Font.size := strtoint(edt_fontememo.Text);
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_fontememoKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
begin
|
|
if Key = vkReturn then
|
|
begin
|
|
mb_fechamento.SetFocus;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_indparcelasChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_indparcelas.Text) > -1) and (queryListaTitulos.Active)
|
|
and (edt_indparcelas.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_indparcelas.Text) >
|
|
strtoint(copy(lbl_maxindpar.Caption, 6, Length(lbl_maxindpar.Caption) -
|
|
1 - 5)) then
|
|
begin
|
|
edt_indparcelas.Text := copy(lbl_maxindpar.Caption, 6,
|
|
Length(lbl_maxindpar.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_encparcelas.Max = 0 then
|
|
begin
|
|
edt_indparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_indparcelasKeyPress(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, edt_indparcelas.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_indquitarChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_indquitar.Text) > -1) and (queryListaTitulos.Active) and
|
|
(edt_indquitar.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_indquitar.Text) >
|
|
strtoint(copy(lbl_maxindquit.Caption, 6, Length(lbl_maxindquit.Caption)
|
|
- 1 - 5)) then
|
|
begin
|
|
edt_indquitar.Text := copy(lbl_maxindquit.Caption, 6,
|
|
Length(lbl_maxindquit.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_encquitar.Max = 0 then
|
|
begin
|
|
edt_indquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_indquitarKeyPress(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, edt_indquitar.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_jurosparcelasChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_jurosparcelas.Text) > -1) and (queryListaTitulos.Active)
|
|
and (edt_jurosparcelas.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_jurosparcelas.Text) >
|
|
strtoint(copy(lbl_maxjurospar.Caption, 6,
|
|
Length(lbl_maxjurospar.Caption) - 1 - 5)) then
|
|
begin
|
|
edt_jurosparcelas.Text := copy(lbl_maxjurospar.Caption, 6,
|
|
Length(lbl_maxjurospar.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_jurosparcelas.Max = 0 then
|
|
begin
|
|
edt_jurosparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_jurosparcelasKeyPress(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, edt_jurosparcelas.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_jurosquitarChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_jurosquitar.Text) > -1) and (queryListaTitulos.Active)
|
|
and (edt_jurosquitar.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_jurosquitar.Text) >
|
|
strtoint(copy(lbl_maxjurosquit.Caption, 6,
|
|
Length(lbl_maxjurosquit.Caption) - 1 - 5)) then
|
|
begin
|
|
edt_jurosquitar.Text := copy(lbl_maxjurosquit.Caption, 6,
|
|
Length(lbl_maxjurosquit.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_jurosquitar.Max = 0 then
|
|
begin
|
|
edt_jurosquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_jurosquitarKeyPress(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, edt_jurosquitar.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_multasparcelasChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_multasparcelas.Text) > -1) and (queryListaTitulos.Active)
|
|
and (edt_multasparcelas.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_multasparcelas.Text) >
|
|
strtoint(copy(lbl_maxmultapar.Caption, 6,
|
|
Length(lbl_maxmultapar.Caption) - 1 - 5)) then
|
|
begin
|
|
edt_multasparcelas.Text := copy(lbl_maxmultapar.Caption, 6,
|
|
Length(lbl_maxmultapar.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_multasparcelas.Max = 0 then
|
|
begin
|
|
edt_multasparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_multasparcelasKeyPress(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, edt_multasparcelas.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_multasquitarChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_multasquitar.Text) > -1) and (queryListaTitulos.Active)
|
|
and (edt_multasquitar.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_multasquitar.Text) >
|
|
strtoint(copy(lbl_maxmultaquit.Caption, 6,
|
|
Length(lbl_maxmultaquit.Caption) - 1 - 5)) then
|
|
begin
|
|
edt_multasquitar.Text := copy(lbl_maxmultaquit.Caption, 6,
|
|
Length(lbl_maxmultaquit.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_multasquitar.Max = 0 then
|
|
begin
|
|
edt_multasquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_multasquitarKeyPress(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, edt_multasquitar.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_nrparcelasChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtoint(edt_nrparcelas.Text) > -1) and (queryListaTitulos.Active) and
|
|
(edt_nrparcelas.Text <> '') then
|
|
begin
|
|
if strtoint(edt_nrparcelas.Text) > up_nrparcelas.Max then
|
|
begin
|
|
edt_nrparcelas.Text := inttostr(up_nrparcelas.Max);
|
|
end;
|
|
if strtoint(edt_nrparcelas.Text) < 0 then
|
|
begin
|
|
edt_nrparcelas.Text := '0';
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if (cb_descquit.Checked) and not(ficha_dev) then
|
|
begin
|
|
edt_nrparcelas.Text := '0';
|
|
end;
|
|
{ if cb_formapag.ItemIndex = 1 then
|
|
begin
|
|
edt_nrparcelas.Text := '0';
|
|
end; }
|
|
// Att_campos;
|
|
// CalcValorParcelas;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_nrparcelasExit(Sender: TObject);
|
|
begin
|
|
if edt_nrparcelas.Text = '' then
|
|
begin
|
|
edt_nrparcelas.Text := '0';
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_prentradaChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtoint(edt_prentrada.Text) > -1) and (queryListaTitulos.Active) and
|
|
(edt_prentrada.Text <> '') then
|
|
begin
|
|
if strtoint(edt_prentrada.Text) >
|
|
strtoint(copy(lbl_maxentrada.Caption, 6, Length(lbl_maxentrada.Caption)
|
|
- 1 - 5)) then
|
|
begin
|
|
edt_prentrada.Text := copy(lbl_maxentrada.Caption, 6,
|
|
Length(lbl_maxentrada.Caption) - 1 - 5);
|
|
end;
|
|
if strtoint(edt_prentrada.Text) <
|
|
strtoint(copy(lbl_minentrada.Caption, 6, Length(lbl_minentrada.Caption)
|
|
- 1 - 5)) then
|
|
begin
|
|
edt_prentrada.Text := copy(lbl_minentrada.Caption, 6,
|
|
Length(lbl_minentrada.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if ud_entrada.Max = 0 then
|
|
begin
|
|
edt_prentrada.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_principalparcelasChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_principalparcelas.Text) > -1) and
|
|
(queryListaTitulos.Active) and (edt_principalparcelas.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_principalparcelas.Text) >
|
|
strtoint(copy(lbl_maxprinpar.Caption, 6, Length(lbl_maxprinpar.Caption)
|
|
- 1 - 5)) then
|
|
begin
|
|
edt_principalparcelas.Text := copy(lbl_maxprinpar.Caption, 6,
|
|
Length(lbl_maxprinpar.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_principalparcelas.Max = 0 then
|
|
begin
|
|
edt_principalparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_principalparcelasKeyPress(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, edt_principalparcelas.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_principalquitarChange(Sender: TObject);
|
|
begin
|
|
try
|
|
if (strtofloat(edt_principalquitar.Text) > -1) and
|
|
(queryListaTitulos.Active) and (edt_principalquitar.Text <> '') then
|
|
begin
|
|
if strtofloat(edt_principalquitar.Text) >
|
|
strtoint(copy(lbl_maxprinquit.Caption, 6,
|
|
Length(lbl_maxprinquit.Caption) - 1 - 5)) then
|
|
begin
|
|
edt_principalquitar.Text := copy(lbl_maxprinquit.Caption, 6,
|
|
Length(lbl_maxprinquit.Caption) - 1 - 5);
|
|
end;
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_principalquitar.Max = 0 then
|
|
begin
|
|
edt_principalquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
except
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_principalquitarKeyPress(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, edt_principalquitar.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_txextraChange(Sender: TObject);
|
|
begin
|
|
inherited;
|
|
if Length(edt_txextra.Text) < 1 then
|
|
begin
|
|
edt_txextra.Text := '0';
|
|
end;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.edt_txextraKeyPress(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, edt_txextra.Text) > 0) then
|
|
begin
|
|
Key := #0;
|
|
end;
|
|
end;
|
|
|
|
// function TcadDevedores.EscreveTitulos: TStringDynArray;
|
|
// var
|
|
// Count, i, j: Integer;
|
|
// tx_titulo, vl_titulo, id_titulo: array of string;
|
|
// begin
|
|
// Count := 0;
|
|
// // queryListaTitulos.DisableControls;
|
|
// for i := 0 to lv_titulos.Items.Count - 1 do
|
|
// begin
|
|
// if lv_titulos.Items.Item[i].Checked then
|
|
// begin
|
|
// Count := Count + 1;
|
|
// dtmSystem.tblTitulos.Locate('ID_TITULO',
|
|
// queryListaTitulosID_TITULO.AsString, []);
|
|
// setlength(tx_titulo, Count);
|
|
// setlength(id_titulo, Count);
|
|
// setlength(vl_titulo, Count);
|
|
// queryListaTitulos.RecNo := i + 1;
|
|
// tx_titulo[Count - 1] := queryListaTitulosTX_PRODUTO.AsString;
|
|
// id_titulo[Count - 1] := queryListaTitulosID_TITULO.AsString;
|
|
// vl_titulo[Count - 1] := CurrToStrF(queryListaTitulosVL_TITULO.AsCurrency,
|
|
// ffCurrency, 2, dtmSystem.CusFmt);
|
|
//
|
|
// end;
|
|
// end;
|
|
// // queryListaTitulos.EnableControls;
|
|
// setlength(Result, Count);
|
|
// for j := 0 to Count - 1 do
|
|
// begin
|
|
// Result[j] := tx_titulo[j] + ' (ID:' + id_titulo[j] +
|
|
// ') no valor nominal de ' + vl_titulo[j] + '.';
|
|
// end;
|
|
// end;
|
|
|
|
function TcadDevedores.FindControlAtPos(AScreenPos: TPoint): TControl;
|
|
var
|
|
i: Integer;
|
|
f, m: TForm;
|
|
p: TPoint;
|
|
r: TRect;
|
|
begin
|
|
Result := nil;
|
|
for i := Screen.FormCount - 1 downto 0 do
|
|
begin
|
|
f := Screen.Forms[i];
|
|
if f.Visible and (f.Parent = nil) and (f.FormStyle <> fsMDIChild) and
|
|
TRect.Create(f.left, f.Top, f.left + f.Width, f.Top + f.Height)
|
|
.Contains(AScreenPos) then
|
|
Result := f;
|
|
end;
|
|
Result := FindSubcontrolAtPos(Result, AScreenPos, AScreenPos);
|
|
if (Result is TForm) and (TForm(Result).ClientHandle <> 0) then
|
|
begin
|
|
Winapi.Windows.GetWindowRect(TForm(Result).ClientHandle, r);
|
|
p := TPoint.Create(AScreenPos.X - r.left, AScreenPos.Y - r.Top);
|
|
m := nil;
|
|
for i := TForm(Result).MDIChildCount - 1 downto 0 do
|
|
begin
|
|
f := TForm(Result).MDIChildren[i];
|
|
if TRect.Create(f.left, f.Top, f.left + f.Width, f.Top + f.Height)
|
|
.Contains(p) then
|
|
m := f;
|
|
end;
|
|
if m <> nil then
|
|
Result := FindSubcontrolAtPos(m, AScreenPos, p);
|
|
end;
|
|
end;
|
|
|
|
function TcadDevedores.FindSubcontrolAtPos(AControl: TControl;
|
|
AScreenPos, AClientPos: TPoint): TControl;
|
|
var
|
|
i: Integer;
|
|
C: TControl;
|
|
begin
|
|
Result := nil;
|
|
C := AControl;
|
|
if (C = nil) or not C.Visible or not TRect.Create(C.left, C.Top,
|
|
C.left + C.Width, C.Top + C.Height).Contains(AClientPos) then
|
|
exit;
|
|
Result := AControl;
|
|
if AControl is TWinControl then
|
|
for i := 0 to TWinControl(AControl).ControlCount - 1 do
|
|
begin
|
|
C := FindSubcontrolAtPos(TWinControl(AControl).Controls[i], AScreenPos,
|
|
AControl.ScreenToClient(AScreenPos));
|
|
if C <> nil then
|
|
Result := C;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.FormClose(Sender: TObject; var Action: TCloseAction);
|
|
// var
|
|
// i: Word;
|
|
// Result: Boolean;
|
|
begin
|
|
// inherited;
|
|
// if MessageDlg
|
|
// ('Você está prestes a fechar um acionamento em andamento. Alterações neste devedor podem não ser salvas. Deseja continuar?',
|
|
// mtWarning, mbYesNo, 0) = mrNo then
|
|
// begin
|
|
// abort;
|
|
// end;
|
|
queryCobradores.Close;
|
|
{ with dtmSystem do
|
|
begin
|
|
Result := false;
|
|
for i := 0 to Screen.FormCount - 1 do
|
|
if Screen.Forms[i] = frmEfetuarCobranca then
|
|
begin
|
|
Result := True;
|
|
with dtmSystem do
|
|
begin
|
|
if not tblDevedores.Active then
|
|
begin
|
|
tblDevedores.Open;
|
|
end;
|
|
if not tblEnderecos.Active then
|
|
begin
|
|
tblEnderecos.Open;
|
|
end;
|
|
if not tblTelefones.Active then
|
|
begin
|
|
tblTelefones.Open;
|
|
end;
|
|
if not tblTitulos.Active then
|
|
begin
|
|
tblTitulos.Open;
|
|
end;
|
|
if not tblProvidencias.Active then
|
|
begin
|
|
tblProvidencias.Open;
|
|
end;
|
|
if not tblHistorico.Active then
|
|
begin
|
|
tblHistorico.Open;
|
|
end;
|
|
if not tblCobCampanha.Active then
|
|
begin
|
|
tblCobCampanha.Open;
|
|
end;
|
|
if not tblCampanhaDevedores.Active then
|
|
begin
|
|
tblCampanhaDevedores.Open;
|
|
end;
|
|
if not tblAgenda.Active then
|
|
begin
|
|
tblAgenda.Open;
|
|
end;
|
|
if not tblEmpresa.Active then
|
|
begin
|
|
tblEmpresa.Open;
|
|
end;
|
|
if not tblCHGEmpresa.Active then
|
|
begin
|
|
tblCHGEmpresa.Open;
|
|
end;
|
|
if not tblIndicadorFinanceiro.Active then
|
|
begin
|
|
tblIndicadorFinanceiro.Open;
|
|
end;
|
|
break;
|
|
end;
|
|
end;
|
|
if Result = false then
|
|
begin
|
|
tblDevedores.Close;
|
|
tblEnderecos.Close;
|
|
tblTelefones.Close;
|
|
tblTitulos.Close;
|
|
tblCHGEmpresa.Close;
|
|
tblHistorico.Close;
|
|
tblProvidencias.Close;
|
|
end;
|
|
end; }
|
|
if imp then
|
|
begin
|
|
frmCobranca.importar := True;
|
|
end
|
|
else
|
|
begin
|
|
frmCobranca.importar := false;
|
|
end;
|
|
Screen.Cursor := crDefault;
|
|
Action := caFree;
|
|
cadDevedores := nil;
|
|
end;
|
|
|
|
procedure TcadDevedores.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
|
|
begin
|
|
inherited;
|
|
if navEmail.DataSource <> nil then
|
|
if navEmail.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
CanClose := false;
|
|
end;
|
|
if navtelefones.DataSource <> nil then
|
|
if navtelefones.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
CanClose := false;
|
|
end;
|
|
if navenderecos.DataSource <> nil then
|
|
if navenderecos.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
CanClose := false;
|
|
end;
|
|
if navtitulos.DataSource <> nil then
|
|
if navtitulos.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
CanClose := false;
|
|
end;
|
|
if navHistorico.DataSource <> nil then
|
|
if navHistorico.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
CanClose := false;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.FormCreate(Sender: TObject);
|
|
var
|
|
Pos, i: Integer;
|
|
// antes: TTime;
|
|
begin
|
|
inherited;
|
|
Screen.Cursor := crHourGlass;
|
|
Pos := 0;
|
|
old_id := -1;
|
|
ficha_dev := false;
|
|
setlength(ids_tits_calc, 0);
|
|
importou := false;
|
|
estado_db := True;
|
|
dtp_agendadatahist.Date := Date;
|
|
dtp_agendadatahist.MinDate := Date;
|
|
dtp_agendahorahist.Time := Timeof(Now);
|
|
id_emp_calc := -1;
|
|
imp := false;
|
|
if dtmSystem.id_grupo <> 1 then
|
|
begin
|
|
dbgrd_tit.Columns[8].Visible := false;
|
|
dbgrd_tit.Columns[9].Visible := false;
|
|
|
|
lbl_dtpag.Visible := false;
|
|
lbl_dtrecibo.Visible := false;
|
|
|
|
rdbdt_pag.Enabled := false;
|
|
rdbdt_pag.Visible := false;
|
|
rdbdt_recibo.Enabled := false;
|
|
rdbdt_recibo.Visible := false;
|
|
|
|
DBGrid1.PopupMenu := nil;
|
|
end;
|
|
|
|
with dtmSystem do
|
|
begin
|
|
OpenOrRefresh(tblDevedores);
|
|
OpenOrRefresh(tblEmail);
|
|
OpenOrRefresh(tblHistorico);
|
|
OpenOrRefresh(tblEstados);
|
|
OpenOrRefresh(tblCidades);
|
|
OpenOrRefresh(tblEnderecos);
|
|
OpenOrRefresh(tblTelefones);
|
|
OpenOrRefresh(tblTitulos);
|
|
OpenOrRefresh(tblProvidencias);
|
|
OpenOrRefresh(tblCHGEmpresa);
|
|
OpenOrRefresh(tblPoliticas);
|
|
OpenOrRefresh(tblFaixas);
|
|
tblCHGEmpresa.First;
|
|
OpenOrRefresh(tblIndicadorFinanceiro);
|
|
OpenOrRefresh(tblLogCampanhas);
|
|
OpenOrRefresh(tblDevEmpBoletos);
|
|
// setlength(cbl_hints,pos+1); pegar do banco texto para jogar nas hints
|
|
|
|
// while not tblCHGEmpresa.Eof do
|
|
// begin
|
|
// clb_empresas.Items.Add(tblCHGEmpresaTX_NOME.AsString);
|
|
// // cbl_hints[pos] := tblCHGEmpresaTX_CNPJ.AsString;
|
|
// if tblTitulosID_EMPRESA.AsString = tblCHGEmpresaID_EMPRESA.AsString then
|
|
// begin
|
|
// clb_empresas.Checked[Pos] := True;
|
|
// // clb_empresas.Selected[Pos] := True;
|
|
// end;
|
|
// tblCHGEmpresa.Next;
|
|
// Pos := Pos + 1;
|
|
// // setlength(cbl_hints,pos+1);
|
|
// end;
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// clb_empresas.ItemEnabled[i] := false;
|
|
// end;
|
|
// if not(tblHistorico.Active) then
|
|
// begin
|
|
// tblHistorico.Open;
|
|
// end;
|
|
end;
|
|
|
|
SetupHackedNavigator(navPrincipal, ImageList1, 's', 2);
|
|
SetupHackedNavigator(navEmail, ImageList1, 's', 2);
|
|
SetupHackedNavigator(navenderecos, ImageList1, 's', 8);
|
|
SetupHackedNavigator(navtelefones, ImageList1, 's', 8);
|
|
SetupHackedNavigator(navtitulos, ImageList1, 's', 8);
|
|
SetupHackedNavigator(navHistorico, ImageList1, 's', 8);
|
|
SetupHackedNavigator(DBNavigator1, ImageList1, 'n', 2);
|
|
|
|
pnl_devedores.Enabled := false;
|
|
pnl_email.Enabled := false;
|
|
|
|
Panel8.Enabled := false;
|
|
Panel9.Enabled := false;
|
|
Panel10.Enabled := false;
|
|
|
|
ChecaPermissoes;
|
|
dtp_atrasorecalc.Date := Date;
|
|
|
|
clb_beneficiarioscalculo.Clear;
|
|
pcDescontos.TabIndex := 0;
|
|
if dtsDB.DataSet.IsEmpty then
|
|
begin
|
|
dbgrd_devedoreslist.Enabled := false;
|
|
end
|
|
else
|
|
begin
|
|
dbgrd_devedoreslist.Enabled := True;
|
|
end;
|
|
|
|
AdjustCheckListBox;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.FormKeyDown(Sender: TObject; var Key: Word;
|
|
Shift: TShiftState);
|
|
begin
|
|
inherited;
|
|
if Key = VK_ESCAPE then
|
|
begin
|
|
if MessageDlg
|
|
('Você está prestes a fechar um acionamento em andamento. Alterações neste devedor podem não ser salvas. Deseja continuar?',
|
|
mtWarning, mbYesNo, 0) = mrNo then
|
|
begin
|
|
abort;
|
|
end;
|
|
Key := 0;
|
|
Close;
|
|
end;
|
|
if (Key = 75) and (Shift = [ssCtrl]) then
|
|
begin
|
|
// ShowMessage('Ctrl+k is pressed!');
|
|
frmLiberaPermissao := TfrmLiberaPermissao.Create(self);
|
|
|
|
with frmLiberaPermissao do
|
|
begin
|
|
level := 3;
|
|
string_permissoes.Add('CBR.02.01.01.01');
|
|
string_permissoes.Add('CBR.02.01.01.01.01');
|
|
|
|
string_permissoes.Add('CBR.02.01.01.06');
|
|
string_permissoes.Add('CBR.02.01.01.06.01');
|
|
string_permissoes.Add('CBR.02.01.01.06.02');
|
|
string_permissoes.Add('CBR.02.01.01.06.03');
|
|
|
|
string_permissoes.Add('CBR.02.01.01.02');
|
|
string_permissoes.Add('CBR.02.01.01.02.01');
|
|
string_permissoes.Add('CBR.02.01.01.02.02');
|
|
string_permissoes.Add('CBR.02.01.01.02.03');
|
|
|
|
string_permissoes.Add('CBR.02.01.01.03');
|
|
string_permissoes.Add('CBR.02.01.01.03.01');
|
|
string_permissoes.Add('CBR.02.01.01.03.02');
|
|
string_permissoes.Add('CBR.02.01.01.03.03');
|
|
|
|
string_permissoes.Add('CBR.02.01.01.04');
|
|
string_permissoes.Add('CBR.02.01.01.04.01');
|
|
string_permissoes.Add('CBR.02.01.01.04.02');
|
|
string_permissoes.Add('CBR.02.01.01.04.03');
|
|
|
|
string_permissoes.Add('CBR.02.01.01.05');
|
|
string_permissoes.Add('CBR.02.01.01.05.01');
|
|
string_permissoes.Add('CBR.02.01.01.05.02');
|
|
string_permissoes.Add('CBR.02.01.01.05.03');
|
|
|
|
string_permissoes.Add('CBR.02.01.02.01.01');
|
|
string_permissoes.Add('CBR.02.01.02.01.02');
|
|
|
|
string_permissoes.Add('CBR.02.01.02.02');
|
|
string_permissoes.Add('CBR.02.01.02.03');
|
|
string_permissoes.Add('CBR.02.01.02.04');
|
|
|
|
ShowModal;
|
|
|
|
if ModalResult = mrOk then
|
|
begin
|
|
case dtmSystem.cod_liberapermissao of
|
|
0:
|
|
navPrincipal.Enabled := True;
|
|
1:
|
|
navPrincipal.VisibleButtons := navPrincipal.VisibleButtons +
|
|
[nbDelete];
|
|
2:
|
|
navEmail.Enabled := True;
|
|
3:
|
|
navEmail.VisibleButtons := navEmail.VisibleButtons + [nbInsert];
|
|
4:
|
|
navEmail.VisibleButtons := navEmail.VisibleButtons + [nbEdit];
|
|
5:
|
|
navEmail.VisibleButtons := navEmail.VisibleButtons + [nbDelete];
|
|
6:
|
|
navenderecos.Enabled := True;
|
|
7:
|
|
navenderecos.VisibleButtons := navenderecos.VisibleButtons +
|
|
[nbInsert];
|
|
8:
|
|
navenderecos.VisibleButtons := navenderecos.VisibleButtons
|
|
+ [nbEdit];
|
|
9:
|
|
navenderecos.VisibleButtons := navenderecos.VisibleButtons +
|
|
[nbDelete];
|
|
10:
|
|
navtelefones.Enabled := True;
|
|
11:
|
|
navtelefones.VisibleButtons := navtelefones.VisibleButtons +
|
|
[nbInsert];
|
|
12:
|
|
navtelefones.VisibleButtons := navtelefones.VisibleButtons
|
|
+ [nbEdit];
|
|
13:
|
|
navtelefones.VisibleButtons := navtelefones.VisibleButtons +
|
|
[nbDelete];
|
|
14:
|
|
navtitulos.Enabled := True;
|
|
15:
|
|
navtitulos.VisibleButtons := navtitulos.VisibleButtons + [nbInsert];
|
|
16:
|
|
navtitulos.VisibleButtons := navtitulos.VisibleButtons + [nbEdit];
|
|
17:
|
|
navtitulos.VisibleButtons := navtitulos.VisibleButtons + [nbDelete];
|
|
18:
|
|
navHistorico.Enabled := True;
|
|
19:
|
|
navHistorico.VisibleButtons := navHistorico.VisibleButtons +
|
|
[nbInsert];
|
|
20:
|
|
navHistorico.VisibleButtons := navHistorico.VisibleButtons
|
|
+ [nbEdit];
|
|
21:
|
|
navHistorico.VisibleButtons := navHistorico.VisibleButtons +
|
|
[nbDelete];
|
|
22:
|
|
tabQuitar.Enabled := True;
|
|
23:
|
|
tabParcelar.Enabled := True;
|
|
24:
|
|
cb_nmulta.Enabled := True;
|
|
25:
|
|
cbx_txextra.Enabled := True;
|
|
26:
|
|
cbx_excentrada.Enabled := True;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
// if (Key = VK_RETURN) and not(mb_fechamento.Focused) then
|
|
// begin
|
|
// Perform(WM_NEXTDLGCTL, 0, 0);
|
|
// Key := 0;
|
|
// end;
|
|
end;
|
|
|
|
procedure TcadDevedores.FormShow(Sender: TObject);
|
|
begin
|
|
dtp_diaagendamento.Date := Date;
|
|
with dtmSystem do
|
|
begin
|
|
if tblDevedoresTP_CLIENTE.AsString = 'F' then
|
|
begin
|
|
dbedt_cpfcnpj.DataField := 'CD_CPF';
|
|
end;
|
|
if tblDevedoresTP_CLIENTE.AsString = 'J' then
|
|
begin
|
|
dbedt_cpfcnpj.DataField := 'CD_CNPJ';
|
|
end;
|
|
end;
|
|
|
|
// if pesquisa <> 0 then
|
|
// begin
|
|
// dtmSystem.tblDevedores.RecNo := pesquisa;
|
|
// end;
|
|
|
|
if dtmSystem.tblDevedores.RecordCount > 0 then
|
|
begin
|
|
|
|
qryConsulta.SQL.Text := 'select * from chg_empresas where id_empresa in ' +
|
|
'(select id_empresa from chg_titulos' +
|
|
' where (tp_situacao = ''A'' or tp_situacao = ''AC'') and (id_devedor = '
|
|
+ dtmSystem.tblDevedoresID_DEVEDOR.AsString + '))';
|
|
qryConsulta.Open;
|
|
qryConsulta.First;
|
|
clb_beneficiarioscalculo.Clear;
|
|
setlength(id_emps_dev, qryConsulta.RecordCount);
|
|
while not qryConsulta.Eof do
|
|
begin
|
|
clb_beneficiarioscalculo.Items.Add(qryConsulta.FieldByName('TX_NOME')
|
|
.AsString);
|
|
id_emps_dev[qryConsulta.RecNo - 1] :=
|
|
qryConsulta.FieldByName('ID_EMPRESA').AsInteger;
|
|
qryConsulta.Next;
|
|
end;
|
|
|
|
// clb_beneficiarioscalculo.Checked[0] := true;
|
|
// CriarLista;
|
|
|
|
queryListaTitulos.SQL.Clear;
|
|
queryListaTitulos.SQL.Text :=
|
|
'select * from (select * from chg_titulos where id_devedor = ' +
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString +
|
|
') where ((tp_situacao = ''A'' or tp_situacao = ''AC''))';
|
|
queryListaTitulos.Open;
|
|
|
|
dia_agendado := '__/__/____';
|
|
hora_agendado := '__:__';
|
|
nome_cobrador := '__________';
|
|
end;
|
|
if dtmSystem.tblUsuarios.RecordCount > 0 then
|
|
begin
|
|
queryCobradores.SQL.Text :=
|
|
'select id_usuario, tx_nome from sys_usuarios where tp_ativo = ' +
|
|
QuotedStr('S') + ' order by tx_nome';
|
|
queryCobradores.Open;
|
|
end;
|
|
Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
function TcadDevedores.gerar_protocolo(id_devedor: string): string;
|
|
var
|
|
tamanho, i: Integer;
|
|
cd_devedor, dia, tempo: string;
|
|
begin
|
|
tempo := FormatDateTime('hhmm', Time);
|
|
dia := FormatDateTime('yyyymmdd', Date);
|
|
cd_devedor := id_devedor;
|
|
tamanho := Length(id_devedor);
|
|
for i := 0 to 7 - tamanho do
|
|
begin
|
|
cd_devedor := '0' + cd_devedor;
|
|
end;
|
|
Result := tempo + dia + cd_devedor;
|
|
end;
|
|
|
|
procedure TcadDevedores.Importao1Click(Sender: TObject);
|
|
begin
|
|
// with TimpDevedores.Create(self) do
|
|
// begin
|
|
// ShowModal;
|
|
// // with dtmSystem do
|
|
// // begin
|
|
// // if (pcClientes.ActivePage = tabEndereco) then
|
|
// // begin
|
|
// // tblEnderecos.Open;
|
|
// // tblCidades.Open;
|
|
// // tblEstados.Open;
|
|
// // end;
|
|
// // if (pcClientes.ActivePage = tabTel) then
|
|
// // begin
|
|
// // tblTelefones.Open;
|
|
// // end;
|
|
// // if (pcClientes.ActivePage = tabTitulos) then
|
|
// // begin
|
|
// // tblCHGEmpresa.Open;
|
|
// // tblTitulos.Open;
|
|
// // end;
|
|
// // end;
|
|
// end;
|
|
imp := True;
|
|
Close;
|
|
end;
|
|
|
|
procedure TcadDevedores.lv_titulosChange(Sender: TObject; Item: TListItem;
|
|
Change: TItemChange);
|
|
begin
|
|
// Att_campos;
|
|
// CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.lv_titulosColumnClick(Sender: TObject;
|
|
Column: TListColumn);
|
|
begin
|
|
// ColumnToSort := Column.Index;
|
|
// (Sender as TCustomListView).AlphaSort;
|
|
end;
|
|
|
|
procedure TcadDevedores.lv_titulosCompare(Sender: TObject;
|
|
Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
|
|
begin
|
|
// case ColumnToSort of
|
|
// 2: Compare := CompareText(Item1.SubItems[ColumnToSort-1], Item2.SubItems[ColumnToSort-1]);
|
|
// 3: Compare := CompareDateTime(strtodate(Item1.SubItems[ColumnToSort-1]), strtodate(Item2.SubItems[ColumnToSort-1]));
|
|
// 4: Compare := CompareValue(strtofloat(Item1.SubItems[ColumnToSort-1]), strtofloat(Item2.SubItems[ColumnToSort-1]));
|
|
// 5: Compare := CompareText(Item1.SubItems[ColumnToSort-1], Item2.SubItems[ColumnToSort-1]);
|
|
// end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.lv_titulosItemChecked(Sender: TObject; Item: TListItem);
|
|
var
|
|
i, k: Integer;
|
|
Checked: Boolean;
|
|
begin
|
|
qtde_titulos := 0;
|
|
Checked := false;
|
|
k := 0;
|
|
if lv_titulos.Items.Count > 0 then
|
|
begin
|
|
queryListaTitulos.DisableControls;
|
|
for i := 0 to lv_titulos.Items.Count - 1 do
|
|
begin
|
|
if lv_titulos.Items.Item[i].Checked then
|
|
begin
|
|
queryListaTitulos.RecNo := i + 1;
|
|
qtde_titulos := qtde_titulos + 1;
|
|
str_titulos := str_titulos + queryListaTitulosID_TITULO.AsString + ';';
|
|
id_emp := queryListaTitulosID_EMPRESA.AsInteger;
|
|
Checked := True;
|
|
setlength(str_tit, k + 1);
|
|
str_tit[k] := queryListaTitulosID_TITULO.AsInteger;
|
|
Inc(k, 1);
|
|
end;
|
|
end;
|
|
queryListaTitulos.EnableControls;
|
|
end;
|
|
if not Checked then
|
|
begin
|
|
str_titulos := 'S/T';
|
|
end;
|
|
edt_indparcelas.Text := '0';
|
|
edt_principalparcelas.Text := '0';
|
|
edt_multasparcelas.Text := '0';
|
|
edt_jurosparcelas.Text := '0';
|
|
edt_corquitar.Text := '0';
|
|
edt_indquitar.Text := '0';
|
|
edt_principalquitar.Text := '0';
|
|
edt_multasquitar.Text := '0';
|
|
edt_jurosquitar.Text := '0';
|
|
edt_corpar.Text := '0';
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.mnuFichatitulosClick(Sender: TObject);
|
|
begin
|
|
|
|
with TfrmFichaTitulos.Create(self) do
|
|
begin
|
|
|
|
with zroqryCredores.SQL do
|
|
begin
|
|
Clear;
|
|
Add('select * from chg_empresas where id_empresa in (');
|
|
Add('select id_empresa from chg_titulos where id_devedor = ' +
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString + ' )');
|
|
end;
|
|
zroqryCredores.Open;
|
|
|
|
ShowModal;
|
|
if ModalResult = mrOk then
|
|
begin
|
|
if zroqryCredores.IsEmpty then
|
|
begin
|
|
MessageDlg('Não há titulos em aberto para constatar.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
relDados := TrelDados.Create(self);
|
|
with relDados do
|
|
begin
|
|
zROqry.SQL.Clear;
|
|
zROqry.SQL.Add('select');
|
|
zROqry.SQL.Add('*');
|
|
zROqry.SQL.Add('from chg_titulos');
|
|
zROqry.SQL.Add('where');
|
|
zROqry.SQL.Add('id_empresa = ' +
|
|
dtmSystem.tblCHGEmpresaID_EMPRESA.AsString);
|
|
zROqry.SQL.Add('and id_devedor = ' +
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString);
|
|
if not inc_baixados then
|
|
begin
|
|
zROqry.SQL.Add('and (tp_situacao = ' + QuotedStr('A') +
|
|
' or tp_situacao = ' + QuotedStr('AC') + ')');
|
|
end;
|
|
// zROqry.SQL.Add('and id_titulo in (' + id_titulos + ')');
|
|
zROqry.SQL.Add('order by dt_vencimento, vl_titulo');
|
|
zROqry.Open;
|
|
// RLLabel1.Caption := RLLabel1.Caption + DateToStr(dtp_atrasorecalc.Date);
|
|
// RLLabel1.Left := floor(frbnd_dados.Width / 2) -
|
|
// floor(RLLabel1.Width / 2);
|
|
end;
|
|
relDados.RLReport1.Preview();
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.mnuQuebraAcordoClick(Sender: TObject);
|
|
var
|
|
str_help: string;
|
|
i: Integer;
|
|
begin
|
|
inherited;
|
|
if MessageDlg('Deseja realmente quebrar o acordo selecionado?' +
|
|
' Esta opção ira apenas desvincular os títulos originais aos parcelamentos.',
|
|
mtWarning, [mbYes, mbNo], 0) = mrYes then
|
|
begin
|
|
ZReadOnlyQuery1.SQL.Text := 'SELECT * FROM SYS_ACORDOS WHERE ID_ACORDO = ' +
|
|
dtmSystem.zroQryAcordosID_ACORDO.AsString;
|
|
ZReadOnlyQuery1.Open;
|
|
ZReadOnlyQuery1.First;
|
|
str_help := 'Antes de deletar:' + sLineBreak;
|
|
while not ZReadOnlyQuery1.Eof do
|
|
begin
|
|
for i := 0 to ZReadOnlyQuery1.Fields.Count - 1 do
|
|
begin
|
|
str_help := str_help + ZReadOnlyQuery1.Fields[i].FieldName + ': ' +
|
|
ZReadOnlyQuery1.Fields[i].AsString + sLineBreak;
|
|
end;
|
|
ZReadOnlyQuery1.Next;
|
|
end;
|
|
dtmSystem.tblLog.Append;
|
|
dtmSystem.tblLogTX_TABELA.AsString := 'SYS_ACORDOS';
|
|
dtmSystem.tblLogID_REGISTRO.AsInteger :=
|
|
dtmSystem.zroQryAcordosID_ITEM.AsInteger;
|
|
dtmSystem.tblLogTX_ACAO.AsString := 'delete';
|
|
dtmSystem.tblLogTL_ACAO.AsString := str_help;
|
|
dtmSystem.tblLog.Post;
|
|
dtmSystem.ZSQLProcessorAcordos.Script.Text :=
|
|
'DELETE FROM SYS_ACORDOS WHERE ID_ACORDO = ' +
|
|
dtmSystem.zroQryAcordosID_ACORDO.AsString;
|
|
dtmSystem.ZSQLProcessorAcordos.Execute;
|
|
dtmSystem.zroQryAcordos.Refresh;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.mnuretirarClick(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
for i := 0 to lv_titulos.Items.Count - 1 do
|
|
begin
|
|
lv_titulos.Items[i].Checked := false;
|
|
|
|
end;
|
|
qtde_titulos := 0;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.mnu_fichahistClick(Sender: TObject);
|
|
begin
|
|
with TconfFichaHistorico.Create(self) do
|
|
begin
|
|
id_devedor := dtsDB.DataSet.FieldByName('id_devedor').AsString;
|
|
ShowModal;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.mnu_incluirClick(Sender: TObject);
|
|
var
|
|
i: Integer;
|
|
begin
|
|
for i := 0 to lv_titulos.Items.Count - 1 do
|
|
begin
|
|
lv_titulos.Items[i].Checked := True;
|
|
|
|
end;
|
|
qtde_titulos := lv_titulos.Items.Count;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TcadDevedores.navenderecosBeforeAction(Sender: TObject;
|
|
Button: TNavigateBtn);
|
|
begin
|
|
// acontece sempre antes de qualquer ação do navigator
|
|
// primeiro o meu código, depois o obtido pela herança
|
|
case Button of
|
|
nbFirst, nbPrior, nbNext, nbLast, nbInsert, nbRefresh:
|
|
if navenderecos.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
nbPost:
|
|
begin
|
|
if dbedt_logradouro.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor preencha o nome da rua.', mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
if dbedt_num.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor preencha um número para o endereço.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
if dblucmbox_uf.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor indique o Estado do enderço.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
if dblucmbox_cidade.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor indique a Cidade do endereço.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
// SelectNext(ActiveControl as TWinControl, True, True);
|
|
end;
|
|
|
|
nbDelete:
|
|
begin
|
|
if navenderecos.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
if MessageDlg('Deseja apagar este registro?', mtConfirmation,
|
|
[mbYes, mbNo], 0) = mrNo then
|
|
abort;
|
|
|
|
try
|
|
dtsEnderecos.DataSet.Delete;
|
|
except
|
|
showmessage
|
|
('Este registro está sendo utilizado pelo sistema ou contém dependências e não pode ser apagado');
|
|
end;
|
|
|
|
abort;
|
|
end;
|
|
|
|
nbCancel:
|
|
if MessageDlg('Deseja cancelar as modificações?', mtConfirmation,
|
|
[mbYes, mbNo], 0) = mrNo then
|
|
abort;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.navHistoricoBeforeAction(Sender: TObject;
|
|
Button: TNavigateBtn);
|
|
var
|
|
string_helper: string;
|
|
begin
|
|
// inherited;
|
|
if Button = nbPost then
|
|
begin
|
|
if dblucb_providencia.keyvalue < 0 then
|
|
begin
|
|
MessageDlg('Por favor escolha uma providência a ser lançada.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
if dtsHistorico.State in [dsInsert] then
|
|
begin
|
|
if MessageDlg
|
|
('Esta inclusão de histórico irá retirar este devedor de qualquer agendamento previamente realizado.'
|
|
+ ' Deseja continuar?', mtWarning, mbYesNo, 0) = mrNo then
|
|
begin
|
|
abort;
|
|
end;
|
|
with zroqryProvAgend do
|
|
begin
|
|
SQL.Clear;
|
|
SQL.Add('select * from chg_providencias where tp_forcaagenda = ' +
|
|
QuotedStr('Sim') + ' and id_providencia = ' +
|
|
dtmSystem.tblProvidenciasID_PROVIDENCIA.AsString);
|
|
Open;
|
|
end;
|
|
if (zroqryProvAgend.RecordCount = 1) and (cb_agendahist.Checked = false)
|
|
then
|
|
begin
|
|
MessageDlg
|
|
('Esta providência exige que você agende o devedor. Por favor agende-o.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
if cb_agendahist.Checked then
|
|
begin
|
|
if dblucb_agendacobhist.keyvalue < 0 then
|
|
begin
|
|
MessageDlg('Por favor escolha o cobrador ao qual será agendado.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
// if MessageDlg
|
|
// ('Você está selecionando um horário para agendamento menor que a hora atual. Por favor verifique o horário do agendamento.',
|
|
// mtWarning, mbYesNo, 0) = mrNo then
|
|
// begin
|
|
// abort;
|
|
// end;
|
|
if (dtp_agendahorahist.Time < Timeof(Now)) and
|
|
(dtp_agendadatahist.Date <= dateof(Now)) then
|
|
begin
|
|
MessageDlg
|
|
('Você está selecionando um horário para agendamento menor que a hora atual.',
|
|
mtWarning, mbYesNo, 0);
|
|
abort;
|
|
end;
|
|
end;
|
|
end;
|
|
with dtmSystem do
|
|
begin
|
|
if not(tblAgenda.Active) then
|
|
begin
|
|
tblAgenda.Open;
|
|
end;
|
|
tblAgenda.Refresh;
|
|
while tblAgenda.Locate('ID_DEVEDOR;TP_SITUACAO',
|
|
VarArrayOf([dtsDevedores.DataSet.FieldByName('ID_DEVEDOR')
|
|
.AsInteger, 'A']), []) do
|
|
begin
|
|
tblAgenda.Edit;
|
|
tblAgendaTP_SITUACAO.AsString := 'B';
|
|
tblAgenda.Post;
|
|
end;
|
|
end;
|
|
if cb_agendahist.Checked then
|
|
begin
|
|
with dtmSystem do
|
|
begin
|
|
tblAgenda.Append;
|
|
tblAgendaID_COBRADOR.AsInteger := dblucb_agendacobhist.keyvalue;
|
|
tblAgendaID_DEVEDOR.AsInteger :=
|
|
dtsDB.DataSet.FieldByName('ID_DEVEDOR').AsInteger;
|
|
tblAgendaDT_AGENDADA.AsDateTime := dtp_agendadatahist.Date;
|
|
tblAgendaHR_AGENDADA.AsDateTime := dtp_agendahorahist.Time;
|
|
tblAgendaDT_QUE_AGENDOU.AsDateTime := Now;
|
|
tblAgendaQUEM_AGENDOU.AsInteger := dtmSystem.id_usuario;
|
|
tblAgenda.Post;
|
|
|
|
end;
|
|
string_helper := 'Agendado para o dia ' +
|
|
DateToStr(dtp_agendadatahist.Date) + ' no horário ' +
|
|
timetostr(dtp_agendahorahist.Time) + ' para o cobrador ' +
|
|
dblucb_agendacobhist.Text;
|
|
dtp_agendadatahist.Date := dateof(Now);
|
|
dtp_agendahorahist.Time := Timeof(Now);
|
|
// end;
|
|
end;
|
|
with dtmSystem do
|
|
begin
|
|
if not tblCampanhaDevedores.Active then
|
|
begin
|
|
tblCampanhaDevedores.Open;
|
|
end;
|
|
|
|
qryCampanha.SQL.Clear;
|
|
qryCampanha.SQL.Text :=
|
|
'select cd.*, c.tx_nome from chg_campanhas_devedores cd left join chg_campanhas c on cd.id_campanha = c.id_campanha where id_devedor = '
|
|
+ dtmSystem.tblDevedoresID_DEVEDOR.AsString;
|
|
qryCampanha.Open;
|
|
qryCampanha.First;
|
|
while not qryCampanha.Eof do
|
|
begin
|
|
tblLogCampanhas.Append;
|
|
dtmSystem.tblLogCampanhasID_CAMPANHA.AsInteger :=
|
|
qryCampanha.FieldByName('id_campanha').AsInteger;
|
|
dtmSystem.tblLogCampanhasTX_NOME_CAMPANHA.AsString :=
|
|
qryCampanha.FieldByName('tx_nome').AsString;
|
|
tblLogCampanhasID_DEVEDOR.AsInteger :=
|
|
qryCampanha.FieldByName('id_devedor').AsInteger;
|
|
tblLogCampanhasID_USUARIO.AsInteger := id_usuario;
|
|
tblLogCampanhasDT_TRANSF.AsDateTime := Now;
|
|
tblLogCampanhasTP_ACAO.AsString := 'apagou p/ agenda';
|
|
tblLogCampanhas.Post;
|
|
qryCampanha.Next;
|
|
end;
|
|
qryCampanha.Close;
|
|
|
|
dtmSystem.ZSQLProcessor1.Script.Text :=
|
|
'delete from chg_campanhas_devedores where id_devedor = ' +
|
|
QuotedStr(dtsDevedores.DataSet.FieldByName('ID_DEVEDOR').AsString);
|
|
dtmSystem.ZSQLProcessor1.Execute;
|
|
if cb_agendahist.Checked then
|
|
begin
|
|
dbmemo_box.lines.Add(string_helper);
|
|
cb_agendahist.Checked := false;
|
|
end;
|
|
tblHistoricoID_DEVEDOR.AsInteger :=
|
|
dtsDB.DataSet.FieldByName('ID_DEVEDOR').AsInteger;
|
|
tblHistoricoDT_CONTATO.AsDateTime := Now;
|
|
dtp_agendadatahist.Date := Date;
|
|
dtp_agendahorahist.Time := Timeof(Now);
|
|
dtp_diaagendamento.Date := Date;
|
|
dtp_horaagendamento.Date := Timeof(Now);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
if Button = nbCancel then
|
|
begin
|
|
if MessageDlg('Deseja realmente cancelar este histórico?', mtWarning,
|
|
[mbYes, mbNo], 0) = mrNo then
|
|
begin
|
|
abort;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.navPrincipalBeforeAction(Sender: TObject;
|
|
Button: TNavigateBtn);
|
|
var
|
|
resp: Integer;
|
|
begin
|
|
// verifica se o usuário realmente deseja remover um devedor
|
|
if Button = nbDelete then
|
|
begin
|
|
resp := MessageDlg
|
|
('Ao remover um devedor todos os dados relacionados a ele serão apagados.'
|
|
+ ' Deseja realmente realizar esta ação:', mtWarning, mbYesNo, 0);
|
|
if resp = mrNo then
|
|
begin
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
resp := MessageDlg('Você tem certeza absoluta disso?', mtWarning,
|
|
mbYesNo, 0);
|
|
if resp = mrNo then
|
|
begin
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
dtmSystem.tblDevedores.Delete;
|
|
abort;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if Button = nbPost then
|
|
begin
|
|
if dbrgrp_tpdevedor.Value = 'F' then
|
|
begin
|
|
dtmSystem.tblDevedoresCD_CNPJ.Clear;
|
|
end;
|
|
if dbrgrp_tpdevedor.Value = 'J' then
|
|
begin
|
|
dtmSystem.tblDevedoresCD_CPF.Clear;
|
|
end;
|
|
if dbedt_cpfcnpj.Text = '' then
|
|
begin
|
|
MessageDlg
|
|
('Por favor insira o CPF/CNPJ antes de finalizar o cadastro do Devedor.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
// dtmSystem.tblDevedoresID_COBRADOR.AsString := 'teste'; //teste de erro
|
|
end;
|
|
|
|
inherited;
|
|
end;
|
|
|
|
procedure TcadDevedores.navtelefonesBeforeAction(Sender: TObject;
|
|
Button: TNavigateBtn);
|
|
begin
|
|
// acontece sempre antes de qualquer ação do navigator
|
|
// primeiro o meu código, depois o obtido pela herança
|
|
case Button of
|
|
nbFirst, nbPrior, nbNext, nbLast, nbInsert, nbRefresh:
|
|
if navtelefones.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
nbPost:
|
|
begin
|
|
if dbedt_tel.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor preencha um número para o telefone.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
try
|
|
dbedt_tel.Text := dtmSystem.FormatTelefone(dbedt_tel.Text);
|
|
except
|
|
on E: Exception do
|
|
begin
|
|
MessageDlg(E.Message, mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
end;
|
|
if dbrg_tipotel.ItemIndex = -1 then
|
|
begin
|
|
MessageDlg('Por favor escolha o tipo de telefone.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
if (Length(dbedt_tel.Text) = 10) then
|
|
begin
|
|
dbrg_tipotel.ItemIndex := 1;
|
|
end;
|
|
|
|
if (Length(dbedt_tel.Text) = 9) then
|
|
begin
|
|
dbrg_tipotel.ItemIndex := 0;
|
|
end;
|
|
|
|
// SelectNext(ActiveControl as TWinControl, True, True);
|
|
end;
|
|
|
|
nbDelete:
|
|
begin
|
|
if navtelefones.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
if MessageDlg('Deseja apagar este registro?', mtConfirmation,
|
|
[mbYes, mbNo], 0) = mrNo then
|
|
abort;
|
|
|
|
try
|
|
dtsTelefones.DataSet.Delete;
|
|
except
|
|
showmessage
|
|
('Este registro está sendo utilizado pelo sistema ou contém dependências e não pode ser apagado');
|
|
end;
|
|
|
|
abort;
|
|
end;
|
|
|
|
nbCancel:
|
|
if MessageDlg('Deseja cancelar as modificações?', mtConfirmation,
|
|
[mbYes, mbNo], 0) = mrNo then
|
|
abort;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.navtitulosBeforeAction(Sender: TObject;
|
|
Button: TNavigateBtn);
|
|
begin
|
|
|
|
case Button of
|
|
nbFirst, nbPrior, nbNext, nbLast, nbInsert, nbRefresh:
|
|
if navtitulos.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
nbPost:
|
|
begin
|
|
if dbedit_produto.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor insira um nome para o título.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
if dbedt_vltit.Text = '' then
|
|
begin
|
|
MessageDlg('Por favor insira um valor para o título.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
// for i := 0 to clb_empresas.Items.Count - 1 do
|
|
// begin
|
|
// if clb_empresas.Checked[i] then
|
|
// begin
|
|
// dtmSystem.tblCHGEmpresa.Locate('TX_NOME',
|
|
// clb_empresas.Items[i], []);
|
|
// if selected_id_chg_empresa <> -1 then
|
|
// begin
|
|
// dtmSystem.tblTitulosID_EMPRESA.AsInteger := selected_id_chg_empresa;
|
|
// end;
|
|
// dtmSystem.tblCHGEmpresaID_EMPRESA.AsString;
|
|
// end;
|
|
// end;
|
|
if DateToStr(rDBDateTimePicker1.Date) = '30/12/1899' then
|
|
begin
|
|
MessageDlg
|
|
('Por favor selecione uma data de vencimento para o título.',
|
|
mtWarning, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
if dtmSystem.tblTitulosID_EMPRESA.AsString = '' then
|
|
begin
|
|
MessageDlg('Por favor indique um Credor para o título.', mtWarning,
|
|
[mbOK], 0);
|
|
abort;
|
|
end;
|
|
// SelectNext(ActiveControl as TWinControl, True, True);
|
|
end;
|
|
|
|
nbDelete:
|
|
begin
|
|
if navtitulos.DataSource.State in [dsInsert, dsEdit] then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtConfirmation, [mbOK], 0);
|
|
abort;
|
|
end;
|
|
|
|
if MessageDlg('Deseja apagar este registro?', mtConfirmation,
|
|
[mbYes, mbNo], 0) = mrNo then
|
|
abort;
|
|
|
|
try
|
|
dtsTitulos.DataSet.Delete;
|
|
except
|
|
showmessage
|
|
('Este registro está sendo utilizado pelo sistema ou contém dependências e não pode ser apagado');
|
|
end;
|
|
|
|
abort;
|
|
end;
|
|
|
|
nbCancel:
|
|
begin
|
|
if MessageDlg('Deseja cancelar as modificações?', mtConfirmation,
|
|
[mbYes, mbNo], 0) = mrNo then
|
|
begin
|
|
abort;
|
|
end;
|
|
// if clb_empresas.Items.IndexOf
|
|
// (dtmSystem.tblCHGEmpresaTX_NOME.AsString) > -1 then
|
|
// begin
|
|
// clb_empresas.Checked
|
|
// [clb_empresas.Items.IndexOf(dtmSystem.tblCHGEmpresaTX_NOME.AsString)
|
|
// ] := false;
|
|
// // clb_empresas.Selected
|
|
// // [clb_empresas.Items.IndexOf(dtmSystem.tblCHGEmpresaTX_NOME.AsString)
|
|
// // ] := false;
|
|
// end;
|
|
// dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA',
|
|
// dtmSystem.tblTitulosID_EMPRESA.AsInteger, []);
|
|
// if clb_empresas.Items.IndexOf
|
|
// (dtmSystem.tblCHGEmpresaTX_NOME.AsString) > -1 then
|
|
// begin
|
|
// clb_empresas.Checked
|
|
// [clb_empresas.Items.IndexOf
|
|
// (dtmSystem.tblCHGEmpresaTX_NOME.AsString)] := True;
|
|
// // clb_empresas.Selected
|
|
// // [clb_empresas.Items.IndexOf(dtmSystem.tblCHGEmpresaTX_NOME.AsString)
|
|
// // ] := false;
|
|
// end;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.Panel1Enter(Sender: TObject);
|
|
begin
|
|
// dbrgrp_tpdevedor.SetFocus;
|
|
// dbrgrp_tpdevedor.ItemIndex := 0;
|
|
end;
|
|
|
|
procedure TcadDevedores.pcClientesChange(Sender: TObject);
|
|
var
|
|
// antes: TTime;
|
|
// estado_db1, estado_db2, estado_db3, estado_db4, estado_db5: Boolean;
|
|
i: Integer;
|
|
begin
|
|
// Screen.Cursor := crHourGlass;
|
|
// if (pagina <> 5) and (pagina <> 6) then
|
|
// begin
|
|
// estado_db := navPrincipal.Enabled;
|
|
// estado_db1 := navenderecos.Enabled;
|
|
// estado_db2 := navtelefones.Enabled;
|
|
// estado_db3 := navtitulos.Enabled;
|
|
// estado_db5 := navHistorico.Enabled;
|
|
// end;
|
|
if fechamento = 'fechamento' then
|
|
begin
|
|
pcClientes.TabIndex := pagina;
|
|
abort;
|
|
end;
|
|
if pcClientes.ActivePage = tabTitulos then
|
|
begin
|
|
dtmSystem.tblTitulos.SortType := stDescending;
|
|
end
|
|
else
|
|
begin
|
|
dtmSystem.tblTitulos.SortType := stAscending;
|
|
end;
|
|
if pcClientes.TabIndex = 6 then
|
|
begin
|
|
pcClientes.TabIndex := pagina;
|
|
abort;
|
|
end;
|
|
if (pagina = 5) then
|
|
begin
|
|
setlength(ids_tits_calc, queryListaTitulos.RecordCount);
|
|
for i := 0 to lv_titulos.Items.Count - 1 do
|
|
begin
|
|
if lv_titulos.Items[i].Checked then
|
|
begin
|
|
ids_tits_calc[i] := True;
|
|
end
|
|
else
|
|
begin
|
|
ids_tits_calc[i] := false;
|
|
end;
|
|
end;
|
|
end;
|
|
if (pcClientes.TabIndex = 5) or (pcClientes.TabIndex = 6) then
|
|
begin
|
|
if (dtsDB.DataSet.State in [dsInsert, dsEdit]) or
|
|
(dtsEnderecos.DataSet.State in [dsInsert, dsEdit]) or
|
|
(dtsTelefones.DataSet.State in [dsInsert, dsEdit]) or
|
|
(dtsTitulos.DataSet.State in [dsInsert, dsEdit]) or
|
|
(dtsHistorico.DataSet.State in [dsInsert, dsEdit]) or
|
|
(dtsEmail.DataSet.State in [dsInsert, dsEdit]) then
|
|
begin
|
|
MessageDlg
|
|
('Existem alterações pendentes, clique em CONFIRMAR ou CANCELAR.',
|
|
mtWarning, [mbOK], 0);
|
|
pcClientes.TabIndex := pagina;
|
|
abort;
|
|
end
|
|
else
|
|
begin
|
|
// navPrincipal.Enabled := false;
|
|
// navenderecos.Enabled := false;
|
|
// navtelefones.Enabled := false;
|
|
// navtitulos.Enabled := false;
|
|
// navHistorico.Enabled := false;
|
|
// GroupBox1.Enabled := false;
|
|
clb_beneficiarioscalculo.Clear;
|
|
|
|
qryConsulta.SQL.Text := 'select * from chg_empresas where id_empresa in '
|
|
+ '(select id_empresa from chg_titulos' +
|
|
' where (tp_situacao = ''A'' or tp_situacao = ''AC'') and (id_devedor = '
|
|
+ dtmSystem.tblDevedoresID_DEVEDOR.AsString + '))';
|
|
qryConsulta.Open;
|
|
qryConsulta.First;
|
|
setlength(id_emps_dev, qryConsulta.RecordCount);
|
|
while not qryConsulta.Eof do
|
|
begin
|
|
clb_beneficiarioscalculo.Items.Add(qryConsulta.FieldByName('TX_NOME')
|
|
.AsString);
|
|
id_emps_dev[qryConsulta.RecNo - 1] :=
|
|
qryConsulta.FieldByName('ID_EMPRESA').AsInteger;
|
|
qryConsulta.Next;
|
|
end;
|
|
if id_emp_calc <> -1 then
|
|
begin
|
|
clb_beneficiarioscalculo.Checked[id_emp_calc] := True;
|
|
end;
|
|
CriarLista;
|
|
if pagina <> 5 then
|
|
begin
|
|
if Length(ids_tits_calc) > 0 then
|
|
begin
|
|
for i := 0 to Length(ids_tits_calc) - 1 do
|
|
begin
|
|
lv_titulos.Items[i].Checked := ids_tits_calc[i];
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
// estado_db := navPrincipal.Enabled;
|
|
// navPrincipal.Enabled := false;
|
|
// GroupBox1.Enabled := false;
|
|
// if (dtmSystem.tblDevedores.RecordCount > 0) { and
|
|
// (not(dtsTitulos.State in [dsInsert])) } then
|
|
// begin
|
|
// qryConsulta.SQL.Clear;
|
|
// qryConsulta.SQL.Text := 'select * from chg_empresas where id_empresa in '
|
|
// + '(select id_empresa from chg_titulos' +
|
|
// ' where (tp_situacao = ''A'' or tp_situacao = ''AC'') and (id_devedor = '
|
|
// + dtmSystem.tblDevedoresID_DEVEDOR.AsString + '))';
|
|
//
|
|
// if not(qryConsulta.Active) then
|
|
// begin
|
|
// qryConsulta.Open;
|
|
// end;
|
|
// qryConsulta.First;
|
|
// clb_beneficiarioscalculo.Clear;
|
|
// while not qryConsulta.Eof do
|
|
// begin
|
|
// clb_beneficiarioscalculo.Items.Add(qryConsulta.FieldByName('TX_NOME')
|
|
// .AsString);
|
|
// qryConsulta.Next;
|
|
// end;
|
|
// end;
|
|
end
|
|
else
|
|
begin
|
|
// if dtmSystem.VerificarPermissao('DEVCBR.01') then
|
|
// begin
|
|
// navPrincipal.Enabled := estado_db;
|
|
// navenderecos.Enabled := estado_db;
|
|
// navtelefones.Enabled := estado_db;
|
|
// navtitulos.Enabled := estado_db;
|
|
// navHistorico.Enabled := estado_db;
|
|
// // end;
|
|
// GroupBox1.Enabled := estado_db;
|
|
end;
|
|
if pcClientes.TabIndex = 5 then
|
|
begin
|
|
|
|
end;
|
|
|
|
pcDescontos.TabIndex := 0;
|
|
// if (pcClientes.TabIndex <> 5) and (pcClientes.TabIndex <> 6) then
|
|
// begin
|
|
// navPrincipal.Enabled := true;
|
|
// navenderecos.Enabled := true;
|
|
// navtelefones.Enabled := true;
|
|
// navtitulos.Enabled := true;
|
|
// navHistorico.Enabled := true;
|
|
// // end;
|
|
// GroupBox1.Enabled := true;
|
|
// end;
|
|
|
|
// navPrincipal.Enabled := dtmSystem.VerificarPermissao('DEVCBR.01');
|
|
// navenderecos.Enabled := dtmSystem.VerificarPermissao('DEVCBR.02');
|
|
// navtelefones.Enabled := dtmSystem.VerificarPermissao('DEVCBR.03');
|
|
// navtitulos.Enabled := dtmSystem.VerificarPermissao('DEVCBR.04');
|
|
// navHistorico.Enabled := dtmSystem.VerificarPermissao('DEVCBR.06');
|
|
// Screen.Cursor := crDefault;
|
|
end;
|
|
|
|
procedure TcadDevedores.pcClientesChanging(Sender: TObject;
|
|
var AllowChange: Boolean);
|
|
begin
|
|
pagina := pcClientes.TabIndex;
|
|
|
|
end;
|
|
|
|
procedure TcadDevedores.PopupMenu1Popup(Sender: TObject);
|
|
var
|
|
Control: TControl;
|
|
begin
|
|
posi := Mouse.CursorPos;
|
|
Control := FindControlAtPos(posi);
|
|
cp_tel.Visible := false;
|
|
cp_telddd.Visible := false;
|
|
if Control is TDBEdit then
|
|
begin
|
|
if ((Control as TDBEdit).DataSource = dtsTelefones) and
|
|
(((Control as TDBEdit).DataField = 'NR_DDD') or
|
|
((Control as TDBEdit).DataField = 'NR_NUMERO')) then
|
|
begin
|
|
cp_tel.Visible := True;
|
|
cp_telddd.Visible := True;
|
|
end;
|
|
end;
|
|
if (Control is TDBGrid) then
|
|
begin
|
|
if (Control as TDBGrid).DataSource = dtsTelefones then
|
|
begin
|
|
cp_tel.Visible := True;
|
|
cp_telddd.Visible := True;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.queryListaTitulosCalcFields(DataSet: TDataSet);
|
|
var
|
|
vl_corrigido, vl_cor_antes_desc, vl_nominal, vl_indices, pl_juros, pl_multa,
|
|
pl_indicador, pl_entrada, pl_encargos, regra_3, valor, juros, parcela,
|
|
par_extra, helper_indice, cred_fin, vl_cor_depois_desc: currency;
|
|
dividendo: double;
|
|
g: Integer;
|
|
begin
|
|
// inicialização de variáveis
|
|
juros := 0.00;
|
|
dividendo := 0.00;
|
|
|
|
// quantidade de dias de atraso
|
|
dtsCHGEmpresa.DataSet.Locate('ID_EMPRESA',
|
|
queryListaTitulosID_EMPRESA.AsString, []);
|
|
if not(dtsEmpresa.DataSet.Active) then
|
|
begin
|
|
dtsEmpresa.DataSet.Open;
|
|
end;
|
|
|
|
dtsEmpresa.DataSet.First;
|
|
if dateof(dtp_atrasorecalc.Date) >
|
|
dateof(queryListaTitulosDT_VENCIMENTO.AsDateTime) then
|
|
begin
|
|
queryListaTitulosDT_ATRASO.AsInteger := DaysBetween(dtp_atrasorecalc.Date,
|
|
queryListaTitulosDT_VENCIMENTO.AsDateTime);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosDT_ATRASO.AsInteger := 0;
|
|
end;
|
|
vl_nominal := queryListaTitulosVL_TITULO.AsCurrency;
|
|
queryListaTitulosVL_PRINCIPAL.AsCurrency := vl_nominal;
|
|
|
|
with dtmSystem do
|
|
begin
|
|
// verifica se o título pertence a algum atraso
|
|
dtsIndicadorFinanceiro.DataSet.Refresh;
|
|
dtsIndicadorFinanceiro.DataSet.Filter := 'ATRASO_MIN <=' +
|
|
inttostr(queryListaTitulosDT_ATRASO.AsInteger) + ' and ATRASO_MAX >= ' +
|
|
inttostr(queryListaTitulosDT_ATRASO.AsInteger) + ' and ID_CHG_EMPRESA = '
|
|
+ dtsCHGEmpresa.DataSet.FieldByName('ID_EMPRESA').AsString;
|
|
dtsIndicadorFinanceiro.DataSet.Filtered := True;
|
|
|
|
if dtsIndicadorFinanceiro.DataSet.IsEmpty then
|
|
begin
|
|
|
|
queryListaTitulosPR_INDICADOR.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
|
|
('PR_INDICADOR_FINANCEIRO').AsFloat;
|
|
// queryListaTitulosPR_INDICADOR.AsFloat := 0;
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosPR_INDICADOR.AsFloat :=
|
|
dtsIndicadorFinanceiro.DataSet.FieldByName('PR_INDICADOR').AsFloat;
|
|
end;
|
|
dtsFaixas.DataSet.Filtered := false;
|
|
dtsPoliticas.DataSet.Refresh;
|
|
dtsPoliticas.DataSet.Filter := 'DT_INICIO <= ' +
|
|
QuotedStr(FormatDateTime('YYYY-mm-dd', Date)) + ' and DT_FIM >= ' +
|
|
QuotedStr(FormatDateTime('YYYY-mm-dd', Date)) + ' and ID_EMPRESA = ' +
|
|
dtsCHGEmpresa.DataSet.FieldByName('ID_EMPRESA').AsString;
|
|
|
|
// número máx de parcelamento
|
|
queryListaTitulosNR_PARCELAS.AsInteger := dtsCHGEmpresa.DataSet.FieldByName
|
|
('NR_PARCELAS').AsInteger;
|
|
dtsFaixas.DataSet.Refresh;
|
|
if tblPoliticasID_POLITICA.AsString <> '' then
|
|
begin
|
|
|
|
dtsFaixas.DataSet.Filter := 'ATRASO_MIN <=' +
|
|
inttostr(queryListaTitulosDT_ATRASO.AsInteger) + ' and ATRASO_MAX >= ' +
|
|
inttostr(queryListaTitulosDT_ATRASO.AsInteger) + ' and ID_POLITICA = ' +
|
|
tblPoliticasID_POLITICA.AsString;
|
|
dtsFaixas.DataSet.Filtered := True;
|
|
if dtsFaixas.DataSet.IsEmpty then
|
|
begin
|
|
dtsFaixas.DataSet.Filtered := false;
|
|
dtsFaixas.DataSet.Filter := 'DT_MIN <=' +
|
|
QuotedStr(FormatDateTime('YYYY-mm-dd',
|
|
queryListaTitulosDT_VENCIMENTO.AsDateTime)) + ' and DT_MAX >= ' +
|
|
QuotedStr(FormatDateTime('YYYY-mm-dd',
|
|
queryListaTitulosDT_VENCIMENTO.AsDateTime)) + ' and ID_POLITICA = ' +
|
|
tblPoliticasID_POLITICA.AsString;
|
|
end;
|
|
|
|
end
|
|
else
|
|
begin
|
|
dtsFaixas.DataSet.Filter := 'DT_MIN <= ' +
|
|
QuotedStr(FormatDateTime('YYYY-mm-dd',
|
|
queryListaTitulosDT_VENCIMENTO.AsDateTime)) + ' and DT_MAX >= ' +
|
|
QuotedStr(FormatDateTime('YYYY-mm-dd',
|
|
queryListaTitulosDT_VENCIMENTO.AsDateTime)) +
|
|
' and ID_POLITICA = 999999999';
|
|
end;
|
|
|
|
dtsFaixas.DataSet.Filtered := True;
|
|
|
|
// porcentagens de cobrança e descontos
|
|
if dtsFaixas.DataSet.IsEmpty then
|
|
begin
|
|
queryListaTitulosPR_MULTA.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
|
|
('PR_MULTA').AsFloat;
|
|
queryListaTitulosPR_JUROS.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
|
|
('PR_JUROS').AsFloat;
|
|
queryListaTitulosNR_JUROS.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
|
|
('NR_JUROS').AsFloat;
|
|
queryListaTitulosTP_JUROS.AsString := dtsCHGEmpresa.DataSet.FieldByName
|
|
('TP_JUROS').AsString;
|
|
|
|
queryListaTitulosPR_QUITACAO_INDICADOR.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_QUIT_IND_FIN').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_PRINCIPAL.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_QUIT_PRIN').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_MULTA.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_QUIT_MULTA').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_JUROS.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_QUIT_JUROS').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_COR.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_QUIT_COR').AsFloat;
|
|
|
|
queryListaTitulosPR_PARCELA_INDICADOR.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_FINAN_IND_FIN').AsFloat;
|
|
queryListaTitulosPR_PARCELA_PRINCIPAL.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_FINAN_PRIN').AsFloat;
|
|
queryListaTitulosPR_PARCELA_MULTA.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_FINAN_MULTA').AsFloat;
|
|
queryListaTitulosPR_PARCELA_JUROS.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_FINAN_JUROS').AsFloat;
|
|
queryListaTitulosPR_PARCELA_COR.AsFloat :=
|
|
dtsCHGEmpresa.DataSet.FieldByName('PR_DESC_FINAN_COR').AsFloat;
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosPR_MULTA.AsFloat := dtsFaixas.DataSet.FieldByName
|
|
('PR_MULTA').AsFloat;
|
|
queryListaTitulosPR_JUROS.AsFloat := dtsFaixas.DataSet.FieldByName
|
|
('PR_JUROS').AsFloat;
|
|
queryListaTitulosNR_JUROS.AsFloat := dtsFaixas.DataSet.FieldByName
|
|
('NR_JUROS').AsFloat;
|
|
queryListaTitulosTP_JUROS.AsString := dtsFaixas.DataSet.FieldByName
|
|
('TP_JUROS').AsString;
|
|
|
|
queryListaTitulosPR_QUITACAO_INDICADOR.AsFloat :=
|
|
dtsFaixas.DataSet.FieldByName('PR_DESC_QUIT_IND_FIN').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_PRINCIPAL.AsFloat :=
|
|
dtsFaixas.DataSet.FieldByName('PR_DESC_QUIT_PRIN').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_MULTA.AsFloat :=
|
|
dtsFaixas.DataSet.FieldByName('PR_DESC_QUIT_MULTA').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_JUROS.AsFloat :=
|
|
dtsFaixas.DataSet.FieldByName('PR_DESC_QUIT_JUROS').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_COR.AsFloat := dtsFaixas.DataSet.FieldByName
|
|
('PR_DESC_QUIT_COR').AsFloat;
|
|
|
|
queryListaTitulosPR_PARCELA_INDICADOR.AsFloat :=
|
|
dtsFaixas.DataSet.FieldByName('PR_DESC_FINAN_IND_FIN').AsFloat;
|
|
queryListaTitulosPR_PARCELA_PRINCIPAL.AsFloat :=
|
|
dtsFaixas.DataSet.FieldByName('PR_DESC_FINAN_PRIN').AsFloat;
|
|
queryListaTitulosPR_PARCELA_MULTA.AsFloat := dtsFaixas.DataSet.FieldByName
|
|
('PR_DESC_FINAN_MULTA').AsFloat;
|
|
queryListaTitulosPR_PARCELA_JUROS.AsFloat := dtsFaixas.DataSet.FieldByName
|
|
('PR_DESC_FINAN_JUROS').AsFloat;
|
|
queryListaTitulosPR_PARCELA_COR.AsFloat := dtsFaixas.DataSet.FieldByName
|
|
('PR_DESC_FINAN_COR').AsFloat;
|
|
end;
|
|
|
|
// valor das parcelas dos encargos
|
|
if dateof(dtp_atrasorecalc.Date) >
|
|
dateof(queryListaTitulosDT_VENCIMENTO.AsDateTime) then
|
|
begin
|
|
pl_indicador := vl_nominal *
|
|
(queryListaTitulosPR_INDICADOR.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
pl_indicador := 0;
|
|
end;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency := pl_indicador;
|
|
if queryListaTitulosTP_JUROS.AsString = 'P' then
|
|
begin
|
|
pl_juros := vl_nominal * ((queryListaTitulosPR_JUROS.AsFloat / 30) / 100)
|
|
* queryListaTitulosDT_ATRASO.AsInteger;
|
|
end
|
|
else
|
|
begin
|
|
pl_juros := queryListaTitulosNR_JUROS.AsFloat *
|
|
queryListaTitulosDT_ATRASO.AsInteger;
|
|
end;
|
|
queryListaTitulosVL_JUROS.AsCurrency := pl_juros;
|
|
|
|
if dateof(dtp_atrasorecalc.Date) >
|
|
dateof(queryListaTitulosDT_VENCIMENTO.AsDateTime) then
|
|
begin
|
|
pl_multa := vl_nominal * (queryListaTitulosPR_MULTA.AsFloat / 100);
|
|
end {
|
|
else
|
|
begin
|
|
pl_multa := 0;
|
|
end };
|
|
|
|
if ((dtp_atrasorecalc.Date) <= (queryListaTitulosDT_VENCIMENTO.AsDateTime))
|
|
or (cb_nmulta.Checked) then
|
|
begin
|
|
pl_multa := 0;
|
|
end;
|
|
|
|
queryListaTitulosVL_MULTA.AsCurrency := pl_multa;
|
|
|
|
pl_encargos := pl_multa + pl_juros + pl_indicador + vl_indices;
|
|
|
|
// valor encargos
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency := pl_encargos;
|
|
|
|
vl_corrigido := vl_nominal + pl_encargos;
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency := vl_corrigido;
|
|
vl_cor_antes_desc := vl_corrigido;
|
|
|
|
// if cb_nmulta.Checked then
|
|
// begin
|
|
// pl_encargos := pl_encargos - pl_multa;
|
|
// vl_corrigido := vl_nominal + pl_encargos;
|
|
// queryListaTitulosVL_CORRIGIDO.AsCurrency := vl_corrigido;
|
|
// end;
|
|
|
|
// // valor encargos
|
|
// queryListaTitulosVL_ENCARGOS.AsCurrency := pl_encargos;
|
|
|
|
// porcentagem da entrada
|
|
queryListaTitulosPR_ENTRADA_MIN.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
|
|
('PR_ENTRADA_MIN').AsFloat;
|
|
queryListaTitulosPR_ENTRADA_MAX.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
|
|
('PR_ENTRADA_MAX').AsFloat;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
pl_entrada := StrToCurr(edt_excentrada.Text);
|
|
if qtde_titulos <> 0 then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := pl_entrada / qtde_titulos;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PO' then
|
|
// entrada em porcentagem
|
|
begin
|
|
// queryListaTitulosPR_ENTRADA.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
|
|
// ('PR_ENTRADA').AsFloat;
|
|
queryListaTitulosPR_ENTRADA.AsFloat := strtofloat(edt_prentrada.Text);
|
|
pl_entrada := vl_corrigido *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := pl_entrada;
|
|
end;
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PA' then
|
|
// entrada = parcela
|
|
begin
|
|
pl_entrada := 0;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := pl_entrada;
|
|
end;
|
|
end;
|
|
|
|
dtsIndicadorFinanceiro.DataSet.Filtered := false;
|
|
dtsPoliticas.DataSet.Filtered := false;
|
|
dtsFaixas.DataSet.Filtered := false;
|
|
end;
|
|
|
|
// Descontos sobre Quitar
|
|
if strtofloat(edt_indquitar.Text) > queryListaTitulosPR_QUITACAO_INDICADOR.AsFloat
|
|
then
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_IND.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency *
|
|
(queryListaTitulosPR_QUITACAO_INDICADOR.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_IND.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency *
|
|
(strtofloat(edt_indquitar.Text) / 100);
|
|
end;
|
|
if strtofloat(edt_principalquitar.Text) >
|
|
queryListaTitulosPR_QUITACAO_PRINCIPAL.AsFloat then
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency *
|
|
(queryListaTitulosPR_QUITACAO_PRINCIPAL.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency *
|
|
(strtofloat(edt_principalquitar.Text) / 100);
|
|
end;
|
|
if strtofloat(edt_multasquitar.Text) > queryListaTitulosPR_QUITACAO_MULTA.AsFloat
|
|
then
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency :=
|
|
queryListaTitulosVL_MULTA.AsCurrency *
|
|
(queryListaTitulosPR_QUITACAO_MULTA.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency :=
|
|
queryListaTitulosVL_MULTA.AsCurrency *
|
|
(strtofloat(edt_multasquitar.Text) / 100);
|
|
end;
|
|
if strtofloat(edt_jurosquitar.Text) > queryListaTitulosPR_QUITACAO_JUROS.AsFloat
|
|
then
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency *
|
|
(queryListaTitulosPR_QUITACAO_JUROS.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency *
|
|
(strtofloat(edt_jurosquitar.Text) / 100);
|
|
end;
|
|
|
|
// Descontos sobre Parcelar
|
|
if strtofloat(edt_indparcelas.Text) > queryListaTitulosPR_PARCELA_INDICADOR.AsFloat
|
|
then
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_IND.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency *
|
|
(queryListaTitulosPR_PARCELA_INDICADOR.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_IND.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency *
|
|
(strtofloat(edt_indparcelas.Text) / 100);
|
|
end;
|
|
if strtofloat(edt_principalparcelas.Text) >
|
|
queryListaTitulosPR_PARCELA_PRINCIPAL.AsFloat then
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency *
|
|
(queryListaTitulosPR_PARCELA_PRINCIPAL.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency *
|
|
(strtofloat(edt_principalparcelas.Text) / 100);
|
|
end;
|
|
if strtofloat(edt_multasparcelas.Text) > queryListaTitulosPR_PARCELA_MULTA.AsFloat
|
|
then
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency :=
|
|
queryListaTitulosVL_MULTA.AsCurrency *
|
|
(queryListaTitulosPR_PARCELA_MULTA.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency :=
|
|
queryListaTitulosVL_MULTA.AsCurrency *
|
|
(strtofloat(edt_multasparcelas.Text) / 100);
|
|
end;
|
|
if strtofloat(edt_jurosparcelas.Text) > queryListaTitulosPR_PARCELA_JUROS.AsFloat
|
|
then
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency *
|
|
(queryListaTitulosPR_PARCELA_JUROS.AsFloat / 100);
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency *
|
|
(strtofloat(edt_jurosparcelas.Text) / 100);
|
|
end;
|
|
queryListaTitulosVL_DESC_IND.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency;
|
|
queryListaTitulosVL_DESC_PRIN.AsCurrency :=
|
|
queryListaTitulosVL_PRINCIPAL.AsCurrency;
|
|
queryListaTitulosVL_DESC_MULTA.AsCurrency :=
|
|
queryListaTitulosVL_MULTA.AsCurrency;
|
|
queryListaTitulosVL_DESC_JUROS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency;
|
|
// valores depois dos descontos aplicados
|
|
if (cb_descquit.Checked) then
|
|
begin
|
|
queryListaTitulosVL_DESC_IND.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency -
|
|
queryListaTitulosVL_DESC_QUIT_IND.AsCurrency;
|
|
queryListaTitulosVL_DESC_PRIN.AsCurrency :=
|
|
queryListaTitulosVL_PRINCIPAL.AsCurrency -
|
|
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency;
|
|
queryListaTitulosVL_DESC_MULTA.AsCurrency :=
|
|
queryListaTitulosVL_MULTA.AsCurrency -
|
|
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency;
|
|
queryListaTitulosVL_DESC_JUROS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency -
|
|
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency;
|
|
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_PRINCIPAL.AsCurrency +
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency -
|
|
(queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
|
|
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency +
|
|
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
|
|
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency);
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
if qtde_titulos <> 0 then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
/ qtde_titulos;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PO' then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PA' then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := 0;
|
|
end;
|
|
end;
|
|
// end;
|
|
end;
|
|
|
|
if (cb_descpar.Checked) and (strtoint(edt_nrparcelas.Text) >= 1) then
|
|
begin
|
|
queryListaTitulosVL_DESC_IND.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency -
|
|
queryListaTitulosVL_DESC_PAR_IND.AsCurrency;
|
|
queryListaTitulosVL_DESC_PRIN.AsCurrency :=
|
|
queryListaTitulosVL_PRINCIPAL.AsCurrency -
|
|
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency;
|
|
queryListaTitulosVL_DESC_MULTA.AsCurrency :=
|
|
queryListaTitulosVL_MULTA.AsCurrency - queryListaTitulosVL_DESC_PAR_MULTA.
|
|
AsCurrency;
|
|
queryListaTitulosVL_DESC_JUROS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency - queryListaTitulosVL_DESC_PAR_JUROS.
|
|
AsCurrency;
|
|
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_PRINCIPAL.AsCurrency +
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency -
|
|
(queryListaTitulosVL_DESC_PAR_IND.AsCurrency +
|
|
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency +
|
|
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency +
|
|
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency);
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
if qtde_titulos <> 0 then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
/ qtde_titulos;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PO' then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PA' then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := 0;
|
|
end;
|
|
end;
|
|
// end;
|
|
end;
|
|
// regra de 3 para ver o valor do desconto total dado
|
|
if vl_cor_antes_desc <> queryListaTitulosVL_CORRIGIDO.AsCurrency then
|
|
begin
|
|
regra_3 := vl_cor_antes_desc - queryListaTitulosVL_CORRIGIDO.AsCurrency;
|
|
edt_desctot.Text := formatfloat('0.##',
|
|
((regra_3 * 100) / vl_cor_antes_desc));
|
|
end
|
|
else
|
|
begin
|
|
edt_desctot.Text := '0';
|
|
end;
|
|
|
|
if cb_desc_quit_cor.Checked and (strtofloat(edt_corquitar.Text) > 0) then
|
|
begin
|
|
vl_cor_depois_desc := queryListaTitulosVL_CORRIGIDO.AsCurrency -
|
|
(queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(strtofloat(edt_corquitar.Text) / 100));
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency := vl_cor_depois_desc;
|
|
end;
|
|
|
|
if cb_desc_par_cor.Checked and (strtofloat(edt_corpar.Text) > 0) then
|
|
begin
|
|
vl_cor_depois_desc := queryListaTitulosVL_CORRIGIDO.AsCurrency -
|
|
(queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(strtofloat(edt_corpar.Text) / 100));
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency := vl_cor_depois_desc;
|
|
end;
|
|
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
if qtde_titulos <> 0 then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text) /
|
|
qtde_titulos;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PO' then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PA' then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := 0;
|
|
end;
|
|
end;
|
|
|
|
if (strtoint(edt_nrparcelas.Text) = 0) and (cb_formapag.ItemIndex = 1) then
|
|
begin
|
|
queryListaTitulosVL_EXTRAS.AsCurrency :=
|
|
(queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100));
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency +
|
|
(queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100));
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency +
|
|
(queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100));
|
|
end;
|
|
|
|
if (cbx_txextra.Checked) and (strtoint(edt_nrparcelas.Text) = 0) and
|
|
(StrToCurr(edt_txextra.Text) > 0) then
|
|
begin
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency + StrToCurr(edt_txextra.Text);
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency + StrToCurr(edt_txextra.Text);
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + StrToCurr(edt_txextra.Text);
|
|
end;
|
|
|
|
// calcula valor das parcelas conforme tipo de pagamento
|
|
if (strtoint(edt_nrparcelas.Text) > 0) then
|
|
begin
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
case cb_formapag.ItemIndex of
|
|
0:
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_DIN.AsString = 'P' then
|
|
begin
|
|
CalcPrice;
|
|
end
|
|
else
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
// parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_CRED.AsString = 'P' then
|
|
begin
|
|
CalcPrice;
|
|
end
|
|
else
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end;
|
|
end;
|
|
3:
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_CHEQUE.AsString = 'P' then
|
|
begin
|
|
CalcPrice;
|
|
end
|
|
else
|
|
begin
|
|
// valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
// RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
// parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
// juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.AsFloat / 100);
|
|
// parcela := parcela + (parcela * juros);
|
|
// queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat /
|
|
100), strtoint(edt_nrparcelas.Text)))));
|
|
|
|
// parcela := ((valor * juros) / dividendo);
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end;
|
|
end;
|
|
end;
|
|
// if dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.AsFloat > 0 then
|
|
// begin
|
|
// valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
// RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
//
|
|
// juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.AsFloat / 100);
|
|
//
|
|
// dividendo :=
|
|
// (1 - (1 / (power(1 + (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.AsFloat
|
|
// / 100), strtoint(edt_nrparcelas.Text)))));
|
|
//
|
|
// parcela := ((valor * juros) / dividendo);
|
|
// queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
// end
|
|
// else
|
|
// begin
|
|
// valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
// RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
// parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
// queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
// end;
|
|
// if cb_formapag.ItemIndex = 2 then
|
|
// begin
|
|
// parcela := queryListaTitulosVL_PARCELA.AsCurrency;
|
|
// case strtoint(edt_nrparcelas.Text) of
|
|
// 1:
|
|
// begin
|
|
// juros := (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100);
|
|
// parcela := parcela + (parcela * juros);
|
|
// end;
|
|
// 2, 3:
|
|
// begin
|
|
// juros := (dtmSystem.tblEmpresaPR_CRED3.AsFloat / 100);
|
|
// parcela := parcela + (parcela * juros);
|
|
// end;
|
|
// 4, 5, 6:
|
|
// begin
|
|
// juros := (dtmSystem.tblEmpresaPR_CRED6.AsFloat / 100);
|
|
// parcela := parcela + (parcela * juros);
|
|
// end;
|
|
// 7, 8, 9, 10, 11, 12:
|
|
// begin
|
|
// juros := (dtmSystem.tblEmpresaPR_CRED12.AsFloat / 100);
|
|
// parcela := parcela + (parcela * juros);
|
|
// end;
|
|
// end;
|
|
// queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
// end;
|
|
|
|
queryListaTitulosVL_EXTRAS.AsCurrency :=
|
|
((RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2) +
|
|
(strtoint(edt_nrparcelas.Text) * queryListaTitulosVL_PARCELA.AsCurrency)
|
|
) - queryListaTitulosVL_CORRIGIDO.AsCurrency);
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency +
|
|
queryListaTitulosVL_EXTRAS.AsCurrency;
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2) +
|
|
(strtoint(edt_nrparcelas.Text) *
|
|
queryListaTitulosVL_PARCELA.AsCurrency);
|
|
end
|
|
else
|
|
begin
|
|
case cb_formapag.ItemIndex of
|
|
0:
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_DIN.AsString = 'P' then
|
|
begin
|
|
CalcPrice;
|
|
end
|
|
else
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_ENTRADA.AsString = 'PO' then
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
strtoint(edt_nrparcelas.Text);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
end;
|
|
if dtmSystem.tblCHGEmpresaTP_ENTRADA.AsString = 'PA' then
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text) + 1);
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text) + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end;
|
|
end;
|
|
2:
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_CRED.AsString = 'P' then
|
|
begin
|
|
CalcPrice;
|
|
end
|
|
else
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_ENTRADA.AsString = 'PO' then
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text));
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
end;
|
|
if dtmSystem.tblCHGEmpresaTP_ENTRADA.AsString = 'PA' then
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text) + 1);
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text) + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end;
|
|
end;
|
|
3:
|
|
begin
|
|
if dtmSystem.tblCHGEmpresaTP_CHEQUE.AsString = 'P' then
|
|
begin
|
|
CalcPrice;
|
|
end
|
|
else
|
|
begin
|
|
if dtsCHGEmpresa.DataSet.FieldByName('TP_ENTRADA').AsString = 'PO'
|
|
then
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text));
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat
|
|
/ 100), strtoint(edt_nrparcelas.Text)))));
|
|
|
|
// parcela := ((valor * juros) / dividendo);
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text));
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
end
|
|
else
|
|
begin
|
|
valor := RoundTo(queryListaTitulosVL_CORRIGIDO.AsCurrency, -2) -
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2);
|
|
parcela := valor / (strtoint(edt_nrparcelas.Text) + 1);
|
|
if cbx_exjurosparcelar.Checked then
|
|
begin
|
|
juros := (strtofloat(edt_excjurosparcela.Text) / 100);
|
|
end
|
|
else
|
|
begin
|
|
juros := (dtmSystem.tblCHGEmpresaPR_JUROS_PARCELAR.
|
|
AsFloat / 100);
|
|
end;
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 + (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat
|
|
/ 100), strtoint(edt_nrparcelas.Text) + 1))));
|
|
|
|
// parcela := ((valor * juros) / dividendo);
|
|
parcela := parcela + (parcela * juros);
|
|
if (cbx_txextra.Checked) and (StrToCurr(edt_txextra.Text) > 0)
|
|
then
|
|
begin
|
|
par_extra := StrToCurr(edt_txextra.Text) /
|
|
(strtoint(edt_nrparcelas.Text) + 1);
|
|
parcela := parcela + par_extra;
|
|
queryListaTitulosVL_INDICADOR.AsCurrency :=
|
|
queryListaTitulosVL_INDICADOR.AsCurrency + par_extra;
|
|
end;
|
|
queryListaTitulosVL_PARCELA.AsCurrency := parcela;
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := parcela;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
|
|
queryListaTitulosVL_EXTRAS.AsCurrency :=
|
|
((RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2) +
|
|
(strtoint(edt_nrparcelas.Text) * queryListaTitulosVL_PARCELA.AsCurrency)
|
|
) - queryListaTitulosVL_CORRIGIDO.AsCurrency);
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency +
|
|
queryListaTitulosVL_EXTRAS.AsCurrency;
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2) +
|
|
(strtoint(edt_nrparcelas.Text) *
|
|
queryListaTitulosVL_PARCELA.AsCurrency);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.SetupHackedNavigator(const Navigator: TDBNavigator;
|
|
const Glyphs: TImageList; S: string; size: Integer);
|
|
const
|
|
Captions: array [TNavigateBtn] of string = ('Primeiro', 'Anterior', 'Próximo',
|
|
'Último', 'Adicionar', 'Excluir', 'Alterar', 'Confirmar', 'Cancelar',
|
|
'Atualizar', 'Aplicar Atualizações', 'Cancelar Atualizãções');
|
|
(* Captions : array[TNavigateBtn] of string =
|
|
('First', 'Prior', 'Next', 'Last', 'Insert',
|
|
'Delete', 'Edit', 'Post', 'Cancel', 'Refresh'); *)
|
|
Hints: array [TNavigateBtn] of string = ('Primeiro', 'Anterior', 'Próximo',
|
|
'Último', 'Adicionar', 'Apagar', 'Modificar', 'Confirmar', 'Cancelar',
|
|
'Atualizar', 'Aplicar Atualizações', 'Cancelar Atualizãções');
|
|
var
|
|
btn: TNavigateBtn;
|
|
begin
|
|
// função propriamente dita para "hackear" o navigator
|
|
for btn := Low(TNavigateBtn) to High(TNavigateBtn) do
|
|
with THackDBNavigator(Navigator).Buttons[btn] do
|
|
begin
|
|
// from the Captions const array
|
|
|
|
Hint := Hints[btn];
|
|
|
|
if LowerCase(S) = 's' then
|
|
begin
|
|
Caption := Captions[btn];
|
|
end;
|
|
|
|
// the number of images in the Glyph property
|
|
NumGlyphs := 1;
|
|
// Remove the old glyph.
|
|
Glyph := nil;
|
|
// Assign the custom one
|
|
Glyphs.GetBitmap(Integer(btn), Glyph);
|
|
// gylph above text
|
|
Layout := blGlyphTop;
|
|
|
|
Font.size := size;
|
|
Font.Style := Font.Style - [fsbold];
|
|
|
|
end;
|
|
end;
|
|
|
|
procedure TcadDevedores.up_fontememoClick(Sender: TObject; Button: TUDBtnType);
|
|
begin
|
|
mb_fechamento.Font.size := strtoint(edt_fontememo.Text);
|
|
end;
|
|
|
|
procedure TcadDevedores.WMMoving(var Msg: TWMMoving);
|
|
var
|
|
workArea: TRect;
|
|
begin
|
|
workArea := Screen.WorkareaRect;
|
|
|
|
with Msg.DragRect^ do
|
|
begin
|
|
if left < workArea.left then
|
|
OffsetRect(Msg.DragRect^, workArea.left - left, 0);
|
|
|
|
if Top < workArea.Top then
|
|
OffsetRect(Msg.DragRect^, 0, workArea.Top - Top);
|
|
|
|
if Right > workArea.Right then
|
|
OffsetRect(Msg.DragRect^, workArea.Right - Right, 0);
|
|
|
|
if Bottom > workArea.Bottom then
|
|
OffsetRect(Msg.DragRect^, 0, workArea.Bottom - Bottom);
|
|
end;
|
|
|
|
end;
|
|
|
|
end.
|