Implementa reforcos orcamentais com aprovacao independente
This commit is contained in:
@@ -8,6 +8,12 @@ import {
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { money } from '@/types/procurement';
|
||||
import {
|
||||
ReinforcementProposal,
|
||||
ReinforcementReview,
|
||||
} from '@/components/budget-reinforcements';
|
||||
import { InventoryPagination } from '@/components/inventory';
|
||||
import type { Page } from '@/types/inventory';
|
||||
|
||||
type Budget = {
|
||||
id: number;
|
||||
@@ -22,13 +28,27 @@ type Budget = {
|
||||
approved_by: number | null;
|
||||
reason: string;
|
||||
includes_tax: boolean;
|
||||
reinforced_minor: number;
|
||||
approved_total_minor: number;
|
||||
};
|
||||
export default function Budgets({
|
||||
centers,
|
||||
budgets,
|
||||
reinforcements,
|
||||
}: {
|
||||
centers: { id: number; code: string; name: string }[];
|
||||
budgets: Budget[];
|
||||
reinforcements: Page<{
|
||||
id: number;
|
||||
budget_id: number;
|
||||
reference: string;
|
||||
amount_minor: number;
|
||||
reason: string;
|
||||
status: string;
|
||||
created_by: number;
|
||||
reviewed_by: number | null;
|
||||
review_reason: string | null;
|
||||
}>;
|
||||
}) {
|
||||
const { auth } = usePage().props;
|
||||
const form = useForm({
|
||||
@@ -57,7 +77,7 @@ export default function Budgets({
|
||||
</p>
|
||||
<Panel
|
||||
title="Preparar dotação"
|
||||
description="Outra pessoa de Administração ou Finanças deve aprovar. Não existem alterações ou reforços nesta etapa."
|
||||
description="Outra pessoa de Administração ou Finanças deve aprovar. A dotação inicial é preservada; reforços têm aprovação própria."
|
||||
>
|
||||
<form
|
||||
className="grid gap-4"
|
||||
@@ -165,6 +185,10 @@ export default function Budgets({
|
||||
{money(b.consumed_minor)} · Disponível:{' '}
|
||||
{money(b.available_minor)}
|
||||
</p>
|
||||
<p>
|
||||
Reforços aprovados: {money(b.reinforced_minor)} ·
|
||||
Dotação acumulada: {money(b.approved_total_minor)}
|
||||
</p>
|
||||
<p className="my-3">{b.reason}</p>
|
||||
{!b.approved_by && b.created_by !== auth.user.id && (
|
||||
<Button
|
||||
@@ -175,8 +199,56 @@ export default function Budgets({
|
||||
Aprovar dotação
|
||||
</Button>
|
||||
)}
|
||||
{b.approved_by && (
|
||||
<ReinforcementProposal budgetId={b.id} />
|
||||
)}
|
||||
</Panel>
|
||||
))}
|
||||
<Panel
|
||||
title="Histórico de reforços"
|
||||
description="Pendentes e rejeitados não alteram o saldo. O valor inicial nunca é reescrito."
|
||||
>
|
||||
<div className="space-y-4">
|
||||
{reinforcements.data.map((r) => (
|
||||
<article
|
||||
key={r.id}
|
||||
className="rounded border p-4 text-sm"
|
||||
>
|
||||
<p className="font-semibold">
|
||||
{r.reference} · Dotação #{r.budget_id} ·{' '}
|
||||
{money(r.amount_minor)}
|
||||
</p>
|
||||
<p>
|
||||
{{
|
||||
pending: 'Pendente',
|
||||
approved: 'Aprovado',
|
||||
rejected: 'Rejeitado',
|
||||
}[r.status] ?? r.status}{' '}
|
||||
· Proposto por #{r.created_by}
|
||||
{r.reviewed_by
|
||||
? ` · Decidido por #${r.reviewed_by}`
|
||||
: ''}
|
||||
</p>
|
||||
<p className="my-2 whitespace-pre-wrap">
|
||||
{r.reason}
|
||||
</p>
|
||||
{r.review_reason && (
|
||||
<p className="whitespace-pre-wrap">
|
||||
Decisão: {r.review_reason}
|
||||
</p>
|
||||
)}
|
||||
{r.status === 'pending' &&
|
||||
r.created_by !== auth.user.id && (
|
||||
<ReinforcementReview id={r.id} />
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
{reinforcements.data.length === 0 && (
|
||||
<p>Sem reforços nesta empresa.</p>
|
||||
)}
|
||||
</div>
|
||||
<InventoryPagination page={reinforcements} />
|
||||
</Panel>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user