Skip to content

Commit

Permalink
add otherCommunityCashFlow to cost inputs + validate nested propertie…
Browse files Browse the repository at this point in the history
…s in create custom project
  • Loading branch information
alexeh committed Nov 18, 2024
1 parent 11cedec commit e7b6b7e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions api/src/modules/calculations/data.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class DataRepository extends Repository<BaseDataView> {
'financingCost',
'implementationLaborPlanting',
'implementationLaborHydrology',
'otherCommunityCashFlow',
],
});
if (!costInputs) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
IsString,
Length,
Validate,
ValidateNested,
} from 'class-validator';
import { ACTIVITY } from '@shared/entities/activity.enum';
import { ECOSYSTEM } from '@shared/entities/ecosystem.enum';
Expand All @@ -14,7 +15,7 @@ import { RestorationProjectParamsDto } from '@api/modules/custom-projects/dto/re
import { CustomProjectAssumptionsDto } from '@api/modules/custom-projects/dto/project-assumptions.dto';
import { CostInputs } from '@api/modules/custom-projects/dto/project-cost-inputs.dto';
import { ProjectParamsValidator } from '@api/modules/custom-projects/validation/project-params.validator';
import { Transform } from 'class-transformer';
import { Transform, Type } from 'class-transformer';

export enum CARBON_REVENUES_TO_COVER {
OPEX = 'Opex',
Expand Down Expand Up @@ -44,16 +45,18 @@ export class CreateCustomProjectDto {
@IsEnum(CARBON_REVENUES_TO_COVER)
carbonRevenuesToCover: CARBON_REVENUES_TO_COVER;

@IsOptional()
@ValidateNested()
@Type(() => CustomProjectAssumptionsDto)
@IsNotEmpty({
message: 'Assumptions are required to create a custom project',
})
assumptions: CustomProjectAssumptionsDto;

@IsOptional()
@IsNotEmpty({
message: 'Cost inputs are required to create a custom project',
})
@ValidateNested()
@Type(() => CostInputs)
costInputs: CostInputs;

@IsNotEmpty()
Expand Down
10 changes: 9 additions & 1 deletion api/src/modules/custom-projects/dto/project-cost-inputs.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { IsNumber } from 'class-validator';
import { IsEnum, IsNumber } from 'class-validator';

export enum PROJECT_DEVELOPMENT_TYPE {
DEVELOPMENT = 'Development',
NON_DEVELOPMENT = 'Non-Development',
}

export class CostInputs {
@IsNumber()
Expand Down Expand Up @@ -48,4 +53,7 @@ export class CostInputs {

@IsNumber()
implementationLabor: number;

@IsEnum(PROJECT_DEVELOPMENT_TYPE)
otherCommunityCashFlow: PROJECT_DEVELOPMENT_TYPE | string;
}

0 comments on commit e7b6b7e

Please sign in to comment.