export interface Movement {
  readonly id: string
  readonly tenantId: string
  readonly itemId: string
  readonly locationId: string
  readonly kind:
    | 'receipt'
    | 'issue'
    | 'adjust'
    | 'transfer_out'
    | 'transfer_in'
    | 'count_variance'
  readonly qtyDelta: string
  readonly unitCost: string | null
  readonly cogsAmount: string | null
  readonly pendingCost: boolean
  readonly holderRef: string | null
  readonly transferGroup: string | null
  readonly occurredAt: Date
  readonly createdAt: Date
}

export interface MovementResult {
  readonly movement: Movement
}

export interface TransferResult {
  readonly transferOut: Movement
  readonly transferIn: Movement
}

export interface OnHand {
  readonly itemId: string
  readonly locationId?: string
  readonly qty: string
  readonly byLocation?: ReadonlyArray<{
    readonly locationId: string
    readonly qty: string
  }>
}

export interface Valuation {
  readonly itemId: string
  readonly qty: string
  readonly unitCost: string
  readonly value: string
  readonly locationId?: string
}

export interface CogsResult {
  readonly total: string
  readonly byItem?: ReadonlyArray<{
    readonly itemId: string
    readonly total: string
  }>
}

export interface CountResult {
  readonly itemId: string
  readonly countedQty: string
  readonly variance: string
  readonly movement: Movement
}
