From a372fe433b723fac2ab180629b23c5c87fbca62a Mon Sep 17 00:00:00 2001 From: Pablo Ferrandez Roca Date: Tue, 4 Nov 2025 08:11:17 +0100 Subject: [PATCH 1/2] solucionado el error que hacia que no se actualizase el precio del servicio al eliminar un tabajo --- Model/TrabajoAT.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/TrabajoAT.php b/Model/TrabajoAT.php index e01b7a0..cd77c38 100644 --- a/Model/TrabajoAT.php +++ b/Model/TrabajoAT.php @@ -211,6 +211,8 @@ protected function onDelete(): void { parent::onDelete(); + $service = $this->getServicio(); + $service->calculatePriceNet(); $this->updateStock($this->referencia, $this->cantidad, $this->estado); } From 707e257ac24cb9de82bee2dfcd1056ce25a97265 Mon Sep 17 00:00:00 2001 From: Pablo Ferrandez Roca Date: Tue, 4 Nov 2025 17:16:04 +0100 Subject: [PATCH 2/2] =?UTF-8?q?a=C3=B1adido=20dest=20para=20comprobar=20qu?= =?UTF-8?q?e=20al=20eliminar=20se=20actualiza=20el=20precio=20neto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Test/main/TrabajoAtTest.php | 38 +++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Test/main/TrabajoAtTest.php b/Test/main/TrabajoAtTest.php index 97d4aa1..aef0476 100644 --- a/Test/main/TrabajoAtTest.php +++ b/Test/main/TrabajoAtTest.php @@ -403,6 +403,44 @@ public function testCreateInvoice(): void $this->assertTrue($customer->delete()); } + public function testUpdateOnDelete(): void + { + // creamos un cliente + $customer = $this->getRandomCustomer(); + $this->assertTrue($customer->save()); + + // creamos un servicio + $service = new ServicioAT(); + $service->codalmacen = Tools::settings('default', 'codalmacen'); + $service->codcliente = $customer->codcliente; + $service->descripcion = 'Test'; + $service->idempresa = Tools::settings('default', 'idempresa'); + $this->assertTrue($service->save()); + + // creamos un trabajo + $work = new TrabajoAT(); + $work->idservicio = $service->idservicio; + $work->descripcion = 'Test work'; + $work->cantidad = 1; + $work->precio = 10; + $this->assertTrue($work->save(), 'Error creating TrabajoAT'); + + // comprobamos que se ha actualizado el neto del servicio + $service->load($service->id()); + $this->assertEquals(10, $service->neto); + + // eliminamos el trabajo + $this->assertTrue($work->delete()); + + // comprobamos que se ha actualizado el neto del servicio + $service->load($service->id()); + $this->assertEquals(0, $service->neto); + + // eliminamos + $this->assertTrue($service->delete()); + $this->assertTrue($customer->delete()); + } + protected function tearDown(): void { $this->logErrors();