Skip to content

WEB-389: Fix date format issue when editing holidays#2741

Merged
gkbishnoi07 merged 1 commit intoopenMF:devfrom
AnvayKharb:WEB-389-editing-existing-holidays-fails-due-to-date-format-problem
Nov 19, 2025
Merged

WEB-389: Fix date format issue when editing holidays#2741
gkbishnoi07 merged 1 commit intoopenMF:devfrom
AnvayKharb:WEB-389-editing-existing-holidays-fails-due-to-date-format-problem

Conversation

@AnvayKharb
Copy link
Contributor

@AnvayKharb AnvayKharb commented Nov 1, 2025

Resolves Issue: web-389

This pull request resolves a critical bug on the Organization > Manage Holidays page. When a user attempted to edit an existing holiday, the form would fail to submit, displaying an API validation error: The parameter “fromDate” is invalid based on the dateFormat: “dd MMMM yyyy” and locale: “en” provided.

The root cause of this issue was a format mismatch between the frontend display logic and the backend API's validation rules. The "Edit Holiday" form was incorrectly configured to display and submit dates in the MM/DD/YYYY format (e.g., "11/7/2025"), while the backend API strictly requires the dd MMMM yyyy format (e.g., "07 November 2025").

The Solution:
This fix addresses the bug at the frontend presentation layer by re-configuring the date picker components used in the "Edit Holiday" form.

The dateFormat prop (or its equivalent) for the fromDate, toDate, and repaymentScheduledTo fields has been explicitly changed from MM/DD/YYYY to dd MMMM yyyy.

The locale is ensured to be en to match the server's expectation.

This change ensures that the date format displayed to the user is the exact string format the server expects. When the form is submitted, the correctly formatted date string (e.g., "07 November 2025") is sent in the payload, which now passes the API validation.

Summary by CodeRabbit

  • Chores
    • Standardized date handling in holiday creation and editing to ensure consistent date formatting across workflows.
    • Improved conditional handling so rescheduled repayment dates are only formatted and applied when appropriate date values and scheduling types are present.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 1, 2025

Note

.coderabbit.yaml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized key(s) in object: 'pre_merge_checks'
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

Replaces formatDate calls with formatDateAsString in holiday components; the create component applies the new formatter directly, while the edit component adds explicit Date-type guards before formatting fromDate, toDate, and repaymentsRescheduledTo.

Changes

Cohort / File(s) Summary
Holiday date formatting refactor
src/app/organization/holidays/create-holiday/create-holiday.component.ts, src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
Replaced formatDate with formatDateAsString for fromDate, toDate, and repaymentsRescheduledTo. Edit component adds guards that only call formatDateAsString when the form values are Date instances and when reSchedulingType === 2 for repayments.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify formatDateAsString signature and dateFormat usage match callers.
  • Check the Date-instance guards in edit-holiday.component.ts cover all code paths and preserve previous behaviour.
  • Ensure no lint/type errors introduced by changed imports or line-break adjustments.

Possibly related PRs

Suggested reviewers

  • IOhacker
  • alberto-art3ch
  • gkbishnoi07

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing date format issues when editing holidays, which aligns with the core objective of resolving the frontend/backend date format mismatch.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a6e1a6 and 6610a01.

📒 Files selected for processing (2)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 03e6703 and 02bbf9a.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json and included by **/*
📒 Files selected for processing (4)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.html (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1 hunks)
  • src/environments/.env.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/organization/holidays/create-holiday/create-holiday.component.ts
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.html
🧬 Code graph analysis (2)
src/app/organization/holidays/create-holiday/create-holiday.component.ts (1)
src/app/settings/settings.service.ts (1)
  • dateFormat (111-113)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)
src/app/settings/settings.service.ts (1)
  • dateFormat (111-113)
🪛 dotenv-linter (4.0.0)
src/environments/.env.ts

[warning] 5-5: [IncorrectDelimiter] The 'version': '251031', key has incorrect delimiter

(IncorrectDelimiter)


[warning] 5-5: [KeyWithoutValue] The 'version': '251031', key should be with a value or have an equal sign

(KeyWithoutValue)


[warning] 5-5: [LeadingCharacter] Invalid leading character detected

(LeadingCharacter)


[warning] 5-5: [LowercaseKey] The 'version': '251031', key should be in uppercase

(LowercaseKey)


[warning] 5-5: [UnorderedKey] The 'version': '251031', key should go before the /* tslint:disable */ key

