Repaso a los controladores que recalculan importes a partir de los detalles. La posición en la tabla de detalles se perdía y siempre se posicionaba en la primera fila cuando debía conservarse su posición.

git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@195 0c75b7a4-871f-7646-8a2f-f78d34cc349f
This commit is contained in:
David Arranz 2007-12-20 21:07:01 +00:00
parent 636310b6d0
commit 86536f0809
7 changed files with 57 additions and 16 deletions

View File

@ -1007,6 +1007,7 @@ end;
procedure TAlbaranesClienteController.RecalcularImportes(AAlbaran: IBizAlbaranCliente); procedure TAlbaranesClienteController.RecalcularImportes(AAlbaran: IBizAlbaranCliente);
var var
bEnEdicion : Boolean; bEnEdicion : Boolean;
ADetallePosAct : Integer;
begin begin
if not Assigned(AAlbaran) then if not Assigned(AAlbaran) then
raise Exception.Create ('Albarán no asignado (RecalcularImportes)'); raise Exception.Create ('Albarán no asignado (RecalcularImportes)');
@ -1014,19 +1015,28 @@ begin
if AAlbaran.DataTable.Active then if AAlbaran.DataTable.Active then
AAlbaran.DataTable.Active := True; AAlbaran.DataTable.Active := True;
{ Hay que guardar la posición en la que estamos en los detalles por que
la asignación de valores a los campos IMPORTE_NETO e IMPORTE_PORTE
(ver más adelante) colocan el puntero en la tabla detalle al principio.
No he encontrado la razón por la que mueve el puntero. }
ADetallePosAct := AAlbaran.Detalles.POSICION;
bEnEdicion := (AAlbaran.DataTable.State in dsEditModes); bEnEdicion := (AAlbaran.DataTable.State in dsEditModes);
if not bEnEdicion then if not bEnEdicion then
AAlbaran.Edit; AAlbaran.Edit;
ShowHourglassCursor; ShowHourglassCursor;
AAlbaran.Edit;
try try
AAlbaran.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(AAlbaran.Detalles); AAlbaran.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(AAlbaran.Detalles);
AAlbaran.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(AAlbaran.Detalles); AAlbaran.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(AAlbaran.Detalles);
if not bEnEdicion then if not bEnEdicion then
AAlbaran.Post; AAlbaran.Post;
finally finally
HideHourglassCursor; HideHourglassCursor;
// Restaurar la posición que teníamos en los detalles.
FDetallesController.LocalizarPosicion(AAlbaran.Detalles, ADetallePosAct);
end; end;
end; end;

View File

@ -9,8 +9,8 @@ const
{ Data table rules ids { Data table rules ids
Feel free to change them to something more human readable Feel free to change them to something more human readable
but make sure they are unique in the context of your application } but make sure they are unique in the context of your application }
RID_AlbaranesCliente = '{4C4AED7E-9AD2-4F22-B68E-AD7B8F338052}'; RID_AlbaranesCliente = '{4F3DAC26-B5BE-40A1-91BA-40CD8BEE897B}';
RID_AlbaranesCliente_Detalles = '{1F13B20A-918D-41E3-970E-3AC9E0E6BB9B}'; RID_AlbaranesCliente_Detalles = '{B3816F25-6801-4E29-AB34-4AF1CDE62250}';
{ Data table names } { Data table names }
nme_AlbaranesCliente = 'AlbaranesCliente'; nme_AlbaranesCliente = 'AlbaranesCliente';
@ -133,7 +133,7 @@ const
type type
{ IAlbaranesCliente } { IAlbaranesCliente }
IAlbaranesCliente = interface(IDAStronglyTypedDataTable) IAlbaranesCliente = interface(IDAStronglyTypedDataTable)
['{CC452DE4-1563-4ECC-B92C-60D8F9E3350A}'] ['{80396348-69BF-4369-94DC-07953C3A96E7}']
{ Property getters and setters } { Property getters and setters }
function GetIDValue: Integer; function GetIDValue: Integer;
procedure SetIDValue(const aValue: Integer); procedure SetIDValue(const aValue: Integer);
@ -624,7 +624,7 @@ type
{ IAlbaranesCliente_Detalles } { IAlbaranesCliente_Detalles }
IAlbaranesCliente_Detalles = interface(IDAStronglyTypedDataTable) IAlbaranesCliente_Detalles = interface(IDAStronglyTypedDataTable)
['{CD3C0BC2-392C-4937-885E-7396FEC8D6CC}'] ['{BACF8085-2BB1-4129-AB97-303413DC64BD}']
{ Property getters and setters } { Property getters and setters }
function GetIDValue: Integer; function GetIDValue: Integer;
procedure SetIDValue(const aValue: Integer); procedure SetIDValue(const aValue: Integer);

