FINERACT-2455: WC - Transaction - Prepay Loan - #6385
Conversation
160ef6a to
2e88f6c
Compare
galovics
left a comment
There was a problem hiding this comment.
The transactionDate parameter is accepted, validated, parsed, and echoed back in the response - but never actually used to compute anything. The template amount is just balance.getTotalOutstanding() as it stands right now, so for a WC loan where penalties and discount fee accrue daily and backdated transactions are allowed, a payoff quote for any date other than today is going to be wrong with no way for the caller to tell. Either the payoff needs to be computed as of transactionDate (which is what I'd expect from something called "prepay" - including whatever the intended treatment of unearned discount fee is on an early settlement), or the parameter should be dropped until it does something.
Two more concrete issues:
repository.getReferenceById(loanId)returns a lazy proxy - an unknownloanIdwon't fail here, it'll throwEntityNotFoundExceptionon first property access (getCurrency()), which has no exception mapper and surfaces as a 500 instead of a 404.retrieveOnein the same class does this correctly viafindByIdWithFullDetails(...).orElseThrow(...)- worth reusing that pattern here, especially sincegetCurrency()and the balance can both be null in general.- The new Swagger response DTO (
WorkingCapitalLoanTransactionTemplateResponse) doesn't match what the endpoint actually returns - it declaresid(which the data class doesn't have) and omitscurrency(which it does). The generated client will always getnullfor a field that never exists and won't expose the one that does.
Smaller things: the permission check happens after loan resolution rather than before (every other endpoint in this resource does it the other way), and this also introduces a second, parallel "template" mechanism on the same resource ({loanId}/transactions/template?command=X vs. the existing {loanId}/template?templateType=X) with different query param names and different backing services for the same concept - worth confirming that's intentional rather than folding prepayLoan into the existing one.
Recommendation: CHANGES_REQUESTED
6d031cf to
7764b19
Compare
|
@galovics I have addressed the concerns!
Working Capital loans employ what is essentially a cash-like accounting, meaning that fee accrued is only dependent on how much money was repaid, not the time elapsed. Every outstanding bucket is For the same reason we only echo transactionDate. I have not added a validation for being future-dated, because the repayment validator rejects future dated transactions and as far as I can see validations are unprecedented when it comes to transaction templates, no other template does similar validations, leaving it to the various transaction processing validators to reject the transactions if they are sent with the wrong value.
The method now throws
I have modified the swagger response DTO to match what the endpoint actually returns.
Moved the permission check to before the loan resolution. As for the template mechanism, I believe it mirrors core behaviour. Term loans already have two template types split between lifecycle vs transaction operations.
The problem is more the opposite. WC currently crams in 8 transaction templates into the lifecycle endpoint. That is why the split looks arbitrary today. I have migrated the 8 transaction templates to the proper transaction template endpoint to mirror core behaviour.
I can revert this and include |
7764b19 to
b60bd94
Compare
|
api backwards compatibility is failing due to the migration of the transactions from the existing template endpoint |
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.