+3
@@ -6,6 +6,7 @@
|
||||
package org.mifosplatform.portfolio.account.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.service.Page;
|
||||
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
||||
import org.mifosplatform.portfolio.account.data.AccountTransferData;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
|
||||
@@ -17,4 +18,6 @@ public interface AccountTransfersReadPlatformService {
|
||||
Page<AccountTransferData> retrieveAll(SearchParameters searchParameters);
|
||||
|
||||
AccountTransferData retrieveOne(Long transferId);
|
||||
|
||||
boolean isAccountTransfer(Long transactionId,PortfolioAccountType accountType);
|
||||
}
|
||||
+28
-3
@@ -247,6 +247,7 @@ public class AccountTransfersReadPlatformServiceImpl implements AccountTransfers
|
||||
sqlBuilder.append("fromclient.id as fromClientId, fromclient.display_name as fromClientName,");
|
||||
sqlBuilder.append("toclient.id as toClientId, toclient.display_name as toClientName,");
|
||||
sqlBuilder.append("fromsavacc.id as fromSavingsAccountId, fromsavacc.account_no as fromSavingsAccountNo,");
|
||||
sqlBuilder.append("fromloanacc.id as fromLoanAccountId, fromloanacc.account_no as fromLoanAccountNo,");
|
||||
sqlBuilder.append("tosavacc.id as toSavingsAccountId, tosavacc.account_no as toSavingsAccountNo,");
|
||||
sqlBuilder.append("toloanacc.id as toLoanAccountId, toloanacc.account_no as toLoanAccountNo,");
|
||||
sqlBuilder.append("fromsavtran.id as fromSavingsAccountTransactionId,");
|
||||
@@ -260,6 +261,7 @@ public class AccountTransfersReadPlatformServiceImpl implements AccountTransfers
|
||||
sqlBuilder.append("join m_client fromclient on fromclient.id = sat.from_client_id ");
|
||||
sqlBuilder.append("join m_client toclient on toclient.id = sat.to_client_id ");
|
||||
sqlBuilder.append("left join m_savings_account fromsavacc on fromsavacc.id = sat.from_savings_account_id ");
|
||||
sqlBuilder.append("left join m_savings_account fromloanacc on fromloanacc.id = sat.from_loan_account_id ");
|
||||
sqlBuilder.append("left join m_savings_account tosavacc on tosavacc.id = sat.to_savings_account_id ");
|
||||
sqlBuilder.append("left join m_loan toloanacc on toloanacc.id = sat.to_loan_account_id ");
|
||||
sqlBuilder.append("left join m_savings_account_transaction fromsavtran on fromsavtran.id = sat.from_savings_transaction_id ");
|
||||
@@ -307,11 +309,20 @@ public class AccountTransfersReadPlatformServiceImpl implements AccountTransfers
|
||||
final String toClientName = rs.getString("toClientName");
|
||||
final ClientData toClient = ClientData.lookup(toClientId, toClientName, toOfficeId, toOfficeName);
|
||||
|
||||
final EnumOptionData fromAccountType = AccountTransferEnumerations.accountType(PortfolioAccountType.SAVINGS);
|
||||
|
||||
final Long fromSavingsAccountId = JdbcSupport.getLong(rs, "fromSavingsAccountId");
|
||||
final String fromSavingsAccountNo = rs.getString("fromSavingsAccountNo");
|
||||
final PortfolioAccountData fromSavingsAccount = PortfolioAccountData.lookup(fromSavingsAccountId, fromSavingsAccountNo);
|
||||
final Long fromLoanAccountId = JdbcSupport.getLong(rs, "fromLoanAccountId");
|
||||
final String fromLoanAccountNo = rs.getString("fromLoanAccountNo");
|
||||
PortfolioAccountData fromAccount = null;
|
||||
EnumOptionData fromAccountType = null;
|
||||
if(fromSavingsAccountId != null){
|
||||
fromAccount = PortfolioAccountData.lookup(fromSavingsAccountId, fromSavingsAccountNo);
|
||||
fromAccountType = AccountTransferEnumerations.accountType(PortfolioAccountType.SAVINGS);
|
||||
}else if(fromLoanAccountId != null){
|
||||
fromAccount = PortfolioAccountData.lookup(fromLoanAccountId, fromLoanAccountNo);
|
||||
fromAccountType = AccountTransferEnumerations.accountType(PortfolioAccountType.LOAN);
|
||||
}
|
||||
|
||||
PortfolioAccountData toAccount = null;
|
||||
EnumOptionData toAccountType = null;
|
||||
@@ -329,7 +340,21 @@ public class AccountTransfersReadPlatformServiceImpl implements AccountTransfers
|
||||
}
|
||||
|
||||
return AccountTransferData.instance(id, reversed, transferDate, currency, transferAmount, transferDescription, fromOffice,
|
||||
toOffice, fromClient, toClient, fromAccountType, fromSavingsAccount, toAccountType, toAccount);
|
||||
toOffice, fromClient, toClient, fromAccountType, fromAccount, toAccountType, toAccount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountTransfer(Long transactionId, PortfolioAccountType accountType) {
|
||||
StringBuilder sql = new StringBuilder("select count(*) from m_savings_account_transfer at where ");
|
||||
if (accountType.isLoanAccount()) {
|
||||
sql.append("at.from_loan_transaction_id=").append(transactionId).append(" or at.to_loan_transaction_id=").append(transactionId);
|
||||
} else {
|
||||
sql.append("at.from_savings_transaction_id=").append(transactionId).append(" or at.to_savings_transaction_id=").append(transactionId);
|
||||
}
|
||||
|
||||
int count = this.jdbcTemplate.queryForInt(sql.toString());
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
}
|
||||
+8
-4
@@ -11,6 +11,7 @@ import java.util.Collection;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||
import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.portfolio.account.data.AccountTransferData;
|
||||
import org.mifosplatform.portfolio.paymentdetail.data.PaymentDetailData;
|
||||
|
||||
/**
|
||||
@@ -35,6 +36,7 @@ public class LoanTransactionData {
|
||||
private final BigDecimal feeChargesPortion;
|
||||
private final BigDecimal penaltyChargesPortion;
|
||||
private final String externalId;
|
||||
private final AccountTransferData transfer;
|
||||
|
||||
// templates
|
||||
final Collection<CodeValueData> paymentTypeOptions;
|
||||
@@ -44,21 +46,22 @@ public class LoanTransactionData {
|
||||
loanTransactionData.type, loanTransactionData.paymentDetailData, loanTransactionData.currency, loanTransactionData.date,
|
||||
loanTransactionData.amount, loanTransactionData.principalPortion, loanTransactionData.interestPortion,
|
||||
loanTransactionData.feeChargesPortion, loanTransactionData.penaltyChargesPortion, paymentTypeOptions,
|
||||
loanTransactionData.externalId);
|
||||
loanTransactionData.externalId,loanTransactionData.transfer);
|
||||
}
|
||||
|
||||
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
|
||||
final PaymentDetailData paymentDetailData, final CurrencyData currency, final LocalDate date, final BigDecimal amount,
|
||||
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
|
||||
final BigDecimal penaltyChargesPortion, final String externalId) {
|
||||
final BigDecimal penaltyChargesPortion, final String externalId, AccountTransferData transfer) {
|
||||
this(id, officeId, officeName, transactionType, paymentDetailData, currency, date, amount, principalPortion, interestPortion,
|
||||
feeChargesPortion, penaltyChargesPortion, null, externalId);
|
||||
feeChargesPortion, penaltyChargesPortion, null, externalId,transfer);
|
||||
}
|
||||
|
||||
public LoanTransactionData(final Long id, final Long officeId, final String officeName, final LoanTransactionEnumData transactionType,
|
||||
final PaymentDetailData paymentDetailData, final CurrencyData currency, final LocalDate date, final BigDecimal amount,
|
||||
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
|
||||
final BigDecimal penaltyChargesPortion, final Collection<CodeValueData> paymentTypeOptions, final String externalId) {
|
||||
final BigDecimal penaltyChargesPortion, final Collection<CodeValueData> paymentTypeOptions, final String externalId,
|
||||
final AccountTransferData transfer) {
|
||||
this.id = id;
|
||||
this.officeId = officeId;
|
||||
this.officeName = officeName;
|
||||
@@ -73,6 +76,7 @@ public class LoanTransactionData {
|
||||
this.penaltyChargesPortion = penaltyChargesPortion;
|
||||
this.paymentTypeOptions = paymentTypeOptions;
|
||||
this.externalId = externalId;
|
||||
this.transfer = transfer;
|
||||
}
|
||||
|
||||
public LocalDate dateOf() {
|
||||
|
||||
+3
-2
@@ -32,6 +32,7 @@ import org.mifosplatform.organisation.monetary.data.CurrencyData;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
import org.mifosplatform.organisation.office.domain.Office;
|
||||
import org.mifosplatform.portfolio.account.data.AccountTransferData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionEnumData;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
@@ -395,7 +396,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
||||
return result;
|
||||
}
|
||||
|
||||
public LoanTransactionData toData(final CurrencyData currencyData) {
|
||||
public LoanTransactionData toData(final CurrencyData currencyData,final AccountTransferData transfer) {
|
||||
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(this.typeOf);
|
||||
PaymentDetailData paymentDetailData = null;
|
||||
if (this.paymentDetail != null) {
|
||||
@@ -403,7 +404,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
||||
}
|
||||
return new LoanTransactionData(this.getId(), this.office.getId(), this.office.getName(), transactionType, paymentDetailData,
|
||||
currencyData, getTransactionDate(), this.amount, this.principalPortion, this.interestPortion, this.feeChargesPortion,
|
||||
this.penaltyChargesPortion, this.externalId);
|
||||
this.penaltyChargesPortion, this.externalId, transfer);
|
||||
}
|
||||
|
||||
public Map<String, Object> toMapData(final CurrencyData currencyData) {
|
||||
|
||||
+100
-9
@@ -31,6 +31,7 @@ import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
import org.mifosplatform.organisation.staff.data.StaffData;
|
||||
import org.mifosplatform.organisation.staff.service.StaffReadPlatformService;
|
||||
import org.mifosplatform.portfolio.account.data.AccountTransferData;
|
||||
import org.mifosplatform.portfolio.accountdetails.service.AccountEnumerations;
|
||||
import org.mifosplatform.portfolio.calendar.data.CalendarData;
|
||||
import org.mifosplatform.portfolio.calendar.domain.CalendarEntityType;
|
||||
@@ -329,7 +330,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final Collection<CodeValueData> paymentOptions = codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
|
||||
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate,
|
||||
possibleNextRepaymentAmount.getAmount(), null, null, null, null, paymentOptions, null);
|
||||
possibleNextRepaymentAmount.getAmount(), null, null, null, null, paymentOptions, null,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -353,7 +354,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
final BigDecimal amount = waiveOfInterest.getAmount(currency).getAmount();
|
||||
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, waiveOfInterest.getTransactionDate(), amount,
|
||||
null, null, null, null, null);
|
||||
null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -363,7 +364,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.WRITEOFF);
|
||||
return new LoanTransactionData(null, null, null, transactionType, null, null, DateUtils.getLocalDateOfTenant(), null, null, null,
|
||||
null, null, null);
|
||||
null, null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,7 +375,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final Collection<CodeValueData> paymentOptions = codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode(PaymentDetailConstants.paymentTypeCodeName);
|
||||
return new LoanTransactionData(null, null, null, transactionType, null, null, loan.getExpectedDisbursedOnLocalDate(), null, null,
|
||||
null, null, null, paymentOptions, null);
|
||||
null, null, null, paymentOptions, null,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -393,8 +394,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
if (transaction == null) { throw new LoanTransactionNotFoundException(transactionId); }
|
||||
|
||||
if (transaction.isNotBelongingToLoanOf(loan)) { throw new LoanTransactionNotFoundException(transactionId, loanId); }
|
||||
|
||||
return transaction.toData(currencyData);
|
||||
|
||||
LoanTransactionsAccountTransferMapper trasfermapper = new LoanTransactionsAccountTransferMapper();
|
||||
String sql = "select "
|
||||
+ trasfermapper.accountTransferSchema()
|
||||
+ " where tr.loan_id = ? and tr.id = ?";
|
||||
AccountTransferData accountTransferData = this.jdbcTemplate.queryForObject(sql, trasfermapper, loanId, transactionId);
|
||||
return transaction.toData(currencyData,accountTransferData);
|
||||
}
|
||||
|
||||
private static final class LoanMapper implements RowMapper<LoanAccountData> {
|
||||
@@ -861,12 +867,20 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, "
|
||||
+ " l.currency_code as currencyCode, l.currency_digits as currencyDigits, l.currency_multiplesof as inMultiplesOf, rc.`name` as currencyName, "
|
||||
+ " rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code as currencyNameCode, "
|
||||
+ " cv.code_value as paymentTypeName, tr.external_id as externalId, tr.office_id as officeId, office.name as officeName "
|
||||
+ " cv.code_value as paymentTypeName, tr.external_id as externalId, tr.office_id as officeId, office.name as officeName, "
|
||||
+ " fromtran.id as fromTransferId, fromtran.is_reversed as fromTransferReversed,"
|
||||
+ " fromtran.transaction_date as fromTransferDate, fromtran.amount as fromTransferAmount,"
|
||||
+ " fromtran.description as fromTransferDescription,"
|
||||
+ " totran.id as toTransferId, totran.is_reversed as toTransferReversed,"
|
||||
+ " totran.transaction_date as toTransferDate, totran.amount as toTransferAmount,"
|
||||
+ " totran.description as toTransferDescription "
|
||||
+ " from m_loan l join m_loan_transaction tr on tr.loan_id = l.id"
|
||||
+ " join m_currency rc on rc.`code` = l.currency_code "
|
||||
+ " left JOIN m_payment_detail pd ON tr.payment_detail_id = pd.id"
|
||||
+ " left join m_code_value cv on pd.payment_type_cv_id = cv.id"
|
||||
+ " left join m_office office on office.id=tr.office_id";
|
||||
+ " left join m_office office on office.id=tr.office_id"
|
||||
+ " left join m_savings_account_transfer fromtran on fromtran.from_loan_transaction_id = tr.id "
|
||||
+ " left join m_savings_account_transfer totran on totran.to_loan_transaction_id = tr.id ";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -910,12 +924,89 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final BigDecimal feeChargesPortion = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "fees");
|
||||
final BigDecimal penaltyChargesPortion = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "penalties");
|
||||
final String externalId = rs.getString("externalId");
|
||||
|
||||
AccountTransferData transfer = null;
|
||||
final Long fromTransferId = JdbcSupport.getLong(rs, "fromTransferId");
|
||||
final Long toTransferId = JdbcSupport.getLong(rs, "toTransferId");
|
||||
if (fromTransferId != null) {
|
||||
final LocalDate fromTransferDate = JdbcSupport.getLocalDate(rs, "fromTransferDate");
|
||||
final BigDecimal fromTransferAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "fromTransferAmount");
|
||||
final boolean fromTransferReversed = rs.getBoolean("fromTransferReversed");
|
||||
final String fromTransferDescription = rs.getString("fromTransferDescription");
|
||||
|
||||
transfer = AccountTransferData.transferBasicDetails(fromTransferId, currencyData, fromTransferAmount, fromTransferDate,
|
||||
fromTransferDescription, fromTransferReversed);
|
||||
} else if (toTransferId != null) {
|
||||
final LocalDate toTransferDate = JdbcSupport.getLocalDate(rs, "toTransferDate");
|
||||
final BigDecimal toTransferAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "toTransferAmount");
|
||||
final boolean toTransferReversed = rs.getBoolean("toTransferReversed");
|
||||
final String toTransferDescription = rs.getString("toTransferDescription");
|
||||
|
||||
transfer = AccountTransferData.transferBasicDetails(toTransferId, currencyData, toTransferAmount, toTransferDate,
|
||||
toTransferDescription, toTransferReversed);
|
||||
}
|
||||
|
||||
|
||||
return new LoanTransactionData(id, officeId, officeName, transactionType, paymentDetailData, currencyData, date, totalAmount,
|
||||
principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, externalId);
|
||||
principalPortion, interestPortion, feeChargesPortion, penaltyChargesPortion, externalId, transfer);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class LoanTransactionsAccountTransferMapper implements RowMapper<AccountTransferData> {
|
||||
|
||||
public String accountTransferSchema() {
|
||||
|
||||
return " l.currency_code as currencyCode, l.currency_digits as currencyDigits, l.currency_multiplesof as inMultiplesOf, rc.`name` as currencyName, "
|
||||
+ " rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code as currencyNameCode, "
|
||||
+ " fromtran.id as fromTransferId, fromtran.is_reversed as fromTransferReversed,"
|
||||
+ " fromtran.transaction_date as fromTransferDate, fromtran.amount as fromTransferAmount,"
|
||||
+ " fromtran.description as fromTransferDescription,"
|
||||
+ " totran.id as toTransferId, totran.is_reversed as toTransferReversed,"
|
||||
+ " totran.transaction_date as toTransferDate, totran.amount as toTransferAmount,"
|
||||
+ " totran.description as toTransferDescription "
|
||||
+ " from m_loan l join m_loan_transaction tr on tr.loan_id = l.id"
|
||||
+ " join m_currency rc on rc.`code` = l.currency_code "
|
||||
+ " left join m_savings_account_transfer fromtran on fromtran.from_loan_transaction_id = tr.id "
|
||||
+ " left join m_savings_account_transfer totran on totran.to_loan_transaction_id = tr.id ";
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountTransferData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||
|
||||
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 currencyData = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf,
|
||||
currencyDisplaySymbol, currencyNameCode);
|
||||
|
||||
AccountTransferData transfer = null;
|
||||
final Long fromTransferId = JdbcSupport.getLong(rs, "fromTransferId");
|
||||
final Long toTransferId = JdbcSupport.getLong(rs, "toTransferId");
|
||||
if (fromTransferId != null) {
|
||||
final LocalDate fromTransferDate = JdbcSupport.getLocalDate(rs, "fromTransferDate");
|
||||
final BigDecimal fromTransferAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "fromTransferAmount");
|
||||
final boolean fromTransferReversed = rs.getBoolean("fromTransferReversed");
|
||||
final String fromTransferDescription = rs.getString("fromTransferDescription");
|
||||
|
||||
transfer = AccountTransferData.transferBasicDetails(fromTransferId, currencyData, fromTransferAmount, fromTransferDate,
|
||||
fromTransferDescription, fromTransferReversed);
|
||||
} else if (toTransferId != null) {
|
||||
final LocalDate toTransferDate = JdbcSupport.getLocalDate(rs, "toTransferDate");
|
||||
final BigDecimal toTransferAmount = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "toTransferAmount");
|
||||
final boolean toTransferReversed = rs.getBoolean("toTransferReversed");
|
||||
final String toTransferDescription = rs.getString("toTransferDescription");
|
||||
|
||||
transfer = AccountTransferData.transferBasicDetails(toTransferId, currencyData, toTransferAmount, toTransferDate,
|
||||
toTransferDescription, toTransferReversed);
|
||||
}
|
||||
return transfer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public LoanAccountData retrieveLoanProductDetailsTemplate(final Long productId) {
|
||||
|
||||
|
||||
+10
-1
@@ -21,6 +21,7 @@ import org.mifosplatform.infrastructure.configuration.domain.ConfigurationDomain
|
||||
import org.mifosplatform.infrastructure.core.api.JsonCommand;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformServiceUnavailableException;
|
||||
import org.mifosplatform.infrastructure.jobs.annotation.CronTarget;
|
||||
import org.mifosplatform.infrastructure.jobs.service.JobName;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
@@ -35,6 +36,7 @@ import org.mifosplatform.organisation.staff.domain.Staff;
|
||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDays;
|
||||
import org.mifosplatform.organisation.workingdays.domain.WorkingDaysRepositoryWrapper;
|
||||
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
||||
import org.mifosplatform.portfolio.account.service.AccountTransfersReadPlatformService;
|
||||
import org.mifosplatform.portfolio.account.service.AccountTransfersWritePlatformService;
|
||||
import org.mifosplatform.portfolio.accountdetails.domain.AccountType;
|
||||
import org.mifosplatform.portfolio.calendar.domain.Calendar;
|
||||
@@ -115,6 +117,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
private final WorkingDaysRepositoryWrapper workingDaysRepository;
|
||||
private final LoanProductReadPlatformService loanProductReadPlatformService;
|
||||
private final AccountTransfersWritePlatformService accountTransfersWritePlatformService;
|
||||
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public LoanWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||
@@ -129,7 +132,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
final PaymentDetailWritePlatformService paymentDetailWritePlatformService, final HolidayRepository holidayRepository,
|
||||
final ConfigurationDomainService configurationDomainService, final WorkingDaysRepositoryWrapper workingDaysRepository,
|
||||
final LoanProductReadPlatformService loanProductReadPlatformService,
|
||||
final AccountTransfersWritePlatformService accountTransfersWritePlatformService) {
|
||||
final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
|
||||
final AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
|
||||
this.context = context;
|
||||
this.loanEventApiJsonValidator = loanEventApiJsonValidator;
|
||||
this.loanAssembler = loanAssembler;
|
||||
@@ -150,6 +154,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
this.workingDaysRepository = workingDaysRepository;
|
||||
this.loanProductReadPlatformService = loanProductReadPlatformService;
|
||||
this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
|
||||
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
|
||||
}
|
||||
|
||||
private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
|
||||
@@ -428,6 +433,10 @@ 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("error.msg.loan.transfer.transaction.update.not.allowed","Loan transaction:"+transactionId+" update not allowed as it involves in account transfer",transactionId);
|
||||
}
|
||||
|
||||
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
|
||||
final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount");
|
||||
|
||||
+16
-2
@@ -27,6 +27,7 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
||||
import org.mifosplatform.infrastructure.core.data.CommandProcessingResultBuilder;
|
||||
import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformServiceUnavailableException;
|
||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
import org.mifosplatform.infrastructure.jobs.annotation.CronTarget;
|
||||
import org.mifosplatform.infrastructure.jobs.service.JobName;
|
||||
@@ -34,6 +35,8 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext
|
||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrencyRepositoryWrapper;
|
||||
import org.mifosplatform.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
||||
import org.mifosplatform.portfolio.account.service.AccountTransfersReadPlatformService;
|
||||
import org.mifosplatform.portfolio.client.domain.Client;
|
||||
import org.mifosplatform.portfolio.client.exception.ClientNotActiveException;
|
||||
import org.mifosplatform.portfolio.group.domain.Group;
|
||||
@@ -72,6 +75,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
private final JournalEntryWritePlatformService journalEntryWritePlatformService;
|
||||
private final SavingsAccountDomainService savingsAccountDomainService;
|
||||
private final NoteRepository noteRepository;
|
||||
private final AccountTransfersReadPlatformService accountTransfersReadPlatformService;
|
||||
|
||||
@Autowired
|
||||
public SavingsAccountWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context,
|
||||
@@ -82,7 +86,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
final PaymentDetailWritePlatformService paymentDetailWritePlatformService,
|
||||
final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepositoryWrapper,
|
||||
final JournalEntryWritePlatformService journalEntryWritePlatformService,
|
||||
final SavingsAccountDomainService savingsAccountDomainService, final NoteRepository noteRepository) {
|
||||
final SavingsAccountDomainService savingsAccountDomainService, final NoteRepository noteRepository,
|
||||
final AccountTransfersReadPlatformService accountTransfersReadPlatformService) {
|
||||
this.context = context;
|
||||
this.savingAccountRepository = savingAccountRepository;
|
||||
this.savingsAccountTransactionRepository = savingsAccountTransactionRepository;
|
||||
@@ -93,6 +98,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
this.journalEntryWritePlatformService = journalEntryWritePlatformService;
|
||||
this.savingsAccountDomainService = savingsAccountDomainService;
|
||||
this.noteRepository = noteRepository;
|
||||
this.accountTransfersReadPlatformService = accountTransfersReadPlatformService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@@ -299,6 +305,10 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
SavingsAccountTransaction savingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
|
||||
transactionId, savingsId);
|
||||
if (savingsAccountTransaction == null) { throw new SavingsAccountTransactionNotFoundException(savingsId, transactionId); }
|
||||
|
||||
if(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);
|
||||
}
|
||||
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
final MathContext mc = new MathContext(15, RoundingMode.HALF_EVEN);
|
||||
@@ -337,6 +347,10 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
|
||||
if (!(savingsAccountTransaction.isDeposit() || savingsAccountTransaction.isWithdrawal()) || savingsAccountTransaction.isReversed()) { throw new TransactionUpdateNotAllowedException(
|
||||
savingsId, transactionId); }
|
||||
|
||||
if(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);
|
||||
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
@@ -361,7 +375,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
//for undo withdrawal fee
|
||||
SavingsAccountTransaction nextSavingsAccountTransaction = this.savingsAccountTransactionRepository.findOneByIdAndSavingsAccountId(
|
||||
transactionId+1, savingsId);
|
||||
if(nextSavingsAccountTransaction.isWithdrawalFeeAndNotReversed()){
|
||||
if(nextSavingsAccountTransaction!=null && nextSavingsAccountTransaction.isWithdrawalFeeAndNotReversed()){
|
||||
account.undoTransaction(transactionId+1, existingReversedTransactionIds);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user