Skip to content

Commit 6fbe0ae

Browse files
committed
fix: eliminazione fatture collegate a interventi
1 parent f1dc4ae commit 6fbe0ae

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

modules/fatture/src/Components/RelationTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ public function delete()
172172
{
173173
$result = parent::delete();
174174

175-
if (!empty($this->idintervento) && $this->fattura->getRighe()->where('idintervento', $this->idintervento)->count() == 1) {
176-
database()->query("UPDATE `in_interventi` SET `idstatointervento` = (SELECT `id` FROM `in_statiintervento` WHERE `codice` = 'OK') WHERE `id`=".prepare($this->idintervento));
177-
}
175+
// Aggiorna lo stato dell'intervento a 'OK' quando la riga viene eliminata
176+
$stato = \Modules\Interventi\Stato::where('codice', 'OK')->first()->id;
177+
\Modules\Interventi\Intervento::where('id', $this->idintervento)->update(['idstatointervento' => $stato]);
178178

179179
return $result;
180180
}

0 commit comments

Comments
 (0)