FINERACT-2455: WC - created and submitted date of all features supported in WCP should follow business date or system date based on configuration - #6299
Conversation
galovics
left a comment
There was a problem hiding this comment.
The core mechanism is right - DateUtils.getBusinessLocalDate() already falls back to the tenant date when enable-business-date is off, so both config states are covered by construction, and the Liquibase backfill/constraint split is done correctly. Two things need fixing before merge though, plus a flaky assertion.
1. Breaking API change - response attribute removed
WorkingCapitalLoanNearBreachActionData and WorkingCapitalLoanPeriodPaymentRateChangeData drop OffsetDateTime createdDate in favor of LocalDate submittedOnDate. These records are the API response payloads (GET .../nearbreachactions, GET .../ratechanges), so this removes a field from the JSON contract - the repo's swagger-brake backward-compatibility check (R014 "Response attribute removed") should flag this. createdDate (system-clock audit stamp) and submittedOnDate (business date) aren't the same thing either, per your own changelog comment - can we add the new field and keep the old one rather than replacing it?
2. Liquibase NOT NULL column with no default - rolling deployment hazard
parts/0070_...xml and parts/0071_...xml add submitted_on_date DATE to existing tables, then addNotNullConstraint with no default value. N-1 code that doesn't know about the column will fail with a NOT NULL violation on insert during a rolling deploy. Either defaultValueComputed="CURRENT_DATE" on the added column, or keep it nullable in this release and tighten it in a follow-up.
3. Flaky e2e assertion (WorkingCapitalNearBreachActionStepDef / WorkingCapitalLoanAccountStepDef)
assertThat(latest.getSubmittedOnDate()).as(...).isEqualTo(Utils.now());Utils.now() is LocalDate.now(Clock.systemUTC()), but the value under test comes from DateUtils.getLocalDateOfTenant() - tenant timezone, which defaults to Asia/Kolkata in this stack. Between 18:30 and 24:00 UTC the tenant is already on the next day and this fails. Can we read the tenant date instead of using Utils.now() for equality here?
4. Global config mutation without the repo's isolation mechanism
Both new e2e scenarios flip enable-business-date globally without using the existing cucumber.execution.exclusive-resources pattern already used for exactly this kind of shared state. Parallelism is off today so it's masked, but it'll silently corrupt other business-date-dependent scenarios the moment it's turned on.
Smaller: the trailing "Then Global configuration is enabled" step duplicates the existing @BusinessDateDisabledCheck after-hook and doesn't run on mid-scenario failure - probably fine to drop in favor of the hook. And the ticket title says "all features supported in WCP" but this only covers rate change + near-breach action - is that the full scope or a first slice?
Recommendation: CHANGES_REQUESTED
2dcbcdd to
da73f49
Compare
@galovics Thank you for your review
|
@mariiaKraievska Do we need a new PR to backfill? |
No, backfill of existing rows is already in this PR. The follow-up is for NOT NULL, the extra WHERE IS NULL update there is just a safety net before adding the constraint, not a separate backfill deliverable. |
da73f49 to
1e98c48
Compare
@galovics Thank you for your review 3 and 4 - I've addressed both |
96a742e to
107cf2a
Compare
I am fine with dropping the audit field from the response:
|
galovics
left a comment
There was a problem hiding this comment.
Nice work on the follow-up. Three of the four points from last round are properly addressed:
- Liquibase: nullable column + separate backfill changeset now, rolling-deploy safe.
- The flaky e2e assertion:
Utils.now()is gone, replaced with a server-round-trip capture-before/after pattern - genuinely fixes the tenant-timezone issue rather than papering over it. - Test isolation: proper
exclusive-resourcesentry plus an@Afterrestore hook forenable-business-date, matching the existing pattern in this file.
One thing is still open though, and CI is now red on exactly it: createdDate is still being replaced by submittedOnDate on both WorkingCapitalLoanNearBreachActionData and WorkingCapitalLoanPeriodPaymentRateChangeData instead of the new field being added alongside it. run-api-backward-compatibility / api-compatibility-check is failing with:
R014 createdDate was removed from response default in GET /v1/working-capital-loans/{loanId}/rate-changes
R014 createdDate was removed from response default in GET /v1/working-capital-loans/external-id/{loanExternalId}/rate-changes
R014 createdDate was removed from response default in GET /v1/working-capital-loans/{loanId}/near-breach-actions
R014 createdDate was removed from response default in GET /v1/working-capital-loans/external-id/{loanExternalId}/near-breach-actions
Could you restore createdDate on both records (and the mapper mapping / constructor arg that were removed alongside it) and keep submittedOnDate as an addition rather than a replacement? If the intent is to phase createdDate out eventually, swaggerBrake { deprecatedApiDeletionAllowed = true } is already configured in fineract-provider/build.gradle, so marking it @Schema(deprecated = true) first and removing it in a later PR would work too.
Two small non-blocking things while I was back in there:
- The new
BusinessDateHelpermethods (captureCurrentTenantDateBeforeWorkingCapitalAction,getEffectiveWorkingCapitalDateFromServer) hard-depend on the WC charge-off template endpoint even thoughBusinessDateHelperis otherwise a generic helper - might be cleaner in a WC-specific helper. assertStampedOnCurrentTenantDatealso asserts.isNotEqualTo(storedBusinessDate)against the hardcoded01 January 2026stub date - harmless today, but it's a latent false failure if this suite is ever run on that calendar date. The.isIn(before, after)check already proves the point on its own.
Recommendation: CHANGES_REQUESTED (down from the prior review - just the API compat piece left)
107cf2a to
74a2c61
Compare
|
@galovics I've pushed
|
@galovics Restored createdDate on both response records and kept submittedOnDate as an addition. Marked createdDate as @Schema(deprecated = true) so we can remove it later. |
74a2c61 to
6386531
Compare
…ted in WCP should follow business date or system date based on configuration
…features supported in WCP should follow business date or system date based on configuration
6386531 to
0214bb3
Compare
All the requested changes were addressed.
Description
Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
Checklist
Please make sure these boxes are checked before submitting your pull request - thanks!
Your assigned reviewer(s) will follow our guidelines for code reviews.