diff --git a/Source/Modulos/Albaranes de cliente/Controller/uAlbaranesClienteController.pas b/Source/Modulos/Albaranes de cliente/Controller/uAlbaranesClienteController.pas index 77563107..6103709c 100644 --- a/Source/Modulos/Albaranes de cliente/Controller/uAlbaranesClienteController.pas +++ b/Source/Modulos/Albaranes de cliente/Controller/uAlbaranesClienteController.pas @@ -44,6 +44,8 @@ type procedure Preview(AAlbaran : IBizAlbaranCliente); procedure Print(AAlbaran : IBizAlbaranCliente); + procedure RecalcularImportes(AAlbaran: IBizAlbaranCliente); + procedure CopiarDireccionEnvio (const ADireccionEnvio: IBizDireccionesContacto; AAlbaran: IBizAlbaranCliente); procedure QuitarDireccionEnvio(AAlbaran: IBizAlbaranCliente); @@ -55,6 +57,7 @@ type end; TAlbaranesClienteController = class(TObservador, IAlbaranesClienteController) + private protected FDataModule : IDataModuleAlbaranesCliente; FClienteController : IClientesController; @@ -117,6 +120,8 @@ type procedure RecuperarCliente(AAlbaran : IBizAlbaranCliente); + procedure RecalcularImportes(AAlbaran: IBizAlbaranCliente); + function CambiarSituacion(AAlbaran : IBizAlbaranCliente; ANuevaSituacion: String; AFechaEnvio : TDateTime = 0; AFechaRecibido : TDateTime = 0; @@ -689,12 +694,7 @@ begin if Supports(ADataTable, IBizDetallesAlbaranCliente, ADetalles) and Supports(ADetalles.DataTable.MasterSource.DataTable, IBizAlbaranCliente, AAlbaran) then begin - AAlbaran.Edit; - try - AAlbaran.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(ADetalles); - finally - AAlbaran.Post; - end; + RecalcularImportes(AAlbaran); end; end; @@ -852,6 +852,31 @@ begin end; end; +procedure TAlbaranesClienteController.RecalcularImportes(AAlbaran: IBizAlbaranCliente); +var + bEnEdicion : Boolean; +begin + if not Assigned(AAlbaran) then + raise Exception.Create ('Albarán no asignado (RecalcularImportes)'); + + if AAlbaran.DataTable.Active then + AAlbaran.DataTable.Active := True; + + bEnEdicion := (AAlbaran.DataTable.State in dsEditModes); + if not bEnEdicion then + AAlbaran.Edit; + + ShowHourglassCursor; + AAlbaran.Edit; + try + AAlbaran.IMPORTE_NETO := FDetallesController.DarTotalImporteTotal(AAlbaran.Detalles); + if not bEnEdicion then + AAlbaran.Post; + finally + HideHourglassCursor; + end; +end; + function TAlbaranesClienteController.GetClienteController: IClientesController; begin Result := FClienteController; diff --git a/Source/Modulos/Lib/AlbaranesCliente_controller.dcp b/Source/Modulos/Lib/AlbaranesCliente_controller.dcp index 3510fa2f..cf1bf78f 100644 Binary files a/Source/Modulos/Lib/AlbaranesCliente_controller.dcp and b/Source/Modulos/Lib/AlbaranesCliente_controller.dcp differ