export interface B2BCustomer {
  id?: string;
  tenant_id: string;
  company_name: string;
  contact_name?: string;
  contact_email?: string;
  contact_phone?: string;
  credit_limit: number;
  credit_used: number;
  payment_terms: number;
  tier_level: 'BRONZE' | 'SILVER' | 'GOLD' | 'PLATINUM';
  status: 'ACTIVE' | 'SUSPENDED' | 'INACTIVE';
  trace_id?: string;
  business_type?: 'TOB';
  created_at?: Date;
  updated_at?: Date;
}

export interface TieredPrice {
  id?: string;
  product_id: string;
  tenant_id: string;
  min_quantity: number;
  max_quantity?: number;
  price: number;
  discount_percent: number;
  trace_id?: string;
  created_at?: Date;
}

export interface BatchOrder {
  id?: string;
  tenant_id: string;
  customer_id: string;
  total_amount: number;
  payment_status: 'PENDING' | 'PARTIAL' | 'PAID' | 'OVERDUE';
  due_date?: Date;
  trace_id?: string;
  task_id?: string;
  business_type?: 'TOB';
  items?: BatchOrderItem[];
  created_at?: Date;
  updated_at?: Date;
}

export interface BatchOrderItem {
  product_id: string;
  sku_id?: string;
  quantity: number;
  unit_price: number;
  discount_percent?: number;
}

export interface TieredPriceResult {
  unitPrice: number;
  totalAmount: number;
  discountPercent: number;
  appliedTier: {
    minQuantity: number;
    maxQuantity?: number;
  };
}

export interface CreditStatus {
  customerId: string;
  creditLimit: number;
  creditUsed: number;
  creditAvailable: number;
  canPlaceOrder: boolean;
  reason?: string;
}

export interface PaymentTermsConfig {
  days: number;
  autoApprove: boolean;
}

export interface PaymentTerms {
  customerId: string;
  days: number;
  status: 'ACTIVE' | 'SUSPENDED' | 'EXPIRED';
  effectiveFrom: Date;
  effectiveTo?: Date;
}
