From e78c983d16f822df82bef897675c046e52226949 Mon Sep 17 00:00:00 2001 From: roberto Date: Fri, 23 May 2008 14:56:32 +0000 Subject: [PATCH] Se cambia el editorFacturacliente para que se desactiven los eventos cuando cerramos el editor y no ningun error (es el clasico error deltas safe,......) git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@234 f4e31baf-9722-1c47-927c-6f952f962d4b --- .../View/uIEditorFacturasClientePreview.pas | 3 - .../Controller/uFacturasClienteController.pas | 95 ++++++++++--------- .../uFacturasClienteReportController.pas | 3 +- .../Data/uDataModuleFacturasCliente.pas | 1 - .../Model/uBizFacturasCliente.pas | 3 - .../Views/uEditorFacturaCliente.dfm | 38 ++------ .../Views/uEditorFacturaCliente.pas | 13 ++- .../Views/uEditorFacturasCliente.pas | 2 +- .../Views/uEditorFacturasClienteReport.dfm | 7 +- .../Views/uEditorFacturasClienteReport.pas | 13 +-- 10 files changed, 78 insertions(+), 100 deletions(-) diff --git a/Source/Modulos/Facturas de cliente/Controller/View/uIEditorFacturasClientePreview.pas b/Source/Modulos/Facturas de cliente/Controller/View/uIEditorFacturasClientePreview.pas index 6b7abc2a..97fe3df0 100644 --- a/Source/Modulos/Facturas de cliente/Controller/View/uIEditorFacturasClientePreview.pas +++ b/Source/Modulos/Facturas de cliente/Controller/View/uIEditorFacturasClientePreview.pas @@ -8,9 +8,6 @@ uses type IEditorFacturasClientePreview = interface(IEditorPreview) ['{0B893ED1-261A-4358-814E-18D7FD768E14}'] -{ function PreviewGetController : IFacturasClienteReportController; - procedure PreviewSetController (const Value : IFacturasClienteReportController); - property PreviewController : IFacturasClienteReportController read PreviewGetController write PreviewSetController;} end; diff --git a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas index 3fe8c882..32cf2c02 100644 --- a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas +++ b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteController.pas @@ -426,10 +426,20 @@ end; function TFacturasClienteController.BuscarTodasPendientesComision(IdAgente:Integer; IdComision: Integer; IdFacturasAsociadas: String): IBizFacturaCliente; var Condicion: TDAWhereExpression; + Condicion1: TDAWhereExpression; + Condicion2: TDAWhereExpression; + Condicion3: TDAWhereExpression; + Condicion4: TDAWhereExpression; + + Cadena : TStringList; + i: Integer; + begin ShowHourglassCursor; try Result := BuscarTodos; + +{//Desactivamos comisiones por AGENTE with Result.DataTable.DynamicWhere do begin //Todas las facturas de un agente determinado @@ -440,14 +450,49 @@ begin else Expression := NewBinaryExpression(Expression, Condicion, dboAnd); end; +} with Result.DataTable.DynamicWhere do begin - //Todas aquellas que no esten asociadas a ninguna comisión o asociadas a la comisión, - //pero no asociadas en el editor de la comision, esto es porque se puede agregar y quitar - //facturas y todos los cambios estan el cache y por lo tanto al pedir las facturas a seleccionar - //debemos tener en cuenta dichso cambios en cache - Condicion := NewBinaryExpression(NewField('', fld_FacturasClienteID_COMISION_LIQUIDADA), NewNull(), dboEqual); + //Todas las facturas de esta liquidación + Condicion1 := NewBinaryExpression(NewField('', fld_FacturasClienteID_COMISION_LIQUIDADA), NewConstant(IdComision, datInteger), dboEqual); + + //Todas aquellas facturas que ya esten asociadas a la liquidación actual no deben salir + if (Length(IdFacturasAsociadas) > 0) then + begin + Cadena := TStringList.Create; + Cadena.CommaText := IdFacturasAsociadas; + Condicion2 := nil; + //Vamos generando todas las where de cada uno de los ID recibidos por parametro + for i := 0 to Cadena.Count - 1 do + with Result.DataTable.DynamicWhere do + begin + Condicion4 := NewBinaryExpression(NewField('', fld_FacturasClienteID), NewConstant(StrToInt(Cadena.Strings[i]), datInteger), dboNotEqual); + if Condicion2 = nil then + Condicion2 := Condicion4 + else + Condicion2 := NewBinaryExpression(Condicion2, Condicion4, dboAnd); + end; + + Cadena.Free; + end; + + //Todas aquellas que no esten asociadas a ninguna liquidación, y que tampoco esten en el editor, ya que en cache estan + //asociadas a la liquidadcion pero en datos me viene como nula + Condicion3 := NewBinaryExpression(NewField('', fld_FacturasClienteID_COMISION_LIQUIDADA), NewNull(), dboEqual); + + //Si no hay facturas en el editor no las tenemos en cuenta + if (Condicion2 <> nil) then + begin + Condicion1 := NewBinaryExpression(Condicion1, Condicion2, dboAnd); + Condicion3 := NewBinaryExpression(Condicion3, Condicion2, dboAnd); + end; + + // Todas aquellas facturas asociadas a la comisión actual y que no estén asociadas al editor (IdFacturasAsociadas) + //esto es porque se puede agregar y quitar facturas y todos los cambios estan en cache + // y por lo tanto al pedir las facturas a seleccionar debemos tener en cuenta que en el + //almacén dichos cambios cache todavía no se han producido + Condicion := NewBinaryExpression(Condicion1, Condicion3, dboOr); if IsEmpty then Expression := Condicion @@ -455,44 +500,6 @@ begin Expression := NewBinaryExpression(Expression, Condicion, dboAnd); end; -{REPASARRRRRRR - //Quitamos aquellas que ya están asociadas - if length(IdFacturasAsociadas) > 0 then - with Result.DataTable.DynamicWhere do - begin - Condicion := NewBinaryExpression(NewField('', fld_FacturasClienteID), ' not in (' + IdFacturasAsociadas + ')');, dboEqual); - - if IsEmpty then - Expression := Condicion - else - Expression := NewBinaryExpression(Expression, Condicion, dboAnd); - end; - - with Result.DataTable.Where do - begin - - CLOSEBraket; - AddOperator(opOR); - - OpenBraket; - //En caso de ser facturas ya asociadas lo limitamos a la comision actual - //ya que no debemos poder elegir facturas asociadas a otras comisiones - OpenBraket; - AddText(fld_FacturasClienteID_COMISION_LIQUIDADA + ' = ' + IntToStr(IdComision)); - CloseBraket; - //En el caso de que halla facturas asociadas - if length(IdFacturasAsociadas) > 0 then - begin - AddOperator(opAND); - OpenBraket; - AddText(fld_FacturasClienteID + ' not in (' + IdFacturasAsociadas + ')'); - CloseBraket; - end; - CloseBraket; - - CloseBraket; - end; -} finally HideHourglassCursor; end; @@ -645,7 +652,7 @@ begin //En caso de ser un Abono no podra tener un importe total positivo if (AFactura.TIPO = CTE_TIPO_ABONO) then if (AFactura.IMPORTE_TOTAL >= 0) then - raise Exception.Create('Un abono nunca no puede tener un importe positivo'); + raise Exception.Create('Un abono nunca no puede tener un importe positivo, asegurese que las cantidades sean negativas'); { Asegurarse de valores en campos "automáticos" tanto en MODIFICACIÓN como en INSERCIÓN. } diff --git a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteReportController.pas b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteReportController.pas index fd029af2..8608589d 100644 --- a/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteReportController.pas +++ b/Source/Modulos/Facturas de cliente/Controller/uFacturasClienteReportController.pas @@ -17,8 +17,7 @@ type TFacturasClienteReportController = class(TInterfacedObject, IFacturasClienteReportController) private FDataModule : IDataModuleFacturasClienteReport; - function CreateEditor(const AName: String; const IID: TGUID; - out Intf): Boolean; + function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean; public constructor Create; destructor Destroy; override; diff --git a/Source/Modulos/Facturas de cliente/Data/uDataModuleFacturasCliente.pas b/Source/Modulos/Facturas de cliente/Data/uDataModuleFacturasCliente.pas index 82ccccb7..d576cff9 100644 --- a/Source/Modulos/Facturas de cliente/Data/uDataModuleFacturasCliente.pas +++ b/Source/Modulos/Facturas de cliente/Data/uDataModuleFacturasCliente.pas @@ -111,7 +111,6 @@ begin // EL CAMPO REFERENCIA TIENE QUE SER AUTOREFRESH!!!!! AFactura.FieldByName(fld_FacturasClienteREFERENCIA).ServerAutoRefresh := TRUE; - AFactura.BusinessRulesID := BIZ_CLIENT_FACTURA_CLIENTE; with TBizFacturaCliente(AFactura.BusinessEventsObj) do diff --git a/Source/Modulos/Facturas de cliente/Model/uBizFacturasCliente.pas b/Source/Modulos/Facturas de cliente/Model/uBizFacturasCliente.pas index 891fea82..f4f2d91a 100644 --- a/Source/Modulos/Facturas de cliente/Model/uBizFacturasCliente.pas +++ b/Source/Modulos/Facturas de cliente/Model/uBizFacturasCliente.pas @@ -256,11 +256,8 @@ begin IVA := AppFactuGES.EmpresaActiva.IVA; RE := 0; SITUACION := CTE_PENDIENTE; - - //TEMPORAL ID_TIENDA := AppFactuGES.VAR_IDTIENDA; TIENDA := AppFactuGES.VAR_TIENDA; - IGNORAR_CONTABILIDAD := 0; end; diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm index bf8a0094..1512b4ff 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.dfm @@ -75,12 +75,12 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente ExplicitLeft = 3 ExplicitTop = 79 ExplicitWidth = 765 - ExplicitHeight = 378 + ExplicitHeight = 398 inherited pagGeneral: TTabSheet ExplicitLeft = 4 ExplicitTop = 24 ExplicitWidth = 757 - ExplicitHeight = 350 + ExplicitHeight = 370 inline frViewFacturaCliente1: TfrViewFacturaCliente Left = 0 Top = 0 @@ -96,38 +96,18 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente TabOrder = 0 ReadOnly = False ExplicitWidth = 757 - ExplicitHeight = 350 + ExplicitHeight = 370 inherited dxLayoutControl1: TdxLayoutControl Width = 757 Height = 370 ExplicitWidth = 757 - ExplicitHeight = 350 - inherited eReferencia: TcxDBTextEdit - ExplicitWidth = 159 - Width = 159 - end - inherited edtFecha: TcxDBDateEdit - ExplicitWidth = 159 - Width = 159 - end + ExplicitHeight = 370 inherited memObservaciones: TcxDBMemo ExplicitWidth = 301 ExplicitHeight = 159 Height = 159 Width = 301 end - inherited cbFormaPago: TcxDBLookupComboBox - ExplicitWidth = 78 - Width = 78 - end - inherited frViewTienda1: TfrViewTienda - inherited dxLayoutControl1: TdxLayoutControl - inherited cbTienda: TcxComboBox - ExplicitWidth = 399 - Width = 399 - end - end - end inherited frViewClienteFactura1: TfrViewClienteFactura Width = 314 ExplicitWidth = 314 @@ -184,7 +164,6 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente object pagContenido: TTabSheet Caption = 'Contenido' ImageIndex = 1 - ExplicitHeight = 350 inline frViewDetallesFacturaCliente1: TfrViewDetallesFacturaCliente Left = 0 Top = 0 @@ -202,7 +181,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente TabOrder = 0 ReadOnly = False ExplicitWidth = 757 - ExplicitHeight = 350 + ExplicitHeight = 370 inherited ToolBar1: TToolBar Width = 757 ExplicitWidth = 757 @@ -267,7 +246,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente Width = 757 Height = 298 ExplicitWidth = 757 - ExplicitHeight = 278 + ExplicitHeight = 298 end inherited TBXDock1: TTBXDock Width = 757 @@ -281,7 +260,6 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente object pagContabilidad: TTabSheet Caption = 'Contabilidad' ImageIndex = 2 - ExplicitHeight = 350 inline frViewListaSubcuentas1: TfrViewListaSubcuentas Left = 0 Top = 0 @@ -329,7 +307,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente item Width = 200 end> - ExplicitTop = 623 + ExplicitTop = 643 ExplicitWidth = 771 end inline frViewTotales1: TfrViewTotales [4] @@ -346,7 +324,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente ParentFont = False TabOrder = 4 ReadOnly = False - ExplicitTop = 460 + ExplicitTop = 480 ExplicitWidth = 771 ExplicitHeight = 163 inherited dxLayoutControl1: TdxLayoutControl diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas index aaf9244b..7a51b082 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturaCliente.pas @@ -42,6 +42,7 @@ type procedure frViewTotales1ePortePropertiesValidate(Sender: TObject; var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); procedure frViewTotales1ePorteEditing(Sender: TObject; var CanEdit: Boolean); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); override; //Importante en este punto se deben de quitar los eventos que puedan afectar a la tabla una vez se cierre el editor. private procedure RecalcularPortePorUnidad; @@ -147,6 +148,15 @@ begin end; end; +procedure TfEditorFacturaCliente.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + frViewTotales1.cbRecargoEquivalencia.Properties.OnEditValueChanged := nil; + frViewTotales1.eIVA.Properties.OnValidate := nil; + frViewTotales1.ePorte.Properties.OnValidate := nil; + + inherited; +end; + procedure TfEditorFacturaCliente.FormShow(Sender: TObject); begin inherited; @@ -218,6 +228,7 @@ procedure TfEditorFacturaCliente.frViewTotales1ePorteEditing(Sender: TObject; var CanEdit: Boolean); begin inherited; + if FFactura.TIPO = CTE_TIPO_ABONO then CanEdit := False; end; @@ -285,7 +296,7 @@ begin begin ShowInfoMessage('El abono se ha dado de alta con el código ' + FFactura.REFERENCIA); //Preguntamos is desea hacer una orden de devolución asociada - if (Application.MessageBox('¿Desea crear una orden de devolución para el abono?', 'Atención', MB_YESNO) = IDYES) then +// if (Application.MessageBox('¿Desea crear una orden de devolución para el abono?', 'Atención', MB_YESNO) = IDYES) then // GenerarAlbaranCli(FFactura); end; end; diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas index 7cb281b6..037bf147 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasCliente.pas @@ -306,7 +306,7 @@ begin GenerarFacturaCli; actRefrescar.Execute; end; - 100 : begin // Albaran nuevo vacio + 100 : begin // Factura nueva vacia if FController.Anadir(Facturas) then FController.Ver(Facturas); end; diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.dfm b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.dfm index 4812f26e..8fe5b073 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.dfm +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.dfm @@ -1,10 +1,7 @@ inherited fEditorFacturasClientePreview: TfEditorFacturasClientePreview Caption = 'Previsualizar la factura' + ExplicitWidth = 954 + ExplicitHeight = 543 PixelsPerInch = 96 TextHeight = 13 - inherited frxReport1: TfrxReport - Datasets = <> - Variables = <> - Style = <> - end end diff --git a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.pas b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.pas index 7961197e..59241109 100644 --- a/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.pas +++ b/Source/Modulos/Facturas de cliente/Views/uEditorFacturasClienteReport.pas @@ -5,26 +5,19 @@ interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uEditorPreview, -{ frxExportImage, frxExportPDF, frxDCtrl, frxClass, frxDMPExport, frxGradient, - frxChBox, frxCross, frxRich, frxChart, frxOLE, frxBarcode, -} JvAppStorage, JvAppRegistryStorage, JvComponentBase, JvFormPlacement, ImgList, PngImageList, StdActns, ActnList, ComCtrls, TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, pngimage, ExtCtrls, JvExControls, JvComponent, JvNavigationPane, uIEditorFacturasClientePreview, - JvExComCtrls, JvStatusBar; + JvExComCtrls, JvStatusBar, frxExportText, frxExportRTF, frxExportMail, + frxExportXLS, frxExportImage, frxExportPDF, frxClass, frxDCtrl, frxGradient, + frxChBox, frxCross, frxRich, frxOLE, frxBarcode; type TfEditorFacturasClientePreview = class(TfEditorPreview, IEditorFacturasClientePreview) - private - { Private declarations } - public - { Public declarations } end; - implementation - {$R *.dfm} end.