(UnorderedKey)


[warning] 6-6: [IncorrectDelimiter] The 'hash': '3b5a68bb' key has incorrect delimiter

(IncorrectDelimiter)


[warning] 6-6: [KeyWithoutValue] The 'hash': '3b5a68bb' key should be with a value or have an equal sign

(KeyWithoutValue)


[warning] 6-6: [LeadingCharacter] Invalid leading character detected

(LeadingCharacter)


[warning] 6-6: [LowercaseKey] The 'hash': '3b5a68bb' key should be in uppercase

(LowercaseKey)


[warning] 6-6: [UnorderedKey] The 'hash': '3b5a68bb' key should go before the 'mifos_x': { key

(UnorderedKey)


[warning] 7-7: [KeyWithoutValue] The }, key should be with a value or have an equal sign

(KeyWithoutValue)


[warning] 7-7: [LeadingCharacter] Invalid leading character detected

(LeadingCharacter)


[warning] 8-8: [IncorrectDelimiter] The 'allow_switching_backend_instance': true key has incorrect delimiter

(IncorrectDelimiter)


[warning] 8-8: [KeyWithoutValue] The 'allow_switching_backend_instance': true key should be with a value or have an equal sign

(KeyWithoutValue)


[warning] 8-8: [LeadingCharacter] Invalid leading character detected

(LeadingCharacter)


[warning] 8-8: [LowercaseKey] The 'allow_switching_backend_instance': true key should be in uppercase

(LowercaseKey)


[warning] 8-8: [UnorderedKey] The 'allow_switching_backend_instance': true key should go before the 'hash': '3b5a68bb' key

(UnorderedKey)

🔇 Additional comments (3)
src/environments/.env.ts (1)

5-8: LGTM - configuration updates look good.

The version/hash updates and new allow_switching_backend_instance feature flag are straightforward configuration changes. Note that the static analysis warnings from dotenv-linter are false positives—this is a TypeScript file, not a .env file.

src/app/organization/holidays/edit-holiday/edit-holiday.component.html (1)

94-94: LGTM - explicit button type improves clarity.

Adding type="submit" to the submit button is a best practice that makes the form submission behavior explicit.

src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)

137-151: LGTM - defensive date formatting logic.

The updated date formatting logic properly:

  • Extracts date values into typed variables
  • Guards formatting with instanceof Date checks to prevent runtime errors
  • Uses formatDateAsString to ensure backend-compatible format (dd MMMM yyyy)
  • Conditionally formats repaymentsRescheduledTo only when reSchedulingType === 2

This addresses the PR objective of fixing date format mismatches.

@AnvayKharb
Copy link
Contributor Author

please review @gkbishnoi07

Copy link
Collaborator

@gkbishnoi07 gkbishnoi07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @AnvayKharb dont push.env.ts file and please squash your commits make it only 1 commit

@AnvayKharb AnvayKharb force-pushed the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch from a04f916 to 22a2ff4 Compare November 2, 2025 16:22
Copy link
Contributor

@IOhacker IOhacker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont add your .env file. the options that you are using on it seems deprecated now. Make sure that your are in sync with the dev branch

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/app/organization/holidays/edit-holiday/edit-holiday.component.html (1)

54-56: Consider adding trackBy to the *ngFor loop for performance.

The loop at line 54 iterates over holidayData.repaymentSchedulingTypes without a trackBy function. While not blocking, adding a trackBy function improves change detection performance and aligns with Angular best practices.

Example refactor:

<mat-option *ngFor="let repayments of holidayData.repaymentSchedulingTypes; trackBy: trackByRepaymentId" [value]="repayments.id">
  {{ repayments.value }}
</mat-option>

Then in the component TypeScript file, add a trackBy method:

trackByRepaymentId(index: number, repayment: any): number {
  return repayment.id;
}

As per coding guidelines.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a04f916 and 22a2ff4.

