/**
 * AR Aging Report types — ar-aging-report (wave-12).
 */

export type ArAgingBucketKey = 'current' | 'd1_30' | 'd31_60' | 'd61_90' | 'd90plus'

export interface ArAgingBucket {
  amount: string  // NUMERIC string, always >= '0.00'
  count: number   // number of invoices in this bucket
}

export interface ArAgingCustomerRow {
  customerId: string
  customerName: string
  customerEmail: string | null
  current: ArAgingBucket
  d1_30: ArAgingBucket
  d31_60: ArAgingBucket
  d61_90: ArAgingBucket
  d90plus: ArAgingBucket
  total: string  // sum of all buckets, NUMERIC string
}

export interface ArAgingSummary {
  current: ArAgingBucket
  d1_30: ArAgingBucket
  d31_60: ArAgingBucket
  d61_90: ArAgingBucket
  d90plus: ArAgingBucket
  total: string
}

export interface ArAgingReport {
  asOf: string       // ISO date YYYY-MM-DD
  currency: string   // 3-char ISO currency code
  summary: ArAgingSummary
  customers: ArAgingCustomerRow[]
}

// ── Request / Response DTOs ───────────────────────────────────────────────────

export interface ArAgingStatementsRequest {
  customer_ids: string[]
  as_of: string           // ISO date YYYY-MM-DD
  subject?: string
  message?: string
}

export interface ArAgingStatementsResponse {
  sent: number
}
