Informes de recibos de cliente adaptados al resumen

git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@889 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
roberto 2009-01-27 16:59:50 +00:00
parent 1dd65983d3
commit 04f1da12de
10 changed files with 1073 additions and 355 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@ object RptRecibosCliente: TRptRecibosCliente
OldCreateOrder = True
OnCreate = DataModuleCreate
Height = 405
Width = 654
Width = 892
object DADataCabecera: TDADataSource
DataSet = tbl_Cabecera.Dataset
DataTable = tbl_Cabecera
@ -206,7 +206,7 @@ object RptRecibosCliente: TRptRecibosCliente
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
LocalSchema = schReport
LocalDataStreamer = DABINAdapter
LocalDataStreamer = Bin2DataStreamer
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
LogicalName = 'Informe_Cabecera'
@ -214,10 +214,6 @@ object RptRecibosCliente: TRptRecibosCliente
Left = 264
Top = 128
end
object DABINAdapter: TDABINAdapter
Left = 48
Top = 80
end
object frxRichObject1: TfrxRichObject
Left = 48
Top = 296
@ -283,9 +279,11 @@ object RptRecibosCliente: TRptRecibosCliente
'iento)'#10'when extract (month from fecha_vencimiento) = 12 then '#39'DI' +
'CIEMBRE - '#39' || extract (year from fecha_vencimiento)'#10'end as TITU' +
'LO,'#10'REFERENCIA, ID_CLIENTE, NOMBRE_CLIENTE, SITUACION, NIF_CIF_' +
'CLIENTE, fecha_vencimiento, FECHA_EMISION,'#10'IMPORTE_TOTAL'#10#10'from V' +
'_recibos_cliente'#10'where {where}'#10'order by ANO, MES, FECHA_VENCIMIE' +
'NTO, NOMBRE_CLIENTE'#10#10
'CLIENTE, fecha_vencimiento, FECHA_EMISION,'#10'IMPORTE_TOTAL,'#10'case'#10'w' +
'hen strlen(DATOS_BANCARIOS) = 0 then '#39'Sin cuenta bancaria'#39#10'else ' +
'DATOS_BANCARIOS'#10'end as DATOS_BANCARIOS'#10#10'from V_recibos_cliente'#10'w' +
'here {where}'#10'order by ANO, MES, FECHA_VENCIMIENTO, NOMBRE_CLIENT' +
'E'#10#10
StatementType = stSQL
ColumnMappings = <
item
@ -335,9 +333,13 @@ object RptRecibosCliente: TRptRecibosCliente
item
DatasetField = 'ANO'
TableField = 'ANO'
end
item
DatasetField = 'DATOS_BANCARIOS'
TableField = 'DATOS_BANCARIOS'
end>
end>
Name = 'InformeListadoRecibos'
Name = 'InformeListadoRecibosPendientes'
Fields = <
item
Name = 'ID_EMPRESA'
@ -391,6 +393,11 @@ object RptRecibosCliente: TRptRecibosCliente
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end
item
Name = 'DATOS_BANCARIOS'
DataType = datString
Size = 255
end>
end
item
@ -853,6 +860,309 @@ object RptRecibosCliente: TRptRecibosCliente
Name = 'LOGOTIPO'
DataType = datBlob
end>
end
item
Params = <>
Statements = <
item
Connection = 'IBX'
TargetTable = 'V_recibos_cliente'
SQL =
'select ID_EMPRESA,'#10'extract (year from fecha_vencimiento) as ANO,' +
#10'extract (month from fecha_vencimiento) as MES,'#10'case'#10'when extrac' +
't (month from fecha_vencimiento) = 1 then '#39'ENERO - '#39' || extract ' +
'(year from fecha_vencimiento)'#10'when extract (month from fecha_ven' +
'cimiento) = 2 then '#39'FEBRERO - '#39' || extract (year from fecha_venc' +
'imiento)'#10'when extract (month from fecha_vencimiento) = 3 then '#39'M' +
'ARZO - '#39' || extract (year from fecha_vencimiento)'#10'when extract (' +
'month from fecha_vencimiento) = 4 then '#39'ABRIL - '#39' || extract (ye' +
'ar from fecha_vencimiento)'#10'when extract (month from fecha_vencim' +
'iento) = 5 then '#39'MAYO - '#39' || extract (year from fecha_vencimient' +
'o)'#10'when extract (month from fecha_vencimiento) = 6 then '#39'JUNIO -' +
' '#39' || extract (year from fecha_vencimiento)'#10'when extract (month ' +
'from fecha_vencimiento) = 7 then '#39'JULIO - '#39' || extract (year fro' +
'm fecha_vencimiento)'#10'when extract (month from fecha_vencimiento)' +
' = 8 then '#39'AGOSTO - '#39' || extract (year from fecha_vencimiento)'#10'w' +
'hen extract (month from fecha_vencimiento) = 9 then '#39'SEPTIEMBRE ' +
'- '#39' || extract (year from fecha_vencimiento)'#10'when extract (month' +
' from fecha_vencimiento) = 10 then '#39'OCTUBRE - '#39' || extract (year' +
' from fecha_vencimiento)'#10'when extract (month from fecha_vencimie' +
'nto) = 11 then '#39'NOVIEMBRE - '#39' || extract (year from fecha_vencim' +
'iento)'#10'when extract (month from fecha_vencimiento) = 12 then '#39'DI' +
'CIEMBRE - '#39' || extract (year from fecha_vencimiento)'#10'end as TITU' +
'LO,'#10'case'#10'when strlen(DATOS_BANCARIOS) = 0 then '#39'Sin cuenta banca' +
'ria'#39#10'else DATOS_BANCARIOS'#10'end as DATOS_BANCARIOS,'#10'sum(IMPORTE_TO' +
'TAL) as Importe_total'#10#10'from V_recibos_cliente'#10'group by 1,2,3,4,5' +
#10'order by 1,2,3,4,5'#10#10
StatementType = stSQL
ColumnMappings = <
item
DatasetField = 'ID_EMPRESA'
TableField = 'ID_EMPRESA'
end
item
DatasetField = 'ANO'
TableField = 'ANO'
end
item
DatasetField = 'MES'
TableField = 'MES'
end
item
DatasetField = 'TITULO'
TableField = 'TITULO'
end
item
DatasetField = 'IMPORTE_TOTAL'
TableField = 'IMPORTE_TOTAL'
end
item
DatasetField = 'DATOS_BANCARIOS'
TableField = 'DATOS_BANCARIOS'
end>
end>
Name = 'InformeListadoRecibosPendientesResumen'
Fields = <
item
Name = 'ID_EMPRESA'
DataType = datInteger
end
item
Name = 'ANO'
DataType = datSmallInt
end
item
Name = 'MES'
DataType = datSmallInt
end
item
Name = 'TITULO'
DataType = datString
Size = 19
end
item
Name = 'DATOS_BANCARIOS'
DataType = datString
Size = 255
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end>
end
item
Params = <>
Statements = <
item
Connection = 'IBX'
TargetTable = 'V_recibos_cliente'
SQL =
'select ID_EMPRESA,'#10'extract (year from fecha_emision) as ANO,'#10'ext' +
'ract (month from fecha_emision) as MES,'#10'case'#10'when extract (month' +
' from fecha_emision) = 1 then '#39'ENERO - '#39' || extract (year from f' +
'echa_emision)'#10'when extract (month from fecha_emision) = 2 then '#39 +
'FEBRERO - '#39' || extract (year from fecha_emision)'#10'when extract (m' +
'onth from fecha_emision) = 3 then '#39'MARZO - '#39' || extract (year fr' +
'om fecha_emision)'#10'when extract (month from fecha_emision) = 4 th' +
'en '#39'ABRIL - '#39' || extract (year from fecha_emision)'#10'when extract ' +
'(month from fecha_emision) = 5 then '#39'MAYO - '#39' || extract (year f' +
'rom fecha_emision)'#10'when extract (month from fecha_emision) = 6 t' +
'hen '#39'JUNIO - '#39' || extract (year from fecha_emision)'#10'when extract' +
' (month from fecha_emision) = 7 then '#39'JULIO - '#39' || extract (year' +
' from fecha_emision)'#10'when extract (month from fecha_emision) = 8' +
' then '#39'AGOSTO - '#39' || extract (year from fecha_emision)'#10'when extr' +
'act (month from fecha_emision) = 9 then '#39'SEPTIEMBRE - '#39' || extra' +
'ct (year from fecha_emision)'#10'when extract (month from fecha_emis' +
'ion) = 10 then '#39'OCTUBRE - '#39' || extract (year from fecha_emision)' +
#10'when extract (month from fecha_emision) = 11 then '#39'NOVIEMBRE - ' +
#39' || extract (year from fecha_emision)'#10'when extract (month from ' +
'fecha_emision) = 12 then '#39'DICIEMBRE - '#39' || extract (year from fe' +
'cha_emision)'#10'end as TITULO,'#10'REFERENCIA, ID_CLIENTE, NOMBRE_CLIE' +
'NTE, SITUACION, NIF_CIF_CLIENTE, fecha_emision, FECHA_VENCIMIENT' +
'O,'#10'IMPORTE_TOTAL'#10#10'from V_recibos_cliente'#10'where {where}'#10'order by ' +
'ANO, MES, fecha_emision, NOMBRE_CLIENTE'#10#10
StatementType = stSQL
ColumnMappings = <
item
DatasetField = 'ID_EMPRESA'
TableField = 'ID_EMPRESA'
end
item
DatasetField = 'ANO'
TableField = 'ANO'
end
item
DatasetField = 'MES'
TableField = 'MES'
end
item
DatasetField = 'TITULO'
TableField = 'TITULO'
end
item
DatasetField = 'REFERENCIA'
TableField = 'REFERENCIA'
end
item
DatasetField = 'ID_CLIENTE'
TableField = 'ID_CLIENTE'
end
item
DatasetField = 'NOMBRE_CLIENTE'
TableField = 'NOMBRE_CLIENTE'
end
item
DatasetField = 'SITUACION'
TableField = 'SITUACION'
end
item
DatasetField = 'NIF_CIF_CLIENTE'
TableField = 'NIF_CIF_CLIENTE'
end
item
DatasetField = 'FECHA_EMISION'
TableField = 'FECHA_EMISION'
end
item
DatasetField = 'FECHA_VENCIMIENTO'
TableField = 'FECHA_VENCIMIENTO'
end
item
DatasetField = 'IMPORTE_TOTAL'
TableField = 'IMPORTE_TOTAL'
end>
end>
Name = 'InformeListadoRecibos'
Fields = <
item
Name = 'ID_EMPRESA'
DataType = datInteger
end
item
Name = 'ANO'
DataType = datSmallInt
end
item
Name = 'MES'
DataType = datSmallInt
end
item
Name = 'TITULO'
DataType = datString
Size = 19
end
item
Name = 'REFERENCIA'
DataType = datString
Size = 255
end
item
Name = 'ID_CLIENTE'
DataType = datInteger
end
item
Name = 'NOMBRE_CLIENTE'
DataType = datString
Size = 255
end
item
Name = 'SITUACION'
DataType = datString
Size = 9
end
item
Name = 'NIF_CIF_CLIENTE'
DataType = datString
Size = 15
end
item
Name = 'FECHA_EMISION'
DataType = datDateTime
end
item
Name = 'FECHA_VENCIMIENTO'
DataType = datDateTime
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end>
end
item
Params = <>
Statements = <
item
Connection = 'IBX'
TargetTable = 'V_recibos_cliente'
SQL =
'select ID_EMPRESA,'#10'extract (year from fecha_emision) as ANO,'#10'ext' +
'ract (month from fecha_emision) as MES,'#10'case'#10'when extract (month' +
' from fecha_emision) = 1 then '#39'ENERO - '#39' || extract (year from f' +
'echa_emision)'#10'when extract (month from fecha_emision) = 2 then '#39 +
'FEBRERO - '#39' || extract (year from fecha_emision)'#10'when extract (m' +
'onth from fecha_emision) = 3 then '#39'MARZO - '#39' || extract (year fr' +
'om fecha_emision)'#10'when extract (month from fecha_emision) = 4 th' +
'en '#39'ABRIL - '#39' || extract (year from fecha_emision)'#10'when extract ' +
'(month from fecha_emision) = 5 then '#39'MAYO - '#39' || extract (year f' +
'rom fecha_emision)'#10'when extract (month from fecha_emision) = 6 t' +
'hen '#39'JUNIO - '#39' || extract (year from fecha_emision)'#10'when extract' +
' (month from fecha_emision) = 7 then '#39'JULIO - '#39' || extract (year' +
' from fecha_emision)'#10'when extract (month from fecha_emision) = 8' +
' then '#39'AGOSTO - '#39' || extract (year from fecha_emision)'#10'when extr' +
'act (month from fecha_emision) = 9 then '#39'SEPTIEMBRE - '#39' || extra' +
'ct (year from fecha_emision)'#10'when extract (month from fecha_emis' +
'ion) = 10 then '#39'OCTUBRE - '#39' || extract (year from fecha_emision)' +
#10'when extract (month from fecha_emision) = 11 then '#39'NOVIEMBRE - ' +
#39' || extract (year from fecha_emision)'#10'when extract (month from ' +
'fecha_emision) = 12 then '#39'DICIEMBRE - '#39' || extract (year from fe' +
'cha_emision)'#10'end as TITULO,'#10'sum(IMPORTE_TOTAL) as importe_total'#10 +
#10'from V_recibos_cliente'#10'group by 1,2,3,4'#10'order by 1,2,3,4'#10
StatementType = stSQL
ColumnMappings = <
item
DatasetField = 'ID_EMPRESA'
TableField = 'ID_EMPRESA'
end
item
DatasetField = 'ANO'
TableField = 'ANO'
end
item
DatasetField = 'MES'
TableField = 'MES'
end
item
DatasetField = 'TITULO'
TableField = 'TITULO'
end
item
DatasetField = 'IMPORTE_TOTAL'
TableField = 'IMPORTE_TOTAL'
end>
end>
Name = 'InformeListadoRecibosResumen'
Fields = <
item
Name = 'ID_EMPRESA'
DataType = datInteger
end
item
Name = 'ANO'
DataType = datSmallInt
end
item
Name = 'MES'
DataType = datSmallInt
end
item
Name = 'TITULO'
DataType = datString
Size = 19
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end>
end>
JoinDataTables = <>
UnionDataTables = <>
@ -878,7 +1188,7 @@ object RptRecibosCliente: TRptRecibosCliente
PrintOptions.Printer = 'Por defecto'
PrintOptions.PrintOnSheet = 0
ReportOptions.CreateDate = 37800.807714351900000000
ReportOptions.LastChange = 39741.852018379630000000
ReportOptions.LastChange = 39840.717636527780000000
ScriptLanguage = 'PascalScript'
ScriptText.Strings = (
'procedure frxReportOnStartReport(Sender: TfrxComponent);'
@ -975,7 +1285,7 @@ object RptRecibosCliente: TRptRecibosCliente
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
LocalSchema = schReport
LocalDataStreamer = DABINAdapter
LocalDataStreamer = Bin2DataStreamer
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
LogicalName = 'Informe_Compensados'
@ -1040,7 +1350,7 @@ object RptRecibosCliente: TRptRecibosCliente
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
LocalSchema = schReport
LocalDataStreamer = DABINAdapter
LocalDataStreamer = Bin2DataStreamer
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
LogicalName = 'InformeListadoRecibos'
@ -1061,4 +1371,149 @@ object RptRecibosCliente: TRptRecibosCliente
Left = 496
Top = 16
end
object Bin2DataStreamer: TDABin2DataStreamer
Left = 48
Top = 88
end
object frxDBInformeListadoRecibosResumen: TfrxDBDataset
UserName = 'frxDBInformeListadoRecibosResumen'
CloseDataSource = True
DataSource = DADSInformeListadoRecibosResumen
Left = 504
Top = 192
end
object DADSInformeListadoRecibosResumen: TDADataSource
DataSet = tbl_InformeListadoRecibosResumen.Dataset
DataTable = tbl_InformeListadoRecibosResumen
Left = 504
Top = 248
end
object tbl_InformeListadoRecibosResumen: TDAMemDataTable
RemoteUpdatesOptions = []
Fields = <>
Params = <>
MasterMappingMode = mmDataRequest
LogChanges = False
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
IndexDefs = <>
Left = 504
Top = 304
end
object frxDBInformeListadoRecibosPendientes: TfrxDBDataset
UserName = 'frxDBInformeListadoRecibosPendientes'
CloseDataSource = True
DataSource = DADSInformeListadoRecibosPendientes
Left = 704
Top = 16
end
object DADSInformeListadoRecibosPendientes: TDADataSource
DataSet = tbl_InformeListadoRecibosPendientes.Dataset
DataTable = tbl_InformeListadoRecibosPendientes
Left = 704
Top = 72
end
object tbl_InformeListadoRecibosPendientes: TDAMemDataTable
RemoteUpdatesOptions = []
Fields = <
item
Name = 'ID_EMPRESA'
DataType = datInteger
end
item
Name = 'ANO'
DataType = datSmallInt
end
item
Name = 'MES'
DataType = datSmallInt
end
item
Name = 'TITULO'
DataType = datString
Size = 19
end
item
Name = 'REFERENCIA'
DataType = datString
Size = 255
end
item
Name = 'ID_CLIENTE'
DataType = datInteger
end
item
Name = 'NOMBRE_CLIENTE'
DataType = datString
Size = 255
end
item
Name = 'SITUACION'
DataType = datString
Size = 9
end
item
Name = 'NIF_CIF_CLIENTE'
DataType = datString
Size = 15
end
item
Name = 'FECHA_VENCIMIENTO'
DataType = datDateTime
end
item
Name = 'FECHA_EMISION'
DataType = datDateTime
end
item
Name = 'IMPORTE_TOTAL'
DataType = datCurrency
end
item
Name = 'DATOS_BANCARIOS'
DataType = datString
Size = 255
end>
Params = <>
LogChanges = False
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
LocalSchema = schReport
LocalDataStreamer = Bin2DataStreamer
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
LogicalName = 'InformeListadoRecibosPendientes'
IndexDefs = <>
Left = 704
Top = 128
end
object frxDBInformeListadoRecibosPendResumen: TfrxDBDataset
UserName = 'frxDBInformeListadoRecibosPendResumen'
CloseDataSource = True
DataSource = DADSInformeListadoRecibosPendResumen
Left = 704
Top = 192
end
object DADSInformeListadoRecibosPendResumen: TDADataSource
DataSet = tbl_InformeListadoRecibosPendResumen.Dataset
DataTable = tbl_InformeListadoRecibosPendResumen
Left = 704
Top = 248
end
object tbl_InformeListadoRecibosPendResumen: TDAMemDataTable
RemoteUpdatesOptions = []
Fields = <>
Params = <>
MasterMappingMode = mmDataRequest
LogChanges = False
StreamingOptions = [soDisableEventsWhileStreaming]
RemoteFetchEnabled = False
DetailOptions = [dtCascadeOpenClose, dtCascadeApplyUpdates, dtAutoFetch, dtCascadeDelete, dtCascadeUpdate, dtDisableLogOfCascadeDeletes, dtDisableLogOfCascadeUpdates, dtIncludeInAllInOneFetch]
MasterOptions = [moCascadeOpenClose, moCascadeApplyUpdates, moCascadeDelete, moCascadeUpdate, moDisableLogOfCascadeDeletes, moDisableLogOfCascadeUpdates]
IndexDefs = <>
Left = 704
Top = 304
end
end

View File

@ -7,13 +7,12 @@ uses
Dialogs, frxClass, frxDBSet, uDAScriptingProvider,
uDADataTable, uDAMemDataTable, DB, uDAClasses, frxChart, frxGradient,
frxChBox, frxCross, frxOLE, frxBarcode, frxRich, uDABINAdapter, uROTypes,
uDAInterfaces, uDADataStreamer, FactuGES_Intf;
uDAInterfaces, uDADataStreamer, FactuGES_Intf, uDABin2DataStreamer;
type
TRptRecibosCliente = class(TDataModule)
DADataCabecera: TDADataSource;
tbl_Cabecera: TDAMemDataTable;
DABINAdapter: TDABINAdapter;
frxRichObject1: TfrxRichObject;
frxBarCodeObject1: TfrxBarCodeObject;
frxOLEObject1: TfrxOLEObject;
@ -29,13 +28,34 @@ type
tbl_InformeListadoRecibos: TDAMemDataTable;
DADSInformeListadoRecibos: TDADataSource;
frxDBInformeListadoRecibos: TfrxDBDataset;
Bin2DataStreamer: TDABin2DataStreamer;
frxDBInformeListadoRecibosResumen: TfrxDBDataset;
DADSInformeListadoRecibosResumen: TDADataSource;
tbl_InformeListadoRecibosResumen: TDAMemDataTable;
frxDBInformeListadoRecibosPendientes: TfrxDBDataset;
DADSInformeListadoRecibosPendientes: TDADataSource;
tbl_InformeListadoRecibosPendientes: TDAMemDataTable;
frxDBInformeListadoRecibosPendResumen: TfrxDBDataset;
DADSInformeListadoRecibosPendResumen: TDADataSource;
tbl_InformeListadoRecibosPendResumen: TDAMemDataTable;
schReport: TDASchema;
DataDictionary: TDADataDictionary;
procedure DataModuleCreate(Sender: TObject);
private
FConnection: IDAConnection;
FIdEmpresa: Integer;
FFechaInicio: Variant;
FFechaFin: Variant;
FFechaVenInicio: Variant;
FFechaVenFin: Variant;
FListaIDClientes: TIntegerArray;
FImporteMinimo: Currency;
procedure _GenerarRecibo(const ID : Integer);
function _GenerarInforme(const TipoInforme: String; const IdEmpresa: Integer; const FechaInicio, FechaFin: Variant; const FechaVenInicio: Variant; FechaVenFin: Variant; const ListaIDClientes: TIntegerArray; const ImporteMinimo: Currency): Binary;
procedure PrepararTablaInforme(ATabla: TDAMemDataTable);
procedure PrepararTablaResumenInforme(ATabla: IDADataset);
function _GenerarInforme(const TipoInforme: String): Binary;
public
function GenerarRecibo(const ListaID : TIntegerArray): Binary;
@ -49,7 +69,7 @@ implementation
{$R *.dfm}
uses
uSistemaFunc, uDataModuleServer, schRecibosClienteClient_Intf;
uSistemaFunc, StrUtils, uDataModuleServer, schRecibosClienteClient_Intf;
const
rptInforme = 'InfReciboCliente.fr3';
@ -61,6 +81,9 @@ const
{ Dataset names for schReport }
ds_InformeCabecera = 'Informe_Cabecera';
ds_InformeCompensados = 'Informe_Compensados';
ds_InformeListadoRecibosResumen = 'InformeListadoRecibosResumen';
ds_InformeListadoRecibosPendientesResumen = 'InformeListadoRecibosPendientesResumen';
{ TRptReciboCliente }
@ -89,6 +112,137 @@ begin
end;
end;
procedure TRptRecibosCliente.PrepararTablaInforme(ATabla: TDAMemDataTable);
var
Condicion: TDAWhereExpression;
i: Integer;
begin
// Filtrar el informe por empresa
with ATabla.DynamicWhere do
begin
// (ID_EMPRESA >= ID)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteID_EMPRESA), NewConstant(FIdEmpresa, datInteger), dboEqual);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
// Filtrar el informe por fechas
if not VarIsNull(FFechaInicio)
and not VarIsNull(FFechaFin) then
begin
with ATabla.DynamicWhere do
begin
// (FECHA_INICIO between FECHA_FIN)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_EMISION), NewConstant(FFechaInicio, datDateTime), dboGreaterOrEqual);
Condicion := NewBinaryExpression(NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_EMISION), NewConstant(FFechaFin, datDateTime), dboLessOrEqual), Condicion, dboAnd);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
// Filtrar el informe por fechas de vencimiento
if not VarIsNull(FFechaVenInicio)
and not VarIsNull(FFechaVenFin) then
begin
with ATabla.DynamicWhere do
begin
// (FECHA_VENCIMIENTO_INICIO between FECHA_VENCIMIENTO_FIN)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_VENCIMIENTO), NewConstant(FFechaVenInicio, datDateTime), dboGreaterOrEqual);
Condicion := NewBinaryExpression(NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_VENCIMIENTO), NewConstant(FFechaVenFin, datDateTime), dboLessOrEqual), Condicion, dboAnd);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
// Filtrar el informe por proveedor
if Assigned(FListaIDClientes) then
begin
with ATabla.DynamicWhere do
begin
for i := 0 to FListaIDClientes.Count - 1 do
begin
// (ID_PROVEEDOR = ID)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteID_CLIENTE), NewConstant(FListaIDClientes.Items[i], datInteger), dboEqual);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
end;
// Filtrar el informe por importe minimo
if (FImporteMinimo > 0) then
begin
with ATabla.DynamicWhere do
begin
// (IMPORTE_TOTAL > ImporteMinimo)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteIMPORTE_TOTAL), NewConstant(FImporteMinimo, datCurrency), dboGreaterOrEqual);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
end;
procedure TRptRecibosCliente.PrepararTablaResumenInforme(ATabla: IDADataset);
var
i: Integer;
AWhereStr : String;
begin
// Filtrar el informe por empresa
AWhereStr := ' (' + fld_RecibosClienteID_EMPRESA + ' = ' + IntToStr(FIdEmpresa) + ') ';
// Filtrar el informe por fechas
if not VarIsNull(FFechaInicio)
and not VarIsNull(FFechaFin) then
begin
if Length(AWhereStr) > 0 then
AWhereStr := AWhereStr + 'AND';
AWhereStr := AWhereStr + ' (' + fld_RecibosClienteFECHA_EMISION + ' between ''' + ReplaceStr(VarToStr(FFechaInicio),'/','.') + ''' and ''' + ReplaceStr(VarToStr(FFechaFin),'/','.') + ''') ';
end;
// Filtrar el informe por fechas de vencimiento
if not VarIsNull(FFechaVenInicio)
and not VarIsNull(FFechaVenFin) then
begin
if Length(AWhereStr) > 0 then
AWhereStr := AWhereStr + 'AND';
AWhereStr := AWhereStr + ' (' + fld_RecibosClienteFECHA_VENCIMIENTO + ' between ''' + ReplaceStr(VarToStr(FFechaVenInicio),'/','.') + ''' and ''' + ReplaceStr(VarToStr(FFechaVenFin),'/','.') + ''') ';
end;
// Filtrar el informe por proveedor
if Assigned(FListaIDClientes) then
begin
for i := 0 to FListaIDClientes.Count - 1 do
begin
if Length(AWhereStr) > 0 then
AWhereStr := AWhereStr + 'AND';
AWhereStr := AWhereStr + ' (' + fld_RecibosClienteID_CLIENTE + ' = ' + IntToStr(FListaIDClientes.Items[i]) + ') ';
end;
end;
// Filtrar el informe por importe minimo
if (FImporteMinimo > 0) then
begin
if Length(AWhereStr) > 0 then
AWhereStr := AWhereStr + 'AND';
AWhereStr := AWhereStr + ' (' + fld_RecibosClienteIMPORTE_TOTAL + ' >= ' + CurrToStr(FImporteMinimo) + ') ';
end;
ATabla.Where.AddText(AWhereStr);
end;
function TRptRecibosCliente.GenerarInformeListadoRecibos(
const IdEmpresa: Integer; const FechaInicio, FechaFin: Variant;
const FechaVenInicio: Variant; FechaVenFin: Variant;
@ -96,15 +250,60 @@ function TRptRecibosCliente.GenerarInformeListadoRecibos(
const ImporteMinimo: Currency): Binary;
var
ATipoInforme: String;
begin
AStream: TMemoryStream;
dsMaster: IDADataset;
//DESGLOSADO POR CLIENTE EN ESTE INFORME NO SE DESGLOSARÁ POR CLIENTE
begin
FConnection.BeginTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
AStream := TMemoryStream.Create;
try
//Inicializamos parametros
FIdEmpresa := IdEmpresa;
FFechaInicio := FechaInicio;
FFechaFin := FechaFin;
FFechaVenInicio := FechaVenInicio;
FFechaVenFin := FechaVenFin;
FImporteMinimo := ImporteMinimo;
if Assigned(FListaIDClientes) then
FListaIDClientes.Free;
FListaIDClientes := ListaIDClientes;
//Se prepara la tabla del listado general del informe
if tbl_InformeListadoRecibos.Active then
tbl_InformeListadoRecibos.Active := False;
PrepararTablaInforme(tbl_InformeListadoRecibos);
//Se prepara la tabla del listado resumen del informe
if tbl_InformeListadoRecibosResumen.Active then
tbl_InformeListadoRecibosResumen.Active := False;
dsMaster := schReport.NewDataset(FConnection, ds_InformeListadoRecibosResumen, [], [], False);
PrepararTablaResumenInforme(dsMaster);
// Filtrar el informe por situacion
//Esto se hace para rellenar la tabla del datamodule que usa el informe.
dsMaster.Open;
AStream.Clear;
Bin2DataStreamer.WriteDataset(AStream, dsMaster, [woRows, woSchema], -1);
Bin2DataStreamer.ReadDataset(AStream, tbl_InformeListadoRecibosResumen, TRUE, '', TRUE, TRUE);
//DESGLOSADO POR CLIENTE EN ESTE INFORME NO SE DESGLOSARÁ POR CLIENTE
if Desglosado then
ATipoInforme := rptInformeListadoRecibosClienteDesglosado
else
ATipoInforme := rptInformeListadoRecibosCliente;
Result := _GenerarInforme(ATipoInforme, IdEmpresa, FechaInicio, FechaFin, FechaVenInicio, FechaVenFin, ListaIDClientes, ImporteMinimo);
//Finalmente se abren las tablas del informe
tbl_InformeListadoRecibos.Active := True;
tbl_InformeListadoRecibosResumen.Active := True;
Result := _GenerarInforme(ATipoInforme);
finally
AStream.Free;
dsMaster := Nil;
FConnection.RollbackTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
end;
end;
function TRptRecibosCliente.GenerarInformeListadoRecibosPendientes(
@ -115,13 +314,33 @@ function TRptRecibosCliente.GenerarInformeListadoRecibosPendientes(
var
Condicion: TDAWhereExpression;
ATipoInforme: String;
AStream: TMemoryStream;
dsMaster: IDADataset;
begin
if tbl_InformeListadoRecibos.Active then
tbl_InformeListadoRecibos.Active := False;
FConnection.BeginTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
AStream := TMemoryStream.Create;
try
//Inicializamos parametros
FIdEmpresa := IdEmpresa;
FFechaInicio := FechaInicio;
FFechaFin := FechaFin;
FFechaVenInicio := FechaVenInicio;
FFechaVenFin := FechaVenFin;
FImporteMinimo := ImporteMinimo;
if Assigned(FListaIDClientes) then
FListaIDClientes.Free;
FListaIDClientes := ListaIDClientes;
//Se prepara la tabla del listado general del informe
if tbl_InformeListadoRecibosPendientes.Active then
tbl_InformeListadoRecibosPendientes.Active := False;
PrepararTablaInforme(tbl_InformeListadoRecibosPendientes);
// Filtrar el informe por situacion
with tbl_InformeListadoRecibos.DynamicWhere do
with tbl_InformeListadoRecibosPendientes.DynamicWhere do
begin
// (ID_EMPRESA >= ID)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteSITUACION), NewConstant('COBRADO', datString), dboNotEqual);
@ -131,126 +350,54 @@ begin
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
//Se prepara la tabla del listado resumen del informe
if tbl_InformeListadoRecibosPendResumen.Active then
tbl_InformeListadoRecibosPendResumen.Active := False;
//DESGLOSADO POR CLIENTE EN ESTE INFORME NO SE DESGLOSARÁ POR CLIENTE
dsMaster := schReport.NewDataset(FConnection, ds_InformeListadoRecibosPendientesResumen, [], [], False);
PrepararTablaResumenInforme(dsMaster);
// Filtrar el informe por situacion
dsMaster.Where.AddText(' AND (SITUACION <> ''COBRADO'')');
//Esto se hace para rellenar la tabla del datamodule que usa el informe.
dsMaster.Open;
AStream.Clear;
Bin2DataStreamer.WriteDataset(AStream, dsMaster, [woRows, woSchema], -1);
Bin2DataStreamer.ReadDataset(AStream, tbl_InformeListadoRecibosPendResumen, TRUE, '', TRUE, TRUE);
//DESGLOSADO POR CLIENTE EN ESTE INFORME NO SE DESGLOSARÁ POR CLIENTE
if Desglosado then
ATipoInforme := rptInformeListadoRecibosCliPendientesDesglosado
else
ATipoInforme := rptInformeListadoRecibosCliPendientes;
//Finalmente se abren las tablas del informe
tbl_InformeListadoRecibosPendientes.Active := True;
tbl_InformeListadoRecibosPendResumen.Active := True;
Result := _GenerarInforme(ATipoInforme, IdEmpresa, FechaInicio, FechaFin, FechaVenInicio, FechaVenFin, ListaIDClientes, ImporteMinimo);
Result := _GenerarInforme(ATipoInforme);
finally
AStream.Free;
dsMaster := Nil;
FConnection.RollbackTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
end;
end;
function TRptRecibosCliente._GenerarInforme(const TipoInforme: String;
const IdEmpresa: Integer; const FechaInicio, FechaFin: Variant;
const FechaVenInicio: Variant; FechaVenFin: Variant;
const ListaIDClientes: TIntegerArray; const ImporteMinimo: Currency): Binary;
function TRptRecibosCliente._GenerarInforme(const TipoInforme: String): Binary;
var
Condicion: TDAWhereExpression;
i: Integer;
AInforme: Variant;
begin
Result := Binary.Create;
FConnection.BeginTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
AInforme := DarRutaFichero(DarRutaInformes, TipoInforme, IntToStr(FIDEmpresa));
if VarIsNull(AInforme) then
raise Exception.Create (('Error Servidor: _GenerarInforme, no encuentra informe ' + TipoInforme));
try
frxReport.LoadFromFile(AInforme, True);
frxReport.Variables.Variables['FechaInicio'] := FFechaInicio;
frxReport.Variables.Variables['FechaFin'] := FFechaFin;
if tbl_InformeListadoRecibos.Active then
tbl_InformeListadoRecibos.Active := False;
// Filtrar el informe por empresa
with tbl_InformeListadoRecibos.DynamicWhere do
begin
// (ID_EMPRESA >= ID)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteID_EMPRESA), NewConstant(IdEmpresa, datInteger), dboEqual);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
// Filtrar el informe por fechas
if not VarIsNull(FechaInicio)
and not VarIsNull(FechaFin) then
begin
with tbl_InformeListadoRecibos.DynamicWhere do
begin
// (FECHA_INICIO between FECHA_FIN)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_EMISION), NewConstant(FechaInicio, datDateTime), dboGreaterOrEqual);
Condicion := NewBinaryExpression(NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_EMISION), NewConstant(FechaFin, datDateTime), dboLessOrEqual), Condicion, dboAnd);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
// Filtrar el informe por fechas de vencimiento
if not VarIsNull(FechaVenInicio)
and not VarIsNull(FechaVenFin) then
begin
with tbl_InformeListadoRecibos.DynamicWhere do
begin
// (FECHA_VENCIMIENTO_INICIO between FECHA_VENCIMIENTO_FIN)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_VENCIMIENTO), NewConstant(FechaVenInicio, datDateTime), dboGreaterOrEqual);
Condicion := NewBinaryExpression(NewBinaryExpression(NewField('', fld_RecibosClienteFECHA_VENCIMIENTO), NewConstant(FechaVenFin, datDateTime), dboLessOrEqual), Condicion, dboAnd);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
// Filtrar el informe por cliente
if Assigned(ListaIDClientes) then
begin
with tbl_InformeListadoRecibos.DynamicWhere do
begin
for i := 0 to ListaIDClientes.Count - 1 do
begin
// (ID_CLIENTE = ID)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteID_CLIENTE), NewConstant(ListaIDClientes.Items[i], datInteger), dboEqual);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
end;
// Filtrar el informe por importe minimo
if (ImporteMinimo > 0) then
begin
with tbl_InformeListadoRecibos.DynamicWhere do
begin
// (IMPORTE_TOTAL > ImporteMinimo)
Condicion := NewBinaryExpression(NewField('', fld_RecibosClienteIMPORTE_TOTAL), NewConstant(ImporteMinimo, datCurrency), dboGreaterOrEqual);
if IsEmpty then
Expression := Condicion
else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end;
end;
tbl_InformeListadoRecibos.Active := True;
AInforme := DarRutaFichero(DarRutaInformes, TipoInforme, IntToStr(IDEmpresa));
if VarIsNull(AInforme) then
raise Exception.Create (('Error Servidor: _GenerarInforme, no encuentra informe ' + TipoInforme));
frxReport.LoadFromFile(AInforme, True);
frxReport.Variables.Variables['FechaInicio'] := FechaInicio;
frxReport.Variables.Variables['FechaFin'] := FechaFin;
frxReport.PrepareReport(False);
frxReport.PreviewPages.SaveToStream(Result);
finally
FConnection.RollbackTransaction; //<--- Creo que no va a hacer falta. "PUES SI ES NECESARIO"
end;
frxReport.PrepareReport(False);
frxReport.PreviewPages.SaveToStream(Result);
end;
procedure TRptRecibosCliente._GenerarRecibo(const ID: Integer);