Skip to content

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

  • Bug Fixes

    • Date fields in holiday create/edit are now only reformatted when valid, preventing incorrect serialization and unintended date changes.
    • Rescheduling and inactive-holiday flows now guard date handling to avoid improper updates.
  • UX

    • Edit-holiday form submit button behavior clarified for more reliable submission.
  • Refactor

    • Repayment schedule now refreshes business date before comparisons to ensure accurate displays.
  • Chores

    • Base images for build/serve updated.

@coderabbitai
Copy link

coderabbitai bot commented Nov 1, 2025

Walkthrough

Refactors date formatting in holiday create/edit components to use formatDateAsString and guard formatting with instanceof Date; moves repaymentsRescheduledTo formatting into the inactive/rescheduling branch. Adds type="submit" to the edit form button, refreshes businessDate in repayment schedule tab, and updates Docker base images.

Changes

Cohort / File(s) Summary
Date formatting — create
src/app/organization/holidays/create-holiday/create-holiday.component.ts
Replace unconditional formatDate calls with formatDateAsString(...) for fromDate/toDate in submit.
Date formatting — edit
src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
Guard fromDate/toDate formatting with instanceof Date, use formatDateAsString, and move repaymentsRescheduledTo formatting under the inactive/rescheduling branch.
Edit form UI
src/app/organization/holidays/edit-holiday/edit-holiday.component.html
Add explicit type="submit" to the Submit button.
Repayment schedule tab
src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts
Adjust imports (remove some, move MatIconButton import); refresh this.businessDate from settingsService.businessDate inside isCurrent before date comparisons.
Build images
Dockerfile
Bump build ARGs: BUILDER_IMAGE node:22.9.0-alpinenode:24-alpine3.22; NGINX_IMAGE nginx:1.27.4-alpine3.21-slimnginx:1.29-alpine3.22-slim.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant HolidayForm as HolidayFormComponent
  participant Validator as DateValidator
  participant Formatter as formatDateAsString
  participant API as BackendAPI

  User->>HolidayForm: Click Submit
  HolidayForm->>Validator: Validate date fields
  Validator-->>HolidayForm: Valid / Invalid
  alt Valid
    note right of HolidayForm `#E6F7FF`: Only format when\nvalue instanceof Date
    HolidayForm->>Formatter: formatDateAsString(date, dateFormat)
    Formatter-->>HolidayForm: formatted date string
    HolidayForm->>API: Send payload with formatted dates
    API-->>HolidayForm: Response
  else Invalid
    HolidayForm-->>User: Show validation errors
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify differences between formatDate and formatDateAsString.
  • Confirm instanceof Date guards handle null/undefined/string inputs appropriately.
  • Check repaymentsRescheduledTo formatting is executed only in the intended branch.
  • Validate repayment-schedule import changes don’t break templates or usage.
  • Ensure Docker image bumps don’t require ancillary build adjustments.

Possibly related PRs

Suggested reviewers

  • alberto-art3ch
  • IOhacker
  • 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 'WEB-389: Fix date format issue when editing holidays' directly and accurately summarizes the main change: addressing a date formatting bug in the holiday editing functionality.
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 727951f and 215d12d.

📒 Files selected for processing (5)
  • 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.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 (5)
  • Dockerfile
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.ts
  • src/app/organization/holidays/create-holiday/create-holiday.component.ts
  • src/app/loans/loans-view/repayment-schedule-tab/repayment-schedule-tab.component.ts
  • src/app/organization/holidays/edit-holiday/edit-holiday.component.html

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

- 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 ee74f08 to 215d12d Compare November 6, 2025 18:25
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