/**
 * Sales Return Repository Interface
 * Defines how SalesReturn entities are persisted
 */

import type { SalesReturn } from '../domain/sales-return.model';

export type CreateSalesReturnRepositoryInput = Omit<
  SalesReturn,
  'id' | 'createdAt' | 'activityLog'
> & {
  id: string;
  createdAt: string;
  activityLog?: SalesReturn['activityLog'];
};

export type UpdateSalesReturnRepositoryInput = Partial<
  Omit<SalesReturn, 'id' | 'createdAt'>
>;

export abstract class SalesReturnRepository {
  /**
   * Get all returns
   */
  abstract list(): Promise<SalesReturn[]>;

  /**
   * Get return by ID
   */
  abstract getById(id: string): Promise<SalesReturn | null>;

  /**
   * Get returns by invoice ID
   */
  abstract getByInvoiceId(invoiceId: string): Promise<SalesReturn[]>;

  /**
   * Get returns by customer ID
   */
  abstract getByCustomerId(customerId: string): Promise<SalesReturn[]>;

  /**
   * Get returns by status
   */
  abstract getByStatus(status: string): Promise<SalesReturn[]>;

  /**
   * Create a new return
   */
  abstract create(input: CreateSalesReturnRepositoryInput): Promise<SalesReturn>;

  /**
   * Update an existing return
   */
  abstract update(
    id: string,
    input: UpdateSalesReturnRepositoryInput
  ): Promise<SalesReturn | null>;

  /**
   * Delete a return
   */
  abstract delete(id: string): Promise<boolean>;

  /**
   * Get next return number (for R/YYYY/XXXX format)
   */
  abstract getNextReturnNumber(year: number): Promise<string>;
}
