Skip to content

Commit cca884d

Browse files
committed
FINERACT-2259: Manage external IDs-Savings
1 parent f3bb66f commit cca884d

File tree

22 files changed

+607
-271
lines changed

22 files changed

+607
-271
lines changed

config/docker/env/aws.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
# under the License.
1818
#
1919

20-
# TODO: remove AWS_ENDPOINT_URL and use FINERACT_AWS_ENDPOINT
2120
AWS_EC2_METADATA_DISABLED=true
22-
AWS_ENDPOINT_URL=http://localstack:4666
23-
#FINERACT_AWS_ENDPOINT=http://localstack:4666
21+
# AWS_ENDPOINT_URL is deprecated, use FINERACT_AWS_ENDPOINT instead
22+
# AWS_ENDPOINT_URL=http://localstack:4666
23+
FINERACT_AWS_ENDPOINT=http://localstack:4666
2424
FINERACT_AWS_REGION_STATIC=us-east-1
2525
FINERACT_AWS_CREDENTIALS_INSTANCE_PROFILE=false
2626
#FINERACT_AWS_CREDENTIALS_ACCESS_KEY=localstack

fineract-core/src/main/java/org/apache/fineract/infrastructure/core/domain/ExternalId.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ public ExternalId(String value) {
4949
this.value = value;
5050
}
5151

52+
/**
53+
* Creates a new ExternalId instance
54+
*
55+
* @param value
56+
* The external ID value as string
57+
* @return A new ExternalId instance
58+
*/
59+
public static ExternalId of(String value) {
60+
return new ExternalId(value);
61+
}
62+
5263
/**
5364
* @return Create a new ExternalId object where value is a newly generated UUID
5465
*/

fineract-investor/src/main/java/org/apache/fineract/investor/domain/ExternalIdConverter.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

