import { Expose , Transform } from 'class-transformer' ; import { IsDate , IsEnum , IsNotEmpty , IsOptional , IsPositive , IsString } from 'class-validator' ; import { FileIds } from './File' ; export enum IssuanceStatus { Draft = 'Draft' , InProgress = 'In-progress' , Rejected = 'Rejected' , Withdrawn = 'Withdrawn' , Submitted = 'Submitted' , Referred = 'Referred' , Verified = 'Verified' , Approved = 'Approved' , Issued = 'Issued' } export class Issue extends FileIds { @ Expose ( { name : 'device_code' , toPlainOnly : true } ) @ IsString ( ) @ IsNotEmpty ( ) device : string ; @ Expose ( { name : 'fuel_code' , toPlainOnly : true } ) @ IsString ( ) @ IsNotEmpty ( ) fuelType : string ; @ Expose ( { name : 'recipient_account_code' , toPlainOnly : true } ) @ IsString ( ) @ IsNotEmpty ( ) recipient : string ; @ Expose ( { name : 'start_date' , toPlainOnly : true } ) @ Transform ( ( value ) => value . toISOString ( ) . split ( 'T' ) [ 0 ] , { toPlainOnly : true } ) @ Transform ( ( value ) => new Date ( value ) , { toClassOnly : true } ) @ IsDate ( ) start : Date ; @ Expose ( { name : 'end_date' , toPlainOnly : true } ) @ Transform ( ( value ) => value . toISOString ( ) . split ( 'T' ) [ 0 ] , { toPlainOnly : true } ) @ Transform ( ( value ) => new Date ( value ) , { toClassOnly : true } ) @ IsDate ( ) end : Date ; @ Expose ( { name : 'period_production' , toPlainOnly : true } ) @ Transform ( ( value ) => value . toString ( ) , { toPlainOnly : true } ) @ Transform ( ( value ) => parseFloat ( value ) , { toClassOnly : true } ) @ IsPositive ( ) production : number ; @ IsOptional ( ) @ IsString ( ) notes ? : string ; } export class ApproveIssue { @ Expose ( { name : 'issuer_account_code' , toPlainOnly : true } ) @ IsString ( ) @ IsNotEmpty ( ) issuer : string ; @ IsOptional ( ) @ IsString ( ) notes ? : string ; } export class IssueWithStatus extends Issue { @ IsString ( ) @ IsNotEmpty ( ) code : string ; @ IsNotEmpty ( ) @ IsEnum ( IssuanceStatus ) status : IssuanceStatus ; }