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.
 

8146 lines
278 KiB

unit ufrmAtendimento;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, DateUtils, System.win.ComObj,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, ZAbstractRODataset,
ZAbstractDataset, ZDataset, Vcl.StdCtrls, Vcl.Grids, Vcl.DBGrids, Vcl.Mask,
Vcl.DBCtrls, Vcl.ComCtrls, Vcl.ExtCtrls, rDBComponents, Vcl.CheckLst,
StrUtils, ClipBrd, System.MaskUtils, System.UITypes, System.Math,
Vcl.Menus, Vcl.Buttons, System.ImageList, Vcl.ImgList, ShellAPI,
DBDateTimePicker, RLReport, Datasnap.DBClient;
type
THackDBNavigator = class(TDBNavigator);
type
TfrmAtendimento = class(TForm)
gb_pesquisar: TGroupBox;
lbl_pesquisar: TLabel;
edt_campop: TEdit;
btn_pesquisar: TButton;
dbgrd_pesquisar: TDBGrid;
cbx_tiponome: TComboBox;
qryPesquisa: TZQuery;
dtsPesquisa: TDataSource;
gb_cabecalho: TGroupBox;
lbl_nomec: TLabel;
dbedt_nomec: TDBEdit;
dtsDevedor: TDataSource;
lbl_cpfcnpjc: TLabel;
dbedt_cpfcnpjc: TDBEdit;
gb_dados: TGroupBox;
pcDevedor: TPageControl;
tabCadastro: TTabSheet;
navdevedor: TDBNavigator;
dbedt_nome: TDBEdit;
dbedt_nomepai: TDBEdit;
lbl_nomepai: TLabel;
dbedt_nomemae: TDBEdit;
lbl_nomemae: TLabel;
lbl_nome: TLabel;
lbl_cpfcnpj: TLabel;
dbedt_cpfcnpj: TDBEdit;
lbl_rg: TLabel;
dbedt_rg: TDBEdit;
lbl_coddev: TLabel;
dbedt_coddev: TDBEdit;
lbl_datanasc: TLabel;
lbl_datacad: TLabel;
Panel1: TPanel;
dbrgrp_tpdevedor: TDBRadioGroup;
lbl_tppessoa: TLabel;
pnl_cadastro: TPanel;
tabEnderecos: TTabSheet;
pnl_enderecos: TPanel;
dbgrd_enderecos: TDBGrid;
dbmb_obsc: TDBMemo;
lbl_obs: TLabel;
lbl_rua: TLabel;
dbedt_rua: TDBEdit;
dtsEnderecos: TDataSource;
lbl_num: TLabel;
dbedt_num: TDBEdit;
lbl_comp: TLabel;
dbedt_comp: TDBEdit;
lbl_cep: TLabel;
dbedt_cep: TDBEdit;
lbl_bairro: TLabel;
dbedt_bairro: TDBEdit;
lbl_uf: TLabel;
dblucmbox_uf: TDBLookupComboBox;
lbl_cidade: TLabel;
dblucmbox_cidade: TDBLookupComboBox;
Panel2: TPanel;
dbrg_situacao: TDBRadioGroup;
Panel6: TPanel;
dbrg_ref: TDBRadioGroup;
Panel7: TPanel;
dbrg_tpend: TDBRadioGroup;
lbl_tpend: TLabel;
lbl_situacao: TLabel;
lbl_ref: TLabel;
navenderecos: TDBNavigator;
tabTelefones: TTabSheet;
pnl_telefones: TPanel;
dbgrd_tel: TDBGrid;
lbl_tel: TLabel;
dbedt_tel: TDBEdit;
lbl_desctel: TLabel;
dbedt_desctel: TDBEdit;
lbl_obstel: TLabel;
btn_clearmemo: TButton;
dbmem_tel: TDBMemo;
lbl_tipo: TLabel;
lbl_sittel: TLabel;
Panel3: TPanel;
dbrg_sittel: TDBRadioGroup;
Panel4: TPanel;
dbrg_tipotel: TDBRadioGroup;
navtelefones: TDBNavigator;
tabTitulos: TTabSheet;
pnl_titulos: TPanel;
dtsTelefones: TDataSource;
dbedit_produto: TDBEdit;
dbedt_codemp: TDBEdit;
dbedt_vltit: TDBEdit;
Label2: TLabel;
lbl_dataent: TLabel;
lbl_datavenc: TLabel;
lbl_empresas: TLabel;
lbl_sittit: TLabel;
lbl_tit: TLabel;
lbl_vltit: TLabel;
Panel5: TPanel;
dbrg_tit: TDBRadioGroup;
pnl_cor1: TPanel;
pnl_color2: TPanel;
pnl_color3: TPanel;
pnl_color4: TPanel;
pnl_color5: TPanel;
pnl_color6: TPanel;
pnl_color7: TPanel;
rDBDateTimePicker1: TrDBDateTimePicker;
rdbdt_entrada: TrDBDateTimePicker;
dbgrd_tit: TDBGrid;
tabHistorico: TTabSheet;
pnl_hist: TPanel;
dbgrd_historico: TDBGrid;
dbmemo_box: TDBMemo;
navtitulos: TDBNavigator;
navhistorico: TDBNavigator;
tabCalc: TTabSheet;
lv_titulos: TListView;
dtsListaTitulos: TDataSource;
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;
queryListaTitulosPR_ENTRADA: TFloatField;
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;
dbgrd_listtitulos: TDBGrid;
lbl_somatitulos: TLabel;
lbl_parcelamento: TLabel;
lbl_somaentrada: TLabel;
lbl_vlaquitar: TLabel;
lbl_extras: TLabel;
lbl_somajuros: TLabel;
lbl_somamulta: TLabel;
lbl_somaindicador: TLabel;
lbl_desctot: TLabel;
lbl_datapgmnto: TLabel;
edt_somatitulos: TEdit;
edt_nrparcelas: TEdit;
up_nrparcelas: TUpDown;
edt_somaentrada: TEdit;
edt_vlaquitar: TEdit;
edt_extras: TEdit;
edt_somajuros: TEdit;
edt_somamulta: TEdit;
edt_somaindicador: TEdit;
cb_nmulta: TCheckBox;
edt_desctot: TEdit;
dtp_atrasorecalc: TDateTimePicker;
lv_parcelas: TListView;
btn_fechamento: TButton;
ppmnu_copiar: TPopupMenu;
copiar_conteudo: TMenuItem;
dtsProtocolos: TDataSource;
dbgrd_protocolos: TDBGrid;
btn_verprotocolo: TButton;
tabFechamento: TTabSheet;
lv_prevtitulos: TListView;
btn_concluir: TButton;
lv_fechamento: TListView;
lbl_prevtitulos: TLabel;
lbl_vltotal: TLabel;
edt_vltotal: TEdit;
lbl_apagamento: TLabel;
lbl_dpagamento: TLabel;
cbx_excentrada: TCheckBox;
edt_excentrada: TEdit;
queryListaTitulosTP_DESPESA: TWideStringField;
queryListaTitulosVL_DESPESA: TCurrencyField;
dtsTitulos: TDataSource;
pnl_cheque: TPanel;
lbl_banco: TLabel;
lbl_nrcheque: TLabel;
lbl_motivo: TLabel;
dbedt_banco: TDBEdit;
dbedt_nrcheque: TDBEdit;
dbedt_motivo: TDBEdit;
dbcbx_tpcheque: TDBCheckBox;
pnl_despesa: TPanel;
dbrg_despesa: TDBRadioGroup;
lbl_tpdespesa: TLabel;
lbl_depesa: TLabel;
dbedt_despesa: TDBEdit;
dtsqryConsulta: TDataSource;
qryConsulta: TZQuery;
clb_beneficiarioscalculo: TCheckListBox;
lbl_beneficiarioscalculo: TLabel;
clb_indices: TCheckListBox;
lbl_indices: TLabel;
queryListaTitulosVL_INDICES: TCurrencyField;
Label1: TLabel;
edt_indices: TEdit;
btn_verrecibos: TButton;
queryConteudoRecibo: TZQuery;
lbl_formarecebimento: TLabel;
edt_formarecebimento: TEdit;
ImageList1: TImageList;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
edt_nrchequerecibo: TEdit;
edt_bancorecibo: TEdit;
edt_pracarecibo: TEdit;
lbl_obsrecibo: TLabel;
Label6: TLabel;
cb_formapag: TComboBox;
dtsHistAgenda: TDataSource;
ROqryHistAgenda: TZReadOnlyQuery;
queryListaTitulosVL_PARCELA: TCurrencyField;
cbx_despesas: TCheckBox;
queryListaTitulosTX_DESPESA: TStringField;
dtsDespesas: TDataSource;
pcTitDespesas: TPageControl;
tabTit: TTabSheet;
tabDespesas: TTabSheet;
navDespesas: TDBNavigator;
dbgrd_despesas: TDBGrid;
queryListaTitulosPR_JUROS_CHEQUE: TFloatField;
btn_amostra: TButton;
btn_acordoin: TButton;
btn_acordoout: TButton;
queryListaTitulosVL_EXTRAS: TCurrencyField;
dtsIndicadorFinanceiro: TDataSource;
dtsCHGEmpresa: TDataSource;
dtsEmpresa: TDataSource;
cbx_descindextras: TCheckBox;
cb_descindicesextras: TComboBox;
edt_descindextras: TEdit;
lbl_maxpar: TLabel;
popmnu_incluir: TPopupMenu;
mnu_incluir: TMenuItem;
mnuretirar: TMenuItem;
tabObs: TTabSheet;
queryListaTitulosPR_QUITACAO_COR: TFloatField;
queryListaTitulosPR_PARCELA_COR: TFloatField;
Label7: TLabel;
DBEdit2: TDBEdit;
Label8: TLabel;
DBEdit3: TDBEdit;
dbdtp_dtnasc: TDBDateTimePicker;
dbdtp_dtcad: TDBDateTimePicker;
lbl_providencias: TLabel;
dbgrd_providencias: TDBGrid;
lbl_prov: TLabel;
edt_prov: TEdit;
pb_atendimento: TProgressBar;
Label9: TLabel;
lbl_processo: TLabel;
dbedt_ddd: TDBEdit;
lbl_ddd: TLabel;
Label10: TLabel;
lbl_minentrada: TLabel;
edt_prentrada: TEdit;
ud_entrada: TUpDown;
lbl_maxentrada: TLabel;
queryListaTitulosPR_ENTRADA_MIN: TFloatField;
queryListaTitulosPR_ENTRADA_MAX: TFloatField;
mem_obsrecibo: TMemo;
cbx_txextra: TCheckBox;
edt_txextra: TEdit;
queryListaTitulosVL_REPASSE_BANCO: TCurrencyField;
queryListaTitulosVL_PRINCIPAL: TCurrencyField;
dbmem_titobs: TDBMemo;
lbl_titobs: TLabel;
cb_agendahist: TCheckBox;
Label11: TLabel;
dtp_agendadatahist: TDateTimePicker;
Label12: TLabel;
dtp_agendahorahist: TDateTimePicker;
Label13: TLabel;
dblucb_agendacobhist: TDBLookupComboBox;
Label14: TLabel;
dblucb_providencia: TDBLookupComboBox;
dtsHistorico: TDataSource;
dtsCobrador: TDataSource;
queryCobradores: TZQuery;
queryCobradoresID_USUARIO: TIntegerField;
queryCobradoresTX_NOME: TWideStringField;
pcDescontos: TPageControl;
tabQuitar: TTabSheet;
gb_descontosquit: TGroupBox;
lbl_indquitar: TLabel;
lbl_principalquitar: TLabel;
lbl_multasquitar: TLabel;
lbl_jurosquitar: TLabel;
lbl_maxindquit: TLabel;
lbl_maxprinquit: TLabel;
lbl_maxmultaquit: TLabel;
lbl_maxjurosquit: TLabel;
lbl_maxquitcor: 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_desc_quit_cor: TCheckBox;
edt_corquitar: TEdit;
ud_corquitar: TUpDown;
cb_descquit: TCheckBox;
tabParcelar: TTabSheet;
gb_descontospar: TGroupBox;
lbl_indparcelas: TLabel;
lbl_jurosparcelas: TLabel;
lbl_multasparcelas: TLabel;
lbl_principalparcelas: TLabel;
lbl_maxindpar: TLabel;
lbl_maxprinpar: TLabel;
lbl_maxmultapar: TLabel;
lbl_maxjurospar: TLabel;
lbl_maxparcor: 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_desc_par_cor: TCheckBox;
edt_corpar: TEdit;
ud_corpar: TUpDown;
cb_descpar: TCheckBox;
queryListaTitulosVL_RETIRADA_TAXA: TCurrencyField;
navEmail: TDBNavigator;
dtsEmail: TDataSource;
Label15: TLabel;
dbedt_email: TDBEdit;
dbgrd_email: TDBGrid;
edt_excjurosparcela: TEdit;
cbx_exjurosparcelar: TCheckBox;
DBGrid1: TDBGrid;
Label16: TLabel;
queryListaTitulosVL_DESC_IND: TCurrencyField;
queryListaTitulosVL_DESC_PRIN: TCurrencyField;
queryListaTitulosVL_DESC_MULTA: TCurrencyField;
queryListaTitulosVL_DESC_JUROS: TCurrencyField;
pnl_contatos: TPanel;
Label17: TLabel;
dblbl_contatos: TDBText;
cb_agendaatend: TCheckBox;
dtp_agatend: TDateTimePicker;
dblucb_agatend: TDBLookupComboBox;
dtph_agatend: TDateTimePicker;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Panel8: TPanel;
DBRadioGroup1: TDBRadioGroup;
Label21: TLabel;
zroqryRecibos: TZReadOnlyQuery;
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;
rotblRepasseFase: TZReadOnlyQuery;
rotblRepasseFaseID_FASE: TIntegerField;
rotblRepasseFasePR_PRINCIPAL: TFloatField;
rotblRepasseFasePR_JUROS: TFloatField;
rotblRepasseFasePR_MULTA: TFloatField;
rotblRepasseFasePR_ENCARGOS: TFloatField;
rotblRepasseFasePR_CORRIGIDO: TFloatField;
rotblRepasseFaseMIN_ATRASO: TIntegerField;
rotblRepasseFaseMAX_ATRASO: TIntegerField;
rotblRepasseFaseID_REPASSE: TIntegerField;
rotblRepasseFaseID_ULTIMO_USUARIO: TIntegerField;
rotblRepasseFaseDT_HORA_ULTIMA_ATT: TDateTimeField;
zroqryHelpRepasse: TZReadOnlyQuery;
dtsCDSTitulos: TDataSource;
cdsParcelas: TClientDataSet;
cdsParcelasid_parcela: TIntegerField;
dtsCDSParcelas: TDataSource;
cdsTitulos: TClientDataSet;
cdsTitulosID_TITULO: TIntegerField;
cdsTitulosID_DEVEDOR: TIntegerField;
cdsTitulosID_EMPRESA: TIntegerField;
cdsTitulosTX_PRODUTO: TStringField;
cdsTitulosVL_TITULO: TCurrencyField;
cdsTitulosDT_ENTRADA: TDateField;
cdsTitulosDT_VENCIMENTO: TDateField;
cdsTitulosTP_SITUACAO: TStringField;
cdsTitulosCD_DEVEDOR: TStringField;
cdsTitulosTP_CHEQUE: TStringField;
cdsTitulosID_BANCO: TIntegerField;
cdsTitulosTX_NRCHEQUE: TStringField;
cdsTitulosTP_MOTIVO: TStringField;
cdsTitulosVL_DESPESA: TCurrencyField;
cdsTitulosTP_DESPESA: TStringField;
cdsTitulosVL_MULTA: TCurrencyField;
cdsTitulosVL_JUROS: TCurrencyField;
cdsTitulosVL_ENCARGOS: TCurrencyField;
cdsTitulosVL_CORRIGIDO: TCurrencyField;
cdsTitulosDT_PAGAMENTO: TDateField;
cdsTitulosTX_OBS: TBlobField;
cdsTitulosID_ULTIMO_USUARIO: TIntegerField;
cdsTitulosDT_HORA_ULTIMA_ATT: TDateField;
cdsTitulosID_IMPLANTACAO: TIntegerField;
cdsTitulosDT_IMPLANTACAO: TDateField;
cdsTitulosQTDE_PARCELAS: TIntegerField;
cdsTitulosVL_DESC_PRINCIPAL: TCurrencyField;
cdsTitulosDT_EMISSAO_RECIBO: TDateField;
cdsTitulosVL_REPASSE_PRIN: TCurrencyField;
cdsTitulosVL_DESC_MULTA: TCurrencyField;
cdsTitulosVL_REPASSE_MULTA: TCurrencyField;
cdsTitulosVL_DESC_JUROS: TCurrencyField;
cdsTitulosVL_REPASSE_JUROS: TCurrencyField;
cdsTitulosVL_INDICADOR: TCurrencyField;
cdsTitulosVL_DESC_INDICADOR: TCurrencyField;
cdsTitulosVL_REPASSE_CORRIGIDO: TCurrencyField;
cdsTitulosTP_PRESTACAO: TStringField;
cdsTitulosVL_REPASSE_ENCARGOS: TCurrencyField;
Label22: TLabel;
dbedt_protocolo: TDBEdit;
btn_protocolo: TButton;
lbl_protocolo1: TLabel;
edt_protocolo1: TEdit;
lbl_protocolo: TLabel;
edt_protocolo: TEdit;
DBLookupComboBox1: TDBLookupComboBox;
Label23: TLabel;
N1: TMenuItem;
DevolverTtulos1: TMenuItem;
procedure btn_pesquisarClick(Sender: TObject);
procedure dbgrd_pesquisarDblClick(Sender: TObject);
procedure dtsDevedorDataChange(Sender: TObject; Field: TField);
procedure clb_empresasClickCheck(Sender: TObject);
procedure dbgrd_titCellClick(Column: TColumn);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure queryListaTitulosCalcFields(DataSet: TDataSet);
procedure edt_campopKeyPress(Sender: TObject; var Key: Char);
procedure lv_titulosChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
procedure edt_nrparcelasChange(Sender: TObject);
procedure cb_nmultaClick(Sender: TObject);
procedure cb_descquitClick(Sender: TObject);
procedure cb_descparClick(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 copiar_conteudoClick(Sender: TObject);
procedure btn_closeClick(Sender: TObject);
procedure dtp_atrasorecalcChange(Sender: TObject);
procedure btn_verprotocoloClick(Sender: TObject);
procedure cbx_descfixoClick(Sender: TObject);
procedure cbx_acrfixoClick(Sender: TObject);
procedure pcDevedorChanging(Sender: TObject; var AllowChange: Boolean);
procedure pcDevedorChange(Sender: TObject);
procedure btn_fechamentoClick(Sender: TObject);
procedure btn_concluirClick(Sender: TObject);
procedure cbx_excentradaClick(Sender: TObject);
procedure edt_excentradaKeyPress(Sender: TObject; var Key: Char);
procedure edt_descfixoKeyPress(Sender: TObject; var Key: Char);
procedure edt_excentradaChange(Sender: TObject);
procedure dtsTitulosDataChange(Sender: TObject; Field: TField);
procedure dtsTitulosStateChange(Sender: TObject);
procedure clb_beneficiarioscalculoClickCheck(Sender: TObject);
procedure clb_indicesClickCheck(Sender: TObject);
procedure btn_verrecibosClick(Sender: TObject);
procedure edt_reciboobsChange(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormCanResize(Sender: TObject; var NewWidth, NewHeight: Integer;
var Resize: Boolean);
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure cb_formapagChange(Sender: TObject);
procedure cbx_despesasClick(Sender: TObject);
procedure dtsDespesasStateChange(Sender: TObject);
procedure btn_amostraClick(Sender: TObject);
procedure btn_acordoinClick(Sender: TObject);
procedure btn_acordooutClick(Sender: TObject);
procedure cbx_descindextrasClick(Sender: TObject);
procedure cb_descindicesextrasChange(Sender: TObject);
procedure edt_descindextrasExit(Sender: TObject);
procedure edt_descindextrasKeyPress(Sender: TObject; var Key: Char);
procedure mnu_incluirClick(Sender: TObject);
procedure mnuretirarClick(Sender: TObject);
procedure edt_nrparcelasExit(Sender: TObject);
procedure lv_titulosItemChecked(Sender: TObject; Item: TListItem);
procedure dbgrd_enderecosTitleClick(Column: TColumn);
procedure dbgrd_telTitleClick(Column: TColumn);
procedure dbgrd_titTitleClick(Column: TColumn);
procedure dbgrd_despesasTitleClick(Column: TColumn);
procedure dbgrd_historicoTitleClick(Column: TColumn);
procedure dbgrd_listtitulosTitleClick(Column: TColumn);
procedure cb_desc_quit_corClick(Sender: TObject);
procedure cb_desc_par_corClick(Sender: TObject);
procedure edt_corquitarChange(Sender: TObject);
procedure edt_corparChange(Sender: TObject);
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_providenciasDblClick(Sender: TObject);
procedure dbgrd_titDrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
procedure edt_prentradaChange(Sender: TObject);
procedure navtelefonesBeforeAction(Sender: TObject; Button: TNavigateBtn);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure dtsEnderecosStateChange(Sender: TObject);
procedure edt_txextraChange(Sender: TObject);
procedure cbx_txextraClick(Sender: TObject);
procedure edt_txextraKeyPress(Sender: TObject; var Key: Char);
procedure up_nrparcelasClick(Sender: TObject; Button: TUDBtnType);
procedure navhistoricoBeforeAction(Sender: TObject; Button: TNavigateBtn);
procedure navtitulosBeforeAction(Sender: TObject; Button: TNavigateBtn);
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 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 dtsHistoricoStateChange(Sender: TObject);
procedure cb_agendahistClick(Sender: TObject);
procedure cbx_exjurosparcelarClick(Sender: TObject);
procedure edt_excjurosparcelaChange(Sender: TObject);
procedure edt_excjurosparcelaKeyPress(Sender: TObject; var Key: Char);
procedure dtsEmailStateChange(Sender: TObject);
procedure cb_agendaatendClick(Sender: TObject);
procedure dbedt_cpfcnpjcKeyPress(Sender: TObject; var Key: Char);
procedure dbrg_tipotelClick(Sender: TObject);
procedure dtsTelefonesDataChange(Sender: TObject; Field: TField);
procedure mnuQuebraAcordoClick(Sender: TObject);
procedure dtsDevedorStateChange(Sender: TObject);
procedure btn_protocoloClick(Sender: TObject);
procedure DevolverTtulos1Click(Sender: TObject);
private
FListViewOldWndProc: TWndMethod;
FlistViewOldWndProc2: TWndMethod;
atendimento: string;
pagina: Integer;
new_id_tit: Integer;
ficha_dev: Boolean;
nr_recibo: string;
id_emps_dev: array of Integer;
procedure ListViewNewWndProc(var Msg: TMessage);
procedure ListViewNewWndProc2(var Msg: TMessage);
procedure CriarLista;
procedure CalcValorParcelas;
procedure Att_campos;
// procedure CarregaProtocolo;
procedure SetupHackedNavigator(const Navigator: TDBNavigator;
const Glyphs: TImageList; S: string; size: Integer);
// procedure WMMoving(var Msg: TWMMoving); message WM_MOVING;
procedure OpenOfficeDocument(path: string);
procedure AdjustCheckListBox;
procedure CalcPrice;
procedure ChecaPermissoes;
procedure GuardaTitulos;
{ Private declarations }
public
data_parcelas: array of TDate;
old_id: Integer;
index_pagamento: Integer;
parcelas_pagamento: Integer;
id_recibo: string;
clpbrd: string;
forma_pagamento: string;
multi_form_pag: Boolean;
nome_titulos: string;
obs_despesas: string;
parcelamento: array of currency;
after_show: Boolean;
tipo_parcelamento: string;
desc_indices_extras: TStringList;
antes: TTime;
quant_titulos: Integer;
qtde_titulos: Integer;
id_empresa: Integer;
acordo_fora: Boolean;
acordo_emp: Integer;
acordo_fantasia: string;
id_emp: Integer;
entrada_credvista: double;
selected_id_chg_empresa: Integer;
str_tit: array of Integer;
id_emp_calc: Integer;
ids_tits_calc: array of Boolean;
qtde_parcelas: Integer;
fez_recibo: Boolean;
log_recibo: TStringList;
{ Public declarations }
end;
var
frmAtendimento: TfrmAtendimento;
implementation
{$R *.dfm}
uses udtmSystem, CommCtrl, ufrmFechamentoAtendimento, urelRecibo, uExtenso,
ufrmEscolheAcordo, urelFichaDivida, urelTeste, ufrmLiberaPermissao;
procedure TfrmAtendimento.AdjustCheckListBox;
var
i, nMaxWidth, nItemWidth: Integer;
begin
// 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 TfrmAtendimento.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, par_cor, quit_cor, minentrada,
maxentrada: Integer;
begin
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;
minentrada := 0;
maxentrada := 0;
quit_ind := 0;
quit_prin := 0;
quit_multa := 0;
quit_juros := 0;
quit_cor := 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.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;
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 TfrmAtendimento.btn_fechamentoClick(Sender: TObject);
var
i, j, k, p, h: Integer;
parcela, valor, juros, dividendo, somatotal, a, entrada_helper, vl_helper,
{ variáveis novas } p_juros, p_multa, p_encargos, p_desc, p_cor, t_juros,
t_multa, t_encargos, t_desc, t_desc_prin, t_cor { variáveis novas }
: currency;
n_marcou, selecionado: Boolean;
mes, ano: string;
begin
n_marcou := true;
for h := 0 to clb_beneficiarioscalculo.Items.Count - 1 do
begin
if clb_beneficiarioscalculo.Checked[h] then
begin
n_marcou := false;
dtmSystem.tblCHGEmpresa.Locate('TX_NOME',
clb_beneficiarioscalculo.Items[h], []);
id_emp := dtmSystem.tblCHGEmpresaID_EMPRESA.AsInteger;
break;
end;
end;
if n_marcou then
begin
Messagedlg('Por favor selecione a empresa a qual o cliente possúi débitos.',
mtWarning, [mbok], 0);
abort;
end;
selecionado := false;
for i := 0 to lv_titulos.Items.Count - 1 do
begin
if lv_titulos.Items[i].Checked = true then
begin
selecionado := true;
break;
end;
end;
if not selecionado then
begin
Messagedlg
('Por favor selecione um título primeiro para realizar o atendimento.',
mtWarning, [mbok], 0);
abort;
end;
if dtmSystem.tblEmpresaRepasse.IsEmpty then
begin
Showmessage('Esta empresa não possui nenhum repasse cadastrado.' +
' Por favor contate a administração.');
abort;
end
else
begin
mes := copy(FormatDateTime('yyyy-mm-dd', dtp_atrasorecalc.Date), 6, 2);
ano := copy(FormatDateTime('yyyy-mm-dd', dtp_atrasorecalc.Date), 1, 4);
if not dtmSystem.tblEmpresaRepasse.Locate('ID_MES;ID_ANO',
VarArrayOf([mes, ano]), []) then
begin
Showmessage
('Esta empresa não possui repasse para o mês da data de pagamento escolhida cadastrado.'
+ ' Por favor contate a administração.');
abort;
end;
end;
with TfrmFechamentoAtendimento.Create(self) do
begin
ShowModal;
if ModalResult = mrOk then
begin
atendimento := 'fechamento';
pcDevedor.TabIndex := 6;
btn_protocoloClick(self);
quant_titulos := 0;
qtde_parcelas := strtoint(edt_nrparcelas.Text);
if forma_pagamento = 'Q' then
begin
btn_acordoin.Enabled := false;
btn_acordoout.Enabled := false;
btn_verrecibos.Enabled := true;
btn_concluir.Enabled := false;
end
else
begin
btn_acordoin.Enabled := true;
btn_acordoout.Enabled := true;
btn_verrecibos.Enabled := false;
btn_concluir.Enabled := false;
end;
lv_prevtitulos.Clear;
lv_fechamento.Clear;
obs_despesas := '';
dtmSystem.tblConteudoRecibo.Open;
if dtmSystem.tblConteudoRecibo.RecordCount <> 0 then
begin
dtmSystem.tblConteudoRecibo.Close;
queryConteudoRecibo.Close;
queryConteudoRecibo.SQL.Text := 'delete from SYS_CONTEUDO_RECIBO';
queryConteudoRecibo.ExecSQL;
end;
dtmSystem.tblConteudoRecibo.Open;
for i := 0 to lv_titulos.Items.Count - 1 do
begin
if lv_titulos.Items[i].Checked then
begin
quant_titulos := quant_titulos + 1;
end;
end;
entrada_credvista := 0;
{ variáveis novas }
t_juros := 0;
t_multa := 0;
t_encargos := 0;
t_desc := 0;
t_desc_prin := 0;
t_cor := 0;
{ variáveis novas }
for i := 0 to lv_titulos.Items.Count - 1 do
begin
if lv_titulos.Items[i].Checked then
begin
queryListaTitulos.RecNo := i + 1;
obs_despesas := obs_despesas + queryListaTitulosTX_DESPESA.AsString;
with lv_prevtitulos.Items.Add do
begin
Caption := queryListaTitulos.FieldByName('TX_PRODUTO').AsString;
SubItems.Add(CurrToStrF(queryListaTitulos.FieldByName('VL_TITULO')
.AsCurrency, ffCurrency, 2, dtmSystem.CusFmt));
SubItems.Add
(CurrToStrF(queryListaTitulos.FieldByName('VL_CORRIGIDO')
.AsCurrency, ffCurrency, 2, dtmSystem.CusFmt));
{ variáveis novas }
t_juros := t_juros + queryListaTitulosVL_JUROS.AsCurrency -
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency -
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency;
t_multa := t_multa + queryListaTitulosVL_MULTA.AsCurrency -
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency -
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency;
t_encargos := t_encargos + queryListaTitulosVL_INDICADOR.AsCurrency
- queryListaTitulosVL_DESC_QUIT_IND.AsCurrency -
queryListaTitulosVL_DESC_PAR_IND.AsCurrency;
t_desc_prin := t_desc_prin + queryListaTitulosVL_DESC_QUIT_PRIN.
AsCurrency + queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency;
t_desc := t_desc + queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency +
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency;
t_cor := t_cor + queryListaTitulosVL_CORRIGIDO.AsCurrency
{ variáveis novas }
end;
if (forma_pagamento = 'Q') or (parcelas_pagamento = 2) then
begin
if index_pagamento = 3 then
begin
dtmSystem.tblPrCartao.Locate('NR_PARCELA', 1, []);
// entrada_credvista :=
// (((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
// length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) +
// ((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
// length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) *
// (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100))) -
// (StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
// length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])))) /
// quant_titulos;
entrada_credvista :=
(((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) +
((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) *
(dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100))) -
(StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])))) /
quant_titulos;
end;
dtmSystem.tblConteudoRecibo.Append;
dtmSystem.tblConteudoReciboTX_NOME.AsString :=
queryListaTitulosTX_PRODUTO.AsString;
dtmSystem.tblConteudoReciboVL_PRINCIPAL.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_TITULO.AsCurrency));
dtmSystem.tblConteudoReciboVL_JUROS.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_JUROS.AsCurrency));
dtmSystem.tblConteudoReciboVL_MULTA.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_MULTA.AsCurrency));
dtmSystem.tblConteudoReciboVL_ENCARGOS.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_INDICADOR.AsCurrency));
dtmSystem.tblConteudoReciboVL_DESCONTOS.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_QUIT_IND.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency));
if (index_pagamento = 1) and (parcelas_pagamento = 2) then
begin
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_CORRIGIDO.AsCurrency)) +
queryListaTitulosVL_ENTRADA.AsCurrency *
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100);
end
else
begin
if index_pagamento = 3 then
begin
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_CORRIGIDO.AsCurrency)) +
entrada_credvista;
end
else
begin
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_CORRIGIDO.AsCurrency));
end;
if (parcelas_pagamento = 2) then
begin
dtmSystem.tblConteudoReciboVL_DESCONTOS.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_PAR_IND.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency));
end;
end;
// dtmSystem.tblConteudoReciboVL_DESPESA.AsCurrency :=
// StrToCurr(formatfloat('0.##',
// queryListaTitulosVL_DESPESA.AsCurrency));
// dtmSystem.tblConteudoReciboTX_DEPESA.AsString :=
// queryListaTitulosTX_DESPESA.AsString;
if (index_pagamento = 1) and (parcelas_pagamento = 2) then
begin
dtmSystem.tblConteudoReciboVL_EXTRAS.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_INDICES.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_EXTRAS.AsCurrency)) +
queryListaTitulosVL_ENTRADA.AsCurrency *
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100) +
entrada_credvista;
end
else
begin
dtmSystem.tblConteudoReciboVL_EXTRAS.AsCurrency :=
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_INDICES.AsCurrency)) +
StrToCurr(formatfloat('0.##',
queryListaTitulosVL_EXTRAS.AsCurrency)) + entrada_credvista;
end;
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
queryListaTitulosDT_VENCIMENTO.AsDateTime;
dtmSystem.tblConteudoRecibo.Post;
end;
end;
end;
// if cbx_txextra.Checked then
// begin
// dtmSystem.tblConteudoRecibo.Append;
// dtmSystem.tblConteudoReciboTX_NOME.AsString := 'Taxa de Pagamento';
// dtmSystem.tblConteudoReciboVL_PRINCIPAL.AsCurrency :=
// StrToCurr(edt_txextra.Text);
// dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
// StrToCurr(edt_txextra.Text);
// dtmSystem.tblConteudoRecibo.Post;
// end;
lv_prevtitulos.Columns[1].Alignment := TAlignment.taRightJustify;
lv_prevtitulos.Columns[2].Alignment := TAlignment.taRightJustify;
if (forma_pagamento = 'Q') or (parcelas_pagamento = 2) then
begin
lv_fechamento.Visible := false;
lbl_dpagamento.Visible := false;
somatotal := 0;
if somatotal <> 0 then
begin
edt_vltotal.Text := CurrToStrF(somatotal, ffCurrency, 2,
dtmSystem.CusFmt);
end
else
begin
edt_vltotal.Text := edt_vlaquitar.Text;
end;
end;
if (forma_pagamento = 'P') then
begin
lv_fechamento.Visible := true;
lbl_dpagamento.Visible := true;
somatotal := 0;
entrada_helper := 0;
for j := 0 to strtoint(edt_nrparcelas.Text) do
begin
with lv_fechamento.Items.Add do
begin
// if parcelas_pagamento <> 2 then
// begin
if j = 0 then
begin
Caption := 'Entrada';
if index_pagamento = 1 then
begin
entrada_helper :=
StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]));
SubItems.Add
(CurrToStrF(entrada_helper + (entrada_helper *
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100)), ffCurrency, 2,
dtmSystem.CusFmt));
somatotal := somatotal + entrada_helper +
(entrada_helper *
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100));
end
else
begin
if index_pagamento = 3 then
begin
dtmSystem.tblPrCartao.Locate('NR_PARCELA', 1, []);
entrada_helper :=
StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '',
[rfReplaceAll]));
// SubItems.Add
// (CurrToStrF(entrada_helper + (entrada_helper *
// (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100)),
// ffCurrency, 2, dtmSystem.CusFmt));
// somatotal := somatotal + entrada_helper +
// (entrada_helper *
// (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100));
SubItems.Add
(CurrToStrF(entrada_helper + (entrada_helper *
(dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100)), ffCurrency,
2, dtmSystem.CusFmt));
somatotal := somatotal + entrada_helper +
(entrada_helper *
(dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100));
end
else
begin
SubItems.Add(edt_somaentrada.Text);
somatotal := somatotal +
(StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '',
[rfReplaceAll])));
end;
end;
SubItems.Add(DateToStr(data_parcelas[0]));
end
else
begin
if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])) = 0.00
then
begin
Caption := 'Parcela nº ' + inttostr(j) + '/' +
edt_nrparcelas.Text;
SubItems.Add(CurrToStrF(parcelamento[j - 1], ffCurrency, 2,
dtmSystem.CusFmt));
SubItems.Add(DateToStr(data_parcelas[j - 1]));
somatotal := somatotal + parcelamento[j - 1];
end
else
begin
Caption := 'Parcela nº ' + inttostr(j) + '/' +
edt_nrparcelas.Text;
SubItems.Add(CurrToStrF(parcelamento[j - 1], ffCurrency, 2,
dtmSystem.CusFmt));
SubItems.Add(DateToStr(data_parcelas[j]));
somatotal := somatotal + parcelamento[j - 1];
end;
end;
end;
end;
if somatotal <> 0 then
begin
edt_vltotal.Text := CurrToStrF(somatotal, ffCurrency, 2,
dtmSystem.CusFmt);
end
else
begin
edt_vltotal.Text := edt_vlaquitar.Text;
end;
if (parcelas_pagamento <> 2) then
begin
{ variáveis novas }
// if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
// length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])) <> 0.00
// then
// begin
// p_juros := p_juros / (lv_fechamento.Items.Count);
// p_multa := p_multa / (lv_fechamento.Items.Count);
// p_encargos := p_encargos / (lv_fechamento.Items.Count);
// p_desc := p_desc / (lv_fechamento.Items.Count);
// end
// else
// begin
// p_juros := p_juros / (lv_fechamento.Items.Count - 1);
// p_multa := p_multa / (lv_fechamento.Items.Count - 1);
// p_encargos := p_encargos / (lv_fechamento.Items.Count - 1);
// p_desc := p_desc / (lv_fechamento.Items.Count - 1);
// end;
{ variáveis novas }
for p := 0 to lv_fechamento.Items.Count - 1 do
begin
if p = 0 then
begin
if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])) <> 0.00
then
begin
dtmSystem.tblConteudoRecibo.Append;
dtmSystem.tblConteudoReciboTX_NOME.AsString := 'Entrada';
if index_pagamento = 1 then
begin
vl_helper :=
StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '',
[rfReplaceAll]));
p_juros := (vl_helper * t_juros) / t_cor;
p_multa := (vl_helper * t_multa) / t_cor;
p_encargos := (vl_helper * t_encargos) / t_cor;
p_desc := (vl_helper * t_desc_prin) / t_cor;
dtmSystem.tblConteudoReciboVL_PRINCIPAL.AsCurrency :=
vl_helper { variáveis novas } - p_juros - p_multa -
p_encargos + p_desc { variáveis novas };
dtmSystem.tblConteudoReciboVL_EXTRAS.AsCurrency :=
(vl_helper * (dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100));
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
vl_helper +
(vl_helper * (dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100));
end
else
begin
if index_pagamento = 3 then
begin
vl_helper :=
StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '',
[rfReplaceAll]));
p_juros := (vl_helper * t_juros) / t_cor;
p_multa := (vl_helper * t_multa) / t_cor;
p_encargos := (vl_helper * t_encargos) / t_cor;
p_desc := (vl_helper * t_desc_prin) / t_cor;
dtmSystem.tblConteudoReciboVL_PRINCIPAL.AsCurrency :=
vl_helper { variáveis novas } - p_juros - p_multa -
p_encargos + p_desc { variáveis novas };
dtmSystem.tblPrCartao.Locate('NR_PARCELA', 1, []);
// dtmSystem.tblConteudoReciboVL_EXTRAS.AsCurrency :=
// (vl_helper *
// (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100));
// dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
// vl_helper +
// (vl_helper *
// (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100));
dtmSystem.tblConteudoReciboVL_EXTRAS.AsCurrency :=
(vl_helper *
(dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100));
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
vl_helper +
(vl_helper *
(dtmSystem.tblPrCartaoPR_JUROS.AsFloat / 100));
end
else
begin
vl_helper :=
StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '',
[rfReplaceAll]));
p_juros := (vl_helper * t_juros) / t_cor;
p_multa := (vl_helper * t_multa) / t_cor;
p_encargos := (vl_helper * t_encargos) / t_cor;
p_desc := (vl_helper * t_desc_prin) / t_cor;
dtmSystem.tblConteudoReciboVL_PRINCIPAL.AsCurrency :=
vl_helper { variáveis novas } - p_juros - p_multa -
p_encargos + p_desc { variáveis novas };
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
vl_helper;
end;
end;
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
StrToDate(FormatDateTime('dd/mm/yyyy', data_parcelas[0]));
{ variáveis novas }
dtmSystem.tblConteudoReciboVL_JUROS.AsCurrency := p_juros;
dtmSystem.tblConteudoReciboVL_MULTA.AsCurrency := p_multa;
dtmSystem.tblConteudoReciboVL_ENCARGOS.AsCurrency := p_encargos;
dtmSystem.tblConteudoReciboVL_DESCONTOS.AsCurrency := p_desc;
{ variáveis novas }
dtmSystem.tblConteudoRecibo.Post;
end;
end
else
begin
case parcelas_pagamento of
3: // cheque
begin
dtmSystem.tblConteudoRecibo.Append;
dtmSystem.tblConteudoReciboTX_NOME.AsString :=
lv_fechamento.Items[p].Caption;
vl_helper :=
StrToCurr(stringreplace
(copy(lv_fechamento.Items[p].SubItems[0], 4,
length(lv_fechamento.Items[p].SubItems[0]) - 3), '.', '',
[rfReplaceAll]));
p_juros := (vl_helper * t_juros) / t_cor;
p_multa := (vl_helper * t_multa) / t_cor;
p_encargos := (vl_helper * t_encargos) / t_cor;
p_desc := (vl_helper * t_desc_prin) / t_cor;
dtmSystem.tblConteudoReciboVL_PRINCIPAL.AsCurrency :=
vl_helper { variáveis novas } - p_juros - p_multa -
p_encargos + p_desc { variáveis novas };
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
vl_helper;
if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]
)) = 0.0 then
begin
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
StrToDate(FormatDateTime('dd/mm/yyyy',
data_parcelas[p - 1]));
end
else
begin
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
StrToDate(FormatDateTime('dd/mm/yyyy',
data_parcelas[p]));
end;
{ variáveis novas }
dtmSystem.tblConteudoReciboVL_JUROS.AsCurrency := p_juros;
dtmSystem.tblConteudoReciboVL_MULTA.AsCurrency := p_multa;
dtmSystem.tblConteudoReciboVL_ENCARGOS.AsCurrency :=
p_encargos;
dtmSystem.tblConteudoReciboVL_DESCONTOS.AsCurrency
:= p_desc;
{ variáveis novas }
dtmSystem.tblConteudoRecibo.Post;
end;
2: // parcelas no crédito
begin
dtmSystem.tblConteudoRecibo.Append;
dtmSystem.tblConteudoReciboTX_NOME.AsString :=
lv_fechamento.Items[p].Caption;
vl_helper :=
StrToCurr(stringreplace
(copy(lv_fechamento.Items[p].SubItems[0], 4,
length(lv_fechamento.Items[p].SubItems[0]) - 3), '.', '',
[rfReplaceAll]));
dtmSystem.tblConteudoReciboVL_PRINCIPAL.AsCurrency :=
vl_helper;
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
vl_helper;
if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]
)) = 0.0 then
begin
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
StrToDate(FormatDateTime('dd/mm/yyyy',
data_parcelas[p - 1]));
end
else
begin
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
StrToDate(FormatDateTime('dd/mm/yyyy',
data_parcelas[p]));
end;
dtmSystem.tblConteudoRecibo.Post;
end;
end;
end;
end;
if somatotal <> 0 then
begin
edt_vltotal.Text := CurrToStrF(somatotal, ffCurrency, 2,
dtmSystem.CusFmt);
end
else
begin
edt_vltotal.Text := edt_vlaquitar.Text;
end;
end;
end;
end;
end;
fez_recibo := false;
end;
procedure TfrmAtendimento.btn_pesquisarClick(Sender: TObject);
var
string_query, tx_pesquisa, help_cpfcnpj: string;
begin
try
if edt_campop.Text <> '' then
begin
tx_pesquisa := Ansiuppercase(stringreplace(edt_campop.Text, ' ', '%',
[rfReplaceAll]));
string_query :=
'select tx_nome, tx_pai, tx_mae, case when TP_CLIENTE = ''F'' ' +
'then CD_CPF when TP_CLIENTE = ''J'' then CD_CNPJ end as TX_DOCUMENTO from chg_devedores where ';
case cbx_tiponome.ItemIndex of
0:
begin
string_query := string_query +
'upper(TX_NOME COLLATE WIN_PTBR) LIKE ' +
QuotedStr(tx_pesquisa + '%') + ' ORDER BY TX_NOME ';
end;
1:
begin
string_query := string_query + 'upper(TX_PAI) LIKE ' +
QuotedStr(tx_pesquisa + '%') + ' ORDER BY TX_NOME ';
end;
2:
begin
string_query := string_query + 'upper(TX_MAE) LIKE ' +
QuotedStr(tx_pesquisa + '%') + ' ORDER BY TX_NOME ';
end;
3:
begin
tx_pesquisa := stringreplace(tx_pesquisa, '.', '', [rfReplaceAll]);
tx_pesquisa := stringreplace(tx_pesquisa, '-', '', [rfReplaceAll]);
tx_pesquisa := stringreplace(tx_pesquisa, '/', '', [rfReplaceAll]);
if length(tx_pesquisa) < 14 then
begin
help_cpfcnpj := copy(tx_pesquisa, 1, 3) + '.' +
copy(tx_pesquisa, 4, 3) + '.' + copy(tx_pesquisa, 7, 3) + '-' +
RightStr(tx_pesquisa, 2);
string_query := string_query + 'CD_CPF like ' +
QuotedStr(help_cpfcnpj) + ' order by tx_nome ';
end
else if length(tx_pesquisa) >= 14 then
begin
help_cpfcnpj := copy(tx_pesquisa, 1, 2) + '.' +
copy(tx_pesquisa, 3, 3) + '.' + copy(tx_pesquisa, 6, 3) + '/' +
copy(tx_pesquisa, 9, 4) + '-' + RightStr(tx_pesquisa, 2);
string_query := string_query + 'CD_CNPJ like ' +
QuotedStr(help_cpfcnpj) + ' order by tx_nome ';
end;
end;
4:
begin
string_query := string_query +
'ID_DEVEDOR in (select id_devedor from chg_titulos where cd_devedor like '
+ QuotedStr('%' + tx_pesquisa + '%') + ')';
end;
5:
begin
if copy(tx_pesquisa, 1, 1) <> '(' then
begin
tx_pesquisa := '(' + tx_pesquisa;
end;
if copy(tx_pesquisa, 4, 1) <> ')' then
begin
tx_pesquisa := copy(tx_pesquisa, 1, 3) + ')' +
copy(tx_pesquisa, 4, 15);
end;
if copy(tx_pesquisa, 9, 1) <> '-' then
begin
tx_pesquisa := copy(tx_pesquisa, 1, 8) + '-' +
copy(tx_pesquisa, 9, 15);
end;
if (length(tx_pesquisa) < 13) or (length(tx_pesquisa) > 14) then
begin
Messagedlg('Número de telefone inválido.', mtWarning, [mbok], 0);
exit;
end;
string_query := string_query +
'ID_DEVEDOR in (SELECT ID_DEVEDOR FROM CHG_TELEFONES WHERE NR_NUMERO like '
+ QuotedStr(tx_pesquisa) + ')';
end;
end;
end;
with qryPesquisa do
begin
Close;
SQL.Text := string_query;
Open;
end;
dbgrd_pesquisar.Columns[0].FieldName := 'tx_nome';
dbgrd_pesquisar.Columns[0].Title.Caption := 'Nome do Devedor';
dbgrd_pesquisar.Columns[1].FieldName := 'tx_pai';
dbgrd_pesquisar.Columns[1].Title.Caption := 'Nome do Pai';
dbgrd_pesquisar.Columns[2].FieldName := 'tx_mae';
dbgrd_pesquisar.Columns[2].Title.Caption := 'Nome da Mãe';
except
end;
end;
procedure TfrmAtendimento.btn_protocoloClick(Sender: TObject);
begin
if edt_protocolo.Text = '' then
begin
edt_protocolo.Text := dtmSystem.gerarProtocolo
(dtmSystem.tblDevedoresID_DEVEDOR.AsString);
edt_protocolo1.Text := edt_protocolo.Text;
btn_protocolo.Enabled := false;
end;
end;
procedure TfrmAtendimento.btn_verprotocoloClick(Sender: TObject);
begin
// CarregaProtocolo;
end;
procedure TfrmAtendimento.btn_verrecibosClick(Sender: TObject);
var
old_nr: Integer;
tot: double;
begin
Screen.Cursor := crHourGlass;
with dtmSystem do
begin
tot := 0;
log_recibo := TStringList.Create;
if not(FileExists(ExtractFilePath(Application.ExeName) + 'log_recibo' +
inttostr(dtmSystem.id_usuario) + '.txt')) then
begin
log_recibo.Add('###############');
log_recibo.Add(DateTimeToStr(Now));
end
else
begin
log_recibo.LoadFromFile(ExtractFilePath(Application.ExeName) +
'log_recibo' + inttostr(dtmSystem.id_usuario) + '.txt');
log_recibo.Add('###############');
log_recibo.Add(DateTimeToStr(Now));
end;
if not tblRecibo.Active then
begin
tblRecibo.Open;
log_recibo.Add('Open na tabela');
end
else
begin
tblRecibo.Refresh;
log_recibo.Add('Refresh na tabela');
end;
tblRecibo.Last;
log_recibo.Add('Last na tabela');
old_nr := tblReciboNR_RECIBO.AsInteger;
log_recibo.Add('Nº do último recibo: ' + tblReciboNR_RECIBO.AsString);
tblConteudoRecibo.Open;
if tblConteudoRecibo.IsEmpty then
begin
Messagedlg('Não há recibos a serem gerados atualmente.', mtWarning,
[mbok], 0);
end
else
begin
tblConteudoRecibo.Filtered := false;
tblConteudoRecibo.RecNo := 1;
while not tblConteudoRecibo.Eof do
begin
tot := tot + tblConteudoReciboVL_CORRIGIDO.AsCurrency;
tblConteudoRecibo.Next;
end;
tblConteudoRecibo.RecNo := 1;
// zroqryRecibos.SQL.Clear;
// zroqryRecibos.SQL.Text := 'select * from sys_recibos';
// zroqryRecibos.Open;
// if zroqryRecibos.RecordCount = 0 then
// begin
// tblRecibo.Append;
// tblReciboNR_RECIBO.AsString := '000001';
// tblReciboTX_NOME.AsString := 'temp';
// tblRecibo.Post;
// end;
// if not zroqryRecibos.Locate('TX_NOME', 'temp', []) then
// begin
// zroqryRecibos.SQL.Clear;
// zroqryRecibos.SQL.Text :=
// 'select nr_recibo from sys_recibos where id_recibo = (select MAX(id_recibo) from sys_recibos)';
// zroqryRecibos.Open;
// end;
zroqryRecibos.Open;
zroqryRecibos.Refresh;
// old_nr := zroqryRecibos.FieldByName('NR_RECIBO').AsInteger;
if (forma_pagamento = 'Q') or (parcelas_pagamento = 2) then
begin
{ if tblReciboTX_NOME.AsString <> 'temp' then
begin }
// nr_recibo := Format('%.*d', [6, old_nr + 1]);
nr_recibo := Format('%.*d', [6, seqRecibos.GetCurrentValue + 1]);
log_recibo.Add('Nº do novo recibo: ' + nr_recibo);
tblRecibo.Append;
tblReciboDT_IMPRESSAO.AsDateTime := Date;
tblReciboTX_CPF.AsString := tblDevedoresCD_CPF.AsString;
tblReciboTX_CNPJ.AsString := tblDevedoresCD_CNPJ.AsString;
tblReciboNR_RECIBO.AsString := nr_recibo;
tblReciboTX_NOME.AsString := dtsDevedores.DataSet.FieldByName('TX_NOME')
.AsString + '- Quitação';
// tblRecibo.Post;
// new_nr := tblReciboID_RECIBO.AsInteger;
// tblRecibo.RecNo := tblRecibo.RecordCount;
{ end
else
begin
tblRecibo.Edit;
tblReciboDT_IMPRESSAO.AsDateTime := Date;
tblReciboTX_CPF.AsString := tblDevedoresCD_CPF.AsString;
tblReciboTX_CNPJ.AsString := tblDevedoresCD_CNPJ.AsString;
tblReciboTX_NOME.AsString := dtsDevedores.DataSet.FieldByName
('TX_NOME').AsString + '- Quitação';
tblRecibo.Post;
new_nr := tblReciboID_RECIBO.AsInteger;
end; }
// tblRecibo.Filter := 'ID_RECIBO = ' + inttostr(tblRecibo.RecNo);
{ tblRecibo.Filter := 'ID_RECIBO = ' + inttostr(new_nr);
tblRecibo.Filtered := true;
id_recibo := tblReciboNR_RECIBO.AsString;
tblRecibo.Edit; }
tblReciboID_DEVEDOR.AsInteger := tblDevedoresID_DEVEDOR.AsInteger;
tblReciboVL_TOTAL.AsCurrency :=
StrToCurr(stringreplace(copy(edt_vltotal.Text, 4,
length(edt_vltotal.Text) - 3), '.', '', [rfReplaceAll]));
while not(tblConteudoRecibo.Eof) do
begin
tblReciboVL_PRINCIPAL.AsCurrency := tblReciboVL_PRINCIPAL.AsCurrency +
tblConteudoReciboVL_PRINCIPAL.AsCurrency;
tblReciboVL_JUROS.AsCurrency := tblReciboVL_JUROS.AsCurrency +
tblConteudoReciboVL_JUROS.AsCurrency;
tblReciboVL_MULTA.AsCurrency := tblReciboVL_MULTA.AsCurrency +
tblConteudoReciboVL_MULTA.AsCurrency;
tblReciboVL_ENCARGOS.AsCurrency := tblReciboVL_ENCARGOS.AsCurrency +
tblConteudoReciboVL_ENCARGOS.AsCurrency;
tblReciboVL_DESCONTOS.AsCurrency := tblReciboVL_DESCONTOS.AsCurrency +
tblConteudoReciboVL_DESCONTOS.AsCurrency;
tblReciboVL_CORRIGIDO.AsCurrency := tblReciboVL_CORRIGIDO.AsCurrency +
tblConteudoReciboVL_CORRIGIDO.AsCurrency;
tblConteudoRecibo.Next;
end;
if index_pagamento = 2 then
begin
tblReciboTP_RECEBIMENTO.AsInteger := 3;
end
else
begin
tblReciboTP_RECEBIMENTO.AsInteger := index_pagamento;
end;
tblReciboID_USUARIO.AsInteger := id_usuario;
tblRecibo.Post;
relRecibo := TrelRecibo.Create(self);
with relRecibo do
begin
nr_recibo_print := dtmSystem.tblReciboNR_RECIBO.AsString;
frlbl_nr_reciboprimeiravia.Caption := nr_recibo_print;
frlbl_nr_recibosegundavia.Caption := nr_recibo_print;
if dtsDevedor.DataSet.FieldByName('CD_CPF').AsString = '' then
begin
frdblbl_cpf.Text := ' CPNJ: ';
frdblbl_cpf.DataField := 'CD_CNPJ';
frdblbl_cpf2v.Text := ' CPNJ: ';
frdblbl_cpf2v.DataField := 'CD_CNPJ';
end;
dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA', id_emp, []);
frlbl_empresatit.Caption := frlbl_empresatit.Caption +
dtmSystem.tblCHGEmpresaTX_NOME.AsString + ' ';
frlbl_empresatit2v.Caption := frlbl_empresatit2v.Caption +
dtmSystem.tblCHGEmpresaTX_NOME.AsString + ' ';
frdblbl_nome.left := frlbl_recebemos.left + frlbl_recebemos.Width + 5;
frdblbl_nome2v.left := frdblbl_nome.left;
frlbl_valortot.Caption := frlbl_valortot.Caption +
CurrToStrF(tot, ffCurrency, 2);
frlbl_valortot2v.Caption := frlbl_valortot.Caption;
frlbl_vlextenso.left := frlbl_valortot.Width + 5;
frlbl_vlextenso2v.left := frlbl_vlextenso.left;
frlbl_dtpag.Caption := frlbl_dtpag.Caption +
DateToStr(dtp_atrasorecalc.Date);
frlbl_dtpag2v.Caption := frlbl_dtpag2v.Caption +
DateToStr(dtp_atrasorecalc.Date);
frlbl_vlextenso.Caption := '(' + valorPorExtenso(tot) + ')';
frlbl_vlextenso2v.Caption := frlbl_vlextenso.Caption;
frlbl_formarecebimento.Caption := frlbl_formarecebimento.Caption +
edt_formarecebimento.Text;
frlbl_formarecebimento2v.Caption := frlbl_formarecebimento.Caption;
if mem_obsrecibo.Lines.Text <> '' then
begin
fr_membobs.Lines.Add('Observações: ' + mem_obsrecibo.Lines.Text);
fr_membobs2v.Lines.Add('Observações: ' + mem_obsrecibo.Lines.Text);
end;
if index_pagamento = 2 then
begin
frpnl_cheque.Visible := true;
frpnl_cheque2v.Visible := true;
if edt_nrchequerecibo.Text <> '' then
begin
frlbl_nrcheque.Caption := frlbl_nrcheque.Caption +
edt_nrchequerecibo.Text;
frlbl_nrcheque2v.Caption := frlbl_nrcheque.Caption;
end;
if edt_bancorecibo.Text <> '' then
begin
frlbl_banco.Caption := frlbl_banco.Caption + edt_bancorecibo.Text;
frlbl_banco2v.Caption := frlbl_banco.Caption;
end;
if edt_pracarecibo.Text <> '' then
begin
frlbl_praca.Caption := frlbl_praca.Caption + edt_pracarecibo.Text;
frlbl_praca2v.Caption := frlbl_praca.Caption;
end;
end;
dtmSystem.tblEstados.Locate('ID_ESTADO',
dtmSystem.tblEmpresaID_ESTADO.AsString, []);
dtmSystem.tblCidades.Locate('ID_CIDADE',
dtmSystem.tblEmpresaID_CIDADE.AsString, []);
frlbl_headerbot.Caption :=
UpperCase(dtmSystem.tblEmpresaTX_ENDERECO.AsString + ' ' +
dtmSystem.tblEmpresaNR_NUMERO.AsString + ' ' +
dtmSystem.tblEmpresaTX_COMPLEMENTO.AsString + ' - ' +
dtmSystem.tblEmpresaTX_BAIRRO.AsString + ' - ' +
dtmSystem.tblCidadesTX_NOME.AsString + ' - ' +
dtmSystem.tblEstadosTX_SIGLA.AsString + ' - TEL: ' +
dtmSystem.tblEmpresaTX_TELEFONE.AsString);
frlbl_headerbot2v.Caption := frlbl_headerbot.Caption;
frlbl_headertop.Caption :=
UpperCase(dtmSystem.tblEmpresaTX_TITULO.AsString + ' - CNPJ: ' +
dtmSystem.tblEmpresaTX_CNPJ.AsString);
frlbl_headertop2v.Caption := frlbl_headertop.Caption;
if frdbimg_logo.Picture.Height > frdbimg_logo.Picture.Width then
begin
frpnl_logo.Height := 100;
frpnl_logo.Width := 75;
frpnl_logo2v.Height := 100;
frpnl_logo2v.Width := 75;
end;
if frdbimg_logo.Picture.Height < frdbimg_logo.Picture.Width then
begin
frpnl_logo.Height := 75;
frpnl_logo.Width := 100;
frpnl_logo2v.Height := 75;
frpnl_logo2v.Width := 100;
end;
if frdbimg_logo.Picture.Height = frdbimg_logo.Picture.Width then
begin
frpnl_logo.Height := 100;
frpnl_logo.Width := 100;
frpnl_logo2v.Height := 100;
frpnl_logo2v.Width := 100;
end;
Screen.Cursor := crDefault;
frRecibo.PreviewModal;
end;
end
else
begin
// if tipo_parcelamento = 'P' then
// begin
// if tblReciboTX_NOME.AsString <> 'temp' then
// begin
// tblRecibo.Append;
// tblReciboDT_IMPRESSAO.AsDateTime := Date;
// tblReciboTX_CPF.AsString := tblDevedoresCD_CPF.AsString;
// tblReciboTX_CNPJ.AsString := tblDevedoresCD_CNPJ.AsString;
// // tblReciboNR_RECIBO.AsString :=
// // Format('%.*d', [6, strtoint(old_nr) + 1]);
// tblReciboNR_RECIBO.AsString := Format('%.*d', [6, old_nr + 1]);
// tblReciboTX_NOME.AsString := dtsDevedores.DataSet.FieldByName
// ('TX_NOME').AsString + '- Parcelamento';
// tblRecibo.Post;
// // tblRecibo.RecNo := tblRecibo.RecordCount;
// new_nr := tblReciboID_RECIBO.AsInteger;
// end
// else
// begin
// tblRecibo.Edit;
// tblReciboDT_IMPRESSAO.AsDateTime := Date;
// tblReciboTX_CPF.AsString := tblDevedoresCD_CPF.AsString;
// tblReciboTX_CNPJ.AsString := tblDevedoresCD_CNPJ.AsString;
// tblReciboTX_NOME.AsString := dtsDevedores.DataSet.FieldByName
// ('TX_NOME').AsString + '- Parcelamento';
// tblRecibo.Post;
// new_nr := tblReciboID_RECIBO.AsInteger;
// end;
// end
// else
// begin
// if tblReciboTX_NOME.AsString <> 'temp' then
// begin
tblRecibo.Append;
tblReciboDT_IMPRESSAO.AsDateTime := Date;
tblReciboTX_CPF.AsString := tblDevedoresCD_CPF.AsString;
tblReciboTX_CNPJ.AsString := tblDevedoresCD_CNPJ.AsString;
// tblReciboNR_RECIBO.AsString :=
// Format('%.*d', [6, strtoint(old_nr) + 1]);
// nr_recibo := Format('%.*d', [6, old_nr + 1]);
nr_recibo := Format('%.*d', [6, seqRecibos.GetCurrentValue + 1]);
log_recibo.Add('Nº do novo recibo: ' + nr_recibo);
tblReciboNR_RECIBO.AsString := nr_recibo;
tblReciboTX_NOME.AsString := dtsDevedores.DataSet.FieldByName('TX_NOME')
.AsString + '- Financiamento';
// tblRecibo.Post;
// new_nr := tblReciboID_RECIBO.AsInteger;
// tblRecibo.RecNo := tblRecibo.RecordCount;
// end
// else
// begin
// tblRecibo.Edit;
// tblReciboDT_IMPRESSAO.AsDateTime := Date;
// tblReciboTX_CPF.AsString := tblDevedoresCD_CPF.AsString;
// tblReciboTX_CNPJ.AsString := tblDevedoresCD_CNPJ.AsString;
// tblReciboTX_NOME.AsString := dtsDevedores.DataSet.FieldByName
// ('TX_NOME').AsString + '- Financiamento';
// tblRecibo.Post;
// new_nr := tblReciboID_RECIBO.AsInteger;
// end;
// end;
// tblRecibo.Edit;
tblReciboID_DEVEDOR.AsInteger := tblDevedoresID_DEVEDOR.AsInteger;
tblReciboVL_TOTAL.AsCurrency :=
StrToCurr(stringreplace(copy(edt_vltotal.Text, 4,
length(edt_vltotal.Text) - 3), '.', '', [rfReplaceAll]));
while not tblConteudoRecibo.Eof do
begin
tblReciboVL_PRINCIPAL.AsCurrency := tblReciboVL_PRINCIPAL.AsCurrency +
tblConteudoReciboVL_PRINCIPAL.AsCurrency;
tblReciboVL_JUROS.AsCurrency := tblReciboVL_JUROS.AsCurrency +
tblConteudoReciboVL_JUROS.AsCurrency;
tblReciboVL_MULTA.AsCurrency := tblReciboVL_MULTA.AsCurrency +
tblConteudoReciboVL_MULTA.AsCurrency;
tblReciboVL_ENCARGOS.AsCurrency := tblReciboVL_ENCARGOS.AsCurrency +
tblConteudoReciboVL_ENCARGOS.AsCurrency;
tblReciboVL_DESCONTOS.AsCurrency := tblReciboVL_DESCONTOS.AsCurrency +
tblConteudoReciboVL_DESCONTOS.AsCurrency;
tblReciboVL_CORRIGIDO.AsCurrency := tblReciboVL_CORRIGIDO.AsCurrency +
tblConteudoReciboVL_CORRIGIDO.AsCurrency;
tblConteudoRecibo.Next;
end;
if index_pagamento = 2 then
begin
tblReciboTP_RECEBIMENTO.AsInteger := 3;
end
else
begin
tblReciboTP_RECEBIMENTO.AsInteger := index_pagamento;
end;
tblReciboID_USUARIO.AsInteger := id_usuario;
tblRecibo.Post;
if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])) <> -1
then
begin
// tblRecibo.Filter := 'ID_RECIBO = ' + recibos_parcelas[i];
// tblRecibo.Filtered := true;
{
tblConteudoRecibo.Filter := 'ID_CONTEUDO = ' + inttostr(i + 1);
tblConteudoRecibo.Filtered := true; }
// id_recibo := tblReciboNR_RECIBO.AsString;
relRecibo := TrelRecibo.Create(self);
with relRecibo do
begin
nr_recibo_print := dtmSystem.tblReciboNR_RECIBO.AsString;
frlbl_nr_reciboprimeiravia.Caption := nr_recibo_print;
frlbl_nr_recibosegundavia.Caption := nr_recibo_print;
if dtsDevedor.DataSet.FieldByName('CD_CPF').AsString = '' then
begin
frdblbl_cpf.Text := ' CPNJ: ';
frdblbl_cpf.DataField := 'CD_CNPJ';
frdblbl_cpf2v.Text := ' CPNJ: ';
frdblbl_cpf2v.DataField := 'CD_CNPJ';
end;
if acordo_fora then
begin
dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA', acordo_emp, []);
end
else
begin
dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA', id_emp, []);
end;
frlbl_empresatit.Caption := frlbl_empresatit.Caption +
dtmSystem.tblCHGEmpresaTX_NOME.AsString + ' ';
frlbl_empresatit2v.Caption := frlbl_empresatit2v.Caption +
dtmSystem.tblCHGEmpresaTX_NOME.AsString + ' ';
frdblbl_nome.left := frlbl_recebemos.left +
frlbl_recebemos.Width + 5;
frdblbl_nome2v.left := frdblbl_nome.left;
// frdblbl_cpf.left := frdblbl_nome.left + frdblbl_nome.Width + 10;
// frdblbl_cpf2v.left := frdblbl_cpf.left;
// frlbl_valortot.Caption := frlbl_valortot.Caption + edt_vltotal.Text;
frlbl_valortot.Caption := frlbl_valortot.Caption +
CurrToStrF(tot, ffCurrency, 2);
frlbl_valortot2v.Caption := frlbl_valortot.Caption;
frlbl_vlextenso.left := frlbl_valortot.Width + 5;
frlbl_vlextenso2v.left := frlbl_vlextenso.left;
// frlbl_vlextenso.Caption := '(' +
// valorPorExtenso(strtofloat(copy(stringreplace(edt_vltotal.Text, '.',
// '', []), 4, length(edt_vltotal.Text) - 3))) + ')';
frlbl_vlextenso.Caption := '(' + valorPorExtenso(tot) + ')';
frlbl_vlextenso2v.Caption := frlbl_vlextenso.Caption;
frlbl_formarecebimento.Caption := frlbl_formarecebimento.Caption +
edt_formarecebimento.Text;
frlbl_dtpag.Caption := frlbl_dtpag.Caption +
DateToStr(dtp_atrasorecalc.Date);
frlbl_dtpag2v.Caption := frlbl_dtpag2v.Caption +
DateToStr(dtp_atrasorecalc.Date);
frlbl_formarecebimento2v.Caption := frlbl_formarecebimento.Caption;
// fr_membobs.Lines.Clear;
// fr_membobs2v.Lines.Clear;
if cbx_despesas.Checked then
begin
if mem_obsrecibo.Lines.Text <> '' then
begin
fr_membobs.Lines.Add('Observações: ' + obs_despesas + ' ' +
mem_obsrecibo.Lines.Text);
fr_membobs2v.Lines.Add('Observações: ' + obs_despesas + ' ' +
mem_obsrecibo.Lines.Text);
end;
end
else
begin
if mem_obsrecibo.Lines.Text <> '' then
begin
fr_membobs.Lines.Add('Observações: ' +
mem_obsrecibo.Lines.Text);
fr_membobs2v.Lines.Add('Observações: ' +
mem_obsrecibo.Lines.Text);
end;
end;
if index_pagamento = 3 then
begin
frpnl_cheque.Visible := true;
// frlbl_obscheque.Visible := true;
frpnl_cheque2v.Visible := true;
// frlbl_obscheque2v.Visible := true;
if edt_nrchequerecibo.Text <> '' then
begin
frlbl_nrcheque.Caption := frlbl_nrcheque.Caption +
edt_nrchequerecibo.Text;
frlbl_nrcheque2v.Caption := frlbl_nrcheque.Caption;
end;
if edt_bancorecibo.Text <> '' then
begin
frlbl_banco.Caption := frlbl_banco.Caption +
edt_bancorecibo.Text;
frlbl_banco2v.Caption := frlbl_banco.Caption;
end;
if edt_pracarecibo.Text <> '' then
begin
frlbl_praca.Caption := frlbl_praca.Caption +
edt_pracarecibo.Text;
frlbl_praca2v.Caption := frlbl_praca.Caption;
end;
end;
dtmSystem.tblEstados.Locate('ID_ESTADO',
dtmSystem.tblEmpresaID_ESTADO.AsString, []);
dtmSystem.tblCidades.Locate('ID_CIDADE',
dtmSystem.tblEmpresaID_CIDADE.AsString, []);
frlbl_headerbot.Caption :=
UpperCase(dtmSystem.tblEmpresaTX_ENDERECO.AsString + ' ' +
dtmSystem.tblEmpresaNR_NUMERO.AsString + ' ' +
dtmSystem.tblEmpresaTX_COMPLEMENTO.AsString + ' - ' +
dtmSystem.tblEmpresaTX_BAIRRO.AsString + ' - ' +
dtmSystem.tblCidadesTX_NOME.AsString + ' - ' +
dtmSystem.tblEstadosTX_SIGLA.AsString + ' - TEL: ' +
dtmSystem.tblEmpresaTX_TELEFONE.AsString);
frlbl_headerbot2v.Caption := frlbl_headerbot.Caption;
frlbl_headertop.Caption :=
UpperCase(dtmSystem.tblEmpresaTX_TITULO.AsString + ' - CNPJ: ' +
dtmSystem.tblEmpresaTX_CNPJ.AsString);
frlbl_headertop2v.Caption := frlbl_headertop.Caption;
if frdbimg_logo.Picture.Height > frdbimg_logo.Picture.Width then
begin
frpnl_logo.Height := 100;
frpnl_logo.Width := 75;
frpnl_logo2v.Height := 100;
frpnl_logo2v.Width := 75;
end;
if frdbimg_logo.Picture.Height < frdbimg_logo.Picture.Width then
begin
frpnl_logo.Height := 75;
frpnl_logo.Width := 100;
frpnl_logo2v.Height := 75;
frpnl_logo2v.Width := 100;
end;
if frdbimg_logo.Picture.Height = frdbimg_logo.Picture.Width then
begin
frpnl_logo.Height := 100;
frpnl_logo.Width := 100;
frpnl_logo2v.Height := 100;
frpnl_logo2v.Width := 100;
end;
Screen.Cursor := crDefault;
frRecibo.PreviewModal;
end;
end;
if parcelas_pagamento = 4 then
begin
// OpenOfficeDocument(ExtractFilePath(Application.ExeName) + 'ACORDOS\' +
// 'teste.docx');
OpenOfficeDocument(dtmSystem.path_executavel + '\ACORDOS\' +
'teste.docx');
end;
end;
log_recibo.Add('Close na tabela.');
tblRecibo.Close;
fez_recibo := true;
end;
end;
log_recibo.SaveToFile(ExtractFilePath(Application.ExeName) + 'log_recibo' +
inttostr(dtmSystem.id_usuario) + '.txt');
btn_concluir.Enabled := true;
btn_verrecibos.Enabled := false;
if FileExists(ExtractFilePath(Application.ExeName) + '000001.pdf') then
begin
Showmessage('Erro ao gerar recibo. Por favor contate o suporte.');
end;
Screen.Cursor := crDefault;
end;
procedure TfrmAtendimento.btn_acordoinClick(Sender: TObject);
begin
Screen.Cursor := crHourGlass;
// OpenOfficeDocument(ExtractFilePath(Application.ExeName) + 'ACORDOS\' +
// 'acordo_financ.doc');
OpenOfficeDocument(dtmSystem.path_executavel + '\ACORDOS\' +
'acordo_financ.doc');
Screen.Cursor := crDefault;
btn_verrecibos.Enabled := true;
end;
procedure TfrmAtendimento.btn_acordooutClick(Sender: TObject);
var
strFolder: string;
begin
// strFolder := ExtractFilePath(Application.ExeName) + 'ACORDOS';
strFolder := dtmSystem.path_executavel + '\ACORDOS';
if not DirectoryExists(strFolder) then
begin
CreateDir(strFolder);
end;
ShellExecute(Application.Handle, PChar('explore'), PChar(strFolder), nil, nil,
SW_SHOWNORMAL);
btn_verrecibos.Enabled := true;
end;
procedure TfrmAtendimento.btn_amostraClick(Sender: TObject);
var
// i: Integer;
// id_titulos: string;
// nao_select: Boolean;
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) 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 := 'atendimento';
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 TfrmAtendimento.btn_closeClick(Sender: TObject);
begin
Close;
end;
procedure TfrmAtendimento.btn_concluirClick(Sender: TObject);
var
i, j, ç, id_acordo, id_histo, Count, atraso, cont, atraso_original, cont_rep,
h: Integer;
string_helper, id_titulos, str_titulos, vencs, mes, ano: string;
ent_help: double;
{ variáveis novas }
ac_pr, ac_j, ac_m, ac_enc, ac_cor, hac_pr, hac_j, hac_m, hac_enc,
hac_cor: array of currency;
help_pr, help_j, help_m, help_enc, help_cor, p_juros, p_multa, p_encargos,
p_desc, rep_prin, rep_jur, rep_mul, rep_enc, rep_cor, vl_pr, vl_j, vl_m,
vl_enc, vl_cor, vl_desc, pr_pr, pr_j, pr_m, pr_enc, pr_cor, help_rep_cor,
cor_antigo { variáveis novas }
: currency;
l: Integer;
error_criar_titulo: Boolean;
a: double;
begin
if not cdsTitulos.Active then
begin
cdsTitulos.Open;
while not cdsTitulos.IsEmpty do
begin
cdsTitulos.Delete;
end;
end;
if not cdsParcelas.Active then
begin
cdsParcelas.Open;
while not cdsParcelas.IsEmpty do
begin
cdsParcelas.Delete;
end;
end;
string_helper := '';
str_titulos := '';
vencs := '';
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;
if dblucb_agatend.KeyValue < 1 then
begin
Messagedlg('Por favor selecione um cobrador para ser agendado.', mtWarning,
[mbok], 0);
abort;
end
else
begin
if Messagedlg
('Por favor verifique corretamente a data, hora e o cobrador do agendamento antes de realizá-lo.'
+ ' Deseja continuar?', mtWarning, [mbYes, mbNo], 0) = mrNo then
begin
abort;
end;
end;
Screen.Cursor := crHourGlass;
Messagedlg('Este processo pode demorar. Por favor aguarde.', mtWarning,
[mbok], 0);
Application.ProcessMessages;
btn_protocolo.Enabled := true;
dtmSystem.tblProvidencias.Locate('TX_NOME', edt_prov.Text, []);
pb_atendimento.Position := 0;
lbl_processo.Caption := 'Baixando Títulos...';
if (forma_pagamento = 'Q') or (parcelas_pagamento = 2) then
begin
if index_pagamento = 3 then
begin
try
dtmSystem.tblPrCartao.Locate('NR_PARCELA', 1, []);
// ent_help :=
// (((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
// length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) +
// ((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
// length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) *
// (dtmSystem.tblEmpresaPR_BANCO_CREDVISTA.AsFloat / 100))) -
// (StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
// length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])))) /
// quant_titulos;
ent_help :=
(((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) +
((StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))) *
(dtmSystem.tblPrCartaoPR_REPASSE.AsFloat / 100))) -
(StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])))) /
quant_titulos;
ent_help := entrada_credvista - ent_help;
except
ent_help := 0;
end;
end
else
begin
ent_help := 0;
end;
pb_atendimento.Step := Ceil(100 / quant_titulos);
Count := 0;
for i := 0 to lv_titulos.Items.Count - 1 do
begin
Application.ProcessMessages;
if lv_titulos.Items[i].Checked then
begin
lbl_processo.Caption := 'Baixando Títulos... Título ' +
inttostr(Count + 1);
// string_helper := '';
queryListaTitulos.RecNo := i + 1;
str_titulos := str_titulos + queryListaTitulosID_TITULO.AsString + ';';
with dtmSystem do
begin
Inc(Count, 1);
tblTitulos.Locate('ID_TITULO',
queryListaTitulosID_TITULO.AsInteger, []);
GuardaTitulos;
tblTitulos.Edit;
tblTitulosTP_PRESTACAO.AsString := 'N';
if tblTitulosTP_SITUACAO.AsString = 'AC' then
// arrumei aqui ##########################
begin
tblAcordos.Open;
tblAcordos.Filtered := false;
tblAcordos.Filter := 'ID_PARCELA = ' + tblTitulosID_TITULO.AsString;
tblAcordos.Filtered := true;
help_rep_cor := 0;
cont_rep := 0;
setlength(ac_pr, tblAcordos.RecordCount);
setlength(ac_j, tblAcordos.RecordCount);
setlength(ac_m, tblAcordos.RecordCount);
setlength(ac_enc, tblAcordos.RecordCount);
setlength(ac_cor, tblAcordos.RecordCount);
tblAcordos.First;
while not tblAcordos.Eof do
begin
zroqryHelpRepasse.SQL.Text :=
'select * from chg_titulos where id_titulo = ' +
tblAcordosID_ORIGINAL.AsString;
zroqryHelpRepasse.Open;
help_rep_cor := help_rep_cor + zroqryHelpRepasse.FieldByName
('VL_CORRIGIDO').AsCurrency;
atraso_original :=
DaysBetween(zroqryHelpRepasse.FieldByName('DT_PAGAMENTO')
.AsDateTime, zroqryHelpRepasse.FieldByName('DT_VENCIMENTO')
.AsDateTime);
mes := inttostr
(strtoint(copy(FormatDateTime('yyyy-mm-dd',
zroqryHelpRepasse.FieldByName('DT_PAGAMENTO')
.AsDateTime), 6, 2)));
ano := copy(FormatDateTime('yyyy-mm-dd',
zroqryHelpRepasse.FieldByName('DT_PAGAMENTO')
.AsDateTime), 1, 4);
// tblCHGEmpresa.Locate('ID_EMPRESA',
// zroqryHelpRepasse.FieldByName('ID_EMPRESA').AsInteger, []);
tblCHGEmpresa.Locate('ID_EMPRESA',
tblTitulosID_EMPRESA.AsInteger, []);
tblEmpresaRepasse.Locate('ID_MES;ID_ANO',
VarArrayOf([mes, ano]), []);
rotblRepasseFase.Close;
rotblRepasseFase.SQL.Text :=
'select * from sys_repasses_fases where id_repasse = ' +
QuotedStr(tblEmpresaRepasseID_ITEM.AsString) +
' and min_atraso <= ' + inttostr(atraso_original) + ' and ' +
inttostr(atraso_original) + ' <= max_atraso';
rotblRepasseFase.Open;
if not rotblRepasseFase.IsEmpty then
begin
ac_pr[cont_rep] :=
(rotblRepasseFasePR_PRINCIPAL.AsCurrency / 100);
ac_j[cont_rep] := (rotblRepasseFasePR_JUROS.AsCurrency / 100);
ac_m[cont_rep] := (rotblRepasseFasePR_MULTA.AsCurrency / 100);
ac_enc[cont_rep] :=
(rotblRepasseFasePR_ENCARGOS.AsCurrency / 100);
ac_cor[cont_rep] :=
(rotblRepasseFasePR_CORRIGIDO.AsCurrency / 100);
end
else
begin
ac_pr[cont_rep] :=
(dtmSystem.tblEmpresaRepassePR_PRINCIPAL.AsCurrency / 100);
ac_j[cont_rep] :=
(dtmSystem.tblEmpresaRepassePR_JUROS.AsCurrency / 100);
ac_m[cont_rep] :=
(dtmSystem.tblEmpresaRepassePR_MULTA.AsCurrency / 100);
ac_enc[cont_rep] :=
(dtmSystem.tblEmpresaRepassePR_ENCARGOS.AsCurrency / 100);
ac_cor[cont_rep] :=
(dtmSystem.tblEmpresaRepassePR_CORRIGIDO.AsCurrency / 100);
end;
Inc(cont_rep, 1);
Application.ProcessMessages;
tblAcordos.Next;
end;
tblAcordos.First;
cont_rep := 0;
help_pr := 0;
help_j := 0;
help_m := 0;
help_enc := 0;
help_cor := 0;
while not tblAcordos.Eof do
begin
zroqryHelpRepasse.SQL.Text :=
'select * from chg_titulos where id_titulo = ' +
tblAcordosID_ORIGINAL.AsString;
zroqryHelpRepasse.Open;
help_pr := help_pr +
((((zroqryHelpRepasse.FieldByName('VL_CORRIGIDO').AsCurrency *
100) / help_rep_cor) * ac_pr[cont_rep] / 100));
help_j := help_j +
((((zroqryHelpRepasse.FieldByName('VL_CORRIGIDO').AsCurrency *
100) / help_rep_cor) * ac_j[cont_rep] / 100));
help_m := help_m +
((((zroqryHelpRepasse.FieldByName('VL_CORRIGIDO').AsCurrency *
100) / help_rep_cor) * ac_m[cont_rep] / 100));
help_enc := help_enc +
((((zroqryHelpRepasse.FieldByName('VL_CORRIGIDO').AsCurrency *
100) / help_rep_cor) * ac_enc[cont_rep] / 100));
help_cor := help_cor +
((((zroqryHelpRepasse.FieldByName('VL_CORRIGIDO').AsCurrency *
100) / help_rep_cor) * ac_cor[cont_rep] / 100));
Inc(cont_rep, 1);
Application.ProcessMessages;
tblAcordos.Next;
end;
tblTitulosVL_MULTA.AsCurrency := tblTitulosVL_MULTA.AsCurrency +
queryListaTitulosVL_MULTA.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency);
tblTitulosVL_DESC_MULTA.AsCurrency :=
tblTitulosVL_DESC_MULTA.AsCurrency +
(queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency);
tblTitulosVL_INDICADOR.AsCurrency :=
tblTitulosVL_INDICADOR.AsCurrency +
queryListaTitulosVL_INDICADOR.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
tblTitulosVL_DESC_INDICADOR.AsCurrency :=
tblTitulosVL_DESC_INDICADOR.AsCurrency +
(queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
tblTitulosVL_JUROS.AsCurrency := tblTitulosVL_JUROS.AsCurrency +
queryListaTitulosVL_JUROS.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency);
tblTitulosVL_DESC_JUROS.AsCurrency :=
tblTitulosVL_DESC_JUROS.AsCurrency +
(queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency);
tblTitulosVL_DESC_PRINCIPAL.AsCurrency :=
tblTitulosVL_DESC_PRINCIPAL.AsCurrency +
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency +
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency;
tblTitulosVL_ENCARGOS.AsCurrency := tblTitulosVL_ENCARGOS.AsCurrency
+ queryListaTitulosVL_INDICADOR.AsCurrency +
// queryListaTitulosVL_RETIRADA_TAXA.AsCurrency +
ent_help - (queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
cor_antigo := tblTitulosVL_CORRIGIDO.AsCurrency;
if index_pagamento = 3 then
begin
tblTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency + ent_help;
end
else
begin
tblTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency;
end;
{ tblTitulosVL_TITULO.AsCurrency := queryListaTitulosVL_CORRIGIDO.AsCurrency -
tblTitulosVL_MULTA.AsCurrency - tblTitulosVL_JUROS.AsCurrency -
tblTitulosVL_ENCARGOS.AsCurrency; } // AQUI
tblTitulosVL_REPASSE_PRIN.AsCurrency :=
tblTitulosVL_REPASSE_PRIN.AsCurrency +
((tblTitulosVL_TITULO.AsCurrency -
tblTitulosVL_DESC_PRINCIPAL.AsCurrency) * (help_pr));
tblTitulosVL_REPASSE_JUROS.AsCurrency :=
tblTitulosVL_REPASSE_JUROS.AsCurrency +
((queryListaTitulosVL_JUROS.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency)) * (help_j));
tblTitulosVL_REPASSE_MULTA.AsCurrency :=
tblTitulosVL_REPASSE_MULTA.AsCurrency +
((queryListaTitulosVL_MULTA.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency)) * (help_m));
tblTitulosVL_REPASSE_ENCARGOS.AsCurrency :=
tblTitulosVL_REPASSE_ENCARGOS.AsCurrency +
((queryListaTitulosVL_INDICADOR.AsCurrency +
// queryListaTitulosVL_RETIRADA_TAXA.AsCurrency +
ent_help - (queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency)) * (help_enc));
tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency :=
tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency +
((tblTitulosVL_CORRIGIDO.AsCurrency - cor_antigo) * (help_cor));
if index_pagamento = 3 then
begin
tblTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency + ent_help;
end
else
begin
tblTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency;
end;
if parcelas_pagamento = 2 then
begin
if dateof(dtp_atrasorecalc.Date) <> dateof(Date) then
begin
tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end
else
begin
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end;
end
else
begin
// if index_pagamento <> 3 then
// begin
if index_pagamento <> 2 then
begin
if dateof(dtp_atrasorecalc.Date) <> dateof(Date) then
begin
tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end
else
begin
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end;
end
else
begin
if dateof(dtp_atrasorecalc.Date) <> dateof(Date) then
begin
tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
end;
end;
end;
end
else
begin
tblTitulosVL_MULTA.AsCurrency :=
queryListaTitulosVL_MULTA.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency);
tblTitulosVL_DESC_MULTA.AsCurrency :=
(queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency);
tblTitulosVL_INDICADOR.AsCurrency :=
queryListaTitulosVL_INDICADOR.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
tblTitulosVL_DESC_INDICADOR.AsCurrency :=
(queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
tblTitulosVL_JUROS.AsCurrency :=
queryListaTitulosVL_JUROS.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency);
tblTitulosVL_DESC_JUROS.AsCurrency :=
(queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency);
tblTitulosVL_DESC_PRINCIPAL.AsCurrency :=
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency +
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency;
tblTitulosVL_ENCARGOS.AsCurrency :=
queryListaTitulosVL_INDICADOR.AsCurrency +
// queryListaTitulosVL_RETIRADA_TAXA.AsCurrency +
ent_help - (queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
if index_pagamento = 3 then
begin
tblTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency + ent_help;
end
else
begin
tblTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency;
end;
if parcelas_pagamento = 2 then
begin
if dateof(dtp_atrasorecalc.Date) <> dateof(Date) then
begin
tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end
else
begin
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end;
end
else
begin
// if index_pagamento <> 3 then
// begin
if index_pagamento <> 2 then
begin
if dateof(dtp_atrasorecalc.Date) <> dateof(Date) then
begin
tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end
else
begin
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end;
end
else
begin
if dateof(dtp_atrasorecalc.Date) <> dateof(Date) then
begin
tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
end;
end;
end;
atraso := DaysBetween(tblTitulosDT_PAGAMENTO.AsDateTime,
tblTitulosDT_VENCIMENTO.AsDateTime);
mes := inttostr(strtoint(copy(FormatDateTime('yyyy-mm-dd',
tblTitulosDT_PAGAMENTO.AsDateTime), 6, 2)));
ano := copy(FormatDateTime('yyyy-mm-dd',
tblTitulosDT_PAGAMENTO.AsDateTime), 1, 4);
tblEmpresaRepasse.Locate('ID_MES;ID_ANO',
VarArrayOf([mes, ano]), []);
rotblRepasseFase.Close;
rotblRepasseFase.SQL.Text :=
'select * from sys_repasses_fases where id_repasse = ' +
QuotedStr(tblEmpresaRepasseID_ITEM.AsString) +
' and min_atraso <= ' + inttostr(atraso) + ' and ' +
inttostr(atraso) + ' <= max_atraso';
rotblRepasseFase.Open;
if not rotblRepasseFase.IsEmpty then
begin
help_pr := (rotblRepasseFasePR_PRINCIPAL.AsCurrency / 100);
help_j := (rotblRepasseFasePR_JUROS.AsCurrency / 100);
help_m := (rotblRepasseFasePR_MULTA.AsCurrency / 100);
help_enc := (rotblRepasseFasePR_ENCARGOS.AsCurrency / 100);
help_cor := (rotblRepasseFasePR_CORRIGIDO.AsCurrency / 100);
end
else
begin
help_pr :=
(dtmSystem.tblEmpresaRepassePR_PRINCIPAL.AsCurrency / 100);
help_j := (dtmSystem.tblEmpresaRepassePR_JUROS.AsCurrency / 100);
help_m := (dtmSystem.tblEmpresaRepassePR_MULTA.AsCurrency / 100);
help_enc :=
(dtmSystem.tblEmpresaRepassePR_ENCARGOS.AsCurrency / 100);
help_cor :=
(dtmSystem.tblEmpresaRepassePR_CORRIGIDO.AsCurrency / 100);
end;
tblTitulosVL_REPASSE_PRIN.AsCurrency :=
(tblTitulosVL_TITULO.AsCurrency -
tblTitulosVL_DESC_PRINCIPAL.AsCurrency) * help_pr;
tblTitulosVL_REPASSE_JUROS.AsCurrency :=
tblTitulosVL_JUROS.AsCurrency * help_j;
tblTitulosVL_REPASSE_MULTA.AsCurrency :=
tblTitulosVL_MULTA.AsCurrency * help_m;
tblTitulosVL_REPASSE_ENCARGOS.AsCurrency :=
tblTitulosVL_ENCARGOS.AsCurrency * help_enc;
tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency :=
tblTitulosVL_CORRIGIDO.AsCurrency * help_cor;
end;
if parcelas_pagamento = 2 then
begin
tblTitulosTP_SITUACAO.AsString := 'QC';
end
else
begin
if index_pagamento <> 2 then
begin
tblTitulosTP_SITUACAO.AsString := 'QC';
end
else
begin
tblTitulosTP_SITUACAO.AsString := 'A';
end;
end;
// end;
if multi_form_pag then
begin
tblTitulosTP_MOTIVO.AsString := 'Q';
end;
if acordo_fora then
begin
tblCHGEmpresa.Locate('ID_EMPRESA', acordo_emp, []);
end
else
begin
tblCHGEmpresa.Locate('ID_EMPRESA',
tblTitulosID_EMPRESA.AsInteger, []);
end;
tblTitulos.Post;
if index_pagamento <> 3 then
begin
string_helper := string_helper + 'O título ' +
tblTitulosTX_PRODUTO.AsString + ' - ' +
tblTitulosCD_DEVEDOR.AsString + ' da empresa ' +
tblCHGEmpresaTX_NOME.AsString + ', pertencente ao devedor ' +
tblDevedoresTX_NOME.AsString + ' com vencimento original de ' +
DateToStr(dateof(tblTitulosDT_VENCIMENTO.AsDateTime)) +
' foi quitado no dia ' + DateToStr(Date) + ' na empresa ' +
tblEmpresaTX_NOME.AsString + '.' + sLineBreak + sLineBreak +
'Valor corrigido: ' +
CurrToStrF(queryListaTitulosVL_CORRIGIDO.AsCurrency, ffCurrency,
2, dtmSystem.CusFmt) + '.' + sLineBreak + sLineBreak +
'Valor nominal: ' +
CurrToStrF(queryListaTitulosVL_TITULO.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.';
vencs := vencs +
DateToStr(dateof(tblTitulosDT_VENCIMENTO.AsDateTime)) +
sLineBreak;
if cb_nmulta.Checked then
begin
string_helper := string_helper + sLineBreak +
'Não foi cobrado multa.';
end
else
begin
string_helper := string_helper + sLineBreak + 'Valor da multa: ' +
CurrToStrF(queryListaTitulosVL_MULTA.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.';
end;
string_helper := string_helper + sLineBreak + 'Valor do juros: ' +
CurrToStrF(queryListaTitulosVL_JUROS.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.' + sLineBreak + 'Valor de encargos: ' +
// CurrToStrF(queryListaTitulosVL_INDICADOR.AsCurrency, ffCurrency,
CurrToStrF(queryListaTitulosVL_INDICADOR.AsCurrency, ffCurrency,
2, dtmSystem.CusFmt) + '.';
string_helper := string_helper + sLineBreak;
end
else
begin
string_helper := string_helper +
'Aguardando abate de cheque para baixa do título : ' +
tblTitulosTX_PRODUTO.AsString + sLineBreak;
end;
end;
end;
Application.ProcessMessages;
pb_atendimento.StepIt;
end;
lbl_processo.Caption := 'Títulos Baixados.';
if cbx_txextra.Checked then
begin
string_helper := string_helper + sLineBreak +
'Taxa de pagamento em múltiplas formas: ' + edt_txextra.Text;
end;
if cb_descquit.Checked then
begin
string_helper := string_helper + sLineBreak +
'Foi concedido descontos conforme a seguir:' + sLineBreak +
'Porcentagem sobre principal: ' + edt_principalquitar.Text + '%.' +
sLineBreak + 'Porcentagem sobre multa: ' + edt_multasquitar.Text + '%.'
+ sLineBreak + 'Porcentagem sobre juros: ' + edt_jurosquitar.Text + '%.'
+ sLineBreak + 'Porcentagem sobre encargos: ' + edt_indquitar.Text +
'%.' + sLineBreak + 'Porcentagem sobre corrigido: ' +
edt_corquitar.Text + '%.';
end;
string_helper := string_helper + sLineBreak + 'Forma de Pagamento: ' +
cb_formapag.Text;
string_helper := string_helper + sLineBreak + 'Recibo referente: ' +
nr_recibo;
string_helper := string_helper + sLineBreak + 'Vencimentos: ';
string_helper := string_helper + sLineBreak + vencs;
string_helper := string_helper + sLineBreak + 'Observações: ' +
mem_obsrecibo.Lines.Text;
// with dtmSystem do
// begin
// tblHistorico.Append;
// tblHistoricoID_DEVEDOR.AsInteger := tblDevedoresID_DEVEDOR.AsInteger;
// tblHistoricoID_COBRADOR.AsInteger := dtmSystem.id_usuario;
// tblHistoricoID_PROVIDENCIA.AsInteger :=
// tblProvidenciasID_PROVIDENCIA.AsInteger;
// tblHistoricoDT_CONTATO.AsDateTime := Now;
// tblHistoricoTL_MEMO.AsString := string_helper;
// tblHistorico.Post;
// id_histo := tblHistoricoID_HISTORICO.AsInteger;
// end;
end;
if (forma_pagamento = 'P') and (not(parcelas_pagamento = 2)) then
begin
pb_atendimento.Step := floor(50 / quant_titulos);
id_titulos := '';
id_acordo := dtmSystem.NovoCodigo('SYS_ACORDOS', 'ID_ACORDO');
{ variáveis novas }
// p_juros := 0;
// p_multa := 0;
// p_encargos := 0;
// p_desc := 0;
rep_prin := 0;
rep_jur := 0;
rep_mul := 0;
rep_enc := 0;
rep_cor := 0;
cont := 0;
vl_pr := 0;
vl_j := 0;
vl_m := 0;
vl_enc := 0;
vl_cor := 0;
vl_desc := 0;
pr_pr := 0;
pr_j := 0;
pr_m := 0;
pr_enc := 0;
pr_cor := 0;
{ variáveis novas }
Count := 0;
for i := 0 to lv_titulos.Items.Count - 1 do
begin
Application.ProcessMessages;
if lv_titulos.Items[i].Checked then
begin
str_titulos := str_titulos + queryListaTitulosID_TITULO.AsString + ';';
queryListaTitulos.RecNo := i + 1;
lbl_processo.Caption := 'Baixando Títulos... Título ' +
inttostr(Count + 1);
Inc(Count);
with dtmSystem do
begin
tblTitulos.Locate('ID_TITULO',
queryListaTitulosID_TITULO.AsInteger, []);
GuardaTitulos;
id_titulos := id_titulos + tblTitulosID_TITULO.AsString + ';';
tblTitulos.Edit;
tblTitulosTP_PRESTACAO.AsString := 'N';
tblTitulosTP_SITUACAO.AsString := 'QC';
tblTitulosVL_MULTA.AsCurrency := queryListaTitulosVL_MULTA.AsCurrency
- (queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency);
tblTitulosVL_DESC_MULTA.AsCurrency :=
(queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency +
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency);
tblTitulosVL_INDICADOR.AsCurrency :=
queryListaTitulosVL_INDICADOR.AsCurrency -
(queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
tblTitulosVL_DESC_INDICADOR.AsCurrency :=
(queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
tblTitulosVL_JUROS.AsCurrency := queryListaTitulosVL_JUROS.AsCurrency
- (queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency);
tblTitulosVL_DESC_JUROS.AsCurrency :=
(queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency +
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency);
tblTitulosVL_DESC_PRINCIPAL.AsCurrency :=
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency +
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency;
tblTitulosVL_ENCARGOS.AsCurrency :=
queryListaTitulosVL_INDICADOR.AsCurrency +
// queryListaTitulosVL_RETIRADA_TAXA.AsCurrency +
ent_help - (queryListaTitulosVL_DESC_QUIT_IND.AsCurrency +
queryListaTitulosVL_DESC_PAR_IND.AsCurrency);
tblTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency;
tblTitulosQTDE_PARCELAS.AsInteger := strtoint(edt_nrparcelas.Text); //
{ variáveis novas }
vl_pr := vl_pr + tblTitulosVL_TITULO.AsCurrency;
vl_j := vl_j + tblTitulosVL_JUROS.AsCurrency;
vl_m := vl_m + tblTitulosVL_MULTA.AsCurrency;
vl_enc := vl_enc + tblTitulosVL_ENCARGOS.AsCurrency;
vl_cor := vl_cor + tblTitulosVL_CORRIGIDO.AsCurrency;
vl_desc := vl_desc + tblTitulosVL_DESC_PRINCIPAL.AsCurrency;
// p_juros := p_juros + tblTitulosVL_JUROS.AsCurrency;
// p_multa := p_multa + tblTitulosVL_MULTA.AsCurrency;
// p_encargos := p_encargos + tblTitulosVL_ENCARGOS.AsCurrency;
// p_desc := p_desc + tblTitulosVL_DESC_PRINCIPAL.AsCurrency;
{ variáveis novas }
if multi_form_pag then
begin
tblTitulosTP_MOTIVO.AsString := 'Q';
end;
tblTitulosDT_PAGAMENTO.AsDateTime := dateof(dtp_atrasorecalc.Date);
if acordo_fora then
begin
tblCHGEmpresa.Locate('ID_EMPRESA', acordo_emp, []);
end
else
begin
tblCHGEmpresa.Locate('ID_EMPRESA',
tblTitulosID_EMPRESA.AsInteger, []);
end;
atraso := DaysBetween(tblTitulosDT_PAGAMENTO.AsDateTime,
tblTitulosDT_VENCIMENTO.AsDateTime);
mes := inttostr(strtoint(copy(FormatDateTime('yyyy-mm-dd',
tblTitulosDT_PAGAMENTO.AsDateTime), 6, 2)));
ano := copy(FormatDateTime('yyyy-mm-dd',
tblTitulosDT_PAGAMENTO.AsDateTime), 1, 4);
tblEmpresaRepasse.Locate('ID_MES;ID_ANO', VarArrayOf([mes, ano]), []);
rotblRepasseFase.Close;
rotblRepasseFase.SQL.Text :=
'select * from sys_repasses_fases where id_repasse = ' +
QuotedStr(tblEmpresaRepasseID_ITEM.AsString) +
' and min_atraso <= ' + inttostr(atraso) + ' and ' +
inttostr(atraso) + ' <= max_atraso';
rotblRepasseFase.Open;
if not rotblRepasseFase.IsEmpty then
begin
help_pr := (rotblRepasseFasePR_PRINCIPAL.AsCurrency / 100);
help_j := (rotblRepasseFasePR_JUROS.AsCurrency / 100);
help_m := (rotblRepasseFasePR_MULTA.AsCurrency / 100);
help_enc := (rotblRepasseFasePR_ENCARGOS.AsCurrency / 100);
help_cor := (rotblRepasseFasePR_CORRIGIDO.AsCurrency / 100);
end
else
begin
help_pr :=
(dtmSystem.tblEmpresaRepassePR_PRINCIPAL.AsCurrency / 100);
help_j := (dtmSystem.tblEmpresaRepassePR_JUROS.AsCurrency / 100);
help_m := (dtmSystem.tblEmpresaRepassePR_MULTA.AsCurrency / 100);
help_enc :=
(dtmSystem.tblEmpresaRepassePR_ENCARGOS.AsCurrency / 100);
help_cor :=
(dtmSystem.tblEmpresaRepassePR_CORRIGIDO.AsCurrency / 100);
end;
tblTitulosVL_REPASSE_PRIN.AsCurrency :=
(tblTitulosVL_TITULO.AsCurrency -
tblTitulosVL_DESC_PRINCIPAL.AsCurrency) * help_pr;
tblTitulosVL_REPASSE_JUROS.AsCurrency :=
tblTitulosVL_JUROS.AsCurrency * help_j;
tblTitulosVL_REPASSE_MULTA.AsCurrency :=
tblTitulosVL_MULTA.AsCurrency * help_m;
tblTitulosVL_REPASSE_ENCARGOS.AsCurrency :=
tblTitulosVL_ENCARGOS.AsCurrency * help_enc;
tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency :=
tblTitulosVL_CORRIGIDO.AsCurrency * help_cor;
// rep_prin := rep_prin + tblTitulosVL_REPASSE_PRIN.AsCurrency;
// rep_jur := rep_jur + tblTitulosVL_REPASSE_JUROS.AsCurrency;
// rep_mul := rep_mul + tblTitulosVL_REPASSE_MULTA.AsCurrency;
// rep_enc := rep_enc + tblTitulosVL_REPASSE_ENCARGOS.AsCurrency;
// rep_cor := rep_cor + tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency;
tblTitulos.Post;
string_helper := string_helper + 'O título ' +
tblTitulosTX_PRODUTO.AsString + ' - ' +
tblTitulosCD_DEVEDOR.AsString + ' da empresa ' +
tblCHGEmpresaTX_NOME.AsString + ', pertencente ao devedor ' +
tblDevedoresTX_NOME.AsString + ' com vencimento original de ' +
DateToStr(dateof(tblTitulosDT_VENCIMENTO.AsDateTime)) +
' foi parcelado no dia ' + DateToStr(Date) + ' na empresa ' +
tblEmpresaTX_NOME.AsString + '.';
if acordo_fora then
begin
string_helper := string_helper + sLineBreak +
'As parcelas foram vinculadas com a empresa ' + acordo_fantasia;
end;
string_helper := string_helper + sLineBreak + 'Valor corrigido: ' +
CurrToStrF(queryListaTitulosVL_CORRIGIDO.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.' + sLineBreak + 'Valor nominal: ' +
CurrToStrF(queryListaTitulosVL_TITULO.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.' + sLineBreak + 'Quantidade de parcelas: ' +
edt_nrparcelas.Text + '.' + sLineBreak + 'Valor da entrada: ' +
CurrToStrF(queryListaTitulosVL_ENTRADA.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.' + sLineBreak + 'Valor da parcela: ' +
CurrToStrF(queryListaTitulosVL_PARCELA.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.';
vencs := vencs + DateToStr(dateof(tblTitulosDT_VENCIMENTO.AsDateTime))
+ sLineBreak;
if cb_nmulta.Checked then
begin
string_helper := string_helper + sLineBreak +
'Não foi cobrado multa.';
end
else
begin
string_helper := string_helper + sLineBreak + 'Valor da multa: ' +
CurrToStrF(queryListaTitulosVL_MULTA.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.';
end;
string_helper := string_helper + sLineBreak + 'Valor do juros: ' +
CurrToStrF(queryListaTitulosVL_JUROS.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.' + sLineBreak + 'Valor de encargos: ' +
CurrToStrF(queryListaTitulosVL_INDICADOR.AsCurrency, ffCurrency, 2,
dtmSystem.CusFmt) + '.';
string_helper := string_helper + sLineBreak;
end;
pb_atendimento.StepIt;
end;
end;
for i := 0 to lv_titulos.Items.Count - 1 do
begin
Application.ProcessMessages;
if lv_titulos.Items[i].Checked then
begin
queryListaTitulos.RecNo := i + 1;
cont := cont + 1;
setlength(ac_pr, cont);
setlength(ac_j, cont);
setlength(ac_m, cont);
setlength(ac_enc, cont);
setlength(ac_cor, cont);
with dtmSystem do
begin
tblTitulos.Locate('ID_TITULO',
queryListaTitulosID_TITULO.AsInteger, []);
if acordo_fora then
begin
tblCHGEmpresa.Locate('ID_EMPRESA', acordo_emp, []);
end
else
begin
tblCHGEmpresa.Locate('ID_EMPRESA',
tblTitulosID_EMPRESA.AsInteger, []);
end;
atraso := DaysBetween(tblTitulosDT_PAGAMENTO.AsDateTime,
tblTitulosDT_VENCIMENTO.AsDateTime);
mes := inttostr(strtoint(copy(FormatDateTime('yyyy-mm-dd',
tblTitulosDT_PAGAMENTO.AsDateTime), 6, 2)));
ano := copy(FormatDateTime('yyyy-mm-dd',
tblTitulosDT_PAGAMENTO.AsDateTime), 1, 4);
tblEmpresaRepasse.Locate('ID_MES;ID_ANO', VarArrayOf([mes, ano]), []);
rotblRepasseFase.Close;
rotblRepasseFase.SQL.Text :=
'select * from sys_repasses_fases where id_repasse = ' +
QuotedStr(tblEmpresaRepasseID_ITEM.AsString) +
' and min_atraso <= ' + inttostr(atraso) + ' and ' +
inttostr(atraso) + ' <= max_atraso';
rotblRepasseFase.Open;
if not rotblRepasseFase.IsEmpty then
begin
help_pr := (rotblRepasseFasePR_PRINCIPAL.AsCurrency / 100);
help_j := (rotblRepasseFasePR_JUROS.AsCurrency / 100);
help_m := (rotblRepasseFasePR_MULTA.AsCurrency / 100);
help_enc := (rotblRepasseFasePR_ENCARGOS.AsCurrency / 100);
help_cor := (rotblRepasseFasePR_CORRIGIDO.AsCurrency / 100);
end
else
begin
help_pr :=
(dtmSystem.tblEmpresaRepassePR_PRINCIPAL.AsCurrency / 100);
help_j := (dtmSystem.tblEmpresaRepassePR_JUROS.AsCurrency / 100);
help_m := (dtmSystem.tblEmpresaRepassePR_MULTA.AsCurrency / 100);
help_enc :=
(dtmSystem.tblEmpresaRepassePR_ENCARGOS.AsCurrency / 100);
help_cor :=
(dtmSystem.tblEmpresaRepassePR_CORRIGIDO.AsCurrency / 100);
end;
ac_pr[cont - 1] := tblTitulosVL_REPASSE_PRIN.AsCurrency;
ac_j[cont - 1] := tblTitulosVL_REPASSE_JUROS.AsCurrency;
ac_m[cont - 1] := tblTitulosVL_REPASSE_MULTA.AsCurrency;
ac_enc[cont - 1] := tblTitulosVL_REPASSE_ENCARGOS.AsCurrency;
ac_cor[cont - 1] := tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency;
if vl_pr <> 0 then
begin
pr_pr := pr_pr + ((ac_pr[cont - 1] * 100) / vl_pr);
end;
if vl_j <> 0 then
begin
pr_j := pr_j + ((ac_j[cont - 1] * 100) / vl_j);
end;
if vl_m <> 0 then
begin
pr_m := pr_m + ((ac_m[cont - 1] * 100) / vl_m);
end;
if vl_enc <> 0 then
begin
pr_enc := pr_enc + ((ac_enc[cont - 1] * 100) / vl_enc);
end;
if vl_cor <> 0 then
begin
pr_cor := pr_cor + ((ac_cor[cont - 1] * 100) / vl_cor);
end;
end;
end;
end;
if cbx_txextra.Checked then
begin
string_helper := string_helper + sLineBreak +
'Taxa de pagamento em múltiplas formas: ' + edt_txextra.Text;
end;
if cb_descpar.Checked then
begin
string_helper := string_helper + sLineBreak +
'Foi concedido descontos conforme a seguir:' + sLineBreak +
'Porcentagem sobre principal: ' + edt_principalparcelas.Text + '%.' +
sLineBreak + 'Porcentagem sobre multa: ' + edt_multasparcelas.Text +
'%.' + sLineBreak + 'Porcentagem sobre juros: ' + edt_jurosparcelas.Text
+ '%.' + sLineBreak + 'Porcentagem sobre encargos: ' +
edt_indparcelas.Text + '%.' + sLineBreak +
'Porcentagem sobre corrigido: ' + edt_corpar.Text + '%.';
end;
string_helper := string_helper + sLineBreak + 'Forma de Pagamento: ' +
cb_formapag.Text;
string_helper := string_helper + sLineBreak + 'Recibo referente: ' +
nr_recibo;
string_helper := string_helper + sLineBreak + 'Vencimentos: ';
string_helper := string_helper + sLineBreak + vencs;
string_helper := string_helper + sLineBreak + 'Observações: ' +
mem_obsrecibo.Lines.Text;
// with dtmSystem do
// begin
// tblHistorico.Append;
// tblHistoricoID_DEVEDOR.AsInteger := tblDevedoresID_DEVEDOR.AsInteger;
// tblHistoricoID_COBRADOR.AsInteger := dtmSystem.id_usuario;
// tblHistoricoID_PROVIDENCIA.AsInteger :=
// tblProvidenciasID_PROVIDENCIA.AsInteger;
// tblHistoricoDT_CONTATO.AsDateTime := Now;
// tblHistoricoTL_MEMO.AsString := string_helper;
// tblHistorico.Post;
// id_histo := tblHistoricoID_HISTORICO.AsInteger;
// end;
pb_atendimento.StepBy(50 - pb_atendimento.Position);
lbl_processo.Caption := 'Criando Títulos do Financiamento...';
pb_atendimento.Step := Ceil(50 / lv_fechamento.Items.Count);
{ variáveis novas }
{ if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])) <> 0.00 then
begin
p_juros := p_juros / lv_fechamento.Items.Count;
p_multa := p_multa / lv_fechamento.Items.Count;
p_encargos := p_encargos / lv_fechamento.Items.Count;
p_desc := p_desc / lv_fechamento.Items.Count;
// rep_prin := rep_prin / lv_fechamento.Items.Count;
// rep_jur := rep_jur / lv_fechamento.Items.Count;
// rep_mul := rep_mul / lv_fechamento.Items.Count;
// rep_enc := rep_enc / lv_fechamento.Items.Count;
// rep_cor := rep_cor / lv_fechamento.Items.Count;
end
else
begin
p_juros := p_juros / (lv_fechamento.Items.Count - 1);
p_multa := p_multa / (lv_fechamento.Items.Count - 1);
p_encargos := p_encargos / (lv_fechamento.Items.Count - 1);
p_desc := p_desc / (lv_fechamento.Items.Count - 1);
// rep_prin := rep_prin / (lv_fechamento.Items.Count - 1);
// rep_jur := rep_jur / (lv_fechamento.Items.Count - 1);
// rep_mul := rep_mul / (lv_fechamento.Items.Count - 1);
// rep_enc := rep_enc / (lv_fechamento.Items.Count - 1);
// rep_cor := rep_cor / (lv_fechamento.Items.Count - 1);
end; }
{ variáveis novas }
error_criar_titulo := false;
for j := 0 to lv_fechamento.Items.Count - 1 do
begin
Application.ProcessMessages;
try
with dtmSystem do
begin
lbl_processo.Caption := 'Criando Títulos do Financiamento... Título '
+ inttostr(j + 1) + ' de ' + inttostr(lv_fechamento.Items.Count);
tblTitulos.Append;
if (j = 0) and
(StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])) <> 0)
then
begin
tblTitulosTX_PRODUTO.AsString := 'Entrada';
if acordo_fora then
begin
tblTitulosID_EMPRESA.AsInteger := acordo_emp;
end
else
begin
tblTitulosID_EMPRESA.AsInteger := id_emp;
end;
tblTitulosDT_VENCIMENTO.AsDateTime := Date;
tblTitulosDT_ENTRADA.AsDateTime := Date;
tblTitulosVL_TITULO.AsCurrency :=
StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll]))
{ variáveis novas } { - p_juros - p_multa - p_encargos +
p_desc }{ variáveis novas };
tblTitulosVL_CORRIGIDO.AsCurrency :=
tblTitulosVL_TITULO.AsCurrency { variáveis novas } { + p_juros +
p_multa + p_encargos - p_desc }{ variáveis novas };
if index_pagamento <> 2 then
begin
tblTitulosTP_SITUACAO.AsString := 'QC';
tblTitulosTP_PRESTACAO.AsString := 'N';
// tblTitulosVL_REPASSE_PRIN.AsCurrency := rep_prin;
// tblTitulosVL_REPASSE_JUROS.AsCurrency := rep_jur;
// tblTitulosVL_REPASSE_MULTA.AsCurrency := rep_mul;
// tblTitulosVL_REPASSE_ENCARGOS.AsCurrency := rep_enc;
// tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency := rep_cor - tblTitulosVL_CORRIGIDO.AsCurrency;
// tblTitulosDT_PAGAMENTO.AsDateTime := dateof(Date);
// tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
if dateof(dtp_atrasorecalc.Date) <> dateof(Date) then
begin
tblTitulosDT_EMISSAO_RECIBO.AsDateTime := dateof(Date);
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end
else
begin
tblTitulosDT_PAGAMENTO.AsDateTime :=
dateof(dtp_atrasorecalc.Date);
end;
end
else
begin
tblTitulosTP_SITUACAO.AsString := 'AC';
end;
{ variáveis novas }
tblTitulosVL_JUROS.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_j) / vl_cor;
tblTitulosVL_MULTA.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_m) / vl_cor;
tblTitulosVL_ENCARGOS.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_enc) / vl_cor;
tblTitulosVL_DESC_PRINCIPAL.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_desc) / vl_cor;
tblTitulosVL_REPASSE_PRIN.AsCurrency :=
((tblTitulosVL_TITULO.AsCurrency -
tblTitulosVL_DESC_PRINCIPAL.AsCurrency) * pr_pr) / 100;
tblTitulosVL_REPASSE_JUROS.AsCurrency :=
(tblTitulosVL_JUROS.AsCurrency * pr_j) / 100;
tblTitulosVL_REPASSE_MULTA.AsCurrency :=
(tblTitulosVL_MULTA.AsCurrency * pr_m) / 100;
tblTitulosVL_REPASSE_ENCARGOS.AsCurrency :=
(tblTitulosVL_ENCARGOS.AsCurrency * pr_enc) / 100;
tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * pr_cor) / 100;
// tblTitulosVL_JUROS.AsCurrency := p_juros;
// tblTitulosVL_MULTA.AsCurrency := p_multa;
// tblTitulosVL_ENCARGOS.AsCurrency := p_encargos;
// tblTitulosVL_DESC_PRINCIPAL.AsCurrency := p_desc;
{ variáveis novas }
end
else
begin
tblTitulosTX_PRODUTO.AsString := 'Parcela nº ' + inttostr(j);
if acordo_fora then
begin
tblTitulosID_EMPRESA.AsInteger := acordo_emp;
end
else
begin
tblTitulosID_EMPRESA.AsInteger := id_emp;
end;
tblTitulosDT_VENCIMENTO.AsDateTime :=
StrToDate(lv_fechamento.Items[j].SubItems[1]);
tblTitulosDT_ENTRADA.AsDateTime := Date;
tblTitulosVL_TITULO.AsCurrency :=
StrToCurr(stringreplace(copy(lv_fechamento.Items[j].SubItems[0],
4, length(lv_fechamento.Items[j].SubItems[1]) - 3), '.', '',
[rfReplaceAll])) { variáveis novas } { - p_juros - p_multa -
p_encargos + p_desc } { variáveis novas };
tblTitulosVL_CORRIGIDO.AsCurrency :=
tblTitulosVL_TITULO.AsCurrency { variáveis novas } { + p_juros +
p_multa + p_encargos - p_desc } { variáveis novas };
// if parcelas_pagamento = 2 then
// begin
// tblTitulosTP_SITUACAO.AsString := 'QC';
// end
// else
// begin
tblTitulosTP_SITUACAO.AsString := 'AC';
// end;
end;
tblTitulosTX_OBS.AsString := 'Títulos relacionados: ' + id_titulos;
tblTitulosQTDE_PARCELAS.AsInteger := qtde_parcelas;
{ variáveis novas }
tblTitulosVL_JUROS.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_j) / vl_cor;
tblTitulosVL_MULTA.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_m) / vl_cor;
tblTitulosVL_ENCARGOS.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_enc) / vl_cor;
tblTitulosVL_DESC_PRINCIPAL.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * vl_desc) / vl_cor;
tblTitulosVL_REPASSE_PRIN.AsCurrency :=
((tblTitulosVL_TITULO.AsCurrency -
tblTitulosVL_DESC_PRINCIPAL.AsCurrency) * pr_pr) / 100;
tblTitulosVL_REPASSE_JUROS.AsCurrency :=
(tblTitulosVL_JUROS.AsCurrency * pr_j) / 100;
tblTitulosVL_REPASSE_MULTA.AsCurrency :=
(tblTitulosVL_MULTA.AsCurrency * pr_m) / 100;
tblTitulosVL_REPASSE_ENCARGOS.AsCurrency :=
(tblTitulosVL_ENCARGOS.AsCurrency * pr_enc) / 100;
tblTitulosVL_REPASSE_CORRIGIDO.AsCurrency :=
(tblTitulosVL_CORRIGIDO.AsCurrency * pr_cor) / 100;
// tblTitulosVL_JUROS.AsCurrency := p_juros;
// tblTitulosVL_MULTA.AsCurrency := p_multa;
// tblTitulosVL_ENCARGOS.AsCurrency := p_encargos;
// tblTitulosVL_DESC_PRINCIPAL.AsCurrency := p_desc;
{ variáveis novas }
if multi_form_pag then
begin
tblTitulosTP_MOTIVO.AsString := 'Q';
end;
tblTitulos.Post;
cdsParcelas.Append;
cdsParcelasid_parcela.AsInteger := tblTitulosID_TITULO.AsInteger;
cdsParcelas.Post;
for ç := 0 to lv_titulos.Items.Count - 1 do
begin
if lv_titulos.Items[ç].Checked then
begin
queryListaTitulos.RecNo := ç + 1;
tblAcordos.Append;
tblAcordosID_ACORDO.AsInteger := id_acordo;
tblAcordosID_PARCELA.AsInteger := tblTitulosID_TITULO.AsInteger;
tblAcordosID_ORIGINAL.AsInteger :=
queryListaTitulosID_TITULO.AsInteger;
tblAcordosID_DEVEDOR.AsInteger :=
tblDevedoresID_DEVEDOR.AsInteger;
tblAcordos.Post;
Application.ProcessMessages;
end;
end;
end;
pb_atendimento.StepIt;
Application.ProcessMessages;
except
on E: Exception do
begin
error_criar_titulo := true;
Showmessage
('Houve um erro na criação dos títulos do financiamento. Voltando estado dos títulos para antes do acordo. '
+ E.Message);
lbl_processo.Caption := 'Quebrando acordo...';
while dtmSystem.tblAcordos.Locate('id_acordo', id_acordo, []) do
begin
dtmSystem.tblAcordos.Delete;
Application.ProcessMessages;
end;
lbl_processo.Caption := 'Apagando títulos gerados do acordo...';
while not cdsParcelas.IsEmpty do
begin
Application.ProcessMessages;
lbl_processo.Caption :=
'Apagando títulos gerados do acordo... Parcelas Restantes: ' +
inttostr(cdsParcelas.RecordCount);
dtmSystem.tblTitulos.Locate('ID_TITULO',
cdsParcelasid_parcela.AsInteger, []);
dtmSystem.tblTitulos.Delete;
cdsParcelas.Delete;
end;
cdsParcelas.Close;
lbl_processo.Caption :=
'Retornando Títulos aos seus estados originais...';
while not cdsTitulos.IsEmpty do
begin
Application.ProcessMessages;
lbl_processo.Caption :=
'Retornando Títulos aos seus estados originais... Títulos Restantes: '
+ inttostr(cdsTitulos.RecordCount);
dtmSystem.tblTitulos.Locate('ID_TITULO',
cdsTitulosID_TITULO.AsInteger, []);
dtmSystem.tblTitulos.Edit;
for l := 1 to cdsTitulos.Fields.Count - 1 do
begin
dtmSystem.tblTitulos.FieldByName(cdsTitulos.Fields[l].FieldName)
.AsVariant := cdsTitulos.Fields[l].AsVariant;
end;
dtmSystem.tblTitulos.Post;
cdsTitulos.Delete;
end;
Showmessage('Processo terminado!');
Screen.Cursor := crDefault;
lbl_processo.Caption := 'Processo revertido.';
end;
end;
end;
end;
if not error_criar_titulo then
begin
try
with dtmSystem do
begin
tblCampanhaDevedores.Filtered := false;
while tblCampanhaDevedores.Locate('ID_DEVEDOR',
tblDevedoresID_DEVEDOR.AsInteger, []) do
begin
if tblCampanhaDevedoresTP_ESTADO.AsString = 'A' then
begin
tblCampanhaDevedores.Edit;
tblCampanhaDevedoresTP_ESTADO.AsString := 'B';
tblCampanhaDevedores.Post;
end;
end;
// tblCampanhaDevedores.Filtered := true;
if not(tblAgenda.Active) then
begin
tblAgenda.Open;
end;
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;
Application.ProcessMessages;
end;
end;
if not(dtmSystem.tblAgenda.Active) then
begin
dtmSystem.tblAgenda.Open;
end;
dtmSystem.tblAgenda.Append;
dtmSystem.tblAgendaID_COBRADOR.AsInteger := dblucb_agatend.KeyValue;
dtmSystem.tblAgendaID_DEVEDOR.AsInteger :=
dtmSystem.tblDevedoresID_DEVEDOR.AsInteger;
dtmSystem.tblAgendaDT_AGENDADA.AsDateTime := dtp_agatend.Date;
dtmSystem.tblAgendaHR_AGENDADA.AsDateTime := dtph_agatend.Time;
dtmSystem.tblAgendaDT_QUE_AGENDOU.AsDateTime := Now;
dtmSystem.tblAgendaQUEM_AGENDOU.AsInteger := dtmSystem.id_usuario;
dtmSystem.tblAgenda.Post;
string_helper := string_helper + sLineBreak + 'Agendado para: ' +
dblucb_agatend.Text + sLineBreak + 'Dia: ' + DateToStr(dtp_agatend.Date)
+ sLineBreak + 'Hora: ' + TimeToStr(dtph_agatend.Time);
except
Messagedlg('Erro ao tentar gerar agendamento.', mtError, [mbok], 0);
end;
try
with dtmSystem do
begin
tblHistorico.Append;
tblHistoricoID_DEVEDOR.AsInteger := tblDevedoresID_DEVEDOR.AsInteger;
tblHistoricoID_COBRADOR.AsInteger := dtmSystem.id_usuario;
tblHistoricoID_PROVIDENCIA.AsInteger :=
tblProvidenciasID_PROVIDENCIA.AsInteger;
tblHistoricoDT_CONTATO.AsDateTime := Now;
tblHistoricoTL_MEMO.AsString := string_helper;
tblHistorico.Post;
end;
except
Messagedlg('Erro ao tentar gerar histórico.', mtError, [mbok], 0);
end;
// if dtmSystem.tblHistoricoID_HISTORICO.AsInteger <> id_histo then
// begin
// dtmSystem.tblHistorico.Locate('ID_HISTORICO', id_histo, []);
// end;
// dtmSystem.tblHistorico.Edit;
// dtmSystem.tblHistoricoTL_MEMO.AsString :=
// dtmSystem.tblHistoricoTL_MEMO.AsString + sLineBreak + 'Agendado para: ' +
// dblucb_agatend.Text + sLineBreak + 'Dia: ' + DateToStr(dtp_agatend.Date) +
// sLineBreak + 'Hora: ' + TimeToStr(dtph_agatend.Time);
// dtmSystem.tblHistorico.Post;
// cb_agendaatend.Checked := false;
// dtp_agatend.Enabled := false;
dtp_agatend.Date := Date;
// dtph_agatend.Enabled := false;
dtph_agatend.Time := Now;
// dblucb_agatend.Enabled := false;
dblucb_agatend.KeyValue := 0;
lbl_processo.Caption := 'Terminou!';
Screen.Cursor := crDefault;
atendimento := 'atendendo';
pcDevedor.TabIndex := 0;
btn_concluir.Enabled := false;
edt_prov.Text := '';
Messagedlg('Processo terminado!', mtWarning, [mbok], 0);
btn_verrecibos.Enabled := true;
setlength(ids_tits_calc, 0);
setlength(str_tit, 0);
fez_recibo := false;
// Close;
end;
end;
procedure TfrmAtendimento.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;
procedure TfrmAtendimento.CalcValorParcelas;
var
i, j, k, Y: Integer;
data_helper: TDate;
dia_antes, dia_depois, mes, ano: Word;
begin
setlength(parcelamento, 0);
lv_parcelas.Clear;
if strtoint(edt_nrparcelas.Text) >= 1 then
begin
setlength(parcelamento, strtoint(edt_nrparcelas.Text));
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;
lv_parcelas.Items.Add;
lv_parcelas.Items[0].Caption := 'Entrada';
lv_parcelas.Items[0].SubItems.Add(edt_somaentrada.Text);
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 TfrmAtendimento.CarregaProtocolo;
var
qnt_titulos: Integer;
i: Integer;
list_titulos: TStringList;
h: Integer;
formapag: string;
begin
list_titulos := TStringList.Create;
list_titulos.Clear;
list_titulos.Delimiter := ';';
qnt_titulos := dtmSystem.tblProtocoloQNT_TITULOS.AsInteger;
list_titulos.DelimitedText := dtmSystem.tblProtocoloID_TITULOS.AsString;
queryListaTitulos.First;
dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA',
dtmSystem.tblProtocoloID_EMPRESA.AsInteger, []);
for h := 0 to clb_beneficiarioscalculo.Items.Count - 1 do
begin
if clb_beneficiarioscalculo.Items[h] = dtmSystem.tblCHGEmpresaTX_NOME.AsString
then
begin
clb_beneficiarioscalculo.Checked[h] := true;
end;
end;
for i := 0 to qnt_titulos - 1 do
begin
while not queryListaTitulos.Eof do
begin
if list_titulos[i] = queryListaTitulosID_TITULO.AsString then
begin
lv_titulos.Items[queryListaTitulos.RecNo - 1].Checked := true;
end;
queryListaTitulos.Next;
end;
end;
if dtmSystem.tblProtocoloTP_DESC_QUIT.AsString = 'S' then
begin
cb_descquit.Checked;
cb_descquitClick(self);
edt_indquitar.Text := dtmSystem.tblProtocoloPR_QUIT_INDICADOR.AsString;
edt_jurosquitar.Text := dtmSystem.tblProtocoloPR_QUIT_JUROS.AsString;
edt_multasquitar.Text := dtmSystem.tblProtocoloPR_QUIT_MULTA.AsString;
edt_corquitar.Text := dtmSystem.tblProtocoloPR_QUIT_COR.AsString;
edt_principalquitar.Text :=
dtmSystem.tblProtocoloPR_QUIT_PRINCIPAL.AsString;
if dtmSystem.tblProtocoloTP_DESC_QUIT_COR.AsString = 'S' then
begin
cb_desc_quit_cor.Enabled := true;
edt_corquitar.Text := dtmSystem.tblProtocoloPR_QUIT_COR.AsString;
end;
end;
if dtmSystem.tblProtocoloTP_DESC_PAR.AsString = 'S' then
begin
cb_descpar.Checked;
cb_descparClick(self);
edt_indparcelas.Text :=
dtmSystem.tblProtocoloPR_PARCELAR_INDICADOR.AsString;
edt_jurosparcelas.Text := dtmSystem.tblProtocoloPR_PARCELAR_JUROS.AsString;
edt_multasparcelas.Text := dtmSystem.tblProtocoloPR_PARCELAR_MULTA.AsString;
edt_corpar.Text := dtmSystem.tblProtocoloPR_PARCELAR_COR.AsString;
edt_principalparcelas.Text :=
dtmSystem.tblProtocoloPR_PARCELAR_PRINCIPAL.AsString;
if dtmSystem.tblProtocoloTP_DESC_PAR_COR.AsString = 'S' then
begin
cb_desc_par_cor.Enabled := true;
edt_corpar.Text := dtmSystem.tblProtocoloPR_PARCELAR_COR.AsString;
end;
end;
edt_prentrada.Text := formatfloat('#,00',
dtmSystem.tblProtocoloPR_ENTRADA.AsFloat);
if dtmSystem.tblProtocoloTP_PAG.AsString = 'DI' then
begin
formapag := 'Dinheiro';
end;
if dtmSystem.tblProtocoloTP_PAG.AsString = 'CQ' then
begin
formapag := 'Cheque';
end;
if dtmSystem.tblProtocoloTP_PAG.AsString = 'DB' then
begin
formapag := 'Débito';
end;
if dtmSystem.tblProtocoloTP_PAG.AsString = 'CR' then
begin
formapag := 'Crédito';
end;
cb_formapag.ItemIndex := cb_formapag.Items.IndexOf(formapag);
CalcValorParcelas;
Att_campos;
end; }
procedure TfrmAtendimento.cbx_acrfixoClick(Sender: TObject);
begin
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.cbx_descfixoClick(Sender: TObject);
begin
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.cbx_despesasClick(Sender: TObject);
begin
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.cbx_excentradaClick(Sender: TObject);
begin
edt_excentrada.Enabled := cbx_excentrada.Enabled;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.cbx_exjurosparcelarClick(Sender: TObject);
begin
edt_excjurosparcela.Enabled := cbx_exjurosparcelar.Enabled;
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.cb_agendaatendClick(Sender: TObject);
begin
// dtp_agatend.Enabled := cb_agendaatend.Checked;
// dtph_agatend.Enabled := cb_agendaatend.Checked;
// dblucb_agatend.Enabled := cb_agendaatend.Checked;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.cb_descindicesextrasChange(Sender: TObject);
begin
edt_descindextras.Text := desc_indices_extras[cb_descindicesextras.ItemIndex];
end;
procedure TfrmAtendimento.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_corquitar.Text := '0';
end;
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.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_corpar.Text := '0';
end;
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.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 TfrmAtendimento.cb_formapagChange(Sender: TObject);
begin
if (cb_formapag.ItemIndex = 1) then
begin
edt_nrparcelas.Text := '0';
// edt_nrparcelas.OnChange;
end;
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.cb_nmultaClick(Sender: TObject);
begin
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.ChecaPermissoes;
begin
with dtmSystem do
begin
navdevedor.Enabled := VerificarPermissao('CBR.01.03.01.01');
navEmail.Enabled := VerificarPermissao('CBR.01.03.01.06');
if not VerificarPermissao('CBR.01.03.01.06.01') then
navEmail.VisibleButtons := navEmail.VisibleButtons - [nbInsert];
if not VerificarPermissao('CBR.01.03.01.06.02') then
navEmail.VisibleButtons := navEmail.VisibleButtons - [nbEdit];
if not VerificarPermissao('CBR.01.03.01.06.03') then
navEmail.VisibleButtons := navEmail.VisibleButtons - [nbDelete];
navenderecos.Enabled := VerificarPermissao('CBR.01.03.01.02');
if not VerificarPermissao('CBR.01.03.01.02.01') then
navenderecos.VisibleButtons := navenderecos.VisibleButtons - [nbInsert];
if not VerificarPermissao('CBR.01.03.01.02.02') then
navenderecos.VisibleButtons := navenderecos.VisibleButtons - [nbEdit];
if not VerificarPermissao('CBR.01.03.01.02.03') then
navenderecos.VisibleButtons := navenderecos.VisibleButtons - [nbDelete];
navtelefones.Enabled := VerificarPermissao('CBR.01.03.01.03');
if not VerificarPermissao('CBR.01.03.01.03.01') then
navtelefones.VisibleButtons := navtelefones.VisibleButtons - [nbInsert];
if not VerificarPermissao('CBR.01.03.01.03.02') then
navtelefones.VisibleButtons := navtelefones.VisibleButtons - [nbEdit];
if not VerificarPermissao('CBR.01.03.01.03.03') then
navtelefones.VisibleButtons := navtelefones.VisibleButtons - [nbDelete];
navtitulos.Enabled := VerificarPermissao('CBR.01.03.01.04');
if not VerificarPermissao('CBR.01.03.01.04.01') then
navtitulos.VisibleButtons := navtitulos.VisibleButtons - [nbInsert];
if not VerificarPermissao('CBR.01.03.01.04.02') then
navtitulos.VisibleButtons := navtitulos.VisibleButtons - [nbEdit];
if not VerificarPermissao('CBR.01.03.01.04.03') then
navtitulos.VisibleButtons := navtitulos.VisibleButtons - [nbDelete];
navhistorico.Enabled := VerificarPermissao('CBR.01.03.01.05');
if not VerificarPermissao('CBR.01.03.01.05.01') then
navhistorico.VisibleButtons := navhistorico.VisibleButtons - [nbInsert];
if not VerificarPermissao('CBR.01.03.01.05.02') then
navhistorico.VisibleButtons := navhistorico.VisibleButtons - [nbEdit];
if not VerificarPermissao('CBR.01.03.01.05.03') then
navhistorico.VisibleButtons := navhistorico.VisibleButtons - [nbDelete];
tabQuitar.Enabled := VerificarPermissao('CBR.01.03.02.01.01');
tabParcelar.Enabled := VerificarPermissao('CBR.01.03.02.01.02');
cbx_descindextras.Enabled := VerificarPermissao('CBR.01.03.02.01.03');
cb_nmulta.Enabled := VerificarPermissao('CBR.01.03.02.02');
cbx_txextra.Enabled := VerificarPermissao('CBR.01.03.02.03');
cbx_excentrada.Enabled := VerificarPermissao('CBR.01.03.02.04');
clb_indices.Enabled := VerificarPermissao('CBR.01.03.02.05');
end;
end;
procedure TfrmAtendimento.cbx_descindextrasClick(Sender: TObject);
begin
edt_descindextras.Enabled := cbx_descindextras.Checked;
end;
procedure TfrmAtendimento.clb_beneficiarioscalculoClickCheck(Sender: TObject);
var
i: Integer;
n_marcou: Boolean;
begin
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 TfrmAtendimento.clb_empresasClickCheck(Sender: TObject);
var
i: Integer;
begin
inherited;
// with TCheckListBox(Sender) do
// begin
// if Checked[ItemIndex] then
// begin
// Items.beginupdate;
// for i := 0 to Items.Count - 1 do
// if i = ItemIndex then
// begin
// dtmSystem.tblCHGEmpresa.Locate('TX_NOME', clb_empresas.Items[i], []);
// selected_id_chg_empresa :=
// dtmSystem.tblCHGEmpresaID_EMPRESA.AsInteger;
// continue;
// end
// else
// begin
// Checked[i] := false;
// end;
// Items.EndUpdate;
// end;
// end;
end;
procedure TfrmAtendimento.clb_indicesClickCheck(Sender: TObject);
begin
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.copiar_conteudoClick(Sender: TObject);
var
nomes, valores: array of string;
spaces: string;
i, j, tam, Count: Integer;
k: Integer;
begin
clpbrd := '';
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 TfrmAtendimento.CriarLista;
var
h: Integer;
achou: Boolean;
begin
Screen.Cursor := crHourGlass;
achou := false;
if queryListaTitulos.Connection = nil then
// BACALHAU, NÃO TEM EXPLICAÇÃO. SÓ FUNCIONA.
begin
exit;
end;
if not dtmSystem.tblCHGEmpresa.Active then
begin
dtmSystem.tblCHGEmpresa.Open;
end;
qtde_titulos := 0;
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], []);
achou := true;
end;
end;
if achou 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.DisableControls;
queryListaTitulos.First;
lv_titulos.Clear;
while not queryListaTitulos.Eof do
begin
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;
queryListaTitulos.Next;
end;
btn_fechamento.Enabled := true;
btn_amostra.Enabled := true;
end
else
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 = 0)' + ' order by DT_VENCIMENTO, VL_TITULO';
queryListaTitulos.Open;
queryListaTitulos.DisableControls;
queryListaTitulos.First;
lv_titulos.Clear;
btn_fechamento.Enabled := false;
btn_amostra.Enabled := false;
end;
queryListaTitulos.EnableControls;
Screen.Cursor := crDefault;
end;
procedure TfrmAtendimento.dbedt_cpfcnpjcKeyPress(Sender: TObject;
var Key: Char);
begin
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 TfrmAtendimento.dbgrd_despesasTitleClick(Column: TColumn);
begin
dtmSystem.OrganizaPorColuna(dtmSystem.tblDespesasTitulos, Column);
end;
procedure TfrmAtendimento.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 TfrmAtendimento.dbgrd_enderecosTitleClick(Column: TColumn);
begin
dtmSystem.OrganizaPorColuna(dtmSystem.tblEnderecos, Column);
end;
procedure TfrmAtendimento.dbgrd_historicoTitleClick(Column: TColumn);
begin
dtmSystem.OrganizaPorColuna(dtmSystem.tblHistorico, Column);
end;
procedure TfrmAtendimento.dbgrd_listtitulosTitleClick(Column: TColumn);
begin
dtmSystem.OrganizaPorColuna(queryListaTitulos, Column);
end;
procedure TfrmAtendimento.dbgrd_pesquisarDblClick(Sender: TObject);
begin
if length(qryPesquisa.FieldByName('TX_DOCUMENTO').AsString) = 14 then
begin
dtmSystem.tblDevedores.Locate('CD_CPF',
qryPesquisa.FieldByName('TX_DOCUMENTO').AsString, [])
end
else
begin
dtmSystem.tblDevedores.Locate('CD_CNPJ',
qryPesquisa.FieldByName('TX_DOCUMENTO').AsString, [])
end;
dtsDevedor.DataSet := dtmSystem.tblDevedores;
pcDevedor.Enabled := true;
// CriarLista;
AdjustCheckListBox;
end;
procedure TfrmAtendimento.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
edt_prov.Text := dtmSystem.tblProvidenciasTX_NOME.AsString;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.dbgrd_telTitleClick(Column: TColumn);
begin
dtmSystem.OrganizaPorColuna(dtmSystem.tblTelefones, Column);
end;
procedure TfrmAtendimento.dbgrd_titCellClick(Column: TColumn);
var
i: Integer;
begin
inherited;
// 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;
// end
// else
// begin
// clb_empresas.Checked[i] := false;
// end;
// end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.dbgrd_titTitleClick(Column: TColumn);
begin
dtmSystem.OrganizaPorColuna(dtmSystem.tblTitulos, Column);
end;
procedure TfrmAtendimento.dbrg_tipotelClick(Sender: TObject);
begin
if dbrg_tipotel.ItemIndex = 1 then
begin
DBRadioGroup1.Enabled := true;
end
else
begin
DBRadioGroup1.Enabled := false;
DBRadioGroup1.ItemIndex := -1;
end;
end;
procedure TfrmAtendimento.DevolverTtulos1Click(Sender: TObject);
var
i: Integer;
begin
if Messagedlg('Deseja devolver os títulos selecionados?', mtInformation,
[mbYes, mbNo], 0) = mrYes then
begin
Screen.Cursor := crHourGlass;
for i := 0 to lv_titulos.Items.Count - 1 do
begin
if lv_titulos.Items[i].Checked then
begin
queryListaTitulos.RecNo := i + 1;
with dtmSystem do
begin
tblTitulos.Locate('ID_TITULO', queryListaTitulosID_TITULO.AsInteger, []);
tblTitulos.Edit;
tblTitulosTP_SITUACAO.AsString := 'AJ';
tblTitulos.Post;
end;
end;
end;
CriarLista;
Screen.Cursor := crDefault;
end;
end;
procedure TfrmAtendimento.dtp_atrasorecalcChange(Sender: TObject);
var
mes, ano: string;
begin
if id_emp_calc <> -1 then
begin
if dtmSystem.tblEmpresaRepasse.IsEmpty then
begin
Showmessage('Esta empresa não possui nenhum repasse cadastrado.' +
' Por favor contate a administração e interrompa a baixa de qualquer título '
+ 'relacionado a empresa em questão.');
end
else
begin
mes := copy(FormatDateTime('yyyy-mm-dd', dtp_atrasorecalc.Date), 6, 2);
ano := copy(FormatDateTime('yyyy-mm-dd', dtp_atrasorecalc.Date), 1, 4);
if not dtmSystem.tblEmpresaRepasse.Locate('ID_MES;ID_ANO',
VarArrayOf([mes, ano]), []) then
begin
Showmessage
('Esta empresa não possui repasse para o mês da data de pagamento escolhida cadastrado.'
+ ' Por favor contate a administração e interrompa a baixa de qualquer título '
+ 'relacionado a empresa em questão.');
end;
end;
end;
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.dtsDespesasStateChange(Sender: TObject);
begin
dbgrd_despesas.ReadOnly := not(dtsDespesas.State in [dsInsert, dsEdit]);
navtitulos.Enabled := not(dtsDespesas.State in [dsInsert, dsEdit]);
end;
procedure TfrmAtendimento.dtsDevedorDataChange(Sender: TObject; Field: TField);
var
new_id, i: Integer;
begin
if qryConsulta.Connection = nil then
begin
exit;
end;
if dtsDevedor.DataSet.FieldByName('TP_CLIENTE').AsString = 'F' then
begin
dbedt_cpfcnpj.DataField := 'CD_CPF';
dbedt_cpfcnpjc.DataField := 'CD_CPF';
end
else
begin
dbedt_cpfcnpj.DataField := 'CD_CNPJ';
dbedt_cpfcnpjc.DataField := 'CD_CNPJ';
end;
new_id := dtmSystem.tblDevedoresID_DEVEDOR.AsInteger;
if (old_id <> new_id) and not(dtsDevedor.State in [dsInsert]) then
begin
setlength(ids_tits_calc, 0);
setlength(str_tit, 0);
lv_titulos.Clear;
id_emp_calc := -1;
mem_obsrecibo.Clear;
atendimento := 'atendendo';
pcDevedor.TabIndex := 0;
for i := 0 to length(ids_tits_calc) - 1 do
begin
ids_tits_calc[i] := false;
end;
old_id := new_id;
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;
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;
ChecaPermissoes;
// clb_beneficiarioscalculo.Checked[0] := True;
end;
end;
procedure TfrmAtendimento.dtsDevedorStateChange(Sender: TObject);
begin
if Assigned(dtsDevedor.DataSet) then
begin
dtmSystem.AlterReadOnly(pnl_cadastro, dtsDevedor.DataSet);
dbedt_nomec.ReadOnly := (dtsDevedor.State in [dsBrowse]);
dbedt_cpfcnpjc.ReadOnly := (dtsDevedor.State in [dsBrowse]);
dbmb_obsc.ReadOnly := (dtsDevedor.State in [dsBrowse]);
end;
end;
procedure TfrmAtendimento.dtsEmailStateChange(Sender: TObject);
begin
dbedt_email.ReadOnly := dtsEmail.State in [dsBrowse];
end;
procedure TfrmAtendimento.dtsEnderecosStateChange(Sender: TObject);
begin
dtmSystem.AlterReadOnly(pnl_enderecos, dtsEnderecos.DataSet);
end;
procedure TfrmAtendimento.dtsHistoricoStateChange(Sender: TObject);
begin
dblucb_providencia.Enabled := dtsHistorico.State in [dsEdit, dsInsert];
dbgrd_historico.ReadOnly := dtsHistorico.State in [dsEdit, dsInsert];
dbmemo_box.ReadOnly := not(dtsHistorico.State in [dsInsert, dsEdit]);
if dtsHistorico.State in [dsInsert] then
begin
dtsHistorico.DataSet.FieldByName('CD_PROTOCOLO').AsString :=
dtmSystem.gerarProtocolo(dtsDevedor.DataSet.FieldByName('ID_DEVEDOR')
.AsString);
edt_protocolo.Text := dtmSystem.gerarProtocolo
(dtsDevedor.DataSet.FieldByName('ID_DEVEDOR').AsString);
edt_protocolo1.Text := edt_protocolo.Text;
btn_protocolo.Enabled := false;
end;
end;
procedure TfrmAtendimento.dtsTelefonesDataChange(Sender: TObject;
Field: TField);
begin
if dbrg_tipotel.ItemIndex = 1 then
begin
DBRadioGroup1.Enabled := true;
end
else
begin
DBRadioGroup1.Enabled := false;
DBRadioGroup1.ItemIndex := -1;
end;
end;
procedure TfrmAtendimento.dtsTitulosDataChange(Sender: TObject; Field: TField);
var
i, old_id_tit: Integer;
begin
// if (Field = dtmSystem.tblTitulosVL_DESPESA) or
// (Field = dtmSystem.tblTitulosTP_DESPESA) then
// begin
// queryListaTitulos.Refresh;
// Att_campos;
// CalcValorParcelas;
// end;
//
// 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;
// end
// else
// begin
// clb_empresas.Checked[i] := false;
// end;
// end;
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;
// 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;
// end;
// 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 TfrmAtendimento.dtsTitulosStateChange(Sender: TObject);
begin
dtmSystem.AlterReadOnly(pnl_titulos, dtsTitulos.DataSet);
dtmSystem.AlterReadOnly(pnl_cheque, dtsTitulos.DataSet);
navDespesas.Enabled := not(dtsTitulos.State in [dsInsert, dsEdit]);
dbmem_titobs.ReadOnly := not(dtsTitulos.State in [dsEdit, dsInsert]);
end;
procedure TfrmAtendimento.edt_txextraChange(Sender: TObject);
begin
if length(edt_txextra.Text) < 1 then
begin
edt_txextra.Text := '0';
end;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.edt_txextraKeyPress(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_txextra.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.edt_descfixoKeyPress(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_descfixo.Text) > 0) then
// begin
// Key := #0;
// end;
end;
procedure TfrmAtendimento.edt_descindextrasExit(Sender: TObject);
begin
try
if edt_descindextras.Text <> '' then
begin
desc_indices_extras[cb_descindicesextras.ItemIndex] :=
edt_descindextras.Text;
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
except
end;
end;
procedure TfrmAtendimento.edt_descindextrasKeyPress(Sender: TObject;
var Key: Char);
begin
if Key = #13 then
begin
SelectNext(ActiveControl as TWinControl, true, true);
end;
end;
procedure TfrmAtendimento.edt_excentradaChange(Sender: TObject);
begin
if length(edt_excentrada.Text) < 1 then
begin
edt_excentrada.Text := '0';
end;
Att_campos;
CalcValorParcelas;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.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 TfrmAtendimento.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 TfrmAtendimento.edt_campopKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
if edt_campop.Text <> '' then
begin
btn_pesquisar.Click;
end;
end;
end;
procedure TfrmAtendimento.edt_corparChange(Sender: TObject);
begin
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 TfrmAtendimento.edt_corparKeyPress(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_corpar.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.edt_corquitarChange(Sender: TObject);
begin
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 TfrmAtendimento.edt_corquitarKeyPress(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_corquitar.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.edt_indparcelasKeyPress(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_indparcelas.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.edt_indquitarKeyPress(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_indquitar.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.edt_jurosparcelasKeyPress(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_jurosparcelas.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.edt_jurosquitarKeyPress(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_jurosquitar.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.edt_multasparcelasKeyPress(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_multasparcelas.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.edt_multasquitarKeyPress(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_multasquitar.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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;
except
end;
end;
procedure TfrmAtendimento.edt_nrparcelasExit(Sender: TObject);
begin
if edt_nrparcelas.Text = '' then
begin
edt_nrparcelas.Text := '0';
queryListaTitulos.Refresh;
Att_campos;
CalcValorParcelas;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.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 TfrmAtendimento.edt_principalparcelasKeyPress(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_principalparcelas.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.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 TfrmAtendimento.edt_principalquitarKeyPress(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_principalquitar.Text) > 0) then
begin
Key := #0;
end;
end;
procedure TfrmAtendimento.edt_reciboobsChange(Sender: TObject);
begin
// if length(mem_obsrecibo.Lines.Text) > edt_reciboobs.MaxLength then
// begin
// edt_reciboobs.Text := copy(edt_reciboobs.Text, 1, edt_reciboobs.MaxLength);
// end;
end;
procedure TfrmAtendimento.FormCanResize(Sender: TObject;
var NewWidth, NewHeight: Integer; var Resize: Boolean);
begin
if after_show then
begin
Resize := false;
end
else
begin
Resize := true;
end;
end;
procedure TfrmAtendimento.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if fez_recibo then
begin
if Messagedlg
('Você está prestes a fechar um acionamento em andamento COM RECIBO JÁ GERADO. Alterações neste devedor podem não ser salvas, mas o RECIBO CONTINUARÁ EXISTINDO. Deseja continuar?',
mtWarning, mbYesNo, 0) = mrNo then
begin
abort;
end;
end;
Screen.Cursor := crDefault;
Action := caFree;
frmAtendimento := nil;
end;
procedure TfrmAtendimento.FormCreate(Sender: TObject);
var
Pos: Integer;
begin
cdsTitulos.Close;
cdsParcelas.Close;
cdsTitulos.CreateDataSet;
cdsParcelas.CreateDataSet;
Pos := 0;
ficha_dev := false;
id_emp_calc := -1;
old_id := -1;
setlength(ids_tits_calc, 0);
atendimento := 'atendendo';
dtp_atrasorecalc.Date := Date;
dtp_agendadatahist.MinDate := Date;
after_show := false;
dtsDevedor.DataSet := nil;
fez_recibo := false;
// tabCadastro.Enabled := false;
with dtmSystem do
begin
if not tblDevedores.Active then
begin
tblDevedores.Open;
end
else
begin
tblDevedores.Refresh;
end;
if not tblEmail.Active then
begin
tblEmail.Open;
end
else
begin
tblEmail.Refresh;
end;
if not tblEnderecos.Active then
begin
tblEnderecos.Open;
end
else
begin
tblEnderecos.Refresh;
end;
if not tblEstados.Active then
begin
tblEstados.Open;
end
else
begin
tblEstados.Refresh;
end;
if not tblCidades.Active then
begin
tblCidades.Open;
end
else
begin
tblCidades.Refresh;
end;
if not tblTelefones.Active then
begin
tblTelefones.Open;
end
else
begin
tblTelefones.Refresh;
end;
// tblTitulos.Close;
if not tblTitulos.Active then
begin
tblTitulos.Open;
end
else
begin
tblTitulos.Refresh;
end;
// if not tblProtocolo.Active then
// begin
// tblProtocolo.Open;
// end;
if not tblEmpresa.Active then
begin
tblEmpresa.Open;
end
else
begin
tblEmpresa.Refresh;
end;
tblEmpresa.First;
if not tblCHGEmpresa.Active then
begin
tblCHGEmpresa.Open;
end
else
begin
tblCHGEmpresa.Refresh;
end;
if not tblEmpresaRepasse.Active then
begin
tblEmpresaRepasse.Open;
end;
tblCHGEmpresa.First;
if not tblDespesasTitulos.Active then
begin
tblDespesasTitulos.Open;
end;
if not tblIndicadorFinanceiro.Active then
begin
tblIndicadorFinanceiro.Open;
end;
if not tblProvidencias.Active then
begin
tblProvidencias.Open;
end
else
begin
tblProvidencias.Refresh;
end;
if not tblHistorico.Active then
begin
tblHistorico.Open;
end
else
begin
tblHistorico.Refresh;
end;
if not tblPoliticas.Active then
begin
tblPoliticas.Open;
end
else
begin
tblPoliticas.Refresh;
end;
if not tblFaixas.Active then
begin
tblFaixas.Open;
end
else
begin
tblFaixas.Refresh;
end;
if not tblAcordos.Active then
begin
tblAcordos.Open;
end
else
begin
tblAcordos.Refresh;
end;
// while not tblCHGEmpresa.Eof do
// begin
// clb_empresas.Items.Add(tblCHGEmpresaTX_NOME.AsString);
// if tblTitulosID_EMPRESA.AsString = tblCHGEmpresaID_EMPRESA.AsString then
// begin
// clb_empresas.Checked[Pos] := true;
// end;
// tblCHGEmpresa.Next;
// Pos := Pos + 1;
// end;
tblIndices.Open;
tblIndices.First;
cb_descindicesextras.Items.Clear;
desc_indices_extras := TStringList.Create;
while not tblIndices.Eof do
begin
cb_descindicesextras.Items.Add(tblIndicesTX_NOME.AsString);
desc_indices_extras.Add('0,00');
clb_indices.Items.Add(tblIndicesTX_NOME.AsString);
tblIndices.Next;
end;
cb_descindicesextras.ItemIndex := 0;
tblHistorico.Open;
if not tblPrCartao.Active then
begin
tblPrCartao.Open;
end
else
begin
tblPrCartao.Refresh;
end;
end;
if dtmSystem.id_grupo <> 1 then
begin
dbgrd_tit.Columns[9].Visible := false;
dbgrd_tit.Columns[10].Visible := false;
DBGrid1.PopupMenu := nil;
end;
dbgrd_enderecos.DataSource.DataSet.First;
gb_descontosquit.Enabled := cb_descquit.Checked;
gb_descontospar.Enabled := cb_descpar.Checked;
FListViewOldWndProc := lv_titulos.WindowProc;
lv_titulos.WindowProc := ListViewNewWndProc;
FlistViewOldWndProc2 := lv_parcelas.WindowProc;
lv_parcelas.WindowProc := ListViewNewWndProc2;
// FListViewOldWndProc3 := lv_prevtitulos.WindowProc;
// lv_prevtitulos.WindowProc := ListViewNewWndProc3;
// FlistViewOldWndProc4 := lv_fechamento.WindowProc;
// lv_fechamento.WindowProc := ListViewNewWndProc4;
SetupHackedNavigator(navdevedor, ImageList1, 's', 8);
SetupHackedNavigator(navEmail, ImageList1, 's', 8);
SetupHackedNavigator(navenderecos, ImageList1, 's', 8);
SetupHackedNavigator(navtelefones, ImageList1, 's', 8);
SetupHackedNavigator(navtitulos, ImageList1, 's', 8);
SetupHackedNavigator(navhistorico, ImageList1, 's', 8);
SetupHackedNavigator(navDespesas, ImageList1, 's', 8);
pcDevedor.ActivePageIndex := 0;
pcDevedor.Enabled := false;
ChecaPermissoes;
dtp_agatend.Date := Date;
dtph_agatend.Time := Now;
// dtsDevedor.DataSet.Refresh;
// cb_descquit.Enabled := dtmSystem.VerificarPermissao('ACBR.01.01');
// cb_descpar.Enabled := dtmSystem.VerificarPermissao('ACBR.01.02');
// cb_nmulta.Enabled := dtmSystem.VerificarPermissao('ACBR.01.03');
// cbx_excentrada.Enabled := dtmSystem.VerificarPermissao('ACBR.01.04');
// clb_indices.Enabled := dtmSystem.VerificarPermissao('ACBR.01.05');
// ECBR.02.01
// navdevedor.Enabled := dtmSystem.VerificarPermissao('ACBR.02.01');
// navenderecos.Enabled := dtmSystem.VerificarPermissao('ACBR.02.02');
// navtelefones.Enabled := dtmSystem.VerificarPermissao('ACBR.02.03');
// navtitulos.Enabled := dtmSystem.VerificarPermissao('ACBR.02.04');
// navhistorico.Enabled := dtmSystem.VerificarPermissao('ACBR.02.05');
end;
procedure TfrmAtendimento.FormDestroy(Sender: TObject);
begin
lv_titulos.WindowProc := FListViewOldWndProc;
FListViewOldWndProc := nil;
end;
procedure TfrmAtendimento.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
resultado: Integer;
begin
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;
if pcDevedor.TabIndex = 6 then
begin
resultado := Messagedlg
('Deseja realmente fechar a janela antes de efetuar a cobrança?',
mtConfirmation, [mbYes, mbNo], 0);
if resultado = mrYes then
begin
Key := 0;
Close;
end
else
begin
Key := 0;
end;
end
else
begin
Key := 0;
Close;
end;
end;
if (Key = 75) and (Shift = [ssCtrl]) then
begin
// ShowMessage('Ctrl+k is pressed!');
frmLiberaPermissao := TfrmLiberaPermissao.Create(self);
with frmLiberaPermissao do
begin
level := 2;
string_permissoes.Add('CBR.01.03.01.01');
string_permissoes.Add('CBR.01.03.01.06');
string_permissoes.Add('CBR.01.03.01.06.01');
string_permissoes.Add('CBR.01.03.01.06.02');
string_permissoes.Add('CBR.01.03.01.06.03');
string_permissoes.Add('CBR.01.03.01.02');
string_permissoes.Add('CBR.01.03.01.02.01');
string_permissoes.Add('CBR.01.03.01.02.02');
string_permissoes.Add('CBR.01.03.01.02.03');
string_permissoes.Add('CBR.01.03.01.03');
string_permissoes.Add('CBR.01.03.01.03.01');
string_permissoes.Add('CBR.01.03.01.03.02');
string_permissoes.Add('CBR.01.03.01.03.03');
string_permissoes.Add('CBR.01.03.01.04');
string_permissoes.Add('CBR.01.03.01.04.01');
string_permissoes.Add('CBR.01.03.01.04.02');
string_permissoes.Add('CBR.01.03.01.04.03');
string_permissoes.Add('CBR.01.03.01.05');
string_permissoes.Add('CBR.01.03.01.05.01');
string_permissoes.Add('CBR.01.03.01.05.02');
string_permissoes.Add('CBR.01.03.01.05.03');
string_permissoes.Add('CBR.01.03.02.01.01');
string_permissoes.Add('CBR.01.03.02.01.02');
string_permissoes.Add('CBR.01.03.02.01.03');
string_permissoes.Add('CBR.01.03.02.02');
string_permissoes.Add('CBR.01.03.02.03');
string_permissoes.Add('CBR.01.03.02.04');
string_permissoes.Add('CBR.01.03.02.05');
ShowModal;
if ModalResult = mrOk then
begin
case dtmSystem.cod_liberapermissao of
0:
navdevedor.Enabled := true;
1:
navEmail.Enabled := true;
2:
navEmail.VisibleButtons := navEmail.VisibleButtons + [nbInsert];
3:
navEmail.VisibleButtons := navEmail.VisibleButtons + [nbEdit];
4:
navEmail.VisibleButtons := navEmail.VisibleButtons + [nbDelete];
5:
navenderecos.Enabled := true;
6:
navenderecos.VisibleButtons := navenderecos.VisibleButtons +
[nbInsert];
7:
navenderecos.VisibleButtons := navenderecos.VisibleButtons
+ [nbEdit];
8:
navenderecos.VisibleButtons := navenderecos.VisibleButtons +
[nbDelete];
9:
navtelefones.Enabled := true;
10:
navtelefones.VisibleButtons := navtelefones.VisibleButtons +
[nbInsert];
11:
navtelefones.VisibleButtons := navtelefones.VisibleButtons
+ [nbEdit];
12:
navtelefones.VisibleButtons := navtelefones.VisibleButtons +
[nbDelete];
13:
navtitulos.Enabled := true;
14:
navtitulos.VisibleButtons := navtitulos.VisibleButtons + [nbInsert];
15:
navtitulos.VisibleButtons := navtitulos.VisibleButtons + [nbEdit];
16:
navtitulos.VisibleButtons := navtitulos.VisibleButtons + [nbDelete];
17:
navhistorico.Enabled := true;
18:
navhistorico.VisibleButtons := navhistorico.VisibleButtons +
[nbInsert];
19:
navhistorico.VisibleButtons := navhistorico.VisibleButtons
+ [nbEdit];
20:
navhistorico.VisibleButtons := navhistorico.VisibleButtons +
[nbDelete];
21:
tabQuitar.Enabled := true;
22:
tabParcelar.Enabled := true;
23:
cbx_descindextras.Enabled := true;
24:
cb_nmulta.Enabled := true;
25:
cbx_txextra.Enabled := true;
26:
cbx_excentrada.Enabled := true;
27:
clb_indices.Enabled := true;
end;
end;
end;
end;
end;
procedure TfrmAtendimento.FormShow(Sender: TObject);
begin
after_show := true;
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;
end;
procedure TfrmAtendimento.GuardaTitulos;
var
i: Integer;
begin
cdsTitulos.Append;
for i := 0 to cdsTitulos.Fields.Count - 1 do
begin
cdsTitulos.Fields[i].AsVariant := dtmSystem.tblTitulos.FieldByName
(cdsTitulos.Fields[i].FieldName).AsVariant;
end;
cdsTitulos.Post;
end;
procedure TfrmAtendimento.ListViewNewWndProc(var Msg: TMessage);
var
hdn: ^THDNotify;
begin
if Msg.Msg = WM_NOTIFY then
begin
hdn := Pointer(Msg.lParam);
if (hdn.hdr.code = HDN_BeginTrackW) or (hdn.hdr.code = HDN_BeginTrackA) then
begin
Msg.result := 1
end
else
begin
FListViewOldWndProc(Msg);
end;
end
else
begin
FListViewOldWndProc(Msg);
end;
end;
procedure TfrmAtendimento.ListViewNewWndProc2(var Msg: TMessage);
var
hdn: ^THDNotify;
begin
if Msg.Msg = WM_NOTIFY then
begin
hdn := Pointer(Msg.lParam);
if (hdn.hdr.code = HDN_BeginTrackW) or (hdn.hdr.code = HDN_BeginTrackA) then
begin
Msg.result := 1
end
else
begin
FlistViewOldWndProc2(Msg);
end;
end
else
begin
FlistViewOldWndProc2(Msg);
end;
end;
procedure TfrmAtendimento.lv_titulosChange(Sender: TObject; Item: TListItem;
Change: TItemChange);
begin
// Att_campos;
// CalcValorParcelas;
end;
procedure TfrmAtendimento.lv_titulosItemChecked(Sender: TObject;
Item: TListItem);
var
i, k: Integer;
begin
qtde_titulos := 0;
k := 0;
if lv_titulos.Items.Count > 0 then
begin
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;
setlength(str_tit, k + 1);
str_tit[k] := queryListaTitulosID_TITULO.AsInteger;
Inc(k, 1);
end;
end;
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 TfrmAtendimento.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 TfrmAtendimento.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 TfrmAtendimento.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 TfrmAtendimento.navhistoricoBeforeAction(Sender: TObject;
Button: TNavigateBtn);
var
string_helper: string;
begin
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 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á prestes a agendar um devedor. Deseja continuar?',
mtWarning, mbYesNo, 0) = mrNo then
begin
abort;
end;
end;
if dtp_agendahorahist.Time < Timeof(Now) then
begin
Messagedlg
('Você está selecionando um horário para agendamento menor que a hora atual.',
mtWarning, mbYesNo, 0);
abort;
end;
end;
if Messagedlg
('Esta inclusão de histórico irá retirar este devedor de qualquer agendamento. Deseja continuar?',
mtWarning, mbYesNo, 0) = mrNo then
begin
abort;
end;
Screen.Cursor := crHourGlass;
with dtmSystem do
begin
if not(tblAgenda.Active) then
begin
tblAgenda.Open;
end;
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 := dtsDevedores.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;
// end;
end
else
begin
string_helper := '';
end;
with dtmSystem do
begin
if not tblCampanhaDevedores.Active then
begin
tblCampanhaDevedores.Open;
end;
while tblCampanhaDevedores.Locate('ID_DEVEDOR',
dtsDevedores.DataSet.FieldByName('ID_DEVEDOR').AsInteger, []) do
begin
tblCampanhaDevedores.Delete;
end;
tblCampanhaDevedores.Close;
tblHistoricoID_DEVEDOR.AsInteger := dtsDevedores.DataSet.FieldByName
('ID_DEVEDOR').AsInteger;
tblHistoricoDT_CONTATO.AsDateTime := Now;
dtmSystem.tblHistoricoTL_MEMO.AsString :=
dtmSystem.tblHistoricoTL_MEMO.AsString + sLineBreak + string_helper;
// tblHistorico.Post;
end;
Screen.Cursor := crDefault;
// abort;
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 TfrmAtendimento.navtelefonesBeforeAction(Sender: TObject;
Button: TNavigateBtn);
begin
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 TfrmAtendimento.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], []);
// dtmSystem.tblTitulosID_EMPRESA.AsString :=
// dtmSystem.tblCHGEmpresaID_EMPRESA.AsString;
// end;
// end;
// if selected_id_chg_empresa <> -1 then
// begin
// dtmSystem.tblTitulosID_EMPRESA.AsInteger := selected_id_chg_empresa;
// 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;
// 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;
// end;
end;
end;
end;
procedure TfrmAtendimento.OpenOfficeDocument(path: string);
var
OpenOffice, OpenDesktop, LoadParams, OODoc, FileReplace, SaveParams,
OOTableContainner, OOTable, OOTableRows, OOTableCell: Variant;
path_file, ASearch, AReplace: string;
ç: Integer;
begin
if VarIsEmpty(OpenOffice) then
begin
OpenOffice := CreateOleObject('com.sun.star.ServiceManager');
end;
OpenDesktop := OpenOffice.CreateInstance('com.sun.star.frame.Desktop');
LoadParams := VarArrayCreate([0, -1], varVariant);
// Param := OpenOffice.Bridge_GetStruct('com.sun.star.beans.PropertyValue');
// Param.Name := 'Hidden';
// Param.Value := True;
// LoadParams := Param;
if path <> '' then
begin
path_file := 'file:///' + stringreplace(path, '\', '/', [rfReplaceAll]);
end
else
begin
path_file := 'private:factory/swriter';
end;
OODoc := OpenDesktop.LoadComponentFromURL(path_file, '_default', 0,
LoadParams);
FileReplace := OODoc.CreateReplaceDescriptor;
FileReplace.SearchCaseSensitive := false;
// Nome do devedor
ASearch := '“NOME_DEVEDOR”'; // alt+0147 e alt+0148
AReplace := dtsDevedor.DataSet.FieldByName('TX_NOME').AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// RG
ASearch := '“CD_RG”'; // alt+0147 e alt+0148
AReplace := dtsDevedor.DataSet.FieldByName('CD_RG').AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// CPF
ASearch := '“CD_CPF”'; // alt+0147 e alt+0148
AReplace := dtsDevedor.DataSet.FieldByName('CD_CPF').AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// INTERMEDIÁRIO
// dtsCHGEmpresa.DataSet.Locate('ID_EMPRESA', id_emp, []);
ASearch := '“EMPRESA_PROGRAMA”'; // alt+0147 e alt+0148
AReplace := UpperCase(dtsEmpresa.DataSet.FieldByName('TX_NOME').AsString) +
' - CNPJ: ' + dtsEmpresa.DataSet.FieldByName('TX_CNPJ').AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// INTERMEDIÁRIO
dtsCHGEmpresa.DataSet.Locate('ID_EMPRESA', id_emp, []);
ASearch := '“EMPRESA_TITULO”'; // alt+0147 e alt+0148
AReplace := UpperCase(dtsCHGEmpresa.DataSet.FieldByName('TX_NOME').AsString) +
' - CNPJ: ' + dtsCHGEmpresa.DataSet.FieldByName('TX_CNPJ').AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// vl_total_corrigido
ASearch := '“VL_TOTAL_CORRIGIDO”'; // alt+0147 e alt+0148
AReplace := edt_vltotal.Text + ' (' + valorPorExtenso
(strtofloat(copy(stringreplace(edt_vltotal.Text, '.', '', []), 4,
length(edt_vltotal.Text) - 3))) + ')';
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// número de parcelas
ASearch := '“NR_PARCELAS”'; // alt+0147 e alt+0148
AReplace := edt_nrparcelas.Text + '(' + Extenso(strtoint(edt_nrparcelas.Text),
false) + ')';
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// Tabela do acordo
OOTableContainner := OODoc.GetTextTables;
OOTable := OOTableContainner.getByIndex(0);
OOTableRows := OOTable.getRows;
if StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll])) <> 0 then
begin
ASearch := '“ENTRADA”'; // alt+0147 e alt+0148
AReplace := 'UMA ENTRADA E ';
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
for ç := 0 to (strtoint(edt_nrparcelas.Text)) do
begin
OOTableRows.insertByIndex(ç + 1, 1);
OOTableCell := OOTable.getCellByName('A' + inttostr(ç + 2));
OOTableCell.setstring(lv_fechamento.Items[ç].SubItems[1]);
OOTableCell := OOTable.getCellByName('B' + inttostr(ç + 2));
OOTableCell.setstring(lv_fechamento.Items[ç].SubItems[0]);
end;
end
else
begin
ASearch := '“ENTRADA”'; // alt+0147 e alt+0148
AReplace := '';
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
for ç := 1 to (strtoint(edt_nrparcelas.Text)) do
begin
OOTableRows.insertByIndex(ç, 1);
OOTableCell := OOTable.getCellByName('A' + inttostr(ç + 1));
OOTableCell.setstring(lv_fechamento.Items[ç].SubItems[1]);
OOTableCell := OOTable.getCellByName('B' + inttostr(ç + 1));
OOTableCell.setstring(lv_fechamento.Items[ç].SubItems[0]);
end;
end;
// Juros
ASearch := '“PR_JUROS”'; // alt+0147 e alt+0148
// dtsCHGEmpresa.DataSet.First;
AReplace := dtsCHGEmpresa.DataSet.FieldByName('PR_JUROS').AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
ASearch := '“EXTENSO_JUROS”'; // “ = alt+0147 e ” = alt+0148
AReplace := Extenso(dtsCHGEmpresa.DataSet.FieldByName('PR_JUROS').AsInteger,
false) + ' por cento';
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// Multa
ASearch := '“PR_MULTA”'; // alt+0147 e alt+0148
// dtsCHGEmpresa.DataSet.First;
AReplace := dtsCHGEmpresa.DataSet.FieldByName('PR_MULTA').AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
ASearch := '“EXTENSO_MULTA”'; // alt+0147 e alt+0148
AReplace := Extenso(dtsCHGEmpresa.DataSet.FieldByName('PR_MULTA').AsInteger,
false) + ' por cento';
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// CIDADE/UF empresa
ASearch := '“CIDADE/UF_EMPRESA”'; // alt+0147 e alt+0148
dtmSystem.tblEstados.Locate('ID_ESTADO',
dtmSystem.tblEmpresaID_ESTADO.AsString, []);
dtmSystem.tblCidades.Locate('ID_CIDADE',
dtmSystem.tblEmpresaID_CIDADE.AsString, []);
AReplace := dtmSystem.tblCidadesTX_NOME.AsString + '/' +
dtmSystem.tblEstadosTX_NOME.AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// CIDADE empresa
ASearch := '“CIDADE_EMP”'; // alt+0147 e alt+0148
AReplace := dtmSystem.tblCidadesTX_NOME.AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// UF empresa
ASearch := '“UF_EMP”'; // alt+0147 e alt+0148
AReplace := dtmSystem.tblEstadosTX_NOME.AsString;
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// Data do dia
ASearch := '“DATA_DIA”'; // alt+0147 e alt+0148
AReplace := DateToStr(Date);
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
// Assinatura
ASearch := '“NOME_EMP”'; // alt+0147 e alt+0148
AReplace := UpperCase(dtsEmpresa.DataSet.FieldByName('TX_NOME').AsString);
FileReplace.SetSearchString(ASearch);
FileReplace.SetReplaceString(AReplace);
OODoc.ReplaceAll(FileReplace);
path_file := stringreplace(path_file, 'acordo_financ',
'acordo_' + dtsCHGEmpresa.DataSet.FieldByName('TX_NOME').AsString + ' - ' +
stringreplace(DateToStr(Date), '/', '-', [rfReplaceAll]), [rfReplaceAll]);
SaveParams := VarArrayCreate([0, -1], varVariant);
OODoc.StoreAsUrl(path_file, SaveParams);
end;
procedure TfrmAtendimento.pcDevedorChange(Sender: TObject);
var
i: Integer;
begin
if pcDevedor.TabIndex = 6 then
begin
if atendimento = 'atendendo' then
begin
pcDevedor.TabIndex := pagina;
end;
if (atendimento = 'fechamento') and (pcDevedor.TabIndex <> 6) then
begin
pcDevedor.TabIndex := 6;
end;
end;
if (pagina = 5) then
begin
setlength(ids_tits_calc, queryListaTitulos.RecordCount);
if length(ids_tits_calc) > 0 then
begin
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;
end;
if pcDevedor.TabIndex = 5 then
begin
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;
if pcDevedor.TabIndex = 3 then
begin
pcTitDespesas.TabIndex := 0;
end;
end;
procedure TfrmAtendimento.pcDevedorChanging(Sender: TObject;
var AllowChange: Boolean);
begin
pagina := pcDevedor.TabIndex;
end;
procedure TfrmAtendimento.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, vl_despesa, helper_indice, cred_fin, vl_cor_depois_desc
: currency;
dividendo, pr_banco: double;
g: Integer;
tx_despesa: string;
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 dtp_atrasorecalc.Date > 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
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;
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.Filtered := false;
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;
if ((dtp_atrasorecalc.Date) <= (queryListaTitulosDT_VENCIMENTO.AsDateTime))
or (cb_nmulta.Checked) then
begin
pl_multa := 0;
end;
// pl_multa := vl_nominal * (queryListaTitulosPR_MULTA.AsFloat / 100);
queryListaTitulosVL_MULTA.AsCurrency := pl_multa;
// if clb_indices.Items.Count > 0 then
// begin
// vl_indices := 0;
// helper_indice := 0;
// for g := 0 to clb_indices.Items.Count - 1 do
// begin
// if clb_indices.Checked[g] then
// begin
// dtmSystem.tblIndices.RecNo := g { + 1 };
// helper_indice :=
// (vl_nominal * (((dtmSystem.tblIndicesPR_INDICE.AsFloat / 30) / 100)
// * queryListaTitulosDT_ATRASO.AsInteger));
// vl_indices := vl_indices + helper_indice;
// end;
// end;
// end;
// queryListaTitulosVL_INDICES.AsCurrency := vl_indices;
queryListaTitulosVL_INDICES.AsCurrency := 0;
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;
// if cbx_descindextras.Checked then
// begin
// vl_indices := 0;
// helper_indice := 0;
// for g := 0 to clb_indices.Items.Count - 1 do
// begin
// if clb_indices.Checked[g] then
// begin
// dtmSystem.tblIndices.RecNo := g { + 1 };
// helper_indice :=
// (vl_nominal * (((dtmSystem.tblIndicesPR_INDICE.AsFloat / 30) / 100)
// * queryListaTitulosDT_ATRASO.AsInteger));
// helper_indice := helper_indice -
// (helper_indice * (strtofloat(desc_indices_extras[g]) / 100));
// vl_indices := vl_indices + helper_indice;
// end;
// end;
// queryListaTitulosVL_INDICES.AsCurrency := vl_indices;
// end;
// porcentagem da entrada
// queryListaTitulosPR_ENTRADA.AsFloat := dtsCHGEmpresa.DataSet.FieldByName
// ('PR_ENTRADA').AsFloat;
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 := 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
queryListaTitulosVL_DESC_QUIT_IND.AsCurrency := 0;
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency := 0;
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency := 0;
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency := 0;
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
queryListaTitulosVL_DESC_PAR_IND.AsCurrency := 0;
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency := 0;
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency := 0;
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency := 0;
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;
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
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;
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;
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;
{ dtmSystem.tblTitulos.Locate('ID_TITULO',
queryListaTitulosID_TITULO.AsInteger, []);
vl_despesa := 0.00;
tx_despesa := '';
if not dtmSystem.tblDespesasTitulos.IsEmpty then
begin
dtmSystem.tblDespesasTitulos.First;
while not dtmSystem.tblDespesasTitulos.Eof do
begin
if dtmSystem.tblDespesasTitulosTP_DESPESA.AsString = 'Adicionar' then
begin
vl_despesa := vl_despesa + dtmSystem.tblDespesasTitulosVL_DESPESA.
AsCurrency;
tx_despesa := dtmSystem.tblDespesasTitulosTX_DESCRICAO.AsString + '(' +
CurrToStrF(dtmSystem.tblDespesasTitulosVL_DESPESA.AsCurrency,
ffCurrency, 2, dtmSystem.CusFmt) + '),';
end
else
begin
vl_despesa := vl_despesa - dtmSystem.tblDespesasTitulosVL_DESPESA.
AsCurrency;
tx_despesa := dtmSystem.tblDespesasTitulosTX_DESCRICAO.AsString + '(' +
CurrToStrF(dtmSystem.tblDespesasTitulosVL_DESPESA.AsCurrency,
ffCurrency, 2, dtmSystem.CusFmt) + '),';
end;
dtmSystem.tblDespesasTitulos.Next;
end;
Delete(tx_despesa, length(tx_despesa), 1);
end;
queryListaTitulosTX_DESPESA.AsString := tx_despesa;
queryListaTitulosVL_DESPESA.AsCurrency := vl_despesa;
if cbx_despesas.Checked then
begin
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency -
queryListaTitulosVL_DESPESA.AsCurrency;
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;
queryListaTitulosVL_EXTRAS.AsCurrency := 0;
queryListaTitulosVL_REPASSE_BANCO.AsCurrency := 0;
queryListaTitulosVL_RETIRADA_TAXA.AsCurrency := 0;
if (strtoint(edt_nrparcelas.Text) = 0) and (cb_formapag.ItemIndex = 1) then
// débito
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));
queryListaTitulosVL_REPASSE_BANCO.AsCurrency :=
queryListaTitulosVL_CORRIGIDO.AsCurrency *
(dtsEmpresa.DataSet.FieldByName('PR_BANCO_DEBITO').AsFloat / 100);
if queryListaTitulosVL_REPASSE_BANCO.AsCurrency > 0 then
begin
queryListaTitulosVL_RETIRADA_TAXA.AsCurrency :=
queryListaTitulosVL_EXTRAS.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency;
end
else
begin
queryListaTitulosVL_RETIRADA_TAXA.AsCurrency := 0;
end;
queryListaTitulosVL_INDICADOR.AsCurrency :=
queryListaTitulosVL_INDICADOR.AsCurrency +
queryListaTitulosVL_RETIRADA_TAXA.AsCurrency;
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;
// dtsCHGEmpresa.DataSet.Locate('ID_EMPRESA',
// queryListaTitulosID_EMPRESA.AsString, []);
if (strtoint(edt_nrparcelas.Text) > 0) then
begin
pr_banco := 0;
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;
dtmSystem.tblPrCartao.Locate('NR_PARCELA',
strtoint(edt_nrparcelas.Text), []);
pr_banco := dtmSystem.tblPrCartaoPR_REPASSE.AsFloat / 100;
{ case (strtoint(edt_nrparcelas.Text)) of
1:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName
('PR_BANCO_CREDVISTA').AsFloat / 100;
end;
2, 3:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName('PR_BANCO_CRED3')
.AsFloat / 100;
end;
4, 5, 6:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName('PR_BANCO_CRED6')
.AsFloat / 100;
end;
7, 8, 9, 10, 11, 12:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName('PR_BANCO_CRED12')
.AsFloat / 100;
end;
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));
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;
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);
// queryListaTitulosVL_REPASSE_BANCO.AsCurrency :=
// queryListaTitulosVL_EXTRAS.AsCurrency -
// ((queryListaTitulosVL_CORRIGIDO.AsCurrency -
// queryListaTitulosVL_ENTRADA.AsCurrency) * pr_banco);
queryListaTitulosVL_REPASSE_BANCO.AsCurrency :=
((strtoint(edt_nrparcelas.Text) *
queryListaTitulosVL_PARCELA.AsCurrency) * pr_banco);
queryListaTitulosVL_RETIRADA_TAXA.AsCurrency :=
queryListaTitulosVL_EXTRAS.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency;
queryListaTitulosVL_INDICADOR.AsCurrency :=
queryListaTitulosVL_INDICADOR.AsCurrency +
queryListaTitulosVL_RETIRADA_TAXA.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;
dtmSystem.tblPrCartao.Locate('NR_PARCELA',
strtoint(edt_nrparcelas.Text), []);
pr_banco := dtmSystem.tblPrCartaoPR_REPASSE.AsFloat / 100;
{ case (strtoint(edt_nrparcelas.Text)) of
1:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName
('PR_BANCO_CREDVISTA').AsFloat / 100;
end;
2, 3:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName('PR_BANCO_CRED3')
.AsFloat / 100;
end;
4, 5, 6:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName('PR_BANCO_CRED6')
.AsFloat / 100;
end;
7, 8, 9, 10, 11, 12:
begin
pr_banco := dtsEmpresa.DataSet.FieldByName('PR_BANCO_CRED12')
.AsFloat / 100;
end;
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_EXTRAS.AsCurrency;
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
RoundTo(queryListaTitulosVL_ENTRADA.AsCurrency, -2) +
(strtoint(edt_nrparcelas.Text) *
queryListaTitulosVL_PARCELA.AsCurrency);
// queryListaTitulosVL_REPASSE_BANCO.AsCurrency :=
// queryListaTitulosVL_EXTRAS.AsCurrency -
// ((queryListaTitulosVL_CORRIGIDO.AsCurrency -
// queryListaTitulosVL_ENTRADA.AsCurrency) * pr_banco);
queryListaTitulosVL_REPASSE_BANCO.AsCurrency :=
((strtoint(edt_nrparcelas.Text) *
queryListaTitulosVL_PARCELA.AsCurrency) * pr_banco);
queryListaTitulosVL_RETIRADA_TAXA.AsCurrency :=
queryListaTitulosVL_EXTRAS.AsCurrency -
queryListaTitulosVL_REPASSE_BANCO.AsCurrency;
queryListaTitulosVL_INDICADOR.AsCurrency :=
queryListaTitulosVL_INDICADOR.AsCurrency +
queryListaTitulosVL_RETIRADA_TAXA.AsCurrency;
end;
end;
end;
procedure TfrmAtendimento.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.Style := Font.Style - [fsbold];
Font.size := size;
end;
end;
procedure TfrmAtendimento.up_nrparcelasClick(Sender: TObject;
Button: TUDBtnType);
begin
end;
// procedure TfrmAtendimento.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.