1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-24 23:37:51 +01:00

Fix scadenzario

This commit is contained in:
Pek5892 2024-05-28 09:21:53 +02:00
parent 50e0e95e2a
commit 44c5b0a1b0
2 changed files with 23 additions and 7 deletions

View File

@ -80,7 +80,13 @@ class Mastrino extends Model
public function delete()
{
// Per ogni movimento imposto il totale = 0
$movimenti = $this->cleanup();
foreach ($movimenti as $movimento) {
$movimento->totale = 0;
$movimento->save();
}
$this->aggiornaScadenzario($movimenti);
return parent::delete();
@ -150,7 +156,7 @@ class Mastrino extends Model
$documentIds = [];
foreach ($movimenti as $movimento) {
if (!in_array($movimento->iddocumento, $documentIds)) {
$documentIds[] = $movimento->documento->id;
$documentIds[] = $movimento->iddocumento;
}
}
return $documentIds;
@ -193,22 +199,21 @@ class Mastrino extends Model
/**
* Funzione dedicata alla distribuzione del totale pagato del movimento nelle relative scadenze associate.
*/
protected function correggiScadenza(Movimento $movimento, $scadenze = null, $documento = null)
protected function correggiScadenza(Movimento $movimento, $scadenze = null, $id_documento = null)
{
$is_nota = false;
$documento = Fattura::find($id_documento);
if ($scadenze) {
if (empty($documento)) {
$dir = $movimento->totale < 0 ? 'uscita' : 'entrata';
} else {
$dir = Fattura::find($documento)->direzione;
$dir = $documento->direzione;
}
$totale_da_distribuire = 0;
foreach ($scadenze as $scadenza) {
$totale_da_distribuire += Movimento::where('id_scadenza', '=', $scadenza->id)
->where('totale', '>', 0)
->sum('totale');
$totale_da_distribuire += $movimento['totale'];
}
}

11
update/2_5_2.php Normal file
View File

@ -0,0 +1,11 @@
<?php
include_once __DIR__.'/core.php';
use Modules\PrimaNota\Mastrino;
$mastrini = Mastrino::where('primanota', 1)->groupBy('idmastrino')->get();
foreach ($mastrini as $mastrino) {
$mastrino->aggiornaScadenzario();
}