FINERACT-1483: Optional value should accessed and throw exception if null
This commit is contained in:
committed by
Arnold Gálovics
parent
68fcddf7a7
commit
645994f870
+6
-6
@@ -777,11 +777,11 @@ public class AccountingProcessorHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LoanTransaction getLoanTransactionById(final long loanTransactionId) {
|
public LoanTransaction getLoanTransactionById(final long loanTransactionId) {
|
||||||
return this.loanTransactionRepository.findById(loanTransactionId).get();
|
return this.loanTransactionRepository.findById(loanTransactionId).orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SavingsAccountTransaction getSavingsTransactionById(final long savingsTransactionId) {
|
public SavingsAccountTransaction getSavingsTransactionById(final long savingsTransactionId) {
|
||||||
return this.savingsAccountTransactionRepository.findById(savingsTransactionId).get();
|
return this.savingsAccountTransactionRepository.findById(savingsTransactionId).orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
private void createCreditJournalEntryOrReversalForLoan(final Office office, final String currencyCode, final int accountMappingTypeId,
|
||||||
@@ -833,7 +833,7 @@ public class AccountingProcessorHelper {
|
|||||||
String modifiedTransactionId = transactionId;
|
String modifiedTransactionId = transactionId;
|
||||||
if (StringUtils.isNumeric(transactionId)) {
|
if (StringUtils.isNumeric(transactionId)) {
|
||||||
long id = Long.parseLong(transactionId);
|
long id = Long.parseLong(transactionId);
|
||||||
savingsAccountTransaction = this.savingsAccountTransactionRepository.findById(id).get();
|
savingsAccountTransaction = this.savingsAccountTransactionRepository.findById(id).orElseThrow();
|
||||||
modifiedTransactionId = SAVINGS_TRANSACTION_IDENTIFIER + transactionId;
|
modifiedTransactionId = SAVINGS_TRANSACTION_IDENTIFIER + transactionId;
|
||||||
}
|
}
|
||||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||||
@@ -854,7 +854,7 @@ public class AccountingProcessorHelper {
|
|||||||
String modifiedTransactionId = transactionId;
|
String modifiedTransactionId = transactionId;
|
||||||
if (StringUtils.isNumeric(transactionId)) {
|
if (StringUtils.isNumeric(transactionId)) {
|
||||||
long id = Long.parseLong(transactionId);
|
long id = Long.parseLong(transactionId);
|
||||||
loanTransaction = this.loanTransactionRepository.findById(id).get();
|
loanTransaction = this.loanTransactionRepository.findById(id).orElseThrow();
|
||||||
modifiedTransactionId = LOAN_TRANSACTION_IDENTIFIER + transactionId;
|
modifiedTransactionId = LOAN_TRANSACTION_IDENTIFIER + transactionId;
|
||||||
}
|
}
|
||||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||||
@@ -904,7 +904,7 @@ public class AccountingProcessorHelper {
|
|||||||
String modifiedTransactionId = transactionId;
|
String modifiedTransactionId = transactionId;
|
||||||
if (StringUtils.isNumeric(transactionId)) {
|
if (StringUtils.isNumeric(transactionId)) {
|
||||||
long id = Long.parseLong(transactionId);
|
long id = Long.parseLong(transactionId);
|
||||||
loanTransaction = this.loanTransactionRepository.findById(id).get();
|
loanTransaction = this.loanTransactionRepository.findById(id).orElseThrow();
|
||||||
modifiedTransactionId = LOAN_TRANSACTION_IDENTIFIER + transactionId;
|
modifiedTransactionId = LOAN_TRANSACTION_IDENTIFIER + transactionId;
|
||||||
}
|
}
|
||||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||||
@@ -924,7 +924,7 @@ public class AccountingProcessorHelper {
|
|||||||
String modifiedTransactionId = transactionId;
|
String modifiedTransactionId = transactionId;
|
||||||
if (StringUtils.isNumeric(transactionId)) {
|
if (StringUtils.isNumeric(transactionId)) {
|
||||||
long id = Long.parseLong(transactionId);
|
long id = Long.parseLong(transactionId);
|
||||||
savingsAccountTransaction = this.savingsAccountTransactionRepository.findById(id).get();
|
savingsAccountTransaction = this.savingsAccountTransactionRepository.findById(id).orElseThrow();
|
||||||
modifiedTransactionId = SAVINGS_TRANSACTION_IDENTIFIER + transactionId;
|
modifiedTransactionId = SAVINGS_TRANSACTION_IDENTIFIER + transactionId;
|
||||||
}
|
}
|
||||||
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
final JournalEntry journalEntry = JournalEntry.createNew(office, paymentDetail, account, currencyCode, modifiedTransactionId,
|
||||||
|
|||||||
+4
-4
@@ -210,11 +210,11 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
|
|||||||
.retrieveLoanProductsProvisioningData(date);
|
.retrieveLoanProductsProvisioningData(date);
|
||||||
Map<Integer, LoanProductProvisioningEntry> provisioningEntries = new HashMap<>();
|
Map<Integer, LoanProductProvisioningEntry> provisioningEntries = new HashMap<>();
|
||||||
for (LoanProductProvisioningEntryData data : entries) {
|
for (LoanProductProvisioningEntryData data : entries) {
|
||||||
LoanProduct loanProduct = this.loanProductRepository.findById(data.getProductId()).get();
|
LoanProduct loanProduct = this.loanProductRepository.findById(data.getProductId()).orElseThrow();
|
||||||
Office office = this.officeRepositoryWrapper.findOneWithNotFoundDetection(data.getOfficeId());
|
Office office = this.officeRepositoryWrapper.findOneWithNotFoundDetection(data.getOfficeId());
|
||||||
ProvisioningCategory provisioningCategory = provisioningCategoryRepository.findById(data.getCategoryId()).get();
|
ProvisioningCategory provisioningCategory = provisioningCategoryRepository.findById(data.getCategoryId()).orElse(null);
|
||||||
GLAccount liabilityAccount = glAccountRepository.findById(data.getLiablityAccount()).get();
|
GLAccount liabilityAccount = glAccountRepository.findById(data.getLiablityAccount()).orElseThrow();
|
||||||
GLAccount expenseAccount = glAccountRepository.findById(data.getExpenseAccount()).get();
|
GLAccount expenseAccount = glAccountRepository.findById(data.getExpenseAccount()).orElseThrow();
|
||||||
MonetaryCurrency currency = loanProduct.getPrincipalAmount().getCurrency();
|
MonetaryCurrency currency = loanProduct.getPrincipalAmount().getCurrency();
|
||||||
Money money = Money.of(currency, data.getBalance());
|
Money money = Money.of(currency, data.getBalance());
|
||||||
Money amountToReserve = money.percentageOf(data.getPercentage(), MoneyHelper.getRoundingMode());
|
Money amountToReserve = money.percentageOf(data.getPercentage(), MoneyHelper.getRoundingMode());
|
||||||
|
|||||||
+5
-4
@@ -117,15 +117,16 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEhcacheEnabled() {
|
public boolean isEhcacheEnabled() {
|
||||||
return this.cacheTypeRepository.findById(1L).get().isEhcacheEnabled();
|
return this.cacheTypeRepository.findById(1L).map(PlatformCache::isEhcacheEnabled).orElseThrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public void updateCache(final CacheType cacheType) {
|
public void updateCache(final CacheType cacheType) {
|
||||||
final PlatformCache cache = this.cacheTypeRepository.findById(1L).get();
|
this.cacheTypeRepository.findById(1L).ifPresent(cache -> {
|
||||||
cache.update(cacheType);
|
cache.update(cacheType);
|
||||||
this.cacheTypeRepository.save(cache);
|
this.cacheTypeRepository.save(cache);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+14
-21
@@ -89,15 +89,9 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl
|
|||||||
try {
|
try {
|
||||||
Long creditBureauID = command.longValueOfParameterNamed("creditBureauID");
|
Long creditBureauID = command.longValueOfParameterNamed("creditBureauID");
|
||||||
|
|
||||||
Optional<String> creditBureauName = getCreditBureau(creditBureauID);
|
String creditBureauName = getCreditBureauName(creditBureauID);
|
||||||
|
|
||||||
if (creditBureauName.isEmpty()) {
|
if (Objects.equals(creditBureauName, CreditBureauConfigurations.THITSAWORKS.toString())) {
|
||||||
baseDataValidator.reset().failWithCode("creditBureau.has.not.been.Integrated");
|
|
||||||
throw new PlatformApiDataValidationException("creditBureau.has.not.been.Integrated", "creditBureau.has.not.been.Integrated",
|
|
||||||
dataValidationErrors);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Objects.equals(creditBureauName.get(), CreditBureauConfigurations.THITSAWORKS.toString())) {
|
|
||||||
|
|
||||||
CreditBureauReportData reportobj = this.thitsaWorksCreditBureauIntegrationWritePlatformService
|
CreditBureauReportData reportobj = this.thitsaWorksCreditBureauIntegrationWritePlatformService
|
||||||
.getCreditReportFromThitsaWorks(command);
|
.getCreditReportFromThitsaWorks(command);
|
||||||
@@ -128,10 +122,10 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl
|
|||||||
@Transactional
|
@Transactional
|
||||||
public String addCreditReport(Long bureauId, File creditReport, FormDataContentDisposition fileDetail) {
|
public String addCreditReport(Long bureauId, File creditReport, FormDataContentDisposition fileDetail) {
|
||||||
|
|
||||||
Optional<String> creditBureauName = getCreditBureau(bureauId);
|
String creditBureauName = getCreditBureauName(bureauId);
|
||||||
String responseMessage = null;
|
String responseMessage = null;
|
||||||
|
|
||||||
if (Objects.equals(creditBureauName.get(), CreditBureauConfigurations.THITSAWORKS.toString())) {
|
if (Objects.equals(creditBureauName, CreditBureauConfigurations.THITSAWORKS.toString())) {
|
||||||
responseMessage = this.thitsaWorksCreditBureauIntegrationWritePlatformService.addCreditReport(bureauId, creditReport,
|
responseMessage = this.thitsaWorksCreditBureauIntegrationWritePlatformService.addCreditReport(bureauId, creditReport,
|
||||||
fileDetail);
|
fileDetail);
|
||||||
} else {
|
} else {
|
||||||
@@ -146,20 +140,19 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<String> getCreditBureau(Long creditBureauID) {
|
private String getCreditBureauName(Long creditBureauID) {
|
||||||
|
|
||||||
if (creditBureauID != null) {
|
if (creditBureauID != null) {
|
||||||
Optional<CreditBureau> creditBureau = this.creditBureauRepository.findById(creditBureauID);
|
Optional<CreditBureau> creditBureau = this.creditBureauRepository.findById(creditBureauID);
|
||||||
|
|
||||||
if (creditBureau.isEmpty()) {
|
if (!creditBureau.isEmpty()) {
|
||||||
return Optional.empty();
|
return creditBureau.get().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.of(creditBureau.get().getName());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Optional.empty();
|
baseDataValidator.reset().failWithCode("creditBureau.has.not.been.Integrated");
|
||||||
|
throw new PlatformApiDataValidationException("creditBureau.has.not.been.Integrated", "creditBureau.has.not.been.Integrated",
|
||||||
|
dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
// saving the fetched creditreport in database
|
// saving the fetched creditreport in database
|
||||||
@@ -170,10 +163,10 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl
|
|||||||
try {
|
try {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
Optional<String> creditBureauName = getCreditBureau(creditBureauId);
|
String creditBureauName = getCreditBureauName(creditBureauId);
|
||||||
CreditReport creditReport = null;
|
CreditReport creditReport = null;
|
||||||
|
|
||||||
if (Objects.equals(creditBureauName.get(), CreditBureauConfigurations.THITSAWORKS.toString())) {
|
if (Objects.equals(creditBureauName, CreditBureauConfigurations.THITSAWORKS.toString())) {
|
||||||
|
|
||||||
// checks whether creditReport for same nationalId was saved before. if yes, then deletes it & replaces
|
// checks whether creditReport for same nationalId was saved before. if yes, then deletes it & replaces
|
||||||
// with new one.
|
// with new one.
|
||||||
@@ -208,10 +201,10 @@ public class CreditReportWritePlatformServiceImpl implements CreditReportWritePl
|
|||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
Optional<String> creditBureauName = getCreditBureau(creditBureauId);
|
String creditBureauName = getCreditBureauName(creditBureauId);
|
||||||
CreditReport creditReport = null;
|
CreditReport creditReport = null;
|
||||||
|
|
||||||
if (Objects.equals(creditBureauName.get(), CreditBureauConfigurations.THITSAWORKS.toString())) {
|
if (Objects.equals(creditBureauName, CreditBureauConfigurations.THITSAWORKS.toString())) {
|
||||||
|
|
||||||
String nationalId = command.stringValueOfParameterNamed("nationalId");
|
String nationalId = command.stringValueOfParameterNamed("nationalId");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ public class ImageResizer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream openStream() throws IOException {
|
public InputStream openStream() throws IOException {
|
||||||
return optResizedIS.get();
|
return optResizedIS.get(); // NOSONAR
|
||||||
}
|
}
|
||||||
}, fileData.name(), fileData.contentType());
|
}, fileData.name(), fileData.contentType());
|
||||||
return resizedImage;
|
return resizedImage;
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ public class NotificationEventListener {
|
|||||||
if (notificationData.getOfficeId() != null) {
|
if (notificationData.getOfficeId() != null) {
|
||||||
List<Long> tempUserIds = new ArrayList<>(userIds);
|
List<Long> tempUserIds = new ArrayList<>(userIds);
|
||||||
for (Long userId : tempUserIds) {
|
for (Long userId : tempUserIds) {
|
||||||
AppUser appUser = appUserRepository.findById(userId).get();
|
AppUser appUser = appUserRepository.findById(userId).orElseThrow();
|
||||||
if (!Objects.equals(appUser.getOffice().getId(), notificationData.getOfficeId())) {
|
if (!Objects.equals(appUser.getOffice().getId(), notificationData.getOfficeId())) {
|
||||||
userIds.remove(userId);
|
userIds.remove(userId);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -83,7 +83,7 @@ public class NotificationWritePlatformServiceImpl implements NotificationWritePl
|
|||||||
private List<Long> insertIntoNotificationMapper(Collection<Long> userIds, Long generatedNotificationId) {
|
private List<Long> insertIntoNotificationMapper(Collection<Long> userIds, Long generatedNotificationId) {
|
||||||
List<Long> mappedIds = new ArrayList<>();
|
List<Long> mappedIds = new ArrayList<>();
|
||||||
for (Long userId : userIds) {
|
for (Long userId : userIds) {
|
||||||
AppUser appUser = this.appUserRepository.findById(userId).get();
|
AppUser appUser = this.appUserRepository.findById(userId).orElseThrow();
|
||||||
NotificationMapper notificationMapper = new NotificationMapper(
|
NotificationMapper notificationMapper = new NotificationMapper(
|
||||||
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false,
|
this.notificationGeneratorReadRepositoryWrapper.findById(generatedNotificationId), appUser, false,
|
||||||
DateUtils.getDateOfTenant());
|
DateUtils.getDateOfTenant());
|
||||||
|
|||||||
+1
-1
@@ -440,7 +440,7 @@ public class AccountTransfersWritePlatformServiceImpl implements AccountTransfer
|
|||||||
|
|
||||||
// if the savings account is GSIM, update its parent as well
|
// if the savings account is GSIM, update its parent as well
|
||||||
if (toSavingsAccount.getGsim() != null) {
|
if (toSavingsAccount.getGsim() != null) {
|
||||||
GroupSavingsIndividualMonitoring gsim = gsimRepository.findById(toSavingsAccount.getGsim().getId()).get();
|
GroupSavingsIndividualMonitoring gsim = gsimRepository.findById(toSavingsAccount.getGsim().getId()).orElseThrow();
|
||||||
BigDecimal currentBalance = gsim.getParentDeposit();
|
BigDecimal currentBalance = gsim.getParentDeposit();
|
||||||
BigDecimal newBalance = currentBalance.add(accountTransferDTO.getTransactionAmount());
|
BigDecimal newBalance = currentBalance.add(accountTransferDTO.getTransactionAmount());
|
||||||
gsim.setParentDeposit(newBalance);
|
gsim.setParentDeposit(newBalance);
|
||||||
|
|||||||
+1
-1
@@ -183,7 +183,7 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult delete(final Long id) {
|
public CommandProcessingResult delete(final Long id) {
|
||||||
AccountTransferStandingInstruction standingInstructionsForUpdate = this.standingInstructionRepository.findById(id).get();
|
AccountTransferStandingInstruction standingInstructionsForUpdate = this.standingInstructionRepository.findById(id).orElseThrow();
|
||||||
// update the "deleted" and "name" properties of the standing
|
// update the "deleted" and "name" properties of the standing
|
||||||
// instruction
|
// instruction
|
||||||
standingInstructionsForUpdate.delete();
|
standingInstructionsForUpdate.delete();
|
||||||
|
|||||||
+2
-2
@@ -76,7 +76,7 @@ public class LoanScheduleHistoryWritePlatformServiceImpl implements LoanSchedule
|
|||||||
|
|
||||||
Date createdOnDate = null;
|
Date createdOnDate = null;
|
||||||
if (repaymentScheduleInstallment.getCreatedDate().isPresent()) {
|
if (repaymentScheduleInstallment.getCreatedDate().isPresent()) {
|
||||||
createdOnDate = Date.from(repaymentScheduleInstallment.getCreatedDate().get());
|
createdOnDate = Date.from(repaymentScheduleInstallment.getCreatedDate().get()); // NOSONAR
|
||||||
}
|
}
|
||||||
|
|
||||||
final AppUser createdByUser = repaymentScheduleInstallment.getCreatedBy().orElse(null);
|
final AppUser createdByUser = repaymentScheduleInstallment.getCreatedBy().orElse(null);
|
||||||
@@ -85,7 +85,7 @@ public class LoanScheduleHistoryWritePlatformServiceImpl implements LoanSchedule
|
|||||||
Date lastModifiedOnDate = null;
|
Date lastModifiedOnDate = null;
|
||||||
|
|
||||||
if (repaymentScheduleInstallment.getLastModifiedDate().isPresent()) {
|
if (repaymentScheduleInstallment.getLastModifiedDate().isPresent()) {
|
||||||
lastModifiedOnDate = Date.from(repaymentScheduleInstallment.getLastModifiedDate().get());
|
lastModifiedOnDate = Date.from(repaymentScheduleInstallment.getLastModifiedDate().get()); // NOSONAR
|
||||||
}
|
}
|
||||||
|
|
||||||
LoanRepaymentScheduleHistory loanRepaymentScheduleHistory = LoanRepaymentScheduleHistory.instance(loan, loanRescheduleRequest,
|
LoanRepaymentScheduleHistory loanRepaymentScheduleHistory = LoanRepaymentScheduleHistory.instance(loan, loanRescheduleRequest,
|
||||||
|
|||||||
+3
-3
@@ -1338,7 +1338,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
|||||||
public CommandProcessingResult approveGLIMLoanAppication(final Long loanId, final JsonCommand command) {
|
public CommandProcessingResult approveGLIMLoanAppication(final Long loanId, final JsonCommand command) {
|
||||||
|
|
||||||
final Long parentLoanId = loanId;
|
final Long parentLoanId = loanId;
|
||||||
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).get();
|
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).orElseThrow();
|
||||||
JsonArray approvalFormData = command.arrayOfParameterNamed("approvalFormData");
|
JsonArray approvalFormData = command.arrayOfParameterNamed("approvalFormData");
|
||||||
|
|
||||||
JsonObject jsonObject = null;
|
JsonObject jsonObject = null;
|
||||||
@@ -1498,7 +1498,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
|||||||
// GroupLoanIndividualMonitoringAccount
|
// GroupLoanIndividualMonitoringAccount
|
||||||
// glimAccount=glimRepository.findOne(loanId);
|
// glimAccount=glimRepository.findOne(loanId);
|
||||||
final Long parentLoanId = loanId;
|
final Long parentLoanId = loanId;
|
||||||
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).get();
|
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).orElseThrow();
|
||||||
List<Loan> childLoans = this.loanRepository.findByGlimId(loanId);
|
List<Loan> childLoans = this.loanRepository.findByGlimId(loanId);
|
||||||
|
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
@@ -1577,7 +1577,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
|||||||
// GroupLoanIndividualMonitoringAccount
|
// GroupLoanIndividualMonitoringAccount
|
||||||
// glimAccount=glimRepository.findOne(loanId);
|
// glimAccount=glimRepository.findOne(loanId);
|
||||||
final Long parentLoanId = glimId;
|
final Long parentLoanId = glimId;
|
||||||
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).get();
|
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).orElseThrow();
|
||||||
List<Loan> childLoans = this.loanRepository.findByGlimId(glimId);
|
List<Loan> childLoans = this.loanRepository.findByGlimId(glimId);
|
||||||
|
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
|
|||||||
+3
-3
@@ -341,7 +341,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult disburseGLIMLoan(final Long loanId, final JsonCommand command) {
|
public CommandProcessingResult disburseGLIMLoan(final Long loanId, final JsonCommand command) {
|
||||||
final Long parentLoanId = loanId;
|
final Long parentLoanId = loanId;
|
||||||
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).get();
|
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).orElseThrow();
|
||||||
List<Loan> childLoans = this.loanRepository.findByGlimId(loanId);
|
List<Loan> childLoans = this.loanRepository.findByGlimId(loanId);
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -848,7 +848,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
// GroupLoanIndividualMonitoringAccount
|
// GroupLoanIndividualMonitoringAccount
|
||||||
// glimAccount=glimRepository.findOne(loanId);
|
// glimAccount=glimRepository.findOne(loanId);
|
||||||
final Long parentLoanId = loanId;
|
final Long parentLoanId = loanId;
|
||||||
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).get();
|
GroupLoanIndividualMonitoringAccount parentLoan = glimRepository.findById(parentLoanId).orElseThrow();
|
||||||
List<Loan> childLoans = this.loanRepository.findByGlimId(loanId);
|
List<Loan> childLoans = this.loanRepository.findByGlimId(loanId);
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -938,7 +938,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
final Long parentLoanId = loanId;
|
final Long parentLoanId = loanId;
|
||||||
|
|
||||||
glimRepository.findById(parentLoanId).get();
|
glimRepository.findById(parentLoanId).orElseThrow();
|
||||||
|
|
||||||
JsonArray repayments = command.arrayOfParameterNamed("formDataArray");
|
JsonArray repayments = command.arrayOfParameterNamed("formDataArray");
|
||||||
JsonCommand childCommand = null;
|
JsonCommand childCommand = null;
|
||||||
|
|||||||
+1
-1
@@ -164,7 +164,7 @@ public class MeetingWritePlatformServiceJpaRepositoryImpl implements MeetingWrit
|
|||||||
/*
|
/*
|
||||||
* If group is within a center then center entityType should be passed for retrieving CalendarInstance.
|
* If group is within a center then center entityType should be passed for retrieving CalendarInstance.
|
||||||
*/
|
*/
|
||||||
final Group group = this.groupRepository.findById(entityId).get();
|
final Group group = this.groupRepository.findById(entityId).orElseThrow();
|
||||||
if (group.isCenter()) {
|
if (group.isCenter()) {
|
||||||
entityType = CalendarEntityType.CENTERS;
|
entityType = CalendarEntityType.CENTERS;
|
||||||
} else if (group.isChildGroup()) {
|
} else if (group.isChildGroup()) {
|
||||||
|
|||||||
+1
-1
@@ -432,7 +432,7 @@ public class SavingsAccountAssembler {
|
|||||||
}
|
}
|
||||||
accountType = AccountType.JLG;
|
accountType = AccountType.JLG;
|
||||||
}
|
}
|
||||||
final SavingsProduct product = this.savingProductRepository.findById(productId).get();
|
final SavingsProduct product = this.savingProductRepository.findById(productId).orElseThrow();
|
||||||
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromSavingsProduct(product);
|
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromSavingsProduct(product);
|
||||||
final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, null, null, null,
|
final SavingsAccount account = SavingsAccount.createNewApplicationForSubmittal(client, group, product, null, null, null,
|
||||||
accountType, appliedonDate, appliedBy, product.nominalAnnualInterestRate(), product.interestCompoundingPeriodType(),
|
accountType, appliedonDate, appliedBy, product.nominalAnnualInterestRate(), product.interestCompoundingPeriodType(),
|
||||||
|
|||||||
+6
-5
@@ -225,7 +225,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
public CommandProcessingResult gsimActivate(final Long gsimId, final JsonCommand command) {
|
public CommandProcessingResult gsimActivate(final Long gsimId, final JsonCommand command) {
|
||||||
|
|
||||||
Long parentSavingId = gsimId;
|
Long parentSavingId = gsimId;
|
||||||
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).get();
|
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).orElseThrow();
|
||||||
List<SavingsAccount> childSavings = this.savingAccountRepositoryWrapper.findByGsimId(gsimId);
|
List<SavingsAccount> childSavings = this.savingAccountRepositoryWrapper.findByGsimId(gsimId);
|
||||||
|
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
@@ -376,14 +376,15 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
LOG.debug("Deposit account has been created: {} ", deposit);
|
LOG.debug("Deposit account has been created: {} ", deposit);
|
||||||
|
|
||||||
GroupSavingsIndividualMonitoring gsim = gsimRepository.findById(account.getGsim().getId()).get();
|
GroupSavingsIndividualMonitoring gsim = gsimRepository.findById(account.getGsim().getId()).orElseThrow();
|
||||||
LOG.info("parent deposit : {} ", gsim.getParentDeposit());
|
LOG.info("parent deposit : {} ", gsim.getParentDeposit());
|
||||||
LOG.info("child account : {} ", savingsId);
|
LOG.info("child account : {} ", savingsId);
|
||||||
BigDecimal currentBalance = gsim.getParentDeposit();
|
BigDecimal currentBalance = gsim.getParentDeposit();
|
||||||
BigDecimal newBalance = currentBalance.add(transactionAmount);
|
BigDecimal newBalance = currentBalance.add(transactionAmount);
|
||||||
gsim.setParentDeposit(newBalance);
|
gsim.setParentDeposit(newBalance);
|
||||||
gsimRepository.save(gsim);
|
gsimRepository.save(gsim);
|
||||||
LOG.info("balance after making deposit : {} ", gsimRepository.findById(account.getGsim().getId()).get().getParentDeposit());
|
LOG.info("balance after making deposit : {} ",
|
||||||
|
gsimRepository.findById(account.getGsim().getId()).orElseThrow().getParentDeposit());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,7 +449,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
transactionAmount, paymentDetail, transactionBooleanValues, backdatedTxnsAllowedTill);
|
transactionAmount, paymentDetail, transactionBooleanValues, backdatedTxnsAllowedTill);
|
||||||
|
|
||||||
if (isGsim && (withdrawal.getId() != null)) {
|
if (isGsim && (withdrawal.getId() != null)) {
|
||||||
GroupSavingsIndividualMonitoring gsim = gsimRepository.findById(account.getGsim().getId()).get();
|
GroupSavingsIndividualMonitoring gsim = gsimRepository.findById(account.getGsim().getId()).orElseThrow();
|
||||||
BigDecimal currentBalance = gsim.getParentDeposit().subtract(transactionAmount);
|
BigDecimal currentBalance = gsim.getParentDeposit().subtract(transactionAmount);
|
||||||
gsim.setParentDeposit(currentBalance);
|
gsim.setParentDeposit(currentBalance);
|
||||||
gsimRepository.save(gsim);
|
gsimRepository.save(gsim);
|
||||||
@@ -939,7 +940,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
public CommandProcessingResult bulkGSIMClose(final Long gsimId, final JsonCommand command) {
|
public CommandProcessingResult bulkGSIMClose(final Long gsimId, final JsonCommand command) {
|
||||||
|
|
||||||
final Long parentSavingId = gsimId;
|
final Long parentSavingId = gsimId;
|
||||||
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).get();
|
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).orElseThrow();
|
||||||
List<SavingsAccount> childSavings = this.savingAccountRepositoryWrapper.findByGsimId(gsimId);
|
List<SavingsAccount> childSavings = this.savingAccountRepositoryWrapper.findByGsimId(gsimId);
|
||||||
|
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
|
|||||||
+3
-3
@@ -488,7 +488,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
// GroupLoanIndividualMonitoringAccount
|
// GroupLoanIndividualMonitoringAccount
|
||||||
// glimAccount=glimRepository.findOne(loanId);
|
// glimAccount=glimRepository.findOne(loanId);
|
||||||
Long parentSavingId = gsimId;
|
Long parentSavingId = gsimId;
|
||||||
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).get();
|
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).orElseThrow();
|
||||||
List<SavingsAccount> childSavings = this.savingAccountRepository.findByGsimId(gsimId);
|
List<SavingsAccount> childSavings = this.savingAccountRepository.findByGsimId(gsimId);
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
@@ -552,7 +552,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult undoGSIMApplicationApproval(final Long gsimId, final JsonCommand command) {
|
public CommandProcessingResult undoGSIMApplicationApproval(final Long gsimId, final JsonCommand command) {
|
||||||
final Long parentSavingId = gsimId;
|
final Long parentSavingId = gsimId;
|
||||||
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).get();
|
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).orElseThrow();
|
||||||
List<SavingsAccount> childSavings = this.savingAccountRepository.findByGsimId(gsimId);
|
List<SavingsAccount> childSavings = this.savingAccountRepository.findByGsimId(gsimId);
|
||||||
|
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
@@ -612,7 +612,7 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
public CommandProcessingResult rejectGSIMApplication(final Long gsimId, final JsonCommand command) {
|
public CommandProcessingResult rejectGSIMApplication(final Long gsimId, final JsonCommand command) {
|
||||||
|
|
||||||
final Long parentSavingId = gsimId;
|
final Long parentSavingId = gsimId;
|
||||||
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).get();
|
GroupSavingsIndividualMonitoring parentSavings = gsimRepository.findById(parentSavingId).orElseThrow();
|
||||||
List<SavingsAccount> childSavings = this.savingAccountRepository.findByGsimId(gsimId);
|
List<SavingsAccount> childSavings = this.savingAccountRepository.findByGsimId(gsimId);
|
||||||
|
|
||||||
CommandProcessingResult result = null;
|
CommandProcessingResult result = null;
|
||||||
|
|||||||
+2
-1
@@ -49,7 +49,8 @@ public class ShareAccountSchedularServiceImpl implements ShareAccountSchedularSe
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void postDividend(final Long dividendDetailId, final Long savingsId) {
|
public void postDividend(final Long dividendDetailId, final Long savingsId) {
|
||||||
|
|
||||||
ShareAccountDividendDetails shareAccountDividendDetails = this.shareAccountDividendRepository.findById(dividendDetailId).get();
|
ShareAccountDividendDetails shareAccountDividendDetails = this.shareAccountDividendRepository.findById(dividendDetailId)
|
||||||
|
.orElseThrow();
|
||||||
final SavingsAccount savingsAccount = this.savingsAccountAssembler.assembleFrom(savingsId, false);
|
final SavingsAccount savingsAccount = this.savingsAccountAssembler.assembleFrom(savingsId, false);
|
||||||
SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountDomainService.handleDividendPayout(savingsAccount,
|
SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountDomainService.handleDividendPayout(savingsAccount,
|
||||||
DateUtils.getLocalDateOfTenant(), shareAccountDividendDetails.getAmount(), false);
|
DateUtils.getLocalDateOfTenant(), shareAccountDividendDetails.getAmount(), false);
|
||||||
|
|||||||
+1
-1
@@ -457,7 +457,7 @@ public class TransferWritePlatformServiceJpaRepositoryImpl implements TransferWr
|
|||||||
} else if (!destinationGroup.isActive()) {
|
} else if (!destinationGroup.isActive()) {
|
||||||
throw new GroupNotActiveException(destinationGroup.getId());
|
throw new GroupNotActiveException(destinationGroup.getId());
|
||||||
}
|
}
|
||||||
transferClientBetweenGroups(client.getGroups().stream().findFirst().get(), client, destinationGroup, true, staff);
|
transferClientBetweenGroups(client.getGroups().iterator().next(), client, destinationGroup, true, staff);
|
||||||
} else if (client.getGroups().size() == 0 && destinationGroup != null) {
|
} else if (client.getGroups().size() == 0 && destinationGroup != null) {
|
||||||
client.getGroups().add(destinationGroup);
|
client.getGroups().add(destinationGroup);
|
||||||
client.updateStaff(destinationGroup.getStaff());
|
client.updateStaff(destinationGroup.getStaff());
|
||||||
|
|||||||
Reference in New Issue
Block a user