Introduzione numero rata in Rate contrattuali

This commit is contained in:
Dasc3er 2020-08-27 15:28:31 +02:00
parent 62e4e9f29c
commit 577bf0d555
2 changed files with 17 additions and 4 deletions

View File

@ -65,6 +65,17 @@ class Pianificazione extends Document
return $this->belongsTo(Fattura::class, 'iddocumento');
}
public function getNumeroPianificazione()
{
$pianificazioni = $this->contratto->pianificazioni;
$p = $this;
return $pianificazioni->search(function ($item) use ($p) {
return $item->id == $p->id;
}) + 1;
}
public function getRighe()
{
$righe = $this->contratto->getRighe();

View File

@ -54,6 +54,7 @@ foreach ($raggruppamenti as $mese => $raggruppamento) {
foreach ($pianificazioni as $pianificazione) {
$contratto = $pianificazione->contratto;
$anagrafica = $contratto->anagrafica;
$numero_pianificazioni = $contratto->pianificazioni()->count();
if (strtolower($pianificazione->data_scadenza->formatLocalized('%B %Y')) == strtolower($mese)) {
echo '
@ -69,10 +70,11 @@ foreach ($raggruppamenti as $mese => $raggruppamento) {
<td>
'.moneyFormat($pianificazione->totale).'<br>
<small>'.tr('_TOT_ / _NUM_ rate', [
'_TOT_' => moneyFormat($contratto->totale),
'_NUM_' => numberFormat($contratto->pianificazioni()->count(), 0),
]).'</small>
<small>'.tr('Rata _IND_/_NUM_ (totale: _TOT_)', [
'_IND_' => numberFormat($pianificazione->getNumeroPianificazione(), 0),
'_NUM_' => numberFormat($numero_pianificazioni, 0),
'_TOT_' => moneyFormat($contratto->totale),
]).'</small>
</td>';
// Pulsanti