📒 Files selected for processing (3)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.html (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/organization/holidays/edit-holiday/edit-holiday.component.html
🔇 Additional comments (2)
src/app/organization/holidays/edit-holiday/edit-holiday.component.html (2)

93-101: Explicit type="submit" clarifies form submission semantics.

Adding the explicit type="submit" attribute is a best practice and ensures the button properly triggers form submission within the Angular reactive forms context.


15-80: Verify date picker configuration in the TypeScript component.

The PR objective states that date picker configuration should use the dd MMMM yyyy format and locale en to match backend expectations. These configurations typically reside in the component TypeScript file, not the template. Please confirm that the corresponding edit-holiday.component.ts file contains the necessary date formatting updates for fromDate, toDate, and repaymentsRescheduledTo using formatDateAsString or equivalent date formatting logic.

@AnvayKharb
Copy link
Contributor Author

Hey @IOhacker @gkbishnoi07 I’ve removed the .env.ts file and squashed my commits into a single one.
Please let me know if any further changes are needed. 👍

Copy link
Collaborator

@alberto-art3ch alberto-art3ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review the changes suggested by coderabbit, In this case they look to be ok

@AnvayKharb AnvayKharb force-pushed the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch from 22a2ff4 to cc88ee2 Compare November 3, 2025 06:34
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 22a2ff4 and cc88ee2.

📒 Files selected for processing (3)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.html (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.html
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/organization/holidays/create-holiday/create-holiday.component.ts
🧬 Code graph analysis (1)
src/app/organization/holidays/create-holiday/create-holiday.component.ts (1)
src/app/settings/settings.service.ts (1)
  • dateFormat (111-113)

@AnvayKharb AnvayKharb force-pushed the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch from cc88ee2 to 727951f Compare November 3, 2025 06:54
@AnvayKharb
Copy link
Contributor Author

please take a look @IOhacker @gkbishnoi07

Copy link
Collaborator

@gkbishnoi07 gkbishnoi07 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AnvayKharb
Copy link
Contributor Author

AnvayKharb commented Nov 5, 2025

hey @IOhacker please take a look

@AnvayKharb
Copy link
Contributor Author

@alberto-art3ch please take a look!!

@gkbishnoi07
Copy link
Collaborator

@AnvayKharb please resolve conflict

@AnvayKharb AnvayKharb force-pushed the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch from ee74f08 to 215d12d Compare November 6, 2025 18:25
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)

137-162: Major: Remove dead code from incomplete refactoring.

The date formatting logic is duplicated. After the new formatting (lines 140-150) executes, holidayFormData.fromDate, toDate, and repaymentsRescheduledTo are already strings. The subsequent instanceof Date checks at lines 151-162 will always be false, making that entire block unreachable dead code.

Based on the PR objectives to fix the date format issue, the old formatDate calls should be removed entirely.

Apply this diff to remove the dead code:

       if (repaymentScheduledTo instanceof Date) {
         holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(repaymentScheduledTo, dateFormat);
       }
     }
-    if (holidayFormData.fromDate instanceof Date) {
-      holidayFormData.fromDate = this.dateUtils.formatDate(holidayFormData.fromDate, dateFormat);
-    }
-    if (holidayFormData.toDate instanceof Date) {
-      holidayFormData.toDate = this.dateUtils.formatDate(holidayFormData.toDate, dateFormat);
-    }
-    if (this.reSchedulingType === 2 && holidayFormData.repaymentsRescheduledTo instanceof Date) {
-      holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDate(
-        holidayFormData.repaymentsRescheduledTo,
-        dateFormat
-      );
-    }
   }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 215d12d and e1cad7b.

📒 Files selected for processing (1)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
🧬 Code graph analysis (1)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)
src/app/settings/settings.service.ts (1)
  • dateFormat (112-115)
🪛 GitHub Actions: build-run
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts

[error] 175-175: npx eslint . reported a parsing error: ESLint: Parsing error: '}' expected in edit-holiday.component.ts.

@AnvayKharb AnvayKharb closed this Nov 7, 2025
@AnvayKharb AnvayKharb reopened this Nov 7, 2025
@AnvayKharb AnvayKharb force-pushed the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch from e1cad7b to 46b7ceb Compare November 7, 2025 16:13
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)

