Skip to content

FINERACT-2316: localize interest rate chart validation#5038

Merged
adamsaghy merged 1 commit intoapache:developfrom
sidshas03:FINERACT-2316-localize-interest-rate-chart-validation
Dec 3, 2025
Merged

FINERACT-2316: localize interest rate chart validation#5038
adamsaghy merged 1 commit intoapache:developfrom
sidshas03:FINERACT-2316-localize-interest-rate-chart-validation

Conversation

@sidshas03
Copy link
Contributor

@sidshas03 sidshas03 commented Sep 16, 2025

Summary
This PR completes the i18n work for InterestRateChart slab validation and gets CI to green. Hard-coded/concatenated messages are replaced with message codes + arguments, message bundles are updated, focused tests cover overlap and gap scenarios, and spotless/checkstyle/spotbugs/tests pass locally.
Supersedes #4793 (credit to the original author and discussion).

What changed (final approach adopted)

  • Domain stays Spring-free; standard validator pattern used

    // InterestRateChart.java
    DataValidatorBuilder v = new DataValidatorBuilder(errors)
        .resource("savings.interestRateChart")
        .parameter("slabs");
    v.failWithCode("overlap", slabContext, nextSlabContext);
    v.failWithCode("gap",     slabContext, nextSlabContext);

    Resolves to clean codes:

    • validation.msg.savings.interestRateChart.slabs.overlap
    • validation.msg.savings.interestRateChart.slabs.gap
  • Message bundles (added/updated in fineract-provider/src/main/resources/messages.properties)

    validation.msg.savings.interestRateChart.slabs.overlap=There is an overlap between slabs {0} and {1}.
    validation.msg.savings.interestRateChart.slabs.gap=There is a gap between slabs {0} and {1}.
    
  • Tests
    Added/updated unit tests to trigger overlap/gap and assert the exact codes (and arguments where exposed).

  • CI
    Ran spotless, checkstyle, spotbugs, and tests locally — all green.

Alternatives evaluated and not taken (with reasons)

  • Injecting MessageSource / LocaleContextHolder into domain/assemblers — rejected to keep the domain layer clean; Fineract typically passes codes + args and resolves messages later.
  • Custom InterestRateChartDataValidatorBuilder subclass — rejected to avoid expanding API surface; standard builder suffices.
  • Using full i18n keys while the builder had resource()/parameter() set — led to double-prefixed codes (e.g., validation.msg.interestRateChart.validation.msg.savings…).
  • Using failWithCodeNoParameterAddedToErrorCode on a builder with context — could still introduce unwanted prefixes or null segments based on builder state.
  • Direct ApiParameterError.parameterError(...) — functional but bypasses the usual validator aggregation flow; reverted for consistency.

Scope (files of interest)

  • fineract-savings/src/main/java/.../InterestRateChart.java
  • fineract-provider/src/main/resources/messages.properties (and optional locale bundles)
  • fineract-savings/src/test/java/.../InterestRateChartValidationTest.java

Compatibility / API notes

  • No REST schema changes.
  • globalisationMessageCode for these validations now follows the standard validation.msg.savings.interestRateChart.* pattern.

How to verify

  1. Build & checks:

    ./gradlew spotlessApply checkstyleMain checkstyleTest spotbugsMain spotbugsTest test
  2. Confirm no hard-coded “overlap/gap” texts remain in InterestRateChart.java.

  3. Run the updated tests; assertions should pass for the two codes above.

Housekeeping

@bharathcgowda - following up from #4793.
I’ve opened this PR to localise the InterestRateChart slab validation using the minimal approach we discussed. Thank you so much for allowing me to work on it. Please kindly review and let me know.

@adamsaghy
Copy link
Contributor

* What went wrong:
Execution failed for task ':rat'.

> A failure occurred while executing org.nosphere.apache.rat.RatWork
   > Apache Rat audit failure - 2 unapproved licenses
     	See file:///home/runner/work/fineract/fineract/build/reports/rat/index.html
@bharathcgowda
Copy link

@sidshas03 one check is failing, could you please check?

sidshas03 added a commit to sidshas03/fineract that referenced this pull request Oct 2, 2025
- Add proper Apache license headers to messages.properties and messages_de.properties
- Fixes Apache RAT license audit failure
- Resolves CI check failure for PR apache#5038
@bharathcgowda
Copy link

@adamsaghy could you please help in review of this PR?

@IOhacker
Copy link
Contributor

@sidshas03 are you still working on this PR?

@adamsaghy
Copy link
Contributor

@sidshas03 Please rebase this PR with latest develop branch!

@adamsaghy
Copy link
Contributor

@sidshas03 Are you still working on this? -> Please rebase this PR with latest develop branch!

@sidshas03
Copy link
Contributor Author

@sidshas03 Are you still working on this? -> Please rebase this PR with latest develop branch!

Yes @adamsaghy I am working on it right now

sidshas03 added a commit to sidshas03/fineract that referenced this pull request Nov 3, 2025
- Add proper Apache license headers to messages.properties and messages_de.properties
- Fixes Apache RAT license audit failure
- Resolves CI check failure for PR apache#5038
@sidshas03 sidshas03 force-pushed the FINERACT-2316-localize-interest-rate-chart-validation branch from 9d2296b to deeff92 Compare November 3, 2025 17:30
@adamsaghy
Copy link
Contributor

@sidshas03 Please rebase and squash your commits.

# dummy
org.apache.fineract.dummy.request.content.not-empty=Dummy request content must have a value

# Interest Rate Chart validation messages
Copy link
Contributor

Choose a reason for hiding this comment

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

Why these validation messages are duplicated? (fineract-command and fineract-provider module)

Copy link
Contributor

@adamsaghy adamsaghy left a comment

Choose a reason for hiding this comment

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

Kindly see my concerns.

- Add localized validation messages for overlap and gap errors in interest rate chart slabs
- Use DataValidatorBuilder with resource/parameter context for clean error codes
- Add unit tests for validation error codes and arguments
- Add German translations for validation messages
@sidshas03 sidshas03 force-pushed the FINERACT-2316-localize-interest-rate-chart-validation branch from deeff92 to 22c5326 Compare December 2, 2025 19:19
@sidshas03
Copy link
Contributor Author

sidshas03 commented Dec 2, 2025

hey @adamsaghy
Thank you for the review and sorry for the delay in making changes.
As per your feedback, I have done the following:

  • Removed the duplicate messages - The validation messages for Interest Rate Chart were present in both fineract-command and fineract-provider modules. I have removed them from fineract-command/src/test/resources/ and kept them only in fineract-provider/src/main/resources/ which is the proper production location.
  • Rebased and squashed commits - All 6 commits have been squashed into a single commit and rebased with latest develop branch.
  • Kindly review and let me know if any other changes are required.

Thanks & Regards
Siddharthan P S

@sidshas03
Copy link
Contributor Author

@adamsaghy I have updated the changes and it has successfully passed the Checks, please kindly review and let me know if there is any changes to be done

@adamsaghy adamsaghy changed the title Fineract 2316 localize interest rate chart validation Dec 3, 2025
@adamsaghy adamsaghy changed the title Fineract-2316: localize interest rate chart validation Dec 3, 2025
@adamsaghy adamsaghy merged commit 3d3b2da into apache:develop Dec 3, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

5 participants