git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES/trunk@4 3f40d355-893c-4141-8e64-b1d9be72e7e7
140 lines
5.4 KiB
ObjectPascal
140 lines
5.4 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.2
|
|
Fecha versión actual: 04-02-2005
|
|
===============================================================================
|
|
Modificaciones:
|
|
|
|
Fecha Comentarios
|
|
---------------------------------------------------------------------------
|
|
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 InformeHistorialFacturacionClientes;
|
|
|
|
interface
|
|
|
|
uses
|
|
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
|
|
Dialogs, InformeBase, FR_IBXDB, FR_Shape, FR_Class, DB, IBCustomDataSet,
|
|
IBQuery, FR_DSet, FR_DBSet, RdxEmpresaActiva;
|
|
|
|
type
|
|
TdmInformeHistorialFacturacionClientes = class(TdmInformeBase)
|
|
TablaFacturas: TfrDBDataSet;
|
|
TablaFacturasClientes: TIBQuery;
|
|
private
|
|
FImporteMinimo: Variant;
|
|
FNombreIni: String;
|
|
FNombreFin: String;
|
|
FFechaFacFin: TDateTime;
|
|
FFechaFacIni: TDateTime;
|
|
protected
|
|
procedure RellenarCabecera(Band: TfrBand); override;
|
|
procedure PrepararConsultas; override;
|
|
public
|
|
constructor Create(AOwner: TComponent); override;
|
|
published
|
|
property NombreIni : String read FNombreIni write FNombreIni;
|
|
property NombreFin : String read FNombreFin write FNombreFin;
|
|
property ImporteMinimo : Variant read FImporteMinimo write FImporteMinimo;
|
|
property FechaFacIni : TDateTime read FFechaFacIni write FFechaFacIni;
|
|
property FechaFacFin : TDateTime read FFechaFacFin write FFechaFacFin;
|
|
end;
|
|
|
|
var
|
|
dmInformeHistorialFacturacionClientes: TdmInformeHistorialFacturacionClientes;
|
|
|
|
implementation
|
|
|
|
{$R *.dfm}
|
|
|
|
{ TdmInformeHistorialFacturasClientes }
|
|
|
|
uses
|
|
BaseDatos, StrFunc, TablaEmpresas;
|
|
|
|
constructor TdmInformeHistorialFacturacionClientes.Create(AOwner: TComponent);
|
|
begin
|
|
inherited;
|
|
FNombreInforme := 'HistorialFacturacionClientes.frf';
|
|
end;
|
|
|
|
procedure TdmInformeHistorialFacturacionClientes.PrepararConsultas;
|
|
begin
|
|
inherited;
|
|
with TablaFacturasClientes do
|
|
begin
|
|
Database := FBaseDatos;
|
|
Transaction := FTransaccion;
|
|
SQL.Clear;
|
|
|
|
SQL.Add('select FC.CODIGO, FC.FECHAFACTURA, FC.CODIGOCLIENTE, FC.NOMBRE, FC.NIFCIF,');
|
|
SQL.Add('COALESCE(C.CALLE, FC.CALLE) as CALLE, COALESCE(C.NUMERO, FC.NUMERO) as NUMERO ,');
|
|
SQL.Add('COALESCE(C.CODIGOPOSTAL, FC.CODIGOPOSTAL) as CODIGOPOSTAL, ');
|
|
SQL.Add('COALESCE(C.POBLACION, FC.POBLACION) as POBLACION ,');
|
|
SQL.Add('COALESCE(C.PROVINCIA, FC.PROVINCIA) as PROVINCIA ,');
|
|
SQL.Add('FC.IVA, FC.BASEIMPONIBLE, FC.IMPORTEIVA, FC.IMPORTETOTAL');
|
|
SQL.Add('from FACTURASCLIENTE FC left join sucursalescliente C');
|
|
SQL.Add('on (FC.CODIGOCLIENTE = C.CODIGOCLIENTE) and (C.TIPO = ''P'')');
|
|
SQL.Add('where FC.CODIGOEMPRESA = :CODIGOEMPRESA');
|
|
SQL.Add('and upper(FC.NOMBRE) between upper(:NOMBREINI) and upper(:NOMBREFIN) ');
|
|
SQL.Add('and FC.FECHAFACTURA between :FECHAFACINI and :FECHAFACFIN ');
|
|
if not VarIsNull(FImporteMinimo) then
|
|
SQL.Add('and FC.BASEIMPONIBLE >= :BASEIMPONIBLE ');
|
|
SQL.Add('order by FC.NOMBRE, FC.FECHAFACTURA');
|
|
ParamByName('CODIGOEMPRESA').AsInteger := EmpresaActiva.Codigo;
|
|
ParamByName('NOMBREINI').AsString := FNombreIni;
|
|
ParamByName('NOMBREFIN').AsString := FNombreFin;
|
|
ParamByName('FECHAFACINI').AsDateTime := FFechaFacIni;
|
|
ParamByName('FECHAFACFIN').AsDateTime := FFechaFacFin;
|
|
if not VarIsNull(FImporteMinimo) then
|
|
ParamByName('BASEIMPONIBLE').AsFloat := FImporteMinimo;
|
|
Prepare;
|
|
end;
|
|
end;
|
|
|
|
procedure TdmInformeHistorialFacturacionClientes.RellenarCabecera(
|
|
Band: TfrBand);
|
|
var
|
|
iCont : Integer;
|
|
Objeto : TfrView;
|
|
begin
|
|
inherited;
|
|
with Band do
|
|
begin
|
|
for iCont := 0 to Objects.Count - 1 do
|
|
begin
|
|
Objeto := Objects[iCont];
|
|
if ((Objeto is TfrMemoView) and (Objeto.Name = 'CabParametros')) then
|
|
begin
|
|
with (Objeto as TfrMemoView) do
|
|
begin
|
|
Memo.Clear;
|
|
Memo.Add('Empresa: ' + EmpresaActiva.NombreComercial);
|
|
Memo.Add('Rango de fechas: ' + DateToStr(FFechaFacIni) + ' - ' + DateToStr(FFechaFacFin));
|
|
Memo.Add('Rango de clientes: ' + FNombreIni + ' - ' + FNombreFin);
|
|
if not VarIsNull(FImporteMinimo) then
|
|
Memo.Add('Importe de facturas mínimo: ' + FormatFloat('#,##0.00', FImporteMinimo) + ' €');
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
end.
|