118-127: Memory leak: valueChanges subscription is never unsubscribed.

The subscription created at line 119 is not cleaned up when the component is destroyed, which can lead to memory leaks.

Consider using takeUntil with a Subject that completes in ngOnDestroy:

+import { Subject } from 'rxjs';
+import { takeUntil } from 'rxjs/operators';
+
 export class EditHolidayComponent implements OnInit {
+  private destroy$ = new Subject<void>();
+
   getReschedulingType() {
-    this.holidayForm.get('reschedulingType').valueChanges.subscribe((option: any) => {
+    this.holidayForm.get('reschedulingType').valueChanges
+      .pipe(takeUntil(this.destroy$))
+      .subscribe((option: any) => {
       this.reSchedulingType = option;
       if (option === 2) {
         this.holidayForm.addControl('repaymentsRescheduledTo', new UntypedFormControl(new Date(), Validators.required));
       } else {
         this.holidayForm.removeControl('repaymentsRescheduledTo');
       }
     });
   }
+
+  ngOnDestroy() {
+    this.destroy$.next();
+    this.destroy$.complete();
+  }

As per coding guidelines.

src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts (1)

171-186: Remove side effect from query method; fix asymmetric businessDate refresh logic.

The businessDate assignment at line 175 confirms multiple issues:

  1. Side effect in query method: isCurrent() modifies component state, violating functional principles and Angular best practices for clean observable patterns.

  2. Asymmetric refresh logic: businessDate is only refreshed in the else branch (when installment.fromDate exists). When !installment.fromDate, the method returns early without refreshing, using stale businessDate. This inconsistency causes unpredictable behavior.

  3. Performance: installmentStyle() is called 13+ times per row in the template (*matCellDef directives), triggering repeated settingsService.businessDate access on every change detection cycle.

  4. Redundant: businessDate is already initialized in the constructor (line 137).

Recommended fix:

Remove the assignment from isCurrent(). If businessDate must be kept current for holiday date calculations in this PR, refresh it in ngOnInit() or use a proper subscription pattern instead:

  isCurrent(installment: RepaymentSchedulePeriod): string {
    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) {
        return 'current';
      }
      if (this.businessDate > dueDate) {
        return 'overdued';
      }
    }
    return '';
  }
🧹 Nitpick comments (1)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)

33-33: Consider defining explicit types instead of any.

Using any for holidayData (and implicitly for holidayFormData at line 133) reduces type safety. Consider defining an interface for holiday data to catch type errors at compile time.

Example:

interface HolidayData {
  id: number;
  name: string;
  description: string;
  status: { value: string };
  reschedulingType: number;
  fromDate?: Date | string;
  toDate?: Date | string;
  repaymentsRescheduledTo?: Date | string;
  repaymentSchedulingTypes?: any[];
}

Then update line 33:

-  holidayData: any;
+  holidayData: HolidayData;

As per coding guidelines.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1cad7b and 46b7ceb.

📒 Files selected for processing (4)
  • Dockerfile (1 hunks)
  • src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts (2 hunks)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
🧬 Code graph analysis (1)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)
src/app/settings/settings.service.ts (1)
  • dateFormat (111-113)
🔇 Additional comments (2)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)

137-151: Date formatting changes look good and syntax error is resolved.

The type guards with instanceof Date combined with formatDateAsString(dateFormat) correctly ensure that dates are formatted according to the backend's expected format. This directly addresses the API validation error described in the PR objectives. The closing brace at line 151 also resolves the syntax error flagged in the previous review.

src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts (1)

14-15: LGTM: Import refinement is appropriate.

The import changes correctly reflect the component's actual dependencies by replacing general button imports with the more specific MatIconButton.

@gkbishnoi07
Copy link
Collaborator

@AnvayKharb still there is conflict

@gkbishnoi07
Copy link
Collaborator

@AnvayKharb why you did change in docker file? and still there is conflict please resolve it

@AnvayKharb AnvayKharb force-pushed the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch from 46b7ceb to 3a6e1a6 Compare November 19, 2025 19:42
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (2)

