mirror of https://github.com/ghostfolio/ghostfolio
				
				
			
			You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							79 lines
						
					
					
						
							1.5 KiB
						
					
					
				
			
		
		
		
			
			
			
		
		
	
	
							79 lines
						
					
					
						
							1.5 KiB
						
					
					
				| import { IsCurrencyCode } from '@ghostfolio/api/validators/is-currency-code'; | |
| import { IsAfter1970Constraint } from '@ghostfolio/common/validator-constraints/is-after-1970'; | |
| 
 | |
| import { AssetClass, AssetSubClass, DataSource, Type } from '@prisma/client'; | |
| import { Transform, TransformFnParams } from 'class-transformer'; | |
| import { | |
|   IsArray, | |
|   IsBoolean, | |
|   IsEnum, | |
|   IsISO8601, | |
|   IsNumber, | |
|   IsOptional, | |
|   IsString, | |
|   Min, | |
|   Validate | |
| } from 'class-validator'; | |
| import { isString } from 'lodash'; | |
| 
 | |
| export class CreateOrderDto { | |
|   @IsOptional() | |
|   @IsString() | |
|   accountId?: string; | |
| 
 | |
|   @IsEnum(AssetClass, { each: true }) | |
|   @IsOptional() | |
|   assetClass?: AssetClass; | |
| 
 | |
|   @IsEnum(AssetSubClass, { each: true }) | |
|   @IsOptional() | |
|   assetSubClass?: AssetSubClass; | |
| 
 | |
|   @IsOptional() | |
|   @IsString() | |
|   @Transform(({ value }: TransformFnParams) => | |
|     isString(value) ? value.trim() : value | |
|   ) | |
|   comment?: string; | |
| 
 | |
|   @IsCurrencyCode() | |
|   currency: string; | |
| 
 | |
|   @IsCurrencyCode() | |
|   @IsOptional() | |
|   customCurrency?: string; | |
| 
 | |
|   @IsEnum(DataSource) | |
|   @IsOptional() // Optional for type FEE, INTEREST, and LIABILITY (default data source is resolved in the backend) | |
|   dataSource?: DataSource; | |
| 
 | |
|   @IsISO8601() | |
|   @Validate(IsAfter1970Constraint) | |
|   date: string; | |
| 
 | |
|   @IsNumber() | |
|   @Min(0) | |
|   fee: number; | |
| 
 | |
|   @IsNumber() | |
|   @Min(0) | |
|   quantity: number; | |
| 
 | |
|   @IsString() | |
|   symbol: string; | |
| 
 | |
|   @IsArray() | |
|   @IsOptional() | |
|   tags?: string[]; | |
| 
 | |
|   @IsEnum(Type, { each: true }) | |
|   type: Type; | |
| 
 | |
|   @IsNumber() | |
|   @Min(0) | |
|   unitPrice: number; | |
| 
 | |
|   @IsBoolean() | |
|   @IsOptional() | |
|   updateAccountBalance?: boolean; | |
| }
 | |
| 
 |