git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES/trunk@4 3f40d355-893c-4141-8e64-b1d9be72e7e7
455 lines
14 KiB
ObjectPascal
455 lines
14 KiB
ObjectPascal
{
|
|
===============================================================================
|
|
Copyright (©) 2003. Rodax Software.
|
|
===============================================================================
|
|
Los contenidos de este fichero son propiedad de Rodax Software titular del
|
|
copyright. Este fichero sólo podrá ser copiado, distribuido y utilizado,
|
|
en su totalidad o en parte, con el permiso escrito de Rodax Software, o de
|
|
acuerdo con los términos y condiciones establecidas en el acuerdo/contrato
|
|
bajo el que se suministra.
|
|
-----------------------------------------------------------------------------
|
|
Web: www.rodax-software.com
|
|
===============================================================================
|
|
Fecha primera versión: 22-02-2003
|
|
Versión actual: 1.0.4
|
|
Fecha versión actual: 04-02-2005
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
15-08-2003 Se ha cambiado el intervalo a intervalo de nombre en vez
|
|
de intervalo de códigos de cliente.
|
|
30-01-2004 Se utiliza el trimestre por defecto.
|
|
30-03-2004 Se ha eliminado el atributo SERIE (P8 MULTIEMPRESA)
|
|
04-02-2005 Se elimnina la separación entre el informe resumen facturas e historial
|
|
facturas quedando un único informe desde el que acceder a ambos.
|
|
===============================================================================
|
|
}
|
|
|
|
unit HistorialFacturacionClientes;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, RdxFrame, RdxTitulos, cxDropDownEdit, cxCalendar, cxDBEdit,
|
|
RdxBotones, RdxPaneles, RdxBarras, cxMaskEdit, cxButtonEdit, cxControls,
|
|
cxContainer, cxEdit, cxTextEdit, StdCtrls, AdvPanel, ExtCtrls, Configuracion,
|
|
cxCheckBox, cxSpinEdit, InformeHistorialFacturacionClientes, VistaPrevia,
|
|
TablaClientes, RdxRadioButton, RdxShape, TablaTrimestres, Entidades,
|
|
InformeResumenFacturacionClientes;
|
|
|
|
type
|
|
TfrHistorialFacturacionClientes = class(TRdxFrame)
|
|
pnlTitulo: TRdxPanelTituloOperacion;
|
|
pnlCuerpo: TPanel;
|
|
pnlProveedor: TAdvPanel;
|
|
eCodigoCliente: TLabel;
|
|
pnlVistaPrevia: TPanel;
|
|
Label2: TLabel;
|
|
cbCantidadMin: TcxCheckBox;
|
|
CantidadMinima: TcxSpinEdit;
|
|
NombreCliIni: TcxButtonEdit;
|
|
NombreCliFin: TcxButtonEdit;
|
|
RdxShape1: TRdxShape;
|
|
rbTrimestre: TRdxRadioButton;
|
|
cbxTrimestres: TcxComboBox;
|
|
rbFechas: TRdxRadioButton;
|
|
FechaInicial: TcxDateEdit;
|
|
eFechaFin: TLabel;
|
|
FechaFinal: TcxDateEdit;
|
|
cbAgrupar: TcxCheckBox;
|
|
procedure bImprimirClick(Sender: TObject);
|
|
procedure cbCantidadMinClick(Sender: TObject);
|
|
procedure cbCantidadMinPropertiesChange(Sender: TObject);
|
|
procedure FechaIniPropertiesValidate(Sender: TObject;
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
procedure FechaFinPropertiesValidate(Sender: TObject;
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
procedure CantidadMinimaPropertiesValidate(Sender: TObject;
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
procedure NombreCliIniPropertiesButtonClick(Sender: TObject;
|
|
AButtonIndex: Integer);
|
|
procedure NombreCliIniPropertiesValidate(Sender: TObject;
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
procedure NombreCliFinPropertiesValidate(Sender: TObject;
|
|
var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
procedure NombreCliFinPropertiesButtonClick(Sender: TObject;
|
|
AButtonIndex: Integer);
|
|
procedure rbTrimestreClick(Sender: TObject);
|
|
procedure rbFechasClick(Sender: TObject);
|
|
procedure cbxTrimestresPropertiesEditValueChanged(Sender: TObject);
|
|
procedure cbAgruparPropertiesChange(Sender: TObject);
|
|
private
|
|
FVistaPrevia : TfrVistaPrevia;
|
|
FInforme : TdmInformeHistorialFacturacionClientes;
|
|
FInforme2 : TdmInformeResumenFacturacionClientes;
|
|
FClienteIni : TDatosCliente;
|
|
FClienteFin : TDatosCliente;
|
|
FCodigoClienteAux : Variant;
|
|
FListaTrimestres : TListaTrimestres;
|
|
FAgrupado : Boolean;
|
|
procedure SetAgrupado(const Value: Boolean);
|
|
protected
|
|
property Agrupado: Boolean read FAgrupado write SetAgrupado;
|
|
procedure VerModal; override;
|
|
procedure FreeContenido; override;
|
|
function CloseFrame : Boolean; override;
|
|
function CambiarEntidad(EntidadAnterior, Entidad : TRdxEntidad): Boolean; override;
|
|
public
|
|
constructor Create(AOwner : TComponent); override;
|
|
destructor Destroy; override;
|
|
end;
|
|
|
|
var
|
|
frHistorialFacturacionClientes: TfrHistorialFacturacionClientes;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
{ TfrHistorialFacturacionClientes }
|
|
|
|
uses
|
|
Literales, Mensajes, DateFunc, StrFunc, DateUtils, InformeBase,
|
|
Clientes, RdxFrameClientes, cxDateUtils;
|
|
|
|
function TfrHistorialFacturacionClientes.CloseFrame: Boolean;
|
|
begin
|
|
FInforme.Preview := NIL;
|
|
FInforme2.Preview := NIL;
|
|
(FVistaPrevia as TRdxFrame).CloseFrame;
|
|
Result := inherited CloseFrame;
|
|
end;
|
|
|
|
constructor TfrHistorialFacturacionClientes.Create(AOwner: TComponent);
|
|
var
|
|
NombreAux : String;
|
|
begin
|
|
inherited Create(AOwner);
|
|
Entidad := entHistorialFacturacionClientes;
|
|
FAgrupado := True;
|
|
|
|
FClienteIni := TDatosCliente.Create;
|
|
FClienteFin := TDatosCliente.Create;
|
|
|
|
FechaInicial.Date := DarDiaInicioMesDat;
|
|
FechaFinal.Date := DarDiaFinalMesDat;
|
|
|
|
NombreAux := dmTablaClientes.DarNombreCliMin;
|
|
FClienteIni.Codigo := '';
|
|
FClienteIni.Nombre := NombreAux;
|
|
FClienteIni.ObtenerDatos;
|
|
NombreCliIni.EditingText := FClienteIni.Nombre;
|
|
|
|
NombreAux := dmTablaClientes.DarNombreCliMax;
|
|
FClienteFin.Codigo := '';
|
|
FClienteFin.Nombre := NombreAux;
|
|
FClienteFin.ObtenerDatos;
|
|
NombreCliFin.EditingText := FClienteFin.Nombre;
|
|
|
|
FVistaPrevia := TfrVistaPrevia.Create(Self);
|
|
FVistaPrevia.Parent := pnlVistaPrevia;
|
|
|
|
FInforme := TdmInformeHistorialFacturacionClientes.Create(Self);
|
|
with FInforme do
|
|
begin
|
|
Preview := FVistaPrevia.Preview;
|
|
NombreIni := FClienteIni.Nombre;
|
|
NombreFin := FClienteFin.Nombre;
|
|
//FechaFacIni := FechaIni.EditValue;
|
|
//FechaFacFin := FechaFin.EditValue;
|
|
if cbCantidadMin.Checked then
|
|
ImporteMinimo := CantidadMinima.Value
|
|
else
|
|
ImporteMinimo := NULL;
|
|
//Previsualizar;
|
|
end;
|
|
|
|
FInforme2 := TdmInformeResumenFacturacionClientes.Create(Self);
|
|
with FInforme2 do
|
|
begin
|
|
Preview := FVistaPrevia.Preview;
|
|
NombreIni := FClienteIni.Nombre;
|
|
NombreFin := FClienteFin.Nombre;
|
|
//FechaFacIni := FechaIni.EditValue;
|
|
//FechaFacFin := FechaFin.EditValue;
|
|
if cbCantidadMin.Checked then
|
|
ImporteMinimo := CantidadMinima.Value
|
|
else
|
|
ImporteMinimo := NULL;
|
|
//Previsualizar;
|
|
end;
|
|
|
|
FListaTrimestres := TListaTrimestres.Create(tlcTriTodos);
|
|
cbxTrimestres.ItemIndex := FListaTrimestres.cargarLista(cbxTrimestres.Properties.Items);
|
|
end;
|
|
|
|
destructor TfrHistorialFacturacionClientes.Destroy;
|
|
begin
|
|
FInforme.Free;
|
|
FInforme2.Free;
|
|
FClienteIni.Free;
|
|
FClienteFin.Free;
|
|
|
|
FListaTrimestres.Free;
|
|
FListaTrimestres:= Nil;
|
|
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.bImprimirClick(Sender: TObject);
|
|
begin
|
|
if Agrupado then
|
|
FInforme.Imprimir
|
|
else
|
|
FInforme2.Imprimir;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.cbCantidadMinClick(
|
|
Sender: TObject);
|
|
begin
|
|
CantidadMinima.Enabled := cbCantidadMin.Checked;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.cbCantidadMinPropertiesChange(
|
|
Sender: TObject);
|
|
begin
|
|
if cbCantidadMin.Checked then
|
|
begin
|
|
FInforme.ImporteMinimo := CantidadMinima.Value;
|
|
FInforme2.ImporteMinimo := CantidadMinima.Value;
|
|
end
|
|
else
|
|
begin
|
|
FInforme.ImporteMinimo := NULL;
|
|
FInforme2.ImporteMinimo := NULL;
|
|
end;
|
|
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.VerModal;
|
|
begin
|
|
if (ContenidoModal is TRdxFrameClientes) then
|
|
(ContenidoModal as TRdxFrameClientes).CodigoCliente := FCodigoClienteAux;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.FreeContenido;
|
|
begin
|
|
if (ContenidoModal is TRdxFrameClientes) then
|
|
FCodigoClienteAux := (ContenidoModal as TRdxFrameClientes).CodigoCliente;
|
|
inherited;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.FechaIniPropertiesValidate(
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
var
|
|
ADate : TDateTime;
|
|
begin
|
|
try
|
|
if DisplayValue > FechaFinal.Date then
|
|
begin
|
|
ErrorText := msgFechasMal;
|
|
Error := True;
|
|
Exit;
|
|
end;
|
|
TextToDateEx(DisplayValue, ADate);
|
|
FInforme.FechaFacIni := ADate;
|
|
FInforme2.FechaFacIni := ADate;
|
|
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
except
|
|
Error := True;
|
|
ErrorText := msgFechaNoValida;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.FechaFinPropertiesValidate(
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
var
|
|
ADate : TDateTime;
|
|
begin
|
|
try
|
|
if DisplayValue < FechaInicial.Date then
|
|
begin
|
|
ErrorText := msgFechasMal;
|
|
Error := True;
|
|
Exit;
|
|
end;
|
|
TextToDateEx(DisplayValue, ADate);
|
|
FInforme.FechaFacFin := ADate;
|
|
FInforme2.FechaFacFin := ADate;
|
|
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
except
|
|
Error := True;
|
|
ErrorText := msgFechaNoValida;
|
|
end;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.CantidadMinimaPropertiesValidate(
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
begin
|
|
if cbCantidadMin.Checked then
|
|
begin
|
|
FInforme.ImporteMinimo := DisplayValue;
|
|
FInforme2.ImporteMinimo := DisplayValue;
|
|
end
|
|
else
|
|
begin
|
|
FInforme.ImporteMinimo := NULL;
|
|
FInforme2.ImporteMinimo := NULL;
|
|
end;
|
|
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.NombreCliIniPropertiesButtonClick(
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
begin
|
|
ContenidoModal := TfrClientes.Create(Self);
|
|
if FCodigoClienteAux <> Null then
|
|
begin
|
|
FClienteIni.Codigo := FCodigoClienteAux;
|
|
FClienteIni.ObtenerDatos;
|
|
NombreCliIni.EditingText := FClienteIni.Nombre;
|
|
PostMessage(NombreCliIni.Handle,WM_KEYDOWN,VK_RETURN,0);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.NombreCliIniPropertiesValidate(
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
begin
|
|
if AnsiCompareText(DisplayValue, NombreCliFin.Text) > 0 then
|
|
begin
|
|
ErrorText := msgCliIniMayor;
|
|
Error := True;
|
|
Exit;
|
|
end;
|
|
FClienteIni.Nombre := DisplayValue;
|
|
FClienteIni.Codigo := '';
|
|
FInforme.NombreIni := FClienteIni.Nombre;
|
|
FInforme2.NombreIni := FClienteIni.Nombre;
|
|
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.NombreCliFinPropertiesValidate(
|
|
Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption;
|
|
var Error: Boolean);
|
|
begin
|
|
if AnsiCompareText(DisplayValue, NombreCliIni.Text) < 0 then
|
|
begin
|
|
ErrorText := msgCliIniMayor;
|
|
Error := True;
|
|
Exit;
|
|
end;
|
|
FClienteFin.Nombre := DisplayValue;
|
|
FClienteFin.Codigo := '';
|
|
FInforme.NombreFin := FClienteFin.Nombre;
|
|
FInforme2.NombreFin := FClienteFin.Nombre;
|
|
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.NombreCliFinPropertiesButtonClick(
|
|
Sender: TObject; AButtonIndex: Integer);
|
|
begin
|
|
ContenidoModal := TfrClientes.Create(Self);
|
|
if FCodigoClienteAux <> Null then
|
|
begin
|
|
FClienteFin.Codigo := FCodigoClienteAux;
|
|
FClienteFin.ObtenerDatos;
|
|
NombreCliFin.EditingText := FClienteFin.Nombre;
|
|
PostMessage(NombreCliFin.Handle,WM_KEYDOWN,VK_RETURN,0);
|
|
end;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.rbTrimestreClick(
|
|
Sender: TObject);
|
|
begin
|
|
cbxTrimestres.Enabled := True;
|
|
FechaInicial.Enabled := False;
|
|
FechaFinal.Enabled := False;
|
|
cbxTrimestresPropertiesEditValueChanged(Sender);
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.rbFechasClick(Sender: TObject);
|
|
begin
|
|
cbxTrimestres.Enabled := False;
|
|
FechaInicial.Enabled := True;
|
|
FechaFinal.Enabled := True;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.cbxTrimestresPropertiesEditValueChanged(
|
|
Sender: TObject);
|
|
var
|
|
FCodigoTrimestre : String;
|
|
begin
|
|
FCodigoTrimestre := FListaTrimestres.getCodItem(cbxTrimestres.ItemIndex);
|
|
FechaInicial.Date := dmTablaTrimestres.darFechaIniTrimestre(FCodigoTrimestre);
|
|
FechaFinal.Date := dmTablaTrimestres.darFechaFinTrimestre(FCodigoTrimestre);
|
|
FInforme.FechaFacIni := FechaInicial.Date;
|
|
FInforme.FechaFacFin := FechaFinal.Date;
|
|
FInforme2.FechaFacIni := FechaInicial.Date;
|
|
FInforme2.FechaFacFin := FechaFinal.Date;
|
|
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
end;
|
|
|
|
function TfrHistorialFacturacionClientes.CambiarEntidad(EntidadAnterior, Entidad: TRdxEntidad): Boolean;
|
|
begin
|
|
inherited CambiarEntidad(EntidadAnterior, Entidad);
|
|
ConfigurarFrame(Self, Self.Entidad);
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.cbAgruparPropertiesChange(
|
|
Sender: TObject);
|
|
begin
|
|
Agrupado := not Agrupado;
|
|
end;
|
|
|
|
procedure TfrHistorialFacturacionClientes.SetAgrupado(const Value: Boolean);
|
|
begin
|
|
FAgrupado := Value;
|
|
if Agrupado then
|
|
FInforme.Previsualizar
|
|
else
|
|
FInforme2.Previsualizar;
|
|
end;
|
|
|
|
end.
|