FINERACT-2234: Improve "Add periodic accrual entries" business step performance
This commit is contained in:
committed by
Adam Saghy
parent
4ebf768286
commit
11912881af
+3
-6
@@ -31,6 +31,7 @@ import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||
import org.apache.fineract.portfolio.client.domain.Client;
|
||||
@@ -52,7 +53,8 @@ public class ClientCollateralManagement extends AbstractPersistableCustom<Long>
|
||||
@JoinColumn(name = "collateral_id", nullable = false)
|
||||
private CollateralManagementDomain collateral;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clientCollateralManagement", fetch = FetchType.EAGER)
|
||||
@Getter
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clientCollateralManagement", fetch = FetchType.LAZY)
|
||||
private Set<LoanCollateralManagement> loanCollateralManagementSet = new HashSet<>();
|
||||
|
||||
public ClientCollateralManagement() {
|
||||
@@ -129,9 +131,4 @@ public class ClientCollateralManagement extends AbstractPersistableCustom<Long>
|
||||
public CollateralManagementDomain getCollaterals() {
|
||||
return this.collateral;
|
||||
}
|
||||
|
||||
public Set<LoanCollateralManagement> getLoanCollateralManagementSet() {
|
||||
return this.loanCollateralManagementSet;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-23
@@ -43,7 +43,7 @@ public class AccrualPeriodData {
|
||||
private Money transactionAccrued;
|
||||
private final List<AccrualChargeData> charges = new ArrayList<>();
|
||||
|
||||
public AccrualPeriodData addCharge(AccrualChargeData charge) {
|
||||
public AccrualPeriodData addCharge(final AccrualChargeData charge) {
|
||||
charges.add(charge);
|
||||
return this;
|
||||
}
|
||||
@@ -56,36 +56,14 @@ public class AccrualPeriodData {
|
||||
return charges.stream().filter(charge -> !charge.isPenalty()).map(AccrualChargeData::getChargeAmount).reduce(null, MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getPenaltyAmount() {
|
||||
return charges.stream().filter(AccrualChargeData::isPenalty).map(AccrualChargeData::getChargeAmount).reduce(null, MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getChargeAccrued() {
|
||||
return charges.stream().map(AccrualChargeData::getChargeAccrued).reduce(null, MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getFeeAccrued() {
|
||||
return charges.stream().filter(charge -> !charge.isPenalty()).map(AccrualChargeData::getChargeAccrued).reduce(null, MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getFeeTransactionAccrued() {
|
||||
return charges.stream().filter(charge -> !charge.isPenalty()).map(AccrualChargeData::getTransactionAccrued).reduce(null,
|
||||
MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getPenaltyAccrued() {
|
||||
return charges.stream().filter(AccrualChargeData::isPenalty).map(AccrualChargeData::getChargeAccrued).reduce(null, MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getPenaltyTransactionAccrued() {
|
||||
return charges.stream().filter(AccrualChargeData::isPenalty).map(AccrualChargeData::getTransactionAccrued).reduce(null,
|
||||
MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getChargeAccruable() {
|
||||
return charges.stream().map(AccrualChargeData::getChargeAccruable).reduce(null, MathUtil::plus);
|
||||
}
|
||||
|
||||
public Money getFeeAccruable() {
|
||||
return charges.stream().filter(charge -> !charge.isPenalty()).map(AccrualChargeData::getChargeAccruable).reduce(null,
|
||||
MathUtil::plus);
|
||||
|
||||
+14
-24
@@ -43,6 +43,7 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
||||
@@ -76,7 +77,7 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom<Long> {
|
||||
@Column(name = "charge_time_enum", nullable = false)
|
||||
private Integer chargeTime;
|
||||
|
||||
@Column(name = "submitted_on_date", nullable = true)
|
||||
@Column(name = "submitted_on_date")
|
||||
private LocalDate submittedOnDate;
|
||||
|
||||
@Column(name = "due_for_collection_as_of_date")
|
||||
@@ -88,10 +89,10 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom<Long> {
|
||||
@Column(name = "charge_payment_mode_enum")
|
||||
private Integer chargePaymentMode;
|
||||
|
||||
@Column(name = "calculation_percentage", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "calculation_percentage", scale = 6, precision = 19)
|
||||
private BigDecimal percentage;
|
||||
|
||||
@Column(name = "calculation_on_amount", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "calculation_on_amount", scale = 6, precision = 19)
|
||||
private BigDecimal amountPercentageAppliedTo;
|
||||
|
||||
@Column(name = "charge_amount_or_percentage", scale = 6, precision = 19, nullable = false)
|
||||
@@ -100,13 +101,14 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom<Long> {
|
||||
@Column(name = "amount", scale = 6, precision = 19, nullable = false)
|
||||
private BigDecimal amount;
|
||||
|
||||
@Column(name = "amount_paid_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "amount_paid_derived", scale = 6, precision = 19)
|
||||
private BigDecimal amountPaid;
|
||||
|
||||
@Column(name = "amount_waived_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Setter
|
||||
@Column(name = "amount_waived_derived", scale = 6, precision = 19)
|
||||
private BigDecimal amountWaived;
|
||||
|
||||
@Column(name = "amount_writtenoff_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "amount_writtenoff_derived", scale = 6, precision = 19)
|
||||
private BigDecimal amountWrittenOff;
|
||||
|
||||
@Column(name = "amount_outstanding_derived", scale = 6, precision = 19, nullable = false)
|
||||
@@ -121,13 +123,13 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom<Long> {
|
||||
@Column(name = "waived", nullable = false)
|
||||
private boolean waived = false;
|
||||
|
||||
@Column(name = "min_cap", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "min_cap", scale = 6, precision = 19)
|
||||
private BigDecimal minCap;
|
||||
|
||||
@Column(name = "max_cap", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "max_cap", scale = 6, precision = 19)
|
||||
private BigDecimal maxCap;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<>();
|
||||
|
||||
@Column(name = "is_active", nullable = false)
|
||||
@@ -136,13 +138,13 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom<Long> {
|
||||
@Column(name = "external_id")
|
||||
private ExternalId externalId;
|
||||
|
||||
@OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, optional = true, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
@OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private LoanOverdueInstallmentCharge overdueInstallmentCharge;
|
||||
|
||||
@OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, optional = true, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
@OneToOne(mappedBy = "loancharge", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private LoanTrancheDisbursementCharge loanTrancheDisbursementCharge;
|
||||
|
||||
@OneToMany(mappedBy = "loanCharge", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
@OneToMany(mappedBy = "loanCharge", cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private Set<LoanChargePaidBy> loanChargePaidBySet = new HashSet<>();
|
||||
|
||||
protected LoanCharge() {
|
||||
@@ -786,14 +788,6 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom<Long> {
|
||||
this.loanInstallmentCharge.clear();
|
||||
}
|
||||
|
||||
public void addLoanInstallmentCharges(final Collection<LoanInstallmentCharge> installmentCharges) {
|
||||
this.loanInstallmentCharge.addAll(installmentCharges);
|
||||
}
|
||||
|
||||
public boolean hasNoLoanInstallmentCharges() {
|
||||
return this.loanInstallmentCharge.isEmpty();
|
||||
}
|
||||
|
||||
public Set<LoanInstallmentCharge> installmentCharges() {
|
||||
return this.loanInstallmentCharge;
|
||||
}
|
||||
@@ -943,10 +937,6 @@ public class LoanCharge extends AbstractAuditableWithUTCDateTimeCustom<Long> {
|
||||
return this.dueDate != null;
|
||||
}
|
||||
|
||||
public void setAmountWaived(final BigDecimal amountWaived) {
|
||||
this.amountWaived = amountWaived;
|
||||
}
|
||||
|
||||
public void undoWaived() {
|
||||
this.waived = false;
|
||||
}
|
||||
|
||||
+18
-43
@@ -25,6 +25,7 @@ import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.OneToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
|
||||
import org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
|
||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
|
||||
@@ -61,29 +62,37 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
|
||||
@Column(name = "rest_frequency_type_enum", nullable = false)
|
||||
private Integer restFrequencyType;
|
||||
|
||||
@Getter
|
||||
@Column(name = "rest_frequency_interval", nullable = false)
|
||||
private Integer restInterval;
|
||||
|
||||
@Column(name = "rest_frequency_nth_day_enum", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "rest_frequency_nth_day_enum")
|
||||
private Integer restFrequencyNthDay;
|
||||
|
||||
@Column(name = "rest_frequency_weekday_enum", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "rest_frequency_weekday_enum")
|
||||
private Integer restFrequencyWeekday;
|
||||
|
||||
@Column(name = "rest_frequency_on_day", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "rest_frequency_on_day")
|
||||
private Integer restFrequencyOnDay;
|
||||
|
||||
@Column(name = "compounding_frequency_type_enum", nullable = true)
|
||||
@Column(name = "compounding_frequency_type_enum")
|
||||
private Integer compoundingFrequencyType;
|
||||
|
||||
@Column(name = "compounding_frequency_interval", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "compounding_frequency_interval")
|
||||
private Integer compoundingInterval;
|
||||
|
||||
@Column(name = "compounding_frequency_nth_day_enum", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "compounding_frequency_nth_day_enum")
|
||||
private Integer compoundingFrequencyNthDay;
|
||||
@Column(name = "compounding_frequency_weekday_enum", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "compounding_frequency_weekday_enum")
|
||||
private Integer compoundingFrequencyWeekday;
|
||||
@Column(name = "compounding_frequency_on_day", nullable = true)
|
||||
@Getter
|
||||
@Column(name = "compounding_frequency_on_day")
|
||||
private Integer compoundingFrequencyOnDay;
|
||||
|
||||
@Column(name = "is_compounding_to_be_posted_as_transaction")
|
||||
@@ -91,6 +100,7 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
|
||||
@Column(name = "allow_compounding_on_eod")
|
||||
private Boolean allowCompoundingOnEod;
|
||||
|
||||
@Getter
|
||||
@Column(name = "pre_close_interest_calculation_strategy")
|
||||
@Enumerated(EnumType.ORDINAL)
|
||||
private LoanPreCloseInterestCalculationStrategy preCloseInterestCalculationStrategy;
|
||||
@@ -161,42 +171,10 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
|
||||
return RecalculationFrequencyType.fromInt(this.restFrequencyType);
|
||||
}
|
||||
|
||||
public Integer getRestInterval() {
|
||||
return this.restInterval;
|
||||
}
|
||||
|
||||
public RecalculationFrequencyType getCompoundingFrequencyType() {
|
||||
return RecalculationFrequencyType.fromInt(this.compoundingFrequencyType);
|
||||
}
|
||||
|
||||
public Integer getCompoundingInterval() {
|
||||
return this.compoundingInterval;
|
||||
}
|
||||
|
||||
public Integer getRestFrequencyNthDay() {
|
||||
return this.restFrequencyNthDay;
|
||||
}
|
||||
|
||||
public Integer getRestFrequencyWeekday() {
|
||||
return this.restFrequencyWeekday;
|
||||
}
|
||||
|
||||
public Integer getRestFrequencyOnDay() {
|
||||
return this.restFrequencyOnDay;
|
||||
}
|
||||
|
||||
public Integer getCompoundingFrequencyNthDay() {
|
||||
return this.compoundingFrequencyNthDay;
|
||||
}
|
||||
|
||||
public Integer getCompoundingFrequencyWeekday() {
|
||||
return this.compoundingFrequencyWeekday;
|
||||
}
|
||||
|
||||
public Integer getCompoundingFrequencyOnDay() {
|
||||
return this.compoundingFrequencyOnDay;
|
||||
}
|
||||
|
||||
public boolean isCompoundingToBePostedAsTransaction() {
|
||||
return this.isCompoundingToBePostedAsTransaction != null && this.isCompoundingToBePostedAsTransaction;
|
||||
}
|
||||
@@ -209,7 +187,4 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
|
||||
return disallowInterestCalculationOnPastDue;
|
||||
}
|
||||
|
||||
public LoanPreCloseInterestCalculationStrategy getPreCloseInterestCalculationStrategy() {
|
||||
return preCloseInterestCalculationStrategy;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-6
@@ -159,10 +159,10 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
|
||||
@Column(name = "is_re_aged", nullable = false)
|
||||
private boolean isReAged;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "loanRepaymentScheduleInstallment")
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "loanRepaymentScheduleInstallment")
|
||||
private Set<LoanInterestRecalcualtionAdditionalDetails> loanCompoundingDetails = new HashSet<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "loanRepaymentScheduleInstallment")
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "loanRepaymentScheduleInstallment")
|
||||
private Set<PostDatedChecks> postDatedChecks = new HashSet<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "installment")
|
||||
@@ -296,10 +296,6 @@ public class LoanRepaymentScheduleInstallment extends AbstractAuditableWithUTCDa
|
||||
return Money.of(currency, this.principalCompleted);
|
||||
}
|
||||
|
||||
public void updateLoanRepaymentSchedule(final BigDecimal amountWaived) {
|
||||
this.feeChargesWaived = this.feeChargesWaived.subtract(amountWaived);
|
||||
}
|
||||
|
||||
public Money getPrincipalWrittenOff(final MonetaryCurrency currency) {
|
||||
return Money.of(currency, this.principalWrittenOff);
|
||||
}
|
||||
|
||||
+21
-143
@@ -33,13 +33,11 @@ import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
||||
import org.apache.fineract.infrastructure.core.domain.ExternalId;
|
||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||
@@ -47,10 +45,8 @@ import org.apache.fineract.infrastructure.core.service.MathUtil;
|
||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||
import org.apache.fineract.organisation.office.domain.Office;
|
||||
import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionEnumData;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.reaging.LoanReAgeParameter;
|
||||
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleType;
|
||||
import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
||||
|
||||
/**
|
||||
@@ -71,7 +67,7 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
private Office office;
|
||||
|
||||
@ManyToOne(optional = true)
|
||||
@JoinColumn(name = "payment_detail_id", nullable = true)
|
||||
@JoinColumn(name = "payment_detail_id")
|
||||
private PaymentDetail paymentDetail;
|
||||
|
||||
@Column(name = "transaction_type_enum", nullable = false)
|
||||
@@ -80,63 +76,67 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
@Column(name = "transaction_date", nullable = false)
|
||||
private LocalDate dateOf;
|
||||
|
||||
@Getter
|
||||
@Column(name = "submitted_on_date", nullable = false)
|
||||
private LocalDate submittedOnDate;
|
||||
|
||||
@Column(name = "amount", scale = 6, precision = 19, nullable = false)
|
||||
private BigDecimal amount;
|
||||
|
||||
@Column(name = "principal_portion_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "principal_portion_derived", scale = 6, precision = 19)
|
||||
private BigDecimal principalPortion;
|
||||
|
||||
@Column(name = "interest_portion_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "interest_portion_derived", scale = 6, precision = 19)
|
||||
private BigDecimal interestPortion;
|
||||
|
||||
@Column(name = "fee_charges_portion_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "fee_charges_portion_derived", scale = 6, precision = 19)
|
||||
private BigDecimal feeChargesPortion;
|
||||
|
||||
@Column(name = "penalty_charges_portion_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "penalty_charges_portion_derived", scale = 6, precision = 19)
|
||||
private BigDecimal penaltyChargesPortion;
|
||||
|
||||
@Column(name = "overpayment_portion_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "overpayment_portion_derived", scale = 6, precision = 19)
|
||||
private BigDecimal overPaymentPortion;
|
||||
|
||||
@Column(name = "unrecognized_income_portion", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "unrecognized_income_portion", scale = 6, precision = 19)
|
||||
private BigDecimal unrecognizedIncomePortion;
|
||||
|
||||
@Column(name = "is_reversed", nullable = false)
|
||||
private boolean reversed;
|
||||
|
||||
@Column(name = "external_id", length = 100, nullable = true, unique = true)
|
||||
@Column(name = "external_id", length = 100, unique = true)
|
||||
private ExternalId externalId;
|
||||
|
||||
@Column(name = "reversal_external_id", length = 100, nullable = true, unique = true)
|
||||
@Column(name = "reversal_external_id", length = 100, unique = true)
|
||||
private ExternalId reversalExternalId;
|
||||
|
||||
@Column(name = "reversed_on_date", nullable = true)
|
||||
@Column(name = "reversed_on_date")
|
||||
private LocalDate reversedOnDate;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanTransaction", orphanRemoval = true, fetch = FetchType.EAGER)
|
||||
@Setter
|
||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanTransaction", orphanRemoval = true, fetch = FetchType.LAZY)
|
||||
private Set<LoanChargePaidBy> loanChargesPaid = new HashSet<>();
|
||||
|
||||
@Column(name = "outstanding_loan_balance_derived", scale = 6, precision = 19, nullable = true)
|
||||
@Column(name = "outstanding_loan_balance_derived", scale = 6, precision = 19)
|
||||
private BigDecimal outstandingLoanBalance;
|
||||
|
||||
@Column(name = "manually_adjusted_or_reversed", nullable = false)
|
||||
private boolean manuallyAdjustedOrReversed;
|
||||
|
||||
@Column(name = "charge_refund_charge_type", length = 1, nullable = true, unique = true)
|
||||
@Column(name = "charge_refund_charge_type", length = 1, unique = true)
|
||||
private String chargeRefundChargeType;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "loanTransaction")
|
||||
private Set<LoanCollateralManagement> loanCollateralManagementSet = new HashSet<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER, mappedBy = "loanTransaction")
|
||||
@Getter
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "loanTransaction")
|
||||
private Set<LoanTransactionToRepaymentScheduleMapping> loanTransactionToRepaymentScheduleMappings = new HashSet<>();
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "fromTransaction")
|
||||
private Set<LoanTransactionRelation> loanTransactionRelations = new HashSet<>();
|
||||
|
||||
@Setter
|
||||
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY, mappedBy = "loanTransaction")
|
||||
private LoanReAgeParameter loanReAgeParameter;
|
||||
|
||||
@@ -209,17 +209,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
txnExternalId);
|
||||
}
|
||||
|
||||
public void setLoanTransactionToRepaymentScheduleMappings(final Integer installmentId, final BigDecimal chargePerInstallment) {
|
||||
for (LoanTransactionToRepaymentScheduleMapping loanTransactionToRepaymentScheduleMapping : this.loanTransactionToRepaymentScheduleMappings) {
|
||||
final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = loanTransactionToRepaymentScheduleMapping
|
||||
.getLoanRepaymentScheduleInstallment();
|
||||
if (loanRepaymentScheduleInstallment.getInstallmentNumber().equals(installmentId)) {
|
||||
loanRepaymentScheduleInstallment.updateLoanRepaymentSchedule(chargePerInstallment);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static LoanTransaction recoveryRepayment(final Office office, final Money amount, final PaymentDetail paymentDetail,
|
||||
final LocalDate paymentDate, final ExternalId externalId) {
|
||||
return new LoanTransaction(null, office, LoanTransactionType.RECOVERY_REPAYMENT, paymentDetail, amount.getAmount(), paymentDate,
|
||||
@@ -527,10 +516,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
return Money.of(currency, this.interestPortion);
|
||||
}
|
||||
|
||||
public Money getUnrecognizedIncomePortion(final MonetaryCurrency currency) {
|
||||
return Money.of(currency, this.unrecognizedIncomePortion);
|
||||
}
|
||||
|
||||
public Money getFeeChargesPortion(final MonetaryCurrency currency) {
|
||||
return Money.of(currency, this.feeChargesPortion);
|
||||
}
|
||||
@@ -563,10 +548,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
return !isReversed();
|
||||
}
|
||||
|
||||
public void setReversed() {
|
||||
this.reversed = true;
|
||||
}
|
||||
|
||||
public void setManuallyAdjustedOrReversed() {
|
||||
this.manuallyAdjustedOrReversed = true;
|
||||
}
|
||||
@@ -621,10 +602,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
return LoanTransactionType.INCOME_POSTING.equals(getTypeOf()) && isNotReversed();
|
||||
}
|
||||
|
||||
public boolean isNotIncomePosting() {
|
||||
return !isIncomePosting();
|
||||
}
|
||||
|
||||
public boolean isDisbursement() {
|
||||
return LoanTransactionType.DISBURSEMENT.equals(getTypeOf()) && isNotReversed();
|
||||
}
|
||||
@@ -649,10 +626,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
return LoanTransactionType.WAIVE_CHARGES.equals(getTypeOf()) && isNotReversed();
|
||||
}
|
||||
|
||||
public boolean isNotInterestWaiver() {
|
||||
return !isInterestWaiver();
|
||||
}
|
||||
|
||||
public boolean isWaiver() {
|
||||
return isInterestWaiver() || isChargesWaiver();
|
||||
}
|
||||
@@ -720,87 +693,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
return !MathUtil.isEmpty(amount);
|
||||
}
|
||||
|
||||
public Map<String, Object> toMapData(final String currencyCode) {
|
||||
final Map<String, Object> thisTransactionData = new LinkedHashMap<>();
|
||||
|
||||
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(this.typeOf);
|
||||
|
||||
thisTransactionData.put("id", getId());
|
||||
thisTransactionData.put("officeId", this.office.getId());
|
||||
thisTransactionData.put("type", transactionType);
|
||||
thisTransactionData.put("reversed", isReversed());
|
||||
thisTransactionData.put("date", getTransactionDate());
|
||||
thisTransactionData.put("currencyCode", currencyCode);
|
||||
thisTransactionData.put("amount", this.amount);
|
||||
thisTransactionData.put("netDisbursalAmount", this.loan.getNetDisbursalAmount());
|
||||
|
||||
if (transactionType.isChargeback()
|
||||
&& (getLoan().getCreditAllocationRules() == null || getLoan().getCreditAllocationRules().size() == 0)) {
|
||||
thisTransactionData.put("principalPortion", this.amount);
|
||||
} else {
|
||||
thisTransactionData.put("principalPortion", this.principalPortion);
|
||||
}
|
||||
|
||||
thisTransactionData.put("interestPortion", this.interestPortion);
|
||||
thisTransactionData.put("feeChargesPortion", this.feeChargesPortion);
|
||||
thisTransactionData.put("penaltyChargesPortion", this.penaltyChargesPortion);
|
||||
thisTransactionData.put("overPaymentPortion", this.overPaymentPortion);
|
||||
if (transactionType.isChargeRefund()) {
|
||||
thisTransactionData.put("chargeRefundChargeType", this.chargeRefundChargeType);
|
||||
}
|
||||
|
||||
if (this.paymentDetail != null) {
|
||||
thisTransactionData.put("paymentTypeId", this.paymentDetail.getPaymentType().getId());
|
||||
}
|
||||
|
||||
if (!this.loanChargesPaid.isEmpty()) {
|
||||
final List<Map<String, Object>> loanChargesPaidData = new ArrayList<>();
|
||||
for (final LoanChargePaidBy chargePaidBy : this.loanChargesPaid) {
|
||||
final Map<String, Object> loanChargePaidData = new LinkedHashMap<>();
|
||||
loanChargePaidData.put("chargeId", chargePaidBy.getLoanCharge().getCharge().getId());
|
||||
loanChargePaidData.put("isPenalty", chargePaidBy.getLoanCharge().isPenaltyCharge());
|
||||
loanChargePaidData.put("loanChargeId", chargePaidBy.getLoanCharge().getId());
|
||||
loanChargePaidData.put("amount", chargePaidBy.getAmount());
|
||||
|
||||
loanChargesPaidData.add(loanChargePaidData);
|
||||
}
|
||||
thisTransactionData.put("loanChargesPaid", loanChargesPaidData);
|
||||
}
|
||||
|
||||
if (transactionType.isChargeback() && this.overPaymentPortion != null && this.overPaymentPortion.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal principalPaid = overPaymentPortion;
|
||||
BigDecimal feePaid = BigDecimal.ZERO;
|
||||
BigDecimal penaltyPaid = BigDecimal.ZERO;
|
||||
if (getLoanTransactionToRepaymentScheduleMappings().size() > 0) {
|
||||
principalPaid = getLoanTransactionToRepaymentScheduleMappings().stream()
|
||||
.map(mapping -> Optional.ofNullable(mapping.getPrincipalPortion()).orElse(BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
feePaid = getLoanTransactionToRepaymentScheduleMappings().stream()
|
||||
.map(mapping -> Optional.ofNullable(mapping.getFeeChargesPortion()).orElse(BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
penaltyPaid = getLoanTransactionToRepaymentScheduleMappings().stream()
|
||||
.map(mapping -> Optional.ofNullable(mapping.getPenaltyChargesPortion()).orElse(BigDecimal.ZERO))
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
}
|
||||
thisTransactionData.put("principalPaid", principalPaid);
|
||||
thisTransactionData.put("feePaid", feePaid);
|
||||
thisTransactionData.put("penaltyPaid", penaltyPaid);
|
||||
}
|
||||
|
||||
LoanTransactionRelation loanTransactionRelation = loanTransactionRelations.stream()
|
||||
.filter(e -> LoanTransactionRelationTypeEnum.CHARGE_ADJUSTMENT.equals(e.getRelationType())).findAny().orElse(null);
|
||||
if (loanTransactionRelation != null) {
|
||||
LoanCharge loanCharge = loanTransactionRelation.getToCharge();
|
||||
thisTransactionData.put("loanChargeData", loanCharge.toData());
|
||||
}
|
||||
|
||||
return thisTransactionData;
|
||||
}
|
||||
|
||||
public void setLoanChargesPaid(final Set<LoanChargePaidBy> loanChargesPaid) {
|
||||
this.loanChargesPaid = loanChargesPaid;
|
||||
}
|
||||
|
||||
public boolean isRefund() {
|
||||
return LoanTransactionType.REFUND.equals(getTypeOf()) && isNotReversed();
|
||||
}
|
||||
@@ -878,7 +770,7 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
}
|
||||
}
|
||||
|
||||
private boolean updateMappingDetail(final Collection<LoanTransactionToRepaymentScheduleMapping> retainMappings,
|
||||
private void updateMappingDetail(final Collection<LoanTransactionToRepaymentScheduleMapping> retainMappings,
|
||||
final LoanTransactionToRepaymentScheduleMapping updatedMapping, boolean overwrite) {
|
||||
boolean isMappingUpdated = false;
|
||||
LoanRepaymentScheduleInstallment updatedInstallment = updatedMapping.getLoanRepaymentScheduleInstallment();
|
||||
@@ -910,7 +802,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
retainMappings.add(newMapping);
|
||||
}
|
||||
}
|
||||
return isMappingUpdated;
|
||||
}
|
||||
|
||||
public void updateLoanChargePaidMappings(final Collection<LoanChargePaidBy> updatedMappings) {
|
||||
@@ -921,7 +812,7 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
this.loanChargesPaid.retainAll(retainMappings);
|
||||
}
|
||||
|
||||
private boolean updateLoanChargePaid(final Collection<LoanChargePaidBy> retainMappings, final LoanChargePaidBy updatedMapping) {
|
||||
private void updateLoanChargePaid(final Collection<LoanChargePaidBy> retainMappings, final LoanChargePaidBy updatedMapping) {
|
||||
boolean updated = false;
|
||||
LoanCharge updatedCharge = updatedMapping.getLoanCharge();
|
||||
Integer updatedInstallment = updatedMapping.getInstallmentNumber();
|
||||
@@ -941,11 +832,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
this.loanChargesPaid.add(newMapping);
|
||||
retainMappings.add(newMapping);
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
public Set<LoanTransactionToRepaymentScheduleMapping> getLoanTransactionToRepaymentScheduleMappings() {
|
||||
return this.loanTransactionToRepaymentScheduleMappings;
|
||||
}
|
||||
|
||||
public Boolean isAllowTypeTransactionAtTheTimeOfLastUndo() {
|
||||
@@ -961,10 +847,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
|| this.isIncomePosting());
|
||||
}
|
||||
|
||||
public LocalDate getSubmittedOnDate() {
|
||||
return submittedOnDate;
|
||||
}
|
||||
|
||||
public boolean hasLoanTransactionRelations() {
|
||||
return !loanTransactionRelations.isEmpty();
|
||||
}
|
||||
@@ -996,10 +878,6 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom<Long
|
||||
return DateUtils.isEqual(getTransactionDate(), date);
|
||||
}
|
||||
|
||||
public void setLoanReAgeParameter(LoanReAgeParameter loanReAgeParameter) {
|
||||
this.loanReAgeParameter = loanReAgeParameter;
|
||||
}
|
||||
|
||||
public boolean happenedBefore(LoanTransaction loanTransaction) {
|
||||
return LoanTransactionComparator.INSTANCE.compare(this, loanTransaction) < 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user