import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import { IsNotEmpty, ValidateNested } from 'class-validator';

class SshafItem {
  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  sellDate: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  buyerNationalCode: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  buyerFullName: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  buyerMobile: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  count: number;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  perPrice: number;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  totalPrice: number;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  productCode: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  productInfo: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  buyerAddress: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  carPlateNumber: string;
}

export class SshafDto {
  @ApiProperty({ type: [SshafItem] })
  @IsNotEmpty({ message: 'لطفا فاکتورهای مورد نظر را ارسال کنید' })
  @ValidateNested({ each: true })
  @Type(() => SshafItem)
  items: SshafItem[];

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  roleCode: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  postalCode: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  sellerPhone: string;

  @ApiProperty()
  @IsNotEmpty({ message: 'تمامی موارد اجباری است' })
  sellerNationalCode: string;
}
