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.
2536 lines
81 KiB
2536 lines
81 KiB
unit ufrmAtendimento;
|
|
|
|
interface
|
|
|
|
uses
|
|
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
|
|
System.Classes, Vcl.Graphics, DateUtils,
|
|
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;
|
|
|
|
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;
|
|
rdbdtp_datanasc: TrDBDateTimePicker;
|
|
lbl_datacad: TLabel;
|
|
rdbdtp_datacad: TrDBDateTimePicker;
|
|
Panel1: TPanel;
|
|
dbrgrp_tpdevedor: TDBRadioGroup;
|
|
lbl_tppessoa: TLabel;
|
|
pnl_cadastro: TPanel;
|
|
tabEnderecos: TTabSheet;
|
|
pnl_enderecos: TPanel;
|
|
dbgrd_enderecos: TDBGrid;
|
|
DBMemo1: 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;
|
|
clb_empresas: TCheckListBox;
|
|
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;
|
|
gb_descontosquit: TGroupBox;
|
|
lbl_indquitar: TLabel;
|
|
lbl_principalquitar: TLabel;
|
|
lbl_multasquitar: TLabel;
|
|
lbl_jurosquitar: TLabel;
|
|
edt_indquitar: TEdit;
|
|
edt_principalquitar: TEdit;
|
|
edt_multasquitar: TEdit;
|
|
up_encquitar: TUpDown;
|
|
up_principalquitar: TUpDown;
|
|
up_multasquitar: TUpDown;
|
|
edt_jurosquitar: TEdit;
|
|
up_jurosquitar: TUpDown;
|
|
cb_descquit: TCheckBox;
|
|
gb_descontospar: TGroupBox;
|
|
lbl_indparcelas: TLabel;
|
|
lbl_jurosparcelas: TLabel;
|
|
lbl_multasparcelas: TLabel;
|
|
lbl_principalparcelas: TLabel;
|
|
edt_indparcelas: TEdit;
|
|
edt_jurosparcelas: TEdit;
|
|
edt_multasparcelas: TEdit;
|
|
edt_principalparcelas: TEdit;
|
|
up_encparcelas: TUpDown;
|
|
up_jurosparcelas: TUpDown;
|
|
up_multasparcelas: TUpDown;
|
|
up_principalparcelas: TUpDown;
|
|
cb_descpar: TCheckBox;
|
|
btn_fechamento: TButton;
|
|
ppmnu_copiar: TPopupMenu;
|
|
copiar_conteudo: TMenuItem;
|
|
B1: TMenuItem;
|
|
C1: TMenuItem;
|
|
btn_close: TButton;
|
|
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;
|
|
re_obsrecibo: TRichEdit;
|
|
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_acrfixoKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_excentradaKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_descfixoKeyPress(Sender: TObject; var Key: Char);
|
|
procedure edt_descfixoChange(Sender: TObject);
|
|
procedure edt_acrfixoChange(Sender: TObject);
|
|
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);
|
|
private
|
|
FListViewOldWndProc: TWndMethod;
|
|
FlistViewOldWndProc2: TWndMethod;
|
|
atendimento: string;
|
|
pagina: 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);
|
|
{ Private declarations }
|
|
public
|
|
data_parcelas: array of TDate;
|
|
old_id: integer;
|
|
index_pagamento: integer;
|
|
clpbrd: string;
|
|
forma_pagamento: string;
|
|
tipo_pagamento: string;
|
|
nome_titulos: string;
|
|
parcelamento: array of currency;
|
|
{ Public declarations }
|
|
end;
|
|
|
|
var
|
|
frmAtendimento: TfrmAtendimento;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
uses udtmSystem, CommCtrl, ufrmFechamentoAtendimento, urelRecibo, uExtenso;
|
|
|
|
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: 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;
|
|
|
|
quit_ind := 0;
|
|
quit_prin := 0;
|
|
quit_multa := 0;
|
|
quit_juros := 0;
|
|
|
|
parc_ind := 0;
|
|
parc_prin := 0;
|
|
parc_multa := 0;
|
|
parc_juros := 0;
|
|
|
|
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 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 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;
|
|
|
|
end;
|
|
end;
|
|
|
|
edt_somatitulos.Text := CurrToStrF(soma_nominal, ffCurrency, 2);
|
|
edt_indices.Text := CurrToStrF(soma_indices, ffCurrency, 2);
|
|
edt_extras.Text := CurrToStrF(soma_encargos, ffCurrency, 2);
|
|
edt_vlaquitar.Text := CurrToStrF(soma_corrigido, ffCurrency, 2);
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
edt_somaentrada.Text := CurrToStrF(StrToCurr(edt_excentrada.Text),
|
|
ffCurrency, 2);
|
|
end
|
|
else
|
|
begin
|
|
edt_somaentrada.Text := CurrToStrF(soma_entrada, ffCurrency, 2);
|
|
end;
|
|
edt_somaindicador.Text := CurrToStrF(soma_indicador, ffCurrency, 2);
|
|
edt_somamulta.Text := CurrToStrF(soma_multas, ffCurrency, 2);
|
|
edt_somajuros.Text := CurrToStrF(soma_juros, ffCurrency, 2);
|
|
up_nrparcelas.Max := n_parcelas;
|
|
|
|
up_encquitar.Max := quit_ind;
|
|
up_principalquitar.Max := quit_prin;
|
|
up_multasquitar.Max := quit_multa;
|
|
up_jurosquitar.Max := quit_juros;
|
|
|
|
up_encparcelas.Max := parc_ind;
|
|
up_principalparcelas.Max := parc_prin;
|
|
up_multasparcelas.Max := parc_multa;
|
|
up_jurosparcelas.Max := parc_juros;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.btn_fechamentoClick(Sender: TObject);
|
|
var
|
|
i, j, k: integer;
|
|
parcela, valor, juros, dividendo, somatotal, a: currency;
|
|
begin
|
|
|
|
with TfrmFechamentoAtendimento.Create(self) do
|
|
begin
|
|
ShowModal;
|
|
if ModalResult = mrOk then
|
|
begin
|
|
atendimento := 'fechamento';
|
|
pcDevedor.TabIndex := 6;
|
|
lv_prevtitulos.Clear;
|
|
lv_fechamento.Clear;
|
|
|
|
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
|
|
queryListaTitulos.RecNo := i + 1;
|
|
with lv_prevtitulos.Items.Add do
|
|
begin
|
|
Caption := queryListaTitulos.FieldByName('TX_PRODUTO').AsString;
|
|
|
|
SubItems.Add(CurrToStrF(queryListaTitulos.FieldByName('VL_TITULO')
|
|
.AsCurrency, ffCurrency, 2));
|
|
SubItems.Add
|
|
(CurrToStrF(queryListaTitulos.FieldByName('VL_CORRIGIDO')
|
|
.AsCurrency, ffCurrency, 2));
|
|
end;
|
|
if forma_pagamento = 'Q' then
|
|
begin
|
|
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_ENCARGOS.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));
|
|
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
|
|
StrToCurr(formatfloat('0.##',
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency));
|
|
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
|
|
queryListaTitulosDT_VENCIMENTO.AsDateTime;
|
|
dtmSystem.tblConteudoRecibo.Post;
|
|
end;
|
|
end;
|
|
end;
|
|
lv_prevtitulos.Columns[1].Alignment := taRightJustify;
|
|
lv_prevtitulos.Columns[2].Alignment := taRightJustify;
|
|
if forma_pagamento = 'Q' then
|
|
begin
|
|
lv_fechamento.Visible := False;
|
|
lbl_dpagamento.Visible := False;
|
|
somatotal := 0;
|
|
for k := 0 to lv_prevtitulos.Items.Count - 1 do
|
|
begin
|
|
with lv_prevtitulos.Items[k] do
|
|
begin
|
|
case index_pagamento of
|
|
// 0=Dinheiro;1=Débito;2=Crédito;3=Cheque;
|
|
1:
|
|
begin
|
|
a := (StrToCurr(stringreplace(copy(lv_prevtitulos.Items[k]
|
|
.SubItems[1], 4, length(lv_prevtitulos.Items[k].SubItems[1])
|
|
- 3), '.', '', [rfReplaceAll, rfIgnoreCase])) *
|
|
(dtmSystem.tblEmpresaPR_DEBITO.AsFloat / 100));
|
|
SubItems[1] :=
|
|
CurrToStrF
|
|
(StrToCurr(stringreplace(copy(lv_prevtitulos.Items[k]
|
|
.SubItems[1], 4, length(lv_prevtitulos.Items[k].SubItems[1])
|
|
- 3), '.', '', [rfReplaceAll, rfIgnoreCase])) + a,
|
|
ffCurrency, 2);
|
|
somatotal := somatotal +
|
|
(StrToCurr(stringreplace(copy(SubItems[1], 4,
|
|
length(SubItems[1]) - 3), '.', '', [rfReplaceAll,
|
|
rfIgnoreCase])));
|
|
end;
|
|
2:
|
|
begin
|
|
a := (StrToCurr(stringreplace(copy(lv_prevtitulos.Items[k]
|
|
.SubItems[1], 4, length(lv_prevtitulos.Items[k].SubItems[1])
|
|
- 3), '.', '', [rfReplaceAll, rfIgnoreCase])) *
|
|
(dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat / 100));
|
|
SubItems[1] :=
|
|
CurrToStrF
|
|
(StrToCurr(stringreplace(copy(lv_prevtitulos.Items[k]
|
|
.SubItems[1], 4, length(lv_prevtitulos.Items[k].SubItems[1])
|
|
- 3), '.', '', [rfReplaceAll, rfIgnoreCase])) + a,
|
|
ffCurrency, 2);
|
|
somatotal := somatotal +
|
|
(StrToCurr(stringreplace(copy(SubItems[1], 4,
|
|
length(SubItems[1]) - 3), '.', '', [rfReplaceAll,
|
|
rfIgnoreCase])));
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
if somatotal <> 0 then
|
|
begin
|
|
edt_vltotal.Text := CurrToStrF(somatotal, ffCurrency, 2);
|
|
end
|
|
else
|
|
begin
|
|
edt_vltotal.Text := edt_vlaquitar.Text;
|
|
end;
|
|
end;
|
|
if forma_pagamento = 'P' then
|
|
begin
|
|
// dtmSystem.tblConteudoRecibo.Append;
|
|
// dtmSystem.tblConteudoReciboTX_NOME.AsString := 'Entrada';
|
|
// dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
|
|
// StrToCurr(copy(edt_somaentrada.Text, 3,
|
|
// length(edt_somaentrada.Text) - 3));
|
|
// dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
|
|
// StrToDate(FormatDateTime('dd/mm/yyyy', data_parcelas[0]));
|
|
// dtmSystem.tblConteudoRecibo.Post;
|
|
lv_fechamento.Visible := True;
|
|
lbl_dpagamento.Visible := True;
|
|
somatotal := 0;
|
|
for j := 0 to strtoint(edt_nrparcelas.Text) do
|
|
begin
|
|
with lv_fechamento.Items.Add do
|
|
begin
|
|
if j = 0 then
|
|
begin
|
|
Caption := 'Entrada';
|
|
SubItems.Add(edt_somaentrada.Text);
|
|
SubItems.Add(DateToStr(data_parcelas[0]));
|
|
end
|
|
else
|
|
begin
|
|
Caption := 'Parcela nº ' + inttostr(j) + '/' +
|
|
edt_nrparcelas.Text;
|
|
// 0=Dinheiro;1=Débito;2=Crédito;3=Cheque;
|
|
case index_pagamento of
|
|
0, 1, 3:
|
|
begin
|
|
SubItems.Add(CurrToStrF(parcelamento[j - 1],
|
|
ffCurrency, 2));
|
|
SubItems.Add(DateToStr(data_parcelas[j]));
|
|
end;
|
|
2:
|
|
begin
|
|
valor := (StrToCurr(stringreplace(copy(edt_vlaquitar.Text,
|
|
4, length(edt_vlaquitar.Text) - 3), '.', '',
|
|
[rfReplaceAll, rfIgnoreCase]))) -
|
|
(StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
|
|
length(edt_somaentrada.Text) - 3), '.', '',
|
|
[rfReplaceAll, rfIgnoreCase])));
|
|
|
|
juros := (dtmSystem.tblEmpresaPR_FINANCIAMENTO.
|
|
AsFloat / 100);
|
|
|
|
dividendo :=
|
|
(1 - (1 / (power(1 +
|
|
(dtmSystem.tblEmpresaPR_FINANCIAMENTO.AsFloat / 100),
|
|
strtoint(edt_nrparcelas.Text)))));
|
|
|
|
parcela := (valor * juros) / dividendo;
|
|
case strtoint(edt_nrparcelas.Text) of
|
|
1:
|
|
begin
|
|
parcela :=
|
|
RoundTo(parcela +
|
|
(parcela * (dtmSystem.tblEmpresaPR_CREDVISTA.AsFloat
|
|
/ 100)), -2);
|
|
|
|
end;
|
|
2, 3:
|
|
begin
|
|
parcela :=
|
|
RoundTo(parcela +
|
|
(parcela * (dtmSystem.tblEmpresaPR_CRED3.AsFloat /
|
|
100)), -2);
|
|
end;
|
|
4, 5, 6:
|
|
begin
|
|
parcela :=
|
|
RoundTo(parcela +
|
|
(parcela * (dtmSystem.tblEmpresaPR_CRED6.AsFloat /
|
|
100)), -2);
|
|
end;
|
|
7, 8, 9, 10, 11, 12:
|
|
begin
|
|
parcela :=
|
|
RoundTo(parcela +
|
|
(parcela * (dtmSystem.tblEmpresaPR_CRED12.AsFloat /
|
|
100)), -2);
|
|
end;
|
|
end;
|
|
SubItems.Add(CurrToStrF(parcela, ffCurrency, 2));
|
|
SubItems.Add(DateToStr(data_parcelas[j]));
|
|
somatotal := somatotal + parcela;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
if j = 0 then
|
|
begin
|
|
dtmSystem.tblConteudoRecibo.Append;
|
|
dtmSystem.tblConteudoReciboTX_NOME.AsString := 'Entrada';
|
|
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
|
|
StrToCurr(copy(edt_somaentrada.Text, 3,
|
|
length(edt_somaentrada.Text) - 3));
|
|
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
|
|
StrToDate(FormatDateTime('dd/mm/yyyy', data_parcelas[0]));
|
|
dtmSystem.tblConteudoRecibo.Post;
|
|
end
|
|
else
|
|
begin
|
|
dtmSystem.tblConteudoRecibo.Append;
|
|
dtmSystem.tblConteudoReciboTX_NOME.AsString := 'Parcela nº ' +
|
|
inttostr(j);
|
|
dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency :=
|
|
(StrToCurr(stringreplace(copy(lv_fechamento.Items[j].SubItems[0],
|
|
4, length(lv_fechamento.Items[j].SubItems[0]) - 3), '.', '',
|
|
[rfReplaceAll, rfIgnoreCase])));
|
|
dtmSystem.tblConteudoReciboDT_VENCIMENTO.AsDateTime :=
|
|
StrToDate(FormatDateTime('dd/mm/yyyy', data_parcelas[j]));
|
|
dtmSystem.tblConteudoRecibo.Post;
|
|
end;
|
|
end;
|
|
if somatotal <> 0 then
|
|
begin
|
|
edt_vltotal.Text :=
|
|
CurrToStrF(somatotal +
|
|
StrToCurr(stringreplace(copy(edt_somaentrada.Text, 4,
|
|
length(edt_somaentrada.Text) - 3), '.', '', [rfReplaceAll,
|
|
rfIgnoreCase])), ffCurrency, 2);
|
|
end
|
|
else
|
|
begin
|
|
edt_vltotal.Text := edt_vlaquitar.Text;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
// edt_formarecebimento.Text := '';
|
|
end;
|
|
|
|
procedure TfrmAtendimento.btn_pesquisarClick(Sender: TObject);
|
|
var
|
|
string_query, tx_pesquisa, help_cpfcnpj: string;
|
|
begin
|
|
if edt_campop.Text <> '' then
|
|
begin
|
|
tx_pesquisa := UpperCase(stringreplace(edt_campop.Text, ' ', '%',
|
|
[rfReplaceAll]));
|
|
|
|
string_query := 'select tx_nome, tx_pai, tx_mae from chg_devedores where ';
|
|
case cbx_tiponome.ItemIndex of
|
|
0:
|
|
begin
|
|
string_query := string_query + 'upper(TX_NOME) 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';
|
|
|
|
end;
|
|
|
|
procedure TfrmAtendimento.btn_verprotocoloClick(Sender: TObject);
|
|
begin
|
|
CarregaProtocolo;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.btn_verrecibosClick(Sender: TObject);
|
|
var
|
|
old_nr: string;
|
|
k, l: integer;
|
|
// i: integer;
|
|
begin
|
|
with dtmSystem do
|
|
begin
|
|
tblRecibo.Open;
|
|
tblConteudoRecibo.Open;
|
|
tblConteudoRecibo.RecNo := 1;
|
|
if tblRecibo.RecordCount = 0 then
|
|
begin
|
|
tblRecibo.Append;
|
|
tblReciboNR_RECIBO.AsString := '000001';
|
|
// tblReciboTX_NOME.AsString := 'temp';
|
|
tblRecibo.Post;
|
|
end;
|
|
tblRecibo.RecNo := tblRecibo.RecordCount;
|
|
old_nr := tblReciboNR_RECIBO.AsString;
|
|
if forma_pagamento = 'Q' then
|
|
begin
|
|
if tblReciboTX_NOME.AsString <> 'temp' then
|
|
begin
|
|
tblRecibo.Append;
|
|
tblReciboNR_RECIBO.AsString :=
|
|
Format('%.*d', [6, strtoint(old_nr) + 1]);
|
|
// tblReciboTX_NOME.AsString := 'temp';
|
|
tblRecibo.Post;
|
|
end;
|
|
tblRecibo.Filtered := true;
|
|
tblRecibo.Filter := 'ID_RECIBO = ' + inttostr(tblRecibo.RecNo);
|
|
relRecibo := TrelRecibo.Create(self);
|
|
with relRecibo do
|
|
begin
|
|
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_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_vlextenso2v.Caption := frlbl_vlextenso.Caption;
|
|
frlbl_formarecebimento.Caption := frlbl_formarecebimento.Caption +
|
|
edt_formarecebimento.Text;
|
|
frlbl_formarecebimento2v.Caption := frlbl_formarecebimento.Caption;
|
|
for k := 0 to re_obsrecibo.Lines.Count - 1 do
|
|
begin
|
|
fr_membobs.Lines.Add(re_obsrecibo.Lines[k]);
|
|
fr_membobs2v.Lines.Add(re_obsrecibo.Lines[k]);
|
|
end;
|
|
if index_pagamento = 3 then
|
|
begin
|
|
frpnl_cheque.Visible := True;
|
|
frlbl_obscheque.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.tblCidades.Locate('ID_CIDADE',
|
|
dtmSystem.tblEmpresaID_CIDADE.AsString, []);
|
|
dtmSystem.tblEstados.Locate('ID_ESTADO',
|
|
dtmSystem.tblEmpresaID_ESTADO.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
|
|
frdbimg_logo.Height := 170;
|
|
frdbimg_logo.Width := 133;
|
|
end;
|
|
if frdbimg_logo.Picture.Height < frdbimg_logo.Picture.Width then
|
|
begin
|
|
frdbimg_logo.Height := 133;
|
|
frdbimg_logo.Width := 170;
|
|
end;
|
|
if frdbimg_logo.Picture.Height = frdbimg_logo.Picture.Width then
|
|
begin
|
|
frdbimg_logo.Height := 133;
|
|
frdbimg_logo.Width := 133;
|
|
end;
|
|
frRecibo.PreviewModal;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
for l := 0 to strtoint(edt_nrparcelas.Text) do
|
|
begin
|
|
if StrToCurr(edt_excentrada.Text) = 0 then
|
|
begin
|
|
continue;
|
|
end
|
|
else
|
|
begin
|
|
|
|
end;
|
|
end;
|
|
if tblReciboTX_NOME.AsString <> '' then
|
|
begin
|
|
tblRecibo.Append;
|
|
tblReciboNR_RECIBO.AsString :=
|
|
Format('%.*d', [6, strtoint(old_nr) + 1]);
|
|
tblRecibo.Post;
|
|
end;
|
|
relRecibo := TrelRecibo.Create(self);
|
|
dtmSystem.tblConteudoRecibo.RecNo := 1;
|
|
with relRecibo do
|
|
begin
|
|
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 +
|
|
CurrToStrF(dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency,
|
|
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
|
|
(dtmSystem.tblConteudoReciboVL_CORRIGIDO.AsCurrency) + ')';
|
|
frlbl_vlextenso2v.Caption := frlbl_vlextenso.Caption;
|
|
frlbl_formarecebimento.Caption := frlbl_formarecebimento.Caption +
|
|
edt_formarecebimento.Text;
|
|
frlbl_formarecebimento2v.Caption := frlbl_formarecebimento.Caption;
|
|
for k := 0 to re_obsrecibo.Lines.Count - 1 do
|
|
begin
|
|
fr_membobs.Lines.Add(re_obsrecibo.Lines[k]);
|
|
fr_membobs2v.Lines.Add(re_obsrecibo.Lines[k]);
|
|
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.tblCidades.Locate('ID_CIDADE',
|
|
dtmSystem.tblEmpresaID_CIDADE.AsString, []);
|
|
dtmSystem.tblEstados.Locate('ID_ESTADO',
|
|
dtmSystem.tblEmpresaID_ESTADO.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
|
|
frdbimg_logo.Height := 170;
|
|
frdbimg_logo.Width := 133;
|
|
end;
|
|
if frdbimg_logo.Picture.Height < frdbimg_logo.Picture.Width then
|
|
begin
|
|
frdbimg_logo.Height := 133;
|
|
frdbimg_logo.Width := 170;
|
|
end;
|
|
if frdbimg_logo.Picture.Height = frdbimg_logo.Picture.Width then
|
|
begin
|
|
frdbimg_logo.Height := 133;
|
|
frdbimg_logo.Width := 133;
|
|
end;
|
|
frRecibo.PreviewModal;
|
|
end;
|
|
end;
|
|
tblRecibo.Close;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmAtendimento.btn_closeClick(Sender: TObject);
|
|
begin
|
|
Close;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.btn_concluirClick(Sender: TObject);
|
|
var
|
|
i, j: integer;
|
|
begin
|
|
// atendimento := 'atendendo';
|
|
// pcDevedor.TabIndex := 5;
|
|
dtmSystem.tblTitulos.RecNo := 1;
|
|
if forma_pagamento = 'Q' then
|
|
begin
|
|
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 := 'QC';
|
|
tblTitulosVL_MULTA.AsCurrency := queryListaTitulosVL_MULTA.AsCurrency;
|
|
tblTitulosVL_JUROS.AsCurrency := queryListaTitulosVL_JUROS.AsCurrency;
|
|
tblTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency;
|
|
tblTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency;
|
|
tblTitulosDT_PAGAMENTO.AsDateTime := Date;
|
|
tblTitulos.Post;
|
|
tblHistorico.Append;
|
|
tblHistoricoID_DEVEDOR.AsInteger := tblDevedoresID_DEVEDOR.AsInteger;
|
|
tblHistoricoID_TITULO.AsInteger := tblTitulosID_TITULO.AsInteger;
|
|
tblHistoricoID_PROVIDENCIA.AsInteger := 2;
|
|
// 2 = quitado com a empresa de cobrança
|
|
tblHistoricoDT_CONTATO.AsDateTime := Date;
|
|
tblHistoricoTL_MEMO.AsString := 'O título ' +
|
|
tblTitulosTX_PRODUTO.AsString + ' - ' +
|
|
tblTitulosCD_DEVEDOR.AsString + ', pertencente ao devedor ' +
|
|
tblDevedoresTX_NOME.AsString + ' foi quitado no dia ' +
|
|
DateToStr(Date) + ' na empresa ' + tblEmpresaTX_NOME.AsString + '.';
|
|
tblHistorico.Post;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if forma_pagamento = 'P' then
|
|
begin
|
|
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 := 'AC';
|
|
tblTitulosVL_MULTA.AsCurrency := queryListaTitulosVL_MULTA.AsCurrency;
|
|
tblTitulosVL_JUROS.AsCurrency := queryListaTitulosVL_JUROS.AsCurrency;
|
|
tblTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency;
|
|
tblTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency;
|
|
tblTitulos.Post;
|
|
tblHistorico.Append;
|
|
tblHistoricoID_DEVEDOR.AsInteger := tblDevedoresID_DEVEDOR.AsInteger;
|
|
tblHistoricoID_TITULO.AsInteger := tblTitulosID_TITULO.AsInteger;
|
|
tblHistoricoID_PROVIDENCIA.AsInteger := 3;
|
|
// 3 = acordado com a empresa de cobrança
|
|
tblHistoricoDT_CONTATO.AsDateTime := Date;
|
|
tblHistoricoTL_MEMO.AsString := 'O título ' +
|
|
tblTitulosTX_PRODUTO.AsString + ' - ' +
|
|
tblTitulosCD_DEVEDOR.AsString + ', pertencente ao devedor ' +
|
|
tblDevedoresTX_NOME.AsString + ' foi acordado no dia ' +
|
|
DateToStr(Date) + ' na empresa ' + tblEmpresaTX_NOME.AsString +
|
|
' para ser parcelado.';
|
|
tblHistorico.Post;
|
|
end;
|
|
end;
|
|
end;
|
|
if dtmSystem.tblCHGEmpresaTP_CONFIANCA.AsString = 'S' then
|
|
begin
|
|
if index_pagamento = 1 then
|
|
begin
|
|
for j := 0 to lv_fechamento.Items.Count - 1 do
|
|
begin
|
|
with dtmSystem do
|
|
begin
|
|
tblTitulos.Append;
|
|
if j = 0 then
|
|
begin
|
|
tblTitulosTX_PRODUTO.AsString := 'Entrada';
|
|
tblTitulosID_EMPRESA.AsInteger := 1;
|
|
tblTitulosDT_VENCIMENTO.AsDateTime := Date;
|
|
tblTitulosDT_ENTRADA.AsDateTime := Date;
|
|
tblTitulosVL_TITULO.AsCurrency :=
|
|
StrToCurr(copy(edt_somaentrada.Text, 3,
|
|
length(edt_somaentrada.Text) - 3));
|
|
tblTitulosTP_SITUACAO.AsString := 'QC';
|
|
// tblTitulosCD_DEVEDOR.AsString := tblDevedoresCD_DEVEDOR.AsString;
|
|
end
|
|
else
|
|
begin
|
|
tblTitulosTX_PRODUTO.AsString := 'Parcela nº ' + inttostr(j);
|
|
tblTitulosID_EMPRESA.AsInteger := 1;
|
|
// if j = 1 then
|
|
// begin
|
|
// tblTitulosDT_VENCIMENTO.AsDateTime := Date;
|
|
// tblTitulosDT_ENTRADA.AsDateTime := Date;
|
|
// tblTitulosVL_TITULO.AsCurrency :=
|
|
// StrToCurr(copy(lv_fechamento.Items[1].SubItems[0], 3,
|
|
// length(lv_fechamento.Items[1].SubItems[0]) - 3));
|
|
// tblTitulosTP_SITUACAO.AsString := 'QC';
|
|
// //tblTitulosCD_DEVEDOR.AsString := tblDevedoresCD_DEVEDOR.AsString;
|
|
// end
|
|
// else
|
|
// begin
|
|
tblTitulosDT_VENCIMENTO.AsDateTime :=
|
|
StrToDate(lv_fechamento.Items[j].SubItems[1]);
|
|
tblTitulosDT_ENTRADA.AsDateTime := Date;
|
|
tblTitulosVL_TITULO.AsCurrency :=
|
|
StrToCurr(copy(lv_fechamento.Items[j].SubItems[0], 3,
|
|
length(lv_fechamento.Items[j].SubItems[1]) - 3));
|
|
tblTitulosTP_SITUACAO.AsString := 'A';
|
|
// tblTitulosCD_DEVEDOR.AsString := tblDevedoresCD_DEVEDOR.AsString;
|
|
// end;
|
|
end;
|
|
tblTitulos.Post;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end;
|
|
atendimento := 'atendendo';
|
|
btn_concluir.Enabled := False;
|
|
Close;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.CalcValorParcelas;
|
|
var
|
|
i, j, k, Y: integer;
|
|
valor_parcela, valor_entrada: currency;
|
|
data_helper: TDate;
|
|
dia_antes, dia_depois, mes, ano: Word;
|
|
begin
|
|
setlength(parcelamento, 0);
|
|
lv_parcelas.Clear;
|
|
valor_entrada := 0;
|
|
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;
|
|
if strtoint(edt_nrparcelas.Text) <= queryListaTitulosNR_PARCELAS.AsInteger
|
|
then
|
|
begin
|
|
if cb_nmulta.Checked then
|
|
begin
|
|
valor_parcela := (queryListaTitulosVL_CORRIGIDO.AsCurrency -
|
|
queryListaTitulosVL_ENTRADA.AsCurrency -
|
|
queryListaTitulosVL_MULTA.AsCurrency) /
|
|
strtofloat(edt_nrparcelas.Text);
|
|
valor_entrada := valor_entrada +
|
|
(queryListaTitulosVL_ENTRADA.AsCurrency);
|
|
end
|
|
else
|
|
begin
|
|
valor_parcela := (queryListaTitulosVL_CORRIGIDO.AsCurrency -
|
|
queryListaTitulosVL_ENTRADA.AsCurrency) /
|
|
strtofloat(edt_nrparcelas.Text);
|
|
end;
|
|
for j := 0 to strtoint(edt_nrparcelas.Text) - 1 do
|
|
begin
|
|
parcelamento[j] := parcelamento[j] + valor_parcela;
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
if cb_nmulta.Checked then
|
|
begin
|
|
valor_parcela := (queryListaTitulosVL_CORRIGIDO.AsCurrency -
|
|
queryListaTitulosVL_ENTRADA.AsCurrency -
|
|
queryListaTitulosVL_MULTA.AsCurrency) /
|
|
queryListaTitulosNR_PARCELAS.AsInteger;
|
|
valor_entrada := valor_entrada +
|
|
(queryListaTitulosVL_ENTRADA.AsCurrency);
|
|
end
|
|
else
|
|
begin
|
|
valor_parcela := (queryListaTitulosVL_CORRIGIDO.AsCurrency -
|
|
queryListaTitulosVL_ENTRADA.AsCurrency) /
|
|
queryListaTitulosNR_PARCELAS.AsInteger;
|
|
end;
|
|
for j := 0 to strtoint(lv_titulos.Items[i].SubItems[4]) - 1 do
|
|
begin
|
|
parcelamento[j] := parcelamento[j] + valor_parcela;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
// if cbx_excentrada.Checked then
|
|
// begin
|
|
// valor_entrada := StrToCurr(edt_excentrada.Text);
|
|
// end;
|
|
// if cbx_descfixo.Checked then
|
|
// begin
|
|
// valor_entrada := valor_entrada - StrToCurr(edt_descfixo.Text);
|
|
// end;
|
|
// if cbx_acrfixo.Checked then
|
|
// begin
|
|
// valor_entrada := valor_entrada + StrToCurr(edt_acrfixo.Text);
|
|
// end;
|
|
lv_parcelas.Items.Add;
|
|
lv_parcelas.Items[0].Caption := 'Entrada';
|
|
if cb_nmulta.Checked then
|
|
begin
|
|
lv_parcelas.Items[0].SubItems.Add(CurrToStrF(valor_entrada,
|
|
ffCurrency, 2));
|
|
end
|
|
else
|
|
begin
|
|
lv_parcelas.Items[0].SubItems.Add(edt_somaentrada.Text);
|
|
end;
|
|
|
|
for k := 0 to length(parcelamento) - 1 do
|
|
begin
|
|
lv_parcelas.Items.Add;
|
|
lv_parcelas.Items[k + 1].Caption := 'Parcela nº ' + inttostr(k + 1);
|
|
lv_parcelas.Items[k + 1].SubItems.Add(CurrToStrF(parcelamento[k],
|
|
ffCurrency, 2));
|
|
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;
|
|
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',
|
|
queryListaTitulosID_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_principalquitar.Text :=
|
|
dtmSystem.tblProtocoloPR_QUIT_PRINCIPAL.AsString;
|
|
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_principalparcelas.Text :=
|
|
dtmSystem.tblProtocoloPR_PARCELAR_PRINCIPAL.AsString;
|
|
end;
|
|
|
|
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_excentradaClick(Sender: TObject);
|
|
begin
|
|
edt_excentrada.Enabled := cbx_excentrada.Enabled;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
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;
|
|
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';
|
|
end;
|
|
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';
|
|
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';
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.cb_nmultaClick(Sender: TObject);
|
|
begin
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.clb_beneficiarioscalculoClickCheck(Sender: TObject);
|
|
var
|
|
i: integer;
|
|
begin
|
|
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
|
|
continue;
|
|
end
|
|
else
|
|
begin
|
|
Checked[i] := False;
|
|
end;
|
|
Items.EndUpdate;
|
|
end;
|
|
end;
|
|
CriarLista;
|
|
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
|
|
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
|
|
clpbrd := clpbrd + nomes[j] + spaces + valores[j] +
|
|
' para ser pago até dia: ' + FormatDateTime('dd/mm/yyyy',
|
|
data_parcelas[j]) + sLineBreak;
|
|
end;
|
|
end;
|
|
if Sender is TMenuItem then
|
|
begin
|
|
Clipboard.AsText := clpbrd;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.CriarLista;
|
|
var
|
|
h: integer;
|
|
begin
|
|
if queryListaTitulos.Connection = nil then
|
|
// BACALHAU, NÃO TEM EXPLICAÇÃO. SÓ FUNCIONA.
|
|
begin
|
|
exit;
|
|
end;
|
|
dtmSystem.tblCHGEmpresa.Open;
|
|
for h := 0 to clb_beneficiarioscalculo.Items.Count - 1 do
|
|
begin
|
|
if clb_beneficiarioscalculo.Checked[h] then
|
|
begin
|
|
dtmSystem.tblCHGEmpresa.Locate('TX_NOME',
|
|
clb_beneficiarioscalculo.Items[h], []);
|
|
end;
|
|
end;
|
|
|
|
queryListaTitulos.SQL.Clear;
|
|
queryListaTitulos.SQL.Text :=
|
|
'select * from (select * from chg_titulos where id_devedor = ' +
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString +
|
|
') where (tp_situacao = ''A'') and' + '(id_empresa = ' +
|
|
dtmSystem.tblCHGEmpresaID_EMPRESA.AsString + ')';
|
|
queryListaTitulos.Open;
|
|
|
|
queryListaTitulos.First;
|
|
|
|
lv_titulos.Clear;
|
|
|
|
while not queryListaTitulos.Eof do
|
|
begin
|
|
dtmSystem.tblFaixas.Filter := '(DT_INICIO < ' +
|
|
queryListaTitulosDT_ATRASO.AsString + ')and(DT_FINAL > ' +
|
|
queryListaTitulosDT_ATRASO.AsString + ')';
|
|
dtmSystem.tblFaixas.Filtered := True;
|
|
dtmSystem.tblFaixas.Open;
|
|
dtmSystem.tblPoliticas.Open;
|
|
dtmSystem.tblPoliticas.Locate('ID_POLITICA',
|
|
dtmSystem.tblFaixasID_POLITICA.AsString, []);
|
|
with lv_titulos.Items.Add do
|
|
begin
|
|
SubItems.Add(queryListaTitulos.FieldByName('NOME_EMPRESA').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('TX_PRODUTO').AsString);
|
|
SubItems.Add(CurrToStrF(queryListaTitulos.FieldByName('VL_TITULO')
|
|
.AsCurrency, ffCurrency, 2));
|
|
SubItems.Add(queryListaTitulos.FieldByName('CD_DEVEDOR').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('NR_PARCELAS').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('DT_VENCIMENTO').AsString);
|
|
SubItems.Add(queryListaTitulos.FieldByName('DT_ENTRADA').AsString);
|
|
end;
|
|
lv_titulos.Column[0].Alignment := taCenter;
|
|
dtmSystem.tblFaixas.Filtered := False;
|
|
queryListaTitulos.Next;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.dbgrd_pesquisarDblClick(Sender: TObject);
|
|
begin
|
|
dtmSystem.tblDevedores.Locate('TX_NOME', qryPesquisa.FieldByName('TX_NOME')
|
|
.AsString, []);
|
|
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.dtp_atrasorecalcChange(Sender: TObject);
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.dtsDevedorDataChange(Sender: TObject; Field: TField);
|
|
var
|
|
new_id: 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 then
|
|
begin
|
|
old_id := new_id;
|
|
clb_beneficiarioscalculo.Clear;
|
|
|
|
qryConsulta.SQL.Text := 'select * from chg_empresas where id_empresa in ' +
|
|
'(select id_empresa from chg_titulos' +
|
|
' where (tp_situacao = ''A'') and (id_devedor = ' +
|
|
dtmSystem.tblDevedoresID_DEVEDOR.AsString + '))';
|
|
qryConsulta.Open;
|
|
qryConsulta.First;
|
|
while not qryConsulta.Eof do
|
|
begin
|
|
clb_beneficiarioscalculo.Items.Add(qryConsulta.FieldByName('TX_NOME')
|
|
.AsString);
|
|
qryConsulta.Next;
|
|
end;
|
|
|
|
CriarLista;
|
|
// clb_beneficiarioscalculo.Checked[0] := True;
|
|
end;
|
|
|
|
end;
|
|
|
|
procedure TfrmAtendimento.dtsTitulosDataChange(Sender: TObject; Field: TField);
|
|
begin
|
|
if (Field = dtmSystem.tblTitulosVL_DESPESA) or
|
|
(Field = dtmSystem.tblTitulosTP_DESPESA) then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.dtsTitulosStateChange(Sender: TObject);
|
|
begin
|
|
dtmSystem.AlterReadOnly(pnl_titulos, dtsTitulos.DataSet);
|
|
dtmSystem.AlterReadOnly(pnl_cheque, dtsTitulos.DataSet);
|
|
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_descfixoChange(Sender: TObject);
|
|
begin
|
|
// if length(edt_descfixo.Text) < 1 then
|
|
// begin
|
|
// edt_descfixo.Text := '0';
|
|
// end;
|
|
// Att_campos;
|
|
// CalcValorParcelas;
|
|
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_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_acrfixoChange(Sender: TObject);
|
|
begin
|
|
// if length(edt_acrfixo.Text) < 1 then
|
|
// begin
|
|
// edt_acrfixo.Text := '0';
|
|
// end;
|
|
// Att_campos;
|
|
// CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_acrfixoKeyPress(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_acrfixo.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_indparcelasChange(Sender: TObject);
|
|
begin
|
|
if edt_indparcelas.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_encparcelas.Max = 0 then
|
|
begin
|
|
edt_indparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_indquitarChange(Sender: TObject);
|
|
begin
|
|
if edt_indquitar.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_encquitar.Max = 0 then
|
|
begin
|
|
edt_indquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_jurosparcelasChange(Sender: TObject);
|
|
begin
|
|
if edt_jurosparcelas.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_jurosparcelas.Max = 0 then
|
|
begin
|
|
edt_jurosparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_jurosquitarChange(Sender: TObject);
|
|
begin
|
|
if edt_jurosquitar.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_jurosquitar.Max = 0 then
|
|
begin
|
|
edt_jurosquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_multasparcelasChange(Sender: TObject);
|
|
begin
|
|
if edt_multasparcelas.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_multasparcelas.Max = 0 then
|
|
begin
|
|
edt_multasparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_multasquitarChange(Sender: TObject);
|
|
begin
|
|
if edt_multasquitar.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_multasquitar.Max = 0 then
|
|
begin
|
|
edt_multasquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_nrparcelasChange(Sender: TObject);
|
|
begin
|
|
if cb_descquit.Checked then
|
|
begin
|
|
edt_nrparcelas.Text := '0';
|
|
end;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_principalparcelasChange(Sender: TObject);
|
|
begin
|
|
if edt_principalparcelas.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
CalcValorParcelas;
|
|
end;
|
|
if up_principalparcelas.Max = 0 then
|
|
begin
|
|
edt_principalparcelas.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.edt_principalquitarChange(Sender: TObject);
|
|
begin
|
|
if edt_principalquitar.Text <> '' then
|
|
begin
|
|
queryListaTitulos.Refresh;
|
|
Att_campos;
|
|
end;
|
|
if up_principalquitar.Max = 0 then
|
|
begin
|
|
edt_principalquitar.Text := '0';
|
|
exit;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.FormCreate(Sender: TObject);
|
|
var
|
|
Pos: integer;
|
|
begin
|
|
Pos := 0;
|
|
old_id := -1;
|
|
atendimento := 'atendendo';
|
|
dtp_atrasorecalc.Date := Date;
|
|
|
|
with dtmSystem do
|
|
begin
|
|
|
|
if not tblDevedores.Active then
|
|
begin
|
|
tblDevedores.Open;
|
|
end;
|
|
tblEnderecos.Open;
|
|
tblTelefones.Open;
|
|
tblTitulos.Open;
|
|
tblProtocolo.Open;
|
|
tblEmpresa.Open;
|
|
tblEmpresa.First;
|
|
tblCHGEmpresa.Open;
|
|
tblCHGEmpresa.First;
|
|
// setlength(cbl_hints,pos+1); pegar do banco texto para jogar nas hints
|
|
while not tblCHGEmpresa.Eof do
|
|
begin
|
|
clb_empresas.Items.Add(tblCHGEmpresaTX_NOME.AsString);
|
|
// cbl_hints[pos] := tblCHGEmpresaTX_CNPJ.AsString;
|
|
if tblTitulosID_EMPRESA.AsString = tblCHGEmpresaID_EMPRESA.AsString then
|
|
begin
|
|
clb_empresas.Checked[Pos] := True;
|
|
end;
|
|
tblCHGEmpresa.Next;
|
|
Pos := Pos + 1;
|
|
// setlength(cbl_hints,pos+1);
|
|
end;
|
|
|
|
tblIndices.Open;
|
|
tblIndices.First;
|
|
while not tblIndices.Eof do
|
|
begin
|
|
clb_indices.Items.Add(tblIndicesTX_NOME.AsString);
|
|
// cbl_hints[pos] := tblCHGEmpresaTX_CNPJ.AsString;
|
|
tblIndices.Next;
|
|
// setlength(cbl_hints,pos+1);
|
|
end;
|
|
tblHistorico.Open;
|
|
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');
|
|
SetupHackedNavigator(navenderecos, ImageList1, 's');
|
|
SetupHackedNavigator(navtelefones, ImageList1, 's');
|
|
SetupHackedNavigator(navtitulos, ImageList1, 's');
|
|
SetupHackedNavigator(navhistorico, ImageList1, 's');
|
|
|
|
pcDevedor.ActivePageIndex := 0;
|
|
dtsDevedor.DataSet.Refresh;
|
|
CriarLista;
|
|
end;
|
|
|
|
procedure TfrmAtendimento.FormDestroy(Sender: TObject);
|
|
begin
|
|
lv_titulos.WindowProc := FListViewOldWndProc;
|
|
FListViewOldWndProc := nil;
|
|
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.pcDevedorChange(Sender: TObject);
|
|
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;
|
|
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: currency;
|
|
g: integer;
|
|
begin
|
|
// quant de dias de atraso
|
|
dtmSystem.tblCHGEmpresa.Locate('ID_EMPRESA',
|
|
queryListaTitulosID_EMPRESA.AsString, []);
|
|
queryListaTitulosDT_ATRASO.AsInteger := DaysBetween(dtp_atrasorecalc.Date,
|
|
queryListaTitulosDT_VENCIMENTO.AsDateTime);
|
|
vl_nominal := queryListaTitulosVL_TITULO.AsCurrency;
|
|
|
|
with dtmSystem do
|
|
begin
|
|
|
|
if ROQueryFaixa.Connection = nil then
|
|
// BACALHAU, NÃO TEM EXPLICAÇÃO. SÓ FUNCIONA.
|
|
begin
|
|
exit;
|
|
end;
|
|
|
|
ROQueryFaixa.SQL.Clear;
|
|
ROQueryFaixa.SQL.Add('select pr_faixa from chg_faixas where DT_INICIO < ' +
|
|
queryListaTitulosDT_ATRASO.AsString + ' and DT_FINAL > ' +
|
|
queryListaTitulosDT_ATRASO.AsString);
|
|
ROQueryFaixa.Open;
|
|
|
|
// valor da parcela do indicador
|
|
queryListaTitulosPR_INDICADOR.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_FAIXA').AsFloat;
|
|
pl_indicador := vl_nominal * (queryListaTitulosPR_INDICADOR.AsFloat / 100);
|
|
queryListaTitulosVL_INDICADOR.AsCurrency := pl_indicador;
|
|
|
|
ROQueryFaixa.SQL.Clear;
|
|
ROQueryFaixa.SQL.Add
|
|
('select * from chg_politicas where id_politica in (select id_politica from chg_faixas where DT_INICIO < '
|
|
+ queryListaTitulosDT_ATRASO.AsString + ' and DT_FINAL > ' +
|
|
queryListaTitulosDT_ATRASO.AsString + ')');
|
|
ROQueryFaixa.Open;
|
|
|
|
// número máx de parcelamento
|
|
queryListaTitulosNR_PARCELAS.AsInteger :=
|
|
ROQueryFaixa.FieldByName('NR_PARCELA_MAXIMO').AsInteger;
|
|
|
|
// parcela do juros
|
|
queryListaTitulosPR_JUROS.AsFloat := ROQueryFaixa.FieldByName
|
|
('PR_JUROS').AsFloat;
|
|
pl_juros := vl_nominal * ((queryListaTitulosPR_JUROS.AsFloat / 30) / 100) *
|
|
queryListaTitulosDT_ATRASO.AsInteger;
|
|
queryListaTitulosVL_JUROS.AsCurrency := pl_juros;
|
|
|
|
// parcela da multa
|
|
queryListaTitulosPR_MULTA.AsFloat := ROQueryFaixa.FieldByName
|
|
('PR_MULTA').AsFloat;
|
|
pl_multa := (queryListaTitulosPR_MULTA.AsFloat / 100) * vl_nominal;
|
|
queryListaTitulosVL_MULTA.AsCurrency := pl_multa;
|
|
|
|
vl_indices := 0;
|
|
for g := 0 to clb_indices.Items.Count - 1 do
|
|
begin
|
|
if clb_indices.Checked[g] then
|
|
begin
|
|
dtmSystem.tblIndices.RecNo := g + 1;
|
|
vl_indices := vl_indices +
|
|
(vl_nominal * (((dtmSystem.tblIndicesPR_INDICE.AsFloat / 30) / 100) *
|
|
queryListaTitulosDT_ATRASO.AsInteger));
|
|
end;
|
|
end;
|
|
// valor dos índices
|
|
queryListaTitulosVL_INDICES.AsCurrency := vl_indices;
|
|
|
|
pl_encargos := pl_multa + pl_juros + pl_indicador + vl_indices;
|
|
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;
|
|
|
|
// parcela da entrada
|
|
queryListaTitulosPR_ENTRADA.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_ENTRADA').AsFloat;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
pl_entrada := StrToCurr(edt_excentrada.Text);
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := pl_entrada;
|
|
end
|
|
else
|
|
begin
|
|
pl_entrada := vl_corrigido * (queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := pl_entrada;
|
|
end;
|
|
|
|
// % descontos
|
|
queryListaTitulosPR_QUITACAO_INDICADOR.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_QUITACAO_INDICADOR').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_PRINCIPAL.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_QUITACAO_PRINCIPAL').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_MULTA.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_QUITACAO_MULTA').AsFloat;
|
|
queryListaTitulosPR_QUITACAO_JUROS.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_QUITACAO_JUROS').AsFloat;
|
|
queryListaTitulosPR_PARCELA_INDICADOR.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_PARCELA_INDICADOR').AsFloat;
|
|
queryListaTitulosPR_PARCELA_PRINCIPAL.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_PARCELA_PRINCIPAL').AsFloat;
|
|
queryListaTitulosPR_PARCELA_MULTA.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_PARCELA_MULTA').AsFloat;
|
|
queryListaTitulosPR_PARCELA_JUROS.AsFloat :=
|
|
ROQueryFaixa.FieldByName('PR_PARCELA_JUROS').AsFloat;
|
|
|
|
tblFaixas.Filtered := False;
|
|
end;
|
|
|
|
// Descontos sobre Quitar
|
|
if strtoint(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 *
|
|
(strtoint(edt_indquitar.Text) / 100);
|
|
end;
|
|
if strtoint(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 *
|
|
(strtoint(edt_principalquitar.Text) / 100);
|
|
end;
|
|
if strtoint(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 *
|
|
(strtoint(edt_multasquitar.Text) / 100);
|
|
end;
|
|
if strtoint(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 *
|
|
(strtoint(edt_jurosquitar.Text) / 100);
|
|
end;
|
|
|
|
// Descontos sobre Parcelar
|
|
if strtoint(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 *
|
|
(strtoint(edt_indparcelas.Text) / 100);
|
|
end;
|
|
if strtoint(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 *
|
|
(strtoint(edt_principalparcelas.Text) / 100);
|
|
end;
|
|
if strtoint(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 *
|
|
(strtoint(edt_multasparcelas.Text) / 100);
|
|
end;
|
|
if strtoint(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 *
|
|
(strtoint(edt_jurosparcelas.Text) / 100);
|
|
end;
|
|
|
|
if (cb_descquit.Checked) then
|
|
begin
|
|
queryListaTitulosVL_INDICADOR.AsCurrency := pl_indicador -
|
|
queryListaTitulosVL_DESC_QUIT_IND.AsCurrency;
|
|
queryListaTitulosVL_TITULO.AsCurrency := vl_nominal -
|
|
queryListaTitulosVL_DESC_QUIT_PRIN.AsCurrency;
|
|
queryListaTitulosVL_JUROS.AsCurrency := pl_juros -
|
|
queryListaTitulosVL_DESC_QUIT_JUROS.AsCurrency;
|
|
queryListaTitulosVL_MULTA.AsCurrency := pl_multa -
|
|
queryListaTitulosVL_DESC_QUIT_MULTA.AsCurrency;
|
|
if cb_nmulta.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency +
|
|
queryListaTitulosVL_INDICADOR.AsCurrency;
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency +
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency +
|
|
queryListaTitulosVL_INDICADOR.AsCurrency +
|
|
queryListaTitulosVL_MULTA.AsCurrency;
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency +
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
if (cb_descpar.Checked) and (strtoint(edt_nrparcelas.Text) >= 1) then
|
|
begin
|
|
queryListaTitulosVL_INDICADOR.AsCurrency := pl_indicador -
|
|
queryListaTitulosVL_DESC_PAR_IND.AsCurrency;
|
|
queryListaTitulosVL_TITULO.AsCurrency := vl_nominal -
|
|
queryListaTitulosVL_DESC_PAR_PRIN.AsCurrency;
|
|
queryListaTitulosVL_JUROS.AsCurrency := pl_juros -
|
|
queryListaTitulosVL_DESC_PAR_JUROS.AsCurrency;
|
|
queryListaTitulosVL_MULTA.AsCurrency := pl_multa -
|
|
queryListaTitulosVL_DESC_PAR_MULTA.AsCurrency;
|
|
if cb_nmulta.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency +
|
|
queryListaTitulosVL_INDICADOR.AsCurrency;
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency +
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency :=
|
|
queryListaTitulosVL_JUROS.AsCurrency +
|
|
queryListaTitulosVL_INDICADOR.AsCurrency +
|
|
queryListaTitulosVL_MULTA.AsCurrency;
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_TITULO.AsCurrency +
|
|
queryListaTitulosVL_ENCARGOS.AsCurrency;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
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 queryListaTitulosVL_DESPESA.AsCurrency <> 0 then
|
|
begin
|
|
if queryListaTitulosTP_DESPESA.AsString = 'A' then
|
|
begin
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency +
|
|
queryListaTitulosVL_DESPESA.AsCurrency;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
end;
|
|
if queryListaTitulosTP_DESPESA.AsString = 'D' then
|
|
begin
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency -
|
|
queryListaTitulosVL_DESPESA.AsCurrency;
|
|
if cbx_excentrada.Checked then
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency := StrToCurr(edt_excentrada.Text)
|
|
end
|
|
else
|
|
begin
|
|
queryListaTitulosVL_ENTRADA.AsCurrency :=
|
|
queryListaTitulosVL_CORRIGIDO.AsCurrency *
|
|
(queryListaTitulosPR_ENTRADA.AsFloat / 100);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
{ procedure TfrmAtendimento.rg_tipopagamentoClick(Sender: TObject);
|
|
begin
|
|
// 0=dinheiro;1=débito;2=crédito;3=cheque;
|
|
if tipo_pagamento = 'Q' then
|
|
begin
|
|
case rg_tipopagamento.ItemIndex of
|
|
0:
|
|
end;
|
|
end;
|
|
if tipo_pagamento = 'P' then
|
|
begin
|
|
|
|
end;
|
|
|
|
end; }
|
|
|
|
procedure TfrmAtendimento.SetupHackedNavigator(const Navigator: TDBNavigator;
|
|
const Glyphs: TImageList; S: string);
|
|
const
|
|
Captions: array [TNavigateBtn] of string = ('Primeiro', 'Anterior', 'Próximo',
|
|
'Último', 'Adicionar', 'Apagar', 'Modificar', '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];
|
|
end;
|
|
end;
|
|
|
|
end.
|