mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-25 07:47:55 +01:00
Fix scadenzario
This commit is contained in:
parent
50e0e95e2a
commit
44c5b0a1b0
@ -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
11
update/2_5_2.php
Normal 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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user