Implementa reforcos orcamentais com aprovacao independente

This commit is contained in:
2026-10-28 15:03:49 +02:00
parent c41628d738
commit 153ba2c1af
24 changed files with 1023 additions and 25 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ class BudgetWorkflow
$ledger = BudgetEntry::query()->where('budget_id', $budget->id);
$used = (int) (clone $ledger)->sum('reserved_minor') + (int) $ledger->sum('committed_minor');
$used += (int) BudgetConsumption::query()->where('budget_id', $budget->id)->sum('amount_minor');
if ($used + $reserveDelta + $commitDelta > $budget->amount_minor) {
if ($used + $reserveDelta + $commitDelta > $budget->approvedTotalMinor()) {
throw ValidationException::withMessages(['budget' => 'Saldo orçamental insuficiente. Não são permitidos excessos.']);
}
BudgetEntry::query()->create(['tenant_id' => $user->tenant_id, 'budget_id' => $budget->id, 'requisition_id' => $request->id, 'created_by' => $user->id, 'kind' => $kind, 'reserved_minor' => $reserveDelta, 'committed_minor' => $commitDelta, 'created_at' => now()]);