Skip to content

Commit

Permalink
Add assumptions and cost inputs in the DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
catalin-oancea authored and alexeh committed Nov 14, 2024
1 parent 2137e99 commit a6c36a6
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 2 deletions.
13 changes: 12 additions & 1 deletion api/src/modules/custom-projects/dto/create-custom-project-dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { ACTIVITY } from '@shared/entities/activity.enum';
import { ECOSYSTEM } from '@shared/entities/ecosystem.enum';
import { ConservationProjectParamDto } from '@api/modules/custom-projects/dto/conservation-project-params.dto';
import { RestorationProjectParamsDto } from '@api/modules/custom-projects/dto/restoration-project-params.dto';
import { CustomProjectAssumptionsDto } from '@api/modules/custom-projects/dto/project-assumptions.dto';
import { CustomProjectCostInputsDto } 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';

Expand Down Expand Up @@ -41,7 +43,16 @@ export class CreateCustomProjectDto {
@IsEnum(CARBON_REVENUES_TO_COVER)
carbonRevenuesToCover: CARBON_REVENUES_TO_COVER;

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

@IsNotEmpty({
message: 'Cost inputs are required to create a custom project',
})
costInputs: CustomProjectCostInputsDto;

@IsNotEmpty()
@Transform(injectEcosystemToParams)
@Validate(ProjectParamsValidator)
Expand Down
24 changes: 24 additions & 0 deletions api/src/modules/custom-projects/dto/project-assumptions.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { IsNumber } from 'class-validator';

export class CustomProjectAssumptionsDto {
@IsNumber()
verificationFrequency: number;

@IsNumber()
discountRate: number;

@IsNumber()
carbonPriceIncrease: number;

@IsNumber()
buffer: number;

@IsNumber()
baselineReassessmentFrequency: number;

@IsNumber()
restorationRate: number;

@IsNumber()
restorationProjectLength: number;
}
60 changes: 60 additions & 0 deletions api/src/modules/custom-projects/dto/project-cost-inputs.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { CustomProject } from '@shared/entities/custom-project.entity';
import { IsNumber } from 'class-validator';

export class CustomProjectCapexCostInputsDto {
@IsNumber()
feasibilityAnalisys: number;

@IsNumber()
conservationPlanningAndAdmin: number;

@IsNumber()
dataCollectionAndFieldCost: number;

@IsNumber()
communityRepresentation: number;

@IsNumber()
blueCarbonProjectPlanning: number;

@IsNumber()
establishingCarbonRights: number;

@IsNumber()
validation: number;

@IsNumber()
implementationLabor: number;
}

export class CustomProjectOpexCostInputsDto {
@IsNumber()
monitoring: number;

@IsNumber()
maintenance: number;

@IsNumber()
communityBenefitShsharingFund: number;

@IsNumber()
carbonStandardFees: number;

@IsNumber()
baselineReassessment: number;

@IsNumber()
mrv: number;

@IsNumber()
longTermProjectOperating: number;
}

export class CustomProjectCostInputsDto {
@IsNumber()
financingCost: number;

capexCostInputs: CustomProjectCapexCostInputsDto;

opexCostInputs: CustomProjectOpexCostInputsDto;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('Create Custom Projects - Request Validations', () => {
.post(customProjectContract.createCustomProject.path)
.send({});

expect(response.body.errors).toHaveLength(10);
expect(response.body.errors).toHaveLength(12);
});
});
describe('Conservation Project Validations', () => {
Expand Down

0 comments on commit a6c36a6

Please sign in to comment.