Aggiunto margine percentuale

This commit is contained in:
Thomas Zilio 2019-09-12 09:31:55 +02:00
parent 87850b4232
commit 6d7cb74248
5 changed files with 59 additions and 34 deletions

View File

@ -67,13 +67,23 @@ abstract class Row extends Description
}
/**
* Restituisce il gaudagno totale (totale_imponibile - spesa) relativo all'elemento.
* Restituisce il margine totale (imponibile - spesa) relativo all'elemento.
*
* @return float
*/
public function getGuadagnoAttribute()
public function getMargineAttribute()
{
return $this->totale_imponibile - $this->spesa;
return $this->imponibile - $this->spesa;
}
/**
* Restituisce il margine percentuale relativo all'elemento.
*
* @return float
*/
public function getMarginePercentualeAttribute()
{
return (1 - ($this->spesa / $this->imponibile)) * 100;
}
// Attributi della componente

View File

@ -121,13 +121,23 @@ abstract class Document extends Model
}
/**
* Calcola il guadagno del documento.
* Calcola il margine del documento.
*
* @return float
*/
public function getGuadagnoAttribute()
public function getMargineAttribute()
{
return $this->calcola('guadagno');
return $this->calcola('margine');
}
/**
* Restituisce il margine percentuale del documento.
*
* @return float
*/
public function getMarginePercentualeAttribute()
{
return (1 - ($this->spesa / $this->imponibile)) * 100;
}
public function delete()

View File

@ -217,11 +217,6 @@ foreach ($righe as $row) {
if (!$row->isDescrizione()) {
echo '
'.moneyFormat($riga['totale_imponibile']);
/*
<br><small class="text-'.($row->guadagno > 0 ? 'success' : 'danger').'">
'.tr('Guadagno').': '.moneyFormat($row->guadagno).'
</small>';
*/
}
echo '
</td>';
@ -286,7 +281,6 @@ $totale_imponibile = abs($fattura->totale_imponibile);
$iva = abs($fattura->iva);
$totale = abs($fattura->totale);
$netto_a_pagare = abs($fattura->netto);
$guadagno = $fattura->guadagno;
// IMPONIBILE
echo '
@ -421,24 +415,6 @@ if ($totale != $netto_a_pagare) {
</tr>';
}
// GUADAGNO TOTALE
if ($dir == 'entrata') {
$guadagno_style = $guadagno < 0 ? 'background-color: #FFC6C6; border: 3px solid red' : '';
/*
echo '
<tr>
<td colspan="5" class="text-right">
<b>'.tr('Guadagno', [], ['upper' => true]).':</b>
</td>
<td align="right" style="'.$guadagno_style.'">
'.moneyFormat($guadagno).'
</td>
<td></td>
</tr>';
*/
}
echo '
</table>';

View File

@ -358,13 +358,23 @@ class Sessione extends Model
}
/**
* Restituisce il gaudagno totale (totale_imponibile - spesa) relativo all'elemento.
* Restituisce il margine totale (imponibile - spesa) relativo all'elemento.
*
* @return float
*/
public function getGuadagnoAttribute()
public function getMargineAttribute()
{
return $this->totale_imponibile - $this->spesa;
return $this->imponibile - $this->spesa;
}
/**
* Restituisce il margine percentuale relativo all'elemento.
*
* @return float
*/
public function getMarginePercentualeAttribute()
{
return (1 - ($this->spesa / $this->imponibile)) * 100;
}
public function getIvaIndetraibileAttribute()

View File

@ -187,7 +187,7 @@ echo '
<td></td>
</tr>';
// Totale contratto
// Totale
echo '
<tr>
<td colspan="5" class="text-right">
@ -199,6 +199,25 @@ echo '
<td></td>
</tr>';
// Margine
$margine = $preventivo->margine;
if (!empty($margine)) {
$margine_style = $margine < 0 ? 'background-color: #FFC6C6; border: 3px solid red' : '';
echo '
<tr>
<td colspan="5" class="text-right">
'.tr('Margine (_PRC_%)', [
'_PRC_' => numberFormat($preventivo->margine_percentuale),
]).':
</td>
<td align="right" style="'.$margine_style.'">
'.moneyFormat($preventivo->margine).'
</td>
<td></td>
</tr>';
}
echo '
</table>';