View File

@ -9,13 +9,13 @@ const
{ Delta rules ids { Delta rules ids
Feel free to change them to something more human readable Feel free to change them to something more human readable
but make sure they are unique in the context of your application } but make sure they are unique in the context of your application }
RID_AlbaranesClienteDelta = '{14AC5B6B-A7CC-4A17-846D-4029E0864BF7}'; RID_AlbaranesClienteDelta = '{42ADDC93-7719-4DFF-84AF-D742A6F242D6}';
RID_AlbaranesCliente_DetallesDelta = '{A1C938B1-881C-4020-8257-2103E228E798}'; RID_AlbaranesCliente_DetallesDelta = '{47F5BC56-134A-4CAA-95BF-D9774DFBBFD1}';
type type
{ IAlbaranesClienteDelta } { IAlbaranesClienteDelta }
IAlbaranesClienteDelta = interface(IAlbaranesCliente) IAlbaranesClienteDelta = interface(IAlbaranesCliente)
['{14AC5B6B-A7CC-4A17-846D-4029E0864BF7}'] ['{42ADDC93-7719-4DFF-84AF-D742A6F242D6}']
{ Property getters and setters } { Property getters and setters }
function GetOldIDValue : Integer; function GetOldIDValue : Integer;
function GetOldID_EMPRESAValue : Integer; function GetOldID_EMPRESAValue : Integer;
@ -507,7 +507,7 @@ type
{ IAlbaranesCliente_DetallesDelta } { IAlbaranesCliente_DetallesDelta }
IAlbaranesCliente_DetallesDelta = interface(IAlbaranesCliente_Detalles) IAlbaranesCliente_DetallesDelta = interface(IAlbaranesCliente_Detalles)
['{A1C938B1-881C-4020-8257-2103E228E798}'] ['{47F5BC56-134A-4CAA-95BF-D9774DFBBFD1}']
{ Property getters and setters } { Property getters and setters }
function GetOldIDValue : Integer; function GetOldIDValue : Integer;
function GetOldID_ALBARANValue : Integer; function GetOldID_ALBARANValue : Integer;

View File

@ -827,6 +827,7 @@ procedure TAlbaranesProveedorController.RecalcularImportes(
AAlbaran: IBizAlbaranProveedor); AAlbaran: IBizAlbaranProveedor);
var var
bEnEdicion : Boolean; bEnEdicion : Boolean;
ADetallePosAct : Integer;
begin begin
if not Assigned(AAlbaran) then if not Assigned(AAlbaran) then
raise Exception.Create ('Albarán no asignado (RecalcularImportes)'); raise Exception.Create ('Albarán no asignado (RecalcularImportes)');
@ -834,12 +835,18 @@ begin
if AAlbaran.DataTable.Active then if AAlbaran.DataTable.Active then
AAlbaran.DataTable.Active := True; AAlbaran.DataTable.Active := True;
{ Hay que guardar la posición en la que estamos en los detalles por que
la asignación de valores a los campos IMPORTE_NETO e IMPORTE_PORTE
(ver más adelante) colocan el puntero en la tabla detalle al principio.
No he encontrado la razón por la que mueve el puntero. }
ADetallePosAct := AAlbaran.Detalles.POSICION;
bEnEdicion := (AAlbaran.DataTable.State in dsEditModes); bEnEdicion := (AAlbaran.DataTable.State in dsEditModes);
if not bEnEdicion then if not bEnEdicion then
AAlbaran.Edit; AAlbaran.Edit;
ShowHourglassCursor; ShowHourglassCursor;
AAlbaran.Edit;
try try
AAlbaran.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(AAlbaran.Detalles); AAlbaran.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(AAlbaran.Detalles);
AAlbaran.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(AAlbaran.Detalles); AAlbaran.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(AAlbaran.Detalles);
@ -847,6 +854,8 @@ begin
AAlbaran.Post; AAlbaran.Post;
finally finally
HideHourglassCursor; HideHourglassCursor;
// Restaurar la posición que teníamos en los detalles.
FDetallesController.LocalizarPosicion(AAlbaran.Detalles, ADetallePosAct);
end; end;
end; end;

View File

