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