payment type applicable for disbursement charge configuration added

This commit is contained in:
venkatconflux
2016-03-09 12:43:10 +05:30
parent b786d459bc
commit 6ecbd28121
5 changed files with 25 additions and 8 deletions
@@ -68,4 +68,6 @@ public interface ConfigurationDomainService {
boolean isOrganisationstartDateEnabled();
Date retrieveOrganisationStartDate();
boolean isPaymnetypeApplicableforDisbursementCharge();
}
@@ -229,4 +229,11 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
return property.getDateValue();
}
@Override
public boolean isPaymnetypeApplicableforDisbursementCharge() {
final String propertyName = "paymenttype-applicable-for-disbursement-charges";
final GlobalConfigurationProperty property = this.globalConfigurationRepository.findOneByNameWithNotFoundDetection(propertyName);
return property.isEnabled();
}
}
@@ -125,6 +125,7 @@ import org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMe
import org.apache.fineract.portfolio.loanproduct.domain.LoanTransactionProcessingStrategy;
import org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType;
import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
import org.apache.fineract.useradministration.domain.AppUser;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
@@ -2287,7 +2288,7 @@ public class Loan extends AbstractPersistable<Long> {
}
public ChangedTransactionDetail disburse(final AppUser currentUser, final JsonCommand command, final Map<String, Object> actualChanges,
final ScheduleGeneratorDTO scheduleGeneratorDTO) {
final ScheduleGeneratorDTO scheduleGeneratorDTO,final PaymentDetail paymentDetail) {
final LoanStatus statusEnum = this.loanLifecycleStateMachine.transition(LoanEvent.LOAN_DISBURSED,
LoanStatus.fromInt(this.loanStatus));
@@ -2318,7 +2319,7 @@ public class Loan extends AbstractPersistable<Long> {
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
updateLoanRepaymentPeriodsDerivedFields(actualDisbursementDate);
LocalDateTime createdDate = DateUtils.getLocalDateTimeOfTenant();
handleDisbursementTransaction(actualDisbursementDate, createdDate, currentUser);
handleDisbursementTransaction(actualDisbursementDate, createdDate, currentUser,paymentDetail);
updateLoanSummaryDerivedFields();
final Money interestApplied = Money.of(getCurrency(), this.summary.getTotalInterestCharged());
@@ -2616,7 +2617,7 @@ public class Loan extends AbstractPersistable<Long> {
return interestRate;
}
private void handleDisbursementTransaction(final LocalDate disbursedOn, final LocalDateTime createdDate, final AppUser currentUser) {
private void handleDisbursementTransaction(final LocalDate disbursedOn, final LocalDateTime createdDate, final AppUser currentUser, final PaymentDetail paymentDetail) {
// add repayment transaction to track incoming money from client to mfi
// for (charges due at time of disbursement)
@@ -2634,7 +2635,7 @@ public class Loan extends AbstractPersistable<Long> {
**/
Money disbursentMoney = Money.zero(getCurrency());
final LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(getOffice(), disbursentMoney, null, disbursedOn,
final LoanTransaction chargesPayment = LoanTransaction.repaymentAtDisbursement(getOffice(), disbursentMoney, paymentDetail, disbursedOn,
null, createdDate, currentUser);
final Integer installmentNumber = null;
for (final LoanCharge charge : charges()) {
@@ -361,8 +361,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
this.loanScheduleHistoryWritePlatformService.createAndSaveLoanScheduleArchive(loan.fetchRepaymentScheduleInstallments(),
loan, null);
}
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO);
if(configurationDomainService.isPaymnetypeApplicableforDisbursementCharge()){
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO,paymentDetail);
}else{
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO,null);
}
}
if (!changes.isEmpty()) {
saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
@@ -594,8 +597,11 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
this.loanScheduleHistoryWritePlatformService.createAndSaveLoanScheduleArchive(
loan.fetchRepaymentScheduleInstallments(), loan, null);
}
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO);
if(configurationDomainService.isPaymnetypeApplicableforDisbursementCharge()){
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO,paymentDetail);
}else{
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO,null);
}
}
if (!changes.isEmpty()) {
@@ -0,0 +1 @@
INSERT INTO `c_configuration` (`name`, `value`, `enabled`, `is_trap_door`, `description`) VALUES ('paymenttype-applicable-for-disbursement-charges', NULL, 0, 0, 'Is the Disbursement Entry need to be considering the fund source of the paymnet type');