33-33: Improve type safety by replacing any types with specific interfaces.

The use of any type for holidayData (line 33) and the implicit any from this.holidayForm.value (line 133) reduces type safety and violates the coding guidelines for Angular code requiring "strict type safety."

As per coding guidelines

Consider defining interfaces for the holiday data structure:

interface HolidayData {
  id: number;
  name: string;
  description?: string;
  fromDate?: Date;
  toDate?: Date;
  reschedulingType: number;
  repaymentsRescheduledTo?: Date;
  status: { value: string };
  repaymentSchedulingTypes?: any[]; // Replace with specific type
}

interface HolidayFormData {
  name: string;
  description?: string;
  fromDate?: string | Date;
  toDate?: string | Date;
  reschedulingType?: number;
  repaymentsRescheduledTo?: string | Date;
}

Then update the declarations:

-  holidayData: any;
+  holidayData: HolidayData;
   submit() {
-    const holidayFormData = this.holidayForm.value;
+    const holidayFormData: HolidayFormData = this.holidayForm.value;

Also applies to: 133-133


137-151: Type guards and date formatting logic are correct; optional refactoring available.

The formatDateAsString method uses moment(value).format(dateFormat) to format dates, correctly handling any format string passed from settingsService. The type guards (instanceof Date) appropriately protect against formatting non-Date values, and the conditional logic correctly applies formatting only to non-active holidays.

The temporary variables (prevFromDate, prevToDate, repaymentScheduledTo) are redundant but not problematic. Simplifying by accessing form values directly in the type-guard conditions would improve clarity:

     if (!this.isActiveHoliday) {
-      const prevFromDate = this.holidayForm.value.fromDate;
-      const prevToDate = this.holidayForm.value.toDate;
-
-      if (prevFromDate instanceof Date) {
-        holidayFormData.fromDate = this.dateUtils.formatDateAsString(prevFromDate, dateFormat);
+      if (this.holidayForm.value.fromDate instanceof Date) {
+        holidayFormData.fromDate = this.dateUtils.formatDateAsString(this.holidayForm.value.fromDate, dateFormat);
       }
-      if (prevToDate instanceof Date) {
-        holidayFormData.toDate = this.dateUtils.formatDateAsString(prevToDate, dateFormat);
+      if (this.holidayForm.value.toDate instanceof Date) {
+        holidayFormData.toDate = this.dateUtils.formatDateAsString(this.holidayForm.value.toDate, dateFormat);
       }
       if (this.reSchedulingType === 2) {
-        const repaymentScheduledTo = this.holidayForm.value.repaymentsRescheduledTo;
-        if (repaymentScheduledTo instanceof Date) {
-          holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(repaymentScheduledTo, dateFormat);
+        if (this.holidayForm.value.repaymentsRescheduledTo instanceof Date) {
+          holidayFormData.repaymentsRescheduledTo = this.dateUtils.formatDateAsString(this.holidayForm.value.repaymentsRescheduledTo, dateFormat);
         }
       }
     }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46b7ceb and 3a6e1a6.

📒 Files selected for processing (2)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts (1 hunks)
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts
🧰 Additional context used
📓 Path-based instructions (1)
src/app/**

⚙️ CodeRabbit configuration file

src/app/**: For Angular code: verify component separation, trackBy on *ngFor,
strict type safety, and clean observable patterns.

Files:

  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
🧬 Code graph analysis (1)
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts (1)
src/app/settings/settings.service.ts (1)
  • dateFormat (111-113)

@AnvayKharb
Copy link
Contributor Author

heyy @gkbishnoi07 now I've changed my files as per you directed.

- 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
@AnvayKharb AnvayKharb force-pushed the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch from 9c4744a to 6610a01 Compare November 19, 2025 20:18
@gkbishnoi07 gkbishnoi07 dismissed stale reviews from alberto-art3ch and IOhacker November 19, 2025 21:06

done

@gkbishnoi07 gkbishnoi07 merged commit d769e84 into openMF:dev Nov 19, 2025
3 checks passed
@AnvayKharb AnvayKharb deleted the WEB-389-editing-existing-holidays-fails-due-to-date-format-problem branch November 21, 2025 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants