import { ApiProperty } from "@nestjs/swagger"; import { Transform, Type } from "class-transformer"; import { IsArray, IsDefined, IsEmail, IsEnum, IsInt, IsNumber, IsOptional, IsString, Length, Matches, Max, MaxLength, Min, ValidateNested } from "class-validator"; export enum YON { YES = "Y", NO = "N", } export class PRINTGL_DTO { @ApiProperty({ required: true, enum: YON }) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @IsEnum(YON, { message: 'P_PRINTGL must be either "Y" or "N"' }) @Length(1, 1, { message: 'P_PRINTGL must be 1 character' }) @IsString() @IsDefined({ message: "Invalid Request" }) P_PRINTGL: YON; } export class CARNETSTATUS_DTO { @ApiProperty({ required: true }) @Length(0, 20, { message: 'Property P_CARNETSTATUS must be between 0 to 20 characters', }) @IsString() @IsDefined({ message: 'Property P_CARNETSTATUS is required' }) P_CARNETSTATUS: string; } export class HEADERID_DTO { @ApiProperty({ required: true }) @Max(999999999, { message: 'Property P_HEADERID must not exceed 999999999', }) @Min(0, { message: 'Property P_HEADERID must be at least 0 or more' }) @IsInt({ message: 'Property P_HEADERID allows only whole numbers' }) @IsNumber({}, { message: 'Property P_HEADERID must be a number' }) @Transform(({ value }) => Number(value)) @IsDefined({ message: 'Property P_HEADERID is required' }) P_HEADERID: number; } export class APPLICATIONNAME_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_APPLICATIONNAME must be a string' }) @IsDefined({ message: 'Property P_APPLICATIONNAME is required' }) P_APPLICATIONNAME: string; } export class GOODS_PORT_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_GOODSPORT must be a string' }) @IsDefined({ message: 'Property P_GOODSPORT is required' }) P_GOODSPORT: string; } export class GOODS_COUNTRY_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_GOODSCOUNTRY must be a string' }) @IsDefined({ message: 'Property P_GOODSCOUNTRY is required' }) P_GOODSCOUNTRY: string; } export class REASON_CODE_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_REASONCODE must be a string' }) @IsDefined({ message: 'Property P_REASONCODE is required' }) P_REASONCODE: string; } export class EXTENSION_PERIOD_DTO { @ApiProperty({ required: true }) @Max(999999999, { message: 'Property P_EXTENSIONPERIOD must not exceed 999999999', }) @Min(0, { message: 'Property P_EXTENSIONPERIOD must be at least 0 or more' }) @IsInt({ message: 'Property P_EXTENSIONPERIOD allows only whole numbers' }) @IsNumber({}, { message: 'Property P_EXTENSIONPERIOD must be a number' }) @Transform(({ value }) => Number(value)) @IsDefined({ message: 'Property P_EXTENSIONPERIOD is required' }) P_EXTENSIONPERIOD: number; } export class ORDERTYPE_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_ORDERTYPE must be a string' }) @IsDefined({ message: 'Property P_ORDERTYPE is required' }) P_ORDERTYPE: string; } export class COMMERCIAL_SAMPLE_FLAG_DTO { @ApiProperty({ required: true, enum: YON }) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @IsEnum(YON, { message: 'P_COMMERCIALSAMPLEFLAG must be either "Y" or "N"' }) @Length(1, 1, { message: 'P_COMMERCIALSAMPLEFLAG must be 1 character' }) @IsString() @IsDefined({ message: "Invalid Request" }) P_COMMERCIALSAMPLEFLAG: YON; } export class PROF_EQUIPMENT_FLAG_DTO { @ApiProperty({ required: true, enum: YON }) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @IsEnum(YON, { message: 'P_PROFEQUIMENTFLAG must be either "Y" or "N"' }) @Length(1, 1, { message: 'P_PROFEQUIMENTFLAG must be 1 character' }) @IsString() @IsDefined({ message: "Invalid Request" }) P_PROFEQUIPMENTFLAG: YON; } export class EXIBITIONS_FAIR_FLAG_DTO { @ApiProperty({ required: true, enum: YON }) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @IsEnum(YON, { message: 'P_EXIBITIONSFAIRFLAG must be either "Y" or "N"' }) @Length(1, 1, { message: 'P_EXIBITIONSFAIRFLAG must be 1 character' }) @IsString() @IsDefined({ message: "Invalid Request" }) P_EXHIBITIONSFAIRFLAG: YON; } export class AUTO_FLAG_DTO { @ApiProperty({ required: true, enum: YON }) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @IsEnum(YON, { message: 'P_AUTOFLAG must be either "Y" or "N"' }) @Length(1, 1, { message: 'P_AUTOFLAG must be 1 character' }) @IsString() @IsDefined({ message: "Invalid Request" }) P_AUTOFLAG: YON; } export class HORSE_FLAG_DTO { @ApiProperty({ required: true, enum: YON }) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @IsEnum(YON, { message: 'P_HORSEFLAG must be either "Y" or "N"' }) @Length(1, 1, { message: 'P_HORSEFLAG must be 1 character' }) @IsString() @IsDefined({ message: "Invalid Request" }) P_HORSEFLAG: YON; } export class AUTHREP_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_AUTHREP must be a string' }) @IsDefined({ message: 'Property P_AUTHREP is required' }) P_AUTHREP: string; } export class GLTABLE_ROW_DTO { @ApiProperty({ required: true }) @Max(99999, { message: 'Property ITEMNO must not exceed 99999' }) @Min(0, { message: 'Property ITEMNO must be at least 0 or more' }) @IsInt({ message: 'Property ITEMNO allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property ITEMNO must be a number' }) @IsDefined({ message: 'Property ITEMNO is required' }) ITEMNO: number; @ApiProperty({ required: true }) @MaxLength(200, { message: 'Property ITEMDESCRIPTION must not exceed 200 characters' }) @IsString({ message: 'Property ITEMDESCRIPTION must be a string' }) @IsDefined({ message: 'Property ITEMDESCRIPTION is required' }) ITEMDESCRIPTION: string; @ApiProperty({ required: true }) @Max(999999999.99, { message: 'Property ITEMVALUE must not exceed 999999999.99' }) @Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' }) @Transform(({ value }) => Number(value)) @IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' }) @IsDefined({ message: 'Property ITEMVALUE is required' }) ITEMVALUE: number; @ApiProperty({ required: true }) @Max(99999, { message: 'Property NOOFPIECES must not exceed 99999' }) @Min(0, { message: 'Property NOOFPIECES must be at least 0 or more' }) @IsInt({ message: 'Property NOOFPIECES allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property NOOFPIECES must be a number' }) @IsDefined({ message: 'Property NOOFPIECES is required' }) NOOFPIECES: number; @ApiProperty({ required: true }) @Max(99999.9999, { message: 'Property ITEMVALUE must not exceed 999999999.99' }) @Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' }) @Transform(({ value }) => Number(value)) @IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' }) @IsDefined({ message: 'Property ITEMVALUE is required' }) ITEMWEIGHT: number; @ApiProperty({ required: true }) @MaxLength(10, { message: 'Property ITEMWEIGHTUOM must not exceed 10 characters' }) @IsString({ message: 'Property ITEMWEIGHTUOM must be a string' }) @IsDefined({ message: 'Property ITEMWEIGHTUOM is required' }) ITEMWEIGHTUOM: string; @ApiProperty({ required: true }) @MaxLength(2, { message: 'Property GOODSORIGINCOUNTRY must not exceed 2 characters' }) @IsString({ message: 'Property GOODSORIGINCOUNTRY must be a string' }) @IsDefined({ message: 'Property GOODSORIGINCOUNTRY is required' }) GOODSORIGINCOUNTRY: string; } export class GLTABLE_ROW_ADD_DTO { @ApiProperty({ required: false }) @Max(99999, { message: 'Property ITEMNO must not exceed 99999' }) @Min(0, { message: 'Property ITEMNO must be at least 0 or more' }) @IsInt({ message: 'Property ITEMNO allows only whole numbers' }) @Transform(({ value }) => { if (value === undefined || value === null || value === '') return 0; return Number(value); }) @IsNumber({}, { message: 'Property ITEMNO must be a number' }) @IsOptional() ITEMNO: number = 0 @ApiProperty({ required: true }) @MaxLength(200, { message: 'Property ITEMDESCRIPTION must not exceed 200 characters' }) @IsString({ message: 'Property ITEMDESCRIPTION must be a string' }) @IsDefined({ message: 'Property ITEMDESCRIPTION is required' }) ITEMDESCRIPTION: string; @ApiProperty({ required: true }) @Max(999999999.99, { message: 'Property ITEMVALUE must not exceed 999999999.99' }) @Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' }) @Transform(({ value }) => Number(value)) @IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' }) @IsDefined({ message: 'Property ITEMVALUE is required' }) ITEMVALUE: number; @ApiProperty({ required: true }) @Max(99999, { message: 'Property NOOFPIECES must not exceed 99999' }) @Min(0, { message: 'Property NOOFPIECES must be at least 0 or more' }) @IsInt({ message: 'Property NOOFPIECES allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property NOOFPIECES must be a number' }) @IsDefined({ message: 'Property NOOFPIECES is required' }) NOOFPIECES: number; @ApiProperty({ required: true }) @Max(99999.9999, { message: 'Property ITEMVALUE must not exceed 999999999.99' }) @Min(0, { message: 'Property ITEMVALUE must be at least 0 or more' }) @Transform(({ value }) => Number(value)) @IsNumber({ maxDecimalPlaces: 2 }, { message: 'Property ITEMVALUE must be a number' }) @IsDefined({ message: 'Property ITEMVALUE is required' }) ITEMWEIGHT: number; @ApiProperty({ required: true }) @MaxLength(10, { message: 'Property ITEMWEIGHTUOM must not exceed 10 characters' }) @IsString({ message: 'Property ITEMWEIGHTUOM must be a string' }) @IsDefined({ message: 'Property ITEMWEIGHTUOM is required' }) ITEMWEIGHTUOM: string; @ApiProperty({ required: true }) @MaxLength(2, { message: 'Property GOODSORIGINCOUNTRY must not exceed 2 characters' }) @IsString({ message: 'Property GOODSORIGINCOUNTRY must be a string' }) @IsDefined({ message: 'Property GOODSORIGINCOUNTRY is required' }) GOODSORIGINCOUNTRY: string; } export class GLTABLE_DTO { @ApiProperty({ required: true, type: () => [GLTABLE_ROW_DTO] }) @Type(() => GLTABLE_ROW_DTO) @ValidateNested({ each: true }) @IsArray({ message: 'Property P_GLTABLE allows only array type' }) @IsDefined({ message: 'Property P_GLTABLE is required' }) P_GLTABLE: GLTABLE_ROW_DTO[]; } export class GLTABLE_ITEMNO_OPTIONAL_DTO { @ApiProperty({ required: true, type: () => [GLTABLE_ROW_ADD_DTO] }) @Type(() => GLTABLE_ROW_ADD_DTO) @ValidateNested({ each: true }) @IsArray({ message: 'Property P_GLTABLE allows only array type' }) @IsDefined({ message: 'Property P_GLTABLE is required' }) P_GLTABLE: GLTABLE_ROW_ADD_DTO[]; } export class ITEMNO_DTO { @ApiProperty({ required: true }) @Max(99999, { message: 'Property ITEMNO must not exceed 99999' }) @Min(0, { message: 'Property ITEMNO must be at least 0 or more' }) @IsInt({ message: 'Property ITEMNO allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property ITEMNO must be a number' }) @IsDefined({ message: 'Property ITEMNO is required' }) P_ITEMNO: number; } export class SHIPCONTACTID_DTO { @ApiProperty({ required: true }) @Max(99999, { message: 'Property P_SHIPCONTACTID must not exceed 99999' }) @Min(0, { message: 'Property P_SHIPCONTACTID must be at least 0 or more' }) @IsInt({ message: 'Property P_SHIPCONTACTID allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property P_SHIPCONTACTID must be a number' }) @IsDefined({ message: 'Property P_SHIPCONTACTID is required' }) P_SHIPCONTACTID: number; } export class SHIPNAME_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_SHIPNAME must be a string' }) @IsDefined({ message: 'Property P_SHIPNAME is required' }) P_SHIPNAME: string; } export class USSETS_DTO { @ApiProperty({ required: true }) // @Max(99999, { message: 'Property P_USSETS must not exceed 99999' }) @Min(0, { message: 'Property P_USSETS must be at least 0 or more' }) @IsInt({ message: 'Property P_USSETS allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property P_USSETS must be a number' }) @IsDefined({ message: 'Property P_USSETS is required' }) P_USSETS: number; } export enum VOT { V = "V", T = "T", } export class COUNTRYTABLE_ROW_DTO { @ApiProperty({ required: true, enum: VOT }) @Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value) @IsEnum(VOT, { message: 'P_VISISTTRANSITIND must be either "V" or "T"' }) @Length(1, 1, { message: 'P_VISISTTRANSITIND must be 1 character' }) @IsString() @IsDefined({ message: "Invalid Request" }) P_VISISTTRANSITIND: VOT; @ApiProperty({ required: true }) @MaxLength(2, { message: 'Property COUNTRYCODE must not exceed 2 characters' }) @IsString({ message: 'Property COUNTRYCODE must be a string' }) @IsDefined({ message: 'Property COUNTRYCODE is required' }) COUNTRYCODE: string; @ApiProperty({ required: true }) @Max(999, { message: 'Property NOOFTIMESENTLEAVE must not exceed 999' }) @Min(0, { message: 'Property NOOFTIMESENTLEAVE must be at least 0 or more' }) @IsInt({ message: 'Property NOOFTIMESENTLEAVE allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property NOOFTIMESENTLEAVE must be a number' }) @IsDefined({ message: 'Property NOOFTIMESENTLEAVE is required' }) NOOFTIMESENTLEAVE: number; } export class COUNTRYTABLE_DTO { @ApiProperty({ required: true, type: () => [COUNTRYTABLE_ROW_DTO] }) @Type(() => COUNTRYTABLE_ROW_DTO) @ValidateNested({ each: true }) @IsArray({ message: 'Property P_COUNTRYTABLE allows only array type' }) @IsDefined({ message: 'Property P_COUNTRYTABLE is required' }) P_COUNTRYTABLE: COUNTRYTABLE_ROW_DTO[]; } export class SHIPTOTYPE_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_SHIPTOTYPE must be a string' }) @IsDefined({ message: 'Property P_SHIPTOTYPE is required' }) P_SHIPTOTYPE: string; } export class SHIPADDRID_DTO { @ApiProperty({ required: true }) // @Max(99999, { message: 'Property P_USSETS must not exceed 99999' }) @Min(0, { message: 'Property P_SHIPADDRID must be at least 0 or more' }) @IsInt({ message: 'Property P_SHIPADDRID allows only whole numbers' }) @Transform(({ value }) => Number(value)) @IsNumber({}, { message: 'Property P_SHIPADDRID must be a number' }) @IsDefined({ message: 'Property P_SHIPADDRID is required' }) P_SHIPADDRID: number; } export class FORMOFSECURITY_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_FORMOFSECURITY must be a string' }) @IsDefined({ message: 'Property P_FORMOFSECURITY is required' }) P_FORMOFSECURITY: string; } export class INSPROTECTION_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_INSPROTECTION must be a string' }) @IsDefined({ message: 'Property P_INSPROTECTION is required' }) P_INSPROTECTION: string; } export class LDIPROTECTION_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_LDIPROTECTION must be a string' }) @IsDefined({ message: 'Property P_LDIPROTECTION is required' }) P_LDIPROTECTION: string; } export class DELIVERYTYPE_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_DELIVERYTYPE must be a string' }) @IsDefined({ message: 'Property P_DELIVERYTYPE is required' }) P_DELIVERYTYPE: string; } export class DELIVERYMETHOD_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_DELIVERYTYPE must be a string' }) @IsDefined({ message: 'Property P_DELIVERYTYPE is required' }) P_DELIVERYMETHOD: string; } export class PAYMENTMETHOD_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_PAYMENTMETHOD must be a string' }) @IsDefined({ message: 'Property P_PAYMENTMETHOD is required' }) P_PAYMENTMETHOD: string; } export class CUSTCOURIERNO_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_CUSTCOURIERNO must be a string' }) @IsDefined({ message: 'Property P_CUSTCOURIERNO is required' }) P_CUSTCOURIERNO: string; } export class REFNO_DTO { @ApiProperty({ required: true }) @IsString({ message: 'Property P_REFNO must be a string' }) @IsDefined({ message: 'Property P_REFNO is required' }) P_REFNO: string; }