-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZARS-698 ZARS-699 [ADD] add additional location information
- Loading branch information
Showing
15 changed files
with
207 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/modules/proposal/dto/proposal/additional-location-information.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Exclude, Expose, Transform } from 'class-transformer'; | ||
import { IsBoolean } from 'class-validator'; | ||
import { MiiLocation } from 'src/shared/constants/mii-locations'; | ||
import { IsNotEmptyString } from 'src/shared/validators/is-not-empty-string.validator'; | ||
|
||
@Exclude() | ||
export class AdditionalLocationInformationGetDto { | ||
@Expose() | ||
location: MiiLocation; | ||
|
||
@Expose() | ||
@IsBoolean() | ||
@Transform((params) => (params.value === 'true' || params.value === true ? true : false)) | ||
legalBasis: boolean; | ||
|
||
@Expose() | ||
@IsNotEmptyString() | ||
locationPublicationName: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/modules/proposal/dto/set-additional-location-information.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Exclude, Expose, Transform } from 'class-transformer'; | ||
import { IsBoolean } from 'class-validator'; | ||
|
||
@Exclude() | ||
export class SetAdditionalLocationInformationDto { | ||
@Expose() | ||
@IsBoolean() | ||
@Transform((params) => (params.value === 'true' || params.value === true ? true : false)) | ||
legalBasis: boolean; | ||
|
||
@Expose() | ||
locationPublicationName: string; | ||
} |
38 changes: 38 additions & 0 deletions
38
src/modules/proposal/dto/set-diz-condition-approval.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Exclude, Expose, Transform } from 'class-transformer'; | ||
import { IsBoolean, IsNumber, MaxLength, ValidateIf } from 'class-validator'; | ||
import { IsNotEmptyString } from 'src/shared/validators/is-not-empty-string.validator'; | ||
|
||
// For some reason the values are all strings so they need to be transformed to the desired type | ||
@Exclude() | ||
export class SetDizConditionApprovalDto { | ||
@Expose() | ||
@IsBoolean() | ||
@Transform((params) => (params.value === 'true' || params.value === true ? true : false)) | ||
value: boolean; | ||
|
||
@Expose() | ||
@ValidateIf((obj: SetDizConditionApprovalDto) => obj.value === true) | ||
@IsNumber() | ||
@Transform((params) => { | ||
if (params.obj.value === 'false' || params.obj.value === false) { | ||
return undefined; | ||
} | ||
const parsed = parseFloat(params.value); | ||
return isNaN(parsed) ? undefined : parsed; | ||
}) | ||
dataAmount?: number; | ||
|
||
@Expose() | ||
@ValidateIf( | ||
(obj: SetDizConditionApprovalDto) => | ||
obj.value === true && typeof obj.conditionReasoning === 'string' && obj.conditionReasoning.trim() !== '', | ||
) | ||
@MaxLength(10_000) | ||
conditionReasoning?: string; | ||
|
||
@Expose() | ||
@ValidateIf((obj: SetDizConditionApprovalDto) => obj.value === false) | ||
@IsNotEmptyString() | ||
@MaxLength(10_000) | ||
declineReason?: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/modules/proposal/schema/sub-schema/additional-location-information.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'; | ||
import { Document } from 'mongoose'; | ||
import { MiiLocation } from 'src/shared/constants/mii-locations'; | ||
|
||
export type AdditionalLocationInformationDocument = AdditionalLocationInformation & Document; | ||
|
||
@Schema({ _id: true }) | ||
export class AdditionalLocationInformation { | ||
_id?: string; | ||
|
||
@Prop(String) | ||
location: MiiLocation; | ||
|
||
@Prop() | ||
legalBasis: boolean; | ||
|
||
@Prop() | ||
locationPublicationName: string; | ||
|
||
@Prop({ | ||
type: Date, | ||
default: Date.now, | ||
immutable: true, | ||
}) | ||
createdAt: Date; | ||
|
||
@Prop({ | ||
type: Date, | ||
default: Date.now, | ||
immutable: false, | ||
}) | ||
updatedAt: Date; | ||
} | ||
|
||
export const AdditionalLocationInformationSchema = SchemaFactory.createForClass(AdditionalLocationInformation); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ForbiddenException } from '@nestjs/common'; | ||
import { ProposalStatus } from '../enums/proposal-status.enum'; | ||
import { Proposal } from '../schema/proposal.schema'; | ||
|
||
export const validateUpdateAdditionalInformationAccess = (proposal: Proposal) => { | ||
if (proposal.status !== ProposalStatus.LocationCheck) { | ||
throw new ForbiddenException('cannot update additional information outside of the location check step.'); | ||
} | ||
}; |