garage-erp/apps/dashboard/modules/inventory-adjustments/inventory-adjustment.schema.ts
humam kerdiah 4bfd8c84a9 feat: add template checkpoint edit dialog and vendor management components
- Implemented TemplateCheckpointEditDialog for creating and editing inspection checkpoints.
- Added VendorActions component for managing vendor actions including edit, activate/deactivate, and delete.
- Created VendorContext for managing vendor state across components.
- Developed VendorGeneralInfo component to display detailed vendor information.
- Introduced AedSymbol and Money components for consistent currency representation.
- Added PromptDialog for user input prompts throughout the application.
- Implemented RelationLink component for unified related-data display in CRUD tables.
- Created InspectionTemplatesClient for API interactions related to inspection templates.
2026-05-18 12:08:42 +04:00

31 lines
1.3 KiB
TypeScript

import { z } from "zod"
export const relationFieldSchema = z
.object({ value: z.string(), label: z.string() })
.nullable()
const partLineSchema = z.object({
part: relationFieldSchema,
quantity: z.coerce.number().int().min(1, "Quantity must be at least 1"),
operation: z.enum(["add", "subtract"]).default("add"),
rate: z.coerce.number().min(0, "Rate must be 0 or more"),
})
export const inventoryAdjustmentFormSchema = z.object({
reference_number: z.string().min(1, "Reference number is required").max(255, "Reference number cannot exceed 255 characters"),
date: z.string().min(1, "Date is required"),
// TODO: pending chart-of-accounts module. Until then this is a free integer
// that the backend stores as-is; replace with an async select bound to the
// chart-of-accounts API once the module ships.
chart_of_account: z.preprocess(
(v) => (v === "" || v == null ? undefined : v),
z.coerce.number().int("Chart of account must be a whole number").optional(),
),
reason: relationFieldSchema,
notes: z.string().optional(),
parts: z.array(partLineSchema).min(1, "At least one part is required"),
})
export type InventoryAdjustmentFormValues = z.infer<typeof inventoryAdjustmentFormSchema>
export type PartLineValues = z.infer<typeof partLineSchema>