@@ -6,7 +6,9 @@ export function InventoryNotice() {
|
||||
return (
|
||||
<div className="rounded-xl border border-amber-200 bg-amber-50 p-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-100">
|
||||
Ambiente de desenvolvimento. Não autoriza compras reais.{' '}
|
||||
<strong>O orçamento ainda não é validado.</strong>
|
||||
<strong>
|
||||
Esta operação física não certifica a validação orçamental.
|
||||
</strong>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
|
||||
export type RelatedProcess = { id: number; number: string; href: string };
|
||||
|
||||
/** Links supplied by the native page; the server retains authority over every destination. */
|
||||
export function OrderDocumentLinks({
|
||||
receiptsHref = null,
|
||||
financialDocumentsHref = null,
|
||||
relatedProcesses = [],
|
||||
}: {
|
||||
receiptsHref?: string | null;
|
||||
financialDocumentsHref?: string | null;
|
||||
relatedProcesses?: RelatedProcess[];
|
||||
}) {
|
||||
if (
|
||||
!receiptsHref &&
|
||||
!financialDocumentsHref &&
|
||||
relatedProcesses.length === 0
|
||||
)
|
||||
return null;
|
||||
return (
|
||||
<nav
|
||||
aria-label="Documentos relacionados da ordem"
|
||||
className="rounded-xl border bg-card p-4"
|
||||
>
|
||||
<ul className="flex flex-wrap gap-x-6 gap-y-3 text-sm font-medium">
|
||||
{relatedProcesses.map((process) => (
|
||||
<li key={process.id}>
|
||||
<Link
|
||||
className="underline underline-offset-4"
|
||||
href={process.href}
|
||||
>
|
||||
Processo {process.number}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
{receiptsHref && (
|
||||
<li>
|
||||
<Link
|
||||
className="underline underline-offset-4"
|
||||
href={receiptsHref}
|
||||
>
|
||||
Recepções, qualidade e quantidades pendentes
|
||||
</Link>
|
||||
</li>
|
||||
)}
|
||||
{financialDocumentsHref && (
|
||||
<li>
|
||||
<Link
|
||||
className="underline underline-offset-4"
|
||||
href={financialDocumentsHref}
|
||||
>
|
||||
Facturas e pagamentos desta ordem
|
||||
</Link>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { Link } from '@inertiajs/react';
|
||||
import type { ProcurementGroup } from '@/lib/procurement-navigation';
|
||||
|
||||
export function ProcurementMenuResults({
|
||||
groups,
|
||||
dashboard,
|
||||
onNavigate,
|
||||
onEscape,
|
||||
}: {
|
||||
groups: ProcurementGroup[];
|
||||
dashboard: boolean;
|
||||
onNavigate: () => void;
|
||||
onEscape: () => void;
|
||||
}) {
|
||||
const count = groups.reduce(
|
||||
(total, group) => total + group.entries.length,
|
||||
dashboard ? 1 : 0,
|
||||
);
|
||||
const linkClass =
|
||||
'block rounded-md px-3 py-2 text-sm hover:bg-accent focus-visible:bg-accent focus-visible:outline-2 focus-visible:outline-ring';
|
||||
return (
|
||||
<section
|
||||
id="sgc-menu-results"
|
||||
aria-label="Resultados da pesquisa do menu"
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
onEscape();
|
||||
}
|
||||
}}
|
||||
className="absolute top-full left-0 z-50 mt-2 max-h-[min(65vh,32rem)] w-[min(36rem,calc(100vw-2rem))] overflow-y-auto rounded-xl border bg-popover p-2 text-popover-foreground shadow-lg"
|
||||
>
|
||||
<p
|
||||
role="status"
|
||||
className="px-3 py-2 text-sm text-muted-foreground"
|
||||
>
|
||||
{count
|
||||
? `${count} ${count === 1 ? 'opção disponível' : 'opções disponíveis'}.`
|
||||
: 'Nenhuma opção encontrada. Tente outra palavra.'}
|
||||
</p>
|
||||
{dashboard && (
|
||||
<Link
|
||||
href="/dashboard"
|
||||
className={linkClass}
|
||||
onClick={onNavigate}
|
||||
>
|
||||
Painel inicial
|
||||
</Link>
|
||||
)}
|
||||
{groups.map((group) => (
|
||||
<div key={group.id}>
|
||||
<h2 className="px-3 pt-3 pb-1 text-xs font-semibold text-muted-foreground">
|
||||
{group.label}
|
||||
</h2>
|
||||
<ul>
|
||||
{group.entries.map((entry) => (
|
||||
<li key={entry.id}>
|
||||
{entry.fullPage ? (
|
||||
<a
|
||||
href={entry.path}
|
||||
className={linkClass}
|
||||
onClick={onNavigate}
|
||||
>
|
||||
{entry.label}
|
||||
<span className="block text-xs text-muted-foreground">
|
||||
{entry.section ?? group.label}
|
||||
</span>
|
||||
</a>
|
||||
) : (
|
||||
<Link
|
||||
href={entry.path}
|
||||
className={linkClass}
|
||||
onClick={onNavigate}
|
||||
>
|
||||
{entry.label}
|
||||
<span className="block text-xs text-muted-foreground">
|
||||
{entry.section ?? group.label}
|
||||
</span>
|
||||
</Link>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
@@ -124,8 +124,9 @@ export function Panel({
|
||||
return (
|
||||
<section
|
||||
id={id}
|
||||
tabIndex={id ? -1 : undefined}
|
||||
aria-labelledby={headingId}
|
||||
className="sgc-panel min-w-0 scroll-mt-24 rounded-xl border bg-card p-4 shadow-xs sm:p-5 print:rounded-none print:shadow-none"
|
||||
className="sgc-panel min-w-0 scroll-mt-24 rounded-xl border bg-card p-4 shadow-xs sm:p-5 lg:scroll-mt-72 print:rounded-none print:shadow-none"
|
||||
>
|
||||
<h2
|
||||
id={headingId}
|
||||
@@ -160,14 +161,20 @@ export function Status({ value }: { value: string }) {
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
export function RequisitionTable({ rows }: { rows: Requisition[] }) {
|
||||
export function RequisitionTable({
|
||||
rows,
|
||||
emptyDescription = 'Não existem pedidos disponíveis neste conjunto para o seu perfil.',
|
||||
}: {
|
||||
rows: Requisition[];
|
||||
emptyDescription?: string;
|
||||
}) {
|
||||
if (!rows.length)
|
||||
return (
|
||||
<div className="py-12 text-center">
|
||||
<ClipboardList className="mx-auto mb-3 size-9 text-muted-foreground/50" />
|
||||
<p className="font-medium">Sem requisições para apresentar</p>
|
||||
<p className="mt-1 text-sm text-muted-foreground">
|
||||
Os pedidos de compra aparecem aqui depois de criados.
|
||||
{emptyDescription}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Link, router, useForm, usePage, useRemember } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { FormErrors, Panel, controlClass } from '@/components/procurement';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
|
||||
type SavedSearch = {
|
||||
id: number;
|
||||
@@ -21,24 +21,6 @@ export type SavedSearches = {
|
||||
};
|
||||
};
|
||||
|
||||
function usePrivatePreparation(dirty: boolean) {
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const form = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', { detail: { form, dirty } }),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [dirty]);
|
||||
return ref;
|
||||
}
|
||||
|
||||
function SavedSearchRow({
|
||||
row,
|
||||
term,
|
||||
@@ -58,7 +40,7 @@ function SavedSearchRow({
|
||||
q: term,
|
||||
});
|
||||
const action = useForm({ version: row.version, q: term });
|
||||
const ref = usePrivatePreparation(editing && edit.isDirty);
|
||||
const ref = usePreparationDirty(editing && edit.isDirty);
|
||||
const endpoint = `/compras/pesquisas-guardadas/${row.id}`;
|
||||
return (
|
||||
<li className="grid min-w-0 grid-cols-1 gap-3 border-b py-4 last:border-0">
|
||||
@@ -185,7 +167,7 @@ export function SavedProcurementSearches({
|
||||
`saved-search:${actor?.tenant_id ?? 'none'}:${actor?.id ?? 'none'}:${term}`,
|
||||
{ name: '', term, q: term },
|
||||
);
|
||||
const ref = usePrivatePreparation(create.data.name !== '');
|
||||
const ref = usePreparationDirty(create.data.name !== '');
|
||||
return (
|
||||
<Panel title="As minhas pesquisas guardadas">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
Search,
|
||||
X,
|
||||
} from 'lucide-react';
|
||||
import { Fragment, useEffect, useState } from 'react';
|
||||
import { Fragment, useEffect, useRef, useState } from 'react';
|
||||
import type { ReactNode } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
@@ -32,6 +32,12 @@ import {
|
||||
import { roleLabels } from '@/types/procurement';
|
||||
import type { WorkContextState } from '@/types/work-context';
|
||||
import { WorkContextChange } from '@/components/work-context-change';
|
||||
import { ProcurementMenuResults } from '@/components/procurement-menu-results';
|
||||
import {
|
||||
matchesMenuSearch,
|
||||
normalizeMenuText,
|
||||
searchProcurementMenu,
|
||||
} from '@/lib/procurement-menu-search';
|
||||
|
||||
export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
const page = usePage();
|
||||
@@ -41,6 +47,7 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
| undefined;
|
||||
const [mobileOpen, setMobileOpen] = useState(false);
|
||||
const [search, setSearch] = useState('');
|
||||
const desktopSearch = useRef<HTMLInputElement>(null);
|
||||
const [expanded, setExpanded] = useState<Record<string, boolean>>({});
|
||||
const access = page.props.organizationAccess as {
|
||||
active: boolean;
|
||||
@@ -55,6 +62,7 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
page.props.orderCancellationAvailable === true,
|
||||
page.props.operationalOrdersAvailable === true,
|
||||
page.props.privateAuditAvailable === true,
|
||||
page.props.capitalRegisterAvailable === true,
|
||||
).flatMap((group) => group.entries.map((entry) => entry.id)),
|
||||
);
|
||||
const groups = procurementNavigation(
|
||||
@@ -64,6 +72,7 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
page.props.orderCancellationAvailable === true,
|
||||
page.props.operationalOrdersAvailable === true,
|
||||
page.props.privateAuditAvailable === true,
|
||||
page.props.capitalRegisterAvailable === true,
|
||||
)
|
||||
.map((group) => ({
|
||||
...group,
|
||||
@@ -91,28 +100,13 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
: { ...previous, [activeGroupId]: true },
|
||||
);
|
||||
}, [activeId, activeGroupId]);
|
||||
const normalize = (text: string) =>
|
||||
text
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLocaleLowerCase('pt');
|
||||
const normalize = normalizeMenuText;
|
||||
const query = normalize(search.trim());
|
||||
const visibleGroups = groups
|
||||
.map((group) => ({
|
||||
...group,
|
||||
entries: group.entries.filter(
|
||||
(entry) =>
|
||||
!query ||
|
||||
normalize(
|
||||
group.label +
|
||||
' ' +
|
||||
(entry.section ?? '') +
|
||||
' ' +
|
||||
entry.label,
|
||||
).includes(query),
|
||||
),
|
||||
}))
|
||||
.filter((group) => group.entries.length);
|
||||
const visibleGroups = searchProcurementMenu(groups, query);
|
||||
const closeSearch = () => {
|
||||
setSearch('');
|
||||
desktopSearch.current?.focus();
|
||||
};
|
||||
const navigate = () => {
|
||||
setMobileOpen(false);
|
||||
setSearch('');
|
||||
@@ -145,12 +139,22 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<input
|
||||
ref={mobile ? undefined : desktopSearch}
|
||||
type="search"
|
||||
aria-label="Procurar no menu"
|
||||
placeholder="Procurar no menu…"
|
||||
value={search}
|
||||
onChange={(event) => setSearch(event.target.value)}
|
||||
className={`h-10 w-full rounded-lg border pr-9 pl-9 text-sm outline-none focus:border-red-400 focus:ring-2 focus:ring-red-400/20 ${mobile ? 'border-white/15 bg-white/5 text-white placeholder:text-slate-400' : 'border-border bg-background text-foreground'}`}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === 'Escape') {
|
||||
event.preventDefault();
|
||||
closeSearch();
|
||||
}
|
||||
}}
|
||||
aria-controls={
|
||||
!mobile && query ? 'sgc-menu-results' : undefined
|
||||
}
|
||||
className={`h-10 w-full rounded-lg border pr-9 pl-9 text-sm outline-none focus:border-red-400 focus:ring-2 focus:ring-red-400/20 [&::-webkit-search-cancel-button]:hidden ${mobile ? 'border-white/15 bg-white/5 text-white placeholder:text-slate-400' : 'border-border bg-background text-foreground'}`}
|
||||
/>
|
||||
{search && (
|
||||
<button
|
||||
@@ -162,6 +166,17 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
)}
|
||||
{!mobile && query && (
|
||||
<ProcurementMenuResults
|
||||
groups={visibleGroups}
|
||||
dashboard={matchesMenuSearch(
|
||||
'Painel inicial Visão geral',
|
||||
query,
|
||||
)}
|
||||
onNavigate={navigate}
|
||||
onEscape={closeSearch}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
const navigation = (
|
||||
@@ -173,7 +188,7 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
ESPAÇO DE TRABALHO
|
||||
</p>
|
||||
{(!query ||
|
||||
normalize('Painel inicial Visão geral').includes(query)) && (
|
||||
matchesMenuSearch('Painel inicial Visão geral', query)) && (
|
||||
<Link
|
||||
href="/dashboard"
|
||||
onClick={navigate}
|
||||
@@ -273,12 +288,12 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
))}
|
||||
{query &&
|
||||
visibleGroups.length === 0 &&
|
||||
!normalize('Painel inicial Visão geral').includes(query) && (
|
||||
!matchesMenuSearch('Painel inicial Visão geral', query) && (
|
||||
<p
|
||||
role="status"
|
||||
className="px-3 py-5 text-sm text-slate-400"
|
||||
>
|
||||
Nenhuma opção encontrada. Tenta outra palavra.
|
||||
Nenhuma opção encontrada. Tente outra palavra.
|
||||
</p>
|
||||
)}
|
||||
</nav>
|
||||
@@ -359,10 +374,7 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
aria-label="Navegação principal horizontal"
|
||||
className="flex min-w-0 flex-1 flex-wrap items-center gap-1 px-3 py-3"
|
||||
>
|
||||
{(!query ||
|
||||
normalize(
|
||||
'Painel inicial Visão geral',
|
||||
).includes(query)) && (
|
||||
{
|
||||
<Link
|
||||
href="/dashboard"
|
||||
onClick={navigate}
|
||||
@@ -379,8 +391,8 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
/>
|
||||
Painel inicial
|
||||
</Link>
|
||||
)}
|
||||
{visibleGroups.map((group) => (
|
||||
}
|
||||
{groups.map((group) => (
|
||||
<DropdownMenu key={group.id}>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<button
|
||||
@@ -451,15 +463,6 @@ export function SgcWorkspaceShell({ children }: { children: ReactNode }) {
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
))}
|
||||
{query &&
|
||||
visibleGroups.length === 0 &&
|
||||
!normalize(
|
||||
'Painel inicial Visão geral',
|
||||
).includes(query) && (
|
||||
<p className="px-3 py-2 text-sm text-slate-400">
|
||||
Nenhuma opção encontrada.
|
||||
</p>
|
||||
)}
|
||||
</nav>
|
||||
</div>
|
||||
<div className="flex min-h-18 items-center justify-between gap-4 px-5 py-3 lg:px-8">
|
||||
|
||||
@@ -465,7 +465,10 @@ function ImprovementContent({
|
||||
(m) => m.status !== 'closed' && m.due_on < data.today,
|
||||
).length;
|
||||
return (
|
||||
<Panel title="Medidas de melhoria e acompanhamento">
|
||||
<Panel
|
||||
id="evaluation-improvements"
|
||||
title="Medidas de melhoria e acompanhamento"
|
||||
>
|
||||
<div className="space-y-5">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Acompanhamento associado a esta revisão, consultado em{' '}
|
||||
|
||||
@@ -437,7 +437,7 @@ function ResponseContent({
|
||||
};
|
||||
const base = `/fornecedores/avaliacoes/${evaluationId}/contraditorios`;
|
||||
return (
|
||||
<Panel title="Contraditório do fornecedor">
|
||||
<Panel id="evaluation-responses" title="Contraditório do fornecedor">
|
||||
<div className="space-y-5">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Documentos e argumentos recebidos, registados pela equipa.
|
||||
|
||||
@@ -5,6 +5,7 @@ import { protectDepartures } from '@/lib/unsaved-navigation';
|
||||
import {
|
||||
connectedDirtyForms,
|
||||
markPreparationDirty,
|
||||
usesGenericPreparationTracking,
|
||||
} from '@/lib/preparation-forms';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -31,7 +32,7 @@ export function WorkContextChange() {
|
||||
!(event.detail.form instanceof HTMLFormElement)
|
||||
)
|
||||
return;
|
||||
markPreparationDirty(event.detail.form, !!event.detail.dirty);
|
||||
markPreparationDirty(event.detail.form, !!event.detail.dirty, true);
|
||||
if (event.detail.dirty) dirty.current.add(event.detail.form);
|
||||
else dirty.current.delete(event.detail.form);
|
||||
};
|
||||
@@ -42,7 +43,7 @@ export function WorkContextChange() {
|
||||
input instanceof HTMLTextAreaElement ||
|
||||
input instanceof HTMLSelectElement
|
||||
) {
|
||||
if (input.form) {
|
||||
if (input.form && usesGenericPreparationTracking(input.form)) {
|
||||
markPreparationDirty(input.form, true);
|
||||
dirty.current.add(input.form);
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ export function usePreparationDirty(dirty: boolean, visible = true) {
|
||||
useEffect(() => {
|
||||
const form = ref.current;
|
||||
if (!form) return;
|
||||
markPreparationDirty(form, visible && dirty);
|
||||
markPreparationDirty(form, visible && dirty, true);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form, dirty: visible && dirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
markPreparationDirty(form, false);
|
||||
markPreparationDirty(form, false, true);
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form, dirty: false },
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
export function markPreparationDirty(
|
||||
form: HTMLFormElement,
|
||||
dirty: boolean,
|
||||
managed = false,
|
||||
): void {
|
||||
form.setAttribute('data-preparation-dirty', dirty ? 'true' : 'false');
|
||||
if (managed) form.setAttribute('data-preparation-managed', 'true');
|
||||
// Explicit query forms change consultation criteria, not a business preparation.
|
||||
form.setAttribute(
|
||||
'data-preparation-dirty',
|
||||
dirty && form.getAttribute('data-query-form') !== 'true'
|
||||
? 'true'
|
||||
: 'false',
|
||||
);
|
||||
}
|
||||
|
||||
/** A form that publishes its own dirty state owns clearing and restoring it. */
|
||||
export function usesGenericPreparationTracking(form: HTMLFormElement): boolean {
|
||||
return (
|
||||
form.getAttribute('data-query-form') !== 'true' &&
|
||||
form.getAttribute('data-preparation-managed') !== 'true'
|
||||
);
|
||||
}
|
||||
|
||||
/** Recover restored preparations even when their effect ran before the guard subscribed. */
|
||||
@@ -20,6 +36,7 @@ export function connectedDirtyForms(
|
||||
].filter(
|
||||
(form) =>
|
||||
form.isConnected &&
|
||||
form.getAttribute('data-query-form') !== 'true' &&
|
||||
form.getAttribute('data-preparation-dirty') !== 'false',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
import type { ProcurementGroup } from '@/lib/procurement-navigation';
|
||||
|
||||
const terms: Record<string, string> = {
|
||||
supply_agreements:
|
||||
'acordo acordos contrato contratos vigência fornecimento',
|
||||
supply_imports:
|
||||
'importação alfândega aduaneira despachante transitário pauta',
|
||||
receipts: 'receber entrega recepção divergência',
|
||||
operational_orders: 'produção manutenção oficina ordem',
|
||||
capital_register:
|
||||
'projecto projeto imobilizado activo ativo património cadastro',
|
||||
my_workflow_tasks: 'tarefa pendência próxima acção',
|
||||
pending_approvals: 'aprovar aprovação decidir decisão',
|
||||
suppliers: 'fornecedor cadastro documento',
|
||||
supplier_evaluations: 'avaliar avaliação fornecedor',
|
||||
invoices: 'factura conferir conferência fornecedor',
|
||||
payments: 'pagamento liquidar liquidação saldo confirmação',
|
||||
budgets: 'orçamento reforço dotação saldo',
|
||||
stock_operations: 'inventário contagem saída entrega',
|
||||
inventory_lots: 'lote validade quarentena',
|
||||
audit_private: 'auditoria exportar exportação privada',
|
||||
audit_metadata: 'auditoria evento histórico metadados',
|
||||
};
|
||||
|
||||
export const normalizeMenuText = (value: string) =>
|
||||
value
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLocaleLowerCase('pt');
|
||||
|
||||
export const matchesMenuSearch = (text: string, query: string) => {
|
||||
const haystack = normalizeMenuText(text);
|
||||
return normalizeMenuText(query)
|
||||
.trim()
|
||||
.split(/\s+/)
|
||||
.every((word) => haystack.includes(word));
|
||||
};
|
||||
|
||||
/** Search only the already authorised navigation; never introduce a route or grant. */
|
||||
export function searchProcurementMenu(
|
||||
groups: ProcurementGroup[],
|
||||
query: string,
|
||||
): ProcurementGroup[] {
|
||||
return groups
|
||||
.map((group) => ({
|
||||
...group,
|
||||
entries: group.entries.filter((entry) =>
|
||||
matchesMenuSearch(
|
||||
`${group.label} ${entry.section ?? ''} ${entry.label} ${terms[entry.id] ?? ''}`,
|
||||
query,
|
||||
),
|
||||
),
|
||||
}))
|
||||
.filter((group) => group.entries.length > 0);
|
||||
}
|
||||
@@ -35,6 +35,7 @@ export function procurementNavigation(
|
||||
orderCancellation = false,
|
||||
operationalOrders = false,
|
||||
privateAudit = false,
|
||||
capitalRegister = false,
|
||||
): ProcurementGroup[] {
|
||||
const groups: ProcurementGroup[] = [
|
||||
{
|
||||
@@ -42,6 +43,11 @@ export function procurementNavigation(
|
||||
label: 'Requisições',
|
||||
icon: ClipboardList,
|
||||
entries: [
|
||||
{
|
||||
id: 'my_workflow_tasks',
|
||||
label: 'As minhas tarefas',
|
||||
path: '/requisicoes/tarefas',
|
||||
},
|
||||
{
|
||||
id: 'process_search',
|
||||
label: 'Pesquisar processos',
|
||||
@@ -57,11 +63,6 @@ export function procurementNavigation(
|
||||
label: 'Minhas requisições',
|
||||
path: '/requisicoes?view=mine',
|
||||
},
|
||||
{
|
||||
id: 'my_workflow_tasks',
|
||||
label: 'As minhas tarefas',
|
||||
path: '/requisicoes/tarefas',
|
||||
},
|
||||
{
|
||||
id: 'my_drafts',
|
||||
label: 'Os meus rascunhos',
|
||||
@@ -69,7 +70,7 @@ export function procurementNavigation(
|
||||
},
|
||||
{
|
||||
id: 'all_requests',
|
||||
label: 'Todas as autorizadas',
|
||||
label: 'Requisições autorizadas',
|
||||
path: '/requisicoes?view=all',
|
||||
},
|
||||
{ id: 'planning', label: 'Planeamento', path: '/planeamento' },
|
||||
@@ -424,6 +425,12 @@ export function procurementNavigation(
|
||||
path: '/equipamentos',
|
||||
roles: inventory,
|
||||
},
|
||||
{
|
||||
id: 'capital_register',
|
||||
label: 'Projectos e imobilizado',
|
||||
path: '/projectos-imobilizado',
|
||||
roles: inventory,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -557,9 +564,25 @@ export function procurementNavigation(
|
||||
label: 'Compras',
|
||||
icon: ClipboardList,
|
||||
entries: purchasing.flatMap((group) =>
|
||||
group.entries.map((entry) => ({
|
||||
(group.id === 'sourcing'
|
||||
? [
|
||||
...group.entries.filter(
|
||||
(entry) => entry.id !== 'supply_imports',
|
||||
),
|
||||
...group.entries.filter(
|
||||
(entry) => entry.id === 'supply_imports',
|
||||
),
|
||||
]
|
||||
: group.entries
|
||||
).map((entry) => ({
|
||||
...entry,
|
||||
section: group.label,
|
||||
section:
|
||||
entry.id === 'supply_imports'
|
||||
? 'Importação'
|
||||
: group.id === 'sourcing' &&
|
||||
entry.id.startsWith('supply_')
|
||||
? 'Fornecimento e reposição'
|
||||
: group.label,
|
||||
})),
|
||||
),
|
||||
},
|
||||
@@ -596,6 +619,7 @@ export function procurementNavigation(
|
||||
(entry.id !== 'audit_private' || privateAudit) &&
|
||||
(entry.id !== 'operational_orders' ||
|
||||
operationalOrders) &&
|
||||
(entry.id !== 'capital_register' || capitalRegister) &&
|
||||
(entry.id !== 'new_request' ||
|
||||
!Array.isArray(role) ||
|
||||
role.includes('requester')) &&
|
||||
@@ -615,6 +639,29 @@ export function activeProcurementEntry(
|
||||
url: string,
|
||||
): string | undefined {
|
||||
const current = new URL(url, 'http://local');
|
||||
if (
|
||||
(current.pathname === '/compras/acordos/vigencia' ||
|
||||
(current.pathname === '/compras/fornecimento' &&
|
||||
['agreements', 'contracts'].includes(
|
||||
current.searchParams.get('view') ?? 'agreements',
|
||||
))) &&
|
||||
groups.some((group) =>
|
||||
group.entries.some((entry) => entry.id === 'supply_agreements'),
|
||||
)
|
||||
)
|
||||
return 'supply_agreements';
|
||||
if (
|
||||
(/^\/requisicoes\/\d+\/(classificacao-pautal|base-legal|estimativa-importacao)(?:\/|$)/.test(
|
||||
current.pathname,
|
||||
) ||
|
||||
/^\/compras\/importacoes\/\d+\/(custos|documentos|suporte-bancario|acompanhamento)(?:\/|$)/.test(
|
||||
current.pathname,
|
||||
)) &&
|
||||
groups.some((group) =>
|
||||
group.entries.some((entry) => entry.id === 'supply_imports'),
|
||||
)
|
||||
)
|
||||
return 'supply_imports';
|
||||
if (/^\/ordens\/\d+\/recepcoes/.test(current.pathname)) return 'receipts';
|
||||
if (/^\/requisicoes\/\d+\/adjudicacao(?:\/|$)/.test(current.pathname))
|
||||
return 'orders';
|
||||
@@ -644,5 +691,17 @@ export function activeProcurementEntry(
|
||||
return target.pathname.length * 100 + target.searchParams.size;
|
||||
};
|
||||
matches.sort((a, b) => specificity(b.path) - specificity(a.path));
|
||||
if (
|
||||
matches.length === 0 &&
|
||||
/^\/administracao\/(prazos-aprovacao|revisao-urgencias)(?:\/|$)/.test(
|
||||
current.pathname,
|
||||
) &&
|
||||
groups.some((group) =>
|
||||
group.entries.some(
|
||||
(entry) => entry.id === 'organization_parameters',
|
||||
),
|
||||
)
|
||||
)
|
||||
return 'organization_parameters';
|
||||
return matches[0]?.id;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ export default function AuditMetadata({
|
||||
<details className="my-4 rounded border p-3">
|
||||
<summary>Filtrar eventos</summary>
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="mt-4 grid gap-4 sm:grid-cols-2"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -83,6 +83,7 @@ export default function GeographyReview({
|
||||
</Panel>
|
||||
<Panel title="Pendências da cartografia">
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="mb-5 flex flex-wrap items-end gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -200,6 +200,7 @@ function ParameterFields({
|
||||
approvalLevels,
|
||||
approvalLevelsReady = false,
|
||||
expiryReady = false,
|
||||
urgentReviewsReady = false,
|
||||
requisitionCategoryOptions = {},
|
||||
companyDetails,
|
||||
companyDetailsReady,
|
||||
@@ -233,6 +234,7 @@ function ParameterFields({
|
||||
approvalLevels?: RequisitionApprovalPlan | null;
|
||||
approvalLevelsReady?: boolean;
|
||||
expiryReady?: boolean;
|
||||
urgentReviewsReady?: boolean;
|
||||
requisitionCategoryOptions?: Record<string, string>;
|
||||
companyDetails: CompanyDetails | null;
|
||||
companyDetailsReady: boolean;
|
||||
@@ -392,29 +394,141 @@ function ParameterFields({
|
||||
return (
|
||||
<>
|
||||
<Head title="Parametrização da aplicação" />
|
||||
{geographyEnabled && (
|
||||
<div className="mx-auto w-full max-w-7xl p-5">
|
||||
<CompanyAdministrativeLocation geography={geography} />
|
||||
<Link
|
||||
className="mt-4 inline-block font-semibold underline"
|
||||
href="/administracao/divisao-administrativa"
|
||||
>
|
||||
Consultar inconsistências da divisão administrativa
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
<Link
|
||||
href="/administracao/candidaturas/formularios"
|
||||
className="m-5 inline-block font-semibold underline"
|
||||
>
|
||||
Formulários de inscrições e candidaturas
|
||||
</Link>
|
||||
<div className="mx-auto max-w-6xl space-y-6 px-5 py-8 lg:px-8">
|
||||
<PageTitle
|
||||
eyebrow="Administração"
|
||||
title="Parametrização da aplicação"
|
||||
description="Defina os perfis da empresa, atribua responsabilidades e mantenha dois administradores permanentes."
|
||||
/>
|
||||
<nav
|
||||
aria-label="Áreas da parametrização"
|
||||
className="rounded-xl border bg-card p-4"
|
||||
>
|
||||
<p className="mb-3 font-semibold">Ir para uma área</p>
|
||||
<ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{[
|
||||
['company-details', 'Dados da empresa'],
|
||||
['approval-levels', 'Níveis de aprovação'],
|
||||
...(geographyEnabled
|
||||
? [
|
||||
[
|
||||
'company-geography',
|
||||
'Localização administrativa',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(ready
|
||||
? [
|
||||
[
|
||||
'company-activation',
|
||||
'Activação da configuração',
|
||||
],
|
||||
[
|
||||
'company-comparison',
|
||||
'Comparação de propostas',
|
||||
],
|
||||
['company-tax', 'IVA de novas linhas'],
|
||||
[
|
||||
'company-approval-rules',
|
||||
'Regras e limites de aprovação',
|
||||
],
|
||||
[
|
||||
'company-profiles',
|
||||
'Perfis e permissões',
|
||||
],
|
||||
[
|
||||
'company-users',
|
||||
'Utilizadores e atribuições',
|
||||
],
|
||||
[
|
||||
'company-cost-centres',
|
||||
'Organização e centros de custo',
|
||||
],
|
||||
...(intelligencePolicy
|
||||
? [
|
||||
[
|
||||
'company-intelligence',
|
||||
'Inteligência operacional',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(aiPlan
|
||||
? [
|
||||
[
|
||||
'company-ai-plan',
|
||||
'Plano de inteligência artificial',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(workContextConfiguration
|
||||
? [
|
||||
[
|
||||
'company-work-contexts',
|
||||
'Opções contratadas',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
[
|
||||
'company-maintenance',
|
||||
'Manutenção TEMPO',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
].map(([id, label]) => (
|
||||
<li key={id}>
|
||||
<a
|
||||
className="font-medium underline underline-offset-4"
|
||||
href={`#${id}`}
|
||||
>
|
||||
{label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
<li>
|
||||
<Link
|
||||
className="font-medium underline underline-offset-4"
|
||||
href="/administracao/candidaturas/formularios"
|
||||
>
|
||||
Formulários de inscrições e candidaturas
|
||||
</Link>
|
||||
</li>
|
||||
{expiryReady && (
|
||||
<li>
|
||||
<Link
|
||||
className="font-medium underline underline-offset-4"
|
||||
href="/administracao/prazos-aprovacao"
|
||||
>
|
||||
Prazos, escalamento e expiração
|
||||
</Link>
|
||||
</li>
|
||||
)}
|
||||
{urgentReviewsReady && (
|
||||
<li>
|
||||
<Link
|
||||
className="font-medium underline underline-offset-4"
|
||||
href="/administracao/revisao-urgencias"
|
||||
>
|
||||
Perfis de revisão posterior das urgências
|
||||
</Link>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
</nav>
|
||||
{geographyEnabled && (
|
||||
<div
|
||||
id="company-geography"
|
||||
tabIndex={-1}
|
||||
className="min-w-0 scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<CompanyAdministrativeLocation geography={geography} />
|
||||
<Link
|
||||
className="mt-4 inline-block font-semibold underline"
|
||||
href="/administracao/divisao-administrativa"
|
||||
>
|
||||
Consultar inconsistências da divisão administrativa
|
||||
</Link>
|
||||
</div>
|
||||
)}
|
||||
{notice && (
|
||||
<p
|
||||
role="status"
|
||||
@@ -423,15 +537,6 @@ function ParameterFields({
|
||||
{notice}
|
||||
</p>
|
||||
)}
|
||||
{expiryReady && (
|
||||
<Link
|
||||
className="block underline"
|
||||
href="/administracao/prazos-aprovacao"
|
||||
>
|
||||
Configurar prazos, escalamento e expiração das
|
||||
aprovações
|
||||
</Link>
|
||||
)}
|
||||
{activationPreview && (
|
||||
<OrganizationActivationPreview
|
||||
preview={activationPreview}
|
||||
@@ -439,19 +544,31 @@ function ParameterFields({
|
||||
tasks={workflowTasks}
|
||||
/>
|
||||
)}
|
||||
<RequisitionApprovalSettings
|
||||
plan={approvalLevels}
|
||||
ready={approvalLevelsReady}
|
||||
categoryOptions={requisitionCategoryOptions}
|
||||
profiles={profiles}
|
||||
costCenters={costCenters}
|
||||
version={version}
|
||||
/>
|
||||
<CompanyDetailsSettings
|
||||
details={companyDetails}
|
||||
ready={companyDetailsReady && ready}
|
||||
version={version}
|
||||
/>
|
||||
<div
|
||||
id="approval-levels"
|
||||
tabIndex={-1}
|
||||
className="min-w-0 scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<RequisitionApprovalSettings
|
||||
plan={approvalLevels}
|
||||
ready={approvalLevelsReady}
|
||||
categoryOptions={requisitionCategoryOptions}
|
||||
profiles={profiles}
|
||||
costCenters={costCenters}
|
||||
version={version}
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
id="company-details"
|
||||
tabIndex={-1}
|
||||
className="min-w-0 scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<CompanyDetailsSettings
|
||||
details={companyDetails}
|
||||
ready={companyDetailsReady && ready}
|
||||
version={version}
|
||||
/>
|
||||
</div>
|
||||
{!ready ? (
|
||||
<Panel title="Instalação pendente">
|
||||
<p>
|
||||
@@ -462,6 +579,7 @@ function ParameterFields({
|
||||
) : (
|
||||
<>
|
||||
<Panel
|
||||
id="company-activation"
|
||||
title={
|
||||
active
|
||||
? 'Parametrização activa'
|
||||
@@ -534,31 +652,52 @@ function ParameterFields({
|
||||
)}
|
||||
</Panel>
|
||||
{intelligencePolicy && (
|
||||
<IntelligenceSettings
|
||||
key={`intelligence-${version}`}
|
||||
policy={intelligencePolicy}
|
||||
version={version}
|
||||
ready={intelligenceReady}
|
||||
/>
|
||||
<div
|
||||
id="company-intelligence"
|
||||
tabIndex={-1}
|
||||
className="min-w-0 scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<IntelligenceSettings
|
||||
key={`intelligence-${version}`}
|
||||
policy={intelligencePolicy}
|
||||
version={version}
|
||||
ready={intelligenceReady}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{aiPlan && (
|
||||
<AiPlanSettings
|
||||
key={`ai-plan-${version}`}
|
||||
plan={aiPlan}
|
||||
domains={aiDomains}
|
||||
scopes={aiDataScopes}
|
||||
version={version}
|
||||
ready={intelligenceReady}
|
||||
/>
|
||||
<div
|
||||
id="company-ai-plan"
|
||||
tabIndex={-1}
|
||||
className="min-w-0 scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<AiPlanSettings
|
||||
key={`ai-plan-${version}`}
|
||||
plan={aiPlan}
|
||||
domains={aiDomains}
|
||||
scopes={aiDataScopes}
|
||||
version={version}
|
||||
ready={intelligenceReady}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{workContextConfiguration && (
|
||||
<WorkContextSettings
|
||||
context={workContextConfiguration}
|
||||
enabled={enabledWorkContexts}
|
||||
version={version}
|
||||
/>
|
||||
<div
|
||||
id="company-work-contexts"
|
||||
tabIndex={-1}
|
||||
className="min-w-0 scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<WorkContextSettings
|
||||
context={workContextConfiguration}
|
||||
enabled={enabledWorkContexts}
|
||||
version={version}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<Panel title="Regras de comparação de propostas">
|
||||
<Panel
|
||||
id="company-comparison"
|
||||
title="Regras de comparação de propostas"
|
||||
>
|
||||
<p className="mb-4 text-sm">
|
||||
{comparisonPolicy.configured
|
||||
? `Revisão ${comparisonPolicy.revision} da empresa.`
|
||||
@@ -731,7 +870,7 @@ function ParameterFields({
|
||||
</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
<Panel title="IVA para novas linhas">
|
||||
<Panel id="company-tax" title="IVA para novas linhas">
|
||||
<p className="mb-4 text-sm">
|
||||
Taxa inicial para novas linhas de requisição.
|
||||
Pode ser ajustada em cada artigo conforme o
|
||||
@@ -794,7 +933,10 @@ function ParameterFields({
|
||||
</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
<Panel title="Regras de aprovação da empresa">
|
||||
<Panel
|
||||
id="company-approval-rules"
|
||||
title="Regras de aprovação da empresa"
|
||||
>
|
||||
<p className="mb-4 text-sm">
|
||||
{companyRules.provisional
|
||||
? 'Os valores actuais são provisórios; confirme e guarde as regras da empresa.'
|
||||
@@ -894,7 +1036,10 @@ function ParameterFields({
|
||||
</Button>
|
||||
</form>
|
||||
</Panel>
|
||||
<Panel title="Perfis e permissões da empresa">
|
||||
<Panel
|
||||
id="company-profiles"
|
||||
title="Perfis e permissões da empresa"
|
||||
>
|
||||
<div className="mb-4 flex flex-wrap gap-3">
|
||||
{profiles.map((p) => (
|
||||
<Button
|
||||
@@ -934,7 +1079,10 @@ function ParameterFields({
|
||||
/>
|
||||
)}
|
||||
</Panel>
|
||||
<Panel title="Utilizadores e atribuições">
|
||||
<Panel
|
||||
id="company-users"
|
||||
title="Utilizadores e atribuições"
|
||||
>
|
||||
<div className="space-y-3">
|
||||
{users.map((person) => (
|
||||
<Assignment
|
||||
@@ -1073,7 +1221,10 @@ function ParameterFields({
|
||||
</form>
|
||||
</details>
|
||||
</Panel>
|
||||
<Panel title="Organização e centros de custo">
|
||||
<Panel
|
||||
id="company-cost-centres"
|
||||
title="Organização e centros de custo"
|
||||
>
|
||||
<div className="grid gap-5 sm:grid-cols-2">
|
||||
<form
|
||||
ref={departmentRef}
|
||||
@@ -1194,7 +1345,10 @@ function ParameterFields({
|
||||
</form>
|
||||
</div>
|
||||
</Panel>
|
||||
<Panel title="Manutenção TEMPO">
|
||||
<Panel
|
||||
id="company-maintenance"
|
||||
title="Manutenção TEMPO"
|
||||
>
|
||||
<p className="text-sm">
|
||||
Atribua a uma conta nominativa um perfil sem
|
||||
administração, assinale manutenção e defina a
|
||||
|
||||
@@ -17,6 +17,7 @@ import type { ConflictDeclaration } from '@/types/conflict';
|
||||
import { date } from '@/types/procurement';
|
||||
|
||||
type Props = {
|
||||
releasedRoots?: number[];
|
||||
declarations: {
|
||||
data: ConflictDeclaration[];
|
||||
prev_page_url: string | null;
|
||||
@@ -32,6 +33,7 @@ export default function Conflicts(props: Props) {
|
||||
}
|
||||
function DeclarationFields({
|
||||
declarations,
|
||||
releasedRoots = [],
|
||||
suppliers,
|
||||
requisitions,
|
||||
identity,
|
||||
@@ -55,14 +57,14 @@ function DeclarationFields({
|
||||
<PageTitle
|
||||
eyebrow="Integridade nas compras · RF-AF-01"
|
||||
title="Conflitos de interesses"
|
||||
description="Registe a sua situação pessoal perante um fornecedor ou processo. Administração e Finanças podem consultar o registo da empresa; os restantes perfis consultam apenas as suas declarações."
|
||||
description="Registe a sua situação pessoal perante um fornecedor ou processo e consulte as declarações abrangidas pelo seu acesso."
|
||||
/>
|
||||
<div className="rounded-xl border border-amber-200 bg-amber-50 p-5 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-100">
|
||||
Um conflito registado mantém o impedimento, mesmo que exista
|
||||
uma declaração posterior de ausência. Não há caducidade
|
||||
automática nem retirada de conflitos nesta etapa: essas
|
||||
condições dependem da política da empresa. A data de
|
||||
conhecimento descreve o facto e não adia o bloqueio.
|
||||
Uma declaração de ausência não anula conflitos anteriores. O
|
||||
levantamento de um impedimento exige autorização expressa da
|
||||
direcção; a declaração e as suas correcções permanecem no
|
||||
histórico. Não há caducidade automática. A data de
|
||||
conhecimento não adia o bloqueio.
|
||||
</div>
|
||||
<Panel
|
||||
title="Nova declaração pessoal"
|
||||
@@ -282,6 +284,15 @@ function DeclarationFields({
|
||||
{d.has_conflict
|
||||
? 'Conflito registado'
|
||||
: 'Ausência declarada'}
|
||||
{d.has_conflict && (
|
||||
<p className="mt-1 text-xs">
|
||||
{releasedRoots.includes(
|
||||
d.root_id ?? d.id,
|
||||
)
|
||||
? 'Impedimento levantado pela direcção'
|
||||
: 'Impedimento activo'}
|
||||
</p>
|
||||
)}
|
||||
{d.successor && (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
Com correcção posterior
|
||||
|
||||
@@ -38,24 +38,28 @@ export default function Dashboard({
|
||||
value: stats.total,
|
||||
icon: ClipboardList,
|
||||
detail: 'Total de pedidos visíveis',
|
||||
href: '/requisicoes',
|
||||
},
|
||||
{
|
||||
label: 'Em aprovação',
|
||||
value: stats.pending,
|
||||
icon: Clock3,
|
||||
detail: `${stats.awaitingMe} aguardam a sua decisão`,
|
||||
detail: 'Pedidos visíveis em aprovação',
|
||||
href: '/requisicoes?status=pending',
|
||||
},
|
||||
{
|
||||
label: 'Aprovadas',
|
||||
value: stats.approved,
|
||||
icon: CheckCheck,
|
||||
detail: 'Todas as etapas concluídas',
|
||||
href: '/requisicoes?status=approved',
|
||||
},
|
||||
{
|
||||
label: 'Valor aprovado',
|
||||
value: money(Number(stats.approvedMinor)),
|
||||
icon: Wallet,
|
||||
detail: 'Estimativa em MZN, com IVA',
|
||||
href: '/requisicoes?status=approved',
|
||||
},
|
||||
];
|
||||
return (
|
||||
@@ -105,9 +109,10 @@ export default function Dashboard({
|
||||
<>
|
||||
<div className="grid gap-4 sm:grid-cols-2 xl:grid-cols-4">
|
||||
{cards.map((card) => (
|
||||
<div
|
||||
<Link
|
||||
key={card.label}
|
||||
className="rounded-xl border bg-card p-5 shadow-xs"
|
||||
href={card.href}
|
||||
className="rounded-xl border bg-card p-5 shadow-xs transition-colors hover:border-teal-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-700"
|
||||
>
|
||||
<div className="flex items-center justify-between text-sm text-muted-foreground">
|
||||
<span>{card.label}</span>
|
||||
@@ -119,9 +124,17 @@ export default function Dashboard({
|
||||
<p className="mt-2 text-xs text-muted-foreground">
|
||||
{card.detail}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
<Link
|
||||
href="/requisicoes?view=approvals"
|
||||
className="inline-flex items-center gap-2 self-start rounded-sm text-sm font-medium text-teal-700 underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-700 dark:text-teal-400"
|
||||
>
|
||||
Requisições que aguardam a sua decisão:{' '}
|
||||
{stats.awaitingMe}
|
||||
<ArrowRight className="size-4" />
|
||||
</Link>
|
||||
{company?.rules_provisional && (
|
||||
<div className="rounded-xl border border-amber-200 bg-amber-50 px-5 py-4 text-sm text-amber-900 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-100">
|
||||
<strong>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
@@ -94,22 +94,7 @@ export default function CapitalRegister(props: Props) {
|
||||
reason: '',
|
||||
},
|
||||
);
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const node = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: form.isDirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [form.isDirty]);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const edit = (record: Record) =>
|
||||
form.setData({
|
||||
...record.data,
|
||||
@@ -135,6 +120,11 @@ export default function CapitalRegister(props: Props) {
|
||||
<Link className="underline" href="/equipamentos">
|
||||
Consultar equipamentos e peças
|
||||
</Link>
|
||||
{props.canManage && (
|
||||
<a className="underline" href="#capital-preparation">
|
||||
Ir para a preparação do cadastro
|
||||
</a>
|
||||
)}
|
||||
<Panel
|
||||
title="Identidades registadas"
|
||||
description="As revisões conservam o código e o histórico. Arquivar impede novas escolhas sem apagar ligações anteriores."
|
||||
@@ -174,16 +164,18 @@ export default function CapitalRegister(props: Props) {
|
||||
<Link
|
||||
className="underline"
|
||||
preserveState
|
||||
href={`${url}?history=${record.record_key}`}
|
||||
href={`${url}?history=${record.record_key}#capital-history`}
|
||||
>
|
||||
Consultar versões e origens
|
||||
</Link>
|
||||
{props.canManage && (
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => edit(record)}
|
||||
>
|
||||
Preparar nova versão
|
||||
<Button asChild variant="outline">
|
||||
<a
|
||||
href="#capital-preparation"
|
||||
onClick={() => edit(record)}
|
||||
>
|
||||
Preparar nova versão
|
||||
</a>
|
||||
</Button>
|
||||
)}
|
||||
</article>
|
||||
@@ -205,7 +197,7 @@ export default function CapitalRegister(props: Props) {
|
||||
</nav>
|
||||
</Panel>
|
||||
{props.history && (
|
||||
<Panel title="Histórico do registo">
|
||||
<Panel id="capital-history" title="Histórico do registo">
|
||||
{props.history.data.map((record) => (
|
||||
<article
|
||||
key={record.id}
|
||||
@@ -373,6 +365,7 @@ export default function CapitalRegister(props: Props) {
|
||||
)}
|
||||
{props.canManage && (
|
||||
<Panel
|
||||
id="capital-preparation"
|
||||
title={
|
||||
form.data.record_key
|
||||
? `Rever cadastro · versão ${form.data.version}`
|
||||
|
||||
@@ -260,7 +260,8 @@ export default function Home() {
|
||||
TEMPO
|
||||
</span>
|
||||
<span>
|
||||
O orçamento ainda não é validado. Os documentos não
|
||||
Consulte no processo as decisões e o controlo
|
||||
orçamental. Documentos de desenvolvimento não
|
||||
autorizam compras reais.
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -291,8 +291,28 @@ export default function Invoices({
|
||||
Todas as facturas / seleccionar outra encomenda
|
||||
</Link>
|
||||
)}
|
||||
<nav
|
||||
aria-label="Áreas da facturação"
|
||||
className="flex flex-wrap gap-4 text-sm font-medium"
|
||||
>
|
||||
<a
|
||||
className="underline underline-offset-4"
|
||||
href="#invoice-documents"
|
||||
>
|
||||
Facturas registadas
|
||||
</a>
|
||||
{canManage && focusInvoiceId === null && (
|
||||
<a
|
||||
className="underline underline-offset-4"
|
||||
href="#invoice-registration"
|
||||
>
|
||||
Registar factura
|
||||
</a>
|
||||
)}
|
||||
</nav>
|
||||
{canManage && focusInvoiceId === null && (
|
||||
<Panel
|
||||
id="invoice-registration"
|
||||
title="Registar factura"
|
||||
description="Reutilize a encomenda e indique os dados novos do documento do fornecedor. Unidade, preço e IVA vêm da encomenda; os totais do documento continuam a exigir coincidência exacta e conferência independente."
|
||||
>
|
||||
@@ -712,102 +732,113 @@ export default function Invoices({
|
||||
{validationError}
|
||||
</p>
|
||||
)}
|
||||
{invoices.data.map((invoice) => (
|
||||
<div key={invoice.id} id={`invoice-${invoice.id}`}>
|
||||
<Panel
|
||||
title={`${invoice.number} · ${invoice.snapshot.supplier.name}`}
|
||||
>
|
||||
<p>
|
||||
{invoice.snapshot.order_number} ·{' '}
|
||||
{invoice.issued_on} ·{' '}
|
||||
{invoice.status === 'validated'
|
||||
? 'Validada'
|
||||
: 'Pendente de validação'}
|
||||
</p>
|
||||
<p>
|
||||
Subtotal{' '}
|
||||
{money(
|
||||
invoice.subtotal_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}{' '}
|
||||
· IVA{' '}
|
||||
{money(
|
||||
invoice.tax_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}{' '}
|
||||
· Total{' '}
|
||||
{money(
|
||||
invoice.total_minor,
|
||||
invoice.snapshot.currency,
|
||||
<section
|
||||
id="invoice-documents"
|
||||
tabIndex={-1}
|
||||
aria-label="Facturas registadas"
|
||||
className="min-w-0 scroll-mt-24 space-y-6 lg:scroll-mt-72"
|
||||
>
|
||||
{invoices.data.map((invoice) => (
|
||||
<div key={invoice.id} id={`invoice-${invoice.id}`}>
|
||||
<Panel
|
||||
title={`${invoice.number} · ${invoice.snapshot.supplier.name}`}
|
||||
>
|
||||
<p>
|
||||
{invoice.snapshot.order_number} ·{' '}
|
||||
{invoice.issued_on} ·{' '}
|
||||
{invoice.status === 'validated'
|
||||
? 'Validada'
|
||||
: 'Pendente de validação'}
|
||||
</p>
|
||||
<p>
|
||||
Subtotal{' '}
|
||||
{money(
|
||||
invoice.subtotal_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}{' '}
|
||||
· IVA{' '}
|
||||
{money(
|
||||
invoice.tax_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}{' '}
|
||||
· Total{' '}
|
||||
{money(
|
||||
invoice.total_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}
|
||||
</p>
|
||||
{payablesAvailable && (
|
||||
<p className="my-3">
|
||||
<a
|
||||
className="underline"
|
||||
href={`/obrigacoes-fornecedores?invoice=${invoice.id}`}
|
||||
>
|
||||
Consultar ou preparar obrigação
|
||||
desta factura
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
</p>
|
||||
{payablesAvailable && (
|
||||
<p className="my-3">
|
||||
<a
|
||||
className="underline"
|
||||
href={`/obrigacoes-fornecedores?invoice=${invoice.id}`}
|
||||
{invoice.status === 'validated' && (
|
||||
<p className="my-3">
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/pagamentos?invoice_id=${invoice.id}`}
|
||||
>
|
||||
Consultar pagamentos externos desta
|
||||
factura
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
<ul className="my-3 space-y-2">
|
||||
{invoice.items.map((l) => (
|
||||
<li key={l.id}>
|
||||
{l.snapshot.description} ·{' '}
|
||||
{l.quantity_milli / 1000}{' '}
|
||||
{l.snapshot.unit} ·{' '}
|
||||
{money(
|
||||
l.subtotal_minor + l.tax_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{invoice.canValidate && (
|
||||
<Button
|
||||
disabled={validating !== null}
|
||||
onClick={() => {
|
||||
setValidationError('');
|
||||
setValidating(invoice.id);
|
||||
router.post(
|
||||
`/facturas/${invoice.id}/validar`,
|
||||
{},
|
||||
{
|
||||
onError: (errors) =>
|
||||
setValidationError(
|
||||
Object.values(
|
||||
errors,
|
||||
).join(' '),
|
||||
),
|
||||
onFinish: () =>
|
||||
setValidating(null),
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
Consultar ou preparar obrigação desta
|
||||
factura
|
||||
</a>
|
||||
</p>
|
||||
)}
|
||||
{invoice.status === 'validated' && (
|
||||
<p className="my-3">
|
||||
<Link
|
||||
className="underline"
|
||||
href={`/pagamentos?invoice_id=${invoice.id}`}
|
||||
>
|
||||
Consultar pagamentos externos desta
|
||||
factura
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
<ul className="my-3 space-y-2">
|
||||
{invoice.items.map((l) => (
|
||||
<li key={l.id}>
|
||||
{l.snapshot.description} ·{' '}
|
||||
{l.quantity_milli / 1000}{' '}
|
||||
{l.snapshot.unit} ·{' '}
|
||||
{money(
|
||||
l.subtotal_minor + l.tax_minor,
|
||||
invoice.snapshot.currency,
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{invoice.canValidate && (
|
||||
<Button
|
||||
disabled={validating !== null}
|
||||
onClick={() => {
|
||||
setValidationError('');
|
||||
setValidating(invoice.id);
|
||||
router.post(
|
||||
`/facturas/${invoice.id}/validar`,
|
||||
{},
|
||||
{
|
||||
onError: (errors) =>
|
||||
setValidationError(
|
||||
Object.values(
|
||||
errors,
|
||||
).join(' '),
|
||||
),
|
||||
onFinish: () =>
|
||||
setValidating(null),
|
||||
},
|
||||
);
|
||||
}}
|
||||
>
|
||||
Conferir e validar
|
||||
</Button>
|
||||
)}
|
||||
</Panel>
|
||||
</div>
|
||||
))}
|
||||
{invoices.data.length === 0 && (
|
||||
<p>Sem facturas registadas nesta empresa.</p>
|
||||
)}
|
||||
<InventoryPagination page={invoices} />
|
||||
Conferir e validar
|
||||
</Button>
|
||||
)}
|
||||
</Panel>
|
||||
</div>
|
||||
))}
|
||||
{invoices.data.length === 0 && (
|
||||
<p>
|
||||
{focusOrderId !== null
|
||||
? 'Sem facturas disponíveis para esta ordem.'
|
||||
: 'Sem facturas disponíveis nesta consulta.'}
|
||||
</p>
|
||||
)}
|
||||
<InventoryPagination page={invoices} />
|
||||
</section>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
@@ -83,22 +83,7 @@ export default function ApprovalTimeouts(props: Props) {
|
||||
},
|
||||
);
|
||||
const current = form.data.version === (props.current?.version ?? 0);
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const node = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: form.isDirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [form.isDirty]);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const edit = () =>
|
||||
form.setData({
|
||||
operation_key: '',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import {
|
||||
PageTitle,
|
||||
Panel,
|
||||
@@ -36,22 +36,7 @@ export default function UrgentReviewPolicy(props: {
|
||||
reason: '',
|
||||
},
|
||||
);
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const node = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: form.isDirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [form.isDirty]);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const current = form.data.version === (props.current?.version ?? 0);
|
||||
return (
|
||||
<main className="mx-auto flex w-full max-w-6xl flex-col gap-6 p-5 lg:p-8">
|
||||
|
||||
@@ -170,6 +170,7 @@ export default function Reports(props: Props) {
|
||||
description="O período refere-se à criação dos processos. A exportação usa os filtros aplicados."
|
||||
>
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="grid gap-4 md:grid-cols-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { Head, Link } from '@inertiajs/react';
|
||||
import {
|
||||
OrderDocumentLinks,
|
||||
type RelatedProcess,
|
||||
} from '@/components/order-document-links';
|
||||
import { AgreementOrderLimitSummary } from '@/components/agreement-order-bindings';
|
||||
import { Printer } from 'lucide-react';
|
||||
import { ComparisonPolicySummary } from '@/components/comparison-policy-summary';
|
||||
@@ -40,6 +44,8 @@ export default function OrderShow({
|
||||
snapshotComplete = true,
|
||||
orderPartsSources = [],
|
||||
canAmendOrderParts = false,
|
||||
financialDocumentsHref = null,
|
||||
relatedProcesses = [],
|
||||
}: {
|
||||
order: PurchaseOrder;
|
||||
history: History[];
|
||||
@@ -47,6 +53,8 @@ export default function OrderShow({
|
||||
snapshotComplete?: boolean;
|
||||
orderPartsSources?: OrderPartFrame[];
|
||||
canAmendOrderParts?: boolean;
|
||||
financialDocumentsHref?: string | null;
|
||||
relatedProcesses?: RelatedProcess[];
|
||||
}) {
|
||||
const snapshot = order.snapshot;
|
||||
if (!snapshotComplete) {
|
||||
@@ -59,6 +67,16 @@ export default function OrderShow({
|
||||
title={order.number}
|
||||
description="Consulta dos dados preservados na emissão."
|
||||
/>
|
||||
{orderCancellation && (
|
||||
<OrderCancellationRequest
|
||||
orderId={order.id}
|
||||
state={orderCancellation}
|
||||
/>
|
||||
)}
|
||||
<OrderDocumentLinks
|
||||
financialDocumentsHref={financialDocumentsHref}
|
||||
relatedProcesses={relatedProcesses}
|
||||
/>
|
||||
<Panel title="Documento original incompleto">
|
||||
<p>
|
||||
Este documento não conserva todos os elementos da
|
||||
@@ -127,14 +145,6 @@ export default function OrderShow({
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{(!orderCancellation || orderCancellation.state === 'issued') && (
|
||||
<Link
|
||||
href={`/ordens/${order.id}/recepcoes`}
|
||||
className="mx-auto mt-4 w-full max-w-6xl px-5 text-sm font-medium text-teal-700 dark:text-teal-400"
|
||||
>
|
||||
Recepções, qualidade e quantidades pendentes
|
||||
</Link>
|
||||
)}
|
||||
<div className="mx-auto flex w-full max-w-6xl flex-col gap-7 p-5 lg:p-8">
|
||||
<PageTitle
|
||||
eyebrow={snapshot.company.name}
|
||||
@@ -159,12 +169,22 @@ export default function OrderShow({
|
||||
reais.
|
||||
</strong>{' '}
|
||||
{snapshot.budget_checked === true
|
||||
? 'Controlo orçamental confirmado para as parcelas emitidas. '
|
||||
: 'Orçamento não verificado. '}{' '}
|
||||
? 'Controlo orçamental registado na emissão. '
|
||||
: 'Este documento não preserva confirmação do controlo orçamental. '}{' '}
|
||||
Os dados apresentados foram congelados na emissão.
|
||||
{snapshot.approval_rules.rules_provisional &&
|
||||
' Regras de aprovação provisórias.'}
|
||||
</div>
|
||||
<OrderDocumentLinks
|
||||
receiptsHref={
|
||||
!orderCancellation ||
|
||||
orderCancellation.state === 'issued'
|
||||
? `/ordens/${order.id}/recepcoes`
|
||||
: null
|
||||
}
|
||||
financialDocumentsHref={financialDocumentsHref}
|
||||
relatedProcesses={relatedProcesses}
|
||||
/>
|
||||
<OrderPartsSummary sources={orderPartsSources} />
|
||||
{canAmendOrderParts && (
|
||||
<Link
|
||||
|
||||
@@ -149,60 +149,77 @@ function ComparisonContent({
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<Link
|
||||
className="text-sm font-medium text-teal-700 dark:text-teal-400"
|
||||
href={`/requisicoes/${requisition.id}/adjudicacao`}
|
||||
>
|
||||
Adjudicação, aprovações do valor final e ordem de compra
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/abertura`}
|
||||
>
|
||||
Sessão de abertura e actas
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/qualificacao`}
|
||||
>
|
||||
Qualificação documental
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/admissao`}
|
||||
>
|
||||
Admissão e exclusão de propostas
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/recomendacao`}
|
||||
>
|
||||
Recomendação antes da adjudicação
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/relatorio`}
|
||||
>
|
||||
Relatório de conferência e impressão
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm text-teal-700"
|
||||
href={`/requisicoes/${requisition.id}`}
|
||||
>
|
||||
Consultar requisição e aprovações
|
||||
</Link>
|
||||
<Link className="text-sm text-teal-700" href="/conflitos">
|
||||
Registar ou consultar a minha declaração de conflito
|
||||
</Link>
|
||||
{urgentQuotationReady &&
|
||||
comparisonPolicy.urgent_minimum_proposals !== undefined && (
|
||||
<Link
|
||||
className="text-sm text-teal-700"
|
||||
href={`/requisicoes/${requisition.id}/urgencia-stock`}
|
||||
<div className="space-y-3 print:hidden">
|
||||
<Link
|
||||
className="text-sm font-medium text-teal-700 dark:text-teal-400"
|
||||
href={`/requisicoes/${requisition.id}/adjudicacao`}
|
||||
>
|
||||
Adjudicação, aprovações do valor final e ordem de compra
|
||||
</Link>
|
||||
<details className="rounded-lg border p-4">
|
||||
<summary className="cursor-pointer text-sm font-medium">
|
||||
Outras etapas e documentos do processo
|
||||
</summary>
|
||||
<nav
|
||||
aria-label="Etapas e documentos relacionados"
|
||||
className="mt-3 grid gap-3 sm:grid-cols-2"
|
||||
>
|
||||
Stock mínimo das cotações urgentes
|
||||
</Link>
|
||||
)}
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/abertura`}
|
||||
>
|
||||
Sessão de abertura e actas
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/qualificacao`}
|
||||
>
|
||||
Qualificação documental
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/admissao`}
|
||||
>
|
||||
Admissão e exclusão de propostas
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/recomendacao`}
|
||||
>
|
||||
Recomendação antes da adjudicação
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm font-medium underline"
|
||||
href={`/requisicoes/${requisition.id}/relatorio`}
|
||||
>
|
||||
Relatório de conferência e impressão
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm text-teal-700"
|
||||
href={`/requisicoes/${requisition.id}`}
|
||||
>
|
||||
Consultar requisição e aprovações
|
||||
</Link>
|
||||
<Link
|
||||
className="text-sm text-teal-700"
|
||||
href="/conflitos"
|
||||
>
|
||||
Registar ou consultar a minha declaração de
|
||||
conflito
|
||||
</Link>
|
||||
{urgentQuotationReady &&
|
||||
comparisonPolicy.urgent_minimum_proposals !==
|
||||
undefined && (
|
||||
<Link
|
||||
className="text-sm text-teal-700"
|
||||
href={`/requisicoes/${requisition.id}/urgencia-stock`}
|
||||
>
|
||||
Stock mínimo das cotações urgentes
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
</details>
|
||||
</div>
|
||||
<div
|
||||
className={`rounded-xl border p-5 text-sm ${ready ? 'border-teal-200 bg-teal-50 text-teal-900' : 'border-amber-200 bg-amber-50 text-amber-900'}`}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Head, Link, useForm, usePage } from '@inertiajs/react';
|
||||
import { OrderDocumentLinks } from '@/components/order-document-links';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import {
|
||||
receiptPreparationKey,
|
||||
@@ -48,6 +49,7 @@ type Props = {
|
||||
warehouses: Warehouse[];
|
||||
stockItems: StockItem[];
|
||||
canConfirm: boolean;
|
||||
financialDocumentsHref?: string | null;
|
||||
conversionQaEnabled?: boolean;
|
||||
lotScopes: {
|
||||
stock_item_id: number;
|
||||
@@ -63,6 +65,7 @@ function ReceiveOrderContent({
|
||||
warehouses,
|
||||
stockItems,
|
||||
canConfirm,
|
||||
financialDocumentsHref = null,
|
||||
conversionQaEnabled = false,
|
||||
lotScopes,
|
||||
}: Props) {
|
||||
@@ -120,6 +123,9 @@ function ReceiveOrderContent({
|
||||
description={supplier_name}
|
||||
/>
|
||||
<InventoryNotice />
|
||||
<OrderDocumentLinks
|
||||
financialDocumentsHref={financialDocumentsHref}
|
||||
/>
|
||||
<Panel title="Quantidades da ordem">
|
||||
<ReceiptProgressTable progress={progress} />
|
||||
<p className="mt-4 text-xs text-muted-foreground">
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Head, Link } from '@inertiajs/react';
|
||||
import { convertedQuantity } from '@/components/receipt-conversion';
|
||||
import { InventoryNotice } from '@/components/inventory';
|
||||
import { PageTitle, Panel } from '@/components/procurement';
|
||||
import { OrderDocumentLinks } from '@/components/order-document-links';
|
||||
import { date } from '@/types/procurement';
|
||||
import { quantity, qualityStates, receiptStates } from '@/types/inventory';
|
||||
import type { Receipt, StockMovement } from '@/types/inventory';
|
||||
@@ -17,6 +18,7 @@ export default function ReceiptShow({
|
||||
canAddDocuments = false,
|
||||
documents = [],
|
||||
purchaseProcessHref = null,
|
||||
financialDocumentsHref = null,
|
||||
}: {
|
||||
receipt: Receipt;
|
||||
movements: StockMovement[];
|
||||
@@ -25,6 +27,7 @@ export default function ReceiptShow({
|
||||
canAddDocuments?: boolean;
|
||||
documents?: ReceiptDocument[];
|
||||
purchaseProcessHref?: string | null;
|
||||
financialDocumentsHref?: string | null;
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
@@ -36,6 +39,9 @@ export default function ReceiptShow({
|
||||
description={`${receipt.snapshot.supplier.name} · ${receiptStates[receipt.status]}`}
|
||||
/>
|
||||
<InventoryNotice />
|
||||
<OrderDocumentLinks
|
||||
financialDocumentsHref={financialDocumentsHref}
|
||||
/>
|
||||
<a
|
||||
href={`/recepcoes/${receipt.id}/imprimir`}
|
||||
className="text-sm underline"
|
||||
|
||||
@@ -124,161 +124,264 @@ export default function ProcurementReports({
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
<nav
|
||||
aria-label="Secções dos relatórios"
|
||||
className="flex flex-wrap gap-2 print:hidden"
|
||||
>
|
||||
{[
|
||||
{
|
||||
id: 'report-filters',
|
||||
label: 'Filtros e requisições',
|
||||
available: true,
|
||||
},
|
||||
{
|
||||
id: 'report-operational',
|
||||
label: 'Acompanhamento',
|
||||
available: !!insights,
|
||||
},
|
||||
{
|
||||
id: 'report-payables',
|
||||
label: 'Obrigações',
|
||||
available: !!payableInsights,
|
||||
},
|
||||
{
|
||||
id: 'report-deliveries',
|
||||
label: 'Entregas',
|
||||
available: !!deliveryInsights,
|
||||
},
|
||||
{
|
||||
id: 'report-payments',
|
||||
label: 'Despesa confirmada',
|
||||
available: !!paymentInsights,
|
||||
},
|
||||
{
|
||||
id: 'report-contracts',
|
||||
label: 'Contratos',
|
||||
available: !!contractInsights,
|
||||
},
|
||||
]
|
||||
.filter((section) => section.available)
|
||||
.map((section) => (
|
||||
<a
|
||||
key={section.id}
|
||||
href={`#${section.id}`}
|
||||
className="rounded-lg border bg-card px-3 py-2 text-sm font-medium hover:border-teal-600 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-teal-700"
|
||||
>
|
||||
{section.label}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
{insights && (
|
||||
<ProcurementOperationalInsights
|
||||
data={insights}
|
||||
neededPastHref={`/relatorios?${attentionParams}`}
|
||||
withoutQuotesHref={`/relatorios?${quoteParams}`}
|
||||
withoutOrderHref={`/relatorios?${orderParams}`}
|
||||
/>
|
||||
<section
|
||||
id="report-operational"
|
||||
aria-label="Acompanhamento"
|
||||
tabIndex={-1}
|
||||
className="scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<ProcurementOperationalInsights
|
||||
data={insights}
|
||||
neededPastHref={`/relatorios?${attentionParams}`}
|
||||
withoutQuotesHref={`/relatorios?${quoteParams}`}
|
||||
withoutOrderHref={`/relatorios?${orderParams}`}
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
{payableInsights && (
|
||||
<ProcurementPayableInsights
|
||||
data={payableInsights}
|
||||
exportHref={`/relatorios/obrigacoes.csv?${params}`}
|
||||
/>
|
||||
<section
|
||||
id="report-payables"
|
||||
aria-label="Obrigações"
|
||||
tabIndex={-1}
|
||||
className="scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<ProcurementPayableInsights
|
||||
data={payableInsights}
|
||||
exportHref={`/relatorios/obrigacoes.csv?${params}`}
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
{deliveryInsights && (
|
||||
<ProcurementDeliveryInsights
|
||||
data={deliveryInsights}
|
||||
pageHref={`/relatorios?${params}`}
|
||||
exportHref={`/relatorios/entregas.csv?${params}`}
|
||||
/>
|
||||
<section
|
||||
id="report-deliveries"
|
||||
aria-label="Entregas"
|
||||
tabIndex={-1}
|
||||
className="scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<ProcurementDeliveryInsights
|
||||
data={deliveryInsights}
|
||||
pageHref={`/relatorios?${params}`}
|
||||
exportHref={`/relatorios/entregas.csv?${params}`}
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
{paymentInsights && (
|
||||
<ProcurementPaymentInsights
|
||||
data={paymentInsights}
|
||||
exportHref={`/relatorios/despesa.csv?${params}`}
|
||||
pageHref={`/relatorios?${params}`}
|
||||
/>
|
||||
<section
|
||||
id="report-payments"
|
||||
aria-label="Despesa confirmada"
|
||||
tabIndex={-1}
|
||||
className="scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<ProcurementPaymentInsights
|
||||
data={paymentInsights}
|
||||
exportHref={`/relatorios/despesa.csv?${params}`}
|
||||
pageHref={`/relatorios?${params}`}
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
{contractInsights && (
|
||||
<ProcurementContractInsights
|
||||
data={contractInsights}
|
||||
exportHref={`/relatorios/contratos.csv?${params}`}
|
||||
/>
|
||||
)}
|
||||
<Panel
|
||||
title="Filtrar requisições"
|
||||
description="O período refere-se à criação da requisição. Os resultados respeitam o seu acesso à empresa e ao departamento."
|
||||
>
|
||||
<form
|
||||
className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.get('/relatorios', { preserveState: true });
|
||||
}}
|
||||
<section
|
||||
id="report-contracts"
|
||||
aria-label="Contratos"
|
||||
tabIndex={-1}
|
||||
className="scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Número da requisição
|
||||
<input
|
||||
className={controlClass}
|
||||
value={form.data.search}
|
||||
onChange={(event) =>
|
||||
form.setData('search', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Estado da requisição
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.status}
|
||||
onChange={(event) =>
|
||||
form.setData('status', event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{Object.entries(statusLabels).map(
|
||||
([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Departamento
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.department_id}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'department_id',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos os autorizados</option>
|
||||
{departments.map((item) => (
|
||||
<option key={item.id} value={item.id}>
|
||||
{item.name}
|
||||
<ProcurementContractInsights
|
||||
data={contractInsights}
|
||||
exportHref={`/relatorios/contratos.csv?${params}`}
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
<section
|
||||
id="report-filters"
|
||||
aria-label="Filtros e requisições"
|
||||
tabIndex={-1}
|
||||
className="scroll-mt-24 lg:scroll-mt-72"
|
||||
>
|
||||
<Panel
|
||||
title="Filtrar requisições"
|
||||
description="O período refere-se à criação da requisição. Os resultados respeitam o seu acesso à empresa e ao departamento."
|
||||
>
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
form.get('/relatorios', {
|
||||
preserveState: true,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Número da requisição
|
||||
<input
|
||||
className={controlClass}
|
||||
value={form.data.search}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'search',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Estado da requisição
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.status}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'status',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
{Object.entries(statusLabels).map(
|
||||
([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
),
|
||||
)}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Departamento
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.department_id}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'department_id',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
Todos os autorizados
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Criada desde
|
||||
<input
|
||||
type="date"
|
||||
className={controlClass}
|
||||
value={form.data.from}
|
||||
onChange={(event) =>
|
||||
form.setData('from', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Criada até
|
||||
<input
|
||||
type="date"
|
||||
className={controlClass}
|
||||
value={form.data.to}
|
||||
onChange={(event) =>
|
||||
form.setData('to', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Acompanhamento
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.attention}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'attention',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
<option value="unapproved_needed">
|
||||
Data de necessidade ultrapassada, por
|
||||
aprovar
|
||||
</option>
|
||||
<option value="approved_without_quotes">
|
||||
Aprovadas sem propostas registadas
|
||||
</option>
|
||||
<option value="approved_without_order">
|
||||
Aprovadas sem ordem visível
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<ActionBar>
|
||||
<Button type="submit" disabled={form.processing}>
|
||||
Aplicar filtros
|
||||
</Button>
|
||||
<Link
|
||||
className="py-2 text-sm underline"
|
||||
href="/relatorios"
|
||||
>
|
||||
Limpar
|
||||
</Link>
|
||||
</ActionBar>
|
||||
<FormErrors errors={form.errors} />
|
||||
</form>
|
||||
</Panel>
|
||||
{departments.map((item) => (
|
||||
<option key={item.id} value={item.id}>
|
||||
{item.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Criada desde
|
||||
<input
|
||||
type="date"
|
||||
className={controlClass}
|
||||
value={form.data.from}
|
||||
onChange={(event) =>
|
||||
form.setData('from', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Criada até
|
||||
<input
|
||||
type="date"
|
||||
className={controlClass}
|
||||
value={form.data.to}
|
||||
onChange={(event) =>
|
||||
form.setData('to', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-1 text-sm">
|
||||
Acompanhamento
|
||||
<select
|
||||
className={controlClass}
|
||||
value={form.data.attention}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
'attention',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
>
|
||||
<option value="">Todos</option>
|
||||
<option value="unapproved_needed">
|
||||
Data de necessidade ultrapassada, por
|
||||
aprovar
|
||||
</option>
|
||||
<option value="approved_without_quotes">
|
||||
Aprovadas sem propostas registadas
|
||||
</option>
|
||||
<option value="approved_without_order">
|
||||
Aprovadas sem ordem visível
|
||||
</option>
|
||||
</select>
|
||||
</label>
|
||||
<ActionBar>
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={form.processing}
|
||||
>
|
||||
Aplicar filtros
|
||||
</Button>
|
||||
<Link
|
||||
className="py-2 text-sm underline"
|
||||
href="/relatorios"
|
||||
>
|
||||
Limpar
|
||||
</Link>
|
||||
</ActionBar>
|
||||
<FormErrors errors={form.errors} />
|
||||
</form>
|
||||
</Panel>
|
||||
</section>
|
||||
<section
|
||||
aria-label="Resumo dos resultados"
|
||||
className="flex flex-wrap gap-3"
|
||||
|
||||
@@ -170,6 +170,7 @@ export default function SupplierImprovementReport({
|
||||
)}
|
||||
<Panel title="Filtros do acompanhamento">
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4 print:hidden"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -76,6 +76,7 @@ export default function Index({ requisitions, filters }: Props) {
|
||||
/>
|
||||
<Panel title="Pedidos de compra">
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="mb-6 flex flex-wrap gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
@@ -128,7 +129,20 @@ export default function Index({ requisitions, filters }: Props) {
|
||||
Filtrar
|
||||
</Button>
|
||||
</form>
|
||||
<RequisitionTable rows={requisitions.data} />
|
||||
<RequisitionTable
|
||||
rows={requisitions.data}
|
||||
emptyDescription={
|
||||
filters.search || filters.status
|
||||
? 'Nenhum pedido corresponde aos filtros neste conjunto. Ajuste a referência ou o estado para voltar a consultar.'
|
||||
: filters.view === 'approvals'
|
||||
? 'Não há requisições com uma etapa disponível para a sua decisão neste momento.'
|
||||
: filters.view === 'decided'
|
||||
? 'Ainda não registou decisões nos pedidos disponíveis para o seu perfil.'
|
||||
: filters.view === 'mine'
|
||||
? 'Ainda não existem pedidos criados por si neste conjunto.'
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
<div className="mt-5 flex flex-wrap items-center justify-between gap-3 border-t pt-4 text-sm text-muted-foreground">
|
||||
<p>
|
||||
{requisitions.total} pedidos · Página{' '}
|
||||
|
||||
@@ -35,6 +35,7 @@ type LinkRecord = {
|
||||
snapshot: { source: Order };
|
||||
};
|
||||
type Props = {
|
||||
selectedOrderId?: number | null;
|
||||
policy: { id: number; version: number; data: { mode: string } } | null;
|
||||
canConfigure: boolean;
|
||||
allowedTypes: string[];
|
||||
@@ -77,6 +78,14 @@ function Workspace(props: Props & { identity: string }) {
|
||||
title="Ordens de produção e manutenção"
|
||||
description="Registe a necessidade no local de utilização ou através do procurement, conforme a configuração da empresa. A ordem de origem acompanha a compra."
|
||||
/>
|
||||
{props.selectedOrderId && (
|
||||
<p className="rounded-lg border bg-card p-3 text-sm">
|
||||
A consultar uma ordem específica.{' '}
|
||||
<Link href={base} className="font-medium underline">
|
||||
Ver todas as ordens disponíveis
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
{props.requisition && (
|
||||
<p>
|
||||
<Link
|
||||
@@ -212,7 +221,12 @@ function Workspace(props: Props & { identity: string }) {
|
||||
)}
|
||||
<ul className="space-y-4">
|
||||
{props.orders.data.map((order) => (
|
||||
<li className="rounded border p-4" key={order.id}>
|
||||
<li
|
||||
id={`op-order-${order.id}`}
|
||||
tabIndex={-1}
|
||||
className="scroll-mt-24 rounded border p-4 lg:scroll-mt-72"
|
||||
key={order.id}
|
||||
>
|
||||
<p className="font-semibold">
|
||||
{labels[order.data.type]} ·{' '}
|
||||
{order.data.reference}
|
||||
|
||||
@@ -351,9 +351,9 @@ export default function Show({
|
||||
investimento vigente, com duas aprovações
|
||||
administrativas, e reserva em dotação de
|
||||
investimento. Sem estas condições permanecem
|
||||
bloqueadas. O orçamento ainda não é validado;
|
||||
documentos de desenvolvimento não autorizam
|
||||
compras reais.
|
||||
bloqueadas. A validação técnica não substitui o
|
||||
controlo orçamental. Documentos de
|
||||
desenvolvimento não autorizam compras reais.
|
||||
</p>
|
||||
{technical?.reviews.map((t) => (
|
||||
<p
|
||||
|
||||
@@ -38,6 +38,8 @@ const statuses: Record<string, string> = {
|
||||
partial: 'Entrega parcial',
|
||||
delivered: 'Entregue',
|
||||
closed: 'Encerrada',
|
||||
archived: 'Arquivado',
|
||||
recorded: 'Registada',
|
||||
};
|
||||
export default function ProcurementSearch({
|
||||
term,
|
||||
@@ -45,6 +47,8 @@ export default function ProcurementSearch({
|
||||
invoiceSearchAvailable = false,
|
||||
supplySearchAvailable = false,
|
||||
warehouseRequestSearchAvailable = false,
|
||||
capitalSearchAvailable = false,
|
||||
operationalOrderSearchAvailable = false,
|
||||
savedSearches = null,
|
||||
}: {
|
||||
term: string;
|
||||
@@ -52,9 +56,13 @@ export default function ProcurementSearch({
|
||||
invoiceSearchAvailable?: boolean;
|
||||
supplySearchAvailable?: boolean;
|
||||
warehouseRequestSearchAvailable?: boolean;
|
||||
capitalSearchAvailable?: boolean;
|
||||
operationalOrderSearchAvailable?: boolean;
|
||||
savedSearches?: SavedSearches | null;
|
||||
}) {
|
||||
const form = useForm({ q: term });
|
||||
const populatedGroups = groups.filter((group) => group.records.total > 0);
|
||||
const emptyGroups = groups.filter((group) => group.records.total === 0);
|
||||
return (
|
||||
<>
|
||||
<Head title="Pesquisar processos" />
|
||||
@@ -66,9 +74,10 @@ export default function ProcurementSearch({
|
||||
/>
|
||||
<Panel
|
||||
title="Pesquisa transversal de Compras"
|
||||
description={`Pesquise requisições, ordens, fornecedores, recepções, equipamentos, artigos e armazéns por referência, necessidade, nome, código ou NUIT.${invoiceSearchAvailable ? ' Pode também procurar facturas de fornecedor pelo número, dentro do seu acesso financeiro.' : ''}${supplySearchAvailable ? ' Acordos e contratos disponíveis são pesquisados pela referência ou pelo nome do fornecedor preservado, na sua versão actual.' : ''}${warehouseRequestSearchAvailable ? ' Requisições internas de armazém podem ser encontradas pela referência RA, destino ou nome do requisitante preservado.' : ''} A pesquisa não inclui Pessoas, conteúdo de anexos ou arquivos externos.`}
|
||||
description="Procure uma referência, código, nome ou necessidade nos módulos disponíveis para si."
|
||||
>
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="flex flex-wrap items-end gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
@@ -97,13 +106,35 @@ export default function ProcurementSearch({
|
||||
<Button disabled={form.processing}>Pesquisar</Button>
|
||||
</form>
|
||||
<FormErrors errors={form.errors} />
|
||||
{invoiceSearchAvailable && (
|
||||
<p className="mt-3 text-sm text-muted-foreground">
|
||||
Os resultados de facturas mostram a referência e o
|
||||
estado. Abra a factura para consultar os valores e
|
||||
documentos autorizados.
|
||||
</p>
|
||||
)}
|
||||
<details className="mt-4 rounded-lg border p-3 text-sm">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Âmbito da pesquisa
|
||||
</summary>
|
||||
<p className="mt-3">{`Pesquise requisições, ordens, fornecedores, recepções, equipamentos, artigos e armazéns por referência, necessidade, nome, código ou NUIT.${invoiceSearchAvailable ? ' Pode também procurar facturas de fornecedor pelo número, dentro do seu acesso financeiro.' : ''}${supplySearchAvailable ? ' Acordos e contratos disponíveis são pesquisados pela referência ou pelo nome do fornecedor preservado, na sua versão actual.' : ''}${warehouseRequestSearchAvailable ? ' Requisições internas de armazém podem ser encontradas pela referência RA, destino ou nome do requisitante preservado.' : ''} A pesquisa não inclui Pessoas, conteúdo de anexos ou arquivos externos.`}</p>
|
||||
{operationalOrderSearchAvailable && (
|
||||
<p className="mt-3 text-sm text-muted-foreground">
|
||||
As ordens de produção e manutenção podem ser
|
||||
procuradas por referência, local ou descrição. O
|
||||
resultado abre a ordem de origem autorizada.
|
||||
</p>
|
||||
)}
|
||||
{capitalSearchAvailable && (
|
||||
<p className="mt-3 text-sm text-muted-foreground">
|
||||
Pode procurar projectos e imobilizado próprios
|
||||
de Compras por código, nome ou referência
|
||||
documental. Os resultados mostram a versão
|
||||
actual e abrem o histórico do cadastro, dentro
|
||||
do seu acesso ao departamento.
|
||||
</p>
|
||||
)}
|
||||
{invoiceSearchAvailable && (
|
||||
<p className="mt-3 text-sm text-muted-foreground">
|
||||
Os resultados de facturas mostram a referência e
|
||||
o estado. Abra a factura para consultar os
|
||||
valores e documentos autorizados.
|
||||
</p>
|
||||
)}
|
||||
</details>
|
||||
</Panel>
|
||||
{savedSearches && (
|
||||
<SavedProcurementSearches
|
||||
@@ -117,13 +148,22 @@ export default function ProcurementSearch({
|
||||
Introduza pelo menos dois caracteres para pesquisar.
|
||||
</p>
|
||||
)}
|
||||
{groups.map((group) => (
|
||||
{groups.length > 0 && populatedGroups.length === 0 && (
|
||||
<p role="status">
|
||||
Não foram encontrados resultados para esta pesquisa no
|
||||
seu âmbito de acesso.
|
||||
</p>
|
||||
)}
|
||||
{populatedGroups.map((group) => (
|
||||
<Panel
|
||||
key={group.key}
|
||||
title={`${group.title} (${group.records.total})`}
|
||||
>
|
||||
{group.records.data.length === 0 ? (
|
||||
<p>Nenhum resultado no seu âmbito de acesso.</p>
|
||||
<p>
|
||||
Não há resultados nesta página. Consulte as
|
||||
páginas disponíveis abaixo.
|
||||
</p>
|
||||
) : (
|
||||
<ul className="divide-y">
|
||||
{group.records.data.map((record) => (
|
||||
@@ -166,6 +206,22 @@ export default function ProcurementSearch({
|
||||
</nav>
|
||||
</Panel>
|
||||
))}
|
||||
{emptyGroups.length > 0 && (
|
||||
<details className="rounded-xl border bg-card p-5">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Áreas sem resultados ({emptyGroups.length})
|
||||
</summary>
|
||||
<p className="mt-3 text-sm text-muted-foreground">
|
||||
Estas áreas também foram pesquisadas dentro do seu
|
||||
acesso actual.
|
||||
</p>
|
||||
<ul className="mt-3 flex flex-wrap gap-x-6 gap-y-2 text-sm">
|
||||
{emptyGroups.map((group) => (
|
||||
<li key={group.key}>{group.title}</li>
|
||||
))}
|
||||
</ul>
|
||||
</details>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -29,6 +29,7 @@ type Props = {
|
||||
warehouse: { name: string } | null;
|
||||
checkedAt: string;
|
||||
planningVisible: boolean;
|
||||
reservationsAvailable?: boolean;
|
||||
rows: null | {
|
||||
data: Row[];
|
||||
total: number;
|
||||
@@ -56,6 +57,7 @@ export default function Availability(props: Props) {
|
||||
/>
|
||||
<Panel title="Escolher armazém">
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="grid gap-4 md:grid-cols-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
@@ -103,10 +105,21 @@ export default function Availability(props: Props) {
|
||||
>
|
||||
<p className="mb-4 text-sm">
|
||||
As necessidades planeadas são apresentadas
|
||||
separadamente. O compromisso físico e a reserva
|
||||
autorizada de requisições ao armazém ainda não estão
|
||||
implementados; não são considerados zero nem deduzidos
|
||||
como se já existissem.
|
||||
separadamente.
|
||||
{props.reservationsAvailable ? (
|
||||
<>
|
||||
{' '}
|
||||
O saldo livre corresponde ao material utilizável
|
||||
menos as reservas físicas registadas.
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{' '}
|
||||
As reservas físicas não estão disponíveis nesta
|
||||
consulta; o compromisso e o saldo livre
|
||||
permanecem por determinar.
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
{!props.rows ? (
|
||||
<p>Seleccione o armazém para consultar.</p>
|
||||
@@ -188,15 +201,18 @@ export default function Availability(props: Props) {
|
||||
null &&
|
||||
row.free_milli < 0
|
||||
? 'Reserva com défice de material utilizável — rever qualidade, validade e atendimento'
|
||||
: row.usable_milli ===
|
||||
0
|
||||
? 'Sem material utilizável — necessidade de compra'
|
||||
: row.at_minimum
|
||||
? 'No mínimo ou abaixo — necessidade de compra'
|
||||
: row.minimum_milli ===
|
||||
null
|
||||
? 'Mínimo por determinar'
|
||||
: 'Acima do mínimo'}
|
||||
: row.free_milli ===
|
||||
null
|
||||
? 'Saldo livre por determinar'
|
||||
: row.usable_milli ===
|
||||
0
|
||||
? 'Sem material utilizável — necessidade de compra'
|
||||
: row.at_minimum
|
||||
? 'No mínimo ou abaixo — necessidade de compra'
|
||||
: row.minimum_milli ===
|
||||
null
|
||||
? 'Mínimo por determinar'
|
||||
: 'Acima do mínimo'}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { useProcurementPreparationIdentity } from '@/hooks/use-procurement-preparation-identity';
|
||||
import { hasPreparationChanges } from '@/lib/requisition-history';
|
||||
import { Printer } from 'lucide-react';
|
||||
import SupplierImprovements from '@/components/supplier-improvements';
|
||||
import type { ImprovementData } from '@/components/supplier-improvements';
|
||||
@@ -33,6 +36,7 @@ type Evaluation = {
|
||||
payload: EvaluationPayload;
|
||||
review_reason: string | null;
|
||||
reviewed_at: string | null;
|
||||
reviewed_by?: number | null;
|
||||
};
|
||||
type History = {
|
||||
id: number;
|
||||
@@ -83,11 +87,27 @@ export default function SupplierEvaluation({
|
||||
improvements: ImprovementData;
|
||||
responses: ResponseData;
|
||||
}) {
|
||||
const form = useForm({ version: e.version, payload: e.payload });
|
||||
const command = useForm({ version: e.version, reason: '' });
|
||||
const preparation = useProcurementPreparationIdentity(
|
||||
`supplier-evaluation:${e.id}:${e.version}`,
|
||||
);
|
||||
const form = useForm(`${preparation}:evidence`, {
|
||||
version: e.version,
|
||||
payload: e.payload,
|
||||
});
|
||||
const command = useForm(`${preparation}:decision`, {
|
||||
version: e.version,
|
||||
reason: '',
|
||||
});
|
||||
const base = `/fornecedores/avaliacoes/${e.id}`;
|
||||
const dirty =
|
||||
JSON.stringify(form.data.payload) !== JSON.stringify(e.payload);
|
||||
const dirty = hasPreparationChanges(
|
||||
{ payload: e.payload },
|
||||
{ payload: form.data.payload },
|
||||
);
|
||||
const evidenceRef = usePreparationDirty(dirty, canEdit);
|
||||
const decisionRef = usePreparationDirty(
|
||||
command.data.reason !== '',
|
||||
canReview,
|
||||
);
|
||||
const waiting = e.payload.criteria.filter((row) =>
|
||||
['pending', 'insufficient'].includes(row.result),
|
||||
).length;
|
||||
@@ -139,6 +159,75 @@ export default function SupplierEvaluation({
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<details className="rounded-xl border bg-card p-4 print:hidden">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Ir para uma área da avaliação
|
||||
</summary>
|
||||
<nav
|
||||
aria-label="Áreas da avaliação do fornecedor"
|
||||
className="mt-4"
|
||||
>
|
||||
<ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{[
|
||||
[
|
||||
'evaluation-evidence',
|
||||
canEdit
|
||||
? 'Preparar evidências'
|
||||
: 'Âmbito e evidências',
|
||||
],
|
||||
...(e.review_reason
|
||||
? [
|
||||
[
|
||||
'evaluation-last-review',
|
||||
'Última decisão documentada',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(canReview
|
||||
? [
|
||||
[
|
||||
'evaluation-review',
|
||||
'Conferência independente',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(canRevise
|
||||
? [
|
||||
[
|
||||
'evaluation-revision',
|
||||
'Preparar nova revisão',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
...(!reportOnly
|
||||
? [
|
||||
[
|
||||
'evaluation-history',
|
||||
'Histórico de alterações e decisões',
|
||||
],
|
||||
]
|
||||
: []),
|
||||
[
|
||||
'evaluation-improvements',
|
||||
'Medidas de melhoria',
|
||||
],
|
||||
[
|
||||
'evaluation-responses',
|
||||
'Contraditório do fornecedor',
|
||||
],
|
||||
].map(([id, label]) => (
|
||||
<li key={id}>
|
||||
<a
|
||||
href={`#${id}`}
|
||||
className="font-medium underline underline-offset-4"
|
||||
>
|
||||
{label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
</details>
|
||||
{notice && (
|
||||
<p
|
||||
role="status"
|
||||
@@ -181,8 +270,13 @@ export default function SupplierEvaluation({
|
||||
só a qualificação, suspensão ou elegibilidade do fornecedor.
|
||||
</p>
|
||||
{canEdit ? (
|
||||
<Panel title="Preparar e conservar evidências">
|
||||
<Panel
|
||||
id="evaluation-evidence"
|
||||
title="Preparar e conservar evidências"
|
||||
>
|
||||
<form
|
||||
ref={evidenceRef}
|
||||
data-preparation-dirty={dirty ? 'true' : undefined}
|
||||
className="space-y-5"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
@@ -241,7 +335,10 @@ export default function SupplierEvaluation({
|
||||
</Panel>
|
||||
) : (
|
||||
<>
|
||||
<Panel title="Âmbito e evidências">
|
||||
<Panel
|
||||
id="evaluation-evidence"
|
||||
title="Âmbito e evidências"
|
||||
>
|
||||
<div className="space-y-4 text-sm">
|
||||
<p>
|
||||
Componente:{' '}
|
||||
@@ -321,18 +418,41 @@ export default function SupplierEvaluation({
|
||||
</>
|
||||
)}
|
||||
{e.review_reason && (
|
||||
<Panel title="Última decisão documentada">
|
||||
<p className="text-sm whitespace-pre-wrap">
|
||||
{e.review_reason}
|
||||
</p>
|
||||
<p className="mt-2 text-xs text-muted-foreground">
|
||||
{e.reviewed_at}
|
||||
</p>
|
||||
</Panel>
|
||||
<div className="print:break-inside-avoid">
|
||||
<Panel
|
||||
id="evaluation-last-review"
|
||||
title="Última decisão documentada"
|
||||
>
|
||||
{e.reviewed_by != null && (
|
||||
<p className="mb-2 text-sm">
|
||||
Revisor:{' '}
|
||||
{people[e.reviewed_by] ??
|
||||
`#${e.reviewed_by}`}
|
||||
</p>
|
||||
)}
|
||||
<p className="text-sm whitespace-pre-wrap">
|
||||
{e.review_reason}
|
||||
</p>
|
||||
<p className="mt-2 text-xs text-muted-foreground">
|
||||
{e.reviewed_at
|
||||
? new Date(e.reviewed_at).toLocaleString(
|
||||
'pt-MZ',
|
||||
)
|
||||
: 'Data não indicada no original'}
|
||||
</p>
|
||||
</Panel>
|
||||
</div>
|
||||
)}
|
||||
{canReview && (
|
||||
<Panel title="Conferência independente">
|
||||
<Panel
|
||||
id="evaluation-review"
|
||||
title="Conferência independente"
|
||||
>
|
||||
<form
|
||||
ref={decisionRef}
|
||||
data-preparation-dirty={
|
||||
command.data.reason !== '' ? 'true' : undefined
|
||||
}
|
||||
className="space-y-4"
|
||||
onSubmit={(event) => event.preventDefault()}
|
||||
>
|
||||
@@ -402,7 +522,10 @@ export default function SupplierEvaluation({
|
||||
</p>
|
||||
)}
|
||||
{canRevise && (
|
||||
<Panel title="Rectificar sem apagar a avaliação aprovada">
|
||||
<Panel
|
||||
id="evaluation-revision"
|
||||
title="Rectificar sem apagar a avaliação aprovada"
|
||||
>
|
||||
<p className="mb-3 text-sm">
|
||||
A rectificação cria outro rascunho, com número de
|
||||
revisão próprio. A versão aprovada anterior mantém o
|
||||
@@ -426,7 +549,10 @@ export default function SupplierEvaluation({
|
||||
</Panel>
|
||||
)}
|
||||
{!reportOnly && (
|
||||
<Panel title="Histórico de alterações e decisões">
|
||||
<Panel
|
||||
id="evaluation-history"
|
||||
title="Histórico de alterações e decisões"
|
||||
>
|
||||
<p className="mb-3 text-sm">
|
||||
{history.total} registos preservados. Cada alteração
|
||||
conserva a sua fotografia; versões aprovadas não são
|
||||
|
||||
@@ -208,6 +208,7 @@ export default function Suppliers({
|
||||
</div>
|
||||
)}
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="mb-5 flex gap-3"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -107,6 +107,7 @@ export default function AgreementFollowup({
|
||||
}
|
||||
>
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="grid gap-4 md:grid-cols-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
@@ -108,22 +108,7 @@ export default function ImportBankSupport(props: Props) {
|
||||
reason: '',
|
||||
},
|
||||
);
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const node = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: form.isDirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [form.isDirty]);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const edit = (record: BankRecord) => {
|
||||
const label = (id: number | null) =>
|
||||
record.snapshot.documents.find((doc) => doc.id === id)?.reference ??
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { Head, Link, useForm, useRemember } from '@inertiajs/react';
|
||||
import { useEffect, useRef, type RefObject } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
ActionBar,
|
||||
@@ -226,24 +226,6 @@ type DraftComponent = {
|
||||
values: string[];
|
||||
};
|
||||
|
||||
function useGuard(ref: RefObject<HTMLFormElement | null>, dirty: boolean) {
|
||||
useEffect(() => {
|
||||
const element = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: element, dirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: element, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [ref, dirty]);
|
||||
}
|
||||
|
||||
function Pagination({
|
||||
page,
|
||||
}: {
|
||||
@@ -295,8 +277,7 @@ function DocumentForm({
|
||||
reason: '',
|
||||
file: null as File | null,
|
||||
}).dontRemember('file');
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useGuard(ref, form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
return (
|
||||
<Panel title="Registar documento adicional">
|
||||
<p className="mb-4">
|
||||
@@ -548,8 +529,7 @@ function CostPreparation(props: Props & { url: string; historyKey: string }) {
|
||||
})) ?? ([] as DraftComponent[]),
|
||||
reason: '',
|
||||
});
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useGuard(ref, form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const selection = () => ({
|
||||
budget_id: form.data.budget_id,
|
||||
item_references: form.data.components
|
||||
@@ -1048,8 +1028,7 @@ function FinancialStage({
|
||||
reason: '',
|
||||
sources: [] as string[],
|
||||
});
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useGuard(ref, form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
if (!financialReady || !latest) return null;
|
||||
const current = latest.state === 'approved';
|
||||
const changed =
|
||||
@@ -1322,8 +1301,7 @@ export default function ImportCosts(props: Props) {
|
||||
operation_key: crypto.randomUUID(),
|
||||
reason: '',
|
||||
});
|
||||
const decisionRef = useRef<HTMLFormElement>(null);
|
||||
useGuard(decisionRef, decision.isDirty);
|
||||
const decisionRef = usePreparationDirty(decision.isDirty);
|
||||
return (
|
||||
<>
|
||||
<Head title="Custo de aterragem" />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useRef } from 'react';
|
||||
import { FormErrors, PageTitle, Panel } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
@@ -69,23 +70,8 @@ export default function Dossier({
|
||||
file: null as File | null,
|
||||
},
|
||||
);
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
useEffect(() => {
|
||||
const current = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: current, dirty: form.isDirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: current, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [form.isDirty]);
|
||||
const correction = (document: Document) => {
|
||||
form.setData({
|
||||
operation_key: crypto.randomUUID(),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
@@ -139,22 +139,7 @@ export default function ImportEstimate(props: Props) {
|
||||
})),
|
||||
},
|
||||
);
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const node = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: form.isDirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [form.isDirty]);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
return (
|
||||
<>
|
||||
<Head title="Estimativa de importação" />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import {
|
||||
FormErrors,
|
||||
PageTitle,
|
||||
@@ -19,6 +19,18 @@ import {
|
||||
specificRateMinor,
|
||||
} from '@/lib/import-legal-specific-rate';
|
||||
import { date, money } from '@/types/procurement';
|
||||
import type { InvalidEvent } from 'react';
|
||||
|
||||
export function revealInvalidLegalField(event: InvalidEvent<HTMLFormElement>) {
|
||||
const field = event.currentTarget.querySelector<HTMLElement>(
|
||||
'input:invalid, select:invalid, textarea:invalid',
|
||||
);
|
||||
if (field !== event.target) return;
|
||||
requestAnimationFrame(() => {
|
||||
field.focus({ preventScroll: true });
|
||||
field.scrollIntoView({ block: 'center', behavior: 'instant' });
|
||||
});
|
||||
}
|
||||
|
||||
type LegalData = {
|
||||
title: string;
|
||||
@@ -52,15 +64,20 @@ type Page<T> = {
|
||||
type Props = {
|
||||
referenceDraftWarnings?: { source_id: number; message: string }[];
|
||||
referenceDrafts?: {
|
||||
label?: string;
|
||||
match_code?: string;
|
||||
suggested_code?: string;
|
||||
source_id: number;
|
||||
code: string;
|
||||
description: string;
|
||||
rate_percent: string;
|
||||
rate_label?: string;
|
||||
title: string;
|
||||
official_reference: string;
|
||||
official_url: string | null;
|
||||
citation: string;
|
||||
valid_from: string;
|
||||
valid_until?: string | null;
|
||||
obligations: string;
|
||||
charges: LegalCharge[];
|
||||
}[];
|
||||
@@ -137,23 +154,6 @@ const states: Record<string, string> = {
|
||||
published: 'Publicada pela área aduaneira',
|
||||
withdrawn: 'Retirada de novas sugestões',
|
||||
};
|
||||
function useDirtyForm(dirty: boolean) {
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const form = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', { detail: { form, dirty } }),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [dirty]);
|
||||
return ref;
|
||||
}
|
||||
function Pages({ page }: { page: Page<unknown> }) {
|
||||
return (
|
||||
<nav className="flex flex-wrap gap-4" aria-label="Páginas">
|
||||
@@ -181,7 +181,7 @@ function Proposal({
|
||||
`legal-proposal:${props.tenantId}:${props.actorId}:${props.requisition.id}:${rule.id}:${JSON.stringify(props.filters)}`,
|
||||
{ operation_key: '', requisition_item_id: '', reason: '', version: 0 },
|
||||
);
|
||||
const ref = useDirtyForm(form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
return (
|
||||
<form
|
||||
ref={ref}
|
||||
@@ -280,7 +280,7 @@ function ChargeEstimate({
|
||||
),
|
||||
},
|
||||
);
|
||||
const ref = useDirtyForm(form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const previous = props.estimates?.find(
|
||||
(estimate) =>
|
||||
String(estimate.data.requisition_item_id) ===
|
||||
@@ -511,7 +511,7 @@ function SourceForm({ url, scope }: { url: string; scope: string }) {
|
||||
reason: '',
|
||||
file: null as File | null,
|
||||
});
|
||||
const ref = useDirtyForm(form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
return (
|
||||
<form
|
||||
ref={ref}
|
||||
@@ -622,23 +622,8 @@ export default function ImportLegal(props: Props) {
|
||||
reason: '',
|
||||
},
|
||||
);
|
||||
const actionRef = useDirtyForm(action.isDirty);
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const node = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: form.isDirty },
|
||||
}),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form: node, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [form.isDirty]);
|
||||
const actionRef = usePreparationDirty(action.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const edit = (rule: LegalRule) => {
|
||||
form.setData({
|
||||
...form.data,
|
||||
@@ -687,11 +672,47 @@ export default function ImportLegal(props: Props) {
|
||||
>
|
||||
Voltar à classificação pautal
|
||||
</Link>
|
||||
<details className="rounded-xl border bg-card p-4">
|
||||
<summary className="cursor-pointer font-medium">
|
||||
Ir para uma área da base legal
|
||||
</summary>
|
||||
<nav
|
||||
aria-label="Áreas da base legal de importação"
|
||||
className="mt-4"
|
||||
>
|
||||
<ul className="grid gap-3 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{[
|
||||
['legal-suggestions', 'Consultar sugestões'],
|
||||
['legal-rules', 'Regras preparadas e publicadas'],
|
||||
...(props.canManage
|
||||
? [['legal-rule-editor', 'Preparar regra']]
|
||||
: []),
|
||||
...(props.canManage && action.data.record_key
|
||||
? [['legal-decision', 'Decisão preparada']]
|
||||
: []),
|
||||
['legal-sources', 'Diplomas disponíveis'],
|
||||
['legal-estimates', 'Estimativas documentadas'],
|
||||
['legal-history', 'Histórico preservado'],
|
||||
].map(([id, label]) => (
|
||||
<li key={id}>
|
||||
<a
|
||||
className="font-medium underline underline-offset-4"
|
||||
href={`#${id}`}
|
||||
>
|
||||
{label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</nav>
|
||||
</details>
|
||||
<Panel
|
||||
id="legal-suggestions"
|
||||
title="Consultar sugestões"
|
||||
description="Não havendo uma correspondência documentada, a regra permanece por determinar. As imposições descritas não são valores calculados nem activam taxas."
|
||||
>
|
||||
<form
|
||||
data-query-form="true"
|
||||
method="get"
|
||||
action={url}
|
||||
className="grid gap-3 sm:grid-cols-2"
|
||||
@@ -755,6 +776,7 @@ export default function ImportLegal(props: Props) {
|
||||
))}
|
||||
</Panel>
|
||||
<Panel
|
||||
id="legal-rules"
|
||||
title="Regras preparadas e publicadas"
|
||||
description="Uma nova preparação conserva a última publicação até ser validada. Retirar uma regra impede novas sugestões e conserva as decisões anteriores."
|
||||
>
|
||||
@@ -787,12 +809,13 @@ export default function ImportLegal(props: Props) {
|
||||
</a>
|
||||
{props.canManage && (
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => edit(rule)}
|
||||
>
|
||||
Preparar nova versão
|
||||
<Button asChild variant="outline">
|
||||
<a
|
||||
href="#legal-rule-editor"
|
||||
onClick={() => edit(rule)}
|
||||
>
|
||||
Preparar nova versão
|
||||
</a>
|
||||
</Button>
|
||||
{rule.state === 'draft' && (
|
||||
<Button
|
||||
@@ -835,6 +858,7 @@ export default function ImportLegal(props: Props) {
|
||||
</Panel>
|
||||
{props.canManage && action.data.record_key && (
|
||||
<Panel
|
||||
id="legal-decision"
|
||||
title={
|
||||
action.data.action === 'publish'
|
||||
? 'Validar e publicar a versão preparada'
|
||||
@@ -881,6 +905,7 @@ export default function ImportLegal(props: Props) {
|
||||
)}
|
||||
{props.canManage && (
|
||||
<Panel
|
||||
id="legal-rule-editor"
|
||||
title={
|
||||
form.data.record_key
|
||||
? `Preparar revisão da versão ${form.data.version}`
|
||||
@@ -902,13 +927,13 @@ export default function ImportLegal(props: Props) {
|
||||
Preparar a partir do exemplar oficial
|
||||
</h3>
|
||||
<p className="text-sm">
|
||||
Transcrição do anexo da Lei 8/2025, páginas
|
||||
2180-(4) a (7), com início em 01/01/2026. Inclui
|
||||
apenas a taxa geral dessa edição; não é uma
|
||||
pauta consolidada nem determina isenções,
|
||||
preferências ou outras imposições. A preparação
|
||||
continua editável e exige gravação e decisão
|
||||
expressas.
|
||||
Propostas identificadas por fonte, citação e
|
||||
período. Cada uma inclui apenas a imposição
|
||||
demonstrada no respectivo exemplar; não é uma
|
||||
pauta consolidada nem determina os restantes
|
||||
impostos ou preferências. Confira as condições
|
||||
da posição escolhida. A preparação continua
|
||||
editável e exige gravação e decisão expressas.
|
||||
</p>
|
||||
{form.isDirty && (
|
||||
<p className="text-sm">
|
||||
@@ -918,7 +943,7 @@ export default function ImportLegal(props: Props) {
|
||||
</p>
|
||||
)}
|
||||
<label className="grid gap-1">
|
||||
Código do anexo e fonte
|
||||
Proposta do exemplar e fonte
|
||||
<select
|
||||
className={controlClass}
|
||||
value=""
|
||||
@@ -954,9 +979,13 @@ export default function ImportLegal(props: Props) {
|
||||
draft.official_url ?? '',
|
||||
citation: draft.citation,
|
||||
valid_from: draft.valid_from,
|
||||
valid_until: '',
|
||||
match_code: draft.code,
|
||||
suggested_code: draft.code,
|
||||
valid_until:
|
||||
draft.valid_until ?? '',
|
||||
match_code:
|
||||
draft.match_code ?? draft.code,
|
||||
suggested_code:
|
||||
draft.suggested_code ??
|
||||
draft.code,
|
||||
origin_country: '',
|
||||
sector: '',
|
||||
obligations: draft.obligations,
|
||||
@@ -979,9 +1008,12 @@ export default function ImportLegal(props: Props) {
|
||||
key={`${draft.source_id}:${draft.code}`}
|
||||
value={`${draft.source_id}:${draft.code}`}
|
||||
>
|
||||
{draft.code} — {draft.description} —
|
||||
taxa geral {draft.rate_percent}% —
|
||||
fonte #{draft.source_id}
|
||||
{draft.label ??
|
||||
`${draft.code} — ${draft.description}`}{' '}
|
||||
—
|
||||
{draft.rate_label ??
|
||||
`taxa geral ${draft.rate_percent}%`}{' '}
|
||||
— fonte #{draft.source_id}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
@@ -991,6 +1023,7 @@ export default function ImportLegal(props: Props) {
|
||||
<form
|
||||
ref={ref}
|
||||
className="space-y-4"
|
||||
onInvalidCapture={revealInvalidLegalField}
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
const operation =
|
||||
@@ -1195,6 +1228,7 @@ export default function ImportLegal(props: Props) {
|
||||
</Panel>
|
||||
)}
|
||||
<Panel
|
||||
id="legal-sources"
|
||||
title="Diplomas disponíveis para consulta"
|
||||
description="Conservar um diploma não publica uma regra nem activa um cálculo. Cada regra usa a citação e o período próprios."
|
||||
>
|
||||
@@ -1217,6 +1251,7 @@ export default function ImportLegal(props: Props) {
|
||||
)}
|
||||
</Panel>
|
||||
<Panel
|
||||
id="legal-estimates"
|
||||
title="Estimativas documentadas das imposições"
|
||||
description="Valores calculados pelas taxas e bases preservadas. Não registam dívida, reserva, pagamento ou custo efectivo."
|
||||
>
|
||||
@@ -1267,7 +1302,7 @@ export default function ImportLegal(props: Props) {
|
||||
<Pages page={props.estimateHistory} />
|
||||
)}
|
||||
</Panel>
|
||||
<Panel title="Histórico preservado">
|
||||
<Panel id="legal-history" title="Histórico preservado">
|
||||
{props.history.data.map((rule) => (
|
||||
<p key={rule.id}>
|
||||
{rule.data.title} · v{rule.version} ·{' '}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { usePreparationDirty } from '@/hooks/use-preparation-dirty';
|
||||
import { Head, Link, useForm } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
FormErrors,
|
||||
@@ -64,23 +64,6 @@ type Props = {
|
||||
tenantId: number;
|
||||
};
|
||||
|
||||
function useGuard(dirty: boolean) {
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const form = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', { detail: { form, dirty } }),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [dirty]);
|
||||
return ref;
|
||||
}
|
||||
function Pagination({ page }: { page: Page<unknown> }) {
|
||||
return (
|
||||
<nav className="my-3 flex flex-wrap gap-4" aria-label="Páginas">
|
||||
@@ -123,7 +106,7 @@ function ItemForm({
|
||||
'',
|
||||
reason: '',
|
||||
});
|
||||
const ref = useGuard(form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
const submit = (action: string) => {
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
@@ -291,7 +274,7 @@ function MasterForm({
|
||||
reason: '',
|
||||
},
|
||||
);
|
||||
const ref = useGuard(form.isDirty);
|
||||
const ref = usePreparationDirty(form.isDirty);
|
||||
return (
|
||||
<details className="rounded border p-3">
|
||||
<summary>
|
||||
@@ -386,6 +369,7 @@ export default function ImportTariffs(props: Props) {
|
||||
)}
|
||||
<Panel title="Localizar material ou código">
|
||||
<form
|
||||
data-query-form="true"
|
||||
method="get"
|
||||
action={url}
|
||||
className="flex flex-wrap gap-3"
|
||||
|
||||
@@ -140,6 +140,26 @@ const titles: Record<string, string> = {
|
||||
calendar: 'Reposição e calendário',
|
||||
imports: 'Importações',
|
||||
};
|
||||
const descriptions: Record<string, string> = {
|
||||
contracts:
|
||||
'Organize contratos com vários artigos, vigência e limites globais. Consulte os artigos associados e as versões preservadas.',
|
||||
agreements:
|
||||
'Defina as condições de fornecimento por artigo, fornecedor e local. Acompanhe a vigência dos acordos e a sua ligação aos contratos.',
|
||||
calendar:
|
||||
'Defina os parâmetros de stock por artigo e local e acompanhe as necessidades de reposição e o calendário previsto.',
|
||||
imports:
|
||||
'Acompanhe as ordens importadas, desde o embarque e a chegada até à libertação aduaneira e recepção efectiva.',
|
||||
};
|
||||
const responsibilities: Record<string, string> = {
|
||||
contracts:
|
||||
'Compras prepara os contratos e os artigos associados; o conferente decide de forma independente. A vigência e os limites ficam preservados em cada versão.',
|
||||
agreements:
|
||||
'Compras prepara os acordos por artigo, fornecedor e local; o conferente decide de forma independente. As condições aprovadas orientam as políticas de reposição associadas.',
|
||||
calendar:
|
||||
'Compras prepara as políticas por artigo e local; o conferente decide de forma independente. O acompanhamento apresenta as necessidades e as datas previstas conforme os parâmetros aprovados.',
|
||||
imports:
|
||||
'Logística acompanha embarque e chegada; o responsável aduaneiro comprova a libertação. Armazém confirma a recepção efectiva e Finanças mantém a conferência de facturas e pagamentos nos circuitos existentes.',
|
||||
};
|
||||
const quantity = (value: number | undefined) =>
|
||||
value === undefined
|
||||
? '—'
|
||||
@@ -1435,37 +1455,44 @@ export default function SupplyIndex(props: Props) {
|
||||
<PageTitle
|
||||
eyebrow="Compras · Fornecimento e reposição"
|
||||
title={titles[props.view]}
|
||||
description="Seleccione os cadastros existentes e registe apenas os dados novos desta etapa. A finalidade e a origem são independentes."
|
||||
description={descriptions[props.view]}
|
||||
/>
|
||||
{(props.kind === 'agreement' ||
|
||||
props.kind === 'policy' ||
|
||||
props.kind === 'contract') && (
|
||||
<Link
|
||||
href={
|
||||
props.kind === 'contract'
|
||||
? '/compras/acordos/vigencia?kind=contract'
|
||||
: '/compras/acordos/vigencia'
|
||||
}
|
||||
className="inline-block text-sm underline"
|
||||
{['agreement', 'policy', 'contract'].includes(props.kind) && (
|
||||
<nav
|
||||
aria-label="Consultas e cadastros de fornecimento"
|
||||
className="flex flex-wrap gap-x-4 gap-y-2"
|
||||
>
|
||||
{props.kind === 'contract'
|
||||
? 'Acompanhar vigência dos contratos globais'
|
||||
: 'Acompanhar vigência dos acordos'}
|
||||
</Link>
|
||||
)}
|
||||
{props.orderLimitsReady && (
|
||||
<Link
|
||||
href={
|
||||
props.kind === 'contract'
|
||||
? '/compras/fornecimento?view=agreements'
|
||||
: '/compras/fornecimento?view=contracts'
|
||||
}
|
||||
className="inline-block text-sm underline"
|
||||
>
|
||||
{props.kind === 'contract'
|
||||
? 'Preparar artigos e limites individuais'
|
||||
: 'Contratos com vários artigos e limite global'}
|
||||
</Link>
|
||||
{(props.kind === 'agreement' ||
|
||||
props.kind === 'policy' ||
|
||||
props.kind === 'contract') && (
|
||||
<Link
|
||||
href={
|
||||
props.kind === 'contract'
|
||||
? '/compras/acordos/vigencia?kind=contract'
|
||||
: '/compras/acordos/vigencia'
|
||||
}
|
||||
className="inline-block text-sm underline"
|
||||
>
|
||||
{props.kind === 'contract'
|
||||
? 'Acompanhar vigência dos contratos globais'
|
||||
: 'Acompanhar vigência dos acordos'}
|
||||
</Link>
|
||||
)}
|
||||
{props.orderLimitsReady && (
|
||||
<Link
|
||||
href={
|
||||
props.kind === 'contract'
|
||||
? '/compras/fornecimento?view=agreements'
|
||||
: '/compras/fornecimento?view=contracts'
|
||||
}
|
||||
className="inline-block text-sm underline"
|
||||
>
|
||||
{props.kind === 'contract'
|
||||
? 'Preparar artigos e limites individuais'
|
||||
: 'Contratos com vários artigos e limite global'}
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
)}
|
||||
{props.linkedContractKey && (
|
||||
<p className="rounded border p-3 text-sm">
|
||||
@@ -1496,12 +1523,7 @@ export default function SupplyIndex(props: Props) {
|
||||
)}
|
||||
<Panel title="Responsabilidades">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Compras prepara os acordos e a reposição; o conferente
|
||||
decide de forma independente. Logística acompanha
|
||||
embarque e chegada; o responsável aduaneiro comprova a
|
||||
libertação. Armazém confirma a recepção efectiva e
|
||||
Finanças mantém a conferência de facturas e pagamentos
|
||||
nos circuitos existentes.
|
||||
{responsibilities[props.view]}
|
||||
</p>
|
||||
</Panel>
|
||||
{props.view === 'calendar' && props.ready && (
|
||||
@@ -1528,7 +1550,9 @@ export default function SupplyIndex(props: Props) {
|
||||
? 'Nova política por artigo e local'
|
||||
: props.kind === 'import'
|
||||
? 'Acompanhar uma ordem importada'
|
||||
: 'Novo acordo de fornecimento'
|
||||
: props.kind === 'contract'
|
||||
? 'Novo contrato com vários artigos'
|
||||
: 'Novo acordo de fornecimento'
|
||||
}
|
||||
>
|
||||
<details>
|
||||
@@ -1575,10 +1599,16 @@ export default function SupplyIndex(props: Props) {
|
||||
<Panel
|
||||
key={`${record.record_key}-${record.version}`}
|
||||
title={
|
||||
record.snapshot.item
|
||||
? `${record.snapshot.item.code} · ${record.snapshot.item.name}`
|
||||
: (record.snapshot.order?.number ??
|
||||
'Processo de fornecimento')
|
||||
props.kind === 'contract'
|
||||
? typeof record.data.reference ===
|
||||
'string' &&
|
||||
record.data.reference.trim() !== ''
|
||||
? `Contrato ${record.data.reference}`
|
||||
: 'Contrato sem referência indicada'
|
||||
: record.snapshot.item
|
||||
? `${record.snapshot.item.code} · ${record.snapshot.item.name}`
|
||||
: (record.snapshot.order?.number ??
|
||||
'Processo de fornecimento')
|
||||
}
|
||||
description={`${states[record.state]} · Versão ${record.version} · ${record.snapshot.warehouse?.name ?? record.data.jurisdiction ?? ''}`}
|
||||
>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Head, Link, router, useForm } from "@inertiajs/react";
|
||||
import { PageTitle, Panel, controlClass } from "@/components/procurement";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { roleLabels, statusLabels } from "@/types/procurement";
|
||||
import { Head, Link, router, useForm } from '@inertiajs/react';
|
||||
import { PageTitle, Panel, controlClass } from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { roleLabels, statusLabels } from '@/types/procurement';
|
||||
|
||||
type Props = {
|
||||
ready: boolean;
|
||||
@@ -61,13 +61,13 @@ export default function Notices({
|
||||
</div>
|
||||
<Panel
|
||||
title={
|
||||
view === "unread"
|
||||
? "Por ler"
|
||||
: view === "outcomes"
|
||||
? "Resultados dos meus pedidos"
|
||||
: view === "tasks"
|
||||
? "Intervenções pendentes"
|
||||
: "Avisos internos"
|
||||
view === 'unread'
|
||||
? 'Por ler'
|
||||
: view === 'outcomes'
|
||||
? 'Resultados dos meus pedidos'
|
||||
: view === 'tasks'
|
||||
? 'Intervenções pendentes'
|
||||
: 'Avisos internos'
|
||||
}
|
||||
description="Intervenções concluídas deixam a fila pendente. Resultados registados mantêm-se visíveis ao requisitante com acesso actual. Não são criados avisos retroactivos para decisões antigas."
|
||||
>
|
||||
@@ -79,6 +79,7 @@ export default function Notices({
|
||||
Localizar por referência da requisição
|
||||
</summary>
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="mt-3 flex flex-wrap items-end gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
@@ -86,7 +87,7 @@ export default function Notices({
|
||||
...data,
|
||||
view,
|
||||
}));
|
||||
form.get("/requisicoes/avisos", {
|
||||
form.get('/requisicoes/avisos', {
|
||||
preserveState: true,
|
||||
});
|
||||
}}
|
||||
@@ -99,7 +100,7 @@ export default function Notices({
|
||||
value={form.data.search}
|
||||
onChange={(event) =>
|
||||
form.setData(
|
||||
"search",
|
||||
'search',
|
||||
event.target.value,
|
||||
)
|
||||
}
|
||||
@@ -118,7 +119,7 @@ export default function Notices({
|
||||
</form>
|
||||
</details>
|
||||
<p className="mb-3 text-sm text-muted-foreground">
|
||||
{notices.total} aviso(s) nesta consulta · Página{" "}
|
||||
{notices.total} aviso(s) nesta consulta · Página{' '}
|
||||
{notices.current_page}
|
||||
</p>
|
||||
{!ready ? (
|
||||
@@ -135,32 +136,32 @@ export default function Notices({
|
||||
className="font-medium underline"
|
||||
href={notice.href}
|
||||
>
|
||||
{notice.reference} ·{" "}
|
||||
{notice.reference} ·{' '}
|
||||
{notice.role_label ??
|
||||
roleLabels[notice.role] ??
|
||||
notice.role}
|
||||
</Link>
|
||||
{notice.kind === "outcome" && (
|
||||
{notice.kind === 'outcome' && (
|
||||
<p className="mt-2 text-sm">
|
||||
Resultado registado:{" "}
|
||||
{notice.outcome === "approved"
|
||||
? "requisição aprovada"
|
||||
: notice.outcome === "expired"
|
||||
? "pedido devolvido por expiração"
|
||||
: "requisição rejeitada"}
|
||||
. Estado actual:{" "}
|
||||
Resultado registado:{' '}
|
||||
{notice.outcome === 'approved'
|
||||
? 'requisição aprovada'
|
||||
: notice.outcome === 'expired'
|
||||
? 'pedido devolvido por expiração'
|
||||
: 'requisição rejeitada'}
|
||||
. Estado actual:{' '}
|
||||
{statusLabels[notice.current_status] ??
|
||||
notice.current_status}
|
||||
. Consulte o processo para conhecer o
|
||||
fundamento e os passos seguintes.
|
||||
</p>
|
||||
)}
|
||||
{notice.kind === "reminder" && (
|
||||
{notice.kind === 'reminder' && (
|
||||
<p className="mt-2 text-sm">
|
||||
Lembrete da etapa de aprovação pendente.
|
||||
</p>
|
||||
)}
|
||||
{notice.kind === "escalation" && (
|
||||
{notice.kind === 'escalation' && (
|
||||
<p className="mt-2 text-sm">
|
||||
Alerta de escalamento da etapa pendente.
|
||||
Consulte o processo e os responsáveis
|
||||
@@ -168,7 +169,7 @@ export default function Notices({
|
||||
</p>
|
||||
)}
|
||||
<p className="mt-2 text-sm">
|
||||
{notice.read_at ? "Lido" : "Por ler"} ·
|
||||
{notice.read_at ? 'Lido' : 'Por ler'} ·
|
||||
Criado em {notice.created_at}
|
||||
</p>
|
||||
{!notice.read_at && (
|
||||
|
||||
@@ -98,6 +98,7 @@ export default function Tasks({
|
||||
</div>
|
||||
<Panel title="Trabalho pendente">
|
||||
<form
|
||||
data-query-form="true"
|
||||
className="mb-4 flex flex-wrap items-end gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<p>Subtotal sem IVA: {{ $money($order->subtotal_minor) }}<br>IVA: {{ $money($order->tax_minor) }}<br>Total com IVA: {{ $money($order->total_minor) }}</p>
|
||||
@else
|
||||
<p>{{ $snapshot['company']['name'] }} · {{ $snapshot['requisition']['number'] }}</p>
|
||||
<div class="notice"><strong>Documento de desenvolvimento. Não autoriza compras reais.</strong><br>@if(($snapshot['budget_checked'] ?? false) === true) Controlo orçamental confirmado para as parcelas emitidas. @else Orçamento não verificado. @endif @if($snapshot['approval_rules']['rules_provisional']) Regras de aprovação provisórias. @endif</div>
|
||||
<div class="notice"><strong>Documento de desenvolvimento. Não autoriza compras reais.</strong><br>@if(($snapshot['budget_checked'] ?? false) === true) Controlo orçamental registado na emissão. @else Este documento não preserva confirmação do controlo orçamental. @endif @if($snapshot['approval_rules']['rules_provisional']) Regras de aprovação provisórias. @endif</div>
|
||||
<div class="columns">
|
||||
<div><h2>Fornecedor</h2><strong>{{ $snapshot['supplier']['name'] }}</strong><br>NUIT {{ $snapshot['supplier']['nuit'] }}<br><span class="pre">{{ $snapshot['supplier']['address'] }}</span><br>{{ $snapshot['supplier']['contact'] }}<br>{{ $snapshot['supplier']['phone'] }} · {{ $snapshot['supplier']['email'] }}</div>
|
||||
<div><h2>Condições</h2>Entrega: {{ $snapshot['award']['delivery_date'] }}<br><span class="pre">{{ $snapshot['award']['delivery_location'] }}</span><br>Pagamento: {{ $snapshot['quotation']['payment_terms'] }}<br>Proposta: {{ $snapshot['quotation']['reference'] }}<br>{{ $snapshot['department']['name'] }} · {{ $snapshot['cost_center']['code'] }}<br>Emitente: {{ $snapshot['issuer']['name'] }}<br>Emissão: {{ $order->issued_at->format('Y-m-d H:i:s') }}</div>
|
||||
|
||||
Reference in New Issue
Block a user