Implementa regras de investimento por empresa com dupla aprovacao

This commit is contained in:
2026-10-28 16:57:45 +02:00
parent 153ba2c1af
commit 95dd2cc1ed
37 changed files with 1418 additions and 28 deletions
+4
View File
@@ -30,6 +30,10 @@ class BudgetWorkflow
if (! $budget) {
return null;
}
$requiredKind = $request->items()->where('purchase_type', 'equipment')->exists() ? 'investment' : 'operating';
if ($budget->kind !== $requiredKind) {
throw ValidationException::withMessages(['budget' => 'A dotação deve ter a classificação explícita adequada: investimento para processos com equipamento; corrente para os restantes.']);
}
if (! $budget->approved_by || ($kind !== 'release' && (int) $budget->year !== now()->year)) {
throw ValidationException::withMessages(['budget' => 'Dotação pendente de aprovação ou exercício encerrado.']);
}