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
This commit is contained in:
roberto 2008-05-23 14:56:32 +00:00
parent f930230d7b
commit e78c983d16
10 changed files with 78 additions and 100 deletions

View File

@ -8,9 +8,6 @@ uses
type type
IEditorFacturasClientePreview = interface(IEditorPreview) IEditorFacturasClientePreview = interface(IEditorPreview)
['{0B893ED1-261A-4358-814E-18D7FD768E14}'] ['{0B893ED1-261A-4358-814E-18D7FD768E14}']
{ function PreviewGetController : IFacturasClienteReportController;
procedure PreviewSetController (const Value : IFacturasClienteReportController);
property PreviewController : IFacturasClienteReportController read PreviewGetController write PreviewSetController;}
end; end;

View File

@ -426,10 +426,20 @@ end;
function TFacturasClienteController.BuscarTodasPendientesComision(IdAgente:Integer; IdComision: Integer; IdFacturasAsociadas: String): IBizFacturaCliente; function TFacturasClienteController.BuscarTodasPendientesComision(IdAgente:Integer; IdComision: Integer; IdFacturasAsociadas: String): IBizFacturaCliente;
var var
Condicion: TDAWhereExpression; Condicion: TDAWhereExpression;
Condicion1: TDAWhereExpression;
Condicion2: TDAWhereExpression;
Condicion3: TDAWhereExpression;
Condicion4: TDAWhereExpression;
Cadena : TStringList;
i: Integer;
begin begin
ShowHourglassCursor; ShowHourglassCursor;
try try
Result := BuscarTodos; Result := BuscarTodos;
{//Desactivamos comisiones por AGENTE
with Result.DataTable.DynamicWhere do with Result.DataTable.DynamicWhere do
begin begin
//Todas las facturas de un agente determinado //Todas las facturas de un agente determinado
@ -440,14 +450,49 @@ begin
else else
Expression := NewBinaryExpression(Expression, Condicion, dboAnd); Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end; end;
}
with Result.DataTable.DynamicWhere do with Result.DataTable.DynamicWhere do
begin begin
//Todas aquellas que no esten asociadas a ninguna comisión o asociadas a la comisión, //Todas las facturas de esta liquidación
//pero no asociadas en el editor de la comision, esto es porque se puede agregar y quitar Condicion1 := NewBinaryExpression(NewField('', fld_FacturasClienteID_COMISION_LIQUIDADA), NewConstant(IdComision, datInteger), dboEqual);
//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 //Todas aquellas facturas que ya esten asociadas a la liquidación actual no deben salir
Condicion := NewBinaryExpression(NewField('', fld_FacturasClienteID_COMISION_LIQUIDADA), NewNull(), dboEqual); 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 if IsEmpty then
Expression := Condicion Expression := Condicion
@ -455,44 +500,6 @@ begin
Expression := NewBinaryExpression(Expression, Condicion, dboAnd); Expression := NewBinaryExpression(Expression, Condicion, dboAnd);
end; 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 finally
HideHourglassCursor; HideHourglassCursor;
end; end;
@ -645,7 +652,7 @@ begin
//En caso de ser un Abono no podra tener un importe total positivo //En caso de ser un Abono no podra tener un importe total positivo
if (AFactura.TIPO = CTE_TIPO_ABONO) then if (AFactura.TIPO = CTE_TIPO_ABONO) then
if (AFactura.IMPORTE_TOTAL >= 0) 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 { Asegurarse de valores en campos "automáticos" tanto
en MODIFICACIÓN como en INSERCIÓN. } en MODIFICACIÓN como en INSERCIÓN. }

View File

@ -17,8 +17,7 @@ type
TFacturasClienteReportController = class(TInterfacedObject, IFacturasClienteReportController) TFacturasClienteReportController = class(TInterfacedObject, IFacturasClienteReportController)
private private
FDataModule : IDataModuleFacturasClienteReport; FDataModule : IDataModuleFacturasClienteReport;
function CreateEditor(const AName: String; const IID: TGUID; function CreateEditor(const AName: String; const IID: TGUID; out Intf): Boolean;
out Intf): Boolean;
public public
constructor Create; constructor Create;
destructor Destroy; override; destructor Destroy; override;

View File

@ -111,7 +111,6 @@ begin
// EL CAMPO REFERENCIA TIENE QUE SER AUTOREFRESH!!!!! // EL CAMPO REFERENCIA TIENE QUE SER AUTOREFRESH!!!!!
AFactura.FieldByName(fld_FacturasClienteREFERENCIA).ServerAutoRefresh := TRUE; AFactura.FieldByName(fld_FacturasClienteREFERENCIA).ServerAutoRefresh := TRUE;
AFactura.BusinessRulesID := BIZ_CLIENT_FACTURA_CLIENTE; AFactura.BusinessRulesID := BIZ_CLIENT_FACTURA_CLIENTE;
with TBizFacturaCliente(AFactura.BusinessEventsObj) do with TBizFacturaCliente(AFactura.BusinessEventsObj) do

