commit melhorias compras5
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-22 19:39:09 +02:00
parent 36dcfdf00c
commit db1615fac1
79 changed files with 4082 additions and 120 deletions
@@ -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