FINERACT-2545: Implement client charge inactivation#5655
FINERACT-2545: Implement client charge inactivation#5655AshharAhmadKhan wants to merge 1 commit intoapache:developfrom
Conversation
|
Pushed a follow-up commit after deeper review of state transitions and API completeness. The first commit fixed the core bug - the missing handler and stub service. While verifying the full operation lifecycle I found three additional issues worth addressing in the same PR rather than leaving as separate tickets.
Updated the Tests added for the undo guard and the fields filter. All existing tests untouched. |
POST /clients/{clientId}/charges/{chargeId}?command=inactivate was
broken end-to-end. The API accepted the command and built a
CommandWrapper with entity=CLIENTCHARGE action=INACTIVATE, but no
command handler was registered for that key, causing
CommandHandlerProvider to throw UnsupportedCommandException on every
call. The service method was also a stub returning null with a
'functionality not yet supported' comment.
This commit completes the originally intended implementation:
- Add InactivateClientChargeCommandHandler wired to CLIENTCHARGE|INACTIVATE
- Add ClientCharge.inactivate() domain method setting status=false
and inactivationDate
- Implement ClientChargeWritePlatformServiceImpl.inactivateCharge()
with guards for already-inactive, already-waived, and already-paid
- Add integration test covering success path and idempotency failure
FINERACT-2545: Fix state integrity and documentation gaps
Three follow-up fixes identified through deep domain analysis:
1. Add isActive and inactivationDate to CLIENT_CHARGES_RESPONSE_DATA_PARAMETERS
so these fields are returned when using the ?fields= query parameter filter.
2. Fix ClientCharge.undoPayment() and undoWaiver() to not restore active
status when a charge has been explicitly inactivated (inactivationDate != null).
Previously, undoing a payment on an inactivated charge would silently
reactivate it, violating state integrity.
3. Add service-level guard in ClientTransactionWritePlatformServiceJpaRepositoryImpl
to block undo operations on inactive charges entirely, enforcing inactivation
as a terminal state at both domain and service layers.
4. Update @operation Swagger annotation on payOrWaiveClientCharge to document
the inactivate command alongside pay and waive.
Tests added: undo blocked on inactive charge, isActive returned correctly
via explicit ?fields= filter.
7524369 to
fa37023
Compare
|
All checks should now be passing after squashing into a single commit. Happy to make any adjustments based on feedback or direction from the ongoing discussion. |
Description
POST /clients/{clientId}/charges/{chargeId}?command=inactivatehas never worked. The API accepted the command and built aCommandWrapperwithentity=CLIENTCHARGEandaction=INACTIVATE, but no command handler was ever registered for the key"CLIENTCHARGE|INACTIVATE". The dispatcher threwUnsupportedCommandExceptionimmediately, returning HTTP 500 to every caller. The service methodClientChargeWritePlatformServiceImpl.inactivateCharge()was also a stub returningnullwith the comment// functionality not yet supported.All the surrounding infrastructure was already in place — the DB columns
is_activeandinactivated_on_dateexist inm_client_charge, the permissionINACTIVATE_CLIENTCHARGEis seeded in0002_initial_data.xml, the builder methodinactivateClientCharge()exists inCommandWrapperBuilder, and the API routing atClientChargesApiResourceline 212 correctly accepts the command. The handler and service implementation were simply never completed.Savings charges have had a fully working equivalent (
InactivateSavingsAccountChargeCommandHandler) since MIFOSX-1408. Client charges were left behind.Changes:
InactivateClientChargeCommandHandler.java— new handler registered underCLIENTCHARGE|INACTIVATE, modelled onWaiveClientChargeCommandHandler.ClientCharge.java— addedinactivate(LocalDate)domain method settingstatus = falseandinactivationDate. The DB columns already existed, the method was simply missing.ClientChargeWritePlatformServiceImpl.java— replaced thereturn nullstub with a full implementation. Guards for already-inactive, already-waived, and already-paid states, followed byclientCharge.inactivate()andsaveAndFlush.ClientHelper.java— addedinactivateChargesForClients()andgetClientChargeField()test helpers.ClientChargesTest.java— addedclientChargeInactivateTest()covering the success path, theisActivefield assertion post-inactivation, and the idempotency failure (inactivating an already-inactive charge must return 400).Checklist