View File

@ -256,11 +256,8 @@ begin
IVA := AppFactuGES.EmpresaActiva.IVA; IVA := AppFactuGES.EmpresaActiva.IVA;
RE := 0; RE := 0;
SITUACION := CTE_PENDIENTE; SITUACION := CTE_PENDIENTE;
//TEMPORAL
ID_TIENDA := AppFactuGES.VAR_IDTIENDA; ID_TIENDA := AppFactuGES.VAR_IDTIENDA;
TIENDA := AppFactuGES.VAR_TIENDA; TIENDA := AppFactuGES.VAR_TIENDA;
IGNORAR_CONTABILIDAD := 0; IGNORAR_CONTABILIDAD := 0;
end; end;

View File

@ -75,12 +75,12 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
ExplicitLeft = 3 ExplicitLeft = 3
ExplicitTop = 79 ExplicitTop = 79
ExplicitWidth = 765 ExplicitWidth = 765
ExplicitHeight = 378 ExplicitHeight = 398
inherited pagGeneral: TTabSheet inherited pagGeneral: TTabSheet
ExplicitLeft = 4 ExplicitLeft = 4
ExplicitTop = 24 ExplicitTop = 24
ExplicitWidth = 757 ExplicitWidth = 757
ExplicitHeight = 350 ExplicitHeight = 370
inline frViewFacturaCliente1: TfrViewFacturaCliente inline frViewFacturaCliente1: TfrViewFacturaCliente
Left = 0 Left = 0
Top = 0 Top = 0
@ -96,38 +96,18 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
TabOrder = 0 TabOrder = 0
ReadOnly = False ReadOnly = False
ExplicitWidth = 757 ExplicitWidth = 757
ExplicitHeight = 350 ExplicitHeight = 370
inherited dxLayoutControl1: TdxLayoutControl inherited dxLayoutControl1: TdxLayoutControl
Width = 757 Width = 757
Height = 370 Height = 370
ExplicitWidth = 757 ExplicitWidth = 757
ExplicitHeight = 350 ExplicitHeight = 370
inherited eReferencia: TcxDBTextEdit
ExplicitWidth = 159
Width = 159
end
inherited edtFecha: TcxDBDateEdit
ExplicitWidth = 159
Width = 159
end
inherited memObservaciones: TcxDBMemo inherited memObservaciones: TcxDBMemo
ExplicitWidth = 301 ExplicitWidth = 301
ExplicitHeight = 159 ExplicitHeight = 159
Height = 159 Height = 159
Width = 301 Width = 301
end 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 inherited frViewClienteFactura1: TfrViewClienteFactura
Width = 314 Width = 314
ExplicitWidth = 314 ExplicitWidth = 314
@ -184,7 +164,6 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
object pagContenido: TTabSheet object pagContenido: TTabSheet
Caption = 'Contenido' Caption = 'Contenido'
ImageIndex = 1 ImageIndex = 1
ExplicitHeight = 350
inline frViewDetallesFacturaCliente1: TfrViewDetallesFacturaCliente inline frViewDetallesFacturaCliente1: TfrViewDetallesFacturaCliente
Left = 0 Left = 0
Top = 0 Top = 0
@ -202,7 +181,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
TabOrder = 0 TabOrder = 0
ReadOnly = False ReadOnly = False
ExplicitWidth = 757 ExplicitWidth = 757
ExplicitHeight = 350 ExplicitHeight = 370
inherited ToolBar1: TToolBar inherited ToolBar1: TToolBar
Width = 757 Width = 757
ExplicitWidth = 757 ExplicitWidth = 757
@ -267,7 +246,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
Width = 757 Width = 757
Height = 298 Height = 298
ExplicitWidth = 757 ExplicitWidth = 757
ExplicitHeight = 278 ExplicitHeight = 298
end end
inherited TBXDock1: TTBXDock inherited TBXDock1: TTBXDock
Width = 757 Width = 757
@ -281,7 +260,6 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
object pagContabilidad: TTabSheet object pagContabilidad: TTabSheet
Caption = 'Contabilidad' Caption = 'Contabilidad'
ImageIndex = 2 ImageIndex = 2
ExplicitHeight = 350
inline frViewListaSubcuentas1: TfrViewListaSubcuentas inline frViewListaSubcuentas1: TfrViewListaSubcuentas
Left = 0 Left = 0
Top = 0 Top = 0
@ -329,7 +307,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
item item
Width = 200 Width = 200
end> end>
ExplicitTop = 623 ExplicitTop = 643
ExplicitWidth = 771 ExplicitWidth = 771
end end
inline frViewTotales1: TfrViewTotales [4] inline frViewTotales1: TfrViewTotales [4]
@ -346,7 +324,7 @@ inherited fEditorFacturaCliente: TfEditorFacturaCliente
ParentFont = False ParentFont = False
TabOrder = 4 TabOrder = 4
ReadOnly = False ReadOnly = False
ExplicitTop = 460 ExplicitTop = 480
ExplicitWidth = 771 ExplicitWidth = 771
ExplicitHeight = 163 ExplicitHeight = 163
inherited dxLayoutControl1: TdxLayoutControl inherited dxLayoutControl1: TdxLayoutControl

