diff --git a/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.dto.ts b/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.dto.ts index c4bbfcc187..9832e53942 100644 --- a/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.dto.ts +++ b/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.dto.ts @@ -5,9 +5,9 @@ export class ApplicationDecisionConditionDateDto { @IsString() uuid?: string; - @Transform(({ value }) => value.getTime()) + @Transform(({ value }) => value && value.getTime()) @IsNumber() - date?: number; + date?: number | null; @Transform(({ value }) => value && value.getTime()) @IsNumber() diff --git a/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.entity.ts b/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.entity.ts index a701450f7f..ca39708830 100644 --- a/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.entity.ts +++ b/services/apps/alcs/src/alcs/application-decision/application-decision-condition/application-decision-condition-date/application-decision-condition-date.entity.ts @@ -13,8 +13,8 @@ export class ApplicationDecisionConditionDate extends Base { } @AutoMap() - @Column({ type: 'timestamptz' }) - date: Date; + @Column({ type: 'timestamptz', nullable: true }) + date: Date | null; @AutoMap() @Column({ type: 'timestamptz', nullable: true }) diff --git a/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.dto.ts b/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.dto.ts index 8c77649889..7f4f30896c 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.dto.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.dto.ts @@ -5,9 +5,9 @@ export class NoticeOfIntentDecisionConditionDateDto { @IsString() uuid?: string; - @Transform(({ value }) => value.getTime()) + @Transform(({ value }) => value && value.getTime()) @IsNumber() - date?: number; + date?: number | null; @Transform(({ value }) => value && value.getTime()) @IsNumber() diff --git a/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.entity.ts b/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.entity.ts index 48669bda3a..82147950bf 100644 --- a/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.entity.ts +++ b/services/apps/alcs/src/alcs/notice-of-intent-decision/notice-of-intent-decision-condition/notice-of-intent-decision-condition-date/notice-of-intent-decision-condition-date.entity.ts @@ -13,8 +13,8 @@ export class NoticeOfIntentDecisionConditionDate extends Base { } @AutoMap() - @Column({ type: 'timestamptz' }) - date: Date; + @Column({ type: 'timestamptz', nullable: true }) + date: Date | null; @AutoMap() @Column({ type: 'timestamptz', nullable: true }) diff --git a/services/apps/alcs/src/common/automapper/application-decision-v2.automapper.profile.ts b/services/apps/alcs/src/common/automapper/application-decision-v2.automapper.profile.ts index 90cbfdf519..d4eeb50ea1 100644 --- a/services/apps/alcs/src/common/automapper/application-decision-v2.automapper.profile.ts +++ b/services/apps/alcs/src/common/automapper/application-decision-v2.automapper.profile.ts @@ -238,7 +238,7 @@ export class ApplicationDecisionProfile extends AutomapperProfile { ApplicationDecisionConditionDateDto, forMember( (dto) => dto.date, - mapFrom((entity) => entity.date.getTime()), + mapFrom((entity) => entity.date && entity.date.getTime()), ), forMember( (dto) => dto.completedDate, diff --git a/services/apps/alcs/src/common/automapper/notice-of-intent-decision.automapper.profile.ts b/services/apps/alcs/src/common/automapper/notice-of-intent-decision.automapper.profile.ts index 5cfae233ff..a1509e6514 100644 --- a/services/apps/alcs/src/common/automapper/notice-of-intent-decision.automapper.profile.ts +++ b/services/apps/alcs/src/common/automapper/notice-of-intent-decision.automapper.profile.ts @@ -171,7 +171,7 @@ export class NoticeOfIntentDecisionProfile extends AutomapperProfile { NoticeOfIntentDecisionConditionDateDto, forMember( (dto) => dto.date, - mapFrom((entity) => entity.date.getTime()), + mapFrom((entity) => entity.date && entity.date.getTime()), ), forMember( (dto) => dto.completedDate, diff --git a/services/apps/alcs/src/providers/typeorm/migrations/1734030229522-make_condition_date_dates_nullable.ts b/services/apps/alcs/src/providers/typeorm/migrations/1734030229522-make_condition_date_dates_nullable.ts new file mode 100644 index 0000000000..7dd5fdd729 --- /dev/null +++ b/services/apps/alcs/src/providers/typeorm/migrations/1734030229522-make_condition_date_dates_nullable.ts @@ -0,0 +1,16 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class MakeConditionDateDatesNullable1734030229522 implements MigrationInterface { + name = 'MakeConditionDateDatesNullable1734030229522' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "alcs"."application_decision_condition_date" ALTER COLUMN "date" DROP NOT NULL`); + await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_decision_condition_date" ALTER COLUMN "date" DROP NOT NULL`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "alcs"."notice_of_intent_decision_condition_date" ALTER COLUMN "date" SET NOT NULL`); + await queryRunner.query(`ALTER TABLE "alcs"."application_decision_condition_date" ALTER COLUMN "date" SET NOT NULL`); + } + +}