fineract-provider/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ compileJava.doLast {
4242
def target = source
4343
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
4444
args '-persistenceinfo', source, source, target
45-
classpath sourceSets.main.runtimeClasspath
45+
classpath = sourceSets.main.runtimeClasspath + project(':fineract-core').sourceSets.main.output
4646
}
4747
delete {
4848
delete "${source}/META-INF/persistence.xml"
@@ -379,7 +379,7 @@ task devRun(type: org.springframework.boot.gradle.tasks.run.BootRun) {
379379
// Configure the build to skip quality checks
380380
gradle.taskGraph.whenReady { graph ->
381381
if (graph.hasTask(devRun)) {
382-
tasks.matching { task ->
382+
tasks.matching { task ->
383383
task.name in ['checkstyle', 'checkstyleMain', 'checkstyleTest',
384384
'spotlessCheck', 'spotlessApply',
385385
'spotbugsMain', 'spotbugsTest',
@@ -400,8 +400,10 @@ task devRun(type: org.springframework.boot.gradle.tasks.run.BootRun) {
400400
classpath = bootRun.classpath
401401
mainClass = bootRun.mainClass
402402
jvmArgs = bootRun.jvmArgs
403-
403+
404404
doFirst {
405405
println "Running in development mode - quality checks are disabled"
406406
}
407407
}
408+
409+
compileJava.dependsOn(':fineract-core:compileJava')

fineract-provider/src/main/java/org/apache/fineract/interoperation/service/InteropServiceImpl.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService;
4848
import org.apache.fineract.infrastructure.core.api.JsonCommand;
4949
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
50+
import org.apache.fineract.infrastructure.core.domain.ExternalId;
5051
import org.apache.fineract.infrastructure.core.exception.ErrorHandler;
5152
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
5253
import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer;
@@ -392,7 +393,7 @@ public InteropTransferResponseData prepareTransfer(@NotNull JsonCommand command)
392393
PaymentDetail paymentDetail = instance(findPaymentType(), savingsAccount.getExternalId().getValue(), null, getRoutingCode(),
393394
transferCode, null);
394395
SavingsAccountTransaction holdTransaction = SavingsAccountTransaction.holdAmount(savingsAccount, savingsAccount.office(),
395-
paymentDetail, transactionDate, Money.of(savingsAccount.getCurrency(), total), false);
396+
paymentDetail, transactionDate, Money.of(savingsAccount.getCurrency(), total), false, ExternalId.empty());
396397
MonetaryCurrency accountCurrency = savingsAccount.getCurrency().copy();
397398
holdTransaction.setRunningBalance(
398399
Money.of(accountCurrency, savingsAccount.getWithdrawableBalance().subtract(holdTransaction.getAmount())));
@@ -456,11 +457,11 @@ public InteropTransferResponseData commitTransfer(@NotNull JsonCommand command)
456457
SavingsTransactionBooleanValues transactionValues = new SavingsTransactionBooleanValues(false, true, true, false, false);
457458
transaction = savingsAccountService.handleWithdrawal(savingsAccount, fmt, transactionDate, request.getAmount().getAmount(),
458459
instance(findPaymentType(), savingsAccount.getExternalId().getValue(), null, getRoutingCode(), transferCode, null),
459-
transactionValues, backdatedTxnsAllowedTill);
460+
transactionValues, backdatedTxnsAllowedTill, ExternalId.empty());
460461
} else {
461462
transaction = savingsAccountService.handleDeposit(savingsAccount, fmt, transactionDate, request.getAmount().getAmount(),
462463
instance(findPaymentType(), savingsAccount.getExternalId().getValue(), null, getRoutingCode(), transferCode, null),
463-
false, true, backdatedTxnsAllowedTill);
464+
false, true, backdatedTxnsAllowedTill, ExternalId.empty());
464465
}
465466

466467
String note = request.getNote();

fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/AccountTransfersWritePlatformServiceImpl.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,15 @@ public CommandProcessingResult create(final JsonCommand command) {
126126
final SavingsTransactionBooleanValues transactionBooleanValues = new SavingsTransactionBooleanValues(isAccountTransfer,
127127
isRegularTransaction, fromSavingsAccount.isWithdrawalFeeApplicableForTransfer(), isInterestTransfer, isWithdrawBalance);
128128
final SavingsAccountTransaction withdrawal = this.savingsAccountDomainService.handleWithdrawal(fromSavingsAccount, fmt,
129-
transactionDate, transactionAmount, paymentDetail, transactionBooleanValues, backdatedTxnsAllowedTill);
129+
transactionDate, transactionAmount, paymentDetail, transactionBooleanValues, backdatedTxnsAllowedTill,
130+
ExternalId.empty());
130131

131132
final Long toSavingsId = command.longValueOfParameterNamed(toAccountIdParamName);
132133
final SavingsAccount toSavingsAccount = this.savingsAccountAssembler.assembleFrom(toSavingsId, backdatedTxnsAllowedTill);
133134

134135
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount, fmt, transactionDate,
135-
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill);
136+
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill,
137+
ExternalId.empty());
136138

137139
if (!fromSavingsAccount.getCurrency().getCode().equals(toSavingsAccount.getCurrency().getCode())) {
138140
throw new DifferentCurrenciesException(fromSavingsAccount.getCurrency().getCode(),
@@ -153,7 +155,8 @@ public CommandProcessingResult create(final JsonCommand command) {
153155
final SavingsTransactionBooleanValues transactionBooleanValues = new SavingsTransactionBooleanValues(isAccountTransfer,
154156
isRegularTransaction, fromSavingsAccount.isWithdrawalFeeApplicableForTransfer(), isInterestTransfer, isWithdrawBalance);
155157
final SavingsAccountTransaction withdrawal = this.savingsAccountDomainService.handleWithdrawal(fromSavingsAccount, fmt,
156-
transactionDate, transactionAmount, paymentDetail, transactionBooleanValues, backdatedTxnsAllowedTill);
158+
transactionDate, transactionAmount, paymentDetail, transactionBooleanValues, backdatedTxnsAllowedTill,
159+
ExternalId.empty());
157160

158161
final Long toLoanAccountId = command.longValueOfParameterNamed(toAccountIdParamName);
159162
Loan toLoanAccount = this.loanAccountAssembler.assembleFrom(toLoanAccountId);
@@ -187,7 +190,8 @@ public CommandProcessingResult create(final JsonCommand command) {
187190
final SavingsAccount toSavingsAccount = this.savingsAccountAssembler.assembleFrom(toSavingsAccountId, backdatedTxnsAllowedTill);
188191

189192
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount, fmt, transactionDate,
190-
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill);
193+
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill,
194+
ExternalId.empty());
191195

192196
final AccountTransferDetails accountTransferDetails = this.accountTransferAssembler.assembleLoanToSavingsTransfer(command,
193197
fromLoanAccount, toSavingsAccount, deposit, loanRefundTransaction);
@@ -315,7 +319,7 @@ public Long transferFunds(final AccountTransferDTO accountTransferDTO) {
315319

316320
final SavingsAccountTransaction withdrawal = this.savingsAccountDomainService.handleWithdrawal(fromSavingsAccount,
317321
accountTransferDTO.getFmt(), accountTransferDTO.getTransactionDate(), accountTransferDTO.getTransactionAmount(),
318-
accountTransferDTO.getPaymentDetail(), transactionBooleanValues, backdatedTxnsAllowedTill);
322+
accountTransferDTO.getPaymentDetail(), transactionBooleanValues, backdatedTxnsAllowedTill, ExternalId.empty());
319323

320324
LoanTransaction loanTransaction;
321325

@@ -394,11 +398,12 @@ public Long transferFunds(final AccountTransferDTO accountTransferDTO) {
394398

395399
final SavingsAccountTransaction withdrawal = this.savingsAccountDomainService.handleWithdrawal(fromSavingsAccount,
396400
accountTransferDTO.getFmt(), transactionDate, accountTransferDTO.getTransactionAmount(),
397-
accountTransferDTO.getPaymentDetail(), transactionBooleanValues, backdatedTxnsAllowedTill);
401+
accountTransferDTO.getPaymentDetail(), transactionBooleanValues, backdatedTxnsAllowedTill, ExternalId.empty());
398402

399403
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount,
400404
accountTransferDTO.getFmt(), transactionDate, accountTransferDTO.getTransactionAmount(),
401-
accountTransferDTO.getPaymentDetail(), isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill);
405+
accountTransferDTO.getPaymentDetail(), isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill,
406+
ExternalId.empty());
402407

