From 3310838d465876fecddefd2375b04a22600f20e3 Mon Sep 17 00:00:00 2001 From: roberto Date: Wed, 15 Sep 2010 16:42:46 +0000 Subject: [PATCH] Repaso de releaciones entre modulos git-svn-id: https://192.168.0.254/svn/Proyectos.LuisLeon_FactuGES2/trunk@60 b2cfbe5a-eba1-4a0c-8b32-7feea0a119f2 --- .../Articulos/Data/uDataModuleArticulos.pas | 3 +- .../Comisiones/Comisiones_Group.groupproj | 26 +- .../Controller/uComisionesController.pas | 119 ++- .../uComisionesReportController.pas | 34 +- .../Comisiones/Data/uDataModuleComisiones.dfm | 16 +- .../Model/schComisionesClient_Intf.pas | 60 +- .../Model/schComisionesServer_Intf.pas | 52 +- .../Comisiones/Model/uBizComisiones.pas | 4 - .../Comisiones/Model/uBizComisionesServer.pas | 130 ++- .../Reports/uRptComisiones_Server.dfm | 935 ++++++++++++++++++ .../Reports/uRptComisiones_Server.pas | 146 +++ .../Servidor/srvComisiones_Impl.dfm | 33 +- .../Servidor/srvComisiones_Impl.pas | 14 +- .../Comisiones/Views/Comisiones_view.dpk | 55 +- .../Comisiones/Views/Comisiones_view.dproj | 116 ++- .../Views/uComisionesViewRegister.pas | 12 +- .../Comisiones/Views/uEditorComision.dfm | 287 ++++-- .../Comisiones/Views/uEditorComision.pas | 14 +- .../Views/uEditorComisionesReport.dfm | 9 +- .../Views/uEditorComisionesReport.pas | 3 +- .../Comisiones/Views/uViewComision.dfm | 9 +- .../Comisiones/Views/uViewComision.pas | 36 +- .../Comisiones/Views/uViewComisiones.dfm | 12 + .../Comisiones/Views/uViewComisiones.pas | 1 + .../Views/uViewFacturasComision.dfm | 11 +- .../Views/uViewFacturasComision.pas | 2 +- .../Controller/uFacturasClienteController.pas | 1 + .../Servidor/srvFacturasProveedor_Impl.dfm | 18 +- .../Views/uEditorFacturasProveedor.dfm | 5 +- 29 files changed, 1778 insertions(+), 385 deletions(-) create mode 100644 Source/Modulos/Comisiones/Reports/uRptComisiones_Server.dfm create mode 100644 Source/Modulos/Comisiones/Reports/uRptComisiones_Server.pas diff --git a/Source/Modulos/Articulos/Data/uDataModuleArticulos.pas b/Source/Modulos/Articulos/Data/uDataModuleArticulos.pas index 8778cc1..afb42d6 100644 --- a/Source/Modulos/Articulos/Data/uDataModuleArticulos.pas +++ b/Source/Modulos/Articulos/Data/uDataModuleArticulos.pas @@ -141,7 +141,8 @@ begin try case Tipo of txArticulo: AArticulo := CloneDataTable(tbl_Articulos); - txProveedor: AArticulo := CloneDataTable(tbl_ArticulosParaCompra); +// txProveedor: AArticulo := CloneDataTable(tbl_ArticulosParaCompra); En el caso de tener varios proveedores para un mismo artículo + txProveedor: AArticulo := CloneDataTable(tbl_Articulos); end; AsignarClaseNegocio(AArticulo); diff --git a/Source/Modulos/Comisiones/Comisiones_Group.groupproj b/Source/Modulos/Comisiones/Comisiones_Group.groupproj index d3ba661..c6159d4 100644 --- a/Source/Modulos/Comisiones/Comisiones_Group.groupproj +++ b/Source/Modulos/Comisiones/Comisiones_Group.groupproj @@ -9,6 +9,8 @@ + + @@ -111,14 +113,32 @@ + + + + + + + + + + + + + + + + + + - + - + - + \ No newline at end of file diff --git a/Source/Modulos/Comisiones/Controller/uComisionesController.pas b/Source/Modulos/Comisiones/Controller/uComisionesController.pas index 84ffdff..e03544e 100644 --- a/Source/Modulos/Comisiones/Controller/uComisionesController.pas +++ b/Source/Modulos/Comisiones/Controller/uComisionesController.pas @@ -173,42 +173,66 @@ begin end; procedure TComisionesController.AsignarImporteTotal(AComision: IBizComisiones; const ImporteTotal: Variant); +var + AEdicion: Boolean; begin if Assigned(AComision) then begin if (not VarIsNull(ImporteTotal)) and (AComision.DataTable.FieldByName(fld_ComisionesIMPORTE_TOTAL).IsNull or (AComision.IMPORTE_TOTAL <> ImporteTotal)) then begin - AComision.Edit; + AEdicion := AComision.DataTable.Editing; + if not AEdicion then + AComision.Edit; + AComision.IMPORTE_TOTAL := ImporteTotal; AComision.Post; + + if AEdicion then + AComision.Edit; end; end; end; function TComisionesController.BuscarFacturasDesglosadas(AFacturas: IBizFacturaCliente): IBizFacturasComision; var - Cadena: String; + Condicion: TDAWhereExpression; + AArray : Array of TDAWhereExpression; + i: Integer; + begin - if Assigned(AFacturas) then + Result := FDataModule.GetFacturasDesglosadas; + with Result.DataTable.DynamicWhere do begin - with AFacturas.DataTable do + //Solo sacaremos las facturas elegidas y pasadas por parámetro + if Assigned(AFacturas) then begin - if not Active then Active := True; - First; - Cadena := ''; - While not Eof do + with AFacturas.DataTable do begin - if (Length(Cadena) > 0) then - Cadena := Cadena + ', '; - Cadena := Cadena + IntToStr(AFacturas.ID); - Next; + if not Active then Active := True; + SetLength(AArray, AFacturas.DataTable.RecordCount); + First; + i := 0; + While not Eof do + begin + AArray[i] := NewConstant(AFacturas.ID, datInteger); + Next; + Inc(i); + end; end; end; + + Condicion := NewBinaryExpression(NewField('', fld_Facturas_ComisionID_FACTURA), NewList(AArray), dboIn); + + if IsEmpty then + Expression := Condicion + else + Expression := NewBinaryExpression(Expression, Condicion, dboAnd); end; -// Showmessage(Cadena); - Result := FDataModule.GetFacturasDesglosadas; + + +{ with Result.DataTable.Where do begin if NotEmpty then @@ -217,6 +241,7 @@ begin AddText('ID_FACTURA in (' + Cadena + ')'); CloseBraket; end; +} end; function TComisionesController.BuscarTodos: IBizComisiones; @@ -295,25 +320,28 @@ var AEditor : IEditorComision; begin AEditor := NIL; - ShowHourglassCursor; - try -// RecuperarObjetos(ARemesaCliente); - CreateEditor('EditorComision', IEditorComision, AEditor); - with (AEditor as IEditorComision) do - begin - Controller := Self; //OJO ORDEN MUY IMPORTANTE - Comision := AComision; - end; - finally - HideHourglassCursor; - end; + CreateEditor('EditorComision', IEditorComision, AEditor); if Assigned(AEditor) then try - AEditor.ShowModal; - AEditor.Release; + AEditor.Controller := Self; //OJO ORDEN MUY IMPORTANTE + AEditor.Comision := AComision; + + //MODO CONSULTAR +// if not EsModificable(AComision) then +// begin +// SetDataTableReadOnly(AComision.DataTable, True); +// AEditor.ReadOnly := True; +// end; + + AEditor.ShowModal; + + //MODO CONSULTAR (Se deja la tabla como estaba) +// if AEditor.ReadOnly then +// SetDataTableReadOnly(AComision.DataTable, False); finally + AEditor.Release; AEditor := NIL; end; end; @@ -323,24 +351,28 @@ var AEditor : IEditorComisiones; begin AEditor := NIL; - ShowHourglassCursor; - try - CreateEditor('EditorComisiones', IEditorComisiones, AEditor); - with AEditor do - begin - Controller := Self; //OJO ORDEN MUY IMPORTANTE - Comisiones := AComision; - end; - finally - HideHourglassCursor; - end; + CreateEditor('EditorComisiones', IEditorComisiones, AEditor); if Assigned(AEditor) then try - AEditor.ShowEmbedded; +// if not EsCadenaVacia(AWindowCaption) then +// AEditor.WindowCaption := AWindowCaption; + +// if not EsCadenaVacia(AHeaderText) then +// AEditor.HeaderText := AHeaderText; + + AEditor.Controller := Self; //OJO ORDEN MUY IMPORTANTE + AEditor.Comisiones := AComision; +// AEditor.MultiSelect := True; +// if AVerModal then +// AEditor.ShowModal +// else + AEditor.ShowEmbedded; finally - AEditor := NIL; - end; +// if AVerModal then +// AEditor.Release; + AEditor := Nil; + end; end; function TComisionesController.ElegirFacturasComision(AComision: IBizComisiones): Boolean; @@ -380,7 +412,8 @@ begin ShowHourglassCursor; try AFacturasDesglosadas := BuscarFacturasDesglosadas(AFacturasSeleccionadas); - + AFacturasDesglosadas.DataTable.Active := True; + //Copia las facturas desglosadas de las facturas seleccionadas DuplicarRegistros(AFacturasDesglosadas.DataTable, AComision.Facturas.DataTable, mdrTodos, True, True, False); diff --git a/Source/Modulos/Comisiones/Controller/uComisionesReportController.pas b/Source/Modulos/Comisiones/Controller/uComisionesReportController.pas index 3032b1a..b15b2f0 100644 --- a/Source/Modulos/Comisiones/Controller/uComisionesReportController.pas +++ b/Source/Modulos/Comisiones/Controller/uComisionesReportController.pas @@ -65,17 +65,21 @@ begin AStream := FDataModule.GetReport(AComisionID, DesglosadoProv,'', '', Null); try CreateEditor('EditorComisionesPreview', IEditorComisionesPreview, AEditor); - AEditor.DataModule := FDataModule; - AEditor.LoadFromStream(AStream); + if Assigned(AEditor) then + try + AEditor.DataModule := FDataModule; + AEditor.LoadFromStream(AStream); + AEditor.Preview; + finally + AEditor.Release; + end; finally - AStream.Free; + FreeAndNil(AStream); + AEditor := Nil; end; finally HideHourglassCursor; end; - - if Assigned(AEditor) then - AEditor.Preview; end; procedure TComisionesReportController.Print(const AComisionID : Variant; const DesglosadoProv: Boolean); @@ -87,20 +91,24 @@ begin ShowHourglassCursor; try - AStream := FDataModule.GetReport(AComisionID, DesglosadoProv, '', '', Null); + AStream := FDataModule.GetReport(AComisionID, DesglosadoProv,'', '', Null); try CreateEditor('EditorComisionesPreview', IEditorComisionesPreview, AEditor); - AEditor.DataModule := FDataModule; - AEditor.LoadFromStream(AStream); + if Assigned(AEditor) then + try + AEditor.DataModule := FDataModule; + AEditor.LoadFromStream(AStream); + AEditor.Print; + finally + AEditor.Release; + end; finally - AStream.Free; + FreeAndNil(AStream); + AEditor := Nil; end; finally HideHourglassCursor; end; - - if Assigned(AEditor) then - AEditor.Print end; end. diff --git a/Source/Modulos/Comisiones/Data/uDataModuleComisiones.dfm b/Source/Modulos/Comisiones/Data/uDataModuleComisiones.dfm index 21be3fe..c1118ea 100644 --- a/Source/Modulos/Comisiones/Data/uDataModuleComisiones.dfm +++ b/Source/Modulos/Comisiones/Data/uDataModuleComisiones.dfm @@ -1,7 +1,7 @@ inherited DataModuleComisiones: TDataModuleComisiones OnCreate = DAClientDataModuleCreate - Height = 248 - Width = 390 + Height = 251 + Width = 414 object RORemoteService: TRORemoteService Message = dmConexion.ROMessage Channel = dmConexion.ROChannel @@ -79,6 +79,7 @@ inherited DataModuleComisiones: TDataModuleComisiones DataType = datString Size = 255 DisplayLabel = 'Comisiones_NOMBRE' + ServerAutoRefresh = True DictionaryEntry = 'Comisiones_NOMBRE' end> Params = <> @@ -175,15 +176,10 @@ inherited DataModuleComisiones: TDataModuleComisiones end item Name = 'IMPORTE_COMISION' - DataType = datCurrency + DataType = datFloat DictionaryEntry = 'Facturas_Comision_IMPORTE_COMISION' end> - Params = < - item - Name = 'ID_COMISION' - Value = '' - ParamType = daptInput - end> + Params = <> MasterMappingMode = mmWhere StreamingOptions = [soDisableEventsWhileStreaming] RemoteDataAdapter = rda_Comisiones @@ -280,7 +276,7 @@ inherited DataModuleComisiones: TDataModuleComisiones end item Name = 'IMPORTE_COMISION' - DataType = datCurrency + DataType = datFloat DictionaryEntry = 'V_Detalles_Facturas_Comision_IMPORTE_COMISION' end> Params = <> diff --git a/Source/Modulos/Comisiones/Model/schComisionesClient_Intf.pas b/Source/Modulos/Comisiones/Model/schComisionesClient_Intf.pas index 599d9ee..15c6e42 100644 --- a/Source/Modulos/Comisiones/Model/schComisionesClient_Intf.pas +++ b/Source/Modulos/Comisiones/Model/schComisionesClient_Intf.pas @@ -3,15 +3,15 @@ unit schComisionesClient_Intf; interface uses - Classes, DB, SysUtils, uROClasses, uDAInterfaces, uDADataTable, FmtBCD, uROXMLIntf; + Classes, DB, schBase_Intf, SysUtils, uROClasses, uDAInterfaces, uDADataTable, FmtBCD, uROXMLIntf; const { Data table rules ids Feel free to change them to something more human readable but make sure they are unique in the context of your application } - RID_Facturas_Comision = '{69C6A9C2-1439-4AAC-9471-8B3FB42EDFE3}'; - RID_Comisiones = '{81E932F0-7BF0-4C1D-A22F-2FED176FD36A}'; - RID_V_Detalles_Facturas_Comision = '{C60C13FF-26D0-444D-85A3-03DC05AAB574}'; + RID_Facturas_Comision = '{80CF12AA-6D93-492A-BAEF-84156B2B83AE}'; + RID_Comisiones = '{2E6A5B1C-EC92-4E6D-B986-2445F4AC11D4}'; + RID_V_Detalles_Facturas_Comision = '{01AA2110-3187-4E1E-BE6C-6587A5BEF596}'; { Data table names } nme_Facturas_Comision = 'Facturas_Comision'; @@ -111,7 +111,7 @@ const type { IFacturas_Comision } IFacturas_Comision = interface(IDAStronglyTypedDataTable) - ['{C147ECB9-0DAF-46FD-B1F6-007A2D40E218}'] + ['{6DD26EF2-D21F-4324-94B3-11F17FC3A310}'] { Property getters and setters } function GetID_EMPRESAValue: Integer; procedure SetID_EMPRESAValue(const aValue: Integer); @@ -169,8 +169,8 @@ type procedure SetIMPORTE_COMISIONABLEValue(const aValue: Currency); function GetIMPORTE_COMISIONABLEIsNull: Boolean; procedure SetIMPORTE_COMISIONABLEIsNull(const aValue: Boolean); - function GetIMPORTE_COMISIONValue: Currency; - procedure SetIMPORTE_COMISIONValue(const aValue: Currency); + function GetIMPORTE_COMISIONValue: Float; + procedure SetIMPORTE_COMISIONValue(const aValue: Float); function GetIMPORTE_COMISIONIsNull: Boolean; procedure SetIMPORTE_COMISIONIsNull(const aValue: Boolean); @@ -204,12 +204,12 @@ type property COMISIONIsNull: Boolean read GetCOMISIONIsNull write SetCOMISIONIsNull; property IMPORTE_COMISIONABLE: Currency read GetIMPORTE_COMISIONABLEValue write SetIMPORTE_COMISIONABLEValue; property IMPORTE_COMISIONABLEIsNull: Boolean read GetIMPORTE_COMISIONABLEIsNull write SetIMPORTE_COMISIONABLEIsNull; - property IMPORTE_COMISION: Currency read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; + property IMPORTE_COMISION: Float read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; property IMPORTE_COMISIONIsNull: Boolean read GetIMPORTE_COMISIONIsNull write SetIMPORTE_COMISIONIsNull; end; { TFacturas_ComisionDataTableRules } - TFacturas_ComisionDataTableRules = class(TDADataTableRules, IFacturas_Comision) + TFacturas_ComisionDataTableRules = class(TIntfObjectDADataTableRules, IFacturas_Comision) private protected { Property getters and setters } @@ -269,8 +269,8 @@ type procedure SetIMPORTE_COMISIONABLEValue(const aValue: Currency); virtual; function GetIMPORTE_COMISIONABLEIsNull: Boolean; virtual; procedure SetIMPORTE_COMISIONABLEIsNull(const aValue: Boolean); virtual; - function GetIMPORTE_COMISIONValue: Currency; virtual; - procedure SetIMPORTE_COMISIONValue(const aValue: Currency); virtual; + function GetIMPORTE_COMISIONValue: Float; virtual; + procedure SetIMPORTE_COMISIONValue(const aValue: Float); virtual; function GetIMPORTE_COMISIONIsNull: Boolean; virtual; procedure SetIMPORTE_COMISIONIsNull(const aValue: Boolean); virtual; @@ -303,7 +303,7 @@ type property COMISIONIsNull: Boolean read GetCOMISIONIsNull write SetCOMISIONIsNull; property IMPORTE_COMISIONABLE: Currency read GetIMPORTE_COMISIONABLEValue write SetIMPORTE_COMISIONABLEValue; property IMPORTE_COMISIONABLEIsNull: Boolean read GetIMPORTE_COMISIONABLEIsNull write SetIMPORTE_COMISIONABLEIsNull; - property IMPORTE_COMISION: Currency read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; + property IMPORTE_COMISION: Float read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; property IMPORTE_COMISIONIsNull: Boolean read GetIMPORTE_COMISIONIsNull write SetIMPORTE_COMISIONIsNull; public @@ -314,7 +314,7 @@ type { IComisiones } IComisiones = interface(IDAStronglyTypedDataTable) - ['{08412911-08D5-4CB6-BD93-E55E146EB577}'] + ['{72453F7B-858F-4439-A873-81D7B0CAE940}'] { Property getters and setters } function GetIDValue: Integer; procedure SetIDValue(const aValue: Integer); @@ -376,7 +376,7 @@ type end; { TComisionesDataTableRules } - TComisionesDataTableRules = class(TDADataTableRules, IComisiones) + TComisionesDataTableRules = class(TIntfObjectDADataTableRules, IComisiones) private protected { Property getters and setters } @@ -445,7 +445,7 @@ type { IV_Detalles_Facturas_Comision } IV_Detalles_Facturas_Comision = interface(IDAStronglyTypedDataTable) - ['{DF8D0894-2A3B-4713-86FE-C8B816CB3256}'] + ['{8397080E-A3D6-4F0C-B038-85A52551E790}'] { Property getters and setters } function GetID_EMPRESAValue: Integer; procedure SetID_EMPRESAValue(const aValue: Integer); @@ -503,8 +503,8 @@ type procedure SetIMPORTE_COMISIONABLEValue(const aValue: Currency); function GetIMPORTE_COMISIONABLEIsNull: Boolean; procedure SetIMPORTE_COMISIONABLEIsNull(const aValue: Boolean); - function GetIMPORTE_COMISIONValue: Currency; - procedure SetIMPORTE_COMISIONValue(const aValue: Currency); + function GetIMPORTE_COMISIONValue: Float; + procedure SetIMPORTE_COMISIONValue(const aValue: Float); function GetIMPORTE_COMISIONIsNull: Boolean; procedure SetIMPORTE_COMISIONIsNull(const aValue: Boolean); @@ -538,12 +538,12 @@ type property COMISIONIsNull: Boolean read GetCOMISIONIsNull write SetCOMISIONIsNull; property IMPORTE_COMISIONABLE: Currency read GetIMPORTE_COMISIONABLEValue write SetIMPORTE_COMISIONABLEValue; property IMPORTE_COMISIONABLEIsNull: Boolean read GetIMPORTE_COMISIONABLEIsNull write SetIMPORTE_COMISIONABLEIsNull; - property IMPORTE_COMISION: Currency read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; + property IMPORTE_COMISION: Float read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; property IMPORTE_COMISIONIsNull: Boolean read GetIMPORTE_COMISIONIsNull write SetIMPORTE_COMISIONIsNull; end; { TV_Detalles_Facturas_ComisionDataTableRules } - TV_Detalles_Facturas_ComisionDataTableRules = class(TDADataTableRules, IV_Detalles_Facturas_Comision) + TV_Detalles_Facturas_ComisionDataTableRules = class(TIntfObjectDADataTableRules, IV_Detalles_Facturas_Comision) private protected { Property getters and setters } @@ -603,8 +603,8 @@ type procedure SetIMPORTE_COMISIONABLEValue(const aValue: Currency); virtual; function GetIMPORTE_COMISIONABLEIsNull: Boolean; virtual; procedure SetIMPORTE_COMISIONABLEIsNull(const aValue: Boolean); virtual; - function GetIMPORTE_COMISIONValue: Currency; virtual; - procedure SetIMPORTE_COMISIONValue(const aValue: Currency); virtual; + function GetIMPORTE_COMISIONValue: Float; virtual; + procedure SetIMPORTE_COMISIONValue(const aValue: Float); virtual; function GetIMPORTE_COMISIONIsNull: Boolean; virtual; procedure SetIMPORTE_COMISIONIsNull(const aValue: Boolean); virtual; @@ -637,7 +637,7 @@ type property COMISIONIsNull: Boolean read GetCOMISIONIsNull write SetCOMISIONIsNull; property IMPORTE_COMISIONABLE: Currency read GetIMPORTE_COMISIONABLEValue write SetIMPORTE_COMISIONABLEValue; property IMPORTE_COMISIONABLEIsNull: Boolean read GetIMPORTE_COMISIONABLEIsNull write SetIMPORTE_COMISIONABLEIsNull; - property IMPORTE_COMISION: Currency read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; + property IMPORTE_COMISION: Float read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; property IMPORTE_COMISIONIsNull: Boolean read GetIMPORTE_COMISIONIsNull write SetIMPORTE_COMISIONIsNull; public @@ -955,14 +955,14 @@ begin DataTable.Fields[idx_Facturas_ComisionIMPORTE_COMISIONABLE].AsVariant := Null; end; -function TFacturas_ComisionDataTableRules.GetIMPORTE_COMISIONValue: Currency; +function TFacturas_ComisionDataTableRules.GetIMPORTE_COMISIONValue: Float; begin - result := DataTable.Fields[idx_Facturas_ComisionIMPORTE_COMISION].AsCurrency; + result := DataTable.Fields[idx_Facturas_ComisionIMPORTE_COMISION].AsFloat; end; -procedure TFacturas_ComisionDataTableRules.SetIMPORTE_COMISIONValue(const aValue: Currency); +procedure TFacturas_ComisionDataTableRules.SetIMPORTE_COMISIONValue(const aValue: Float); begin - DataTable.Fields[idx_Facturas_ComisionIMPORTE_COMISION].AsCurrency := aValue; + DataTable.Fields[idx_Facturas_ComisionIMPORTE_COMISION].AsFloat := aValue; end; function TFacturas_ComisionDataTableRules.GetIMPORTE_COMISIONIsNull: boolean; @@ -1483,14 +1483,14 @@ begin DataTable.Fields[idx_V_Detalles_Facturas_ComisionIMPORTE_COMISIONABLE].AsVariant := Null; end; -function TV_Detalles_Facturas_ComisionDataTableRules.GetIMPORTE_COMISIONValue: Currency; +function TV_Detalles_Facturas_ComisionDataTableRules.GetIMPORTE_COMISIONValue: Float; begin - result := DataTable.Fields[idx_V_Detalles_Facturas_ComisionIMPORTE_COMISION].AsCurrency; + result := DataTable.Fields[idx_V_Detalles_Facturas_ComisionIMPORTE_COMISION].AsFloat; end; -procedure TV_Detalles_Facturas_ComisionDataTableRules.SetIMPORTE_COMISIONValue(const aValue: Currency); +procedure TV_Detalles_Facturas_ComisionDataTableRules.SetIMPORTE_COMISIONValue(const aValue: Float); begin - DataTable.Fields[idx_V_Detalles_Facturas_ComisionIMPORTE_COMISION].AsCurrency := aValue; + DataTable.Fields[idx_V_Detalles_Facturas_ComisionIMPORTE_COMISION].AsFloat := aValue; end; function TV_Detalles_Facturas_ComisionDataTableRules.GetIMPORTE_COMISIONIsNull: boolean; diff --git a/Source/Modulos/Comisiones/Model/schComisionesServer_Intf.pas b/Source/Modulos/Comisiones/Model/schComisionesServer_Intf.pas index 4651539..3f31421 100644 --- a/Source/Modulos/Comisiones/Model/schComisionesServer_Intf.pas +++ b/Source/Modulos/Comisiones/Model/schComisionesServer_Intf.pas @@ -9,14 +9,14 @@ const { Delta rules ids Feel free to change them to something more human readable but make sure they are unique in the context of your application } - RID_Facturas_ComisionDelta = '{88A76329-95DC-43B9-B006-2105266C4624}'; - RID_ComisionesDelta = '{09A69155-5018-438D-B5C6-F0C7C44D67A1}'; - RID_V_Detalles_Facturas_ComisionDelta = '{E0EC6778-1F46-4E20-AFD3-40F830E827D0}'; + RID_Facturas_ComisionDelta = '{4C5DE436-DABE-4CF3-82F0-DBE9E5E15ED4}'; + RID_ComisionesDelta = '{68D578AF-F1C5-407E-8982-243DEDD3DBC7}'; + RID_V_Detalles_Facturas_ComisionDelta = '{F4B4675E-F31B-456C-8523-3BB2CEB9A910}'; type { IFacturas_ComisionDelta } IFacturas_ComisionDelta = interface(IFacturas_Comision) - ['{88A76329-95DC-43B9-B006-2105266C4624}'] + ['{4C5DE436-DABE-4CF3-82F0-DBE9E5E15ED4}'] { Property getters and setters } function GetOldID_EMPRESAValue : Integer; function GetOldID_AGENTEValue : Integer; @@ -32,7 +32,7 @@ type function GetOldPROVEEDORValue : String; function GetOldCOMISIONValue : Float; function GetOldIMPORTE_COMISIONABLEValue : Currency; - function GetOldIMPORTE_COMISIONValue : Currency; + function GetOldIMPORTE_COMISIONValue : Float; { Properties } property OldID_EMPRESA : Integer read GetOldID_EMPRESAValue; @@ -49,7 +49,7 @@ type property OldPROVEEDOR : String read GetOldPROVEEDORValue; property OldCOMISION : Float read GetOldCOMISIONValue; property OldIMPORTE_COMISIONABLE : Currency read GetOldIMPORTE_COMISIONABLEValue; - property OldIMPORTE_COMISION : Currency read GetOldIMPORTE_COMISIONValue; + property OldIMPORTE_COMISION : Float read GetOldIMPORTE_COMISIONValue; end; { TFacturas_ComisionBusinessProcessorRules } @@ -141,11 +141,11 @@ type function GetOldIMPORTE_COMISIONABLEIsNull: Boolean; virtual; procedure SetIMPORTE_COMISIONABLEValue(const aValue: Currency); virtual; procedure SetIMPORTE_COMISIONABLEIsNull(const aValue: Boolean); virtual; - function GetIMPORTE_COMISIONValue: Currency; virtual; + function GetIMPORTE_COMISIONValue: Float; virtual; function GetIMPORTE_COMISIONIsNull: Boolean; virtual; - function GetOldIMPORTE_COMISIONValue: Currency; virtual; + function GetOldIMPORTE_COMISIONValue: Float; virtual; function GetOldIMPORTE_COMISIONIsNull: Boolean; virtual; - procedure SetIMPORTE_COMISIONValue(const aValue: Currency); virtual; + procedure SetIMPORTE_COMISIONValue(const aValue: Float); virtual; procedure SetIMPORTE_COMISIONIsNull(const aValue: Boolean); virtual; { Properties } @@ -205,9 +205,9 @@ type property IMPORTE_COMISIONABLEIsNull : Boolean read GetIMPORTE_COMISIONABLEIsNull write SetIMPORTE_COMISIONABLEIsNull; property OldIMPORTE_COMISIONABLE : Currency read GetOldIMPORTE_COMISIONABLEValue; property OldIMPORTE_COMISIONABLEIsNull : Boolean read GetOldIMPORTE_COMISIONABLEIsNull; - property IMPORTE_COMISION : Currency read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; + property IMPORTE_COMISION : Float read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; property IMPORTE_COMISIONIsNull : Boolean read GetIMPORTE_COMISIONIsNull write SetIMPORTE_COMISIONIsNull; - property OldIMPORTE_COMISION : Currency read GetOldIMPORTE_COMISIONValue; + property OldIMPORTE_COMISION : Float read GetOldIMPORTE_COMISIONValue; property OldIMPORTE_COMISIONIsNull : Boolean read GetOldIMPORTE_COMISIONIsNull; public @@ -218,7 +218,7 @@ type { IComisionesDelta } IComisionesDelta = interface(IComisiones) - ['{09A69155-5018-438D-B5C6-F0C7C44D67A1}'] + ['{68D578AF-F1C5-407E-8982-243DEDD3DBC7}'] { Property getters and setters } function GetOldIDValue : Integer; function GetOldID_EMPRESAValue : Integer; @@ -348,7 +348,7 @@ type { IV_Detalles_Facturas_ComisionDelta } IV_Detalles_Facturas_ComisionDelta = interface(IV_Detalles_Facturas_Comision) - ['{E0EC6778-1F46-4E20-AFD3-40F830E827D0}'] + ['{F4B4675E-F31B-456C-8523-3BB2CEB9A910}'] { Property getters and setters } function GetOldID_EMPRESAValue : Integer; function GetOldID_AGENTEValue : Integer; @@ -364,7 +364,7 @@ type function GetOldPROVEEDORValue : String; function GetOldCOMISIONValue : Float; function GetOldIMPORTE_COMISIONABLEValue : Currency; - function GetOldIMPORTE_COMISIONValue : Currency; + function GetOldIMPORTE_COMISIONValue : Float; { Properties } property OldID_EMPRESA : Integer read GetOldID_EMPRESAValue; @@ -381,7 +381,7 @@ type property OldPROVEEDOR : String read GetOldPROVEEDORValue; property OldCOMISION : Float read GetOldCOMISIONValue; property OldIMPORTE_COMISIONABLE : Currency read GetOldIMPORTE_COMISIONABLEValue; - property OldIMPORTE_COMISION : Currency read GetOldIMPORTE_COMISIONValue; + property OldIMPORTE_COMISION : Float read GetOldIMPORTE_COMISIONValue; end; { TV_Detalles_Facturas_ComisionBusinessProcessorRules } @@ -473,11 +473,11 @@ type function GetOldIMPORTE_COMISIONABLEIsNull: Boolean; virtual; procedure SetIMPORTE_COMISIONABLEValue(const aValue: Currency); virtual; procedure SetIMPORTE_COMISIONABLEIsNull(const aValue: Boolean); virtual; - function GetIMPORTE_COMISIONValue: Currency; virtual; + function GetIMPORTE_COMISIONValue: Float; virtual; function GetIMPORTE_COMISIONIsNull: Boolean; virtual; - function GetOldIMPORTE_COMISIONValue: Currency; virtual; + function GetOldIMPORTE_COMISIONValue: Float; virtual; function GetOldIMPORTE_COMISIONIsNull: Boolean; virtual; - procedure SetIMPORTE_COMISIONValue(const aValue: Currency); virtual; + procedure SetIMPORTE_COMISIONValue(const aValue: Float); virtual; procedure SetIMPORTE_COMISIONIsNull(const aValue: Boolean); virtual; { Properties } @@ -537,9 +537,9 @@ type property IMPORTE_COMISIONABLEIsNull : Boolean read GetIMPORTE_COMISIONABLEIsNull write SetIMPORTE_COMISIONABLEIsNull; property OldIMPORTE_COMISIONABLE : Currency read GetOldIMPORTE_COMISIONABLEValue; property OldIMPORTE_COMISIONABLEIsNull : Boolean read GetOldIMPORTE_COMISIONABLEIsNull; - property IMPORTE_COMISION : Currency read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; + property IMPORTE_COMISION : Float read GetIMPORTE_COMISIONValue write SetIMPORTE_COMISIONValue; property IMPORTE_COMISIONIsNull : Boolean read GetIMPORTE_COMISIONIsNull write SetIMPORTE_COMISIONIsNull; - property OldIMPORTE_COMISION : Currency read GetOldIMPORTE_COMISIONValue; + property OldIMPORTE_COMISION : Float read GetOldIMPORTE_COMISIONValue; property OldIMPORTE_COMISIONIsNull : Boolean read GetOldIMPORTE_COMISIONIsNull; public @@ -998,7 +998,7 @@ begin BusinessProcessor.CurrentChange.NewValueByName[fld_Facturas_ComisionIMPORTE_COMISIONABLE] := Null; end; -function TFacturas_ComisionBusinessProcessorRules.GetIMPORTE_COMISIONValue: Currency; +function TFacturas_ComisionBusinessProcessorRules.GetIMPORTE_COMISIONValue: Float; begin result := BusinessProcessor.CurrentChange.NewValueByName[fld_Facturas_ComisionIMPORTE_COMISION]; end; @@ -1008,7 +1008,7 @@ begin result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_Facturas_ComisionIMPORTE_COMISION]); end; -function TFacturas_ComisionBusinessProcessorRules.GetOldIMPORTE_COMISIONValue: Currency; +function TFacturas_ComisionBusinessProcessorRules.GetOldIMPORTE_COMISIONValue: Float; begin result := BusinessProcessor.CurrentChange.OldValueByName[fld_Facturas_ComisionIMPORTE_COMISION]; end; @@ -1018,7 +1018,7 @@ begin result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_Facturas_ComisionIMPORTE_COMISION]); end; -procedure TFacturas_ComisionBusinessProcessorRules.SetIMPORTE_COMISIONValue(const aValue: Currency); +procedure TFacturas_ComisionBusinessProcessorRules.SetIMPORTE_COMISIONValue(const aValue: Float); begin BusinessProcessor.CurrentChange.NewValueByName[fld_Facturas_ComisionIMPORTE_COMISION] := aValue; end; @@ -1766,7 +1766,7 @@ begin BusinessProcessor.CurrentChange.NewValueByName[fld_V_Detalles_Facturas_ComisionIMPORTE_COMISIONABLE] := Null; end; -function TV_Detalles_Facturas_ComisionBusinessProcessorRules.GetIMPORTE_COMISIONValue: Currency; +function TV_Detalles_Facturas_ComisionBusinessProcessorRules.GetIMPORTE_COMISIONValue: Float; begin result := BusinessProcessor.CurrentChange.NewValueByName[fld_V_Detalles_Facturas_ComisionIMPORTE_COMISION]; end; @@ -1776,7 +1776,7 @@ begin result := VarIsNull(BusinessProcessor.CurrentChange.NewValueByName[fld_V_Detalles_Facturas_ComisionIMPORTE_COMISION]); end; -function TV_Detalles_Facturas_ComisionBusinessProcessorRules.GetOldIMPORTE_COMISIONValue: Currency; +function TV_Detalles_Facturas_ComisionBusinessProcessorRules.GetOldIMPORTE_COMISIONValue: Float; begin result := BusinessProcessor.CurrentChange.OldValueByName[fld_V_Detalles_Facturas_ComisionIMPORTE_COMISION]; end; @@ -1786,7 +1786,7 @@ begin result := VarIsNull(BusinessProcessor.CurrentChange.OldValueByName[fld_V_Detalles_Facturas_ComisionIMPORTE_COMISION]); end; -procedure TV_Detalles_Facturas_ComisionBusinessProcessorRules.SetIMPORTE_COMISIONValue(const aValue: Currency); +procedure TV_Detalles_Facturas_ComisionBusinessProcessorRules.SetIMPORTE_COMISIONValue(const aValue: Float); begin BusinessProcessor.CurrentChange.NewValueByName[fld_V_Detalles_Facturas_ComisionIMPORTE_COMISION] := aValue; end; diff --git a/Source/Modulos/Comisiones/Model/uBizComisiones.pas b/Source/Modulos/Comisiones/Model/uBizComisiones.pas index 9802dc7..ae38f40 100644 --- a/Source/Modulos/Comisiones/Model/uBizComisiones.pas +++ b/Source/Modulos/Comisiones/Model/uBizComisiones.pas @@ -98,10 +98,6 @@ procedure TBizComisiones.SetFacturas(const Value: IBizFacturasComision); begin FFacturas := Value; EnlazarMaestroDetalle(FFacturasLink, FFacturas); - - if Assigned(FFacturas) then - if not FFacturas.DataTable.Active then - FFacturas.DataTable.Active := True; end; initialization diff --git a/Source/Modulos/Comisiones/Model/uBizComisionesServer.pas b/Source/Modulos/Comisiones/Model/uBizComisionesServer.pas index eeca9aa..60bf754 100644 --- a/Source/Modulos/Comisiones/Model/uBizComisionesServer.pas +++ b/Source/Modulos/Comisiones/Model/uBizComisionesServer.pas @@ -3,76 +3,112 @@ unit uBizComisionesServer; interface uses - schComisionesServer_Intf, uDAInterfaces, - uDADataTable, uDABusinessProcessor; + uDAInterfaces, uDADelta, uDABusinessProcessor, + schComisionesServer_Intf; const BIZ_SERVER_COMISIONES = 'Server.Comisiones'; - REF_COMISIONES = 'REF_COMISIONES'; + type TBizComisionesServer = class(TComisionesBusinessProcessorRules) + private + FReferenciaAutomatica : Boolean; + function DarReferencia : String; + function IncrementarReferencia : Boolean; protected - procedure BeforeProcessChange(Sender: TDABusinessProcessor; - aChangeType: TDAChangeType; aChange: TDADeltaChange; - var ProcessChange: Boolean); override; + procedure BeforeProcessDelta(Sender: TDABusinessProcessor; const aDelta: IDADelta); override; + procedure AfterProcessChange(Sender: TDABusinessProcessor; aChange: TDADeltaChange; Processed: Boolean; + var CanRemoveFromDelta: Boolean); override; end; implementation - -uses - Dialogs, SysUtils, Variants, uDataModuleServer, uDAClasses, DARemoteService_Impl, - schComisionesClient_Intf, uBusinessUtils, uReferenciasUtils, uROClasses; - { TBizComisionesServer } -procedure TBizComisionesServer.BeforeProcessChange( - Sender: TDABusinessProcessor; aChangeType: TDAChangeType; - aChange: TDADeltaChange; var ProcessChange: Boolean); -var - ASchema : TDASchema; - ACurrentConn : IDAConnection; - dsData: IDADataset; - Empresa : Variant; +uses + Variants, uDAClasses, uBusinessUtils, uROClasses, uROServer, SysUtils, + uDataModuleServer, schComisionesClient_Intf, FactuGES_Intf; +const + REF_COMISIONES = 'REF_COMISIONES'; + +procedure TBizComisionesServer.AfterProcessChange(Sender: TDABusinessProcessor; + aChange: TDADeltaChange; Processed: Boolean; var CanRemoveFromDelta: Boolean); begin inherited; - case aChangeType of + case aChange.ChangeType of + ctInsert: begin +// Insert_Asiento_Factura(aChange); + end; + ctUpdate: begin +// Update_Asiento_Factura(aChange); + end; + ctDelete: begin +// Delete_Asiento_Factura(aChange); + end; + end; + + { Por defecto, mantenemos los deltas por si alguna tabla hija los necesita } + CanRemoveFromDelta := False; + + case aChange.ChangeType of + ctInsert, ctUpdate: begin + if FReferenciaAutomatica then + begin + IncrementarReferencia; + FReferenciaAutomatica := False; + end; + end; + end; +end; + +procedure TBizComisionesServer.BeforeProcessDelta(Sender: TDABusinessProcessor; + const aDelta: IDADelta); +begin + FReferenciaAutomatica := False; + + case Sender.CurrentChange.ChangeType of ctInsert, ctUpdate: begin //Si la referencia no ha sido asignada le asignamos una nosotros - if (VarIsNull(aChange.NewValueByName[fld_ComisionesREFERENCIA])) - or (VarToStr(aChange.NewValueByName[fld_ComisionesREFERENCIA]) = '') then + if REFERENCIAIsNull or (Length(REFERENCIA) = 0) then begin - ASchema := BusinessProcessor.Schema; - ACurrentConn := GetBusinessProcessorConnection(BusinessProcessor); - - try - //Siempre va a estar rellena - Empresa := aChange.NewValueByName[fld_ComisionesID_EMPRESA]; - - dsData := ASchema.NewDataset(ACurrentConn, 'DarReferencia', ['CODIGO', 'EMPRESA'], [REF_COMISIONES, Empresa]); - except - RaiseError('No existe la tabla REFERENCIAS'); - end; - - dsData.Active := True; - - if dsData.IsEmpty then - RaiseError('NO HAY REFERENCIA ' + REF_COMISIONES + ' DECLARADA EN TABLA REFERENCIAS'); - - REFERENCIA := dsData.FieldByName('VALOR').AsString; - - try - ASchema.NewCommand(ACurrentConn, 'ModificarReferencia', ['CODIGO', 'VALOR', 'ID_EMPRESA'], [REF_COMISIONES, DarReferenciaSiguiente(REFERENCIA), Empresa]); - except - RaiseError('Error al asignar la nueva ' + REFERENCIA + ' referencia en tabla'); - end; - + FReferenciaAutomatica := True; + REFERENCIA := DarReferencia; end; end; end; end; +function TBizComisionesServer.DarReferencia: String; +var + AReferenciasService : IsrvReferencias; + Intf : IInterface; + AClientID : TGUID; +begin + // Aunque sea un abono, la referencia es la misma que una factura + + CreateGUID(AClientID); + + GetClassFactory('srvReferencias').CreateInstance(AClientID, Intf); + AReferenciasService := Intf as IsrvReferencias; + Result := AReferenciasService.DarNuevaReferencia(REF_COMISIONES, ID_EMPRESA) +end; + +function TBizComisionesServer.IncrementarReferencia: Boolean; +var + AReferenciasService : IsrvReferencias; + Intf : IInterface; + AClientID : TGUID; +begin + // Aunque sea un abono, la referencia es la misma que una factura + + CreateGUID(AClientID); + + GetClassFactory('srvReferencias').CreateInstance(AClientID, Intf); + AReferenciasService := Intf as IsrvReferencias; + Result := AReferenciasService.IncrementarValorReferencia(REF_COMISIONES, Self.REFERENCIA, ID_EMPRESA) +end; + initialization RegisterBusinessProcessorRules(BIZ_SERVER_COMISIONES, TBizComisionesServer); diff --git a/Source/Modulos/Comisiones/Reports/uRptComisiones_Server.dfm b/Source/Modulos/Comisiones/Reports/uRptComisiones_Server.dfm new file mode 100644 index 0000000..d82102a --- /dev/null +++ b/Source/Modulos/Comisiones/Reports/uRptComisiones_Server.dfm @@ -0,0 +1,935 @@ +object RptComisiones: TRptComisiones + OldCreateOrder = True + OnCreate = DataModuleCreate + Height = 405 + Width = 447 + object DADataCabecera: TDADataSource + DataSet = tbl_Comisiones.Dataset + DataTable = tbl_Comisiones + Left = 264 + Top = 72 + end + object tbl_Comisiones: TDACDSDataTable + RemoteUpdatesOptions = [] + Fields = <> + Params = <> + MasterMappingMode = mmDataRequest + LogChanges = False + StreamingOptions = [soDisableEventsWhileStreaming] + RemoteFetchEnabled = False + LocalSchema = schReport + LocalDataStreamer = Bin2DataStreamer + IndexDefs = <> + Left = 264 + Top = 128 + end + object frxRichObject1: TfrxRichObject + Left = 48 + Top = 296 + end + object frxBarCodeObject1: TfrxBarCodeObject + Left = 144 + Top = 296 + end + object frxOLEObject1: TfrxOLEObject + Left = 48 + Top = 344 + end + object frxCrossObject1: TfrxCrossObject + Left = 144 + Top = 344 + end + object frxCheckBoxObject1: TfrxCheckBoxObject + Left = 256 + Top = 296 + end + object frxGradientObject1: TfrxGradientObject + Left = 360 + Top = 296 + end + object frxChartObject1: TfrxChartObject + Left = 256 + Top = 344 + end + object schReport: TDASchema + ConnectionManager = dmServer.ConnectionManager + DataDictionary = DataDictionary + Datasets = < + item + Params = <> + Statements = < + item + Connection = 'IBX' + TargetTable = 'V_AGENTES_COMISIONES_DET_FAC' + SQL = + 'select'#10' COMISIONES_LIQUIDADAS.FECHA AS FECHA_COMISION,'#10' ' + + ' COMISIONES_LIQUIDADAS.REFERENCIA AS REFERENCIA_COMISION,'#10' ' + + ' COMISIONES_LIQUIDADAS.DESCRIPCION,'#10' COMISIONES_LIQUIDA' + + 'DAS.IMPORTE_TOTAL,'#10#10' V_AGENTES_COMISIONES_DET_FAC.ID_EMPRE' + + 'SA, EMPRESAS.NIF_CIF as NIF_CIF_EMPRESA, COALESCE(EMPRESAS.RAZON' + + '_SOCIAL, EMPRESAS.NOMBRE) as RAZON_SOCIAL,'#10' EMPRESAS.CALLE' + + ' as CALLE_EMPRESA, EMPRESAS.POBLACION as POBLACION_EMPRESA,'#10' ' + + ' EMPRESAS.PROVINCIA as PROVINCIA_EMPRESA, EMPRESAS.CODIGO_POST' + + 'AL as CODIGO_POSTAL_EMPRESA,'#10' EMPRESAS.TELEFONO_1, EMPRESA' + + 'S.FAX, EMPRESAS.MOVIL_1, EMPRESAS.EMAIL_1,'#10' EMPRESAS.PAGIN' + + 'A_WEB, EMPRESAS.REGISTRO_MERCANTIL,'#10#10' V_AGENTES_COMISIONES' + + '_DET_FAC.ID_AGENTE, CONTACTOS1.NOMBRE as AGENTE,'#10' V_AGENTE' + + 'S_COMISIONES_DET_FAC.ID_FACTURA,'#10' V_AGENTES_COMISIONES_DET' + + '_FAC.ID_COMISION_LIQUIDADA,'#10' V_AGENTES_COMISIONES_DET_FAC.' + + 'FECHA,'#10' V_AGENTES_COMISIONES_DET_FAC.REFERENCIA,'#10' V_' + + 'AGENTES_COMISIONES_DET_FAC.SITUACION,'#10' V_AGENTES_COMISIONE' + + 'S_DET_FAC.ID_CLIENTE,'#10' CONTACTOS2.NOMBRE as CLIENTE,'#10#10' ' + + ' SUM(V_AGENTES_COMISIONES_DET_FAC.IMPORTE_TOTAL) as IMPORTE_CO' + + 'MISIONABLE,'#10' SUM(V_AGENTES_COMISIONES_DET_FAC.IMPORTE_COMI' + + 'SION) as IMPORTE_COMISION'#10#10#10'from V_AGENTES_COMISIONES_DET_FAC'#10'LE' + + 'FT JOIN COMISIONES_LIQUIDADAS ON (COMISIONES_LIQUIDADAS.ID = V_A' + + 'GENTES_COMISIONES_DET_FAC.ID_COMISION_LIQUIDADA)'#10'LEFT JOIN EMPRE' + + 'SAS ON EMPRESAS.ID = V_AGENTES_COMISIONES_DET_FAC.ID_EMPRESA'#10'LEF' + + 'T JOIN CONTACTOS CONTACTOS1 ON (CONTACTOS1.ID = V_AGENTES_COMISI' + + 'ONES_DET_FAC.ID_AGENTE)'#10'LEFT JOIN CONTACTOS CONTACTOS2 ON (CONTA' + + 'CTOS2.ID = V_AGENTES_COMISIONES_DET_FAC.ID_CLIENTE)'#10'LEFT JOIN CO' + + 'NTACTOS CONTACTOS3 ON (CONTACTOS3.ID = V_AGENTES_COMISIONES_DET_' + + 'FAC.ID_PROVEEDOR)'#10'WHERE V_AGENTES_COMISIONES_DET_FAC.ID_COMISION' + + '_LIQUIDADA IS NOT NULL'#10'and {where}'#10'GROUP BY 1, 2, 3, 4, 5, 6, 7,' + + ' 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 2' + + '4, 25, 26'#10'ORDER BY 1'#10 + StatementType = stSQL + ColumnMappings = < + item + DatasetField = 'REFERENCIA' + TableField = 'REFERENCIA' + end + item + DatasetField = 'ID_EMPRESA' + TableField = 'ID_EMPRESA' + end + item + DatasetField = 'ID_CLIENTE' + TableField = 'ID_CLIENTE' + end + item + DatasetField = 'REFERENCIA_COMISION' + TableField = 'REFERENCIA_COMISION' + end + item + DatasetField = 'DESCRIPCION' + TableField = 'DESCRIPCION' + end + item + DatasetField = 'ID_AGENTE' + TableField = 'ID_AGENTE' + end + item + DatasetField = 'AGENTE' + TableField = 'AGENTE' + end + item + DatasetField = 'ID_FACTURA' + TableField = 'ID_FACTURA' + end + item + DatasetField = 'ID_COMISION_LIQUIDADA' + TableField = 'ID_COMISION_LIQUIDADA' + end + item + DatasetField = 'FECHA' + TableField = 'FECHA' + end + item + DatasetField = 'SITUACION' + TableField = 'SITUACION' + end + item + DatasetField = 'CLIENTE' + TableField = 'CLIENTE' + end + item + DatasetField = 'IMPORTE_COMISIONABLE' + TableField = 'IMPORTE_COMISIONABLE' + end + item + DatasetField = 'IMPORTE_COMISION' + TableField = 'IMPORTE_COMISION' + end + item + DatasetField = 'FECHA_COMISION' + TableField = 'FECHA_COMISION' + end + item + DatasetField = 'IMPORTE_TOTAL' + TableField = 'IMPORTE_TOTAL' + end + item + DatasetField = 'NIF_CIF_EMPRESA' + TableField = 'NIF_CIF_EMPRESA' + end + item + DatasetField = 'RAZON_SOCIAL' + TableField = 'RAZON_SOCIAL' + end + item + DatasetField = 'CALLE_EMPRESA' + TableField = 'CALLE_EMPRESA' + end + item + DatasetField = 'POBLACION_EMPRESA' + TableField = 'POBLACION_EMPRESA' + end + item + DatasetField = 'PROVINCIA_EMPRESA' + TableField = 'PROVINCIA_EMPRESA' + end + item + DatasetField = 'CODIGO_POSTAL_EMPRESA' + TableField = 'CODIGO_POSTAL_EMPRESA' + end + item + DatasetField = 'TELEFONO_1' + TableField = 'TELEFONO_1' + end + item + DatasetField = 'FAX' + TableField = 'FAX' + end + item + DatasetField = 'MOVIL_1' + TableField = 'MOVIL_1' + end + item + DatasetField = 'EMAIL_1' + TableField = 'EMAIL_1' + end + item + DatasetField = 'PAGINA_WEB' + TableField = 'PAGINA_WEB' + end + item + DatasetField = 'REGISTRO_MERCANTIL' + TableField = 'REGISTRO_MERCANTIL' + end> + end> + Name = 'InformeComisiones' + Fields = < + item + Name = 'FECHA_COMISION' + DataType = datDateTime + end + item + Name = 'REFERENCIA_COMISION' + DataType = datString + Size = 255 + end + item + Name = 'DESCRIPCION' + DataType = datString + Size = 255 + end + item + Name = 'IMPORTE_TOTAL' + DataType = datCurrency + end + item + Name = 'ID_EMPRESA' + DataType = datInteger + end + item + Name = 'NIF_CIF_EMPRESA' + DataType = datString + Size = 15 + end + item + Name = 'RAZON_SOCIAL' + DataType = datString + Size = 255 + end + item + Name = 'CALLE_EMPRESA' + DataType = datString + Size = 255 + end + item + Name = 'POBLACION_EMPRESA' + DataType = datString + Size = 255 + end + item + Name = 'PROVINCIA_EMPRESA' + DataType = datString + Size = 255 + end + item + Name = 'CODIGO_POSTAL_EMPRESA' + DataType = datString + Size = 10 + end + item + Name = 'TELEFONO_1' + DataType = datString + Size = 25 + end + item + Name = 'FAX' + DataType = datString + Size = 25 + end + item + Name = 'MOVIL_1' + DataType = datString + Size = 25 + end + item + Name = 'EMAIL_1' + DataType = datString + Size = 255 + end + item + Name = 'PAGINA_WEB' + DataType = datString + Size = 255 + end + item + Name = 'REGISTRO_MERCANTIL' + DataType = datString + Size = 255 + end + item + Name = 'ID_AGENTE' + DataType = datInteger + end + item + Name = 'AGENTE' + DataType = datString + Size = 255 + end + item + Name = 'ID_FACTURA' + DataType = datInteger + end + item + Name = 'ID_COMISION_LIQUIDADA' + DataType = datInteger + end + item + Name = 'FECHA' + DataType = datDateTime + end + item + Name = 'REFERENCIA' + DataType = datString + Size = 255 + end + item + Name = 'SITUACION' + DataType = datString + Size = 19 + end + item + Name = 'ID_CLIENTE' + DataType = datInteger + end + item + Name = 'CLIENTE' + DataType = datString + Size = 255 + end + item + Name = 'IMPORTE_COMISIONABLE' + DataType = datCurrency + end + item + Name = 'IMPORTE_COMISION' + DataType = datFloat + end> + end + item + Params = <> + Statements = < + item + Connection = 'IBX' + TargetTable = 'V_AGENTES_COMISIONES_DET_FAC' + SQL = + 'select'#10' COMISIONES_LIQUIDADAS.FECHA AS FECHA_COMISION,'#10' ' + + ' COMISIONES_LIQUIDADAS.REFERENCIA AS REFERENCIA_COMISION,'#10' ' + + ' COMISIONES_LIQUIDADAS.DESCRIPCION,'#10' COMISIONES_LIQUIDA' + + 'DAS.IMPORTE_TOTAL,'#10#10' V_AGENTES_COMISIONES_DET_FAC.ID_EMPRE' + + 'SA, EMPRESAS.NIF_CIF as NIF_CIF_EMPRESA, COALESCE(EMPRESAS.RAZON' + + '_SOCIAL, EMPRESAS.NOMBRE) as RAZON_SOCIAL,'#10' EMPRESAS.CALLE' + + ' as CALLE_EMPRESA, EMPRESAS.POBLACION as POBLACION_EMPRESA,'#10' ' + + ' EMPRESAS.PROVINCIA as PROVINCIA_EMPRESA, EMPRESAS.CODIGO_POST' + + 'AL as CODIGO_POSTAL_EMPRESA,'#10' EMPRESAS.TELEFONO_1, EMPRESA' + + 'S.FAX, EMPRESAS.MOVIL_1, EMPRESAS.EMAIL_1,'#10' EMPRESAS.PAGIN' + + 'A_WEB, EMPRESAS.REGISTRO_MERCANTIL,'#10#10' V_AGENTES_COMISIONES' + + '_DET_FAC.ID_AGENTE, CONTACTOS1.NOMBRE as AGENTE,'#10' V_AGENTE' + + 'S_COMISIONES_DET_FAC.ID_FACTURA,'#10' V_AGENTES_COMISIONES_DET' + + '_FAC.ID_COMISION_LIQUIDADA,'#10' V_AGENTES_COMISIONES_DET_FAC.' + + 'FECHA,'#10' V_AGENTES_COMISIONES_DET_FAC.REFERENCIA,'#10' V_' + + 'AGENTES_COMISIONES_DET_FAC.SITUACION,'#10' V_AGENTES_COMISIONE' + + 'S_DET_FAC.ID_CLIENTE,'#10' CONTACTOS2.NOMBRE as CLIENTE,'#10' ' + + ' V_AGENTES_COMISIONES_DET_FAC.ID_PROVEEDOR,'#10' CONTACTOS3.N' + + 'OMBRE as PROVEEDOR,'#10' V_AGENTES_COMISIONES_DET_FAC.COMISION' + + ','#10#10' SUM(V_AGENTES_COMISIONES_DET_FAC.IMPORTE_TOTAL) as IMP' + + 'ORTE_COMISIONABLE,'#10' SUM(V_AGENTES_COMISIONES_DET_FAC.IMPOR' + + 'TE_COMISION) as IMPORTE_COMISION'#10#10#10'from V_AGENTES_COMISIONES_DET' + + '_FAC'#10'LEFT JOIN COMISIONES_LIQUIDADAS ON (COMISIONES_LIQUIDADAS.I' + + 'D = V_AGENTES_COMISIONES_DET_FAC.ID_COMISION_LIQUIDADA)'#10'LEFT JOI' + + 'N EMPRESAS ON EMPRESAS.ID = V_AGENTES_COMISIONES_DET_FAC.ID_EMPR' + + 'ESA'#10'LEFT JOIN CONTACTOS CONTACTOS1 ON (CONTACTOS1.ID = V_AGENTES' + + '_COMISIONES_DET_FAC.ID_AGENTE)'#10'LEFT JOIN CONTACTOS CONTACTOS2 ON' + + ' (CONTACTOS2.ID = V_AGENTES_COMISIONES_DET_FAC.ID_CLIENTE)'#10'LEFT ' + + 'JOIN CONTACTOS CONTACTOS3 ON (CONTACTOS3.ID = V_AGENTES_COMISION' + + 'ES_DET_FAC.ID_PROVEEDOR)'#10'WHERE V_AGENTES_COMISIONES_DET_FAC.ID_C' + + 'OMISION_LIQUIDADA IS NOT NULL'#10'and {where}'#10'GROUP BY 1, 2, 3, 4, 5' + + ', 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22' + + ', 23, 24, 25, 26, 27, 28, 29'#10'ORDER BY 1'#10 + StatementType = stSQL + ColumnMappings = < + item + DatasetField = 'REFERENCIA' + TableField = 'REFERENCIA' + end + item + DatasetField = 'ID_EMPRESA' + TableField = 'ID_EMPRESA' + end + item + DatasetField = 'ID_CLIENTE' + TableField = 'ID_CLIENTE' + end + item + DatasetField = 'REFERENCIA_COMISION' + TableField = 'REFERENCIA_COMISION' + end + item + DatasetField = 'DESCRIPCION' + TableField = 'DESCRIPCION' + end + item + DatasetField = 'ID_AGENTE' + TableField = 'ID_AGENTE' + end + item + DatasetField = 'AGENTE' + TableField = 'AGENTE' + end + item + DatasetField = 'ID_FACTURA' + TableField = 'ID_FACTURA' + end + item + DatasetField = 'ID_COMISION_LIQUIDADA' + TableField = 'ID_COMISION_LIQUIDADA' + end + item + DatasetField = 'FECHA' + TableField = 'FECHA' + end + item + DatasetField = 'SITUACION' + TableField = 'SITUACION' + end + item + DatasetField = 'CLIENTE' + TableField = 'CLIENTE' + end + item + DatasetField = 'ID_PROVEEDOR' + TableField = 'ID_PROVEEDOR' + end + item + DatasetField = 'PROVEEDOR' + TableField = 'PROVEEDOR' + end + item + DatasetField = 'COMISION' + TableField = 'COMISION' + end + item + DatasetField = 'IMPORTE_COMISIONABLE' + TableField = 'IMPORTE_COMISIONABLE' + end + item + DatasetField = 'IMPORTE_COMISION' + TableField = 'IMPORTE_COMISION' + end + item + DatasetField = 'FECHA_COMISION' + TableField = 'FECHA_COMISION' + end + item + DatasetField = 'IMPORTE_TOTAL' + TableField = 'IMPORTE_TOTAL' + end + item + DatasetField = 'NIF_CIF_EMPRESA' + TableField = 'NIF_CIF_EMPRESA' + end + item + DatasetField = 'RAZON_SOCIAL' + TableField = 'RAZON_SOCIAL' + end + item + DatasetField = 'CALLE_EMPRESA' + TableField = 'CALLE_EMPRESA' + end + item + DatasetField = 'POBLACION_EMPRESA' + TableField = 'POBLACION_EMPRESA' + end + item + DatasetField = 'PROVINCIA_EMPRESA' + TableField = 'PROVINCIA_EMPRESA' + end + item + DatasetField = 'CODIGO_POSTAL_EMPRESA' + TableField = 'CODIGO_POSTAL_EMPRESA' + end + item + DatasetField = 'TELEFONO_1' + TableField = 'TELEFONO_1' + end + item + DatasetField = 'FAX' + TableField = 'FAX' + end + item + DatasetField = 'MOVIL_1' + TableField = 'MOVIL_1' + end + item + DatasetField = 'EMAIL_1' + TableField = 'EMAIL_1' + end + item + DatasetField = 'PAGINA_WEB' + TableField = 'PAGINA_WEB' + end + item + DatasetField = 'REGISTRO_MERCANTIL' + TableField = 'REGISTRO_MERCANTIL' + end> + end> + Name = 'InformeComisionesDesglosado' + Fields = < + item + Name = 'FECHA_COMISION' + DataType = datDateTime + end + item + Name = 'REFERENCIA_COMISION' + DataType = datString + Size = 255 + end + item + Name = 'DESCRIPCION' + DataType = datString + Size = 255 + end + item + Name = 'IMPORTE_TOTAL' + DataType = datCurrency + end + item + Name = 'ID_EMPRESA' + DataType = datInteger + end + item + Name = 'NIF_CIF_EMPRESA' + DataType = datString + Size = 15 + end + item + Name = 'RAZON_SOCIAL' + DataType = datString + Size = 255 + end + item + Name = 'CALLE_EMPRESA' + DataType = datString + Size = 255 + end + item + Name = 'POBLACION_EMPRESA' + DataType = datString + Size = 255 + end + item + Name = 'PROVINCIA_EMPRESA' + DataType = datString + Size = 255 + end + item + Name = 'CODIGO_POSTAL_EMPRESA' + DataType = datString + Size = 10 + end + item + Name = 'TELEFONO_1' + DataType = datString + Size = 25 + end + item + Name = 'FAX' + DataType = datString + Size = 25 + end + item + Name = 'MOVIL_1' + DataType = datString + Size = 25 + end + item + Name = 'EMAIL_1' + DataType = datString + Size = 255 + end + item + Name = 'PAGINA_WEB' + DataType = datString + Size = 255 + end + item + Name = 'REGISTRO_MERCANTIL' + DataType = datString + Size = 255 + end + item + Name = 'ID_AGENTE' + DataType = datInteger + end + item + Name = 'AGENTE' + DataType = datString + Size = 255 + end + item + Name = 'ID_FACTURA' + DataType = datInteger + end + item + Name = 'ID_COMISION_LIQUIDADA' + DataType = datInteger + end + item + Name = 'FECHA' + DataType = datDateTime + end + item + Name = 'REFERENCIA' + DataType = datString + Size = 255 + end + item + Name = 'SITUACION' + DataType = datString + Size = 19 + end + item + Name = 'ID_CLIENTE' + DataType = datInteger + end + item + Name = 'CLIENTE' + DataType = datString + Size = 255 + end + item + Name = 'ID_PROVEEDOR' + DataType = datInteger + end + item + Name = 'PROVEEDOR' + DataType = datString + Size = 255 + end + item + Name = 'COMISION' + DataType = datFloat + end + item + Name = 'IMPORTE_COMISIONABLE' + DataType = datCurrency + end + item + Name = 'IMPORTE_COMISION' + DataType = datFloat + end> + end> + JoinDataTables = <> + UnionDataTables = <> + Commands = <> + RelationShips = <> + UpdateRules = <> + Version = 0 + Left = 48 + Top = 16 + end + object DataDictionary: TDADataDictionary + Fields = < + item + Name = 'FacturasCliente_ID' + DataType = datAutoInc + Required = True + DisplayLabel = 'ID' + end + item + Name = 'FacturasCliente_ID_EMPRESA' + DataType = datInteger + DisplayLabel = 'ID_EMPRESA' + end + item + Name = 'FacturasCliente_ID_CONTRATO' + DataType = datInteger + DisplayLabel = 'ID_CONTRATO' + end + item + Name = 'FacturasCliente_FECHA_FACTURA' + DataType = datDateTime + DisplayLabel = 'Fecha de las factura' + end + item + Name = 'FacturasCliente_VENCIMIENTO' + DataType = datInteger + DisplayLabel = 'Vencimiento' + end + item + Name = 'FacturasCliente_SITUACION' + DataType = datString + Size = 255 + DisplayLabel = 'Situaci'#243'n' + end + item + Name = 'FacturasCliente_BASE_IMPONIBLE' + DataType = datFloat + DisplayLabel = 'Base imponible' + Alignment = taRightJustify + end + item + Name = 'FacturasCliente_IMPORTE_DESCUENTO' + DataType = datFloat + DisplayLabel = 'Importe dto.' + Alignment = taRightJustify + end + item + Name = 'FacturasCliente_IMPORTE_IVA' + DataType = datFloat + DisplayLabel = 'Importe IVA' + Alignment = taRightJustify + end + item + Name = 'FacturasCliente_IMPORTE_TOTAL' + DataType = datFloat + DisplayLabel = 'Importe total' + Alignment = taRightJustify + end + item + Name = 'FacturasCliente_FORMA_PAGO' + DataType = datMemo + DisplayLabel = 'Forma de pago' + end + item + Name = 'FacturasCliente_ID_CLIENTE' + DataType = datInteger + DisplayLabel = 'ID_CLIENTE' + end + item + Name = 'FacturasCliente_NIF_CIF' + DataType = datString + Size = 15 + DisplayLabel = 'NIF/CIF' + end + item + Name = 'FacturasCliente_CODIGO_POSTAL' + DataType = datString + Size = 10 + DisplayLabel = 'C'#243'd. postal' + end + item + Name = 'FacturasCliente_FECHA_ALTA' + DataType = datDateTime + DisplayLabel = 'FECHA_ALTA' + end + item + Name = 'FacturasCliente_FECHA_MODIFICACION' + DataType = datDateTime + DisplayLabel = 'FECHA_MODIFICACION' + end + item + Name = 'FacturasCliente_OBSERVACIONES' + DataType = datMemo + DisplayLabel = 'Observaciones' + end + item + Name = 'FacturasCliente_NOMBRE' + DataType = datString + Size = 100 + DisplayLabel = 'Cliente' + end + item + Name = 'FacturasCliente_CALLE' + DataType = datString + Size = 150 + DisplayLabel = 'Direcci'#243'n' + end + item + Name = 'FacturasCliente_PROVINCIA' + DataType = datString + Size = 30 + DisplayLabel = 'Provincia' + end + item + Name = 'FacturasCliente_POBLACION' + DataType = datString + Size = 150 + DisplayLabel = 'Poblaci'#243'n' + end + item + Name = 'FacturasCliente_IVA' + DataType = datFloat + DisplayLabel = 'IVA' + end + item + Name = 'FacturasCliente_USUARIO' + DataType = datString + Size = 100 + DisplayLabel = 'USUARIO' + end + item + Name = 'FacturasCliente_REFERENCIA' + DataType = datString + Size = 20 + DisplayLabel = 'Referencia' + end + item + Name = 'FacturasCliente_DESCUENTO' + DataType = datFloat + DisplayLabel = 'Dto.' + end + item + Name = 'FacturasCliente_Detalles_ID' + DataType = datAutoInc + Required = True + DisplayLabel = 'ID' + end + item + Name = 'FacturasCliente_Detalles_ID_FACTURA' + DataType = datInteger + DisplayLabel = 'ID_FACTURA' + end + item + Name = 'FacturasCliente_Detalles_TIPO_DETALLE' + DataType = datString + Size = 10 + DisplayLabel = 'Tipo detalle' + end + item + Name = 'FacturasCliente_Detalles_CONCEPTO' + DataType = datString + Size = 2000 + DisplayLabel = 'Concepto' + end + item + Name = 'FacturasCliente_Detalles_IMPORTE_UNIDAD' + DataType = datFloat + DisplayLabel = 'Importe unidad' + Alignment = taRightJustify + end + item + Name = 'FacturasCliente_Detalles_IMPORTE_TOTAL' + DataType = datFloat + DisplayLabel = 'Importe total' + Alignment = taRightJustify + end + item + Name = 'FacturasCliente_Detalles_VISIBLE' + DataType = datInteger + DisplayLabel = #191'Visible?' + end + item + Name = 'FacturasCliente_Detalles_POSICION' + DataType = datInteger + DisplayLabel = 'Posici'#243'n' + end + item + Name = 'FacturasCliente_Detalles_CANTIDAD' + DataType = datInteger + DisplayLabel = 'Cantidad' + end> + Left = 46 + Top = 158 + end + object frxReport: TfrxReport + Version = '4.7.71' + DotMatrixReport = False + EngineOptions.DoublePass = True + IniFile = '\Software\Fast Reports' + PreviewOptions.Buttons = [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick] + PreviewOptions.OutlineWidth = 180 + PreviewOptions.Zoom = 1.000000000000000000 + PrintOptions.Printer = 'Default' + PrintOptions.PrintOnSheet = 0 + ReportOptions.CreateDate = 37871.995398692100000000 + ReportOptions.LastChange = 39266.688905347220000000 + ReportOptions.VersionBuild = '1' + ReportOptions.VersionMajor = '12' + ReportOptions.VersionMinor = '13' + ReportOptions.VersionRelease = '1' + ScriptLanguage = 'PascalScript' + ScriptText.Strings = ( + 'procedure DatosEmpresaOnBeforePrint(Sender: TfrxComponent);' + 'var' + ' Cadena: String;' + 'begin' + ' DatosEmpresa.Lines.Clear;' + ' DatosEmpresa.Lines.Add();' + ' DatosEmpresa.Lines.Add();' + '' + ' Cadena := '#39#39';' + ' if ( <> '#39#39') then' + ' Cadena := '#39'TLF: '#39' + ;' + ' if ( <> '#39#39') then' + ' Cadena := Cadena + '#39' FAX: '#39' + ;' + ' DatosEmpresa.Lines.Add(Cadena);' + '' + ' Cadena := '#39#39';' + ' if ( <> '#39#39') then' + ' Cadena := ;' + ' if ( <> '#39#39') then' + + ' Cadena := Cadena + '#39' '#39' + ;' + ' if ( <> '#39#39') then' + + ' Cadena := Cadena + '#39' - '#39' + ;' + ' DatosEmpresa.Lines.Add(Cadena);' + 'end;' + '' + 'procedure Memo26OnBeforePrint(Sender: TfrxComponent);' + 'begin' + ' if ( <> '#39#39') then' + ' Memo31.Visible := True' + ' else' + ' Memo31.Visible := False;' + 'end;' + '' + 'BEGIN' + '' + 'END.') + ShowProgress = False + StoreInDFM = False + Left = 169 + Top = 16 + end + object frxDBCabecera: TfrxDBDataset + UserName = 'frxDBCabecera' + CloseDataSource = False + DataSource = DADataCabecera + BCDToCurrency = False + Left = 264 + Top = 16 + end + object Bin2DataStreamer: TDABin2DataStreamer + Left = 48 + Top = 88 + end +end diff --git a/Source/Modulos/Comisiones/Reports/uRptComisiones_Server.pas b/Source/Modulos/Comisiones/Reports/uRptComisiones_Server.pas new file mode 100644 index 0000000..2e02b02 --- /dev/null +++ b/Source/Modulos/Comisiones/Reports/uRptComisiones_Server.pas @@ -0,0 +1,146 @@ +unit uRptComisiones_Server; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, frxClass, frxDBSet, uDAScriptingProvider, + uDADataTable, uDACDSDataTable, DB, uDAClasses, frxChart, frxGradient, + frxChBox, frxCross, frxOLE, frxBarcode, frxRich, uDABINAdapter, uROTypes, + uDAInterfaces, uDADataStreamer, uDABin2DataStreamer; + +type + TRptComisiones = class(TDataModule) + DADataCabecera: TDADataSource; + tbl_Comisiones: TDACDSDataTable; + frxRichObject1: TfrxRichObject; + frxBarCodeObject1: TfrxBarCodeObject; + frxOLEObject1: TfrxOLEObject; + frxCrossObject1: TfrxCrossObject; + frxCheckBoxObject1: TfrxCheckBoxObject; + frxGradientObject1: TfrxGradientObject; + frxChartObject1: TfrxChartObject; + frxDBCabecera: TfrxDBDataset; + frxReport: TfrxReport; + Bin2DataStreamer: TDABin2DataStreamer; + schReport: TDASchema; + DataDictionary: TDADataDictionary; + procedure DataModuleCreate(Sender: TObject); + private + FConnection: IDAConnection; + public + function GenerarComision(const AComisionID : Variant; const DesglosadoProv: Boolean; FechaIni: String; FechaFin: String; AAgenteID: Variant): Binary; + end; + +implementation + +{$R *.dfm} + +uses + uSistemaFunc, uDataModuleServer, schComisionesClient_Intf; + +const + rptComision = 'InfComisiones.fr3'; + rptComisionDesglosado = 'InfComisionesDesglosado.fr3'; + + { Dataset names for schReport } + ds_InformeComisiones = 'InformeComisiones'; + ds_InformeComisionesDesglosado = 'InformeComisionesDesglosado'; + + +{ TRptComision } + +procedure TRptComisiones.DataModuleCreate(Sender: TObject); +begin + schReport.ConnectionManager := dmServer.ConnectionManager; + FConnection := dmServer.DarNuevaConexion; + frxReport.EngineOptions.NewSilentMode := simReThrow; +end; + +function TRptComisiones.GenerarComision(const AComisionID : Variant; const DesglosadoProv: Boolean; FechaIni: String; FechaFin: String; AAgenteID: Variant): Binary; +var + dsMaster: IDADataset; + AStream: TMemoryStream; + AInforme: Variant; + Condicion: TDAWhereExpression; + +begin + AStream := TMemoryStream.Create; + Result := Binary.Create; + FConnection.BeginTransaction; + try + if DesglosadoProv then + dsMaster := schReport.NewDataset(FConnection, ds_InformeComisionesDesglosado,[], [], False) + else + dsMaster := schReport.NewDataset(FConnection, ds_InformeComisiones,[], [], False); + + // Filtrar las facturas actuales por empresa + with dsMaster.DynamicWhere do + begin + if not VarIsNull(AComisionID) then + begin + Condicion := NewBinaryExpression(NewField('', fld_Facturas_ComisionID_COMISION_LIQUIDADA), NewConstant(VarToStr(AComisionID), datString), dboEqual); + if IsEmpty then + Expression := Condicion + else + Expression := NewBinaryExpression(Expression, Condicion, dboAnd); + end; + + if not VarIsNull(AAgenteID) then + begin + Condicion := NewBinaryExpression(NewField('', fld_Facturas_ComisionID_AGENTE), NewConstant(VarToStr(AAgenteID), datString), dboEqual); + if IsEmpty then + Expression := Condicion + else + Expression := NewBinaryExpression(Expression, Condicion, dboAnd); + end; + + if (Length(FechaIni) > 0) + and (Length(FechaFin) > 0) then + begin + // (FECHA_INICIO between FECHA_FIN) + Condicion := NewBinaryExpression(NewField('', fld_Facturas_ComisionFecha), NewConstant(FechaIni, datString), dboGreaterOrEqual); + Condicion := NewBinaryExpression(NewBinaryExpression(NewField('', fld_Facturas_ComisionFecha), NewConstant(FechaFin, datString), dboLessOrEqual), Condicion, dboAnd); + + if IsEmpty then + Expression := Condicion + else + Expression := NewBinaryExpression(Expression, Condicion, dboAnd); + end; + end; + + dsMaster.Open; + + AStream.Clear; + Bin2DataStreamer.WriteDataset(AStream, dsMaster, [woRows, woSchema], -1); + Bin2DataStreamer.ReadDataset(AStream, tbl_Comisiones, TRUE, '', TRUE, TRUE); + + if DesglosadoProv then + begin + AInforme := DarRutaFichero(DarRutaInformes, rptComisionDesglosado, tbl_Comisiones.FieldByName('ID_EMPRESA').AsString); + if VarIsNull(AInforme) then + raise Exception.Create (('Error Servidor: _GenerarComision, no encuentra informe ' + rptComisionDesglosado)); + + frxReport.LoadFromFile(AInforme, True); + end + else + begin + AInforme := DarRutaFichero(DarRutaInformes, rptComision, tbl_Comisiones.FieldByName('ID_EMPRESA').AsString); + if VarIsNull(AInforme) then + raise Exception.Create (('Error Servidor: _GenerarComision, no encuentra informe ' + rptComision)); + + frxReport.LoadFromFile(AInforme, True); + end; + + frxReport.Variables['FechaIni'] := QuotedStr(FechaIni); + frxReport.Variables['FechaFin'] := QuotedStr(FechaFin); + frxReport.PrepareReport; + frxReport.PreviewPages.SaveToStream(Result); + finally + AStream.Free; + dsMaster := Nil; + FConnection.RollbackTransaction; + end; +end; + +end. diff --git a/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.dfm b/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.dfm index c189d76..63ea0f5 100644 --- a/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.dfm +++ b/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.dfm @@ -77,12 +77,7 @@ object srvComisiones: TsrvComisiones Diagrams = Diagrams Datasets = < item - Params = < - item - Name = 'ID_COMISION' - Value = '' - ParamType = daptInput - end> + Params = <> Statements = < item Connection = 'IBX' @@ -104,9 +99,8 @@ object srvComisiones: TsrvComisiones 'V_AGENTES_COMISIONES_DET_FAC.ID_AGENTE)'#10'LEFT JOIN CONTACTOS CONT' + 'ACTOS2 ON (CONTACTOS2.ID = V_AGENTES_COMISIONES_DET_FAC.ID_CLIEN' + 'TE)'#10'LEFT JOIN CONTACTOS CONTACTOS3 ON (CONTACTOS3.ID = V_AGENTES' + - '_COMISIONES_DET_FAC.ID_PROVEEDOR)'#10'WHERE V_AGENTES_COMISIONES_DET' + - '_FAC.ID_COMISION_LIQUIDADA = :ID_COMISION'#10'GROUP BY 1, 2, 3, 4, 5' + - ', 6, 7, 8, 9, 10, 11, 12, 13' + '_COMISIONES_DET_FAC.ID_PROVEEDOR)'#10' WHERE {Where}'#10'GROUP BY 1, 2,' + + ' 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13'#10 StatementType = stSQL ColumnMappings = < item @@ -249,7 +243,7 @@ object srvComisiones: TsrvComisiones end item Name = 'IMPORTE_COMISION' - DataType = datCurrency + DataType = datFloat DictionaryEntry = 'Facturas_Comision_IMPORTE_COMISION' end> end @@ -350,6 +344,7 @@ object srvComisiones: TsrvComisiones Name = 'NOMBRE' DataType = datString Size = 255 + ServerAutoRefresh = True DictionaryEntry = 'Comisiones_NOMBRE' end> end @@ -376,8 +371,8 @@ object srvComisiones: TsrvComisiones ' V_AGENTES_COMISIONES_DET_FAC.ID_AGENTE)'#10'LEFT JOIN CONTACTOS CON' + 'TACTOS2 ON (CONTACTOS2.ID = V_AGENTES_COMISIONES_DET_FAC.ID_CLIE' + 'NTE)'#10'LEFT JOIN CONTACTOS CONTACTOS3 ON (CONTACTOS3.ID = V_AGENTE' + - 'S_COMISIONES_DET_FAC.ID_PROVEEDOR)'#10'GROUP BY 1, 2, 3, 4, 5, 6, 7,' + - ' 8, 9, 10, 11, 12, 13' + 'S_COMISIONES_DET_FAC.ID_PROVEEDOR)'#10'where {where}'#10'GROUP BY 1, 2, ' + + '3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13'#10 StatementType = stSQL ColumnMappings = < item @@ -519,7 +514,7 @@ object srvComisiones: TsrvComisiones end item Name = 'IMPORTE_COMISION' - DataType = datCurrency + DataType = datFloat DictionaryEntry = 'V_Detalles_Facturas_Comision_IMPORTE_COMISION' end> end> @@ -754,7 +749,15 @@ object srvComisiones: TsrvComisiones end> Name = 'Update_Comisiones' end> - RelationShips = <> + RelationShips = < + item + Name = 'FK_Comision_Facturas' + MasterDatasetName = 'Comisiones' + MasterFields = 'ID' + DetailDatasetName = 'Facturas_Comision' + DetailFields = 'ID_COMISION_LIQUIDADA' + RelationshipType = rtForeignKey + end> UpdateRules = < item Name = 'Insert Comisiones' @@ -819,7 +822,7 @@ object srvComisiones: TsrvComisiones DeleteCommandName = 'Delete_Comisiones' UpdateCommandName = 'Update_Comisiones' ReferencedDataset = 'Comisiones' - ProcessorOptions = [poPrepareCommands] + ProcessorOptions = [poAutoGenerateRefreshDataset, poPrepareCommands] UpdateMode = updWhereKeyOnly Left = 248 Top = 24 diff --git a/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.pas b/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.pas index 952d92e..a4ff988 100644 --- a/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.pas +++ b/Source/Modulos/Comisiones/Servidor/srvComisiones_Impl.pas @@ -38,8 +38,9 @@ implementation {$R *.dfm} uses - {Generated:} FactuGES_Invk, uDataModuleServer, - uDatabaseUtils, schComisionesClient_Intf, uRestriccionesUsuarioUtils; + {Generated:} FactuGES_Invk, uDataModuleServer, + uDatabaseUtils, schComisionesClient_Intf, uRestriccionesUsuarioUtils, + uBizComisionesServer, uRptComisiones_Server; procedure Create_srvComisiones(out anInstance : IUnknown); begin @@ -50,6 +51,8 @@ end; procedure TsrvComisiones.DARemoteServiceCreate(Sender: TObject); begin //SessionManager := dmServer.SessionManager; + //SessionManager := dmServer.SessionManager; + bpComisiones.BusinessRulesID := BIZ_SERVER_COMISIONES; end; procedure TsrvComisiones.DataAbstractServiceBeforeAcquireConnection( @@ -61,16 +64,15 @@ end; function TsrvComisiones.GenerateReport(const AComisionID: Variant; const DesglosadoProv: Boolean; const FechaIni, FechaFin: String; const AAgenteID: Variant): Binary; -//var -// AReportGenerator : TRptComisiones; +var + AReportGenerator : TRptComisiones; begin -{ AReportGenerator := TRptComisiones.Create(nil); + AReportGenerator := TRptComisiones.Create(nil); try Result := AReportGenerator.GenerarComision(AComisionID, DesglosadoProv, FechaIni, FechaFin, AAgenteID); finally FreeAndNIL(AReportGenerator); end; -} end; initialization diff --git a/Source/Modulos/Comisiones/Views/Comisiones_view.dpk b/Source/Modulos/Comisiones/Views/Comisiones_view.dpk index 05b4864..23f3427 100644 --- a/Source/Modulos/Comisiones/Views/Comisiones_view.dpk +++ b/Source/Modulos/Comisiones/Views/Comisiones_view.dpk @@ -29,11 +29,62 @@ requires Contactos_controller, Contactos_model, GUIBase, - ApplicationBase; + ApplicationBase, + rtl, + vcl, + dbrtl, + vcldb, + PngComponentsD10, + PNG_D10, + vclactnband, + vclx, + cxLibraryD11, + dxThemeD11, + dxGDIPlusD11, + dxCoreD11, + cxEditorsD11, + cxDataD11, + vcljpg, + DataAbstract_Core_D11, + dsnap, + adortl, + RemObjects_Core_D11, + GUISDK_D11R, + designide, + xmlrtl, + dxLayoutControlD11, + dxComnD11, + JvCoreD11R, + JclVcl, + Jcl, + JvAppFrmD11R, + JvCtrlsD11R, + JvSystemD11R, + JvStdCtrlsD11R, + cxGridD11, + cxPageControlD11, + cxExtEditorsD11, + cxExportD11, + tb2k_d10, + tbx_d10, + JvPageCompsD11R, + frx11, + fs11, + fqb110, + bdertl, + frxe11, + frxTee11, + fsTee11, + tee, + teeUI; contains uComisionesViewRegister in 'uComisionesViewRegister.pas', uViewComisiones in 'uViewComisiones.pas' {frViewComisiones: TFrame}, - uEditorComisiones in 'uEditorComisiones.pas' {fEditorComisiones: TfEditorComisiones}; + uEditorComisiones in 'uEditorComisiones.pas' {fEditorComisiones: TfEditorComisiones}, + uViewComision in 'uViewComision.pas' {frViewComision: TFrame}, + uViewFacturasComision in 'uViewFacturasComision.pas' {frViewFacturasComision: TFrame}, + uEditorComision in 'uEditorComision.pas' {fEditorComision: TfEditorComision}, + uEditorComisionesReport in 'uEditorComisionesReport.pas' {fEditorComisionesReport: TfEditorComisionesReport}; end. diff --git a/Source/Modulos/Comisiones/Views/Comisiones_view.dproj b/Source/Modulos/Comisiones/Views/Comisiones_view.dproj index 8620c06..67910f7 100644 --- a/Source/Modulos/Comisiones/Views/Comisiones_view.dproj +++ b/Source/Modulos/Comisiones/Views/Comisiones_view.dproj @@ -31,70 +31,92 @@ Delphi.Personality Package - - False - True - False - - - False - False - False - - - True - False - 1 - 0 - 0 - 0 - False - False - False - False - False - 3082 - 1252 - - - - - 1.0.0.0 - - - - - - 1.0.0.0 - - - - Comisiones_view.dpk - - +FalseTrueFalseFalseFalseFalseTrueFalse1000FalseFalseFalseFalseFalse308212521.0.0.01.0.0.0Comisiones_view.dpk MainSource - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fEditorComision
+ TfEditorComisiones +
fEditorComisiones
TfEditorComisiones
+ +
fEditorComisionesRepor
+ TfEditorComisiones +
+ +
frViewComision
+ TFrame +
frViewComisiones
TFrame
+ +
frViewFacturasComision
+ TFrame +
+ + + + + +
-