From 46b7cebf7981eab8b4282e2d1a97f07c7badc419 Mon Sep 17 00:00:00 2001 From: Anvay Date: Thu, 6 Nov 2025 23:54:34 +0530 Subject: [PATCH] WEB-389: Fix date formatting issue when editing and creating holidays - Changed edit-holiday component to use formatDateAsString with proper instanceof checks - Changed create-holiday component to use formatDateAsString - Fixed bug where incorrect date checks were being performed - formatDateAsString uses moment.format() which correctly handles Date objects - Resolves date format problems when editing existing holidays --- Dockerfile | 4 ++-- .../repayment-schedule-tab.component.ts | 5 +++-- .../create-holiday.component.ts | 9 +++++--- .../edit-holiday/edit-holiday.component.ts | 21 +++++++++++-------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 888d58a5bc..5e57509251 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ ############### ### STAGE 1: Build app ############### -ARG BUILDER_IMAGE=node:22.9.0-alpine -ARG NGINX_IMAGE=nginx:1.27.4-alpine3.21-slim +ARG BUILDER_IMAGE=node:24-alpine3.22 +ARG NGINX_IMAGE=nginx:1.29-alpine3.22-slim FROM $BUILDER_IMAGE AS builder ARG NPM_REGISTRY_URL=https://registry.npmjs.org/ diff --git a/src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts b/src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts index a1c9a09376..64d23abdeb 100644 --- a/src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts +++ b/src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts @@ -11,8 +11,8 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base'; import { jsPDF, jsPDFOptions } from 'jspdf'; import autoTable from 'jspdf-autotable'; -import { NgIf, NgClass, CurrencyPipe } from '@angular/common'; -import { MatButton, MatIconButton } from '@angular/material/button'; +import { NgClass, CurrencyPipe } from '@angular/common'; +import { MatIconButton } from '@angular/material/button'; import { FaIconComponent } from '@fortawesome/angular-fontawesome'; import { MatTable, @@ -172,6 +172,7 @@ export class RepaymentScheduleTabComponent implements OnInit, OnChanges { if (!installment.fromDate) { return ''; } else { + this.businessDate = this.settingsService.businessDate; const fromDate = this.dateUtils.parseDate(installment.fromDate); const dueDate = this.dateUtils.parseDate(installment.dueDate); if (fromDate <= this.businessDate && this.businessDate < dueDate) { diff --git a/src/app/organization/holidays/create-holiday/create-holiday.component.ts b/src/app/organization/holidays/create-holiday/create-holiday.component.ts index 4ce0073adb..6926740597 100644 --- a/src/app/organization/holidays/create-holiday/create-holiday.component.ts +++ b/src/app/organization/holidays/create-holiday/create-holiday.component.ts @@ -332,11 +332,14 @@ export class CreateHolidayComponent implements OnInit { const locale = this.settings.language.code; const prevFromDate: Date = this.holidayForm.value.fromDate; const prevToDate: Date = this.holidayForm.value.toDate; - holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); - holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); + holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat); + holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat); if (this.holidayForm.contains('repaymentsRescheduledTo')) { const prevRepaymentsRescheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo; - holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(prevRepaymentsRescheduledTo, dateFormat); + holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString( + prevRepaymentsRescheduledTo, + dateFormat + ); } const offices = this.holidayForm.value.offices.map((office: string) => { return { officeId: Number.parseInt(office, 10) }; diff --git a/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts b/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts index 2795f206cb..9bb4f1cc7c 100644 --- a/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts +++ b/src/app/organization/holidays/edit-holiday/edit-holiday.component.ts @@ -134,17 +134,20 @@ export class EditHolidayComponent implements OnInit { const locale = this.settingsService.language.code; const dateFormat = this.settingsService.dateFormat; if (!this.isActiveHoliday) { - if (this.reSchedulingType === 2) { - const repaymentScheduledTo: Date = this.holidayForm.value.repaymentsRescheduledTo; - holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(repaymentScheduledTo, dateFormat); + const prevFromDate = this.holidayForm.value.fromDate; + const prevToDate = this.holidayForm.value.toDate; + + if (prevFromDate instanceof Date) { + holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat); } - const prevFromDate: Date = this.holidayForm.value.fromDate; - const prevToDate: Date = this.holidayForm.value.toDate; - if (holidayFormData.closureDate instanceof Date) { - holidayFormData.fromDate = this.dateUtils.formatDate(prevFromDate, dateFormat); + if (prevToDate instanceof Date) { + holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat); } - if (holidayFormData.closureDate instanceof Date) { - holidayFormData.toDate = this.dateUtils.formatDate(prevToDate, dateFormat); + if (this.reSchedulingType === 2) { + const repaymentScheduledTo = this.holidayForm.value.repaymentsRescheduledTo; + if (repaymentScheduledTo instanceof Date) { + holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(repaymentScheduledTo, dateFormat); + } } } const data = {