@ -793,6 +793,11 @@ begin
if AFactura.DataTable.Active then if AFactura.DataTable.Active then
AFactura.DataTable.Active := True; AFactura.DataTable.Active := True;
{ Hay que guardar la posición en la que estamos en los detalles por que
la asignación de valores a los campos IMPORTE_NETO e IMPORTE_PORTE
(ver más adelante) colocan el puntero en la tabla detalle al principio.
No he encontrado la razón por la que mueve el puntero. }
ADetallePosAct := AFactura.Detalles.POSICION; ADetallePosAct := AFactura.Detalles.POSICION;
bEnEdicion := (AFactura.DataTable.State in dsEditModes); bEnEdicion := (AFactura.DataTable.State in dsEditModes);
@ -803,14 +808,13 @@ begin
try try
AFactura.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(AFactura.Detalles); AFactura.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(AFactura.Detalles);
AFactura.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(AFactura.Detalles); AFactura.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(AFactura.Detalles);
FDetallesController.LocalizarPosicion(AFactura.Detalles, ADetallePosAct);
if not bEnEdicion then if not bEnEdicion then
AFactura.Post; AFactura.Post;
finally finally
HideHourglassCursor; HideHourglassCursor;
// Restaurar la posición que teníamos en los detalles.
FDetallesController.LocalizarPosicion(AFactura.Detalles, ADetallePosAct);
end; end;
end; end;

View File

@ -778,6 +778,7 @@ procedure TFacturasProveedorController.RecalcularImportes(
FFactura: IBizFacturaProveedor); FFactura: IBizFacturaProveedor);
var var
bEnEdicion : Boolean; bEnEdicion : Boolean;
ADetallePosAct : Integer;
begin begin
if not Assigned(FFactura) then if not Assigned(FFactura) then
raise Exception.Create ('Factura no asignada (RecalcularImportes)'); raise Exception.Create ('Factura no asignada (RecalcularImportes)');
@ -785,12 +786,18 @@ begin
if FFactura.DataTable.Active then if FFactura.DataTable.Active then
FFactura.DataTable.Active := True; FFactura.DataTable.Active := True;
{ Hay que guardar la posición en la que estamos en los detalles por que
la asignación de valores a los campos IMPORTE_NETO e IMPORTE_PORTE
(ver más adelante) colocan el puntero en la tabla detalle al principio.
No he encontrado la razón por la que mueve el puntero. }
ADetallePosAct := FFactura.Detalles.POSICION;
bEnEdicion := (FFactura.DataTable.State in dsEditModes); bEnEdicion := (FFactura.DataTable.State in dsEditModes);
if not bEnEdicion then if not bEnEdicion then
FFactura.Edit; FFactura.Edit;
ShowHourglassCursor; ShowHourglassCursor;
FFactura.Edit;
try try
FFactura.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(FFactura.Detalles); FFactura.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(FFactura.Detalles);
FFactura.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(FFactura.Detalles); FFactura.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(FFactura.Detalles);
@ -798,6 +805,8 @@ begin
FFactura.Post; FFactura.Post;
finally finally
HideHourglassCursor; HideHourglassCursor;
// Restaurar la posición que teníamos en los detalles.
FDetallesController.LocalizarPosicion(FFactura.Detalles, ADetallePosAct);
end; end;
end; end;

View File

@ -566,6 +566,7 @@ procedure TPedidosProveedorController.RecalcularImportes(
APedido: IBizPedidoProveedor); APedido: IBizPedidoProveedor);
var var
bEnEdicion : Boolean; bEnEdicion : Boolean;
ADetallePosAct : Integer;
begin begin
if not Assigned(APedido) then if not Assigned(APedido) then
raise Exception.Create ('Pedido no asignado (RecalcularImportes)'); raise Exception.Create ('Pedido no asignado (RecalcularImportes)');
@ -573,12 +574,18 @@ begin
if APedido.DataTable.Active then if APedido.DataTable.Active then
APedido.DataTable.Active := True; APedido.DataTable.Active := True;
{ Hay que guardar la posición en la que estamos en los detalles por que
la asignación de valores a los campos IMPORTE_NETO e IMPORTE_PORTE
(ver más adelante) colocan el puntero en la tabla detalle al principio.
No he encontrado la razón por la que mueve el puntero. }
ADetallePosAct := APedido.Detalles.POSICION;
bEnEdicion := (APedido.DataTable.State in dsEditModes); bEnEdicion := (APedido.DataTable.State in dsEditModes);
if not bEnEdicion then if not bEnEdicion then
APedido.Edit; APedido.Edit;
ShowHourglassCursor; ShowHourglassCursor;
APedido.Edit;
try try
APedido.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(APedido.Detalles); APedido.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(APedido.Detalles);
APedido.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(APedido.Detalles); APedido.IMPORTE_PORTE := FDetallesController.DarTotalPorteTotal(APedido.Detalles);
@ -586,6 +593,8 @@ begin
APedido.Post; APedido.Post;
finally finally
HideHourglassCursor; HideHourglassCursor;
// Restaurar la posición que teníamos en los detalles.
FDetallesController.LocalizarPosicion(APedido.Detalles, ADetallePosAct);
end; end;
end; end;