fix eclipse warnings around unused imports and fields in Data objects.

This commit is contained in:
Keith Woodlock
2013-09-20 10:19:42 +01:00
parent 6e252b8a58
commit 5192afaf4e
11 changed files with 182 additions and 192 deletions
@@ -2,7 +2,9 @@ package org.mifosplatform.portfolio.account.data;
public class AccountAssociationsData {
@SuppressWarnings("unused")
private final Long id;
@SuppressWarnings("unused")
private final PortfolioAccountData account;
private final PortfolioAccountData linkedAccount;
@@ -31,14 +31,14 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
@Override
public PortfolioAccountData retriveLoanAssociation(final Long loanId) {
PortfolioAccountData linkedAccount = null;
AccountAssociationsMapper mapper = new AccountAssociationsMapper();
String sql = "select " + mapper.schema() + " where aa.loan_account_id = ? ";
final AccountAssociationsMapper mapper = new AccountAssociationsMapper();
final String sql = "select " + mapper.schema() + " where aa.loan_account_id = ? ";
try {
AccountAssociationsData accountAssociationsData = jdbcTemplate.queryForObject(sql, mapper, loanId);
final AccountAssociationsData accountAssociationsData = this.jdbcTemplate.queryForObject(sql, mapper, loanId);
if (accountAssociationsData != null) {
linkedAccount = accountAssociationsData.linkedAccount();
}
} catch (EmptyResultDataAccessException e) {
} catch (final EmptyResultDataAccessException e) {
logger.debug("Linking account is not configured");
}
return linkedAccount;
@@ -47,13 +47,13 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
@Override
public boolean isLinkedWithAnyActiveLoan(final Long savingsId) {
boolean hasActiveLoan = false;
String sql = "select loanAccount.loan_status_id as status from m_portfolio_account_associations aa " +
final String sql = "select loanAccount.loan_status_id as status from m_portfolio_account_associations aa " +
"left join m_loan loanAccount on loanAccount.id = aa.loan_account_id " +
"where aa.linked_savings_account_id = ?";
List<Integer> statusList= this.jdbcTemplate.queryForList(sql,Integer.class, savingsId);
for(Integer status:statusList){
LoanStatus loanStatus= LoanStatus.fromInt(status);
final List<Integer> statusList= this.jdbcTemplate.queryForList(sql,Integer.class, savingsId);
for(final Integer status:statusList){
final LoanStatus loanStatus= LoanStatus.fromInt(status);
if(loanStatus.isActiveOrAwaitingApprovalOrDisbursal() || loanStatus.isUnderTransfer()){
hasActiveLoan = true;
break;
@@ -67,7 +67,7 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
private final String schemaSql;
public AccountAssociationsMapper() {
StringBuilder sqlBuilder = new StringBuilder();
final StringBuilder sqlBuilder = new StringBuilder();
sqlBuilder.append("aa.id as id,");
// sqlBuilder.append("savingsAccount.id as savingsAccountId, savingsAccount.account_no as savingsAccountNo,");
sqlBuilder.append("loanAccount.id as loanAccountId, loanAccount.account_no as loanAccountNo,");
@@ -86,7 +86,7 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
}
@Override
public AccountAssociationsData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
public AccountAssociationsData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
final Long id = rs.getLong("id");
// final Long savingsAccountId = JdbcSupport.getLong(rs,
@@ -94,8 +94,7 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
// final String savingsAccountNo = rs.getString("savingsAccountNo");
final Long loanAccountId = JdbcSupport.getLong(rs, "loanAccountId");
final String loanAccountNo = rs.getString("loanAccountNo");
PortfolioAccountData account = PortfolioAccountData.lookup(loanAccountId, loanAccountNo);
;
final PortfolioAccountData account = PortfolioAccountData.lookup(loanAccountId, loanAccountNo);
/*
* if (savingsAccountId != null) { account =
* PortfolioAccountData.lookup(savingsAccountId, savingsAccountNo);
@@ -108,7 +107,7 @@ public class AccountAssociationsReadPlatformServiceImpl implements AccountAssoci
// "linkLoanAccountId");
// final String linkLoanAccountNo =
// rs.getString("linkLoanAccountNo");
PortfolioAccountData linkedAccount = PortfolioAccountData.lookup(linkSavingsAccountId, linkSavingsAccountNo);
final PortfolioAccountData linkedAccount = PortfolioAccountData.lookup(linkSavingsAccountId, linkSavingsAccountNo);
/*
* if (linkSavingsAccountId != null) { linkedAccount =
* PortfolioAccountData.lookup(linkSavingsAccountId,
@@ -19,19 +19,14 @@ import org.mifosplatform.portfolio.charge.domain.ChargePaymentMode;
*/
public class LoanChargeData {
@SuppressWarnings("unused")
private final Long id;
@SuppressWarnings("unused")
private final Long chargeId;
@SuppressWarnings("unused")
private final String name;
@SuppressWarnings("unused")
private final EnumOptionData chargeTimeType;
@SuppressWarnings("unused")
private final LocalDate dueDate;
@SuppressWarnings("unused")
@@ -55,7 +50,6 @@ public class LoanChargeData {
@SuppressWarnings("unused")
private final BigDecimal amountWrittenOff;
@SuppressWarnings("unused")
private final BigDecimal amountOutstanding;
@SuppressWarnings("unused")
@@ -72,9 +66,10 @@ public class LoanChargeData {
private final boolean paid;
private final boolean waived;
@SuppressWarnings("unused")
private final boolean chargePayable;
private final Long loanId;
public static LoanChargeData template(final Collection<ChargeData> chargeOptions) {
@@ -96,7 +91,7 @@ public class LoanChargeData {
final BigDecimal amountPaid, final BigDecimal amountWaived, final BigDecimal amountWrittenOff,
final BigDecimal amountOutstanding, final EnumOptionData chargeTimeType, final LocalDate dueDate,
final EnumOptionData chargeCalculationType, final BigDecimal percentage, final BigDecimal amountPercentageAppliedTo,
final boolean penalty, EnumOptionData chargePaymentMode, boolean paid, boolean waived, Long loanId) {
final boolean penalty, final EnumOptionData chargePaymentMode, final boolean paid, final boolean waived, final Long loanId) {
this.id = id;
this.chargeId = chargeId;
this.name = name;
@@ -129,8 +124,8 @@ public class LoanChargeData {
private LoanChargeData(final Long id, final Long chargeId, final String name, final CurrencyData currency, final BigDecimal amount,
final BigDecimal pecentage, final EnumOptionData chargeTimeType, final EnumOptionData chargeCalculationType,
final Collection<ChargeData> chargeOptions, final boolean penalty, EnumOptionData chargePaymentMode, boolean paid,
boolean waived, Long loanId) {
final Collection<ChargeData> chargeOptions, final boolean penalty, final EnumOptionData chargePaymentMode, final boolean paid,
final boolean waived, final Long loanId) {
this.id = id;
this.chargeId = chargeId;
this.name = name;
@@ -193,20 +188,20 @@ public class LoanChargeData {
}
return isAccountTransfer && !this.paid && !this.waived;
}
public Long getId() {
return this.id;
}
public LocalDate getDueDate() {
return this.dueDate;
}
public Long getLoanId() {
return this.loanId;
}
public BigDecimal getAmountOutstanding() {
return this.amountOutstanding;
}
@@ -33,7 +33,6 @@ import org.mifosplatform.portfolio.calendar.domain.CalendarInstance;
import org.mifosplatform.portfolio.calendar.domain.CalendarInstanceRepository;
import org.mifosplatform.portfolio.calendar.domain.CalendarRepository;
import org.mifosplatform.portfolio.calendar.exception.CalendarNotFoundException;
import org.mifosplatform.portfolio.charge.domain.ChargePaymentMode;
import org.mifosplatform.portfolio.client.domain.AccountNumberGenerator;
import org.mifosplatform.portfolio.client.domain.AccountNumberGeneratorFactory;
import org.mifosplatform.portfolio.client.domain.Client;
@@ -149,7 +148,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
}
private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
List<LoanStatus> allowedLoanStatuses = Arrays.asList(LoanStatus.values());
final List<LoanStatus> allowedLoanStatuses = Arrays.asList(LoanStatus.values());
return new DefaultLoanLifecycleStateMachine(allowedLoanStatuses);
}
@@ -158,14 +157,14 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
public CommandProcessingResult submitApplication(final JsonCommand command) {
try {
final AppUser currentUser = context.authenticatedUser();
final AppUser currentUser = this.context.authenticatedUser();
this.fromApiJsonDeserializer.validateForCreate(command.json());
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
final Long productId = fromJsonHelper.extractLongNamed("productId", command.parsedJson());
final Long productId = this.fromJsonHelper.extractLongNamed("productId", command.parsedJson());
final LoanProduct loanProduct = this.loanProductRepository.findOne(productId);
if (loanProduct == null) { throw new LoanProductNotFoundException(productId); }
@@ -173,7 +172,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
final Loan newLoanApplication = loanAssembler.assembleFrom(command, currentUser);
final Loan newLoanApplication = this.loanAssembler.assembleFrom(command, currentUser);
validateSubmittedOnDate(newLoanApplication);
@@ -193,7 +192,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
final String submittedOnNote = command.stringValueOfParameterNamed("submittedOnNote");
if (StringUtils.isNotBlank(submittedOnNote)) {
Note note = Note.loanNote(newLoanApplication, submittedOnNote);
final Note note = Note.loanNote(newLoanApplication, submittedOnNote);
this.noteRepository.save(note);
}
@@ -205,7 +204,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
calendar = this.calendarRepository.findOne(calendarId);
if (calendar == null) { throw new CalendarNotFoundException(calendarId); }
CalendarInstance calendarInstance = new CalendarInstance(calendar, newLoanApplication.getId(),
final CalendarInstance calendarInstance = new CalendarInstance(calendar, newLoanApplication.getId(),
CalendarEntityType.LOANS.getValue());
this.calendarInstanceRepository.save(calendarInstance);
}
@@ -213,9 +212,9 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
// Save linked account information
final Long savingsAccountId = command.longValueOfParameterNamed("linkAccountId");
if (savingsAccountId != null) {
SavingsAccount savingsAccount = this.savingsAccountAssembler.assembleFrom(savingsAccountId);
final SavingsAccount savingsAccount = this.savingsAccountAssembler.assembleFrom(savingsAccountId);
this.fromApiJsonDeserializer.validatelinkedSavingsAccount(savingsAccount, newLoanApplication);
AccountAssociations accountAssociations = AccountAssociations.associateSavingsAccount(newLoanApplication, savingsAccount);
final AccountAssociations accountAssociations = AccountAssociations.associateSavingsAccount(newLoanApplication, savingsAccount);
this.accountAssociationsRepository.save(accountAssociations);
}
@@ -227,7 +226,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
.withGroupId(newLoanApplication.getGroupId()) //
.withLoanId(newLoanApplication.getId()) //
.build();
} catch (DataIntegrityViolationException dve) {
} catch (final DataIntegrityViolationException dve) {
handleDataIntegrityIssues(command, dve);
return CommandProcessingResult.empty();
}
@@ -238,7 +237,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
public CommandProcessingResult modifyApplication(final Long loanId, final JsonCommand command) {
try {
context.authenticatedUser();
this.context.authenticatedUser();
this.fromApiJsonDeserializer.validateForModify(command.json());
@@ -351,7 +350,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
final String submittedOnNote = command.stringValueOfParameterNamed("submittedOnNote");
if (StringUtils.isNotBlank(submittedOnNote)) {
Note note = Note.loanNote(existingLoanApplication, submittedOnNote);
final Note note = Note.loanNote(existingLoanApplication, submittedOnNote);
this.noteRepository.save(note);
}
@@ -362,27 +361,27 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (calendar == null) { throw new CalendarNotFoundException(calendarId); }
}
List<CalendarInstance> ciList = (List<CalendarInstance>) this.calendarInstanceRepository.findByEntityIdAndEntityTypeId(loanId,
final List<CalendarInstance> ciList = (List<CalendarInstance>) this.calendarInstanceRepository.findByEntityIdAndEntityTypeId(loanId,
CalendarEntityType.LOANS.getValue());
if (calendar != null) {
// For loans, allow to attach only one calendar instance per
// loan
if (ciList != null && !ciList.isEmpty()) {
CalendarInstance calendarInstance = ciList.get(0);
final CalendarInstance calendarInstance = ciList.get(0);
if (calendarInstance.getCalendar().getId() != calendar.getId()) {
calendarInstance.updateCalendar(calendar);
this.calendarInstanceRepository.saveAndFlush(calendarInstance);
}
} else {
// attaching new calendar
CalendarInstance calendarInstance = new CalendarInstance(calendar, existingLoanApplication.getId(),
final CalendarInstance calendarInstance = new CalendarInstance(calendar, existingLoanApplication.getId(),
CalendarEntityType.LOANS.getValue());
this.calendarInstanceRepository.save(calendarInstance);
}
} else if (ciList != null && !ciList.isEmpty()) {
CalendarInstance calendarInstance = ciList.get(0);
final CalendarInstance calendarInstance = ciList.get(0);
this.calendarInstanceRepository.delete(calendarInstance);
}
@@ -406,13 +405,13 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (accountAssociations == null) {
isModified = true;
} else {
SavingsAccount savingsAccount = accountAssociations.linkedSavingsAccount();
final SavingsAccount savingsAccount = accountAssociations.linkedSavingsAccount();
if (savingsAccount == null || savingsAccount.getId() != savingsAccountId) {
isModified = true;
}
}
if (isModified) {
SavingsAccount savingsAccount = this.savingsAccountAssembler.assembleFrom(savingsAccountId);
final SavingsAccount savingsAccount = this.savingsAccountAssembler.assembleFrom(savingsAccountId);
this.fromApiJsonDeserializer.validatelinkedSavingsAccount(savingsAccount, existingLoanApplication);
if (accountAssociations == null) {
accountAssociations = AccountAssociations.associateSavingsAccount(existingLoanApplication, savingsAccount);
@@ -426,7 +425,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (!isLinkedAccPresent) {
final Set<LoanCharge> charges = existingLoanApplication.charges();
for (LoanCharge loanCharge : charges) {
for (final LoanCharge loanCharge : charges) {
if (loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
final String errorMessage = "one of the charges requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge", errorMessage);
@@ -441,7 +440,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
.withGroupId(existingLoanApplication.getGroupId()) //
.withLoanId(existingLoanApplication.getId()) //
.with(changes).build();
} catch (DataIntegrityViolationException dve) {
} catch (final DataIntegrityViolationException dve) {
handleDataIntegrityIssues(command, dve);
return CommandProcessingResult.empty();
}
@@ -453,7 +452,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
*/
private void handleDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
Throwable realCause = dve.getMostSpecificCause();
final Throwable realCause = dve.getMostSpecificCause();
if (realCause.getMessage().contains("loan_account_no_UNIQUE")) {
final String accountNo = command.stringValueOfParameterNamed("accountNo");
@@ -478,14 +477,14 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
@Override
public CommandProcessingResult deleteApplication(final Long loanId) {
context.authenticatedUser();
this.context.authenticatedUser();
final Loan loan = retrieveLoanBy(loanId);
checkClientOrGroupActive(loan);
if (loan.isNotSubmittedAndPendingApproval()) { throw new LoanApplicationNotInSubmittedAndPendingApprovalStateCannotBeDeleted(loanId); }
List<Note> relatedNotes = this.noteRepository.findByLoanId(loan.getId());
final List<Note> relatedNotes = this.noteRepository.findByLoanId(loan.getId());
this.noteRepository.deleteInBatch(relatedNotes);
this.loanRepository.delete(loanId);
@@ -503,7 +502,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
@Override
public CommandProcessingResult approveApplication(final Long loanId, final JsonCommand command) {
final AppUser currentUser = context.authenticatedUser();
final AppUser currentUser = this.context.authenticatedUser();
this.loanApplicationTransitionApiJsonValidator.validateApproval(command.json());
@@ -516,7 +515,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) {
Note note = Note.loanNote(loan, noteText);
final Note note = Note.loanNote(loan, noteText);
changes.put("note", noteText);
this.noteRepository.save(note);
}
@@ -537,7 +536,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
@Override
public CommandProcessingResult undoApplicationApproval(final Long loanId, final JsonCommand command) {
context.authenticatedUser();
this.context.authenticatedUser();
this.fromApiJsonDeserializer.validateForUndo(command.json());
@@ -548,9 +547,9 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (!changes.isEmpty()) {
this.loanRepository.save(loan);
String noteText = command.stringValueOfParameterNamed("note");
final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) {
Note note = Note.loanNote(loan, noteText);
final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note);
}
}
@@ -570,7 +569,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
@Override
public CommandProcessingResult rejectApplication(final Long loanId, final JsonCommand command) {
final AppUser currentUser = context.authenticatedUser();
final AppUser currentUser = this.context.authenticatedUser();
this.loanApplicationTransitionApiJsonValidator.validateRejection(command.json());
@@ -581,9 +580,9 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (!changes.isEmpty()) {
this.loanRepository.save(loan);
String noteText = command.stringValueOfParameterNamed("note");
final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) {
Note note = Note.loanNote(loan, noteText);
final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note);
}
}
@@ -603,7 +602,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
@Override
public CommandProcessingResult applicantWithdrawsFromApplication(final Long loanId, final JsonCommand command) {
final AppUser currentUser = context.authenticatedUser();
final AppUser currentUser = this.context.authenticatedUser();
this.loanApplicationTransitionApiJsonValidator.validateApplicantWithdrawal(command.json());
@@ -615,9 +614,9 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (!changes.isEmpty()) {
this.loanRepository.save(loan);
String noteText = command.stringValueOfParameterNamed("note");
final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) {
Note note = Note.loanNote(loan, noteText);
final Note note = Note.loanNote(loan, noteText);
this.noteRepository.save(note);
}
}
@@ -25,7 +25,6 @@ import org.mifosplatform.organisation.staff.exception.StaffRoleException;
import org.mifosplatform.organisation.workingdays.domain.WorkingDays;
import org.mifosplatform.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
import org.mifosplatform.portfolio.accountdetails.service.AccountEnumerations;
import org.mifosplatform.portfolio.charge.domain.ChargePaymentMode;
import org.mifosplatform.portfolio.client.domain.Client;
import org.mifosplatform.portfolio.client.domain.ClientRepositoryWrapper;
import org.mifosplatform.portfolio.client.exception.ClientNotActiveException;
@@ -56,8 +55,8 @@ import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct;
import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRelatedDetail;
import org.mifosplatform.portfolio.loanproduct.domain.LoanProductRepository;
import org.mifosplatform.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy;
import org.mifosplatform.portfolio.loanproduct.exception.LinkedAccountRequiredException;
import org.mifosplatform.portfolio.loanproduct.exception.InvalidCurrencyException;
import org.mifosplatform.portfolio.loanproduct.exception.LinkedAccountRequiredException;
import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException;
import org.mifosplatform.useradministration.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
@@ -160,9 +159,9 @@ public class LoanAssembler {
final String errorMessage = "Charge and Loan must have the same currency.";
throw new InvalidCurrencyException("loanCharge", "attach.to.loan", errorMessage);
}
if(loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()){
if (loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
final Long savingsAccountId = this.fromApiJsonHelper.extractLongNamed("linkAccountId", element);
if(savingsAccountId == null){
if (savingsAccountId == null) {
final String errorMessage = "one of the charges requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge", errorMessage);
}
@@ -10,7 +10,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
@@ -246,22 +245,21 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
postJournalEntries(loan, existingTransactionIds, existingReversedTransactionIds);
}
Set<LoanCharge> loanCharges = loan.charges();
Map<Long,BigDecimal> disBuLoanCharges = new HashMap<Long,BigDecimal>();
for (LoanCharge loanCharge : loanCharges) {
final Set<LoanCharge> loanCharges = loan.charges();
final Map<Long, BigDecimal> disBuLoanCharges = new HashMap<Long, BigDecimal>();
for (final LoanCharge loanCharge : loanCharges) {
if (loanCharge.isDueAtDisbursement() && loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
disBuLoanCharges.put(loanCharge.getId(), loanCharge.amount());
}
}
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
for (Map.Entry<Long, BigDecimal> entrySet: disBuLoanCharges.entrySet()) {
PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loanId,
"Loan Charge Payment", locale, fmt, null, null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue(),
entrySet.getKey());
accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
for (final Map.Entry<Long, BigDecimal> entrySet : disBuLoanCharges.entrySet()) {
final PortfolioAccountData savingAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(actualDisbursementDate, entrySet.getValue(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, savingAccountData.accountId(), loanId, "Loan Charge Payment",
locale, fmt, null, null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.getValue(), entrySet.getKey());
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
}
return new CommandProcessingResultBuilder() //
@@ -475,7 +473,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final LoanTransaction transactionToAdjust = this.loanTransactionRepository.findOne(transactionId);
if (transactionToAdjust == null) { throw new LoanTransactionNotFoundException(transactionId); }
if (accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) { throw new PlatformServiceUnavailableException(
if (this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.LOAN)) { throw new PlatformServiceUnavailableException(
"error.msg.loan.transfer.transaction.update.not.allowed", "Loan transaction:" + transactionId
+ " update not allowed as it involves in account transfer", transactionId); }
@@ -793,12 +791,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final String errorMessage = "Charge and Loan must have the same currency.";
throw new InvalidCurrencyException("loanCharge", "attach.to.loan", errorMessage);
}
if(loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()){
PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
if(portfolioAccountData == null){
final String errorMessage = loanCharge.name()+"Charge requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.add", errorMessage,loanCharge.name());
}
if (loanCharge.getChargePaymentMode().isPaymentModeAccountTransfer()) {
final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
if (portfolioAccountData == null) {
final String errorMessage = loanCharge.name() + "Charge requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.add", errorMessage, loanCharge.name());
}
}
final List<Long> existingTransactionIds = new ArrayList<Long>();
@@ -949,7 +947,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Override
@Transactional
public CommandProcessingResult payLoanCharge(final Long loanId, Long loanChargeId, final JsonCommand command,
boolean isChargeIdIncludedInJson) {
final boolean isChargeIdIncludedInJson) {
this.loanEventApiJsonValidator.validateChargePaymentTransaction(command.json(), isChargeIdIncludedInJson);
if (isChargeIdIncludedInJson) {
@@ -978,15 +976,15 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Locale locale = command.extractLocale();
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
if(portfolioAccountData == null){
final String errorMessage = "Charge with id:"+loanChargeId+" requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage,loanChargeId);
final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService.retriveLoanAssociation(loanId);
if (portfolioAccountData == null) {
final String errorMessage = "Charge with id:" + loanChargeId + " requires linked savings account for payment";
throw new LinkedAccountRequiredException("loanCharge.pay", errorMessage, loanChargeId);
}
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, loanCharge.amountOutstanding(),
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, loanCharge.amountOutstanding(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, portfolioAccountData.accountId(), loanId, "Loan Charge Payment",
locale, fmt, null, null, LoanTransactionType.CHARGE_PAYMENT.getValue(), loanChargeId);
accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
@@ -1001,24 +999,24 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Override
@CronTarget(jobName = JobName.TRANSFER_FEE_CHARGE_FOR_LOANS)
public void transferFeeCharges() throws JobExecutionException {
Collection<LoanChargeData> chargeDatas = this.LoanChargeReadPlatformService.retrieveLoanChargesForFeePayment(
final Collection<LoanChargeData> chargeDatas = this.LoanChargeReadPlatformService.retrieveLoanChargesForFeePayment(
ChargePaymentMode.ACCOUNT_TRANSFER.getValue(), LoanStatus.ACTIVE.getValue());
StringBuilder sb = new StringBuilder();
final StringBuilder sb = new StringBuilder();
if (chargeDatas != null) {
for (LoanChargeData chargeData : chargeDatas) {
if (chargeData.getDueDate()!=null && !chargeData.getDueDate().isAfter(new LocalDate())) {
PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService
for (final LoanChargeData chargeData : chargeDatas) {
if (chargeData.getDueDate() != null && !chargeData.getDueDate().isAfter(new LocalDate())) {
final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService
.retriveLoanAssociation(chargeData.getLoanId());
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(), chargeData.getAmountOutstanding(),
final AccountTransferDTO accountTransferDTO = new AccountTransferDTO(new LocalDate(), chargeData.getAmountOutstanding(),
PortfolioAccountType.SAVINGS, PortfolioAccountType.LOAN, portfolioAccountData.accountId(),
chargeData.getLoanId(), "Loan Charge Payment", null, null, null, null,
LoanTransactionType.CHARGE_PAYMENT.getValue(), chargeData.getId());
try {
accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} catch (PlatformApiDataValidationException e) {
this.accountTransfersWritePlatformService.transferFunds(accountTransferDTO);
} catch (final PlatformApiDataValidationException e) {
sb.append("Validation exception while paying charge ").append(chargeData.getId()).append(" for loan id:")
.append(chargeData.getLoanId()).append("--------");
} catch (InsufficientAccountBalanceException e) {
} catch (final InsufficientAccountBalanceException e) {
sb.append("InsufficientAccountBalance Exception while paying charge ").append(chargeData.getId())
.append("for loan id:").append(chargeData.getLoanId()).append("--------");
@@ -1086,7 +1084,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Transactional
@Override
public LoanTransaction withdrawLoanTransfer(Long accountId, LocalDate transferDate) {
public LoanTransaction withdrawLoanTransfer(final Long accountId, final LocalDate transferDate) {
final Loan loan = this.loanAssembler.assembleFrom(accountId);
final List<Long> existingTransactionIds = new ArrayList<Long>(loan.findExistingTransactionIds());
@@ -1106,7 +1104,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Transactional
@Override
public void rejectLoanTransfer(Long accountId) {
public void rejectLoanTransfer(final Long accountId) {
final Loan loan = this.loanAssembler.assembleFrom(accountId);
loan.setLoanStatus(LoanStatus.TRANSFER_ON_HOLD.getValue());
this.loanRepository.save(loan);
@@ -55,6 +55,7 @@ public class SavingsAccountData {
private final SavingsAccountSummaryData summary;
@SuppressWarnings("unused")
private final Collection<SavingsAccountTransactionData> transactions;
@SuppressWarnings("unused")
private final Collection<SavingsAccountChargeData> charges;
// template
@@ -76,7 +77,7 @@ public class SavingsAccountData {
final EnumOptionData interestCalculationType, final EnumOptionData interestCalculationDaysInYearType,
final BigDecimal minRequiredOpeningBalance, final Integer lockinPeriodFrequency,
final EnumOptionData lockinPeriodFrequencyType, final BigDecimal withdrawalFeeAmount, final EnumOptionData withdrawalFeeType,
boolean withdrawalFeeForTransfers, final BigDecimal annualFeeAmount, final MonthDay annualFeeOnMonthDay,
final boolean withdrawalFeeForTransfers, final BigDecimal annualFeeAmount, final MonthDay annualFeeOnMonthDay,
final LocalDate annualFeeNextDueDate, final SavingsAccountSummaryData summary) {
final Collection<SavingsProductData> productOptions = null;
@@ -217,7 +218,7 @@ public class SavingsAccountData {
final Collection<SavingsAccountChargeData> charges = null;
final Collection<ChargeData> chargeOptions = null;
return new SavingsAccountData(id, accountNo, externalId, groupId, groupName, clientId, clientName, productId, productName,
fieldOfficerId, fieldOfficerName, status, timeline, currency, nominalAnnualInterestRate, interestPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
@@ -282,7 +283,7 @@ public class SavingsAccountData {
this.interestCalculationDaysInYearTypeOptions = interestCalculationDaysInYearTypeOptions;
this.lockinPeriodFrequencyTypeOptions = lockinPeriodFrequencyTypeOptions;
this.withdrawalFeeTypeOptions = withdrawalFeeTypeOptions;
this.charges = charges;//charges associated with Savings account
this.chargeOptions = chargeOptions;//charges available for adding to Savings account
}
@@ -313,7 +314,7 @@ public class SavingsAccountData {
if (obj == null) { return false; }
if (obj == this) { return true; }
if (obj.getClass() != getClass()) { return false; }
SavingsAccountData rhs = (SavingsAccountData) obj;
final SavingsAccountData rhs = (SavingsAccountData) obj;
return new EqualsBuilder().append(this.id, rhs.id).append(this.accountNo, rhs.accountNo).isEquals();
}
@@ -7,12 +7,11 @@ package org.mifosplatform.portfolio.savings.domain;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.annualFeeAmountParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.annualFeeOnMonthDayParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.idParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargeIdParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.chargesParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.currencyCodeParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.descriptionParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.digitsAfterDecimalParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.idParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.inMultiplesOfParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.interestCalculationDaysInYearTypeParamName;
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.interestCalculationTypeParamName;
@@ -55,7 +54,7 @@ import com.google.gson.JsonObject;
public class SavingsProductAssembler {
private final ChargeRepositoryWrapper chargeRepository;
@Autowired
public SavingsProductAssembler(final ChargeRepositoryWrapper chargeRepository) {
this.chargeRepository = chargeRepository;
@@ -69,7 +68,7 @@ public class SavingsProductAssembler {
final String currencyCode = command.stringValueOfParameterNamed(currencyCodeParamName);
final Integer digitsAfterDecimal = command.integerValueOfParameterNamed(digitsAfterDecimalParamName);
final Integer inMultiplesOf = command.integerValueOfParameterNamed(inMultiplesOfParamName);
MonetaryCurrency currency = new MonetaryCurrency(currencyCode, digitsAfterDecimal,inMultiplesOf);
final MonetaryCurrency currency = new MonetaryCurrency(currencyCode, digitsAfterDecimal,inMultiplesOf);
final BigDecimal interestRate = command.bigDecimalValueOfParameterNamed(nominalAnnualInterestRateParamName);
@@ -114,7 +113,7 @@ public class SavingsProductAssembler {
if (withdrawalFeeTypeValue != null) {
withdrawalFeeType = SavingsWithdrawalFeesType.fromInt(withdrawalFeeTypeValue);
}
boolean iswithdrawalFeeApplicableForTransfer = false;
if(command.parameterExists(withdrawalFeeForTransfersParamName)){
iswithdrawalFeeApplicableForTransfer = command.booleanPrimitiveValueOfParameterNamed(withdrawalFeeForTransfersParamName);
@@ -123,10 +122,10 @@ public class SavingsProductAssembler {
final BigDecimal annualFeeAmount = command.bigDecimalValueOfParameterNamedDefaultToNullIfZero(annualFeeAmountParamName);
final MonthDay monthDayOfAnnualFee = command.extractMonthDayNamed(annualFeeOnMonthDayParamName);
final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule"));
//Savings product charges
final Set<Charge> charges = this.assembleListOfSavingsProductCharges(command, currencyCode);
final Set<Charge> charges = assembleListOfSavingsProductCharges(command, currencyCode);
return SavingsProduct.createNew(name, description, currency, interestRate, interestCompoundingPeriodType,
interestPostingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance,
lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeAmount, withdrawalFeeType, iswithdrawalFeeApplicableForTransfer,
@@ -136,9 +135,9 @@ public class SavingsProductAssembler {
public Set<Charge> assembleListOfSavingsProductCharges(final JsonCommand command, final String savingsProductCurrencyCode) {
final Set<Charge> charges = new HashSet<Charge>();
if (command.parameterExists(chargesParamName)) {
JsonArray chargesArray = command.arrayOfParameterNamed(chargesParamName);
final JsonArray chargesArray = command.arrayOfParameterNamed(chargesParamName);
if (chargesArray != null) {
for (int i = 0; i < chargesArray.size(); i++) {
@@ -149,12 +148,12 @@ public class SavingsProductAssembler {
final Charge charge = this.chargeRepository.findOneWithNotFoundDetection(id);
if(!charge.isSavingsCharge()){
String errorMessage = "Charge with identifier " + charge.getId() + " cannot be applied to Savings product.";
throw new ChargeCannotBeAppliedToException("savings.product", errorMessage, charge.getId());
final String errorMessage = "Charge with identifier " + charge.getId() + " cannot be applied to Savings product.";
throw new ChargeCannotBeAppliedToException("savings.product", errorMessage, charge.getId());
}
if (!savingsProductCurrencyCode.equals(charge.getCurrencyCode())) {
String errorMessage = "Charge and Savings Product must have the same currency.";
final String errorMessage = "Charge and Savings Product must have the same currency.";
throw new InvalidCurrencyException("charge", "attach.to.savings.product", errorMessage);
}
charges.add(charge);
@@ -173,7 +173,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount");
final Map<String, Object> changes = new LinkedHashMap<String, Object>();
PaymentDetail paymentDetail = paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(account, fmt, transactionDate,
transactionAmount, paymentDetail);
@@ -206,12 +206,12 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
final Map<String, Object> changes = new LinkedHashMap<String, Object>();
PaymentDetail paymentDetail = paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
checkClientOrGroupActive(account);
SavingsAccountTransaction withdrawal = this.savingsAccountDomainService.handleWithdrawal(account, fmt, transactionDate,
final SavingsAccountTransaction withdrawal = this.savingsAccountDomainService.handleWithdrawal(account, fmt, transactionDate,
transactionAmount, paymentDetail, true);
return new CommandProcessingResultBuilder() //
@@ -319,16 +319,16 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
@Override
public CommandProcessingResult undoTransaction(final Long savingsId, final Long transactionId, boolean allowAccountTransferModification) {
public CommandProcessingResult undoTransaction(final Long savingsId, final Long transactionId, final boolean allowAccountTransferModification) {
final List<Long> newTransactionIds = new ArrayList<Long>();
final List<Long> reversedTransactionIds = new ArrayList<Long>();
SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
transactionId, savingsId);
if (savingsAccountTransaction == null) { throw new SavingsAccountTransactionNotFoundException(savingsId, transactionId); }
if(!allowAccountTransferModification && accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.SAVINGS)){
if(!allowAccountTransferModification && this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.SAVINGS)){
throw new PlatformServiceUnavailableException("error.msg.saving.account.transfer.transaction.update.not.allowed","Savings account transaction:"+transactionId+" update not allowed as it involves in account transfer",transactionId);
}
@@ -363,14 +363,14 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
@Override
public CommandProcessingResult adjustSavingsTransaction(final Long savingsId, final Long transactionId, final JsonCommand command) {
SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
final SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
transactionId, savingsId);
if (savingsAccountTransaction == null) { throw new SavingsAccountTransactionNotFoundException(savingsId, transactionId); }
if (!(savingsAccountTransaction.isDeposit() || savingsAccountTransaction.isWithdrawal()) || savingsAccountTransaction.isReversed()) { throw new TransactionUpdateNotAllowedException(
savingsId, transactionId); }
if(accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.SAVINGS)){
if(this.accountTransfersReadPlatformService.isAccountTransfer(transactionId, PortfolioAccountType.SAVINGS)){
throw new PlatformServiceUnavailableException("error.msg.saving.account.transfer.transaction.update.not.allowed","Savings account transaction:"+transactionId+" update not allowed as it involves in account transfer",transactionId);
}
this.savingsAccountTransactionDataValidator.validate(command);
@@ -389,13 +389,13 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final List<Long> existingTransactionIds = new ArrayList<Long>();
final List<Long> existingReversedTransactionIds = new ArrayList<Long>();
final Map<String, Object> changes = new LinkedHashMap<String, Object>();
PaymentDetail paymentDetail = paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
final PaymentDetail paymentDetail = this.paymentDetailWritePlatformService.createAndPersistPaymentDetail(command, changes);
final MathContext mc = new MathContext(10, RoundingMode.HALF_EVEN);
account.undoTransaction(transactionId, existingReversedTransactionIds);
// for undo withdrawal fee
SavingsAccountTransaction nextSavingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
final SavingsAccountTransaction nextSavingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
transactionId+1, savingsId);
if(nextSavingsAccountTransaction!=null && nextSavingsAccountTransaction.isWithdrawalFeeAndNotReversed()){
account.undoTransaction(transactionId+1, existingReversedTransactionIds);
@@ -403,11 +403,11 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
SavingsAccountTransaction transaction = null;
if (savingsAccountTransaction.isDeposit()) {
SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
existingTransactionIds, existingReversedTransactionIds, paymentDetail);
transaction = account.deposit(transactionDTO);
} else {
SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
existingTransactionIds, existingReversedTransactionIds, paymentDetail);
transaction = account.withdraw(transactionDTO, true);
}
@@ -433,9 +433,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
/**
*
*
*/
private void throwValidationForActiveStatus(String actionName) {
private void throwValidationForActiveStatus(final String actionName) {
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
.resource(SAVINGS_ACCOUNT_RESOURCE_NAME + actionName);
@@ -451,7 +451,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
final Map<String, Object> accountingBridgeData = savingsAccount.deriveAccountingBridgeData(applicationCurrency.toData(),
existingTransactionIds, existingReversedTransactionIds);
journalEntryWritePlatformService.createJournalEntriesForSavings(accountingBridgeData);
this.journalEntryWritePlatformService.createJournalEntriesForSavings(accountingBridgeData);
}
private void checkClientOrGroupActive(final SavingsAccount account) {
@@ -466,17 +466,17 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
@Override
public CommandProcessingResult close(Long savingsId, JsonCommand command) {
public CommandProcessingResult close(final Long savingsId, final JsonCommand command) {
final AppUser user = this.context.authenticatedUser();
this.savingsAccountTransactionDataValidator.validateClosing(command);
final SavingsAccount account = this.savingAccountAssembler.assembleFrom(savingsId);
final boolean isLinkedWithAnyActiveLoan = accountAssociationsReadPlatformService.isLinkedWithAnyActiveLoan(savingsId);
final boolean isLinkedWithAnyActiveLoan = this.accountAssociationsReadPlatformService.isLinkedWithAnyActiveLoan(savingsId);
if(isLinkedWithAnyActiveLoan){
String defaultUserMessage = "Closing savings account with id:"+savingsId+" is not allowed, since it is linked with one of the active loans";
final String defaultUserMessage = "Closing savings account with id:"+savingsId+" is not allowed, since it is linked with one of the active loans";
throw new SavingsAccountClosingNotAllowedException("linked", defaultUserMessage, savingsId);
}
final Map<String, Object> changes = account.close(user, command, DateUtils.getLocalDateOfTenant());
if (!changes.isEmpty()) {
this.savingAccountRepository.save(account);
@@ -499,7 +499,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
@Override
public SavingsAccountTransaction initiateSavingsTransfer(Long accountId, LocalDate transferDate) {
public SavingsAccountTransaction initiateSavingsTransfer(final Long accountId, final LocalDate transferDate) {
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
final List<Long> existingTransactionIds = new ArrayList<Long>(savingsAccount.findExistingTransactionIds());
@@ -519,7 +519,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
@Override
public SavingsAccountTransaction withdrawSavingsTransfer(Long accountId, LocalDate transferDate) {
public SavingsAccountTransaction withdrawSavingsTransfer(final Long accountId, final LocalDate transferDate) {
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
final List<Long> existingTransactionIds = new ArrayList<Long>(savingsAccount.findExistingTransactionIds());
@@ -539,15 +539,15 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
}
@Override
public void rejectSavingsTransfer(Long accountId) {
public void rejectSavingsTransfer(final Long accountId) {
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_ON_HOLD.getValue());
this.savingAccountRepository.save(savingsAccount);
}
@Override
public SavingsAccountTransaction acceptSavingsTransfer(Long accountId, LocalDate transferDate, Office acceptedInOffice,
Staff fieldOfficer) {
public SavingsAccountTransaction acceptSavingsTransfer(final Long accountId, final LocalDate transferDate, final Office acceptedInOffice,
final Staff fieldOfficer) {
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(accountId);
final List<Long> existingTransactionIds = new ArrayList<Long>(savingsAccount.findExistingTransactionIds());
@@ -568,7 +568,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
return acceptTransferTransaction;
}
@Transactional
@Override
public CommandProcessingResult addSavingsAccountCharge(final JsonCommand command) {
@@ -581,14 +581,14 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
checkClientOrGroupActive(savingsAccount);
final DateTimeFormatter fmt = DateTimeFormat.forPattern("dd MM yyyy");
final Long chargeDefinitionId = command.longValueOfParameterNamed(chargeIdParamName);
final Charge chargeDefinition = this.chargeRepository.findOneWithNotFoundDetection(chargeDefinitionId);
final SavingsAccountCharge savingsAccountCharge = SavingsAccountCharge.createNewFromJson(savingsAccount, chargeDefinition, command);
savingsAccount.addCharge(fmt, savingsAccountCharge, chargeDefinition);
this.savingAccountRepository.saveAndFlush(savingsAccount);
return new CommandProcessingResultBuilder() //
@@ -603,16 +603,16 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
@Transactional
@Override
public CommandProcessingResult updateSavingsAccountCharge(JsonCommand command) {
public CommandProcessingResult updateSavingsAccountCharge(final JsonCommand command) {
this.context.authenticatedUser();
this.savingsAccountChargeDataValidator.validateUpdate(command.json());
final Long savingsAccountId = command.getSavingsId();
final Long savingsChargeId = command.entityId();//SavingsAccount Charge entity
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(savingsAccountId);
checkClientOrGroupActive(savingsAccount);
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(savingsChargeId, savingsAccountId);
final Map<String, Object> changes = savingsAccountCharge.update(command);
this.savingsAccountChargeRepository.saveAndFlush(savingsAccountCharge);
@@ -634,24 +634,24 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
.with(changes) //
.build();
}
@Transactional
@Override
public CommandProcessingResult waiveCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command) {
public CommandProcessingResult waiveCharge(final Long savingsAccountId, final Long savingsAccountChargeId, final JsonCommand command) {
this.context.authenticatedUser();
final List<Long> existingTransactionIds = new ArrayList<Long>();
final List<Long> existingReversedTransactionIds = new ArrayList<Long>();
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(savingsAccountId);
checkClientOrGroupActive(savingsAccount);
savingsAccount.waiveCharge(savingsAccountChargeId, existingTransactionIds, existingReversedTransactionIds);
this.savingAccountRepository.saveAndFlush(savingsAccount);
return new CommandProcessingResultBuilder() //
.withCommandId(command.commandId()) //
.withEntityId(savingsAccountChargeId) //
@@ -664,18 +664,18 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
@Transactional
@Override
public CommandProcessingResult deleteSavingsAccountCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command) {
public CommandProcessingResult deleteSavingsAccountCharge(final Long savingsAccountId, final Long savingsAccountChargeId, @SuppressWarnings("unused") final JsonCommand command) {
this.context.authenticatedUser();
final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(savingsAccountId);
checkClientOrGroupActive(savingsAccount);
final SavingsAccountCharge savingsAccountCharge = this.savingsAccountChargeRepository.findOneWithNotFoundDetection(savingsAccountChargeId, savingsAccountId);
//TODO AA: validate before deleting a charge
savingsAccount.removeCharge(savingsAccountCharge);
this.savingAccountRepository.saveAndFlush(savingsAccount);
return new CommandProcessingResultBuilder() //
.withEntityId(savingsAccountChargeId) //
.withOfficeId(savingsAccount.officeId()) //
@@ -687,7 +687,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
@Transactional
@Override
public CommandProcessingResult payCharge(Long savingsAccountId, Long savingsAccountChargeId, JsonCommand command) {
public CommandProcessingResult payCharge(final Long savingsAccountId, final Long savingsAccountChargeId, final JsonCommand command) {
this.context.authenticatedUser();
final List<Long> existingTransactionIds = new ArrayList<Long>();
@@ -711,5 +711,5 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
.build();
}
}
@@ -29,7 +29,6 @@ import org.mifosplatform.organisation.monetary.domain.ApplicationCurrencyReposit
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
import org.mifosplatform.organisation.staff.domain.Staff;
import org.mifosplatform.organisation.staff.domain.StaffRepositoryWrapper;
import org.mifosplatform.portfolio.charge.domain.Charge;
import org.mifosplatform.portfolio.client.domain.AccountNumberGenerator;
import org.mifosplatform.portfolio.client.domain.AccountNumberGeneratorFactory;
import org.mifosplatform.portfolio.client.domain.Client;
@@ -232,11 +231,11 @@ public class SavingsApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
}
account.update(fieldOfficer);
}
if (changes.containsKey("charges")) {
//final Set<Charge> savingsProductCharges = this.savi.assembleListOfSavingsProductCharges(command, product.currency().getCode());
final Set<SavingsAccountCharge> charges = this.savingsAccountChargeAssembler.fromParsedJson(command.parsedJson());
boolean updated = account.update(charges);
final boolean updated = account.update(charges);
if (!updated) {
changes.remove("charges");
}
@@ -17,7 +17,6 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
import org.mifosplatform.organisation.monetary.data.CurrencyData;
import org.mifosplatform.portfolio.charge.data.ChargeData;
import org.mifosplatform.portfolio.savings.data.SavingsProductData;
import org.mifosplatform.portfolio.savings.exception.SavingsProductNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
@@ -37,7 +36,7 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
@Autowired
public SavingsProductReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource) {
this.context = context;
jdbcTemplate = new JdbcTemplate(dataSource);
this.jdbcTemplate = new JdbcTemplate(dataSource);
}
@Override
@@ -45,26 +44,26 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
this.context.authenticatedUser();
final String sql = "select " + savingsProductRowMapper.schema();
final String sql = "select " + this.savingsProductRowMapper.schema();
return this.jdbcTemplate.query(sql, savingsProductRowMapper);
return this.jdbcTemplate.query(sql, this.savingsProductRowMapper);
}
@Override
public Collection<SavingsProductData> retrieveAllForLookup() {
final String sql = "select " + savingsProductLookupsRowMapper.schema();
final String sql = "select " + this.savingsProductLookupsRowMapper.schema();
return this.jdbcTemplate.query(sql, savingsProductLookupsRowMapper);
return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper);
}
@Override
public SavingsProductData retrieveOne(final Long savingProductId) {
try {
this.context.authenticatedUser();
final String sql = "select " + savingsProductRowMapper.schema() + " where sp.id = ?";
return this.jdbcTemplate.queryForObject(sql, savingsProductRowMapper, new Object[] { savingProductId });
} catch (EmptyResultDataAccessException e) {
final String sql = "select " + this.savingsProductRowMapper.schema() + " where sp.id = ?";
return this.jdbcTemplate.queryForObject(sql, this.savingsProductRowMapper, new Object[] { savingProductId });
} catch (final EmptyResultDataAccessException e) {
throw new SavingsProductNotFoundException(savingProductId);
}
}
@@ -108,29 +107,29 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
@Override
public SavingsProductData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
Long id = rs.getLong("id");
String name = rs.getString("name");
String description = rs.getString("description");
final Long id = rs.getLong("id");
final String name = rs.getString("name");
final String description = rs.getString("description");
String currencyCode = rs.getString("currencyCode");
String currencyName = rs.getString("currencyName");
String currencyNameCode = rs.getString("currencyNameCode");
String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
final String currencyCode = rs.getString("currencyCode");
final String currencyName = rs.getString("currencyName");
final String currencyNameCode = rs.getString("currencyNameCode");
final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf");
final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf,
currencyDisplaySymbol, currencyNameCode);
final BigDecimal nominalAnnualInterestRate = rs.getBigDecimal("nominalAnnualInterestRate");
final Integer compoundingInterestPeriodTypeValue = JdbcSupport.getInteger(rs, "compoundingInterestPeriodType");
EnumOptionData compoundingInterestPeriodType = SavingsEnumerations
final EnumOptionData compoundingInterestPeriodType = SavingsEnumerations
.compoundingInterestPeriodType(compoundingInterestPeriodTypeValue);
final Integer interestPostingPeriodTypeValue = JdbcSupport.getInteger(rs, "interestPostingPeriodType");
EnumOptionData interestPostingPeriodType = SavingsEnumerations.interestPostingPeriodType(interestPostingPeriodTypeValue);
final EnumOptionData interestPostingPeriodType = SavingsEnumerations.interestPostingPeriodType(interestPostingPeriodTypeValue);
final Integer interestCalculationTypeValue = JdbcSupport.getInteger(rs, "interestCalculationType");
EnumOptionData interestCalculationType = SavingsEnumerations.interestCalculationType(interestCalculationTypeValue);
final EnumOptionData interestCalculationType = SavingsEnumerations.interestCalculationType(interestCalculationTypeValue);
EnumOptionData interestCalculationDaysInYearType = null;
final Integer interestCalculationDaysInYearTypeValue = JdbcSupport.getInteger(rs, "interestCalculationDaysInYearType");
@@ -144,7 +143,7 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
final BigDecimal minRequiredOpeningBalance = rs.getBigDecimal("minRequiredOpeningBalance");
Integer lockinPeriodFrequency = JdbcSupport.getInteger(rs, "lockinPeriodFrequency");
final Integer lockinPeriodFrequency = JdbcSupport.getInteger(rs, "lockinPeriodFrequency");
EnumOptionData lockinPeriodFrequencyType = null;
final Integer lockinPeriodFrequencyTypeValue = JdbcSupport.getInteger(rs, "lockinPeriodFrequencyType");
if (lockinPeriodFrequencyTypeValue != null) {
@@ -158,7 +157,7 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead
if (withdrawalFeeTypeValue != null) {
withdrawalFeeType = SavingsEnumerations.withdrawalFeeType(withdrawalFeeTypeValue);
}
final boolean withdrawalFeeForTransfers = rs.getBoolean("withdrawalFeeForTransfers");
final BigDecimal annualFeeAmount = JdbcSupport.getBigDecimalDefaultToNullIfZero(rs, "annualFeeAmount");