import { BaseEntity } from '@edr/api-common';
import { Entity, Column, Index } from 'typeorm';

export enum DisposalMethod {
  SALE = 'SALE',
  SCRAP = 'SCRAP',
  RETURN_LEASE = 'RETURN_LEASE',
  TRADE_IN = 'TRADE_IN',
}

@Entity({ name: 'asset_disposals', schema: 'freight' })
@Index(['vehicleId', 'disposalDate'])
export class AssetDisposal extends BaseEntity {
  @Column({ name: 'vehicle_id', type: 'uuid' })
  vehicleId!: string;

  @Column({ name: 'disposal_date', type: 'date' })
  disposalDate!: string;

  @Column({ name: 'method', type: 'varchar' })
  method!: DisposalMethod;

  @Column({ name: 'sale_price', type: 'numeric', precision: 14, scale: 2, nullable: true })
  salePrice?: number;

  @Column({ name: 'buyer', nullable: true })
  buyer?: string;

  @Column({ name: 'notes', type: 'text', nullable: true })
  notes?: string;
}