View File

@ -42,6 +42,7 @@ type
procedure frViewTotales1ePortePropertiesValidate(Sender: TObject; procedure frViewTotales1ePortePropertiesValidate(Sender: TObject;
var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean); var DisplayValue: Variant; var ErrorText: TCaption; var Error: Boolean);
procedure frViewTotales1ePorteEditing(Sender: TObject; var CanEdit: 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 private
procedure RecalcularPortePorUnidad; procedure RecalcularPortePorUnidad;
@ -147,6 +148,15 @@ begin
end; end;
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); procedure TfEditorFacturaCliente.FormShow(Sender: TObject);
begin begin
inherited; inherited;
@ -218,6 +228,7 @@ procedure TfEditorFacturaCliente.frViewTotales1ePorteEditing(Sender: TObject;
var CanEdit: Boolean); var CanEdit: Boolean);
begin begin
inherited; inherited;
if FFactura.TIPO = CTE_TIPO_ABONO then if FFactura.TIPO = CTE_TIPO_ABONO then
CanEdit := False; CanEdit := False;
end; end;
@ -285,7 +296,7 @@ begin
begin begin
ShowInfoMessage('El abono se ha dado de alta con el código ' + FFactura.REFERENCIA); ShowInfoMessage('El abono se ha dado de alta con el código ' + FFactura.REFERENCIA);
//Preguntamos is desea hacer una orden de devolución asociada //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); // GenerarAlbaranCli(FFactura);
end; end;
end; end;

View File

@ -306,7 +306,7 @@ begin
GenerarFacturaCli; GenerarFacturaCli;
actRefrescar.Execute; actRefrescar.Execute;
end; end;
100 : begin // Albaran nuevo vacio 100 : begin // Factura nueva vacia
if FController.Anadir(Facturas) then if FController.Anadir(Facturas) then
FController.Ver(Facturas); FController.Ver(Facturas);
end; end;

View File

@ -1,10 +1,7 @@
inherited fEditorFacturasClientePreview: TfEditorFacturasClientePreview inherited fEditorFacturasClientePreview: TfEditorFacturasClientePreview
Caption = 'Previsualizar la factura' Caption = 'Previsualizar la factura'
ExplicitWidth = 954
ExplicitHeight = 543
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
inherited frxReport1: TfrxReport
Datasets = <>
Variables = <>
Style = <>
end
end end

View File

@ -5,26 +5,19 @@ interface
uses uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, uEditorPreview, Dialogs, uEditorPreview,
{ frxExportImage, frxExportPDF, frxDCtrl, frxClass, frxDMPExport, frxGradient,
frxChBox, frxCross, frxRich, frxChart, frxOLE, frxBarcode,
}
JvAppStorage, JvAppRegistryStorage, JvComponentBase, JvAppStorage, JvAppRegistryStorage, JvComponentBase,
JvFormPlacement, ImgList, PngImageList, StdActns, ActnList, ComCtrls, JvFormPlacement, ImgList, PngImageList, StdActns, ActnList, ComCtrls,
TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, pngimage, TB2ExtItems, TBXExtItems, TBX, TB2Item, TB2Dock, TB2Toolbar, pngimage,
ExtCtrls, JvExControls, JvComponent, JvNavigationPane, uIEditorFacturasClientePreview, ExtCtrls, JvExControls, JvComponent, JvNavigationPane, uIEditorFacturasClientePreview,
JvExComCtrls, JvStatusBar; JvExComCtrls, JvStatusBar, frxExportText, frxExportRTF, frxExportMail,
frxExportXLS, frxExportImage, frxExportPDF, frxClass, frxDCtrl, frxGradient,
frxChBox, frxCross, frxRich, frxOLE, frxBarcode;
type type
TfEditorFacturasClientePreview = class(TfEditorPreview, IEditorFacturasClientePreview) TfEditorFacturasClientePreview = class(TfEditorPreview, IEditorFacturasClientePreview)
private
{ Private declarations }
public
{ Public declarations }
end; end;
implementation implementation
{$R *.dfm} {$R *.dfm}
end. end.