import { InventoryEventActions } from '@/components/inventory-event-actions'; import { Head, Link, useForm } from '@inertiajs/react'; import { FormErrors, PageTitle, Panel, controlClass, } from '@/components/procurement'; import { Button } from '@/components/ui/button'; type Row = { source_movement_id: number; warehouse_id: number; warehouse_name: string; original_quantity_milli: number; quantity_milli: number; original_type: string; lots: { lot_id: number | null; code: string | null; quantity: number }[]; }; type Entry = { id: number; record_key: string; version: number; state: string; reason: string; created_at: string; data: { reference: string; source_kind: string; source_operation_id: number | null; receipt_item_id: number | null; event?: { event_on: string; evidence: string }; }; snapshot: { execution_lots?: { lot_id: number; movement_id: number; quantity: number; }[]; contributors: number[]; reviewed_by?: number; actor: { name: string }; source: { document: { reference: string }; item: { code: string; name: string; unit: string }; rows: Row[]; }; }; }; type Props = { ready: boolean; actorId: number; today: string; canViewDispositions: boolean; capabilities: Record; records: Entry[]; operations: { id: number; label: string }[]; receipts: { id: number; label: string }[]; history: Record; }; const qty = (milli: number) => (milli / 1000).toLocaleString('pt-MZ', { maximumFractionDigits: 3 }); const states: Record = { draft: 'Em preparação', returned: 'Para actualização', approved: 'Aprovado para estorno', executed: 'Estorno integral registado', }; function Prepare({ props, old }: { props: Props; old?: Entry }) { const form = useForm({ operation_key: crypto.randomUUID(), record_key: old?.record_key, version: old?.version ?? 0, action: 'save', reason: '', data: { reference: old?.data.reference ?? '', source_kind: old?.data.source_kind ?? 'operation', source_operation_id: old?.data.source_operation_id ? String(old.data.source_operation_id) : '', receipt_item_id: old?.data.receipt_item_id ? String(old.data.receipt_item_id) : '', }, }); return (
{ e.preventDefault(); form.post('/stock/estornos'); }} > {form.data.data.source_kind === 'operation' ? ( ) : ( )}