Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ public interface ConfigurationDomainService {
boolean isOrganisationstartDateEnabled();

Date retrieveOrganisationStartDate();

boolean isPaymnetypeApplicableforDisbursementCharge();
}
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,11 @@ public Date retrieveOrganisationStartDate() {
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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
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;
Expand Down Expand Up @@ -2287,7 +2288,7 @@ public Collection<Long> findExistingReversedTransactionIds() {
}

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));
Expand Down Expand Up @@ -2318,7 +2319,7 @@ public ChangedTransactionDetail disburse(final AppUser currentUser, final JsonCo
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());

Expand Down Expand Up @@ -2616,7 +2617,7 @@ private BigDecimal constructFloatingInterestRates(final BigDecimal annualNominal
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)
Expand All @@ -2634,7 +2635,7 @@ private void handleDisbursementTransaction(final LocalDate disbursedOn, final Lo
**/

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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,11 @@ public CommandProcessingResult disburseLoan(final Long loanId, final JsonCommand
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);
Expand Down Expand Up @@ -594,8 +597,11 @@ public Map<String, Object> bulkLoanDisbursal(final JsonCommand command, final Co
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()) {

Expand Down
Original file line number Diff line number Diff line change
@@ -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');