Cocoa-Puffs commented on code in PR #6151:
URL: https://github.com/apache/fineract/pull/6151#discussion_r3623126500


##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/service/WorkingCapitalLoanAllocationApplier.java:
##########
@@ -48,28 +53,42 @@ public class WorkingCapitalLoanAllocationApplier {
 
     private final WorkingCapitalLoanChargePaymentHandler chargePaymentHandler;
 
-    public WorkingCapitalLoanTransactionAllocation apply(final 
WorkingCapitalLoanTransaction transaction,
-            final WorkingCapitalLoanTransactionAllocation existingAllocation, 
final WorkingCapitalLoanAllocationPlan plan,
-            final List<WorkingCapitalLoanCharge> charges) {
+    /**
+     * The materialized outcome of applying a plan: the transaction allocation 
and the per-charge paid-by rows produced
+     * while settling the plan's charge allocations. Both are for the 
orchestrator to persist.
+     */
+    public record Result(WorkingCapitalLoanTransactionAllocation allocation, 
List<WorkingCapitalLoanChargePaidBy> chargesPaidBy) {
+    }
+
+    public Result apply(final WorkingCapitalLoanTransaction transaction, final 
WorkingCapitalLoanTransactionAllocation existingAllocation,
+            final WorkingCapitalLoanAllocationPlan plan, final 
List<WorkingCapitalLoanCharge> charges) {
         final Map<Long, WorkingCapitalLoanCharge> chargesById = 
charges.stream()
                 .collect(Collectors.toMap(WorkingCapitalLoanCharge::getId, 
Function.identity()));
         return apply(transaction, existingAllocation, plan, chargesById);
     }
 
-    public WorkingCapitalLoanTransactionAllocation apply(final 
WorkingCapitalLoanTransaction transaction,
-            final WorkingCapitalLoanTransactionAllocation existingAllocation, 
final WorkingCapitalLoanAllocationPlan plan,
-            final Map<Long, WorkingCapitalLoanCharge> chargesById) {
+    public Result apply(final WorkingCapitalLoanTransaction transaction, final 
WorkingCapitalLoanTransactionAllocation existingAllocation,

Review Comment:
   Updated the code, the original issue that made the "existingAllocation" 
parameter mandatory, was that the applier only linked the transaction to the 
allocation, it didn't set the inverse. So a newly created transaction that just 
had it's allocation applied returned a stale "null" when txn.getAllocation() 
was called.
   
   I updated the 
`org.apache.fineract.portfolio.workingcapitalloan.domain.WorkingCapitalLoanTransactionAllocation#forPortions`
 method to make the link both ways. This also simplified the logic a bit in the 
reprocessor.



-- 
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