Implementa regras de investimento por empresa com dupla aprovacao
This commit is contained in:
@@ -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.']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user