Merge branch 'PR363' into develop

This commit is contained in:
Nazeer Hussain Shaik
2017-06-09 16:09:57 +05:30
13 changed files with 98 additions and 27 deletions
@@ -50,6 +50,7 @@ public class CollectionSheetConstants {
public static final String loanIdParamName = "loanId"; public static final String loanIdParamName = "loanId";
public static final String savingsIdParamName = "savingsId"; public static final String savingsIdParamName = "savingsId";
public static final String transactionAmountParamName = "transactionAmount"; public static final String transactionAmountParamName = "transactionAmount";
public static final String depositAccountTypeParamName = "depositAccountType";
public static final Set<String> COLLECTIONSHEET_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName, public static final Set<String> COLLECTIONSHEET_REQUEST_DATA_PARAMETERS = new HashSet<>(Arrays.asList(localeParamName,
dateFormatParamName, transactionDateParamName, actualDisbursementDateParamName, bulkRepaymentTransactionsParamName, dateFormatParamName, transactionDateParamName, actualDisbursementDateParamName, bulkRepaymentTransactionsParamName,
@@ -48,6 +48,7 @@ import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException; import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.portfolio.paymentdetail.PaymentDetailConstants; import org.apache.fineract.portfolio.paymentdetail.PaymentDetailConstants;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -119,7 +120,7 @@ public class CollectionSheetTransactionDataValidator {
final JsonElement element = this.fromApiJsonHelper.parse(json); final JsonElement element = this.fromApiJsonHelper.parse(json);
final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(transactionDateParamName, element); final LocalDate transactionDate = this.fromApiJsonHelper.extractLocalDateNamed(transactionDateParamName, element);
baseDataValidator.reset().parameter(transactionDateParamName).value(transactionDate).notNull(); baseDataValidator.reset().parameter(transactionDateParamName).value(transactionDate).notNull().validateDateBeforeOrEqual(DateUtils.getLocalDateOfTenant());
final String note = this.fromApiJsonHelper.extractStringNamed(noteParamName, element); final String note = this.fromApiJsonHelper.extractStringNamed(noteParamName, element);
if (StringUtils.isNotBlank(note)) { if (StringUtils.isNotBlank(note)) {
@@ -40,14 +40,16 @@ public class SavingsDueData {
private final CurrencyData currency; private final CurrencyData currency;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private BigDecimal dueAmount = BigDecimal.ZERO; private BigDecimal dueAmount = BigDecimal.ZERO;
@SuppressWarnings("unused")
private String depositAccountType;
public static SavingsDueData instance(final Long savingsId, final String accountId, final Integer accountStatusId, public static SavingsDueData instance(final Long savingsId, final String accountId, final Integer accountStatusId,
final String productName, final Long productId, final CurrencyData currency, final BigDecimal dueAmount) { final String productName, final Long productId, final CurrencyData currency, final BigDecimal dueAmount, final String depositAccountType) {
return new SavingsDueData(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount); return new SavingsDueData(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount, depositAccountType);
} }
private SavingsDueData(final Long savingsId, final String accountId, final Integer accountStatusId, final String productName, private SavingsDueData(final Long savingsId, final String accountId, final Integer accountStatusId, final String productName,
final Long productId, final CurrencyData currency, final BigDecimal dueAmount) { final Long productId, final CurrencyData currency, final BigDecimal dueAmount, final String depositAccountType) {
this.savingsId = savingsId; this.savingsId = savingsId;
this.accountId = accountId; this.accountId = accountId;
this.accountStatusId = accountStatusId; this.accountStatusId = accountStatusId;
@@ -55,6 +57,7 @@ public class SavingsDueData {
this.productId = productId; this.productId = productId;
this.currency = currency; this.currency = currency;
this.dueAmount = dueAmount; this.dueAmount = dueAmount;
this.depositAccountType = depositAccountType;
} }
public String productName() { public String productName() {
@@ -65,4 +68,8 @@ public class SavingsDueData {
return this.productId; return this.productId;
} }
public String getDepositAccountType() {
return depositAccountType;
}
} }
@@ -235,7 +235,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
.append("if(ln.loan_status_id = 200 , ln.principal_amount , null) As disbursementAmount, ") .append("if(ln.loan_status_id = 200 , ln.principal_amount , null) As disbursementAmount, ")
.append("sum(ifnull(if(ln.loan_status_id = 300, ls.principal_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.principal_completed_derived, 0.0), 0.0)) As principalDue, ") .append("sum(ifnull(if(ln.loan_status_id = 300, ls.principal_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.principal_completed_derived, 0.0), 0.0)) As principalDue, ")
.append("ln.principal_repaid_derived As principalPaid, ") .append("ln.principal_repaid_derived As principalPaid, ")
.append("sum(ifnull(if(ln.loan_status_id = 300, ls.interest_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.interest_completed_derived, 0.0), 0.0)) As interestDue, ") .append("sum(ifnull(if(ln.loan_status_id = 300, ls.interest_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.interest_completed_derived, 0.0), 0.0) - IFNULL(IF(ln.loan_status_id = 300, ls.interest_waived_derived, 0.0), 0.0)) As interestDue, ")
.append("ln.interest_repaid_derived As interestPaid, ") .append("ln.interest_repaid_derived As interestPaid, ")
.append("sum(ifnull(if(ln.loan_status_id = 300, ls.fee_charges_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.fee_charges_completed_derived, 0.0), 0.0)) As feeDue, ") .append("sum(ifnull(if(ln.loan_status_id = 300, ls.fee_charges_amount, 0.0), 0.0) - ifnull(if(ln.loan_status_id = 300, ls.fee_charges_completed_derived, 0.0), 0.0)) As feeDue, ")
.append("ln.fee_charges_repaid_derived As feePaid, ") .append("ln.fee_charges_repaid_derived As feePaid, ")
@@ -439,6 +439,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
for (SavingsDueData savingsDueData : savingsDatas) { for (SavingsDueData savingsDueData : savingsDatas) {
final SavingsProductData savingsProduct = SavingsProductData.lookup(savingsDueData.productId(), final SavingsProductData savingsProduct = SavingsProductData.lookup(savingsDueData.productId(),
savingsDueData.productName()); savingsDueData.productName());
savingsProduct.setDepositAccountType(savingsDueData.getDepositAccountType());
if (!savingsProducts.contains(savingsProduct)) { if (!savingsProducts.contains(savingsProduct)) {
savingsProducts.add(savingsProduct); savingsProducts.add(savingsProduct);
} }
@@ -515,6 +516,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
.append("sa.currency_multiplesof as inMultiplesOf, ") .append("sa.currency_multiplesof as inMultiplesOf, ")
.append("rc.`name` as currencyName, ") .append("rc.`name` as currencyName, ")
.append("rc.display_symbol as currencyDisplaySymbol, ") .append("rc.display_symbol as currencyDisplaySymbol, ")
.append("if(sa.deposit_type_enum=100,'Saving Deposit',if(sa.deposit_type_enum=300,'Recurring Deposit','Current Deposit')) as depositAccountType, ")
.append("rc.internationalized_name_code as currencyNameCode, ") .append("rc.internationalized_name_code as currencyNameCode, ")
.append("sum(ifnull(mss.deposit_amount,0) - ifnull(mss.deposit_amount_completed_derived,0)) as dueAmount ") .append("sum(ifnull(mss.deposit_amount,0) - ifnull(mss.deposit_amount_completed_derived,0)) as dueAmount ")
@@ -526,8 +528,8 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
.append("JOIN m_client cl ON cl.id = gc.client_id ") .append("JOIN m_client cl ON cl.id = gc.client_id ")
.append("JOIN m_savings_account sa ON sa.client_id=cl.id and sa.status_enum=300 ") .append("JOIN m_savings_account sa ON sa.client_id=cl.id and sa.status_enum=300 ")
.append("JOIN m_savings_product sp ON sa.product_id=sp.id ") .append("JOIN m_savings_product sp ON sa.product_id=sp.id ")
.append("JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = true ") .append("LEFT JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = true ")
.append("JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.duedate <= :dueDate ") .append("LEFT JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.duedate <= :dueDate ")
.append("LEFT JOIN m_currency rc on rc.`code` = sa.currency_code "); .append("LEFT JOIN m_currency rc on rc.`code` = sa.currency_code ");
if (isCenterCollection) { if (isCenterCollection) {
@@ -655,25 +657,25 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
private SavingsDueDataMapper() {} private SavingsDueDataMapper() {}
@Override @Override
public SavingsDueData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException { public SavingsDueData mapRow(ResultSet rs, int rowNum) throws SQLException {
final Long savingsId = rs.getLong("savingsId"); final Long savingsId = rs.getLong("savingsId");
final String accountId = rs.getString("accountId"); final String accountId = rs.getString("accountId");
final Integer accountStatusId = JdbcSupport.getInteger(rs, "accountStatusId"); final Integer accountStatusId = JdbcSupport.getInteger(rs, "accountStatusId");
final String productName = rs.getString("productShortName"); final String productName = rs.getString("productShortName");
final Long productId = rs.getLong("productId"); final Long productId = rs.getLong("productId");
final BigDecimal dueAmount = rs.getBigDecimal("dueAmount"); final BigDecimal dueAmount = rs.getBigDecimal("dueAmount");
final String currencyCode = rs.getString("currencyCode"); final String currencyCode = rs.getString("currencyCode");
final String currencyName = rs.getString("currencyName"); final String currencyName = rs.getString("currencyName");
final String currencyNameCode = rs.getString("currencyNameCode"); final String currencyNameCode = rs.getString("currencyNameCode");
final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol"); final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits"); final Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf"); final Integer inMultiplesOf = JdbcSupport.getInteger(rs, "inMultiplesOf");
final String depositAccountType = rs.getString("depositAccountType");
// currency // currency
final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf, final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDigits, inMultiplesOf,
currencyDisplaySymbol, currencyNameCode); currencyDisplaySymbol, currencyNameCode);
return SavingsDueData.instance(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount); return SavingsDueData.instance(savingsId, accountId, accountStatusId, productName, productId, currency, dueAmount, depositAccountType);
} }
} }
@@ -818,7 +820,7 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
public IndividualMandatorySavingsCollectionsheetExtractor(final boolean checkForOfficeId, final boolean checkforStaffId) { public IndividualMandatorySavingsCollectionsheetExtractor(final boolean checkForOfficeId, final boolean checkforStaffId) {
final StringBuffer sb = new StringBuffer(400); final StringBuffer sb = new StringBuffer(400);
sb.append("SELECT cl.display_name As clientName, cl.id As clientId, "); sb.append("SELECT if(sa.deposit_type_enum=100,'Saving Deposit',if(sa.deposit_type_enum=300,'Recurring Deposit','Current Deposit')) as depositAccountType, cl.display_name As clientName, cl.id As clientId, ");
sb.append("sa.id As savingsId, sa.account_no As accountId, sa.status_enum As accountStatusId, "); sb.append("sa.id As savingsId, sa.account_no As accountId, sa.status_enum As accountStatusId, ");
sb.append("sp.short_name As productShortName, sp.id As productId, "); sb.append("sp.short_name As productShortName, sp.id As productId, ");
sb.append("sa.currency_code as currencyCode, sa.currency_digits as currencyDigits, sa.currency_multiplesof as inMultiplesOf, "); sb.append("sa.currency_code as currencyCode, sa.currency_digits as currencyDigits, sa.currency_multiplesof as inMultiplesOf, ");
@@ -827,11 +829,11 @@ public class CollectionSheetReadPlatformServiceImpl implements CollectionSheetRe
sb.append("FROM m_savings_account sa "); sb.append("FROM m_savings_account sa ");
sb.append("JOIN m_client cl ON cl.id = sa.client_id "); sb.append("JOIN m_client cl ON cl.id = sa.client_id ");
sb.append("JOIN m_savings_product sp ON sa.product_id=sp.id "); sb.append("JOIN m_savings_product sp ON sa.product_id=sp.id ");
sb.append("JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = false "); sb.append("LEFT JOIN m_deposit_account_recurring_detail dard ON sa.id = dard.savings_account_id AND dard.is_mandatory = true AND dard.is_calendar_inherited = false ");
sb.append("JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.completed_derived = 0 AND mss.duedate <= :dueDate "); sb.append("LEFT JOIN m_mandatory_savings_schedule mss ON mss.savings_account_id=sa.id AND mss.completed_derived = 0 AND mss.duedate <= :dueDate ");
sb.append("LEFT JOIN m_office of ON of.id = cl.office_id AND of.hierarchy like :officeHierarchy "); sb.append("LEFT JOIN m_office of ON of.id = cl.office_id AND of.hierarchy like :officeHierarchy ");
sb.append("LEFT JOIN m_currency rc on rc.`code` = sa.currency_code "); sb.append("LEFT JOIN m_currency rc on rc.`code` = sa.currency_code ");
sb.append("WHERE sa.status_enum=300 and sa.group_id is null "); sb.append("WHERE sa.status_enum=300 and sa.group_id is null and sa.deposit_type_enum in (100,300,400) ");
sb.append("and (cl.status_enum = 300 or (cl.status_enum = 600 and cl.closedon_date >= :dueDate)) "); sb.append("and (cl.status_enum = 300 or (cl.status_enum = 600 and cl.closedon_date >= :dueDate)) ");
if (checkForOfficeId) { if (checkForOfficeId) {
sb.append("and of.id = :officeId "); sb.append("and of.id = :officeId ");
@@ -35,9 +35,10 @@ public class SavingsAccountTransactionDTO {
private final Date createdDate; private final Date createdDate;
private final Long savingsAccountId; private final Long savingsAccountId;
private final AppUser appUser; private final AppUser appUser;
private final Integer depositAccountType;
public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate, public SavingsAccountTransactionDTO(final DateTimeFormatter formatter, final LocalDate transactionDate,
final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate, final AppUser appUser) { final BigDecimal transactionAmount, final PaymentDetail paymentDetail, final Date createdDate, final AppUser appUser, final Integer depositAccountType) {
this.formatter = formatter; this.formatter = formatter;
this.transactionDate = transactionDate; this.transactionDate = transactionDate;
this.transactionAmount = transactionAmount; this.transactionAmount = transactionAmount;
@@ -45,6 +46,7 @@ public class SavingsAccountTransactionDTO {
this.createdDate = createdDate; this.createdDate = createdDate;
this.savingsAccountId = null; this.savingsAccountId = null;
this.appUser = appUser; this.appUser = appUser;
this.depositAccountType = depositAccountType;
} }
/** /**
@@ -58,7 +60,7 @@ public class SavingsAccountTransactionDTO {
* @param savingsAccountId * @param savingsAccountId
*/ */
public SavingsAccountTransactionDTO(DateTimeFormatter formatter, LocalDate transactionDate, BigDecimal transactionAmount, public SavingsAccountTransactionDTO(DateTimeFormatter formatter, LocalDate transactionDate, BigDecimal transactionAmount,
PaymentDetail paymentDetail, Date createdDate, Long savingsAccountId, AppUser appUser) { PaymentDetail paymentDetail, Date createdDate, Long savingsAccountId, AppUser appUser, final Integer depositAccountType) {
this.formatter = formatter; this.formatter = formatter;
this.transactionDate = transactionDate; this.transactionDate = transactionDate;
this.transactionAmount = transactionAmount; this.transactionAmount = transactionAmount;
@@ -66,6 +68,7 @@ public class SavingsAccountTransactionDTO {
this.createdDate = createdDate; this.createdDate = createdDate;
this.savingsAccountId = savingsAccountId; this.savingsAccountId = savingsAccountId;
this.appUser = appUser; this.appUser = appUser;
this.depositAccountType = depositAccountType;
} }
public DateTimeFormatter getFormatter() { public DateTimeFormatter getFormatter() {
@@ -95,4 +98,10 @@ public class SavingsAccountTransactionDTO {
public AppUser getAppUser() { public AppUser getAppUser() {
return this.appUser; return this.appUser;
} }
public Integer getAccountType() {
return this.depositAccountType;
}
} }
@@ -61,6 +61,7 @@ public class SavingsProductData {
private final BigDecimal minOverdraftForInterestCalculation; private final BigDecimal minOverdraftForInterestCalculation;
private final boolean withHoldTax; private final boolean withHoldTax;
private final TaxGroupData taxGroup; private final TaxGroupData taxGroup;
private String depositAccountType = null;
// accounting // accounting
private final EnumOptionData accountingRule; private final EnumOptionData accountingRule;
@@ -436,4 +437,14 @@ public class SavingsProductData {
public String getName() { public String getName() {
return this.name; return this.name;
} }
public String getDepositAccountType() {
return depositAccountType;
}
public void setDepositAccountType(String depositAccountType) {
this.depositAccountType = depositAccountType;
}
} }
@@ -73,6 +73,7 @@ import org.apache.fineract.portfolio.accountdetails.domain.AccountType;
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.client.exception.ClientNotActiveException; import org.apache.fineract.portfolio.client.exception.ClientNotActiveException;
import org.apache.fineract.portfolio.collectionsheet.CollectionSheetConstants;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper; import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper;
import org.apache.fineract.portfolio.group.exception.CenterNotActiveException; import org.apache.fineract.portfolio.group.exception.CenterNotActiveException;
@@ -444,12 +445,14 @@ public class DepositAccountAssembler {
final Long savingsId = this.fromApiJsonHelper.extractLongNamed(savingsIdParamName, savingsTransactionElement); final Long savingsId = this.fromApiJsonHelper.extractLongNamed(savingsIdParamName, savingsTransactionElement);
final BigDecimal dueAmount = this.fromApiJsonHelper.extractBigDecimalNamed(transactionAmountParamName, final BigDecimal dueAmount = this.fromApiJsonHelper.extractBigDecimalNamed(transactionAmountParamName,
savingsTransactionElement, locale); savingsTransactionElement, locale);
final Integer depositAccountType = this.fromApiJsonHelper.extractIntegerNamed(
CollectionSheetConstants.depositAccountTypeParamName, savingsTransactionElement, locale);
PaymentDetail detail = paymentDetail; PaymentDetail detail = paymentDetail;
if (paymentDetail == null) { if (paymentDetail == null) {
detail = this.paymentDetailAssembler.fetchPaymentDetail(savingsTransactionElement); detail = this.paymentDetailAssembler.fetchPaymentDetail(savingsTransactionElement);
} }
final SavingsAccountTransactionDTO savingsAccountTransactionDTO = new SavingsAccountTransactionDTO(formatter, final SavingsAccountTransactionDTO savingsAccountTransactionDTO = new SavingsAccountTransactionDTO(formatter,
transactionDate, dueAmount, detail, new Date(), savingsId, user); transactionDate, dueAmount, detail, new Date(), savingsId, user, depositAccountType);
savingsAccountTransactions.add(savingsAccountTransactionDTO); savingsAccountTransactions.add(savingsAccountTransactionDTO);
} }
} }
@@ -38,6 +38,9 @@ public interface DepositAccountDomainService {
SavingsAccountTransaction handleRDDeposit(RecurringDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate, SavingsAccountTransaction handleRDDeposit(RecurringDepositAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction); BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction);
SavingsAccountTransaction handleSavingDeposit(SavingsAccount account, DateTimeFormatter fmt, LocalDate transactionDate,
BigDecimal transactionAmount, PaymentDetail paymentDetail, boolean isRegularTransaction);
Long handleFDAccountClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command, Long handleFDAccountClosure(FixedDepositAccount account, PaymentDetail paymentDetail, AppUser user, JsonCommand command,
LocalDate tenantsTodayDate, Map<String, Object> changes); LocalDate tenantsTodayDate, Map<String, Object> changes);
@@ -164,6 +164,21 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
return deposit; return deposit;
} }
@Transactional
@Override
public SavingsAccountTransaction handleSavingDeposit(final SavingsAccount account, final DateTimeFormatter fmt,
final LocalDate transactionDate, final BigDecimal transactionAmount, final PaymentDetail paymentDetail,
final boolean isRegularTransaction) {
boolean isAccountTransfer = false;
final SavingsAccountTransaction deposit = this.savingsAccountDomainService.handleDeposit(account, fmt, transactionDate,
transactionAmount, paymentDetail, isAccountTransfer, isRegularTransaction);
final Set<Long> existingTransactionIds = new HashSet<>();
final Set<Long> existingReversedTransactionIds = new HashSet<>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds, isAccountTransfer);
return deposit;
}
private boolean isAnyActivationChargesDue(final RecurringDepositAccount account) { private boolean isAnyActivationChargesDue(final RecurringDepositAccount account) {
for (final SavingsAccountCharge savingsAccountCharge : account.charges()) { for (final SavingsAccountCharge savingsAccountCharge : account.charges()) {
if (savingsAccountCharge.isSavingsActivation() && savingsAccountCharge.amoutOutstanding() != null if (savingsAccountCharge.isSavingsActivation() && savingsAccountCharge.amoutOutstanding() != null
@@ -523,7 +523,7 @@ public class RecurringDepositAccount extends SavingsAccount {
final Money minRequiredOpeningBalance = Money.of(this.currency, this.minRequiredOpeningBalance); final Money minRequiredOpeningBalance = Money.of(this.currency, this.minRequiredOpeningBalance);
if (minRequiredOpeningBalance.isGreaterThanZero()) { if (minRequiredOpeningBalance.isGreaterThanZero()) {
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, getActivationLocalDate(), final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, getActivationLocalDate(),
minRequiredOpeningBalance.getAmount(), null, new Date(), user); minRequiredOpeningBalance.getAmount(), null, new Date(), user, accountType);
deposit(transactionDTO); deposit(transactionDTO);
// update existing transactions so derived balance fields are // update existing transactions so derived balance fields are
@@ -95,8 +95,9 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
final LocalDate postInterestOnDate = null; final LocalDate postInterestOnDate = null;
final Set<Long> existingReversedTransactionIds = new HashSet<>(); final Set<Long> existingReversedTransactionIds = new HashSet<>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
Integer accountType = null;
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
paymentDetail, new Date(), user); paymentDetail, new Date(), user, accountType);
final SavingsAccountTransaction withdrawal = account.withdraw(transactionDTO, transactionBooleanValues.isApplyWithdrawFee()); final SavingsAccountTransaction withdrawal = account.withdraw(transactionDTO, transactionBooleanValues.isApplyWithdrawFee());
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
if (account.isBeforeLastPostingPeriod(transactionDate)) { if (account.isBeforeLastPostingPeriod(transactionDate)) {
@@ -157,8 +158,9 @@ public class SavingsAccountDomainServiceJpa implements SavingsAccountDomainServi
final Set<Long> existingTransactionIds = new HashSet<>(); final Set<Long> existingTransactionIds = new HashSet<>();
final Set<Long> existingReversedTransactionIds = new HashSet<>(); final Set<Long> existingReversedTransactionIds = new HashSet<>();
updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds); updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
Integer accountType = null;
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
paymentDetail, new Date(), user); paymentDetail, new Date(), user, accountType);
final SavingsAccountTransaction deposit = account.deposit(transactionDTO, savingsAccountTransactionType); final SavingsAccountTransaction deposit = account.deposit(transactionDTO, savingsAccountTransactionType);
final LocalDate postInterestOnDate = null; final LocalDate postInterestOnDate = null;
final MathContext mc = MathContext.DECIMAL64; final MathContext mc = MathContext.DECIMAL64;
@@ -699,13 +699,14 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
account.undoTransaction(transactionId); account.undoTransaction(transactionId);
SavingsAccountTransaction transaction = null; SavingsAccountTransaction transaction = null;
Integer accountType = null;
if (savingsAccountTransaction.isDeposit()) { if (savingsAccountTransaction.isDeposit()) {
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
paymentDetail, savingsAccountTransaction.createdDate(), user); paymentDetail, savingsAccountTransaction.createdDate(), user, accountType);
transaction = account.deposit(transactionDTO); transaction = account.deposit(transactionDTO);
} else { } else {
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
paymentDetail, savingsAccountTransaction.createdDate(), user); paymentDetail, savingsAccountTransaction.createdDate(), user, accountType);
transaction = account.withdraw(transactionDTO, true); transaction = account.withdraw(transactionDTO, true);
} }
final Long newtransactionId = saveTransactionToGenerateTransactionId(transaction); final Long newtransactionId = saveTransactionToGenerateTransactionId(transaction);
@@ -1358,17 +1359,32 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
@Override @Override
public SavingsAccountTransaction mandatorySavingsAccountDeposit(final SavingsAccountTransactionDTO accountTransactionDTO) { public SavingsAccountTransaction mandatorySavingsAccountDeposit(final SavingsAccountTransactionDTO accountTransactionDTO) {
boolean isRegularTransaction = false; boolean isRegularTransaction = false;
final RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(
accountTransactionDTO.getSavingsAccountId(), DepositAccountType.RECURRING_DEPOSIT);
final PaymentDetail paymentDetail = accountTransactionDTO.getPaymentDetail(); final PaymentDetail paymentDetail = accountTransactionDTO.getPaymentDetail();
if (paymentDetail != null && paymentDetail.getId() == null) { if (paymentDetail != null && paymentDetail.getId() == null) {
this.paymentDetailWritePlatformService.persistPaymentDetail(paymentDetail); this.paymentDetailWritePlatformService.persistPaymentDetail(paymentDetail);
} }
return this.depositAccountDomainService.handleRDDeposit(account, accountTransactionDTO.getFormatter(), if (accountTransactionDTO.getAccountType().equals(DepositAccountType.RECURRING_DEPOSIT.getValue())) {
RecurringDepositAccount account = (RecurringDepositAccount) this.depositAccountAssembler.assembleFrom(
accountTransactionDTO.getSavingsAccountId(), DepositAccountType.RECURRING_DEPOSIT);
return this.depositAccountDomainService.handleRDDeposit(account, accountTransactionDTO.getFormatter(),
accountTransactionDTO.getTransactionDate(), accountTransactionDTO.getTransactionAmount(), paymentDetail,
isRegularTransaction);
}
SavingsAccount account = null;
if (accountTransactionDTO.getAccountType().equals(DepositAccountType.SAVINGS_DEPOSIT.getValue())) {
account = this.depositAccountAssembler.assembleFrom(accountTransactionDTO.getSavingsAccountId(),
DepositAccountType.SAVINGS_DEPOSIT);
} else {
account = this.depositAccountAssembler.assembleFrom(accountTransactionDTO.getSavingsAccountId(),
DepositAccountType.CURRENT_DEPOSIT);
}
return this.depositAccountDomainService.handleSavingDeposit(account, accountTransactionDTO.getFormatter(),
accountTransactionDTO.getTransactionDate(), accountTransactionDTO.getTransactionAmount(), paymentDetail, accountTransactionDTO.getTransactionDate(), accountTransactionDTO.getTransactionAmount(), paymentDetail,
isRegularTransaction); isRegularTransaction);
} }
private AppUser getAppUserIfPresent() { private AppUser getAppUserIfPresent() {
AppUser user = null; AppUser user = null;
if (this.context != null) { if (this.context != null) {
@@ -550,8 +550,9 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
SavingsAccountTransaction transaction = null; SavingsAccountTransaction transaction = null;
boolean isInterestTransfer = false; boolean isInterestTransfer = false;
Integer accountType = null;
final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount, final SavingsAccountTransactionDTO transactionDTO = new SavingsAccountTransactionDTO(fmt, transactionDate, transactionAmount,
paymentDetail, savingsAccountTransaction.createdDate(), user); paymentDetail, savingsAccountTransaction.createdDate(), user, accountType);
if (savingsAccountTransaction.isDeposit()) { if (savingsAccountTransaction.isDeposit()) {
transaction = account.deposit(transactionDTO); transaction = account.deposit(transactionDTO);
} else { } else {