Implementa reforcos orcamentais com aprovacao independente
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Models\Concerns\BelongsToTenant;
|
||||
use Brick\Math\BigDecimal;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/** @property int $id
|
||||
@@ -16,6 +17,13 @@ class Budget extends Model
|
||||
|
||||
protected $guarded = ['id'];
|
||||
|
||||
public function approvedTotalMinor(): int
|
||||
{
|
||||
$sum = BudgetReinforcement::query()->where('budget_id', $this->id)->where('status', 'approved')->sum('amount_minor');
|
||||
|
||||
return BigDecimal::of((string) $sum)->plus($this->amount_minor)->toInt();
|
||||
}
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::updating(function (Budget $budget) {
|
||||
|
||||
Reference in New Issue
Block a user