403408
accountTransferDetails = this.accountTransferAssembler.assembleSavingsToSavingsTransfer(accountTransferDTO, fromSavingsAccount,
404409
toSavingsAccount, withdrawal, deposit);
@@ -442,7 +447,8 @@ public Long transferFunds(final AccountTransferDTO accountTransferDTO) {
442447

443448
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount,
444449
accountTransferDTO.getFmt(), accountTransferDTO.getTransactionDate(), accountTransferDTO.getTransactionAmount(),
445-
accountTransferDTO.getPaymentDetail(), isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill);
450+
accountTransferDTO.getPaymentDetail(), isAccountTransfer, isRegularTransaction, backdatedTxnsAllowedTill,
451+
ExternalId.empty());
446452
accountTransferDetails = this.accountTransferAssembler.assembleLoanToSavingsTransfer(accountTransferDTO, fromLoanAccount,
447453
toSavingsAccount, deposit, loanTransaction);
448454
this.accountTransferDetailRepository.saveAndFlush(accountTransferDetails);
@@ -552,7 +558,7 @@ public CommandProcessingResult refundByTransfer(JsonCommand command) {
552558
final SavingsAccount toSavingsAccount = this.savingsAccountAssembler.assembleFrom(toSavingsAccountId, backdatedTxnsAllowedTill);
553559

554560
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(toSavingsAccount, fmt, transactionDate,
555-
transactionAmount, paymentDetail, true, true, backdatedTxnsAllowedTill);
561+
transactionAmount, paymentDetail, true, true, backdatedTxnsAllowedTill, ExternalId.empty());
556562

557563
final AccountTransferDetails accountTransferDetails = this.accountTransferAssembler.assembleLoanToSavingsTransfer(command,
558564
fromLoanAccount, toSavingsAccount, deposit, loanRefundTransaction);

fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/DepositAccountDomainService.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,40 @@
2323
import java.time.format.DateTimeFormatter;
2424
import java.util.Map;
2525
import org.apache.fineract.infrastructure.core.api.JsonCommand;
26+
import org.apache.fineract.infrastructure.core.domain.ExternalId;
2627
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
2728
import org.apache.fineract.useradministration.domain.AppUser;
2829
import org.springframework.transaction.annotation.Transactional;
2930

3031
public interface DepositAccountDomainService {
3132

3233
SavingsAccountTransaction handleWithdrawal(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
33-
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean applyWithdrawFee, boolean isRegularTransaction);
34+
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean applyWithdrawFee, boolean isRegularTransaction,
35+
ExternalId externalId);
3436

3537
SavingsAccountTransaction handleFDDeposit(FixedDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
36-
BigDecimal transactionAmount, PaymentDetail paymentDetail);
38+
BigDecimal transactionAmount, PaymentDetail paymentDetail, ExternalId externalId);
3739

3840
SavingsAccountTransaction handleRDDeposit(RecurringDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
39-
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction);
41+
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction, ExternalId externalId);
4042

4143
SavingsAccountTransaction handleSavingDeposit(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
42-
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction);
44+
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction, ExternalId externalId);
4345

4446
Long handleFDAccountClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
45-
Map<String, Object> changes);
47+
Map<String, Object> changes, ExternalId externalId);
4648

4749
@Transactional
4850
Long handleFDAccountMaturityClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, DateTimeFormatter fmt,
49-
LocalDate closedDate, Integer onAccountClosureId, Long toSavingsId, String transferDescription, Map<String, Object> changes);
51+
LocalDate closedDate, Integer onAccountClosureId, Long toSavingsId, String transferDescription, Map<String, Object> changes,
52+
ExternalId externalId);
5053

5154
Long handleRDAccountClosure(RecurringDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
52-
Map<String, Object> changes);
55+
Map<String, Object> changes, ExternalId externalId);
5356

5457
Long handleFDAccountPreMatureClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
55-
Map<String, Object> changes);
58+
Map<String, Object> changes, ExternalId externalId);
5659

5760
Long handleRDAccountPreMatureClosure(RecurringDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
58-
Map<String, Object> changes);
61+
Map<String, Object> changes, ExternalId externalId);
5962
}

0 commit comments

Comments
 (0)