@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user