import { BaseMetadata, CreatedUser } from '@/types/api/api-general';
import { ProductCategory } from '@/types/api/master-data/product-category';
import { Supplier } from '@/types/api/master-data/supplier';
import { Uom } from '@/types/api/master-data/uom';
import { Location } from '@/types/api/master-data/location';

export type BaseInventoryProduct = {
  id: number;
  name: string;
  brand: string;
  sku: string;
  ProductPrice: number;
  SellingPrice?: number;
  product_price: number;
  selling_price?: number;
  tax?: number;
  expiry_period?: number;
  uom: Uom;
  product_category: ProductCategory;
  suppliers: Supplier[];
  flags: string[];
  product_warehouses?: ProductWarehouseStock[];
  total_stock?: number;
};

export type ProductWarehouseStock = {
  id: number;
  product_id: number;
  warehouse_id: number;
  warehouse_name: string;
  location: Location | null;
  current_stock: number;
  stock_logs: StockLog[];
};

export type StockLog = {
  id: number;
  increase: number;
  decrease: number;
  stock: number;
  loggable_type: string;
  loggable_id: number;
  notes: string;
  product_warehouse_id: number;
  created_by: number;
  created_user: CreatedUser;
  created_at: string;
};

export type InventoryProduct = BaseInventoryProduct & BaseMetadata;
