openstamanager/include/src/Components/Discount.php

38 lines
795 B
PHP
Raw Normal View History

2019-04-04 17:12:32 +02:00
<?php
namespace Common\Components;
use Illuminate\Database\Eloquent\Builder;
abstract class Discount extends Row
{
public function getIvaAttribute()
{
return $this->attributes['iva'];
}
/**
* Effettua i conti per l'IVA.
*/
protected function fixIva()
{
2019-04-05 04:42:02 +02:00
$this->attributes['iva'] = parent::getIvaAttribute();
2019-04-04 17:12:32 +02:00
$descrizione = $this->aliquota->descrizione;
if (!empty($descrizione)) {
$this->attributes['desc_iva'] = $descrizione;
}
$this->fixIvaIndetraibile();
}
protected static function boot($bypass = false)
{
parent::boot(true);
static::addGlobalScope('discounts', function (Builder $builder) {
$builder->where('subtotale', '=', 0);
});
}
}