- Added existing_material_ids to PurchaseForEdit and RestockForEdit types. - Introduced RawMaterialVariant and ProductVariantForRestock types for better variant handling. - Updated PurchaseCreate and PurchaseEdit components to fetch and display raw material variants. - Enhanced RestockCreate and RestockEdit components to manage product variants dynamically. - Modified TransactionCreate and TransactionEdit components to support product variants. - Added routes for fetching active products and raw materials.
108 lines
2.3 KiB
TypeScript
108 lines
2.3 KiB
TypeScript
export type PurchaseItem = {
|
|
id: number;
|
|
raw_material_price_id: number;
|
|
quantity: number;
|
|
unit_price: number;
|
|
subtotal: number;
|
|
variant_name: string;
|
|
};
|
|
|
|
export type Purchase = {
|
|
id: number;
|
|
supplier_id: number;
|
|
created_by_id: number;
|
|
subtotal: number;
|
|
discount: number;
|
|
shipping_cost: number;
|
|
total: number;
|
|
notes: string | null;
|
|
photo_urls: string[];
|
|
photo_conversion_urls: string[];
|
|
created_at: string;
|
|
variants_count: number;
|
|
materials_count: number;
|
|
total_qty: number;
|
|
material_name: string | null;
|
|
unit: string | null;
|
|
supplier: {
|
|
id: number;
|
|
name: string;
|
|
};
|
|
created_by: {
|
|
id: number;
|
|
user_profile: {
|
|
full_name: string;
|
|
};
|
|
};
|
|
purchase_items?: PurchaseItemDetail[];
|
|
};
|
|
|
|
export type PurchaseItemDetail = {
|
|
id: number;
|
|
raw_material_price_id: number;
|
|
quantity: number;
|
|
unit_price: number;
|
|
subtotal: number;
|
|
raw_material_price: {
|
|
id: number;
|
|
variant: string;
|
|
price: number;
|
|
stock: number;
|
|
photo_url: string | null;
|
|
photo_conversion_url: string | null;
|
|
raw_material: {
|
|
id: number;
|
|
name: string;
|
|
unit: string;
|
|
};
|
|
};
|
|
};
|
|
|
|
export type PurchaseForEdit = {
|
|
id: number;
|
|
name: string;
|
|
unit: string;
|
|
supplier_id: number;
|
|
discount: number;
|
|
shipping_cost: number;
|
|
notes: string | null;
|
|
photo_keys: string[];
|
|
photo_urls: string[];
|
|
variants: {
|
|
id: number;
|
|
variant: string;
|
|
price: number;
|
|
stock: number;
|
|
photo_key: string | null;
|
|
photo_url: string | null;
|
|
}[];
|
|
default_mode: 'new' | 'existing';
|
|
existing_material_name: string | null;
|
|
existing_quantities: Record<string, number>;
|
|
existing_material_ids: number[];
|
|
};
|
|
|
|
export type Supplier = {
|
|
id: number;
|
|
name: string;
|
|
};
|
|
|
|
export type PurchaseCreateData = {
|
|
suppliers: Supplier[];
|
|
rawMaterials: {
|
|
id: number;
|
|
name: string;
|
|
unit: string;
|
|
}[];
|
|
};
|
|
|
|
export type RawMaterialVariant = {
|
|
id: number;
|
|
raw_material_id: number;
|
|
variant: string;
|
|
price: number;
|
|
stock: number;
|
|
photo_url: string | null;
|
|
photo_conversion_url: string | null;
|
|
};
|