import { ApiProperty } from '@nestjs/swagger';

export class PriceLineItemDto {
  @ApiProperty()
  code!: string;

  @ApiProperty()
  description!: string;

  /** Computed line total (unitAmount × quantity). Retained for totals elsewhere. */
  @ApiProperty()
  amount!: number;

  /** Price for a single unit of this charge (e.g. one 20ft container, one ton). */
  @ApiProperty()
  unitAmount!: number;

  /** Unit the rate is charged per: PER_CONTAINER | PER_TON | PER_WAGON | PER_KM | FLAT. */
  @ApiProperty()
  unit!: string;

  /** How many units this charge applies to (containers, tons, wagons; 1 for FLAT). */
  @ApiProperty()
  quantity!: number;

  @ApiProperty()
  currency!: string;
}

export class OverweightLineDto {
  @ApiProperty()
  containerTypeCode!: string;

  @ApiProperty()
  totalVgmTons!: number;

  @ApiProperty()
  maxAllowedTons!: number;

  @ApiProperty()
  excessTons!: number;
}

export class GeneratePriceResponseDto {
  @ApiProperty()
  bookingId!: string;

  @ApiProperty()
  totalAmount!: number;

  @ApiProperty()
  currency!: string;

  @ApiProperty({ type: [PriceLineItemDto] })
  lineItems!: PriceLineItemDto[];

  @ApiProperty({ type: [String] })
  warnings!: string[];

  /** Overweight container lines (VGM over the weight-limit rule) — surcharge already in lineItems. */
  @ApiProperty({ type: [OverweightLineDto] })
  overweightLines!: OverweightLineDto[];

  /**
   * 20ft weight-pairing violations. Non-empty means the booking cannot be
   * balanced onto wagons and submit is HARD-BLOCKED — the customer must fix
   * container weights/quantities. (Overweight, by contrast, only warns.)
   */
  @ApiProperty({ type: [String] })
  pairingErrors!: string[];
}
