@@ -8,6 +8,7 @@ type SavedLevel = {
|
||||
scope: 'company' | 'department';
|
||||
min_minor: number | null;
|
||||
categories: string[];
|
||||
procurement_categories?: string[];
|
||||
cost_center_ids: number[];
|
||||
};
|
||||
export type RequisitionApprovalPlan = {
|
||||
@@ -28,6 +29,7 @@ const newLevel = () => ({
|
||||
scope: 'department' as 'company' | 'department',
|
||||
min_amount: '',
|
||||
categories_text: '',
|
||||
procurement_categories: [] as string[],
|
||||
cost_center_ids: [] as number[],
|
||||
});
|
||||
|
||||
@@ -37,12 +39,14 @@ export function RequisitionApprovalSettings({
|
||||
profiles,
|
||||
costCenters,
|
||||
version,
|
||||
categoryOptions = {},
|
||||
}: {
|
||||
plan?: RequisitionApprovalPlan | null;
|
||||
ready: boolean;
|
||||
profiles: Profile[];
|
||||
costCenters: { id: number; code: string; name: string }[];
|
||||
version: number;
|
||||
categoryOptions?: Record<string, string>;
|
||||
}) {
|
||||
const form = useForm({
|
||||
version,
|
||||
@@ -55,6 +59,7 @@ export function RequisitionApprovalSettings({
|
||||
scope: level.scope,
|
||||
min_amount: amountInput(level.min_minor),
|
||||
categories_text: level.categories.join('\n'),
|
||||
procurement_categories: level.procurement_categories ?? [],
|
||||
cost_center_ids: level.cost_center_ids,
|
||||
})) ?? [],
|
||||
});
|
||||
@@ -100,6 +105,8 @@ export function RequisitionApprovalSettings({
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean),
|
||||
cost_center_ids: level.cost_center_ids,
|
||||
procurement_categories:
|
||||
level.procurement_categories,
|
||||
})),
|
||||
}));
|
||||
form.post(
|
||||
@@ -210,7 +217,8 @@ export function RequisitionApprovalSettings({
|
||||
className="grid gap-2 text-sm"
|
||||
htmlFor={`approval-categories-${index}`}
|
||||
>
|
||||
Categorias exactas (opcional, uma por linha)
|
||||
Categorias exactas do artigo (opcional, uma
|
||||
por linha)
|
||||
<textarea
|
||||
id={`approval-categories-${index}`}
|
||||
className={controlClass}
|
||||
@@ -224,6 +232,58 @@ export function RequisitionApprovalSettings({
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
{Object.keys(categoryOptions).length > 0 && (
|
||||
<fieldset className="space-y-2 rounded-lg border p-4">
|
||||
<legend className="text-sm font-medium">
|
||||
Categoria da necessidade (RQ-01)
|
||||
</legend>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Sem selecção, esta condição não
|
||||
restringe o nível. As categorias
|
||||
seleccionadas exigem classificação
|
||||
explícita e combinam-se com o valor, a
|
||||
categoria do artigo e o centro de custo.
|
||||
Os pedidos anteriores não são
|
||||
classificados automaticamente.
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
{Object.entries(categoryOptions).map(
|
||||
([value, label]) => (
|
||||
<label
|
||||
key={value}
|
||||
className="flex items-center gap-2 text-sm"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={level.procurement_categories.includes(
|
||||
value,
|
||||
)}
|
||||
onChange={(event) =>
|
||||
change(index, {
|
||||
procurement_categories:
|
||||
event.target
|
||||
.checked
|
||||
? [
|
||||
...level.procurement_categories,
|
||||
value,
|
||||
]
|
||||
: level.procurement_categories.filter(
|
||||
(
|
||||
item,
|
||||
) =>
|
||||
item !==
|
||||
value,
|
||||
),
|
||||
})
|
||||
}
|
||||
/>
|
||||
{label}
|
||||
</label>
|
||||
),
|
||||
)}
|
||||
</div>
|
||||
</fieldset>
|
||||
)}
|
||||
<fieldset className="space-y-2">
|
||||
<legend className="text-sm font-medium">
|
||||
Perfis elegíveis — basta um aprovador
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import { controlClass } from '@/components/procurement';
|
||||
|
||||
export const requisitionCategoryLabels: Record<string, string> = {
|
||||
production_input: 'Insumos de produção',
|
||||
spare_part: 'Peças sobressalentes',
|
||||
capital_equipment: 'Maquinaria',
|
||||
office_equipment: 'Equipamento de escritório',
|
||||
other: 'Outra categoria',
|
||||
};
|
||||
|
||||
const guidance: Record<string, string> = {
|
||||
production_input:
|
||||
'Seleccione um material de stock no catálogo publicado. A categoria original do artigo é conservada.',
|
||||
spare_part:
|
||||
'Seleccione o tipo Peça e associe a peça ao equipamento. Os controlos de stock e criticidade existentes mantêm-se.',
|
||||
capital_equipment:
|
||||
'Seleccione o tipo Equipamento e justifique o investimento. Mantêm-se a validação técnica, Finanças e o orçamento de investimento.',
|
||||
office_equipment:
|
||||
'Prefira um artigo do catálogo; se usar texto livre, explique a necessidade.',
|
||||
other: 'Identifique a categoria do artigo e justifique o uso de texto livre quando não existir selecção do catálogo.',
|
||||
};
|
||||
|
||||
export function RequisitionCategoryFields({
|
||||
index,
|
||||
category,
|
||||
reason,
|
||||
options,
|
||||
onChange,
|
||||
}: {
|
||||
index: number;
|
||||
category: string;
|
||||
reason: string;
|
||||
options: Record<string, string>;
|
||||
onChange: (
|
||||
field: 'procurement_category' | 'category_reason',
|
||||
value: string,
|
||||
) => void;
|
||||
}) {
|
||||
const prefix = `rq-category-${index}`;
|
||||
return (
|
||||
<div className="grid gap-3 rounded-lg border p-4 sm:col-span-3">
|
||||
<label className="grid gap-2 text-sm" htmlFor={prefix}>
|
||||
Categoria da necessidade
|
||||
<select
|
||||
id={prefix}
|
||||
className={controlClass}
|
||||
value={category}
|
||||
aria-describedby={`${prefix}-help`}
|
||||
onChange={(event) =>
|
||||
onChange('procurement_category', event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Sem classificação adicional</option>
|
||||
{Object.entries(options).map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p id={`${prefix}-help`} className="text-sm text-muted-foreground">
|
||||
{(!category && reason
|
||||
? 'Seleccione a categoria para este motivo ou limpe-o se não quiser classificação adicional.'
|
||||
: guidance[category]) ??
|
||||
'Conserva a categoria original do artigo. Uma classificação anterior não é inferida nem alterada automaticamente.'}
|
||||
</p>
|
||||
{(category || reason) && (
|
||||
<label
|
||||
className="grid gap-2 text-sm"
|
||||
htmlFor={`${prefix}-reason`}
|
||||
>
|
||||
{category === 'capital_equipment'
|
||||
? 'Justificação do investimento'
|
||||
: 'Justificação da categoria ou do texto livre'}
|
||||
<textarea
|
||||
id={`${prefix}-reason`}
|
||||
className={controlClass}
|
||||
maxLength={2000}
|
||||
value={reason}
|
||||
onChange={(event) =>
|
||||
onChange('category_reason', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
import { Link, router, useForm, usePage, useRemember } from '@inertiajs/react';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { FormErrors, Panel, controlClass } from '@/components/procurement';
|
||||
|
||||
type SavedSearch = {
|
||||
id: number;
|
||||
name: string;
|
||||
term: string;
|
||||
version: number;
|
||||
href: string;
|
||||
};
|
||||
export type SavedSearches = {
|
||||
max_active: number;
|
||||
active: SavedSearch[];
|
||||
archived: {
|
||||
data: SavedSearch[];
|
||||
total: number;
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
};
|
||||
|
||||
function usePrivatePreparation(dirty: boolean) {
|
||||
const ref = useRef<HTMLFormElement>(null);
|
||||
useEffect(() => {
|
||||
const form = ref.current;
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', { detail: { form, dirty } }),
|
||||
);
|
||||
return () => {
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('sgc:context-dirty', {
|
||||
detail: { form, dirty: false },
|
||||
}),
|
||||
);
|
||||
};
|
||||
}, [dirty]);
|
||||
return ref;
|
||||
}
|
||||
|
||||
function SavedSearchRow({
|
||||
row,
|
||||
term,
|
||||
archived = false,
|
||||
}: {
|
||||
row: SavedSearch;
|
||||
term: string;
|
||||
archived?: boolean;
|
||||
}) {
|
||||
const actor = usePage().props.auth?.user;
|
||||
const historyKey = `saved-search-edit:${actor?.tenant_id ?? 'none'}:${actor?.id ?? 'none'}:${row.id}:${row.version}`;
|
||||
const [editing, setEditing] = useRemember(false, `${historyKey}:editing`);
|
||||
const edit = useForm(historyKey, {
|
||||
name: row.name,
|
||||
term: row.term,
|
||||
version: row.version,
|
||||
q: term,
|
||||
});
|
||||
const action = useForm({ version: row.version, q: term });
|
||||
const ref = usePrivatePreparation(editing && edit.isDirty);
|
||||
const endpoint = `/compras/pesquisas-guardadas/${row.id}`;
|
||||
return (
|
||||
<li className="grid min-w-0 grid-cols-1 gap-3 border-b py-4 last:border-0">
|
||||
{editing ? (
|
||||
<form
|
||||
ref={ref}
|
||||
className="grid gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
edit.transform((data) => ({ ...data, q: term }));
|
||||
edit.put(endpoint, {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => setEditing(false),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<label className="grid gap-2 text-sm">
|
||||
Nome da pesquisa
|
||||
<input
|
||||
className={controlClass}
|
||||
value={edit.data.name}
|
||||
maxLength={100}
|
||||
required
|
||||
onChange={(event) =>
|
||||
edit.setData('name', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="grid gap-2 text-sm">
|
||||
Texto a procurar
|
||||
<input
|
||||
className={controlClass}
|
||||
value={edit.data.term}
|
||||
minLength={2}
|
||||
maxLength={100}
|
||||
required
|
||||
onChange={(event) =>
|
||||
edit.setData('term', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<FormErrors errors={edit.errors} />
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<Button disabled={edit.processing}>
|
||||
Guardar alterações
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => {
|
||||
edit.reset();
|
||||
setEditing(false);
|
||||
}}
|
||||
>
|
||||
Cancelar edição
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<>
|
||||
{archived ? (
|
||||
<p className="font-medium break-words">{row.name}</p>
|
||||
) : (
|
||||
<Link
|
||||
className="font-medium break-words underline"
|
||||
href={row.href}
|
||||
>
|
||||
{row.name}
|
||||
</Link>
|
||||
)}
|
||||
<p className="text-sm break-words text-muted-foreground">
|
||||
Critério: {row.term}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{!archived && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => setEditing(true)}
|
||||
aria-label={`Editar pesquisa ${row.name}`}
|
||||
>
|
||||
Editar
|
||||
</Button>
|
||||
)}
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={action.processing}
|
||||
aria-label={`${archived ? 'Restaurar' : 'Arquivar'} pesquisa ${row.name}`}
|
||||
onClick={() => {
|
||||
action.transform((data) => ({
|
||||
...data,
|
||||
q: term,
|
||||
}));
|
||||
action.post(
|
||||
`${endpoint}/${archived ? 'restaurar' : 'arquivar'}`,
|
||||
{ preserveScroll: true },
|
||||
);
|
||||
}}
|
||||
>
|
||||
{archived ? 'Restaurar' : 'Arquivar'}
|
||||
</Button>
|
||||
</div>
|
||||
<FormErrors errors={action.errors} />
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
export function SavedProcurementSearches({
|
||||
saved,
|
||||
term,
|
||||
}: {
|
||||
saved: SavedSearches;
|
||||
term: string;
|
||||
}) {
|
||||
const actor = usePage().props.auth?.user;
|
||||
const [managing, setManaging] = useRemember(
|
||||
false,
|
||||
`saved-search-management:${actor?.tenant_id ?? 'none'}:${actor?.id ?? 'none'}`,
|
||||
);
|
||||
const create = useForm(
|
||||
`saved-search:${actor?.tenant_id ?? 'none'}:${actor?.id ?? 'none'}:${term}`,
|
||||
{ name: '', term, q: term },
|
||||
);
|
||||
const ref = usePrivatePreparation(create.data.name !== '');
|
||||
return (
|
||||
<Panel title="As minhas pesquisas guardadas">
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Guarde apenas os critérios. Ao reabrir, os resultados são
|
||||
consultados de novo com o seu acesso actual. Estas pesquisas são
|
||||
privadas; arquivar conserva os critérios e permite restaurá-los.
|
||||
</p>
|
||||
<label
|
||||
className="my-4 grid gap-2 text-sm"
|
||||
htmlFor="saved-search-open"
|
||||
>
|
||||
Reabrir uma pesquisa
|
||||
<select
|
||||
id="saved-search-open"
|
||||
className={controlClass}
|
||||
value=""
|
||||
disabled={saved.active.length === 0}
|
||||
onChange={(event) => {
|
||||
const row = saved.active.find(
|
||||
(item) => String(item.id) === event.target.value,
|
||||
);
|
||||
if (row) router.get(row.href);
|
||||
}}
|
||||
>
|
||||
<option value="">Seleccione uma pesquisa guardada</option>
|
||||
{saved.active.map((row) => (
|
||||
<option key={row.id} value={row.id}>
|
||||
{row.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<details
|
||||
open={managing}
|
||||
onToggle={(event) => setManaging(event.currentTarget.open)}
|
||||
className="rounded-lg border p-4"
|
||||
>
|
||||
<summary className="cursor-pointer">
|
||||
Guardar, editar ou arquivar pesquisas
|
||||
</summary>
|
||||
<form
|
||||
ref={ref}
|
||||
className="my-4 grid gap-3"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
create.transform((data) => ({
|
||||
...data,
|
||||
term,
|
||||
q: term,
|
||||
}));
|
||||
create.post('/compras/pesquisas-guardadas', {
|
||||
preserveScroll: true,
|
||||
onSuccess: () => create.reset('name'),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<p className="text-sm break-words">
|
||||
Pesquisa apresentada:{' '}
|
||||
{term || 'Introduza primeiro o texto a procurar.'}
|
||||
</p>
|
||||
<label className="grid gap-2 text-sm">
|
||||
Nome para guardar esta pesquisa
|
||||
<input
|
||||
className={controlClass}
|
||||
maxLength={100}
|
||||
value={create.data.name}
|
||||
onChange={(event) =>
|
||||
create.setData('name', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<FormErrors errors={create.errors} />
|
||||
<Button
|
||||
className="justify-self-start"
|
||||
disabled={
|
||||
create.processing ||
|
||||
!create.data.name.trim() ||
|
||||
term.trim().length < 2
|
||||
}
|
||||
>
|
||||
Guardar pesquisa
|
||||
</Button>
|
||||
</form>
|
||||
<p className="text-sm">
|
||||
{saved.active.length}{' '}
|
||||
{saved.active.length === 1
|
||||
? 'pesquisa activa'
|
||||
: 'pesquisas activas'}{' '}
|
||||
· até {saved.max_active} por utilizador.
|
||||
</p>
|
||||
<ul>
|
||||
{saved.active.map((row) => (
|
||||
<SavedSearchRow
|
||||
key={`${row.id}:${row.version}`}
|
||||
row={row}
|
||||
term={term}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
{saved.archived.total > 0 && (
|
||||
<details className="mt-4 rounded-lg border p-4">
|
||||
<summary className="cursor-pointer">
|
||||
Pesquisas arquivadas ({saved.archived.total})
|
||||
</summary>
|
||||
<ul>
|
||||
{saved.archived.data.map((row) => (
|
||||
<SavedSearchRow
|
||||
key={`${row.id}:${row.version}`}
|
||||
row={row}
|
||||
term={term}
|
||||
archived
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
<nav
|
||||
aria-label="Pesquisas arquivadas"
|
||||
className="flex flex-wrap gap-4"
|
||||
>
|
||||
{saved.archived.prev_page_url && (
|
||||
<Link href={saved.archived.prev_page_url}>
|
||||
Anteriores
|
||||
</Link>
|
||||
)}
|
||||
{saved.archived.next_page_url && (
|
||||
<Link href={saved.archived.next_page_url}>
|
||||
Seguintes
|
||||
</Link>
|
||||
)}
|
||||
</nav>
|
||||
</details>
|
||||
)}
|
||||
</details>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
@@ -21,8 +21,19 @@ function preparation(data: Record<string, unknown>): unknown {
|
||||
typeof item === 'object' &&
|
||||
!Array.isArray(item)
|
||||
) {
|
||||
const { key: _rowKey, ...values } = item;
|
||||
return values;
|
||||
const {
|
||||
key: _rowKey,
|
||||
procurement_category,
|
||||
category_reason,
|
||||
...values
|
||||
} = item;
|
||||
return {
|
||||
...values,
|
||||
...(procurement_category
|
||||
? { procurement_category }
|
||||
: {}),
|
||||
...(category_reason ? { category_reason } : {}),
|
||||
};
|
||||
}
|
||||
return item;
|
||||
})
|
||||
|
||||
@@ -173,6 +173,7 @@ function Assignment({
|
||||
export default function Parameters({
|
||||
approvalLevels,
|
||||
approvalLevelsReady = false,
|
||||
requisitionCategoryOptions = {},
|
||||
companyDetails,
|
||||
companyDetailsReady,
|
||||
ready,
|
||||
@@ -201,6 +202,7 @@ export default function Parameters({
|
||||
}: {
|
||||
approvalLevels?: RequisitionApprovalPlan | null;
|
||||
approvalLevelsReady?: boolean;
|
||||
requisitionCategoryOptions?: Record<string, string>;
|
||||
companyDetails: CompanyDetails | null;
|
||||
companyDetailsReady: boolean;
|
||||
ready: boolean;
|
||||
@@ -316,6 +318,7 @@ export default function Parameters({
|
||||
<RequisitionApprovalSettings
|
||||
plan={approvalLevels}
|
||||
ready={approvalLevelsReady}
|
||||
categoryOptions={requisitionCategoryOptions}
|
||||
profiles={profiles}
|
||||
costCenters={costCenters}
|
||||
version={version}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Label } from '@/components/ui/label';
|
||||
import { money } from '@/types/procurement';
|
||||
import type { CostCenter, Requisition } from '@/types/procurement';
|
||||
import { CatalogueSearch } from '@/components/requisition-catalogue';
|
||||
import { RequisitionCategoryFields } from '@/components/requisition-category-fields';
|
||||
import type { CatalogueOptions } from '@/components/requisition-catalogue';
|
||||
|
||||
type Line = {
|
||||
@@ -33,6 +34,8 @@ type Line = {
|
||||
spare_part_id: string;
|
||||
production_area: string;
|
||||
downtime_started_at: string;
|
||||
procurement_category: string;
|
||||
category_reason: string;
|
||||
};
|
||||
const emptyLine = (taxRate: string): Line => ({
|
||||
source_line_id: '',
|
||||
@@ -51,10 +54,17 @@ const emptyLine = (taxRate: string): Line => ({
|
||||
spare_part_id: '',
|
||||
production_area: '',
|
||||
downtime_started_at: '',
|
||||
procurement_category: '',
|
||||
category_reason: '',
|
||||
});
|
||||
const lineFields = [
|
||||
{ key: 'description', label: 'Descrição', type: 'text', maxLength: 255 },
|
||||
{ key: 'category', label: 'Categoria', type: 'text', maxLength: 100 },
|
||||
{
|
||||
key: 'category',
|
||||
label: 'Categoria do artigo',
|
||||
type: 'text',
|
||||
maxLength: 100,
|
||||
},
|
||||
{
|
||||
key: 'quantity',
|
||||
label: 'Quantidade',
|
||||
@@ -91,6 +101,7 @@ export default function RequisitionForm({
|
||||
defaultTaxRate = '16.00',
|
||||
catalogue,
|
||||
incompleteDraftsAvailable = false,
|
||||
requisitionCategories = {},
|
||||
}: {
|
||||
costCenters: CostCenter[];
|
||||
requisition: Requisition | null;
|
||||
@@ -100,6 +111,7 @@ export default function RequisitionForm({
|
||||
defaultTaxRate?: string;
|
||||
catalogue?: CatalogueOptions;
|
||||
incompleteDraftsAvailable?: boolean;
|
||||
requisitionCategories?: Record<string, string>;
|
||||
}) {
|
||||
const page = usePage();
|
||||
const ready = page.props.internalRequisitionReady === true;
|
||||
@@ -143,6 +155,8 @@ export default function RequisitionForm({
|
||||
key: String(i.id),
|
||||
description: i.description,
|
||||
category: i.category,
|
||||
procurement_category: i.category_context?.category ?? '',
|
||||
category_reason: i.category_context?.reason ?? '',
|
||||
purchase_type: i.purchase_type,
|
||||
quantity: String(i.quantity),
|
||||
unit: i.unit,
|
||||
@@ -340,6 +354,27 @@ export default function RequisitionForm({
|
||||
LINHA {index + 1}
|
||||
</legend>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{Object.keys(requisitionCategories)
|
||||
.length > 0 && (
|
||||
<RequisitionCategoryFields
|
||||
index={index}
|
||||
category={
|
||||
line.procurement_category ??
|
||||
''
|
||||
}
|
||||
reason={
|
||||
line.category_reason ?? ''
|
||||
}
|
||||
options={requisitionCategories}
|
||||
onChange={(field, value) =>
|
||||
changeLine(
|
||||
index,
|
||||
field,
|
||||
value,
|
||||
)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{catalogue?.ready && (
|
||||
<label className="space-y-2 sm:col-span-3">
|
||||
Fonte do artigo
|
||||
|
||||
@@ -13,6 +13,7 @@ import { Button } from '@/components/ui/button';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { date, money, priorityLabels, roleLabels } from '@/types/procurement';
|
||||
import type { Requisition } from '@/types/procurement';
|
||||
import { requisitionCategoryLabels } from '@/components/requisition-category-fields';
|
||||
|
||||
type Audit = {
|
||||
id: number;
|
||||
@@ -331,10 +332,11 @@ export default function Show({
|
||||
(r.draft_input?.incomplete ? (
|
||||
<div role="status" className="rounded-xl border p-5">
|
||||
<p>
|
||||
Rascunho incompleto guardado. Os montantes estão
|
||||
por completar; não há submissão nem reserva
|
||||
orçamental. As linhas anteriormente completas
|
||||
não representam esta preparação.
|
||||
Rascunho incompleto guardado. Complete os dados
|
||||
e os requisitos aplicáveis às linhas; não há
|
||||
submissão nem reserva orçamental. As linhas
|
||||
anteriormente completas não representam esta
|
||||
preparação.
|
||||
</p>
|
||||
<Link
|
||||
className="mt-3 inline-block underline"
|
||||
@@ -453,6 +455,22 @@ export default function Show({
|
||||
<p className="mt-1 text-xs text-muted-foreground">
|
||||
{i.category}
|
||||
</p>
|
||||
{i.category_context && (
|
||||
<p className="mt-1 text-xs">
|
||||
{requisitionCategoryLabels[
|
||||
i
|
||||
.category_context
|
||||
.category
|
||||
] ??
|
||||
i
|
||||
.category_context
|
||||
.category}
|
||||
{i
|
||||
.category_context
|
||||
.reason &&
|
||||
` · ${i.category_context.reason}`}
|
||||
</p>
|
||||
)}
|
||||
{i.equipment_id && (
|
||||
<p className="mt-1 text-xs">
|
||||
Equipamento #
|
||||
|
||||
@@ -6,6 +6,8 @@ import {
|
||||
controlClass,
|
||||
} from '@/components/procurement';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { SavedProcurementSearches } from '@/components/saved-procurement-searches';
|
||||
import type { SavedSearches } from '@/components/saved-procurement-searches';
|
||||
|
||||
type Group = {
|
||||
key: string;
|
||||
@@ -34,10 +36,12 @@ export default function ProcurementSearch({
|
||||
term,
|
||||
groups,
|
||||
invoiceSearchAvailable = false,
|
||||
savedSearches = null,
|
||||
}: {
|
||||
term: string;
|
||||
groups: Group[];
|
||||
invoiceSearchAvailable?: boolean;
|
||||
savedSearches?: SavedSearches | null;
|
||||
}) {
|
||||
const form = useForm({ q: term });
|
||||
return (
|
||||
@@ -90,6 +94,13 @@ export default function ProcurementSearch({
|
||||
</p>
|
||||
)}
|
||||
</Panel>
|
||||
{savedSearches && (
|
||||
<SavedProcurementSearches
|
||||
key={term}
|
||||
saved={savedSearches}
|
||||
term={term}
|
||||
/>
|
||||
)}
|
||||
{term.trim().length < 2 && (
|
||||
<p role="status">
|
||||
Introduza pelo menos dois caracteres para pesquisar.
|
||||
|
||||
@@ -14,6 +14,11 @@ export type Company = {
|
||||
rules_provisional: boolean;
|
||||
};
|
||||
export type RequisitionItem = {
|
||||
category_context?: {
|
||||
version: number;
|
||||
category: string;
|
||||
reason: string | null;
|
||||
} | null;
|
||||
catalogue_entry_id?: number | null;
|
||||
catalogue_snapshot?: {
|
||||
entry_id: number;
|
||||
@@ -42,7 +47,11 @@ export type RequisitionItem = {
|
||||
total_minor: number;
|
||||
};
|
||||
export type ApprovalStep = {
|
||||
routing?: { name: string; scope: 'company' | 'department'; profile_ids: number[] } | null;
|
||||
routing?: {
|
||||
name: string;
|
||||
scope: 'company' | 'department';
|
||||
profile_ids: number[];
|
||||
} | null;
|
||||
id: number;
|
||||
position: number;
|
||||
role: string;
|
||||
|
||||
Reference in New Issue
Block a user