/**
 * Sales Reference Data Port
 * Provides access to reference data needed for sales operations
 */

export type Customer = {
  id: string;
  name: string;
  category?: string;
  email?: string;
  phone?: string;
  creditLimit?: number;
  allowedDiscount?: number; // %
};

export type Material = {
  id: string;
  name: string;
  salePrice?: number;
  category?: string;
};

export type Warehouse = {
  id: string;
  name: string;
  shelves?: Array<{ id: string; name: string }>;
};

export type Currency = {
  code: string;
  name: string;
  symbol: string;
};

export type SalesRep = {
  id: string;
  name: string;
  commissionRate?: number;
};

export interface SalesReferenceDataPort {
  /**
   * Get customer details
   */
  getCustomer(id: string): Promise<Customer | null>;

  /**
   * List all customers
   */
  listCustomers(options?: {
    category?: string;
    search?: string;
  }): Promise<Customer[]>;

  /**
   * Get material details
   */
  getMaterial(id: string): Promise<Material | null>;

  /**
   * List all materials for sale
   */
  listMaterials(options?: {
    category?: string;
    search?: string;
  }): Promise<Material[]>;

  /**
   * Get warehouse details
   */
  getWarehouse(id: string): Promise<Warehouse | null>;

  /**
   * List all warehouses
   */
  listWarehouses(): Promise<Warehouse[]>;

  /**
   * Get currency details
   */
  getCurrency(code: string): Promise<Currency | null>;

  /**
   * List all currencies
   */
  listCurrencies(): Promise<Currency[]>;

  /**
   * Get base currency code
   */
  getBaseCurrencyCode(): Promise<string>;

  /**
   * Get sales rep details
   */
  getSalesRep(id: string): Promise<SalesRep | null>;

  /**
   * List all sales reps
   */
  listSalesReps(): Promise<SalesRep[]>;

  /**
   * Get customer pricing for material
   */
  getCustomerPricing(
    customerId: string,
    materialId: string
  ): Promise<number | null>;

  /**
   * Get customer category pricing adjustments
   */
  getCategoryPricing(category: string): Promise<Record<string, number> | null>;
}
