Skip to content

Commit 59cf29a

Browse files
authored
Merge pull request #5742
FINERACT-2455: WC - Transaction Type - Disbursement and Undo Disbursement
2 parents e0d817a + a349027 commit 59cf29a

File tree

32 files changed

+1106
-29
lines changed

32 files changed

+1106
-29
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"name": "WorkingCapitalLoanTransactionDataV1",
3+
"namespace": "org.apache.fineract.avro.workingcapitalloan.v1",
4+
"type": "record",
5+
"fields": [
6+
{
7+
"default": null,
8+
"name": "id",
9+
"type": [
10+
"null",
11+
"long"
12+
]
13+
},
14+
{
15+
"default": null,
16+
"name": "wcLoanId",
17+
"type": [
18+
"null",
19+
"long"
20+
]
21+
},
22+
{
23+
"default": null,
24+
"name": "type",
25+
"type": [
26+
"null",
27+
"org.apache.fineract.avro.loan.v1.LoanTransactionEnumDataV1"
28+
]
29+
},
30+
{
31+
"default": null,
32+
"name": "transactionDate",
33+
"type": [
34+
"null",
35+
"string"
36+
]
37+
},
38+
{
39+
"default": null,
40+
"name": "submittedOnDate",
41+
"type": [
42+
"null",
43+
"string"
44+
]
45+
},
46+
{
47+
"default": null,
48+
"name": "transactionAmount",
49+
"type": [
50+
"null",
51+
"bigdecimal"
52+
]
53+
},
54+
{
55+
"default": null,
56+
"name": "paymentDetailData",
57+
"type": [
58+
"null",
59+
"org.apache.fineract.avro.payment.v1.PaymentDetailDataV1"
60+
]
61+
},
62+
{
63+
"default": null,
64+
"name": "classification",
65+
"type": [
66+
"null",
67+
"org.apache.fineract.avro.generic.v1.CodeValueDataV1"
68+
]
69+
},
70+
{
71+
"default": null,
72+
"name": "externalId",
73+
"type": [
74+
"null",
75+
"string"
76+
]
77+
},
78+
{
79+
"default": null,
80+
"name": "reversed",
81+
"type": [
82+
"null",
83+
"boolean"
84+
]
85+
},
86+
{
87+
"default": null,
88+
"name": "reversalExternalId",
89+
"type": [
90+
"null",
91+
"string"
92+
]
93+
},
94+
{
95+
"default": null,
96+
"name": "reversedOnDate",
97+
"type": [
98+
"null",
99+
"string"
100+
]
101+
},
102+
{
103+
"default": null,
104+
"name": "principalPortion",
105+
"type": [
106+
"null",
107+
"bigdecimal"
108+
]
109+
},
110+
{
111+
"default": null,
112+
"name": "feeChargesPortion",
113+
"type": [
114+
"null",
115+
"bigdecimal"
116+
]
117+
},
118+
{
119+
"default": null,
120+
"name": "penaltyChargesPortion",
121+
"type": [
122+
"null",
123+
"bigdecimal"
124+
]
125+
}
126+
]
127+
}

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/EventCheckHelper.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,15 @@
3737
import org.apache.fineract.avro.loan.v1.LoanOwnershipTransferDataV1;
3838
import org.apache.fineract.avro.loan.v1.LoanTransactionAdjustmentDataV1;
3939
import org.apache.fineract.avro.loan.v1.LoanTransactionDataV1;
40+
import org.apache.fineract.avro.workingcapitalloan.v1.WorkingCapitalLoanTransactionDataV1;
4041
import org.apache.fineract.client.feign.FineractFeignClient;
4142
import org.apache.fineract.client.models.ExternalTransferData;
4243
import org.apache.fineract.client.models.GetClientsClientIdResponse;
4344
import org.apache.fineract.client.models.GetLoansLoanIdDelinquencyPausePeriod;
4445
import org.apache.fineract.client.models.GetLoansLoanIdResponse;
4546
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
47+
import org.apache.fineract.client.models.GetWorkingCapitalLoanTransactionIdResponse;
48+
import org.apache.fineract.client.models.GetWorkingCapitalLoansLoanIdResponse;
4649
import org.apache.fineract.client.models.GlobalConfigurationPropertyData;
4750
import org.apache.fineract.client.models.PageExternalTransferData;
4851
import org.apache.fineract.client.models.PostClientsResponse;
@@ -80,6 +83,8 @@
8083
import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransactionMerchantIssuedRefundPostEvent;
8184
import org.apache.fineract.test.messaging.event.loan.transaction.LoanTransactionPayoutRefundPostEvent;
8285
import org.apache.fineract.test.messaging.event.loan.transaction.LoanUndoContractTerminationBusinessEvent;
86+
import org.apache.fineract.test.messaging.event.workingcapitalloan.transaction.WorkingCapitalLoanDisbursalTransactionBusinessEvent;
87+
import org.apache.fineract.test.messaging.event.workingcapitalloan.transaction.WorkingCapitalLoanUndoDisbursalTransactionBusinessEvent;
8388
import org.springframework.beans.factory.annotation.Autowired;
8489
import org.springframework.stereotype.Component;
8590

@@ -289,6 +294,55 @@ public void loanDisbursalTransactionEventCheck(PostLoansLoanIdResponse loanDisbu
289294
.extractingBigDecimal(LoanTransactionDataV1::getAmount).isEqualTo(disbursementTransaction.getAmount());//
290295
}
291296

