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