rymghosn opened a new pull request, #6579:
URL: https://github.com/apache/fineract/pull/6579

   ## Description
   
   JIRA: https://issues.apache.org/jira/browse/FINERACT-2891
   
   `SavingsAccountCharge.pay()` closes a recurring fee's cycle (weekly, 
monthly, annual), advancing the due date and resetting the outstanding, only 
once the outstanding reaches zero. A partial payment therefore leaves the cycle 
open. `undoPayment()` always did the reverse: it called 
`resetPropertiesForRecurringFees()` and `updateToPreviousDueDate()` 
unconditionally. That is only correct when the undone payment was the one that 
closed the cycle. Undoing one of two partial payments reset the outstanding to 
the full fee, so paid plus outstanding exceeded the fee amount, and moved the 
due date back one interval.
   
   `undoPayment()` now first checks whether the undone amount was paid against 
the current open cycle: the cycle is partly paid (`amount - amountOutstanding > 
0`) and has received at least this amount. If so, it returns the amount to that 
cycle (`amountPaid -= x`, `amountOutstanding += x`) and leaves the due date 
alone. `amountPaid`/`amountWaived` accumulate across cycles, so the open 
cycle's paid part is derived from its outstanding; `waive()` always closes a 
whole cycle, so an open cycle carries no waiver. Undoing a cycle-closing 
payment keeps the existing behaviour.
   
   ### Tests
   
   - New `SavingsAccountChargeUndoPaymentTest` (`fineract-savings`), 4 cases: 
undoing one of two partial payments, undoing the only partial payment, a 
partial payment after an earlier waived cycle, and undoing a full-cycle payment 
(still rolls the due date back). 4/4 pass with the change; on develop the first 
three fail and the cycle-closing case passes. `spotlessJavaCheck` passes.
   - Live red/green against a local stock build (PostgreSQL, develop 
`4684c66380`): weekly fee 45.00 due on the activation date, deposit 10.00, 
`POST /v1/savingsaccounts/{id}/charges/{chargeId}?command=paycharge` with 
`amount: 2` twice (paid 4.00, outstanding 41.00), then `POST 
/v1/savingsaccounts/{id}/transactions/{txId}?command=undo` on the second 
PAY_CHARGE:
     - **Red** (develop): paid 2.00, outstanding **45.00**, due date moved back 
one week.
     - **Green** (this change): paid 2.00, outstanding **43.00**, due date 
unchanged. Paying the remaining 43.00 then closes the cycle and advances the 
due date, and undoing that cycle-closing payment still rolls it back, as before.
   
   ### API
   
   No API change.
   
   ## Checklist
   
   - [x] Write the commit message as per [our 
guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [x] Acknowledge that we will not review PRs that are not passing the build 
_("green")_ - it is your responsibility to get a proposed PR to pass the build, 
not primarily the project's maintainers.
   - [x] Create/update [unit or integration 
tests](https://fineract.apache.org/docs/current/#_testing) for verifying the 
changes made.
   - [x] Follow our [coding 
conventions](https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions).
   - [ ] Add required Swagger annotation and update API documentation at 
fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with 
details of any API changes (no API change)
   - [x] [This PR must not be a "code 
dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit).
 Large changes can be made in a branch, with assistance. Ask for help on the 
[developer mailing list](https://fineract.apache.org/#contribute).
   - [x] If merging this PR resolves a JIRA issue, I will mark that issue as 
resolved and set "Fix Version/s" appropriately.
   - [x] I followed the [AI 
Policy](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#ai-policy).
   
   Your assigned reviewer(s) will follow our [guidelines for code 
reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to