export type ContractStatus =
  | "DRAFT"
  | "PENDING_SIGNATURE"
  | "SIGNED"
  | "EXPIRED"
  | "TERMINATED";

export interface ContractCustomerSummary {
  id: string;
  name: string;
  document: string;
  phone?: string | null;
  email?: string | null;
}

export interface ContractReceivable {
  id: string;
  description: string;
  amount: number;
  dueDate: string;
  paidAt?: string | null;
  status: "OPEN" | "PAID" | "OVERDUE" | "CANCELED";
}

export interface Contract {
  id: string;
  companyId: string;
  code: string;
  customerId: string;
  rentalId?: string | null;
  title: string;
  startDate: string;
  endDate: string;
  value: number;
  depositAmount?: number;
  depositPaidAt?: string | null;
  clauses?: string | null;
  notes?: string | null;
  status: ContractStatus;
  signedAt?: string | null;
  createdAt: string;
  updatedAt: string;
  customer?: ContractCustomerSummary;
  equipmentCount?: number;
  receivables?: ContractReceivable[];
}

export interface CreateContractDTO {
  customerId: string;
  rentalId?: string;
  title: string;
  startDate: string;
  endDate: string;
  value: number;
  depositAmount?: number;
  paymentMethod?: string;
  installmentsCount?: number;
  clauses?: string;
  notes?: string;
  status?: ContractStatus;
}

export type UpdateContractDTO = Partial<CreateContractDTO>;

export interface ContractStats {
  total: number;
  signed: number;
  pendingSignature: number;
  draft: number;
  totalContractedValue: number;
}

export interface ContractFilterParams {
  search?: string;
  status?: ContractStatus | "ALL";
  customerId?: string | "ALL";
  page?: number;
  limit?: number;
}
