From a6c36a6007a65e0788ecb360d26b7e7f4ec68ccd Mon Sep 17 00:00:00 2001 From: Catalin Oancea Date: Tue, 12 Nov 2024 09:57:53 +0200 Subject: [PATCH] Add assumptions and cost inputs in the DTO --- .../dto/create-custom-project-dto.ts | 13 +++- .../dto/project-assumptions.dto.ts | 24 ++++++++ .../dto/project-cost-inputs.dto.ts | 60 +++++++++++++++++++ .../custom-projects-validations.spec.ts | 2 +- 4 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 api/src/modules/custom-projects/dto/project-assumptions.dto.ts create mode 100644 api/src/modules/custom-projects/dto/project-cost-inputs.dto.ts diff --git a/api/src/modules/custom-projects/dto/create-custom-project-dto.ts b/api/src/modules/custom-projects/dto/create-custom-project-dto.ts index 266c8220..17d38aae 100644 --- a/api/src/modules/custom-projects/dto/create-custom-project-dto.ts +++ b/api/src/modules/custom-projects/dto/create-custom-project-dto.ts @@ -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'; @@ -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) diff --git a/api/src/modules/custom-projects/dto/project-assumptions.dto.ts b/api/src/modules/custom-projects/dto/project-assumptions.dto.ts new file mode 100644 index 00000000..2e6cf264 --- /dev/null +++ b/api/src/modules/custom-projects/dto/project-assumptions.dto.ts @@ -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; +} diff --git a/api/src/modules/custom-projects/dto/project-cost-inputs.dto.ts b/api/src/modules/custom-projects/dto/project-cost-inputs.dto.ts new file mode 100644 index 00000000..e6aa7b16 --- /dev/null +++ b/api/src/modules/custom-projects/dto/project-cost-inputs.dto.ts @@ -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; +} diff --git a/api/test/integration/custom-projects/custom-projects-validations.spec.ts b/api/test/integration/custom-projects/custom-projects-validations.spec.ts index 2df70018..d06952c3 100644 --- a/api/test/integration/custom-projects/custom-projects-validations.spec.ts +++ b/api/test/integration/custom-projects/custom-projects-validations.spec.ts @@ -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', () => {