import {
  IsString,
  IsOptional,
  IsEnum,
  IsInt,
  IsDateString,
  IsUUID,
  IsNumber,
  MaxLength,
  Min,
} from 'class-validator';
import { SettingStatus } from 'generated/prisma/client'
import { Type } from 'class-transformer';
import { PartialType } from '@nestjs/mapped-types';

export class CreatePricingDetailDto {
  @IsUUID()
  headerId: string;

  @IsUUID()
  itemTypeId: string;

  @Type(() => Number)
  @IsNumber()
  @Min(0)
  pricePerUnit: number;
  @IsInt()
  @Min(1)
  weight: number;
  @IsString()
  @MaxLength(50)
  unit: string;
  @IsOptional()
  @IsEnum(SettingStatus)
  status?: SettingStatus;

  @IsDateString()
  beginEffective: string;

  @IsOptional()
  @IsDateString()
  endEffective?: string;

  @IsUUID()
  createdBy: string;

  @IsUUID()
  modifiedBy: string;
}

export class UpdatePricingDetailDto extends PartialType(CreatePricingDetailDto) {}

export class UpdatePriceDto {
  @Type(() => Number)
  @IsNumber()
  @Min(0)
  pricePerUnit: number;

  @IsDateString()
  beginEffective: string;

  @IsUUID()
  modifiedBy: string;
}

