FINERACT-2455: WC - Support discount fee and discount fee adjustment by transaction external id - #6480
Conversation
c3dcb4f to
8bd2b96
Compare
e6894db to
200b303
Compare
200b303 to
1c997b3
Compare
|
@oleksii-novikov-onix To cover all possibilities:
|
galovics
left a comment
There was a problem hiding this comment.
Routing, permissions, transaction-type checks and the COB filter all hold up, and the e2e coverage is good. No new JAX-RS routes are added - the four transactions/{transactionId} and transactions/external-id/{transactionExternalId} POST endpoints already existed for undo and just gain two more command values, and the builders use the same DISCOUNTFEE/DISCOUNTFEEADJUSTMENT + WORKINGCAPITALLOAN pair as the loan-level ones, so the same permissions apply. The loan and transaction external ids aren't mixed up (the transaction is loaded with findByIdAndWcLoan_Id), a wrong-type transaction is rejected in both directions, the duplicate discount fee guard still applies, and the COB filter is unaffected: isExternal now uses the anchored EXTERNAL_ID_LOAN_PATH_PATTERN, so /{loanId}/transactions/external-id/{x} resolves the numeric loan id (the #6351 issue), covered by WorkingCapitalLoanCOBApiFilterTest.
Things I'd change:
- A missing/foreign transaction id in the path returns 400, while the external-id form and the GET return 404.
resolveTransactionIdreturns a suppliedtransactionIdwithout checking it belongs to the loan, so an unknown one reaches the service and fails with a 400...transaction.not.found; the docs and e2e tests lock the 400 in. 404 is the usual convention for a path resource - reusefindByIdAndWcLoan_IdinresolveTransactionIdand throw the not-found exception. - The handlers pick the flow by whether
loanIdhappens to be set (WorkingCapitalLoanDiscountFeeCommandHandler/...AdjustmentCommandHandler:Optional.ofNullable(command.getLoanId())). It works only because the loan-level builders don't setloanId; other WC builders do, so if someone adds it "for consistency" every body-based call silently switches to the path form and the loan id is treated as a disbursement transaction id. Use an explicit signal (a dedicated action, or the transaction id on the wrapper) and add a unit test per branch. - Pending maker-checker rows record a transaction id as the loan's resource id (
entityName = WORKINGCAPITALLOAN,entityId = transactionIdin the new builders);updateForAuditcorrects it afterwards, but pending rows are misleading. - Docs say a non-positive
relatedResourceIdgets...not.a.number, butlongGreaterThanZeroreturns...not.greater.than.zerofor0/-1; and the new "norelatedResourceIdin the body of a path form" check has no test. - The non-numeric
relatedResourceIdvalidation now also changes the error on the existing body-based endpoint (probably an improvement, but worth noting), and addingexternalLoanIdto the transaction data/response/Avro isn't needed for this ticket (and is inserted mid-record) - consider its own ticket.
Recommendation: COMMENT
1c997b3 to
4e38fb3
Compare
Done.
|
4e38fb3 to
73a5d0b
Compare
|
…by transaction external id
…scount fee and discount fee adjustment by transaction external id
73a5d0b to
4a41a7e
Compare
4a41a7e to
9ed1749
Compare
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.