- Add TarifasService with findTarifaByLane, calcularCostoEnvio methods - Create RecargosService for surcharge catalog and fuel surcharge - Add TarifasController with full REST API for tarifas, lanes, recargos - Implement DTOs with class-validator decorators - Support lane-based tariff lookup with fallback to generic - Calculate shipping cost with fuel surcharge, insurance, and other recargos - Include peso/volumen calculation with volumetric factor (1m3=250kg) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
113 lines
1.5 KiB
TypeScript
113 lines
1.5 KiB
TypeScript
import {
|
|
IsString,
|
|
IsOptional,
|
|
IsNumber,
|
|
MaxLength,
|
|
Min,
|
|
} from 'class-validator';
|
|
|
|
/**
|
|
* DTO for finding tarifa by lane
|
|
*/
|
|
export class FindTarifaByLaneDto {
|
|
@IsString()
|
|
@MaxLength(100)
|
|
origenCiudad: string;
|
|
|
|
@IsString()
|
|
@MaxLength(100)
|
|
destinoCiudad: string;
|
|
|
|
@IsString()
|
|
@MaxLength(50)
|
|
tipoCarga: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(50)
|
|
tipoEquipo?: string;
|
|
}
|
|
|
|
/**
|
|
* DTO for basic tarifa quotation
|
|
*/
|
|
export class CotizarTarifaDto {
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
km?: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
toneladas?: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
m3?: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
pallets?: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
horas?: number;
|
|
}
|
|
|
|
/**
|
|
* DTO for full shipping cost calculation
|
|
*/
|
|
export class CalcularCostoEnvioDto {
|
|
@IsString()
|
|
@MaxLength(100)
|
|
origenCiudad: string;
|
|
|
|
@IsString()
|
|
@MaxLength(100)
|
|
destinoCiudad: string;
|
|
|
|
@IsString()
|
|
@MaxLength(50)
|
|
tipoCarga: string;
|
|
|
|
@IsString()
|
|
@MaxLength(50)
|
|
tipoEquipo: string;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
pesoKg?: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
volumenM3?: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
valorDeclarado?: number;
|
|
}
|
|
|
|
/**
|
|
* DTO for calculating surcharges
|
|
*/
|
|
export class CalcularRecargosDto {
|
|
@IsNumber()
|
|
@Min(0)
|
|
montoBase: number;
|
|
|
|
@IsOptional()
|
|
@IsNumber()
|
|
@Min(0)
|
|
valorDeclarado?: number;
|
|
|
|
@IsOptional()
|
|
incluirFuelSurcharge?: boolean;
|
|
}
|