Skip to content

Commit

Permalink
add multiple date to decision condition type entity
Browse files Browse the repository at this point in the history
- add multiple date to decision condition type entity and DTO for applications and NOIs
- rename corresponding fields
  • Loading branch information
Abradat committed Nov 29, 2024
1 parent 9d0be42 commit ebefd18
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ export class ApplicationDecisionConditionTypesService {
isAdministrativeFeeAmountChecked: true,
isAdministrativeFeeAmountRequired: true,
administrativeFeeAmount: true,
isDateChecked: true,
isDateRequired: true,
isSingleDateChecked: true,
isSingleDateRequired: true,
singleDateLabel: true,
isMultipleDateChecked: true,
isSecurityAmountChecked: true,
isSecurityAmountRequired: true,
},
Expand Down Expand Up @@ -59,10 +61,14 @@ export class ApplicationDecisionConditionTypesService {
? updateDto.administrativeFeeAmount
: null;

type.isSingleDateChecked = updateDto.isSingleDateChecked;
type.isSingleDateRequired = updateDto.isSingleDateChecked ? updateDto.isSingleDateRequired : null;
type.isDateChecked = updateDto.isDateChecked;
type.isDateRequired = updateDto.isDateChecked ? updateDto.isDateRequired : null;

type.isSingleDateChecked = updateDto.isDateChecked ? updateDto.isSingleDateChecked : null;
type.singleDateLabel = updateDto.isSingleDateChecked ? updateDto.singleDateLabel : null;

type.isMultipleDateChecked = updateDto.isDateChecked ? updateDto.isMultipleDateChecked : null;

type.isSecurityAmountChecked = updateDto.isSecurityAmountChecked;
type.isSecurityAmountRequired = updateDto.isSecurityAmountChecked ? updateDto.isSecurityAmountRequired : null;

Expand All @@ -84,10 +90,14 @@ export class ApplicationDecisionConditionTypesService {
? createDto.administrativeFeeAmount
: null;

type.isSingleDateChecked = createDto.isSingleDateChecked;
type.isSingleDateRequired = createDto.isSingleDateChecked ? createDto.isSingleDateRequired : null;
type.isDateChecked = createDto.isDateChecked;
type.isDateRequired = createDto.isDateChecked ? createDto.isDateRequired : null;

type.isSingleDateChecked = createDto.isDateChecked ? createDto.isSingleDateChecked : null;
type.singleDateLabel = createDto.isSingleDateChecked ? createDto.singleDateLabel : null;

type.isMultipleDateChecked = createDto.isDateChecked ? createDto.isMultipleDateChecked : null;

type.isSecurityAmountChecked = createDto.isSecurityAmountChecked;
type.isSecurityAmountRequired = createDto.isSecurityAmountChecked ? createDto.isSecurityAmountRequired : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ export class NoticeofIntentDecisionConditionTypesService {
isAdministrativeFeeAmountChecked: true,
isAdministrativeFeeAmountRequired: true,
administrativeFeeAmount: true,
isDateChecked: true,
isDateRequired: true,
isSingleDateChecked: true,
isSingleDateRequired: true,
singleDateLabel: true,
isMultipleDateChecked: true,
isSecurityAmountChecked: true,
isSecurityAmountRequired: true,
},
Expand Down Expand Up @@ -59,10 +61,14 @@ export class NoticeofIntentDecisionConditionTypesService {
? updateDto.administrativeFeeAmount
: null;

type.isSingleDateChecked = updateDto.isSingleDateChecked;
type.isSingleDateRequired = updateDto.isSingleDateChecked ? updateDto.isSingleDateRequired : null;
type.isDateChecked = updateDto.isDateChecked;
type.isDateRequired = updateDto.isDateChecked ? updateDto.isDateRequired : null;

type.isSingleDateChecked = updateDto.isDateChecked ? updateDto.isSingleDateChecked : null;
type.singleDateLabel = updateDto.isSingleDateChecked ? updateDto.singleDateLabel : null;

type.isMultipleDateChecked = updateDto.isDateChecked ? updateDto.isMultipleDateChecked : null;

type.isSecurityAmountChecked = updateDto.isSecurityAmountChecked;
type.isSecurityAmountRequired = updateDto.isSecurityAmountChecked ? updateDto.isSecurityAmountRequired : null;

Expand All @@ -84,10 +90,14 @@ export class NoticeofIntentDecisionConditionTypesService {
? createDto.administrativeFeeAmount
: null;

type.isSingleDateChecked = createDto.isSingleDateChecked;
type.isSingleDateRequired = createDto.isSingleDateChecked ? createDto.isSingleDateRequired : null;
type.isDateChecked = createDto.isDateChecked;
type.isDateRequired = createDto.isDateChecked ? createDto.isDateRequired : null;

type.isSingleDateChecked = createDto.isDateChecked ? createDto.isSingleDateChecked : null;
type.singleDateLabel = createDto.isSingleDateChecked ? createDto.singleDateLabel : null;

type.isMultipleDateChecked = createDto.isDateChecked ? createDto.isMultipleDateChecked : null;

type.isSecurityAmountChecked = createDto.isSecurityAmountChecked;
type.isSecurityAmountRequired = createDto.isSecurityAmountChecked ? createDto.isSecurityAmountRequired : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,24 @@ export class ApplicationDecisionConditionType extends BaseCodeEntity {

@AutoMap()
@Column({ default: false, type: 'boolean' })
isSingleDateChecked: boolean;
isDateChecked: boolean;

@AutoMap()
@Column({ nullable: true, type: 'boolean' })
isSingleDateRequired: boolean | null;
isDateRequired: boolean | null;

@AutoMap()
@Column({ nullable: true, type: 'boolean' })
isSingleDateChecked: boolean | null;

@AutoMap()
@Column({ type: 'enum', enum: DateLabel, nullable: true })
singleDateLabel: DateLabel | null;

@AutoMap()
@Column({ nullable: true, type: 'boolean' })
isMultipleDateChecked: boolean | null;

@AutoMap()
@Column({ default: false, type: 'boolean' })
isSecurityAmountChecked: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ export class ApplicationDecisionConditionTypeDto extends BaseCodeDto {

@AutoMap()
@IsBoolean()
isSingleDateChecked: boolean;
isDateChecked: boolean;

@AutoMap()
@IsBoolean()
isSingleDateRequired: boolean | null;
isDateRequired: boolean | null;

@AutoMap()
@IsBoolean()
isSingleDateChecked: boolean | null;

@AutoMap()
@IsEnum(DateLabel)
singleDateLabel: DateLabel | null;

@AutoMap()
@IsBoolean()
isMultipleDateChecked: boolean | null;

@AutoMap()
@IsBoolean()
isSecurityAmountChecked: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,24 @@ export class NoticeOfIntentDecisionConditionType extends BaseCodeEntity {

@AutoMap()
@Column({ default: false, type: 'boolean' })
isSingleDateChecked: boolean;
isDateChecked: boolean;

@AutoMap()
@Column({ nullable: true, type: 'boolean' })
isSingleDateRequired: boolean | null;
isDateRequired: boolean | null;

@AutoMap()
@Column({ nullable: true, type: 'boolean' })
isSingleDateChecked: boolean | null;

@AutoMap()
@Column({ type: 'enum', enum: DateLabel, nullable: true })
singleDateLabel: DateLabel | null;

@AutoMap()
@Column({ nullable: true, type: 'boolean' })
isMultipleDateChecked: boolean | null;

@AutoMap()
@Column({ default: false, type: 'boolean' })
isSecurityAmountChecked: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,24 @@ export class NoticeOfIntentDecisionConditionTypeDto extends BaseCodeDto {

@AutoMap()
@IsBoolean()
isSingleDateChecked: boolean;
isDateChecked: boolean;

@AutoMap()
@IsBoolean()
isSingleDateRequired: boolean | null;
isDateRequired: boolean | null;

@AutoMap()
@IsBoolean()
isSingleDateChecked: boolean | null;

@AutoMap()
@IsEnum(DateLabel)
singleDateLabel: DateLabel | null;

@AutoMap()
@IsBoolean()
isMultipleDateChecked: boolean | null;

@AutoMap()
@IsBoolean()
isSecurityAmountChecked: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,21 @@ export class ApplicationDecisionProfile extends AutomapperProfile {
mapFrom((entity) => (entity.administrativeFeeAmount !== null ? entity.administrativeFeeAmount : null)),
),
forMember(
(dto) => dto.isSingleDateRequired,
mapFrom((entity) => (entity.isSingleDateRequired !== null ? entity.isSingleDateRequired : null)),
(dto) => dto.isDateRequired,
mapFrom((entity) => (entity.isDateRequired !== null ? entity.isDateRequired : null)),
),
forMember(
(dto) => dto.isSingleDateChecked,
mapFrom((entity) => (entity.isSingleDateChecked !== null ? entity.isSingleDateChecked : null)),
),
forMember(
(dto) => dto.singleDateLabel,
mapFrom((entity) => (entity.singleDateLabel !== null ? entity.singleDateLabel : null)),
),
forMember(
(dto) => dto.isMultipleDateChecked,
mapFrom((entity) => (entity.isMultipleDateChecked !== null ? entity.isMultipleDateChecked : null)),
),
forMember(
(dto) => dto.isSecurityAmountRequired,
mapFrom((entity) => (entity.isSecurityAmountRequired !== null ? entity.isSecurityAmountRequired : null)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,21 @@ export class NoticeOfIntentDecisionProfile extends AutomapperProfile {
mapFrom((entity) => (entity.administrativeFeeAmount !== null ? entity.administrativeFeeAmount : null)),
),
forMember(
(dto) => dto.isSingleDateRequired,
mapFrom((entity) => (entity.isSingleDateRequired !== null ? entity.isSingleDateRequired : null)),
(dto) => dto.isDateRequired,
mapFrom((entity) => (entity.isDateRequired !== null ? entity.isDateRequired : null)),
),
forMember(
(dto) => dto.isSingleDateChecked,
mapFrom((entity) => (entity.isSingleDateChecked !== null ? entity.isSingleDateChecked : null)),
),
forMember(
(dto) => dto.singleDateLabel,
mapFrom((entity) => (entity.singleDateLabel !== null ? entity.singleDateLabel : null)),
),
forMember(
(dto) => dto.isMultipleDateChecked,
mapFrom((entity) => (entity.isMultipleDateChecked !== null ? entity.isMultipleDateChecked : null)),
),
forMember(
(dto) => dto.isSecurityAmountRequired,
mapFrom((entity) => (entity.isSecurityAmountRequired !== null ? entity.isSecurityAmountRequired : null)),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddMultipleDateToConditionType1732918376279 implements MigrationInterface {
name = 'AddMultipleDateToConditionType1732918376279';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" DROP COLUMN "is_single_date_required"`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" DROP COLUMN "is_single_date_required"`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" ADD "is_date_checked" boolean NOT NULL DEFAULT false`,
);
await queryRunner.query(`ALTER TABLE "alcs"."application_decision_condition_type" ADD "is_date_required" boolean`);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" ADD "is_multiple_date_checked" boolean`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ADD "is_date_checked" boolean NOT NULL DEFAULT false`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ADD "is_date_required" boolean`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ADD "is_multiple_date_checked" boolean`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" ALTER COLUMN "is_single_date_checked" DROP NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" ALTER COLUMN "is_single_date_checked" DROP DEFAULT`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ALTER COLUMN "is_single_date_checked" DROP NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ALTER COLUMN "is_single_date_checked" DROP DEFAULT`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ALTER COLUMN "is_single_date_checked" SET DEFAULT false`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ALTER COLUMN "is_single_date_checked" SET NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" ALTER COLUMN "is_single_date_checked" SET DEFAULT false`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" ALTER COLUMN "is_single_date_checked" SET NOT NULL`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" DROP COLUMN "is_multiple_date_checked"`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" DROP COLUMN "is_date_required"`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" DROP COLUMN "is_date_checked"`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" DROP COLUMN "is_multiple_date_checked"`,
);
await queryRunner.query(`ALTER TABLE "alcs"."application_decision_condition_type" DROP COLUMN "is_date_required"`);
await queryRunner.query(`ALTER TABLE "alcs"."application_decision_condition_type" DROP COLUMN "is_date_checked"`);
await queryRunner.query(
`ALTER TABLE "alcs"."notice_of_intent_decision_condition_type" ADD "is_single_date_required" boolean`,
);
await queryRunner.query(
`ALTER TABLE "alcs"."application_decision_condition_type" ADD "is_single_date_required" boolean`,
);
}
}

0 comments on commit ebefd18

Please sign in to comment.