297+
public void workingCapitalLoanDisbursalTransactionEventCheck(final Long loanId) {
298+
workingCapitalLoanDisbursalTransactionEventCheck(loanId, null);
299+
}
300+
301+
public void workingCapitalLoanDisbursalTransactionEventCheck(final Long loanId, final BigDecimal expectedAmount) {
302+
waitForTransactionCommit();
303+
final GetWorkingCapitalLoansLoanIdResponse body = ok(
304+
() -> fineractClient.workingCapitalLoans().retrieveWorkingCapitalLoanById(loanId));
305+
if (body.getTransactions() == null || body.getTransactions().isEmpty()) {
306+
throw new IllegalStateException("No Working Capital Loan transactions found");
307+
}
308+
309+
final GetWorkingCapitalLoanTransactionIdResponse disbursementTransaction = body.getTransactions().stream()
310+
.filter(t -> t.getType() != null && "loanTransactionType.disbursement".equals(t.getType().getCode())
311+
&& !Boolean.TRUE.equals(t.getReversed()))
312+
.reduce((first, second) -> second).orElseThrow(() -> new IllegalStateException("Disbursement transaction not found"));
313+
314+
eventAssertion.assertEvent(WorkingCapitalLoanDisbursalTransactionBusinessEvent.class, disbursementTransaction.getId())//
315+
.extractingData(WorkingCapitalLoanTransactionDataV1::getWcLoanId).isEqualTo(loanId)//
316+
.extractingBigDecimal(WorkingCapitalLoanTransactionDataV1::getTransactionAmount)
317+
.isEqualTo(expectedAmount == null ? disbursementTransaction.getTransactionAmount() : expectedAmount)//
318+
.extractingData(WorkingCapitalLoanTransactionDataV1::getReversed).isEqualTo(Boolean.FALSE);
319+
}
320+
321+
public void workingCapitalLoanUndoDisbursalTransactionEventCheck(final Long loanId) {
322+
workingCapitalLoanUndoDisbursalTransactionEventCheck(loanId, null);
323+
}
324+
325+
public void workingCapitalLoanUndoDisbursalTransactionEventCheck(final Long loanId, final BigDecimal expectedAmount) {
326+
waitForTransactionCommit();
327+
final GetWorkingCapitalLoansLoanIdResponse body = ok(
328+
() -> fineractClient.workingCapitalLoans().retrieveWorkingCapitalLoanById(loanId));
329+
if (body.getTransactions() == null || body.getTransactions().isEmpty()) {
330+
throw new IllegalStateException("No Working Capital Loan transactions found");
331+
}
332+
333+
final GetWorkingCapitalLoanTransactionIdResponse reversedDisbursementTransaction = body.getTransactions().stream()
334+
.filter(t -> t.getType() != null && "loanTransactionType.disbursement".equals(t.getType().getCode())
335+
&& Boolean.TRUE.equals(t.getReversed()))
336+
.reduce((first, second) -> second)
337+
.orElseThrow(() -> new IllegalStateException("Reversed disbursement transaction not found"));
338+
339+
eventAssertion.assertEvent(WorkingCapitalLoanUndoDisbursalTransactionBusinessEvent.class, reversedDisbursementTransaction.getId())//
340+
.extractingData(WorkingCapitalLoanTransactionDataV1::getWcLoanId).isEqualTo(loanId)//
341+
.extractingBigDecimal(WorkingCapitalLoanTransactionDataV1::getTransactionAmount)
342+
.isEqualTo(expectedAmount == null ? reversedDisbursementTransaction.getTransactionAmount() : expectedAmount)//
343+
.extractingData(WorkingCapitalLoanTransactionDataV1::getReversed).isEqualTo(Boolean.TRUE);
344+
}
345+
292346
public EventAssertion.EventAssertionBuilder<LoanTransactionDataV1> transactionEventCheck(
293347
PostLoansLoanIdTransactionsResponse transactionResponse, TransactionType transactionType, String externalOwnerId) {
294348
Long loanId = transactionResponse.getLoanId();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.test.messaging.event.workingcapitalloan.transaction;
20+
21+
import java.util.function.Function;
22+
import org.apache.fineract.avro.workingcapitalloan.v1.WorkingCapitalLoanTransactionDataV1;
23+
import org.apache.fineract.test.messaging.event.Event;
24+
25+
public abstract class AbstractWorkingCapitalLoanTransactionEvent implements Event<WorkingCapitalLoanTransactionDataV1> {
26+
27+
@Override
28+
public Class<WorkingCapitalLoanTransactionDataV1> getDataClass() {
29+
return WorkingCapitalLoanTransactionDataV1.class;
30+
}
31+
32+
@Override
33+
public Function<WorkingCapitalLoanTransactionDataV1, Long> getIdExtractor() {
34+
return WorkingCapitalLoanTransactionDataV1::getId;
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.test.messaging.event.workingcapitalloan.transaction;
20+
21+
public class WorkingCapitalLoanDisbursalTransactionBusinessEvent extends AbstractWorkingCapitalLoanTransactionEvent {
22+
23+
@Override
24+
public String getEventName() {
25+
return "WorkingCapitalLoanDisbursalTransactionBusinessEvent";
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.test.messaging.event.workingcapitalloan.transaction;
20+
21+
public class WorkingCapitalLoanUndoDisbursalTransactionBusinessEvent extends AbstractWorkingCapitalLoanTransactionEvent {
22+
23+
@Override
24+
public String getEventName() {
25+
return "WorkingCapitalLoanUndoDisbursalTransactionBusinessEvent";
26+
}
27+
}

0 commit comments

Comments
 (0)