Removing Hibernate annotations
This commit is contained in:
+1
@@ -3805,6 +3805,7 @@ public class ClientLoanIntegrationTest {
|
|||||||
final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE,
|
final Integer loanID = applyForLoanApplicationForInterestRecalculation(clientID, loanProductID, LOAN_DISBURSEMENT_DATE,
|
||||||
REST_START_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, null);
|
REST_START_DATE, LoanApplicationTestBuilder.DEFAULT_STRATEGY, null);
|
||||||
|
|
||||||
|
|
||||||
Assert.assertNotNull(loanID);
|
Assert.assertNotNull(loanID);
|
||||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
|
||||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||||
|
|||||||
+5
-6
@@ -21,10 +21,12 @@ package org.apache.fineract.accounting.provisioning.domain;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
@@ -33,8 +35,6 @@ import javax.persistence.Temporal;
|
|||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -44,9 +44,8 @@ public class ProvisioningEntry extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "journal_entry_created")
|
@Column(name = "journal_entry_created")
|
||||||
private Boolean isJournalEntryCreated;
|
private Boolean isJournalEntryCreated;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "entry", orphanRemoval = true)
|
Set<LoanProductProvisioningEntry> provisioningEntries = new HashSet<>();
|
||||||
Collection<LoanProductProvisioningEntry> provisioningEntries = new HashSet<>();
|
|
||||||
|
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "createdby_id")
|
@JoinColumn(name = "createdby_id")
|
||||||
@@ -68,7 +67,7 @@ public class ProvisioningEntry extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProvisioningEntry(AppUser createdBy, Date createdDate, AppUser lastModifiedBy, Date lastModifiedDate, Collection<LoanProductProvisioningEntry> provisioningEntries ) {
|
public ProvisioningEntry(AppUser createdBy, Date createdDate, AppUser lastModifiedBy, Date lastModifiedDate, Set<LoanProductProvisioningEntry> provisioningEntries ) {
|
||||||
this.provisioningEntries = provisioningEntries ;
|
this.provisioningEntries = provisioningEntries ;
|
||||||
this.createdBy = createdBy ;
|
this.createdBy = createdBy ;
|
||||||
this.createdDate = createdDate ;
|
this.createdDate = createdDate ;
|
||||||
|
|||||||
+2
-5
@@ -22,6 +22,7 @@ import java.util.Collection;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
|
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
|
||||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository;
|
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepository;
|
||||||
@@ -58,8 +59,6 @@ import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
|
|||||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.dao.DataIntegrityViolationException;
|
import org.springframework.dao.DataIntegrityViolationException;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -69,8 +68,6 @@ import com.google.gson.JsonObject;
|
|||||||
@Service
|
@Service
|
||||||
public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements ProvisioningEntriesWritePlatformService {
|
public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements ProvisioningEntriesWritePlatformService {
|
||||||
|
|
||||||
private final static Logger logger = LoggerFactory.getLogger(ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl.class);
|
|
||||||
|
|
||||||
private final ProvisioningEntriesReadPlatformService provisioningEntriesReadPlatformService;
|
private final ProvisioningEntriesReadPlatformService provisioningEntriesReadPlatformService;
|
||||||
private final ProvisioningCriteriaReadPlatformService provisioningCriteriaReadPlatformService ;
|
private final ProvisioningCriteriaReadPlatformService provisioningCriteriaReadPlatformService ;
|
||||||
private final LoanProductRepository loanProductRepository;
|
private final LoanProductRepository loanProductRepository;
|
||||||
@@ -192,7 +189,7 @@ public class ProvisioningEntriesWritePlatformServiceJpaRepositoryImpl implements
|
|||||||
AppUser currentUser = this.platformSecurityContext.authenticatedUser();
|
AppUser currentUser = this.platformSecurityContext.authenticatedUser();
|
||||||
AppUser lastModifiedBy = null;
|
AppUser lastModifiedBy = null;
|
||||||
Date lastModifiedDate = null;
|
Date lastModifiedDate = null;
|
||||||
Collection<LoanProductProvisioningEntry> nullEntries = null;
|
Set<LoanProductProvisioningEntry> nullEntries = null;
|
||||||
ProvisioningEntry requestedEntry = new ProvisioningEntry(currentUser, date, lastModifiedBy, lastModifiedDate, nullEntries);
|
ProvisioningEntry requestedEntry = new ProvisioningEntry(currentUser, date, lastModifiedBy, lastModifiedDate, nullEntries);
|
||||||
Collection<LoanProductProvisioningEntry> entries = generateLoanProvisioningEntry(requestedEntry, date);
|
Collection<LoanProductProvisioningEntry> entries = generateLoanProvisioningEntry(requestedEntry, date);
|
||||||
requestedEntry.setProvisioningEntries(entries);
|
requestedEntry.setProvisioningEntries(entries);
|
||||||
|
|||||||
+2
-4
@@ -28,6 +28,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -40,8 +41,6 @@ import org.apache.fineract.accounting.journalentry.domain.JournalEntryType;
|
|||||||
import org.apache.fineract.accounting.rule.api.AccountingRuleJsonInputParams;
|
import org.apache.fineract.accounting.rule.api.AccountingRuleJsonInputParams;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.organisation.office.domain.Office;
|
import org.apache.fineract.organisation.office.domain.Office;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -69,8 +68,7 @@ public class AccountingRule extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "system_defined", nullable = false)
|
@Column(name = "system_defined", nullable = false)
|
||||||
private Boolean systemDefined;
|
private Boolean systemDefined;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accountingRule", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accountingRule", orphanRemoval = true)
|
|
||||||
private final List<AccountingTagRule> accountingTagRules = new ArrayList<>();
|
private final List<AccountingTagRule> accountingTagRules = new ArrayList<>();
|
||||||
|
|
||||||
@Column(name = "allow_multiple_credits", nullable = false)
|
@Column(name = "allow_multiple_credits", nullable = false)
|
||||||
|
|||||||
+2
-4
@@ -29,6 +29,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
@@ -39,8 +40,6 @@ import org.apache.fineract.infrastructure.core.data.ApiParameterError;
|
|||||||
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
|
import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||||
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
import org.apache.fineract.infrastructure.core.exception.PlatformDataIntegrityException;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
@@ -74,8 +73,7 @@ public final class Report extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "report_sql")
|
@Column(name = "report_sql")
|
||||||
private String reportSql;
|
private String reportSql;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "report", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "report", orphanRemoval = true)
|
|
||||||
private final Set<ReportParameterUsage> reportParameterUsages = new HashSet<>();
|
private final Set<ReportParameterUsage> reportParameterUsages = new HashSet<>();
|
||||||
|
|
||||||
public static Report fromJson(final JsonCommand command, final Collection<String> reportTypes) {
|
public static Report fromJson(final JsonCommand command, final Collection<String> reportTypes) {
|
||||||
|
|||||||
+4
-6
@@ -20,16 +20,16 @@ package org.apache.fineract.infrastructure.hooks.domain;
|
|||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
||||||
import org.apache.fineract.template.domain.Template;
|
import org.apache.fineract.template.domain.Template;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import javax.persistence.*;
|
import javax.persistence.*;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -47,12 +47,10 @@ public class Hook extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "is_active", nullable = false)
|
@Column(name = "is_active", nullable = false)
|
||||||
private Boolean isActive;
|
private Boolean isActive;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "hook", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "hook", orphanRemoval = true)
|
|
||||||
private Set<HookResource> events = new HashSet<>();
|
private Set<HookResource> events = new HashSet<>();
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "hook", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "hook", orphanRemoval = true)
|
|
||||||
private Set<HookConfiguration> config = new HashSet<>();
|
private Set<HookConfiguration> config = new HashSet<>();
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true)
|
||||||
|
|||||||
+2
-4
@@ -26,13 +26,12 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -42,8 +41,7 @@ public class HookTemplate extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "name", nullable = false, length = 100)
|
@Column(name = "name", nullable = false, length = 100)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "template", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "template", orphanRemoval = true)
|
|
||||||
private final Set<Schema> fields = new HashSet<>();
|
private final Set<Schema> fields = new HashSet<>();
|
||||||
|
|
||||||
private HookTemplate(final String name) {
|
private HookTemplate(final String name) {
|
||||||
|
|||||||
+3
-6
@@ -27,6 +27,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
@@ -38,8 +39,6 @@ import org.apache.fineract.organisation.provisioning.constants.ProvisioningCrite
|
|||||||
import org.apache.fineract.organisation.provisioning.data.ProvisioningCriteriaDefinitionData;
|
import org.apache.fineract.organisation.provisioning.data.ProvisioningCriteriaDefinitionData;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -49,12 +48,10 @@ public class ProvisioningCriteria extends AbstractAuditableCustom<AppUser, Long>
|
|||||||
@Column(name = "criteria_name", nullable = false)
|
@Column(name = "criteria_name", nullable = false)
|
||||||
private String criteriaName;
|
private String criteriaName;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "criteria", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "criteria", orphanRemoval = true)
|
|
||||||
Set<ProvisioningCriteriaDefinition> provisioningCriteriaDefinition = new HashSet<>();
|
Set<ProvisioningCriteriaDefinition> provisioningCriteriaDefinition = new HashSet<>();
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "criteria", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "criteria", orphanRemoval = true)
|
|
||||||
Set<LoanProductProvisionCriteria> loanProductMapping = new HashSet<>();
|
Set<LoanProductProvisionCriteria> loanProductMapping = new HashSet<>();
|
||||||
|
|
||||||
public String getCriteriaName() {
|
public String getCriteriaName() {
|
||||||
|
|||||||
+1
-4
@@ -35,8 +35,6 @@ import org.apache.fineract.organisation.office.domain.Office;
|
|||||||
import org.apache.fineract.portfolio.client.domain.Client;
|
import org.apache.fineract.portfolio.client.domain.Client;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -78,8 +76,7 @@ public class AccountTransferDetails extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "transfer_type")
|
@Column(name = "transfer_type")
|
||||||
private Integer transferType;
|
private Integer transferType;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accountTransferDetails", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accountTransferDetails", orphanRemoval = true)
|
|
||||||
private final List<AccountTransferTransaction> accountTransferTransactions = new ArrayList<>();
|
private final List<AccountTransferTransaction> accountTransferTransactions = new ArrayList<>();
|
||||||
|
|
||||||
@OneToOne(mappedBy = "accountTransferDetails", cascade = CascadeType.ALL, optional = true, orphanRemoval = true, fetch = FetchType.LAZY)
|
@OneToOne(mappedBy = "accountTransferDetails", cascade = CascadeType.ALL, optional = true, orphanRemoval = true, fetch = FetchType.LAZY)
|
||||||
|
|||||||
+1
-4
@@ -57,8 +57,6 @@ import org.apache.fineract.portfolio.group.domain.Group;
|
|||||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
||||||
import org.apache.fineract.portfolio.savings.domain.SavingsProduct;
|
import org.apache.fineract.portfolio.savings.domain.SavingsProduct;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
@@ -134,8 +132,7 @@ public final class Client extends AbstractPersistable<Long> {
|
|||||||
@JoinColumn(name = "staff_id")
|
@JoinColumn(name = "staff_id")
|
||||||
private Staff staff;
|
private Staff staff;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@ManyToMany(fetch=FetchType.EAGER)
|
||||||
@ManyToMany
|
|
||||||
@JoinTable(name = "m_group_client", joinColumns = @JoinColumn(name = "client_id"), inverseJoinColumns = @JoinColumn(name = "group_id"))
|
@JoinTable(name = "m_group_client", joinColumns = @JoinColumn(name = "client_id"), inverseJoinColumns = @JoinColumn(name = "group_id"))
|
||||||
private Set<Group> groups;
|
private Set<Group> groups;
|
||||||
|
|
||||||
|
|||||||
+2
-4
@@ -30,6 +30,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -48,8 +49,6 @@ import org.apache.fineract.organisation.office.domain.Office;
|
|||||||
import org.apache.fineract.organisation.office.domain.OrganisationCurrency;
|
import org.apache.fineract.organisation.office.domain.OrganisationCurrency;
|
||||||
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@@ -96,8 +95,7 @@ public class ClientTransaction extends AbstractPersistable<Long> {
|
|||||||
@JoinColumn(name = "appuser_id", nullable = true)
|
@JoinColumn(name = "appuser_id", nullable = true)
|
||||||
private AppUser appUser;
|
private AppUser appUser;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clientTransaction", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "clientTransaction", orphanRemoval = true)
|
|
||||||
private Set<ClientChargePaidBy> clientChargePaidByCollection = new HashSet<>();
|
private Set<ClientChargePaidBy> clientChargePaidByCollection = new HashSet<>();
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
|
|||||||
+2
-4
@@ -30,6 +30,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -43,8 +44,6 @@ import org.apache.fineract.infrastructure.core.service.DateUtils;
|
|||||||
import org.apache.fineract.portfolio.floatingrates.data.FloatingRateDTO;
|
import org.apache.fineract.portfolio.floatingrates.data.FloatingRateDTO;
|
||||||
import org.apache.fineract.portfolio.floatingrates.data.FloatingRatePeriodData;
|
import org.apache.fineract.portfolio.floatingrates.data.FloatingRatePeriodData;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@@ -66,8 +65,7 @@ public class FloatingRate extends AbstractPersistable<Long> {
|
|||||||
private boolean isActive;
|
private boolean isActive;
|
||||||
|
|
||||||
@OrderBy(value = "fromDate,id")
|
@OrderBy(value = "fromDate,id")
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "floatingRate", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "floatingRate", orphanRemoval = true)
|
|
||||||
private Set<FloatingRatePeriod> floatingRatePeriods;
|
private Set<FloatingRatePeriod> floatingRatePeriods;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true)
|
||||||
|
|||||||
-1
@@ -48,7 +48,6 @@ import org.apache.fineract.portfolio.loanproduct.data.TransactionProcessingStrat
|
|||||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductConfigurableAttributes;
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductConfigurableAttributes;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductValueConditionType;
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductValueConditionType;
|
||||||
import org.apache.fineract.portfolio.note.data.NoteData;
|
import org.apache.fineract.portfolio.note.data.NoteData;
|
||||||
import org.hibernate.dialect.Sybase11Dialect;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
|||||||
+188
-151
@@ -40,6 +40,7 @@ import javax.persistence.CascadeType;
|
|||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -130,8 +131,6 @@ import org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyTy
|
|||||||
import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
|
import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
|
||||||
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.Days;
|
import org.joda.time.Days;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
@@ -172,23 +171,23 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "loan_type_enum", nullable = false)
|
@Column(name = "loan_type_enum", nullable = false)
|
||||||
private Integer loanType;
|
private Integer loanType;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch=FetchType.EAGER)
|
||||||
@JoinColumn(name = "product_id", nullable = false)
|
@JoinColumn(name = "product_id", nullable = false)
|
||||||
private LoanProduct loanProduct;
|
private LoanProduct loanProduct;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.EAGER)
|
||||||
@JoinColumn(name = "fund_id", nullable = true)
|
@JoinColumn(name = "fund_id", nullable = true)
|
||||||
private Fund fund;
|
private Fund fund;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch=FetchType.EAGER)
|
||||||
@JoinColumn(name = "loan_officer_id", nullable = true)
|
@JoinColumn(name = "loan_officer_id", nullable = true)
|
||||||
private Staff loanOfficer;
|
private Staff loanOfficer;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "loanpurpose_cv_id", nullable = true)
|
@JoinColumn(name = "loanpurpose_cv_id", nullable = true)
|
||||||
private CodeValue loanPurpose;
|
private CodeValue loanPurpose;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch=FetchType.EAGER)
|
||||||
@JoinColumn(name = "loan_transaction_strategy_id", nullable = true)
|
@JoinColumn(name = "loan_transaction_strategy_id", nullable = true)
|
||||||
private LoanTransactionProcessingStrategy transactionProcessingStrategy;
|
private LoanTransactionProcessingStrategy transactionProcessingStrategy;
|
||||||
|
|
||||||
@@ -212,7 +211,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "submittedon_date")
|
@Column(name = "submittedon_date")
|
||||||
private Date submittedOnDate;
|
private Date submittedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "submittedon_userid", nullable = true)
|
@JoinColumn(name = "submittedon_userid", nullable = true)
|
||||||
private AppUser submittedBy;
|
private AppUser submittedBy;
|
||||||
|
|
||||||
@@ -220,7 +219,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "rejectedon_date")
|
@Column(name = "rejectedon_date")
|
||||||
private Date rejectedOnDate;
|
private Date rejectedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "rejectedon_userid", nullable = true)
|
@JoinColumn(name = "rejectedon_userid", nullable = true)
|
||||||
private AppUser rejectedBy;
|
private AppUser rejectedBy;
|
||||||
|
|
||||||
@@ -228,7 +227,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "withdrawnon_date")
|
@Column(name = "withdrawnon_date")
|
||||||
private Date withdrawnOnDate;
|
private Date withdrawnOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "withdrawnon_userid", nullable = true)
|
@JoinColumn(name = "withdrawnon_userid", nullable = true)
|
||||||
private AppUser withdrawnBy;
|
private AppUser withdrawnBy;
|
||||||
|
|
||||||
@@ -236,7 +235,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "approvedon_date")
|
@Column(name = "approvedon_date")
|
||||||
private Date approvedOnDate;
|
private Date approvedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "approvedon_userid", nullable = true)
|
@JoinColumn(name = "approvedon_userid", nullable = true)
|
||||||
private AppUser approvedBy;
|
private AppUser approvedBy;
|
||||||
|
|
||||||
@@ -248,7 +247,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "disbursedon_date")
|
@Column(name = "disbursedon_date")
|
||||||
private Date actualDisbursementDate;
|
private Date actualDisbursementDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "disbursedon_userid", nullable = true)
|
@JoinColumn(name = "disbursedon_userid", nullable = true)
|
||||||
private AppUser disbursedBy;
|
private AppUser disbursedBy;
|
||||||
|
|
||||||
@@ -256,7 +255,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "closedon_date")
|
@Column(name = "closedon_date")
|
||||||
private Date closedOnDate;
|
private Date closedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "closedon_userid", nullable = true)
|
@JoinColumn(name = "closedon_userid", nullable = true)
|
||||||
private AppUser closedBy;
|
private AppUser closedBy;
|
||||||
|
|
||||||
@@ -268,7 +267,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "rescheduledon_date")
|
@Column(name = "rescheduledon_date")
|
||||||
private Date rescheduledOnDate;
|
private Date rescheduledOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "rescheduledon_userid", nullable = true)
|
@JoinColumn(name = "rescheduledon_userid", nullable = true)
|
||||||
private AppUser rescheduledByUser;
|
private AppUser rescheduledByUser;
|
||||||
|
|
||||||
@@ -297,35 +296,37 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "loan_product_counter")
|
@Column(name = "loan_product_counter")
|
||||||
private Integer loanProductCounter;
|
private Integer loanProductCounter;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
|
||||||
private Set<LoanCharge> charges = new HashSet<>();
|
private Set<LoanCharge> charges = new HashSet<>();
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
|
||||||
private Set<LoanTrancheCharge> trancheCharges = new HashSet<>();
|
private Set<LoanTrancheCharge> trancheCharges = new HashSet<>();
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.LAZY)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
|
||||||
private Set<LoanCollateral> collateral = null;
|
private Set<LoanCollateral> collateral = null;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.LAZY)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
|
||||||
private Set<LoanOfficerAssignmentHistory> loanOfficerHistory;
|
private Set<LoanOfficerAssignmentHistory> loanOfficerHistory;
|
||||||
|
|
||||||
// see
|
// see
|
||||||
// http://stackoverflow.com/questions/4334970/hibernate-cannot-simultaneously-fetch-multiple-bags
|
// http://stackoverflow.com/questions/4334970/hibernate-cannot-simultaneously-fetch-multiple-bags
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
|
||||||
@OrderBy(value = "installmentNumber")
|
@OrderBy(value = "installmentNumber")
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
private final List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments = new ArrayList<>();
|
private final Set<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments = new HashSet<>();
|
||||||
|
|
||||||
// see
|
// see
|
||||||
// http://stackoverflow.com/questions/4334970/hibernate-cannot-simultaneously-fetch-multiple-bags
|
// http://stackoverflow.com/questions/4334970/hibernate-cannot-simultaneously-fetch-multiple-bags
|
||||||
@OrderBy(value = "dateOf, id")
|
@OrderBy(value = "dateOf, id")
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
private final Set<LoanTransaction> loanTransactions = new HashSet<>();
|
||||||
private final List<LoanTransaction> loanTransactions = new ArrayList<>();
|
|
||||||
|
private transient List<LoanTransaction> sortedTransactions = null ;
|
||||||
|
|
||||||
|
private transient boolean isTransactionsListDirty = false ;
|
||||||
|
|
||||||
|
private transient List<LoanRepaymentScheduleInstallment> sortedrepaymentScheduleInstallments = null ;
|
||||||
|
|
||||||
|
private transient boolean isrepaymentScheduleInstallmentsListDirty = false ;
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
private LoanSummary summary;
|
private LoanSummary summary;
|
||||||
@@ -352,21 +353,18 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "max_outstanding_loan_balance", scale = 6, precision = 19, nullable = false)
|
@Column(name = "max_outstanding_loan_balance", scale = 6, precision = 19, nullable = false)
|
||||||
private BigDecimal maxOutstandingLoanBalance;
|
private BigDecimal maxOutstandingLoanBalance;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
|
||||||
@OrderBy(value = "expectedDisbursementDate, id")
|
@OrderBy(value = "expectedDisbursementDate, id")
|
||||||
private Set<LoanDisbursementDetails> disbursementDetails = new HashSet<>();
|
private Set<LoanDisbursementDetails> disbursementDetails = new HashSet<>();
|
||||||
|
|
||||||
@OrderBy(value = "termApplicableFrom, id")
|
@OrderBy(value = "termApplicableFrom, id")
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true)
|
private final Set<LoanTermVariations> loanTermVariations = new HashSet<>();
|
||||||
private final List<LoanTermVariations> loanTermVariations = new ArrayList<>();
|
|
||||||
|
|
||||||
@Column(name = "total_recovered_derived", scale = 6, precision = 19)
|
@Column(name = "total_recovered_derived", scale = 6, precision = 19)
|
||||||
private BigDecimal totalRecovered;
|
private BigDecimal totalRecovered;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loan", optional = true, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loan", optional = true, orphanRemoval = true)
|
|
||||||
private LoanInterestRecalculationDetails loanInterestRecalculationDetails;
|
private LoanInterestRecalculationDetails loanInterestRecalculationDetails;
|
||||||
|
|
||||||
@Column(name = "is_npa", nullable = false)
|
@Column(name = "is_npa", nullable = false)
|
||||||
@@ -392,7 +390,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "interest_rate_differential", scale = 6, precision = 19, nullable = true)
|
@Column(name = "interest_rate_differential", scale = 6, precision = 19, nullable = true)
|
||||||
private BigDecimal interestRateDifferential;
|
private BigDecimal interestRateDifferential;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "writeoff_reason_cv_id", nullable = true)
|
@JoinColumn(name = "writeoff_reason_cv_id", nullable = true)
|
||||||
private CodeValue writeOffReason;
|
private CodeValue writeOffReason;
|
||||||
|
|
||||||
@@ -616,7 +614,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
// store Id's of existing loan transactions and existing reversed loan
|
// store Id's of existing loan transactions and existing reversed loan
|
||||||
// transactions
|
// transactions
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), getRepaymentScheduleInstallments(), charges());
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -627,11 +625,12 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
}
|
}
|
||||||
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactionMappings().values());
|
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactionMappings().values());
|
||||||
|
this.isTransactionsListDirty = true ;
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
this.loanTransactions.removeAll(changedTransactionDetail.getNewTransactionMappings().values());
|
this.loanTransactions.removeAll(changedTransactionDetail.getNewTransactionMappings().values());
|
||||||
return changedTransactionDetail;
|
return changedTransactionDetail;
|
||||||
@@ -681,7 +680,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(applyLoanChargeTransaction, loanCharge, loanCharge.getAmount(
|
final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(applyLoanChargeTransaction, loanCharge, loanCharge.getAmount(
|
||||||
getCurrency()).getAmount(), installmentNumber);
|
getCurrency()).getAmount(), installmentNumber);
|
||||||
applyLoanChargeTransaction.getLoanChargesPaid().add(loanChargePaidBy);
|
applyLoanChargeTransaction.getLoanChargesPaid().add(loanChargePaidBy);
|
||||||
this.loanTransactions.add(applyLoanChargeTransaction);
|
addLoanTransaction(applyLoanChargeTransaction);
|
||||||
return applyLoanChargeTransaction;
|
return applyLoanChargeTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -691,7 +690,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(chargesPayment, charge, chargesPayment.getAmount(getCurrency())
|
final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(chargesPayment, charge, chargesPayment.getAmount(getCurrency())
|
||||||
.getAmount(), installmentNumber);
|
.getAmount(), installmentNumber);
|
||||||
chargesPayment.getLoanChargesPaid().add(loanChargePaidBy);
|
chargesPayment.getLoanChargesPaid().add(loanChargePaidBy);
|
||||||
this.loanTransactions.add(chargesPayment);
|
addLoanTransaction(chargesPayment);
|
||||||
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_CHARGE_PAYMENT,
|
final LoanStatus statusEnum = loanLifecycleStateMachine.transition(LoanEvent.LOAN_CHARGE_PAYMENT,
|
||||||
LoanStatus.fromInt(this.loanStatus));
|
LoanStatus.fromInt(this.loanStatus));
|
||||||
this.loanStatus = statusEnum.getValue();
|
this.loanStatus = statusEnum.getValue();
|
||||||
@@ -700,7 +699,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
final List<LoanRepaymentScheduleInstallment> chargePaymentInstallments = new ArrayList<>();
|
final List<LoanRepaymentScheduleInstallment> chargePaymentInstallments = new ArrayList<>();
|
||||||
LocalDate startDate = getDisbursementDate();
|
LocalDate startDate = getDisbursementDate();
|
||||||
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installmentNumber == null && charge.isDueForCollectionFromAndUpToAndIncluding(startDate, installment.getDueDate())) {
|
if (installmentNumber == null && charge.isDueForCollectionFromAndUpToAndIncluding(startDate, installment.getDueDate())) {
|
||||||
chargePaymentInstallments.add(installment);
|
chargePaymentInstallments.add(installment);
|
||||||
break;
|
break;
|
||||||
@@ -743,7 +743,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
private LocalDate getLastRepaymentPeriodDueDate(final boolean includeRecalculatedInterestComponent) {
|
private LocalDate getLastRepaymentPeriodDueDate(final boolean includeRecalculatedInterestComponent) {
|
||||||
LocalDate lastRepaymentDate = getDisbursementDate();
|
LocalDate lastRepaymentDate = getDisbursementDate();
|
||||||
for (LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if ((includeRecalculatedInterestComponent || !installment.isRecalculatedInterestComponent())
|
if ((includeRecalculatedInterestComponent || !installment.isRecalculatedInterestComponent())
|
||||||
&& installment.getDueDate().isAfter(lastRepaymentDate)) {
|
&& installment.getDueDate().isAfter(lastRepaymentDate)) {
|
||||||
lastRepaymentDate = installment.getDueDate();
|
lastRepaymentDate = installment.getDueDate();
|
||||||
@@ -765,7 +766,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
if (removed) {
|
if (removed) {
|
||||||
loanCharge.setActive(false);
|
loanCharge.setActive(false);
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), getRepaymentScheduleInstallments(), charges());
|
||||||
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
updateSummaryWithTotalFeeChargesDueAtDisbursement(deriveSumTotalOfChargesDueAtDisbursement());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -784,7 +785,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
***/
|
***/
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
||||||
getCurrency(), this.repaymentScheduleInstallments, charges());
|
getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
}
|
}
|
||||||
this.charges.remove(loanCharge);
|
this.charges.remove(loanCharge);
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -793,7 +794,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
private void removeOrModifyTransactionAssociatedWithLoanChargeIfDueAtDisbursement(final LoanCharge loanCharge) {
|
private void removeOrModifyTransactionAssociatedWithLoanChargeIfDueAtDisbursement(final LoanCharge loanCharge) {
|
||||||
if (loanCharge.isDueAtDisbursement()) {
|
if (loanCharge.isDueAtDisbursement()) {
|
||||||
LoanTransaction transactionToRemove = null;
|
LoanTransaction transactionToRemove = null;
|
||||||
for (final LoanTransaction transaction : this.loanTransactions) {
|
List<LoanTransaction> transactions = getLoanTransactions() ;
|
||||||
|
for (final LoanTransaction transaction : transactions) {
|
||||||
if (transaction.isRepaymentAtDisbursement() && transaction.getLoanChargesPaid().contains(loanCharge)) {
|
if (transaction.isRepaymentAtDisbursement() && transaction.getLoanChargesPaid().contains(loanCharge)) {
|
||||||
|
|
||||||
final MonetaryCurrency currency = loanCurrency();
|
final MonetaryCurrency currency = loanCurrency();
|
||||||
@@ -842,11 +844,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
***/
|
***/
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
||||||
getCurrency(), this.repaymentScheduleInstallments, charges());
|
getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
} else {
|
} else {
|
||||||
// reprocess loan schedule based on charge been waived.
|
// reprocess loan schedule based on charge been waived.
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), getRepaymentScheduleInstallments(), charges());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -889,7 +891,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public BigDecimal getTotalInterest() {
|
public BigDecimal getTotalInterest() {
|
||||||
return this.loanSummaryWrapper.calculateTotalInterestCharged(this.repaymentScheduleInstallments, getCurrency()).getAmount();
|
return this.loanSummaryWrapper.calculateTotalInterestCharged(getRepaymentScheduleInstallments(), getCurrency()).getAmount();
|
||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal calculatePerInstallmentChargeAmount(final LoanCharge loanCharge) {
|
private BigDecimal calculatePerInstallmentChargeAmount(final LoanCharge loanCharge) {
|
||||||
@@ -898,7 +900,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public BigDecimal calculatePerInstallmentChargeAmount(final ChargeCalculationType calculationType, final BigDecimal percentage) {
|
public BigDecimal calculatePerInstallmentChargeAmount(final ChargeCalculationType calculationType, final BigDecimal percentage) {
|
||||||
Money amount = Money.zero(getCurrency());
|
Money amount = Money.zero(getCurrency());
|
||||||
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
amount = amount.plus(calculateInstallmentChargeAmount(calculationType, percentage, installment));
|
amount = amount.plus(calculateInstallmentChargeAmount(calculationType, percentage, installment));
|
||||||
}
|
}
|
||||||
return amount.getAmount();
|
return amount.getAmount();
|
||||||
@@ -995,8 +998,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(waiveLoanChargeTransaction, loanCharge, waiveLoanChargeTransaction
|
final LoanChargePaidBy loanChargePaidBy = new LoanChargePaidBy(waiveLoanChargeTransaction, loanCharge, waiveLoanChargeTransaction
|
||||||
.getAmount(getCurrency()).getAmount(), loanInstallmentNumber);
|
.getAmount(getCurrency()).getAmount(), loanInstallmentNumber);
|
||||||
waiveLoanChargeTransaction.getLoanChargesPaid().add(loanChargePaidBy);
|
waiveLoanChargeTransaction.getLoanChargesPaid().add(loanChargePaidBy);
|
||||||
this.loanTransactions.add(waiveLoanChargeTransaction);
|
addLoanTransaction(waiveLoanChargeTransaction) ;
|
||||||
|
|
||||||
if (this.repaymentScheduleDetail().isInterestRecalculationEnabled()
|
if (this.repaymentScheduleDetail().isInterestRecalculationEnabled()
|
||||||
&& (loanCharge.getDueLocalDate() == null || LocalDate.now().isAfter(loanCharge.getDueLocalDate()))) {
|
&& (loanCharge.getDueLocalDate() == null || LocalDate.now().isAfter(loanCharge.getDueLocalDate()))) {
|
||||||
regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO, currentUser);
|
regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO, currentUser);
|
||||||
@@ -1016,11 +1018,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
***/
|
***/
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), allNonContraTransactionsPostDisbursement,
|
||||||
getCurrency(), this.repaymentScheduleInstallments, charges());
|
getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
} else {
|
} else {
|
||||||
// reprocess loan schedule based on charge been waived.
|
// reprocess loan schedule based on charge been waived.
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), getRepaymentScheduleInstallments(), charges());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -1139,7 +1141,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public void updateLoanSchedule(final LoanScheduleModel modifiedLoanSchedule, AppUser currentUser) {
|
public void updateLoanSchedule(final LoanScheduleModel modifiedLoanSchedule, AppUser currentUser) {
|
||||||
this.repaymentScheduleInstallments.clear();
|
this.repaymentScheduleInstallments.clear();
|
||||||
|
this.isrepaymentScheduleInstallmentsListDirty = true ;
|
||||||
for (final LoanScheduleModelPeriod scheduledLoanInstallment : modifiedLoanSchedule.getPeriods()) {
|
for (final LoanScheduleModelPeriod scheduledLoanInstallment : modifiedLoanSchedule.getPeriods()) {
|
||||||
|
|
||||||
if (scheduledLoanInstallment.isRepaymentPeriod()) {
|
if (scheduledLoanInstallment.isRepaymentPeriod()) {
|
||||||
@@ -1149,7 +1151,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
scheduledLoanInstallment.interestDue(), scheduledLoanInstallment.feeChargesDue(),
|
scheduledLoanInstallment.interestDue(), scheduledLoanInstallment.feeChargesDue(),
|
||||||
scheduledLoanInstallment.penaltyChargesDue(), scheduledLoanInstallment.isRecalculatedInterestComponent(),
|
scheduledLoanInstallment.penaltyChargesDue(), scheduledLoanInstallment.isRecalculatedInterestComponent(),
|
||||||
scheduledLoanInstallment.getLoanCompoundingDetails());
|
scheduledLoanInstallment.getLoanCompoundingDetails());
|
||||||
addRepaymentScheduleInstallment(installment);
|
addLoanRepaymentScheduleInstallment(installment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1161,8 +1163,9 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public void updateLoanSchedule(final Collection<LoanRepaymentScheduleInstallment> installments, AppUser currentUser) {
|
public void updateLoanSchedule(final Collection<LoanRepaymentScheduleInstallment> installments, AppUser currentUser) {
|
||||||
this.repaymentScheduleInstallments.clear();
|
this.repaymentScheduleInstallments.clear();
|
||||||
|
this.isrepaymentScheduleInstallmentsListDirty = true ;
|
||||||
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
addRepaymentScheduleInstallment(installment);
|
addLoanRepaymentScheduleInstallment(installment);
|
||||||
}
|
}
|
||||||
updateLoanScheduleDependentDerivedFields();
|
updateLoanScheduleDependentDerivedFields();
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -1184,8 +1187,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void applyPeriodicAccruals(final Collection<LoanTransaction> accruals) {
|
private void applyPeriodicAccruals(final Collection<LoanTransaction> accruals) {
|
||||||
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
for (LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
Money interest = Money.zero(getCurrency());
|
Money interest = Money.zero(getCurrency());
|
||||||
Money fee = Money.zero(getCurrency());
|
Money fee = Money.zero(getCurrency());
|
||||||
Money penality = Money.zero(getCurrency());
|
Money penality = Money.zero(getCurrency());
|
||||||
@@ -1207,8 +1210,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
installment.updateAccrualPortion(interest, fee, penality);
|
installment.updateAccrualPortion(interest, fee, penality);
|
||||||
}
|
}
|
||||||
LoanRepaymentScheduleInstallment lastInstallment = this.repaymentScheduleInstallments
|
LoanRepaymentScheduleInstallment lastInstallment = getRepaymentScheduleInstallments()
|
||||||
.get(this.repaymentScheduleInstallments.size() - 1);
|
.get(getRepaymentScheduleInstallments().size() - 1);
|
||||||
for (LoanTransaction loanTransaction : accruals) {
|
for (LoanTransaction loanTransaction : accruals) {
|
||||||
if (loanTransaction.getTransactionDate().isAfter(lastInstallment.getDueDate()) && !loanTransaction.isReversed()) {
|
if (loanTransaction.getTransactionDate().isAfter(lastInstallment.getDueDate()) && !loanTransaction.isReversed()) {
|
||||||
loanTransaction.reverse();
|
loanTransaction.reverse();
|
||||||
@@ -1226,7 +1229,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final LocalDateTime currentDateTime = DateUtils.getLocalDateTimeOfTenant();
|
final LocalDateTime currentDateTime = DateUtils.getLocalDateTimeOfTenant();
|
||||||
final LoanTransaction interestAppliedTransaction = LoanTransaction.accrueInterest(getOffice(), this, interestApplied,
|
final LoanTransaction interestAppliedTransaction = LoanTransaction.accrueInterest(getOffice(), this, interestApplied,
|
||||||
getDisbursementDate(), currentDateTime, currentUser);
|
getDisbursementDate(), currentDateTime, currentUser);
|
||||||
this.loanTransactions.add(interestAppliedTransaction);
|
addLoanTransaction(interestAppliedTransaction) ;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Set<LoanChargePaidBy> chargePaidBies = loanTransaction.getLoanChargesPaid();
|
Set<LoanChargePaidBy> chargePaidBies = loanTransaction.getLoanChargesPaid();
|
||||||
@@ -1262,7 +1265,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
this.totalRecovered = recoveredAmount.getAmountDefaultedToNullIfZero();
|
this.totalRecovered = recoveredAmount.getAmountDefaultedToNullIfZero();
|
||||||
|
|
||||||
final Money principal = this.loanRepaymentScheduleDetail.getPrincipal();
|
final Money principal = this.loanRepaymentScheduleDetail.getPrincipal();
|
||||||
this.summary.updateSummary(loanCurrency(), principal, this.repaymentScheduleInstallments, this.loanSummaryWrapper,
|
this.summary.updateSummary(loanCurrency(), principal, getRepaymentScheduleInstallments(), this.loanSummaryWrapper,
|
||||||
isDisbursed(), this.charges);
|
isDisbursed(), this.charges);
|
||||||
updateLoanOutstandingBalaces();
|
updateLoanOutstandingBalaces();
|
||||||
}
|
}
|
||||||
@@ -1885,9 +1888,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeFirstDisbursementTransaction() {
|
private void removeFirstDisbursementTransaction() {
|
||||||
for (final LoanTransaction loanTransaction : this.loanTransactions) {
|
List<LoanTransaction> transactions = getLoanTransactions() ;
|
||||||
|
for (final LoanTransaction loanTransaction : transactions) {
|
||||||
if (loanTransaction.isDisbursement()) {
|
if (loanTransaction.isDisbursement()) {
|
||||||
this.loanTransactions.remove(loanTransaction);
|
this.loanTransactions.remove(loanTransaction);
|
||||||
|
transactions.remove(loanTransaction) ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1970,8 +1975,9 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
private LocalDate determineExpectedMaturityDate() {
|
private LocalDate determineExpectedMaturityDate() {
|
||||||
final int numberOfInstallments = this.repaymentScheduleInstallments.size();
|
final int numberOfInstallments = this.repaymentScheduleInstallments.size();
|
||||||
LocalDate maturityDate = this.repaymentScheduleInstallments.get(numberOfInstallments - 1).getDueDate();
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
ListIterator<LoanRepaymentScheduleInstallment> iterator = this.repaymentScheduleInstallments.listIterator(numberOfInstallments);
|
LocalDate maturityDate = installments.get(numberOfInstallments - 1).getDueDate();
|
||||||
|
ListIterator<LoanRepaymentScheduleInstallment> iterator = installments.listIterator(numberOfInstallments);
|
||||||
while(iterator.hasPrevious()){
|
while(iterator.hasPrevious()){
|
||||||
LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = iterator.previous();
|
LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = iterator.previous();
|
||||||
if(!loanRepaymentScheduleInstallment.isRecalculatedInterestComponent()){
|
if(!loanRepaymentScheduleInstallment.isRecalculatedInterestComponent()){
|
||||||
@@ -2240,8 +2246,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
public Collection<Long> findExistingTransactionIds() {
|
public Collection<Long> findExistingTransactionIds() {
|
||||||
|
|
||||||
final Collection<Long> ids = new ArrayList<>();
|
final Collection<Long> ids = new ArrayList<>();
|
||||||
|
List<LoanTransaction> transactions = getLoanTransactions() ;
|
||||||
for (final LoanTransaction transaction : this.loanTransactions) {
|
for (final LoanTransaction transaction : transactions) {
|
||||||
ids.add(transaction.getId());
|
ids.add(transaction.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2251,8 +2257,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
public Collection<Long> findExistingReversedTransactionIds() {
|
public Collection<Long> findExistingReversedTransactionIds() {
|
||||||
|
|
||||||
final Collection<Long> ids = new ArrayList<>();
|
final Collection<Long> ids = new ArrayList<>();
|
||||||
|
List<LoanTransaction> transactions = getLoanTransactions() ;
|
||||||
for (final LoanTransaction transaction : this.loanTransactions) {
|
for (final LoanTransaction transaction : transactions) {
|
||||||
if (transaction.isReversed()) {
|
if (transaction.isReversed()) {
|
||||||
ids.add(transaction.getId());
|
ids.add(transaction.getId());
|
||||||
}
|
}
|
||||||
@@ -2307,7 +2313,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
&& ((isMultiDisburmentLoan() && getDisbursedLoanDisbursementDetails().size() == 1) || !isMultiDisburmentLoan())) {
|
&& ((isMultiDisburmentLoan() && getDisbursedLoanDisbursementDetails().size() == 1) || !isMultiDisburmentLoan())) {
|
||||||
final LoanTransaction interestAppliedTransaction = LoanTransaction.accrueInterest(getOffice(), this, interestApplied,
|
final LoanTransaction interestAppliedTransaction = LoanTransaction.accrueInterest(getOffice(), this, interestApplied,
|
||||||
actualDisbursementDate, createdDate, currentUser);
|
actualDisbursementDate, createdDate, currentUser);
|
||||||
this.loanTransactions.add(interestAppliedTransaction);
|
addLoanTransaction(interestAppliedTransaction) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return reprocessTransactionForDisbursement();
|
return reprocessTransactionForDisbursement();
|
||||||
@@ -2456,7 +2462,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
|
final LoanRepaymentScheduleTransactionProcessor loanRepaymentScheduleTransactionProcessor = this.transactionProcessorFactory
|
||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
}
|
}
|
||||||
@@ -2556,8 +2562,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateLoanRepaymentPeriodsDerivedFields(final LocalDate actualDisbursementDate) {
|
private void updateLoanRepaymentPeriodsDerivedFields(final LocalDate actualDisbursementDate) {
|
||||||
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
for (final LoanRepaymentScheduleInstallment repaymentPeriod : this.repaymentScheduleInstallments) {
|
for (final LoanRepaymentScheduleInstallment repaymentPeriod : installments) {
|
||||||
repaymentPeriod.updateDerivedFields(loanCurrency(), actualDisbursementDate);
|
repaymentPeriod.updateDerivedFields(loanCurrency(), actualDisbursementDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2667,7 +2673,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final Money zero = Money.zero(getCurrency());
|
final Money zero = Money.zero(getCurrency());
|
||||||
chargesPayment.updateComponentsAndTotal(zero, zero, disbursentMoney, zero);
|
chargesPayment.updateComponentsAndTotal(zero, zero, disbursentMoney, zero);
|
||||||
chargesPayment.updateLoan(this);
|
chargesPayment.updateLoan(this);
|
||||||
this.loanTransactions.add(chargesPayment);
|
addLoanTransaction(chargesPayment) ;
|
||||||
updateLoanOutstandingBalaces();
|
updateLoanOutstandingBalaces();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2713,7 +2719,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final Money zero = Money.zero(getCurrency());
|
final Money zero = Money.zero(getCurrency());
|
||||||
chargesPayment.updateComponents(zero, zero, charge.getAmount(getCurrency()), zero);
|
chargesPayment.updateComponents(zero, zero, charge.getAmount(getCurrency()), zero);
|
||||||
chargesPayment.updateLoan(this);
|
chargesPayment.updateLoan(this);
|
||||||
this.loanTransactions.add(chargesPayment);
|
addLoanTransaction(chargesPayment) ;
|
||||||
updateLoanOutstandingBalaces();
|
updateLoanOutstandingBalaces();
|
||||||
charge.markAsFullyPaid();
|
charge.markAsFullyPaid();
|
||||||
return chargesPayment;
|
return chargesPayment;
|
||||||
@@ -2786,8 +2792,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
charge.resetToOriginal(loanCurrency());
|
charge.resetToOriginal(loanCurrency());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
for (final LoanRepaymentScheduleInstallment currentInstallment : this.repaymentScheduleInstallments) {
|
for (final LoanRepaymentScheduleInstallment currentInstallment : installments) {
|
||||||
currentInstallment.resetDerivedComponents();
|
currentInstallment.resetDerivedComponents();
|
||||||
}
|
}
|
||||||
final List<LoanTermVariations> removeTerms = new ArrayList<>(this.loanTermVariations.size());
|
final List<LoanTermVariations> removeTerms = new ArrayList<>(this.loanTermVariations.size());
|
||||||
@@ -2798,7 +2804,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
this.loanTermVariations.removeAll(removeTerms);
|
this.loanTermVariations.removeAll(removeTerms);
|
||||||
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
final LoanRepaymentScheduleProcessingWrapper wrapper = new LoanRepaymentScheduleProcessingWrapper();
|
||||||
wrapper.reprocess(getCurrency(), getDisbursementDate(), this.repaymentScheduleInstallments, charges());
|
wrapper.reprocess(getCurrency(), getDisbursementDate(), getRepaymentScheduleInstallments(), charges());
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
}
|
}
|
||||||
@@ -2899,7 +2905,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final String errorMessage = "The refund amount must be less than or equal to overpaid amount ";
|
final String errorMessage = "The refund amount must be less than or equal to overpaid amount ";
|
||||||
throw new InvalidLoanStateTransitionException("transaction", "is.exceeding.overpaid.amount", errorMessage,
|
throw new InvalidLoanStateTransitionException("transaction", "is.exceeding.overpaid.amount", errorMessage,
|
||||||
this.totalOverpaid, loanTransaction.getAmount(getCurrency()).getAmount());
|
this.totalOverpaid, loanTransaction.getAmount(getCurrency()).getAmount());
|
||||||
} else if (!isAfterLatRepayment(loanTransaction, this.loanTransactions)) {
|
} else if (!isAfterLatRepayment(loanTransaction, getLoanTransactions())) {
|
||||||
final String errorMessage = "Transfer funds is allowed only after last repayment date";
|
final String errorMessage = "Transfer funds is allowed only after last repayment date";
|
||||||
throw new InvalidLoanStateTransitionException("transaction", "is.not.after.repayment.date", errorMessage);
|
throw new InvalidLoanStateTransitionException("transaction", "is.not.after.repayment.date", errorMessage);
|
||||||
}
|
}
|
||||||
@@ -2910,7 +2916,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
loanTransaction.updateLoan(this);
|
loanTransaction.updateLoan(this);
|
||||||
|
|
||||||
if (loanTransaction.isNotZero(loanCurrency())) {
|
if (loanTransaction.isNotZero(loanCurrency())) {
|
||||||
this.loanTransactions.add(loanTransaction);
|
addLoanTransaction(loanTransaction) ;
|
||||||
}
|
}
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
doPostLoanTransactionChecks(loanTransaction.getTransactionDate(), loanLifecycleStateMachine);
|
doPostLoanTransactionChecks(loanTransaction.getTransactionDate(), loanLifecycleStateMachine);
|
||||||
@@ -2939,10 +2945,10 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
loanTransaction.updateLoan(this);
|
loanTransaction.updateLoan(this);
|
||||||
|
|
||||||
final boolean isTransactionChronologicallyLatest = isChronologicallyLatestRepaymentOrWaiver(loanTransaction, this.loanTransactions);
|
final boolean isTransactionChronologicallyLatest = isChronologicallyLatestRepaymentOrWaiver(loanTransaction, getLoanTransactions());
|
||||||
|
|
||||||
if (loanTransaction.isNotZero(loanCurrency())) {
|
if (loanTransaction.isNotZero(loanCurrency())) {
|
||||||
this.loanTransactions.add(loanTransaction);
|
addLoanTransaction(loanTransaction) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loanTransaction.isNotRepayment() && loanTransaction.isNotWaiver() && loanTransaction.isNotRecoveryRepayment()) {
|
if (loanTransaction.isNotRepayment() && loanTransaction.isNotWaiver() && loanTransaction.isNotRecoveryRepayment()) {
|
||||||
@@ -3000,7 +3006,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
if (isTransactionChronologicallyLatest && adjustedTransaction == null
|
if (isTransactionChronologicallyLatest && adjustedTransaction == null
|
||||||
&& (!reprocess || !this.repaymentScheduleDetail().isInterestRecalculationEnabled()) && !isForeclosure()) {
|
&& (!reprocess || !this.repaymentScheduleDetail().isInterestRecalculationEnabled()) && !isForeclosure()) {
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(loanTransaction, getCurrency(), this.repaymentScheduleInstallments,
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(loanTransaction, getCurrency(), getRepaymentScheduleInstallments(),
|
||||||
charges());
|
charges());
|
||||||
reprocess = false;
|
reprocess = false;
|
||||||
if (this.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
|
if (this.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
|
||||||
@@ -3021,7 +3027,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
}
|
}
|
||||||
@@ -3031,6 +3037,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
* transactions first and then new transactions.
|
* transactions first and then new transactions.
|
||||||
*/
|
*/
|
||||||
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactionMappings().values());
|
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactionMappings().values());
|
||||||
|
this.isTransactionsListDirty = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
@@ -3061,7 +3068,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
private LoanRepaymentScheduleInstallment fetchLoanRepaymentScheduleInstallment(LocalDate dueDate) {
|
private LoanRepaymentScheduleInstallment fetchLoanRepaymentScheduleInstallment(LocalDate dueDate) {
|
||||||
LoanRepaymentScheduleInstallment installment = null;
|
LoanRepaymentScheduleInstallment installment = null;
|
||||||
for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : installments) {
|
||||||
if (dueDate.equals(loanRepaymentScheduleInstallment.getDueDate())) {
|
if (dueDate.equals(loanRepaymentScheduleInstallment.getDueDate())) {
|
||||||
installment = loanRepaymentScheduleInstallment;
|
installment = loanRepaymentScheduleInstallment;
|
||||||
break;
|
break;
|
||||||
@@ -3072,7 +3080,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
private List<LoanTransaction> retreiveListOfIncomePostingTransactions() {
|
private List<LoanTransaction> retreiveListOfIncomePostingTransactions() {
|
||||||
final List<LoanTransaction> incomePostTransactions = new ArrayList<>();
|
final List<LoanTransaction> incomePostTransactions = new ArrayList<>();
|
||||||
for (final LoanTransaction transaction : this.loanTransactions) {
|
List<LoanTransaction> trans = getLoanTransactions() ;
|
||||||
|
for (final LoanTransaction transaction : trans) {
|
||||||
if (transaction.isNotReversed() && transaction.isIncomePosting()) {
|
if (transaction.isNotReversed() && transaction.isIncomePosting()) {
|
||||||
incomePostTransactions.add(transaction);
|
incomePostTransactions.add(transaction);
|
||||||
}
|
}
|
||||||
@@ -3084,7 +3093,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
private List<LoanTransaction> retreiveListOfTransactionsPostDisbursement() {
|
private List<LoanTransaction> retreiveListOfTransactionsPostDisbursement() {
|
||||||
final List<LoanTransaction> repaymentsOrWaivers = new ArrayList<>();
|
final List<LoanTransaction> repaymentsOrWaivers = new ArrayList<>();
|
||||||
for (final LoanTransaction transaction : this.loanTransactions) {
|
List<LoanTransaction> trans = getLoanTransactions() ;
|
||||||
|
for (final LoanTransaction transaction : trans) {
|
||||||
if (transaction.isNotReversed() && !(transaction.isDisbursement() || transaction.isNonMonetaryTransaction())) {
|
if (transaction.isNotReversed() && !(transaction.isDisbursement() || transaction.isNonMonetaryTransaction())) {
|
||||||
repaymentsOrWaivers.add(transaction);
|
repaymentsOrWaivers.add(transaction);
|
||||||
}
|
}
|
||||||
@@ -3185,7 +3195,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
BigDecimal amountToPost = interestToPost.add(feeToPost).add(penaltyToPost);
|
BigDecimal amountToPost = interestToPost.add(feeToPost).add(penaltyToPost);
|
||||||
LoanTransaction finalIncomeTransaction = LoanTransaction.incomePosting(this, this.getOffice(), closedDate, amountToPost,
|
LoanTransaction finalIncomeTransaction = LoanTransaction.incomePosting(this, this.getOffice(), closedDate, amountToPost,
|
||||||
interestToPost, feeToPost, penaltyToPost, null);
|
interestToPost, feeToPost, penaltyToPost, null);
|
||||||
this.loanTransactions.add(finalIncomeTransaction);
|
addLoanTransaction(finalIncomeTransaction) ;
|
||||||
if (isPeriodicAccrualAccountingEnabledOnLoanProduct()) {
|
if (isPeriodicAccrualAccountingEnabledOnLoanProduct()) {
|
||||||
List<LoanTransaction> updatedAccrualTransactions = retreiveListOfAccrualTransactions();
|
List<LoanTransaction> updatedAccrualTransactions = retreiveListOfAccrualTransactions();
|
||||||
LocalDate lastAccruedDate = this.getDisbursementDate();
|
LocalDate lastAccruedDate = this.getDisbursementDate();
|
||||||
@@ -3197,7 +3207,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
LoanTransaction finalAccrual = LoanTransaction.accrueTransaction(this, this.getOffice(), closedLocalDate, amountToPost,
|
LoanTransaction finalAccrual = LoanTransaction.accrueTransaction(this, this.getOffice(), closedLocalDate, amountToPost,
|
||||||
interestToPost, feeToPost, penaltyToPost, null);
|
interestToPost, feeToPost, penaltyToPost, null);
|
||||||
updateLoanChargesPaidBy(finalAccrual, feeDetails, null);
|
updateLoanChargesPaidBy(finalAccrual, feeDetails, null);
|
||||||
this.loanTransactions.add(finalAccrual);
|
addLoanTransaction(finalAccrual) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateLoanOutstandingBalaces();
|
updateLoanOutstandingBalaces();
|
||||||
@@ -3207,7 +3217,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
BigDecimal interest = BigDecimal.ZERO;
|
BigDecimal interest = BigDecimal.ZERO;
|
||||||
BigDecimal fee = BigDecimal.ZERO;
|
BigDecimal fee = BigDecimal.ZERO;
|
||||||
BigDecimal penalty = BigDecimal.ZERO;
|
BigDecimal penalty = BigDecimal.ZERO;
|
||||||
for (LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
interest = interest.add(installment.getInterestCharged(getCurrency()).getAmount());
|
interest = interest.add(installment.getInterestCharged(getCurrency()).getAmount());
|
||||||
fee = fee.add(installment.getFeeChargesCharged(getCurrency()).getAmount());
|
fee = fee.add(installment.getFeeChargesCharged(getCurrency()).getAmount());
|
||||||
penalty = penalty.add(installment.getPenaltyChargesCharged(getCurrency()).getAmount());
|
penalty = penalty.add(installment.getPenaltyChargesCharged(getCurrency()).getAmount());
|
||||||
@@ -3295,7 +3306,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public LocalDate possibleNextRepaymentDate() {
|
public LocalDate possibleNextRepaymentDate() {
|
||||||
LocalDate earliestUnpaidInstallmentDate = new LocalDate();
|
LocalDate earliestUnpaidInstallmentDate = new LocalDate();
|
||||||
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.isNotFullyPaidOff()) {
|
if (installment.isNotFullyPaidOff()) {
|
||||||
earliestUnpaidInstallmentDate = installment.getDueDate();
|
earliestUnpaidInstallmentDate = installment.getDueDate();
|
||||||
break;
|
break;
|
||||||
@@ -3319,8 +3331,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public LoanRepaymentScheduleInstallment possibleNextRepaymentInstallment() {
|
public LoanRepaymentScheduleInstallment possibleNextRepaymentInstallment() {
|
||||||
LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = null;
|
LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = null;
|
||||||
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.isNotFullyPaidOff()) {
|
if (installment.isNotFullyPaidOff()) {
|
||||||
loanRepaymentScheduleInstallment = installment;
|
loanRepaymentScheduleInstallment = installment;
|
||||||
break;
|
break;
|
||||||
@@ -3339,7 +3351,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
if (totalInterestOutstanding.isGreaterThanZero()) {
|
if (totalInterestOutstanding.isGreaterThanZero()) {
|
||||||
// find earliest known instance of overdue interest and default to
|
// find earliest known instance of overdue interest and default to
|
||||||
// that
|
// that
|
||||||
for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment scheduledRepayment : installments) {
|
||||||
|
|
||||||
final Money outstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency());
|
final Money outstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency());
|
||||||
if (scheduledRepayment.isOverdueOn(new LocalDate()) && scheduledRepayment.isNotFullyPaidOff()
|
if (scheduledRepayment.isOverdueOn(new LocalDate()) && scheduledRepayment.isNotFullyPaidOff()
|
||||||
@@ -3418,7 +3431,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO, currentUser);
|
regenerateRepaymentScheduleWithInterestRecalculation(scheduleGeneratorDTO, currentUser);
|
||||||
}
|
}
|
||||||
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(
|
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(
|
||||||
getDisbursementDate(), allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments,
|
getDisbursementDate(), allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(),
|
||||||
charges());
|
charges());
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
return changedTransactionDetail;
|
return changedTransactionDetail;
|
||||||
@@ -3447,8 +3460,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
final MonetaryCurrency currency = loanCurrency();
|
final MonetaryCurrency currency = loanCurrency();
|
||||||
Money cumulativeTotalPaidOnInstallments = Money.zero(currency);
|
Money cumulativeTotalPaidOnInstallments = Money.zero(currency);
|
||||||
Money cumulativeTotalWaivedOnInstallments = Money.zero(currency);
|
Money cumulativeTotalWaivedOnInstallments = Money.zero(currency);
|
||||||
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
|
for (final LoanRepaymentScheduleInstallment scheduledRepayment : installments) {
|
||||||
|
|
||||||
cumulativeTotalPaidOnInstallments = cumulativeTotalPaidOnInstallments
|
cumulativeTotalPaidOnInstallments = cumulativeTotalPaidOnInstallments
|
||||||
.plus(scheduledRepayment.getPrincipalCompleted(currency).plus(scheduledRepayment.getInterestPaid(currency)))
|
.plus(scheduledRepayment.getPrincipalCompleted(currency).plus(scheduledRepayment.getInterestPaid(currency)))
|
||||||
@@ -3533,9 +3546,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
writtenOffOnLocalDate);
|
writtenOffOnLocalDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loanTransactions.add(loanTransaction);
|
addLoanTransaction(loanTransaction) ;
|
||||||
|
loanRepaymentScheduleTransactionProcessor.handleWriteOff(loanTransaction, loanCurrency(), getRepaymentScheduleInstallments());
|
||||||
loanRepaymentScheduleTransactionProcessor.handleWriteOff(loanTransaction, loanCurrency(), this.repaymentScheduleInstallments);
|
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
}
|
}
|
||||||
@@ -3558,10 +3570,10 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
this.loanTransactions.add(mapEntry.getValue());
|
addLoanTransaction(mapEntry.getValue()) ;
|
||||||
}
|
}
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
LoanTransaction loanTransaction = findlatestTransaction();
|
LoanTransaction loanTransaction = findlatestTransaction();
|
||||||
@@ -3627,17 +3639,16 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
this.closedOnDate = closureDate.toDate();
|
this.closedOnDate = closureDate.toDate();
|
||||||
loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId,
|
loanTransaction = LoanTransaction.writeoff(this, getOffice(), closureDate, txnExternalId,
|
||||||
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
||||||
final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, this.loanTransactions);
|
final boolean isLastTransaction = isChronologicallyLatestTransaction(loanTransaction, getLoanTransactions());
|
||||||
if (!isLastTransaction) {
|
if (!isLastTransaction) {
|
||||||
final String errorMessage = "The closing date of the loan must be on or after latest transaction date.";
|
final String errorMessage = "The closing date of the loan must be on or after latest transaction date.";
|
||||||
throw new InvalidLoanStateTransitionException("close.loan", "must.occur.on.or.after.latest.transaction.date",
|
throw new InvalidLoanStateTransitionException("close.loan", "must.occur.on.or.after.latest.transaction.date",
|
||||||
errorMessage, closureDate);
|
errorMessage, closureDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loanTransactions.add(loanTransaction);
|
addLoanTransaction(loanTransaction) ;
|
||||||
|
|
||||||
loanRepaymentScheduleTransactionProcessor.handleWriteOff(loanTransaction, loanCurrency(),
|
loanRepaymentScheduleTransactionProcessor.handleWriteOff(loanTransaction, loanCurrency(),
|
||||||
this.repaymentScheduleInstallments);
|
getRepaymentScheduleInstallments());
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
} else if (totalOutstanding.isGreaterThanZero()) {
|
} else if (totalOutstanding.isGreaterThanZero()) {
|
||||||
@@ -3871,11 +3882,6 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
return firstRepaymentDate;
|
return firstRepaymentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addRepaymentScheduleInstallment(final LoanRepaymentScheduleInstallment installment) {
|
|
||||||
installment.updateLoan(this);
|
|
||||||
this.repaymentScheduleInstallments.add(installment);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isActualDisbursedOnDateEarlierOrLaterThanExpected(final LocalDate actualDisbursedOnDate) {
|
private boolean isActualDisbursedOnDateEarlierOrLaterThanExpected(final LocalDate actualDisbursedOnDate) {
|
||||||
boolean isRegenerationRequired = false;
|
boolean isRegenerationRequired = false;
|
||||||
if (this.loanProduct.isMultiDisburseLoan()) {
|
if (this.loanProduct.isMultiDisburseLoan()) {
|
||||||
@@ -3917,7 +3923,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
private Money getTotalInterestOutstandingOnLoan() {
|
private Money getTotalInterestOutstandingOnLoan() {
|
||||||
Money cumulativeInterest = Money.zero(loanCurrency());
|
Money cumulativeInterest = Money.zero(loanCurrency());
|
||||||
|
|
||||||
for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment scheduledRepayment : installments) {
|
||||||
cumulativeInterest = cumulativeInterest.plus(scheduledRepayment.getInterestOutstanding(loanCurrency()));
|
cumulativeInterest = cumulativeInterest.plus(scheduledRepayment.getInterestOutstanding(loanCurrency()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3927,8 +3934,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private Money getTotalInterestOverdueOnLoan() {
|
private Money getTotalInterestOverdueOnLoan() {
|
||||||
Money cumulativeInterestOverdue = Money.zero(this.loanRepaymentScheduleDetail.getPrincipal().getCurrency());
|
Money cumulativeInterestOverdue = Money.zero(this.loanRepaymentScheduleDetail.getPrincipal().getCurrency());
|
||||||
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
|
for (final LoanRepaymentScheduleInstallment scheduledRepayment : installments) {
|
||||||
|
|
||||||
final Money interestOutstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency());
|
final Money interestOutstandingForPeriod = scheduledRepayment.getInterestOutstanding(loanCurrency());
|
||||||
if (scheduledRepayment.isOverdueOn(new LocalDate())) {
|
if (scheduledRepayment.isOverdueOn(new LocalDate())) {
|
||||||
@@ -4263,7 +4270,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
LocalDate newRepaymentDate = null;
|
LocalDate newRepaymentDate = null;
|
||||||
Boolean isFirstTime = true;
|
Boolean isFirstTime = true;
|
||||||
LocalDate latestRepaymentDate = null;
|
LocalDate latestRepaymentDate = null;
|
||||||
for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : installments) {
|
||||||
|
|
||||||
LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
|
LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
|
||||||
|
|
||||||
@@ -4319,7 +4327,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
LocalDate newRepaymentDate = null;
|
LocalDate newRepaymentDate = null;
|
||||||
LocalDate seedDate = meetingStartDate;
|
LocalDate seedDate = meetingStartDate;
|
||||||
LocalDate latestRepaymentDate = null;
|
LocalDate latestRepaymentDate = null;
|
||||||
for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : installments) {
|
||||||
|
|
||||||
LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
|
LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
|
||||||
|
|
||||||
@@ -4387,7 +4396,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
// first repayment's from date is same as disbursement date.
|
// first repayment's from date is same as disbursement date.
|
||||||
LocalDate tmpFromDate = getDisbursementDate();
|
LocalDate tmpFromDate = getDisbursementDate();
|
||||||
// Loop through all loanRepayments
|
// Loop through all loanRepayments
|
||||||
for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : installments) {
|
||||||
final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
|
final LocalDate oldDueDate = loanRepaymentScheduleInstallment.getDueDate();
|
||||||
|
|
||||||
// update from date if it's not same as previous installament's due
|
// update from date if it's not same as previous installament's due
|
||||||
@@ -4495,8 +4505,19 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
return this.termPeriodFrequencyType;
|
return this.termPeriodFrequencyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//This method returns copy of all transactions
|
||||||
public List<LoanTransaction> getLoanTransactions() {
|
public List<LoanTransaction> getLoanTransactions() {
|
||||||
return this.loanTransactions;
|
if(this.sortedTransactions == null || isTransactionsListDirty) {
|
||||||
|
this.sortedTransactions = new ArrayList<>(this.loanTransactions) ;
|
||||||
|
this.sortedTransactions.sort(new LoanTransactionComparator());
|
||||||
|
this.isTransactionsListDirty = false ;
|
||||||
|
}
|
||||||
|
return sortedTransactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLoanTransaction(final LoanTransaction loanTransaction) {
|
||||||
|
this.loanTransactions.add(loanTransaction) ;
|
||||||
|
this.isTransactionsListDirty = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLoanStatus(final Integer loanStatus) {
|
public void setLoanStatus(final Integer loanStatus) {
|
||||||
@@ -4680,7 +4701,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
public Set<LoanInstallmentCharge> generateInstallmentLoanCharges(final LoanCharge loanCharge) {
|
public Set<LoanInstallmentCharge> generateInstallmentLoanCharges(final LoanCharge loanCharge) {
|
||||||
final Set<LoanInstallmentCharge> loanChargePerInstallments = new HashSet<>();
|
final Set<LoanInstallmentCharge> loanChargePerInstallments = new HashSet<>();
|
||||||
if (loanCharge.isInstalmentFee()) {
|
if (loanCharge.isInstalmentFee()) {
|
||||||
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
BigDecimal amount = BigDecimal.ZERO;
|
BigDecimal amount = BigDecimal.ZERO;
|
||||||
if (loanCharge.getChargeCalculation().isFlat()) {
|
if (loanCharge.getChargeCalculation().isFlat()) {
|
||||||
amount = loanCharge.amountOrPercentage();
|
amount = loanCharge.amountOrPercentage();
|
||||||
@@ -4900,11 +4922,11 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(
|
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(
|
||||||
getDisbursementDate(), allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments,
|
getDisbursementDate(), allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(),
|
||||||
charges());
|
charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
this.loanTransactions.add(mapEntry.getValue());
|
addLoanTransaction(mapEntry.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return changedTransactionDetail;
|
return changedTransactionDetail;
|
||||||
@@ -4925,7 +4947,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
public LoanRepaymentScheduleInstallment fetchRepaymentScheduleInstallment(final Integer installmentNumber) {
|
public LoanRepaymentScheduleInstallment fetchRepaymentScheduleInstallment(final Integer installmentNumber) {
|
||||||
LoanRepaymentScheduleInstallment installment = null;
|
LoanRepaymentScheduleInstallment installment = null;
|
||||||
if (installmentNumber == null) { return installment; }
|
if (installmentNumber == null) { return installment; }
|
||||||
for (final LoanRepaymentScheduleInstallment scheduleInstallment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment scheduleInstallment : installments) {
|
||||||
if (scheduleInstallment.getInstallmentNumber().equals(installmentNumber)) {
|
if (scheduleInstallment.getInstallmentNumber().equals(installmentNumber)) {
|
||||||
installment = scheduleInstallment;
|
installment = scheduleInstallment;
|
||||||
break;
|
break;
|
||||||
@@ -5006,7 +5029,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(
|
ChangedTransactionDetail changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(
|
||||||
getDisbursementDate(), allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments,
|
getDisbursementDate(), allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(),
|
||||||
charges());
|
charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
@@ -5017,7 +5040,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
* first and then new transactions.
|
* first and then new transactions.
|
||||||
*/
|
*/
|
||||||
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactionMappings().values());
|
this.loanTransactions.addAll(changedTransactionDetail.getNewTransactionMappings().values());
|
||||||
|
this.isTransactionsListDirty = true ;
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
|
|
||||||
this.loanTransactions.removeAll(changedTransactionDetail.getNewTransactionMappings().values());
|
this.loanTransactions.removeAll(changedTransactionDetail.getNewTransactionMappings().values());
|
||||||
@@ -5094,8 +5117,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
accrualTransaction);
|
accrualTransaction);
|
||||||
lastCompoundingDate = compoundingDetail.getEffectiveDate();
|
lastCompoundingDate = compoundingDetail.getEffectiveDate();
|
||||||
}
|
}
|
||||||
LoanRepaymentScheduleInstallment lastInstallment = this.repaymentScheduleInstallments.get(this.repaymentScheduleInstallments
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
.size() - 1);
|
LoanRepaymentScheduleInstallment lastInstallment = installments.get(installments.size() - 1);
|
||||||
reverseTransactionsPostEffectiveDate(incomeTransactions, lastInstallment.getDueDate());
|
reverseTransactionsPostEffectiveDate(incomeTransactions, lastInstallment.getDueDate());
|
||||||
reverseTransactionsPostEffectiveDate(accrualTransactions, lastInstallment.getDueDate());
|
reverseTransactionsPostEffectiveDate(accrualTransactions, lastInstallment.getDueDate());
|
||||||
}
|
}
|
||||||
@@ -5137,12 +5160,12 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
if (existingIncomeTransaction == null) {
|
if (existingIncomeTransaction == null) {
|
||||||
LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(), compoundingDetail.getEffectiveDate()
|
LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(), compoundingDetail.getEffectiveDate()
|
||||||
.toDate(), compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
.toDate(), compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
||||||
this.loanTransactions.add(transaction);
|
addLoanTransaction(transaction);
|
||||||
} else if (existingIncomeTransaction.getAmount(getCurrency()).getAmount().compareTo(compoundingDetail.getAmount()) != 0) {
|
} else if (existingIncomeTransaction.getAmount(getCurrency()).getAmount().compareTo(compoundingDetail.getAmount()) != 0) {
|
||||||
existingIncomeTransaction.reverse();
|
existingIncomeTransaction.reverse();
|
||||||
LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(), compoundingDetail.getEffectiveDate()
|
LoanTransaction transaction = LoanTransaction.incomePosting(this, this.getOffice(), compoundingDetail.getEffectiveDate()
|
||||||
.toDate(), compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
.toDate(), compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
||||||
this.loanTransactions.add(transaction);
|
addLoanTransaction(transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isPeriodicAccrualAccountingEnabledOnLoanProduct()) {
|
if (isPeriodicAccrualAccountingEnabledOnLoanProduct()) {
|
||||||
@@ -5150,13 +5173,13 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
LoanTransaction accrual = LoanTransaction.accrueTransaction(this, this.getOffice(), compoundingDetail.getEffectiveDate(),
|
LoanTransaction accrual = LoanTransaction.accrueTransaction(this, this.getOffice(), compoundingDetail.getEffectiveDate(),
|
||||||
compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
||||||
updateLoanChargesPaidBy(accrual, feeDetails, null);
|
updateLoanChargesPaidBy(accrual, feeDetails, null);
|
||||||
this.loanTransactions.add(accrual);
|
addLoanTransaction(accrual);
|
||||||
} else if (existingAccrualTransaction.getAmount(getCurrency()).getAmount().compareTo(compoundingDetail.getAmount()) != 0) {
|
} else if (existingAccrualTransaction.getAmount(getCurrency()).getAmount().compareTo(compoundingDetail.getAmount()) != 0) {
|
||||||
existingAccrualTransaction.reverse();
|
existingAccrualTransaction.reverse();
|
||||||
LoanTransaction accrual = LoanTransaction.accrueTransaction(this, this.getOffice(), compoundingDetail.getEffectiveDate(),
|
LoanTransaction accrual = LoanTransaction.accrueTransaction(this, this.getOffice(), compoundingDetail.getEffectiveDate(),
|
||||||
compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
compoundingDetail.getAmount(), interest, fee, penalties, currentUser);
|
||||||
updateLoanChargesPaidBy(accrual, feeDetails, null);
|
updateLoanChargesPaidBy(accrual, feeDetails, null);
|
||||||
this.loanTransactions.add(accrual);
|
addLoanTransaction(accrual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateLoanOutstandingBalaces();
|
updateLoanOutstandingBalaces();
|
||||||
@@ -5167,7 +5190,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
BigDecimal penalties = BigDecimal.ZERO;
|
BigDecimal penalties = BigDecimal.ZERO;
|
||||||
|
|
||||||
List<Integer> installments = new ArrayList<>();
|
List<Integer> installments = new ArrayList<>();
|
||||||
for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> repaymentSchedule = getRepaymentScheduleInstallments() ;
|
||||||
|
for (LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment : repaymentSchedule) {
|
||||||
if (loanRepaymentScheduleInstallment.getDueDate().isAfter(fromDate)
|
if (loanRepaymentScheduleInstallment.getDueDate().isAfter(fromDate)
|
||||||
&& !loanRepaymentScheduleInstallment.getDueDate().isAfter(toDate)) {
|
&& !loanRepaymentScheduleInstallment.getDueDate().isAfter(toDate)) {
|
||||||
installments.add(loanRepaymentScheduleInstallment.getInstallmentNumber());
|
installments.add(loanRepaymentScheduleInstallment.getInstallmentNumber());
|
||||||
@@ -5218,8 +5242,9 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
private List<LoanInterestRecalcualtionAdditionalDetails> extractInterestRecalculationAdditionalDetails() {
|
private List<LoanInterestRecalcualtionAdditionalDetails> extractInterestRecalculationAdditionalDetails() {
|
||||||
List<LoanInterestRecalcualtionAdditionalDetails> retDetails = new ArrayList<>();
|
List<LoanInterestRecalcualtionAdditionalDetails> retDetails = new ArrayList<>();
|
||||||
|
List<LoanRepaymentScheduleInstallment> repaymentSchedule = getRepaymentScheduleInstallments() ;
|
||||||
if (null != this.repaymentScheduleInstallments && this.repaymentScheduleInstallments.size() > 0) {
|
if (null != this.repaymentScheduleInstallments && this.repaymentScheduleInstallments.size() > 0) {
|
||||||
Iterator<LoanRepaymentScheduleInstallment> installmentsItr = this.repaymentScheduleInstallments.iterator();
|
Iterator<LoanRepaymentScheduleInstallment> installmentsItr = repaymentSchedule.iterator();
|
||||||
while (installmentsItr.hasNext()) {
|
while (installmentsItr.hasNext()) {
|
||||||
LoanRepaymentScheduleInstallment installment = installmentsItr.next();
|
LoanRepaymentScheduleInstallment installment = installmentsItr.next();
|
||||||
if (null != installment.getLoanCompoundingDetails()) {
|
if (null != installment.getLoanCompoundingDetails()) {
|
||||||
@@ -5247,7 +5272,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
copyTransactions.add(LoanTransaction.copyTransactionProperties(loanTransaction));
|
copyTransactions.add(LoanTransaction.copyTransactionProperties(loanTransaction));
|
||||||
}
|
}
|
||||||
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), copyTransactions, getCurrency(),
|
loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(), copyTransactions, getCurrency(),
|
||||||
this.repaymentScheduleInstallments, charges());
|
getRepaymentScheduleInstallments(), charges());
|
||||||
|
|
||||||
updateLoanSummaryDerivedFields();
|
updateLoanSummaryDerivedFields();
|
||||||
}
|
}
|
||||||
@@ -5269,7 +5294,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
return loanScheduleGenerator.rescheduleNextInstallments(mc, loanApplicationTerms, charges(), generatorDTO.getHolidayDetailDTO(),
|
return loanScheduleGenerator.rescheduleNextInstallments(mc, loanApplicationTerms, charges(), generatorDTO.getHolidayDetailDTO(),
|
||||||
retreiveListOfTransactionsPostDisbursementExcludeAccruals(), loanRepaymentScheduleTransactionProcessor,
|
retreiveListOfTransactionsPostDisbursementExcludeAccruals(), loanRepaymentScheduleTransactionProcessor,
|
||||||
repaymentScheduleInstallments, generatorDTO.getRecalculateFrom());
|
getRepaymentScheduleInstallments(), generatorDTO.getRecalculateFrom());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoanRepaymentScheduleInstallment fetchPrepaymentDetail(final ScheduleGeneratorDTO scheduleGeneratorDTO, final LocalDate onDate) {
|
public LoanRepaymentScheduleInstallment fetchPrepaymentDetail(final ScheduleGeneratorDTO scheduleGeneratorDTO, final LocalDate onDate) {
|
||||||
@@ -5287,7 +5312,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
.determineProcessor(this.transactionProcessingStrategy);
|
.determineProcessor(this.transactionProcessingStrategy);
|
||||||
installment = loanScheduleGenerator.calculatePrepaymentAmount(getCurrency(), onDate, loanApplicationTerms, mc, charges(),
|
installment = loanScheduleGenerator.calculatePrepaymentAmount(getCurrency(), onDate, loanApplicationTerms, mc, charges(),
|
||||||
scheduleGeneratorDTO.getHolidayDetailDTO(), retreiveListOfTransactionsPostDisbursementExcludeAccruals(),
|
scheduleGeneratorDTO.getHolidayDetailDTO(), retreiveListOfTransactionsPostDisbursementExcludeAccruals(),
|
||||||
loanRepaymentScheduleTransactionProcessor, this.fetchRepaymentScheduleInstallments());
|
loanRepaymentScheduleTransactionProcessor, getRepaymentScheduleInstallments());
|
||||||
} else {
|
} else {
|
||||||
installment = this.getTotalOutstandingOnLoan();
|
installment = this.getTotalOutstandingOnLoan();
|
||||||
}
|
}
|
||||||
@@ -5366,8 +5391,9 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
Money penaltyCharges = Money.zero(loanCurrency());
|
Money penaltyCharges = Money.zero(loanCurrency());
|
||||||
Money totalPrincipal = Money.zero(loanCurrency());
|
Money totalPrincipal = Money.zero(loanCurrency());
|
||||||
Money totalInterest = Money.zero(loanCurrency());
|
Money totalInterest = Money.zero(loanCurrency());
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
||||||
for (final LoanRepaymentScheduleInstallment scheduledRepayment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> repaymentSchedule = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment scheduledRepayment : repaymentSchedule) {
|
||||||
totalPrincipal = totalPrincipal.plus(scheduledRepayment.getPrincipalOutstanding(loanCurrency()));
|
totalPrincipal = totalPrincipal.plus(scheduledRepayment.getPrincipalOutstanding(loanCurrency()));
|
||||||
totalInterest = totalInterest.plus(scheduledRepayment.getInterestOutstanding(loanCurrency()));
|
totalInterest = totalInterest.plus(scheduledRepayment.getInterestOutstanding(loanCurrency()));
|
||||||
feeCharges = feeCharges.plus(scheduledRepayment.getFeeChargesOutstanding(loanCurrency()));
|
feeCharges = feeCharges.plus(scheduledRepayment.getFeeChargesOutstanding(loanCurrency()));
|
||||||
@@ -5377,10 +5403,6 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
totalInterest.getAmount(), feeCharges.getAmount(), penaltyCharges.getAmount(), false, compoundingDetails);
|
totalInterest.getAmount(), feeCharges.getAmount(), penaltyCharges.getAmount(), false, compoundingDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LoanRepaymentScheduleInstallment> fetchRepaymentScheduleInstallments() {
|
|
||||||
return this.repaymentScheduleInstallments;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalDate getAccruedTill() {
|
public LocalDate getAccruedTill() {
|
||||||
LocalDate accruedTill = null;
|
LocalDate accruedTill = null;
|
||||||
if (this.accruedTill != null) {
|
if (this.accruedTill != null) {
|
||||||
@@ -5431,9 +5453,21 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
* @return List of loan repayments schedule objects
|
* @return List of loan repayments schedule objects
|
||||||
**/
|
**/
|
||||||
public List<LoanRepaymentScheduleInstallment> getRepaymentScheduleInstallments() {
|
public List<LoanRepaymentScheduleInstallment> getRepaymentScheduleInstallments() {
|
||||||
return this.repaymentScheduleInstallments;
|
if (this.sortedrepaymentScheduleInstallments == null || this.isrepaymentScheduleInstallmentsListDirty) {
|
||||||
|
this.sortedrepaymentScheduleInstallments = new ArrayList<>(this.repaymentScheduleInstallments);
|
||||||
|
this.sortedrepaymentScheduleInstallments.sort(LoanRepaymentScheduleInstallment.installmentNumberComparator);
|
||||||
|
}
|
||||||
|
return sortedrepaymentScheduleInstallments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getLoanRepaymentScheduleInstallmentsSize() {
|
||||||
|
return this.repaymentScheduleInstallments.size() ;
|
||||||
|
}
|
||||||
|
public void addLoanRepaymentScheduleInstallment(final LoanRepaymentScheduleInstallment installment) {
|
||||||
|
installment.updateLoan(this);
|
||||||
|
this.repaymentScheduleInstallments.add(installment);
|
||||||
|
this.isrepaymentScheduleInstallmentsListDirty = true ;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @return Loan product minimum repayments schedule related detail
|
* @return Loan product minimum repayments schedule related detail
|
||||||
**/
|
**/
|
||||||
@@ -5464,7 +5498,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
LoanRepaymentScheduleInstallment installment = null;
|
LoanRepaymentScheduleInstallment installment = null;
|
||||||
|
|
||||||
if (dueDate != null) {
|
if (dueDate != null) {
|
||||||
for (LoanRepaymentScheduleInstallment repaymentScheduleInstallment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (LoanRepaymentScheduleInstallment repaymentScheduleInstallment : installments) {
|
||||||
|
|
||||||
if (repaymentScheduleInstallment.getDueDate().isEqual(dueDate)) {
|
if (repaymentScheduleInstallment.getDueDate().isEqual(dueDate)) {
|
||||||
installment = repaymentScheduleInstallment;
|
installment = repaymentScheduleInstallment;
|
||||||
@@ -5747,7 +5782,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (loanTransaction.isNotZero(loanCurrency())) {
|
if (loanTransaction.isNotZero(loanCurrency())) {
|
||||||
this.loanTransactions.add(loanTransaction);
|
addLoanTransaction(loanTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loanTransaction.isNotRefundForActiveLoan()) {
|
if (loanTransaction.isNotRefundForActiveLoan()) {
|
||||||
@@ -5782,12 +5817,12 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
// If is a refund
|
// If is a refund
|
||||||
if (adjustedTransaction == null) {
|
if (adjustedTransaction == null) {
|
||||||
loanRepaymentScheduleTransactionProcessor.handleRefund(loanTransaction, getCurrency(), this.repaymentScheduleInstallments,
|
loanRepaymentScheduleTransactionProcessor.handleRefund(loanTransaction, getCurrency(), getRepaymentScheduleInstallments(),
|
||||||
charges());
|
charges());
|
||||||
} else {
|
} else {
|
||||||
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
final List<LoanTransaction> allNonContraTransactionsPostDisbursement = retreiveListOfTransactionsPostDisbursement();
|
||||||
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
changedTransactionDetail = loanRepaymentScheduleTransactionProcessor.handleTransaction(getDisbursementDate(),
|
||||||
allNonContraTransactionsPostDisbursement, getCurrency(), this.repaymentScheduleInstallments, charges());
|
allNonContraTransactionsPostDisbursement, getCurrency(), getRepaymentScheduleInstallments(), charges());
|
||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
mapEntry.getValue().updateLoan(this);
|
mapEntry.getValue().updateLoan(this);
|
||||||
}
|
}
|
||||||
@@ -5932,7 +5967,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
this.interestRateDifferential = interestRateDifferential;
|
this.interestRateDifferential = interestRateDifferential;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LoanTermVariations> getLoanTermVariations() {
|
public Set<LoanTermVariations> getLoanTermVariations() {
|
||||||
return this.loanTermVariations;
|
return this.loanTermVariations;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5950,8 +5985,9 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
public int fetchNumberOfInstallmensAfterExceptions() {
|
public int fetchNumberOfInstallmensAfterExceptions() {
|
||||||
if (this.repaymentScheduleInstallments.size() > 0) {
|
if (this.repaymentScheduleInstallments.size() > 0) {
|
||||||
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
int numberOfInstallments = 0;
|
int numberOfInstallments = 0;
|
||||||
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (!installment.isRecalculatedInterestComponent()) {
|
if (!installment.isRecalculatedInterestComponent()) {
|
||||||
numberOfInstallments++;
|
numberOfInstallments++;
|
||||||
}
|
}
|
||||||
@@ -5973,7 +6009,8 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
LocalDate nextRepaymentDate = new LocalDate();
|
LocalDate nextRepaymentDate = new LocalDate();
|
||||||
for (LoanDisbursementDetails loanDisbursementDetail : loanDisbursementDetails) {
|
for (LoanDisbursementDetails loanDisbursementDetail : loanDisbursementDetails) {
|
||||||
if (loanDisbursementDetail.actualDisbursementDate() == null) {
|
if (loanDisbursementDetail.actualDisbursementDate() == null) {
|
||||||
for (final LoanRepaymentScheduleInstallment installment : this.repaymentScheduleInstallments) {
|
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.getDueDate().isEqual(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
|
if (installment.getDueDate().isEqual(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
|
||||||
|| installment.getDueDate().isAfter(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
|
|| installment.getDueDate().isAfter(loanDisbursementDetail.expectedDisbursementDateAsLocalDate())
|
||||||
&& installment.isNotFullyPaidOff()) {
|
&& installment.isNotFullyPaidOff()) {
|
||||||
@@ -6014,7 +6051,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
Money[] receivables = retriveIncomeOutstandingTillDate(closureDate);
|
Money[] receivables = retriveIncomeOutstandingTillDate(closureDate);
|
||||||
Money totalPrincipal = (Money.of(getCurrency(), this.getSummary().getTotalPrincipalOutstanding()));
|
Money totalPrincipal = (Money.of(getCurrency(), this.getSummary().getTotalPrincipalOutstanding()));
|
||||||
totalPrincipal = totalPrincipal.minus(receivables[3]);
|
totalPrincipal = totalPrincipal.minus(receivables[3]);
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
||||||
final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
|
final LocalDate currentDate = DateUtils.getLocalDateOfTenant();
|
||||||
return new LoanRepaymentScheduleInstallment(null, 0, currentDate, currentDate, totalPrincipal.getAmount(),
|
return new LoanRepaymentScheduleInstallment(null, 0, currentDate, currentDate, totalPrincipal.getAmount(),
|
||||||
receivables[0].getAmount(), receivables[1].getAmount(), receivables[2].getAmount(), false, compoundingDetails);
|
receivables[0].getAmount(), receivables[1].getAmount(), receivables[2].getAmount(), false, compoundingDetails);
|
||||||
@@ -6278,7 +6315,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
public void updateLoanScheduleOnForeclosure(final Collection<LoanRepaymentScheduleInstallment> installments) {
|
public void updateLoanScheduleOnForeclosure(final Collection<LoanRepaymentScheduleInstallment> installments) {
|
||||||
this.repaymentScheduleInstallments.clear();
|
this.repaymentScheduleInstallments.clear();
|
||||||
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
for (final LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
addRepaymentScheduleInstallment(installment);
|
addLoanRepaymentScheduleInstallment(installment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -192,7 +192,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
|||||||
for (Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
saveLoanTransactionWithDataIntegrityViolationChecks(mapEntry.getValue());
|
saveLoanTransactionWithDataIntegrityViolationChecks(mapEntry.getValue());
|
||||||
// update loan with references to the newly created transactions
|
// update loan with references to the newly created transactions
|
||||||
loan.getLoanTransactions().add(mapEntry.getValue());
|
loan.addLoanTransaction(mapEntry.getValue());
|
||||||
updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
|||||||
|
|
||||||
private void saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
private void saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
||||||
try {
|
try {
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
for (LoanRepaymentScheduleInstallment installment : installments) {
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.getId() == null) {
|
if (installment.getId() == null) {
|
||||||
this.repaymentScheduleInstallmentRepository.save(installment);
|
this.repaymentScheduleInstallmentRepository.save(installment);
|
||||||
@@ -257,7 +257,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
|||||||
@Override
|
@Override
|
||||||
public void saveLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
public void saveLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
||||||
try {
|
try {
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
for (LoanRepaymentScheduleInstallment installment : installments) {
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.getId() == null) {
|
if (installment.getId() == null) {
|
||||||
this.repaymentScheduleInstallmentRepository.save(installment);
|
this.repaymentScheduleInstallmentRepository.save(installment);
|
||||||
@@ -410,7 +410,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
|||||||
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), amount, paymentDetail, transactionDate,
|
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), amount, paymentDetail, transactionDate,
|
||||||
txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
||||||
disbursementTransaction.updateLoan(loan);
|
disbursementTransaction.updateLoan(loan);
|
||||||
loan.getLoanTransactions().add(disbursementTransaction);
|
loan.addLoanTransaction(disbursementTransaction);
|
||||||
saveLoanTransactionWithDataIntegrityViolationChecks(disbursementTransaction);
|
saveLoanTransactionWithDataIntegrityViolationChecks(disbursementTransaction);
|
||||||
saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
|
saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
|
||||||
|
|
||||||
@@ -448,7 +448,7 @@ public class LoanAccountDomainServiceJpa implements LoanAccountDomainService {
|
|||||||
if (!loan.isPeriodicAccrualAccountingEnabledOnLoanProduct() || !loan.repaymentScheduleDetail().isInterestRecalculationEnabled()
|
if (!loan.isPeriodicAccrualAccountingEnabledOnLoanProduct() || !loan.repaymentScheduleDetail().isInterestRecalculationEnabled()
|
||||||
|| accruedTill == null || loan.isNpa() || !loan.status().isActive()) { return; }
|
|| accruedTill == null || loan.isNpa() || !loan.status().isActive()) { return; }
|
||||||
Collection<LoanScheduleAccrualData> loanScheduleAccrualDatas = new ArrayList<>();
|
Collection<LoanScheduleAccrualData> loanScheduleAccrualDatas = new ArrayList<>();
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
Long loanId = loan.getId();
|
Long loanId = loan.getId();
|
||||||
Long officeId = loan.getOfficeId();
|
Long officeId = loan.getOfficeId();
|
||||||
LocalDate accrualStartDate = null;
|
LocalDate accrualStartDate = null;
|
||||||
|
|||||||
+1
-4
@@ -53,8 +53,6 @@ import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
|
|||||||
import org.apache.fineract.portfolio.charge.exception.LoanChargeWithoutMandatoryFieldException;
|
import org.apache.fineract.portfolio.charge.exception.LoanChargeWithoutMandatoryFieldException;
|
||||||
import org.apache.fineract.portfolio.loanaccount.command.LoanChargeCommand;
|
import org.apache.fineract.portfolio.loanaccount.command.LoanChargeCommand;
|
||||||
import org.apache.fineract.portfolio.loanaccount.data.LoanChargePaidDetail;
|
import org.apache.fineract.portfolio.loanaccount.data.LoanChargePaidDetail;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@@ -122,8 +120,7 @@ public class LoanCharge extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "max_cap", scale = 6, precision = 19, nullable = true)
|
@Column(name = "max_cap", scale = 6, precision = 19, nullable = true)
|
||||||
private BigDecimal maxCap;
|
private BigDecimal maxCap;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loancharge", orphanRemoval = true)
|
|
||||||
private final Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<>();
|
private final Set<LoanInstallmentCharge> loanInstallmentCharge = new HashSet<>();
|
||||||
|
|
||||||
@Column(name = "is_active", nullable = false)
|
@Column(name = "is_active", nullable = false)
|
||||||
|
|||||||
+7
-9
@@ -19,14 +19,15 @@
|
|||||||
package org.apache.fineract.portfolio.loanaccount.domain;
|
package org.apache.fineract.portfolio.loanaccount.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -38,8 +39,6 @@ import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
|||||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -131,10 +130,9 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
|
|||||||
@Column(name = "recalculated_interest_component", nullable = false)
|
@Column(name = "recalculated_interest_component", nullable = false)
|
||||||
private boolean recalculatedInterestComponent;
|
private boolean recalculatedInterestComponent;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
@JoinColumn(name = "loan_repayment_schedule_id", referencedColumnName = "id", nullable = false)
|
@JoinColumn(name = "loan_repayment_schedule_id", referencedColumnName = "id", nullable = false)
|
||||||
private List<LoanInterestRecalcualtionAdditionalDetails> loanCompoundingDetails = new ArrayList<>();
|
private Set<LoanInterestRecalcualtionAdditionalDetails> loanCompoundingDetails = new HashSet<>();
|
||||||
protected LoanRepaymentScheduleInstallment() {
|
protected LoanRepaymentScheduleInstallment() {
|
||||||
this.installmentNumber = null;
|
this.installmentNumber = null;
|
||||||
this.fromDate = null;
|
this.fromDate = null;
|
||||||
@@ -145,7 +143,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
|
|||||||
public LoanRepaymentScheduleInstallment(final Loan loan, final Integer installmentNumber, final LocalDate fromDate,
|
public LoanRepaymentScheduleInstallment(final Loan loan, final Integer installmentNumber, final LocalDate fromDate,
|
||||||
final LocalDate dueDate, final BigDecimal principal, final BigDecimal interest, final BigDecimal feeCharges,
|
final LocalDate dueDate, final BigDecimal principal, final BigDecimal interest, final BigDecimal feeCharges,
|
||||||
final BigDecimal penaltyCharges, final boolean recalculatedInterestComponent,
|
final BigDecimal penaltyCharges, final boolean recalculatedInterestComponent,
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails) {
|
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails) {
|
||||||
this.loan = loan;
|
this.loan = loan;
|
||||||
this.installmentNumber = installmentNumber;
|
this.installmentNumber = installmentNumber;
|
||||||
this.fromDate = fromDate.toDateTimeAtStartOfDay().toDate();
|
this.fromDate = fromDate.toDateTimeAtStartOfDay().toDate();
|
||||||
@@ -782,7 +780,7 @@ public final class LoanRepaymentScheduleInstallment extends AbstractAuditableCus
|
|||||||
public Money getDue(MonetaryCurrency currency) {
|
public Money getDue(MonetaryCurrency currency) {
|
||||||
return getPrincipal(currency).plus(getInterestCharged(currency)).plus(getFeeChargesCharged(currency)).plus(getPenaltyChargesCharged(currency));
|
return getPrincipal(currency).plus(getInterestCharged(currency)).plus(getFeeChargesCharged(currency)).plus(getPenaltyChargesCharged(currency));
|
||||||
}
|
}
|
||||||
public List<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
public Set<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
||||||
return this.loanCompoundingDetails;
|
return this.loanCompoundingDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-7
@@ -31,6 +31,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -51,8 +52,6 @@ import org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations;
|
|||||||
import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData;
|
import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData;
|
||||||
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
@@ -123,8 +122,7 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
|||||||
@JoinColumn(name = "appuser_id", nullable = true)
|
@JoinColumn(name = "appuser_id", nullable = true)
|
||||||
private final AppUser appUser;
|
private final AppUser appUser;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanTransaction", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanTransaction", orphanRemoval = true)
|
|
||||||
private Set<LoanChargePaidBy> loanChargesPaid = new HashSet<>();
|
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, nullable = true)
|
||||||
@@ -133,9 +131,8 @@ public final class LoanTransaction extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "manually_adjusted_or_reversed", nullable = false)
|
@Column(name = "manually_adjusted_or_reversed", nullable = false)
|
||||||
private boolean manuallyAdjustedOrReversed;
|
private boolean manuallyAdjustedOrReversed;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
@JoinColumn(name = "loan_transaction_id", referencedColumnName= "id" , nullable = false)
|
||||||
@JoinColumn(name = "loan_transaction_id", referencedColumnName = "id", nullable = false)
|
|
||||||
private Set<LoanTransactionToRepaymentScheduleMapping> loanTransactionToRepaymentScheduleMappings = new HashSet<>();
|
private Set<LoanTransactionToRepaymentScheduleMapping> loanTransactionToRepaymentScheduleMappings = new HashSet<>();
|
||||||
|
|
||||||
protected LoanTransaction() {
|
protected LoanTransaction() {
|
||||||
|
|||||||
+2
-4
@@ -27,6 +27,7 @@ import java.util.Map;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -39,8 +40,6 @@ import org.apache.fineract.infrastructure.codes.domain.CodeValue;
|
|||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||||
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GUARANTOR_JSON_INPUT_PARAMS;
|
import org.apache.fineract.portfolio.loanaccount.guarantor.GuarantorConstants.GUARANTOR_JSON_INPUT_PARAMS;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -101,8 +100,7 @@ public class Guarantor extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "is_active", nullable = false)
|
@Column(name = "is_active", nullable = false)
|
||||||
private boolean active;
|
private boolean active;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "guarantor", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "guarantor", orphanRemoval = true)
|
|
||||||
private final List<GuarantorFundingDetails> guarantorFundDetails = new ArrayList<>();
|
private final List<GuarantorFundingDetails> guarantorFundDetails = new ArrayList<>();
|
||||||
|
|
||||||
protected Guarantor() {
|
protected Guarantor() {
|
||||||
|
|||||||
+2
-4
@@ -25,6 +25,7 @@ import java.util.List;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -33,8 +34,6 @@ import javax.persistence.Table;
|
|||||||
import org.apache.fineract.portfolio.account.domain.AccountAssociations;
|
import org.apache.fineract.portfolio.account.domain.AccountAssociations;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
|
||||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -64,8 +63,7 @@ public class GuarantorFundingDetails extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "amount_transfered_derived", scale = 6, precision = 19, nullable = true)
|
@Column(name = "amount_transfered_derived", scale = 6, precision = 19, nullable = true)
|
||||||
private BigDecimal amountTransfered;
|
private BigDecimal amountTransfered;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "guarantorFundingDetails", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "guarantorFundingDetails", orphanRemoval = true)
|
|
||||||
private final List<GuarantorFundingTransaction> guarantorFundingTransactions = new ArrayList<>();
|
private final List<GuarantorFundingTransaction> guarantorFundingTransactions = new ArrayList<>();
|
||||||
|
|
||||||
protected GuarantorFundingDetails() {}
|
protected GuarantorFundingDetails() {}
|
||||||
|
|||||||
+2
-2
@@ -2575,7 +2575,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
|||||||
currency);
|
currency);
|
||||||
}
|
}
|
||||||
Money amountCharged = getIncomeForCompounding(loanApplicationTerms, currency, installment);
|
Money amountCharged = getIncomeForCompounding(loanApplicationTerms, currency, installment);
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> details = installment.getLoanCompoundingDetails();
|
final Set<LoanInterestRecalcualtionAdditionalDetails> details = installment.getLoanCompoundingDetails();
|
||||||
Money totalCompounded = Money.zero(currency);
|
Money totalCompounded = Money.zero(currency);
|
||||||
Map<LocalDate, Money> compoundingMap = new TreeMap<>();
|
Map<LocalDate, Money> compoundingMap = new TreeMap<>();
|
||||||
for (LoanInterestRecalcualtionAdditionalDetails additionalDetails : details) {
|
for (LoanInterestRecalcualtionAdditionalDetails additionalDetails : details) {
|
||||||
@@ -2754,7 +2754,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
|
|||||||
penaltyCharges = penaltyCharges.plus(currentInstallment.getPenaltyChargesOutstanding(currency));
|
penaltyCharges = penaltyCharges.plus(currentInstallment.getPenaltyChargesOutstanding(currency));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
||||||
return new LoanRepaymentScheduleInstallment(null, 0, onDate, onDate, totalPrincipal.getAmount(), totalInterest.getAmount(),
|
return new LoanRepaymentScheduleInstallment(null, 0, onDate, onDate, totalPrincipal.getAmount(), totalInterest.getAmount(),
|
||||||
feeCharges.getAmount(), penaltyCharges.getAmount(), false, compoundingDetails);
|
feeCharges.getAmount(), penaltyCharges.getAmount(), false, compoundingDetails);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
|
package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtionAdditionalDetails;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtionAdditionalDetails;
|
||||||
@@ -125,7 +125,7 @@ public final class LoanScheduleModelDisbursementPeriod implements LoanScheduleMo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
public Set<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -19,7 +19,7 @@
|
|||||||
package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
|
package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtionAdditionalDetails;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtionAdditionalDetails;
|
||||||
@@ -53,5 +53,5 @@ public interface LoanScheduleModelPeriod {
|
|||||||
void addPrincipalAmount(Money principalDue);
|
void addPrincipalAmount(Money principalDue);
|
||||||
|
|
||||||
void addInterestAmount(Money interestDue);
|
void addInterestAmount(Money interestDue);
|
||||||
List<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails();
|
Set<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails();
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -19,8 +19,8 @@
|
|||||||
package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
|
package org.apache.fineract.portfolio.loanaccount.loanschedule.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtionAdditionalDetails;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtionAdditionalDetails;
|
||||||
@@ -43,7 +43,7 @@ public final class LoanScheduleModelRepaymentPeriod implements LoanScheduleModel
|
|||||||
private Money penaltyChargesDue;
|
private Money penaltyChargesDue;
|
||||||
private Money totalDue;
|
private Money totalDue;
|
||||||
private final boolean recalculatedInterestComponent;
|
private final boolean recalculatedInterestComponent;
|
||||||
private final List<LoanInterestRecalcualtionAdditionalDetails> loanCompoundingDetails = new ArrayList<>();
|
private final Set<LoanInterestRecalcualtionAdditionalDetails> loanCompoundingDetails = new HashSet<>();
|
||||||
|
|
||||||
public static LoanScheduleModelRepaymentPeriod repayment(final int periodNumber, final LocalDate startDate,
|
public static LoanScheduleModelRepaymentPeriod repayment(final int periodNumber, final LocalDate startDate,
|
||||||
final LocalDate scheduledDueDate, final Money principalDue, final Money outstandingLoanBalance, final Money interestDue,
|
final LocalDate scheduledDueDate, final Money principalDue, final Money outstandingLoanBalance, final Money interestDue,
|
||||||
@@ -159,7 +159,7 @@ public final class LoanScheduleModelRepaymentPeriod implements LoanScheduleModel
|
|||||||
this.totalDue = this.totalDue.plus(principalDue);
|
this.totalDue = this.totalDue.plus(principalDue);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public List<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
public Set<LoanInterestRecalcualtionAdditionalDetails> getLoanCompoundingDetails() {
|
||||||
return this.loanCompoundingDetails;
|
return this.loanCompoundingDetails;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-6
@@ -23,7 +23,6 @@ import java.math.MathContext;
|
|||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -87,7 +86,6 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanDisbursementDetails;
|
|||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTermVariationType;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanTermVariationType;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTermVariations;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanTermVariations;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTermVariationsComparator;
|
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
|
||||||
import org.apache.fineract.portfolio.loanaccount.domain.transactionprocessor.LoanRepaymentScheduleTransactionProcessor;
|
import org.apache.fineract.portfolio.loanaccount.domain.transactionprocessor.LoanRepaymentScheduleTransactionProcessor;
|
||||||
import org.apache.fineract.portfolio.loanaccount.exception.LoanApplicationDateException;
|
import org.apache.fineract.portfolio.loanaccount.exception.LoanApplicationDateException;
|
||||||
@@ -663,7 +661,7 @@ public class LoanScheduleAssembler {
|
|||||||
public void assempleVariableScheduleFrom(final Loan loan, final String json) {
|
public void assempleVariableScheduleFrom(final Loan loan, final String json) {
|
||||||
this.variableLoanScheduleFromApiJsonValidator.validateSchedule(json, loan);
|
this.variableLoanScheduleFromApiJsonValidator.validateSchedule(json, loan);
|
||||||
|
|
||||||
List<LoanTermVariations> variations = loan.getLoanTermVariations();
|
Set<LoanTermVariations> variations = loan.getLoanTermVariations();
|
||||||
List<LoanTermVariations> newVariations = new ArrayList<>();
|
List<LoanTermVariations> newVariations = new ArrayList<>();
|
||||||
extractLoanTermVariations(loan, json, newVariations);
|
extractLoanTermVariations(loan, json, newVariations);
|
||||||
|
|
||||||
@@ -674,7 +672,7 @@ public class LoanScheduleAssembler {
|
|||||||
newVariations = retainVariations;
|
newVariations = retainVariations;
|
||||||
}
|
}
|
||||||
variations.addAll(newVariations);
|
variations.addAll(newVariations);
|
||||||
Collections.sort(variations, new LoanTermVariationsComparator());
|
//Collections.sort(variations, new LoanTermVariationsComparator());
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* List<LoanTermVariationsData> loanTermVariationsDatas = new
|
* List<LoanTermVariationsData> loanTermVariationsDatas = new
|
||||||
@@ -686,7 +684,7 @@ public class LoanScheduleAssembler {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// date validations
|
// date validations
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
Set<LocalDate> dueDates = new TreeSet<>();
|
Set<LocalDate> dueDates = new TreeSet<>();
|
||||||
LocalDate graceApplicable = loan.getExpectedDisbursedOnLocalDate();
|
LocalDate graceApplicable = loan.getExpectedDisbursedOnLocalDate();
|
||||||
Integer graceOnPrincipal = loan.getLoanProductRelatedDetail().graceOnPrincipalPayment();
|
Integer graceOnPrincipal = loan.getLoanProductRelatedDetail().graceOnPrincipalPayment();
|
||||||
@@ -845,11 +843,12 @@ public class LoanScheduleAssembler {
|
|||||||
loan.regenerateRepaymentSchedule(scheduleGeneratorDTO, currentUser);
|
loan.regenerateRepaymentSchedule(scheduleGeneratorDTO, currentUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<LoanTermVariations> adjustExistingVariations(List<LoanTermVariations> variations, List<LoanTermVariations> newVariations,
|
private List<LoanTermVariations> adjustExistingVariations(Set<LoanTermVariations> variations, List<LoanTermVariations> newVariations,
|
||||||
final Map<LocalDate, LocalDate> adjustDueDateVariations) {
|
final Map<LocalDate, LocalDate> adjustDueDateVariations) {
|
||||||
Map<LocalDate, LoanTermVariations> amountVariations = new HashMap<>();
|
Map<LocalDate, LoanTermVariations> amountVariations = new HashMap<>();
|
||||||
Map<LocalDate, LoanTermVariations> dueDateVariations = new HashMap<>();
|
Map<LocalDate, LoanTermVariations> dueDateVariations = new HashMap<>();
|
||||||
Map<LocalDate, LoanTermVariations> insertVariations = new HashMap<>();
|
Map<LocalDate, LoanTermVariations> insertVariations = new HashMap<>();
|
||||||
|
|
||||||
for (LoanTermVariations loanTermVariations : variations) {
|
for (LoanTermVariations loanTermVariations : variations) {
|
||||||
switch (loanTermVariations.getTermType()) {
|
switch (loanTermVariations.getTermType()) {
|
||||||
case EMI_AMOUNT:
|
case EMI_AMOUNT:
|
||||||
|
|||||||
+4
-3
@@ -161,7 +161,8 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC
|
|||||||
MonetaryCurrency currency = loan.getCurrency();
|
MonetaryCurrency currency = loan.getCurrency();
|
||||||
Money totalPrincipal = Money.zero(currency);
|
Money totalPrincipal = Money.zero(currency);
|
||||||
final List<LoanSchedulePeriodData> futureInstallments = new ArrayList<>();
|
final List<LoanSchedulePeriodData> futureInstallments = new ArrayList<>();
|
||||||
for (final LoanRepaymentScheduleInstallment currentInstallment : loan.fetchRepaymentScheduleInstallments()) {
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments() ;
|
||||||
|
for (final LoanRepaymentScheduleInstallment currentInstallment : installments) {
|
||||||
if (currentInstallment.isNotFullyPaidOff()) {
|
if (currentInstallment.isNotFullyPaidOff()) {
|
||||||
if (!currentInstallment.getDueDate().isAfter(today)) {
|
if (!currentInstallment.getDueDate().isAfter(today)) {
|
||||||
totalPrincipal = totalPrincipal.plus(currentInstallment.getPrincipalOutstanding(currency));
|
totalPrincipal = totalPrincipal.plus(currentInstallment.getPrincipalOutstanding(currency));
|
||||||
@@ -172,7 +173,7 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC
|
|||||||
LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = this.loanScheduleAssembler.calculatePrepaymentAmount(currency,
|
LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = this.loanScheduleAssembler.calculatePrepaymentAmount(currency,
|
||||||
today, loanApplicationTerms, loan.charges(), loan.getOfficeId(),
|
today, loanApplicationTerms, loan.charges(), loan.getOfficeId(),
|
||||||
loan.retreiveListOfTransactionsPostDisbursementExcludeAccruals(), loanRepaymentScheduleTransactionProcessor,
|
loan.retreiveListOfTransactionsPostDisbursementExcludeAccruals(), loanRepaymentScheduleTransactionProcessor,
|
||||||
loan.fetchRepaymentScheduleInstallments());
|
loan.getRepaymentScheduleInstallments());
|
||||||
Money totalAmount = totalPrincipal.plus(loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency)).plus(
|
Money totalAmount = totalPrincipal.plus(loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency)).plus(
|
||||||
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency));
|
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency));
|
||||||
Money interestDue = Money.zero(currency);
|
Money interestDue = Money.zero(currency);
|
||||||
@@ -193,7 +194,7 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoanScheduleModel model = this.loanScheduleAssembler.assembleForInterestRecalculation(loanApplicationTerms, loan.getOfficeId(),
|
LoanScheduleModel model = this.loanScheduleAssembler.assembleForInterestRecalculation(loanApplicationTerms, loan.getOfficeId(),
|
||||||
modifiedTransactions, loan.charges(), loanRepaymentScheduleTransactionProcessor, loan.fetchRepaymentScheduleInstallments(),
|
modifiedTransactions, loan.charges(), loanRepaymentScheduleTransactionProcessor, loan.getRepaymentScheduleInstallments(),
|
||||||
loan.fetchInterestRecalculateFromDate());
|
loan.fetchInterestRecalculateFromDate());
|
||||||
LoanScheduleData scheduleDate = model.toData();
|
LoanScheduleData scheduleDate = model.toData();
|
||||||
Collection<LoanSchedulePeriodData> periodDatas = scheduleDate.getPeriods();
|
Collection<LoanSchedulePeriodData> periodDatas = scheduleDate.getPeriods();
|
||||||
|
|||||||
+3
-2
@@ -22,6 +22,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -71,7 +72,7 @@ public class LoanScheduleWritePlatformServiceImpl implements LoanScheduleWritePl
|
|||||||
this.loanAccountDomainService.saveLoanWithDataIntegrityViolationChecks(loan);
|
this.loanAccountDomainService.saveLoanWithDataIntegrityViolationChecks(loan);
|
||||||
final Map<String, Object> changes = new HashMap<>();
|
final Map<String, Object> changes = new HashMap<>();
|
||||||
List<LoanTermVariationsData> newVariationsData = new ArrayList<>();
|
List<LoanTermVariationsData> newVariationsData = new ArrayList<>();
|
||||||
List<LoanTermVariations> modifiedVariations = loan.getLoanTermVariations();
|
Set<LoanTermVariations> modifiedVariations = loan.getLoanTermVariations();
|
||||||
for (LoanTermVariations termVariations : modifiedVariations) {
|
for (LoanTermVariations termVariations : modifiedVariations) {
|
||||||
if (loanTermVariations.containsKey(termVariations.getId())) {
|
if (loanTermVariations.containsKey(termVariations.getId())) {
|
||||||
loanTermVariations.remove(termVariations.getId());
|
loanTermVariations.remove(termVariations.getId());
|
||||||
@@ -93,7 +94,7 @@ public class LoanScheduleWritePlatformServiceImpl implements LoanScheduleWritePl
|
|||||||
@Override
|
@Override
|
||||||
public CommandProcessingResult deleteLoanScheduleVariations(final Long loanId) {
|
public CommandProcessingResult deleteLoanScheduleVariations(final Long loanId) {
|
||||||
final Loan loan = this.loanAssembler.assembleFrom(loanId);
|
final Loan loan = this.loanAssembler.assembleFrom(loanId);
|
||||||
List<LoanTermVariations> variations = loan.getLoanTermVariations();
|
Set<LoanTermVariations> variations = loan.getLoanTermVariations();
|
||||||
List<Long> deletedVariations = new ArrayList<>(variations.size());
|
List<Long> deletedVariations = new ArrayList<>(variations.size());
|
||||||
for (LoanTermVariations loanTermVariations : variations) {
|
for (LoanTermVariations loanTermVariations : variations) {
|
||||||
deletedVariations.add(loanTermVariations.getId());
|
deletedVariations.add(loanTermVariations.getId());
|
||||||
|
|||||||
+5
-4
@@ -28,6 +28,7 @@ import java.util.Date;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService;
|
import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService;
|
||||||
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
|
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
|
||||||
@@ -371,7 +372,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
|
|||||||
final Collection<LoanRescheduleModelRepaymentPeriod> periods = loanRescheduleModel.getPeriods();
|
final Collection<LoanRescheduleModelRepaymentPeriod> periods = loanRescheduleModel.getPeriods();
|
||||||
List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments = loan.getRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> repaymentScheduleInstallments = loan.getRepaymentScheduleInstallments();
|
||||||
Collection<LoanCharge> waiveLoanCharges = new ArrayList<>();
|
Collection<LoanCharge> waiveLoanCharges = new ArrayList<>();
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
||||||
for (LoanRescheduleModelRepaymentPeriod period : periods) {
|
for (LoanRescheduleModelRepaymentPeriod period : periods) {
|
||||||
|
|
||||||
if (period.isNew()) {
|
if (period.isNew()) {
|
||||||
@@ -379,7 +380,8 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
|
|||||||
period.periodNumber(), period.periodFromDate(), period.periodDueDate(), period.principalDue(),
|
period.periodNumber(), period.periodFromDate(), period.periodDueDate(), period.principalDue(),
|
||||||
period.interestDue(), BigDecimal.ZERO, BigDecimal.ZERO, false, compoundingDetails);
|
period.interestDue(), BigDecimal.ZERO, BigDecimal.ZERO, false, compoundingDetails);
|
||||||
|
|
||||||
repaymentScheduleInstallments.add(repaymentScheduleInstallment);
|
loan.addLoanRepaymentScheduleInstallment(repaymentScheduleInstallment);
|
||||||
|
repaymentScheduleInstallments.add(repaymentScheduleInstallment) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
@@ -423,8 +425,7 @@ public class LoanRescheduleRequestWritePlatformServiceImpl implements LoanResche
|
|||||||
waiveLoanCharges(loan, waiveLoanCharges);
|
waiveLoanCharges(loan, waiveLoanCharges);
|
||||||
|
|
||||||
// update the Loan summary
|
// update the Loan summary
|
||||||
loanSummary
|
loanSummary.updateSummary(currency, loan.getPrincpal(), repaymentScheduleInstallments, new LoanSummaryWrapper(), true, null);
|
||||||
.updateSummary(currency, loan.getPrincpal(), repaymentScheduleInstallments, new LoanSummaryWrapper(), true, null);
|
|
||||||
|
|
||||||
// update the total number of schedule repayments
|
// update the total number of schedule repayments
|
||||||
loan.updateNumberOfRepayments(periods.size());
|
loan.updateNumberOfRepayments(periods.size());
|
||||||
|
|||||||
+1
-1
@@ -959,7 +959,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
|||||||
if (loan.getFixedEmiAmount() != null) {
|
if (loan.getFixedEmiAmount() != null) {
|
||||||
Integer minimumNoOfRepayments = loan.loanProduct().getMinNumberOfRepayments();
|
Integer minimumNoOfRepayments = loan.loanProduct().getMinNumberOfRepayments();
|
||||||
Integer maximumNoOfRepayments = loan.loanProduct().getMaxNumberOfRepayments();
|
Integer maximumNoOfRepayments = loan.loanProduct().getMaxNumberOfRepayments();
|
||||||
Integer actualNumberOfRepayments = loan.getRepaymentScheduleInstallments().size();
|
Integer actualNumberOfRepayments = loan.getLoanRepaymentScheduleInstallmentsSize();
|
||||||
// validate actual number of repayments is > minimum number of
|
// validate actual number of repayments is > minimum number of
|
||||||
// repayments
|
// repayments
|
||||||
if (minimumNoOfRepayments != null && minimumNoOfRepayments != 0 && actualNumberOfRepayments < minimumNoOfRepayments) {
|
if (minimumNoOfRepayments != null && minimumNoOfRepayments != 0 && actualNumberOfRepayments < minimumNoOfRepayments) {
|
||||||
|
|||||||
+1
-1
@@ -1164,7 +1164,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
|||||||
|
|
||||||
private void saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
private void saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
||||||
try {
|
try {
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
for (LoanRepaymentScheduleInstallment installment : installments) {
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.getId() == null) {
|
if (installment.getId() == null) {
|
||||||
this.repaymentScheduleInstallmentRepository.save(installment);
|
this.repaymentScheduleInstallmentRepository.save(installment);
|
||||||
|
|||||||
+16
-15
@@ -365,7 +365,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), disburseAmount, paymentDetail,
|
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), disburseAmount, paymentDetail,
|
||||||
actualDisbursementDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
actualDisbursementDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
||||||
disbursementTransaction.updateLoan(loan);
|
disbursementTransaction.updateLoan(loan);
|
||||||
loan.getLoanTransactions().add(disbursementTransaction);
|
loan.addLoanTransaction(disbursementTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
regenerateScheduleOnDisbursement(command, loan, recalculateSchedule, scheduleGeneratorDTO, nextPossibleRepaymentDate, rescheduledRepaymentDate);
|
regenerateScheduleOnDisbursement(command, loan, recalculateSchedule, scheduleGeneratorDTO, nextPossibleRepaymentDate, rescheduledRepaymentDate);
|
||||||
@@ -508,7 +508,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
private void saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
private void saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
||||||
try {
|
try {
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
for (LoanRepaymentScheduleInstallment installment : installments) {
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.getId() == null) {
|
if (installment.getId() == null) {
|
||||||
this.repaymentScheduleInstallmentRepository.save(installment);
|
this.repaymentScheduleInstallmentRepository.save(installment);
|
||||||
@@ -529,7 +529,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
private void saveLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
private void saveLoanWithDataIntegrityViolationChecks(final Loan loan) {
|
||||||
try {
|
try {
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
for (LoanRepaymentScheduleInstallment installment : installments) {
|
for (LoanRepaymentScheduleInstallment installment : installments) {
|
||||||
if (installment.getId() == null) {
|
if (installment.getId() == null) {
|
||||||
this.repaymentScheduleInstallmentRepository.save(installment);
|
this.repaymentScheduleInstallmentRepository.save(installment);
|
||||||
@@ -607,7 +607,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), disburseAmount, paymentDetail,
|
LoanTransaction disbursementTransaction = LoanTransaction.disbursement(loan.getOffice(), disburseAmount, paymentDetail,
|
||||||
actualDisbursementDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
actualDisbursementDate, txnExternalId, DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
||||||
disbursementTransaction.updateLoan(loan);
|
disbursementTransaction.updateLoan(loan);
|
||||||
loan.getLoanTransactions().add(disbursementTransaction);
|
loan.addLoanTransaction(disbursementTransaction);
|
||||||
}
|
}
|
||||||
LocalDate recalculateFrom = null;
|
LocalDate recalculateFrom = null;
|
||||||
final ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
|
final ScheduleGeneratorDTO scheduleGeneratorDTO = this.loanUtilService.buildScheduleGeneratorDTO(loan, recalculateFrom);
|
||||||
@@ -903,7 +903,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
this.loanTransactionRepository.save(mapEntry.getValue());
|
this.loanTransactionRepository.save(mapEntry.getValue());
|
||||||
// update loan with references to the newly created transactions
|
// update loan with references to the newly created transactions
|
||||||
loan.getLoanTransactions().add(mapEntry.getValue());
|
loan.addLoanTransaction(mapEntry.getValue());
|
||||||
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1017,7 +1017,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
|
||||||
this.loanTransactionRepository.save(mapEntry.getValue());
|
this.loanTransactionRepository.save(mapEntry.getValue());
|
||||||
// update loan with references to the newly created transactions
|
// update loan with references to the newly created transactions
|
||||||
loan.getLoanTransactions().add(mapEntry.getValue());
|
loan.addLoanTransaction(mapEntry.getValue());
|
||||||
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1322,7 +1322,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
this.loanTransactionRepository.save(mapEntry.getValue());
|
this.loanTransactionRepository.save(mapEntry.getValue());
|
||||||
// update loan with references to the newly created
|
// update loan with references to the newly created
|
||||||
// transactions
|
// transactions
|
||||||
loan.getLoanTransactions().add(mapEntry.getValue());
|
loan.addLoanTransaction(mapEntry.getValue());
|
||||||
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1384,7 +1384,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
this.loanTransactionRepository.save(mapEntry.getValue());
|
this.loanTransactionRepository.save(mapEntry.getValue());
|
||||||
// update loan with references to the newly created
|
// update loan with references to the newly created
|
||||||
// transactions
|
// transactions
|
||||||
loan.getLoanTransactions().add(mapEntry.getValue());
|
loan.addLoanTransaction(mapEntry.getValue());
|
||||||
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1776,7 +1776,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
final LoanTransaction newTransferTransaction = LoanTransaction.initiateTransfer(loan.getOffice(), loan, transferDate,
|
final LoanTransaction newTransferTransaction = LoanTransaction.initiateTransfer(loan.getOffice(), loan, transferDate,
|
||||||
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
||||||
loan.getLoanTransactions().add(newTransferTransaction);
|
loan.addLoanTransaction(newTransferTransaction);
|
||||||
loan.setLoanStatus(LoanStatus.TRANSFER_IN_PROGRESS.getValue());
|
loan.setLoanStatus(LoanStatus.TRANSFER_IN_PROGRESS.getValue());
|
||||||
|
|
||||||
this.loanTransactionRepository.save(newTransferTransaction);
|
this.loanTransactionRepository.save(newTransferTransaction);
|
||||||
@@ -1803,7 +1803,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
final LoanTransaction newTransferAcceptanceTransaction = LoanTransaction.approveTransfer(acceptedInOffice, loan, transferDate,
|
final LoanTransaction newTransferAcceptanceTransaction = LoanTransaction.approveTransfer(acceptedInOffice, loan, transferDate,
|
||||||
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
||||||
loan.getLoanTransactions().add(newTransferAcceptanceTransaction);
|
loan.addLoanTransaction(newTransferAcceptanceTransaction);
|
||||||
if (loan.getTotalOverpaid() != null) {
|
if (loan.getTotalOverpaid() != null) {
|
||||||
loan.setLoanStatus(LoanStatus.OVERPAID.getValue());
|
loan.setLoanStatus(LoanStatus.OVERPAID.getValue());
|
||||||
} else {
|
} else {
|
||||||
@@ -1838,7 +1838,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
final LoanTransaction newTransferAcceptanceTransaction = LoanTransaction.withdrawTransfer(loan.getOffice(), loan, transferDate,
|
final LoanTransaction newTransferAcceptanceTransaction = LoanTransaction.withdrawTransfer(loan.getOffice(), loan, transferDate,
|
||||||
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
DateUtils.getLocalDateTimeOfTenant(), currentUser);
|
||||||
loan.getLoanTransactions().add(newTransferAcceptanceTransaction);
|
loan.addLoanTransaction(newTransferAcceptanceTransaction);
|
||||||
loan.setLoanStatus(LoanStatus.ACTIVE.getValue());
|
loan.setLoanStatus(LoanStatus.ACTIVE.getValue());
|
||||||
|
|
||||||
this.loanTransactionRepository.save(newTransferAcceptanceTransaction);
|
this.loanTransactionRepository.save(newTransferAcceptanceTransaction);
|
||||||
@@ -2327,7 +2327,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
this.loanTransactionRepository.save(mapEntry.getValue());
|
this.loanTransactionRepository.save(mapEntry.getValue());
|
||||||
// update loan with references to the newly created
|
// update loan with references to the newly created
|
||||||
// transactions
|
// transactions
|
||||||
loan.getLoanTransactions().add(mapEntry.getValue());
|
loan.addLoanTransaction(mapEntry.getValue());
|
||||||
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2348,7 +2348,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
private void addInstallmentIfPenaltyAppliedAfterLastDueDate(Loan loan, LocalDate lastChargeDate) {
|
private void addInstallmentIfPenaltyAppliedAfterLastDueDate(Loan loan, LocalDate lastChargeDate) {
|
||||||
if (lastChargeDate != null) {
|
if (lastChargeDate != null) {
|
||||||
List<LoanRepaymentScheduleInstallment> installments = loan.fetchRepaymentScheduleInstallments();
|
List<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
|
||||||
LoanRepaymentScheduleInstallment lastInstallment = loan.fetchRepaymentScheduleInstallment(installments.size());
|
LoanRepaymentScheduleInstallment lastInstallment = loan.fetchRepaymentScheduleInstallment(installments.size());
|
||||||
if (lastChargeDate.isAfter(lastInstallment.getDueDate())) {
|
if (lastChargeDate.isAfter(lastInstallment.getDueDate())) {
|
||||||
if (lastInstallment.isRecalculatedInterestComponent()) {
|
if (lastInstallment.isRecalculatedInterestComponent()) {
|
||||||
@@ -2360,11 +2360,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
BigDecimal interest = BigDecimal.ZERO;
|
BigDecimal interest = BigDecimal.ZERO;
|
||||||
BigDecimal feeCharges = BigDecimal.ZERO;
|
BigDecimal feeCharges = BigDecimal.ZERO;
|
||||||
BigDecimal penaltyCharges = BigDecimal.ONE;
|
BigDecimal penaltyCharges = BigDecimal.ONE;
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
||||||
LoanRepaymentScheduleInstallment newEntry = new LoanRepaymentScheduleInstallment(loan, installments.size() + 1,
|
LoanRepaymentScheduleInstallment newEntry = new LoanRepaymentScheduleInstallment(loan, installments.size() + 1,
|
||||||
lastInstallment.getDueDate(), lastChargeDate, principal, interest, feeCharges, penaltyCharges,
|
lastInstallment.getDueDate(), lastChargeDate, principal, interest, feeCharges, penaltyCharges,
|
||||||
recalculatedInterestComponent, compoundingDetails);
|
recalculatedInterestComponent, compoundingDetails);
|
||||||
installments.add(newEntry);
|
installments.add(newEntry);
|
||||||
|
loan.addLoanRepaymentScheduleInstallment(newEntry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2722,7 +2723,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
this.loanTransactionRepository.save(mapEntry.getValue());
|
this.loanTransactionRepository.save(mapEntry.getValue());
|
||||||
// update loan with references to the newly created
|
// update loan with references to the newly created
|
||||||
// transactions
|
// transactions
|
||||||
loan.getLoanTransactions().add(mapEntry.getValue());
|
loan.addLoanTransaction(mapEntry.getValue());
|
||||||
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
this.accountTransfersWritePlatformService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-12
@@ -60,8 +60,6 @@ import org.apache.fineract.portfolio.floatingrates.domain.FloatingRate;
|
|||||||
import org.apache.fineract.portfolio.fund.domain.Fund;
|
import org.apache.fineract.portfolio.fund.domain.Fund;
|
||||||
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.AprCalculator;
|
import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.AprCalculator;
|
||||||
import org.apache.fineract.portfolio.loanproduct.LoanProductConstants;
|
import org.apache.fineract.portfolio.loanproduct.LoanProductConstants;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@@ -133,8 +131,7 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "external_id", length = 100, nullable = true, unique = true)
|
@Column(name = "external_id", length = 100, nullable = true, unique = true)
|
||||||
private String externalId;
|
private String externalId;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true)
|
|
||||||
private Set<LoanProductBorrowerCycleVariations> borrowerCycleVariations = new HashSet<>();
|
private Set<LoanProductBorrowerCycleVariations> borrowerCycleVariations = new HashSet<>();
|
||||||
|
|
||||||
@Column(name = "overdue_days_for_npa", nullable = true)
|
@Column(name = "overdue_days_for_npa", nullable = true)
|
||||||
@@ -143,15 +140,13 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "min_days_between_disbursal_and_first_repayment", nullable = true)
|
@Column(name = "min_days_between_disbursal_and_first_repayment", nullable = true)
|
||||||
private Integer minimumDaysBetweenDisbursalAndFirstRepayment;
|
private Integer minimumDaysBetweenDisbursalAndFirstRepayment;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true)
|
|
||||||
private LoanProductInterestRecalculationDetails productInterestRecalculationDetails;
|
private LoanProductInterestRecalculationDetails productInterestRecalculationDetails;
|
||||||
|
|
||||||
@Column(name = "hold_guarantee_funds")
|
@Column(name = "hold_guarantee_funds")
|
||||||
private boolean holdGuaranteeFunds;
|
private boolean holdGuaranteeFunds;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true)
|
|
||||||
private LoanProductGuaranteeDetails loanProductGuaranteeDetails;
|
private LoanProductGuaranteeDetails loanProductGuaranteeDetails;
|
||||||
|
|
||||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true)
|
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true)
|
||||||
@@ -172,15 +167,13 @@ public class LoanProduct extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "is_linked_to_floating_interest_rates", nullable = false)
|
@Column(name = "is_linked_to_floating_interest_rates", nullable = false)
|
||||||
private boolean isLinkedToFloatingInterestRate;
|
private boolean isLinkedToFloatingInterestRate;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true)
|
|
||||||
private LoanProductFloatingRates floatingRates;
|
private LoanProductFloatingRates floatingRates;
|
||||||
|
|
||||||
@Column(name = "allow_variabe_installments", nullable = false)
|
@Column(name = "allow_variabe_installments", nullable = false)
|
||||||
private boolean allowVariabeInstallments;
|
private boolean allowVariabeInstallments;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToOne(cascade = CascadeType.ALL, mappedBy = "loanProduct", optional = true, orphanRemoval = true)
|
|
||||||
private LoanProductVariableInstallmentConfig variableInstallmentConfig;
|
private LoanProductVariableInstallmentConfig variableInstallmentConfig;
|
||||||
|
|
||||||
public static LoanProduct assembleFromJson(final Fund fund, final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy,
|
public static LoanProduct assembleFromJson(final Fund fund, final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy,
|
||||||
|
|||||||
+1
-1
@@ -466,7 +466,7 @@ public class DepositAccountDomainServiceJpa implements DepositAccountDomainServi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateAlreadyPostedTransactions(final Set<Long> existingTransactionIds, final SavingsAccount savingsAccount) {
|
private void updateAlreadyPostedTransactions(final Set<Long> existingTransactionIds, final SavingsAccount savingsAccount) {
|
||||||
List<SavingsAccountTransaction> transactions = savingsAccount.getTransactions();
|
List<SavingsAccountTransaction> transactions = savingsAccount.getTransactions() ;
|
||||||
int size = transactions.size();
|
int size = transactions.size();
|
||||||
for (int i = size - 1;; i--) {
|
for (int i = size - 1;; i--) {
|
||||||
SavingsAccountTransaction transaction = transactions.get(i);
|
SavingsAccountTransaction transaction = transactions.get(i);
|
||||||
|
|||||||
+2
-4
@@ -25,6 +25,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.OneToOne;
|
import javax.persistence.OneToOne;
|
||||||
@@ -37,8 +38,6 @@ import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartS
|
|||||||
import org.apache.fineract.portfolio.interestratechart.incentive.AttributeIncentiveCalculation;
|
import org.apache.fineract.portfolio.interestratechart.incentive.AttributeIncentiveCalculation;
|
||||||
import org.apache.fineract.portfolio.interestratechart.incentive.AttributeIncentiveCalculationFactory;
|
import org.apache.fineract.portfolio.interestratechart.incentive.AttributeIncentiveCalculationFactory;
|
||||||
import org.apache.fineract.portfolio.interestratechart.incentive.IncentiveDTO;
|
import org.apache.fineract.portfolio.interestratechart.incentive.IncentiveDTO;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@@ -53,8 +52,7 @@ public class DepositAccountInterestRateChart extends AbstractPersistable<Long> {
|
|||||||
@JoinColumn(name = "savings_account_id", nullable = false)
|
@JoinColumn(name = "savings_account_id", nullable = false)
|
||||||
private SavingsAccount account;
|
private SavingsAccount account;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(mappedBy = "depositAccountInterestRateChart", cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(mappedBy = "depositAccountInterestRateChart", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private Set<DepositAccountInterestRateChartSlabs> chartSlabs = new HashSet<>();
|
private Set<DepositAccountInterestRateChartSlabs> chartSlabs = new HashSet<>();
|
||||||
|
|
||||||
protected DepositAccountInterestRateChart() {
|
protected DepositAccountInterestRateChart() {
|
||||||
|
|||||||
+2
-4
@@ -24,6 +24,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -32,8 +33,6 @@ import javax.persistence.Table;
|
|||||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestIncentives;
|
import org.apache.fineract.portfolio.interestratechart.domain.InterestIncentives;
|
||||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab;
|
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlab;
|
||||||
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabFields;
|
import org.apache.fineract.portfolio.interestratechart.domain.InterestRateChartSlabFields;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -47,8 +46,7 @@ public class DepositAccountInterestRateChartSlabs extends AbstractPersistable<Lo
|
|||||||
@JoinColumn(name = "savings_account_interest_rate_chart_id", referencedColumnName = "id", nullable = false)
|
@JoinColumn(name = "savings_account_interest_rate_chart_id", referencedColumnName = "id", nullable = false)
|
||||||
private DepositAccountInterestRateChart depositAccountInterestRateChart;
|
private DepositAccountInterestRateChart depositAccountInterestRateChart;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(mappedBy = "depositAccountInterestRateChartSlabs", cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(mappedBy = "depositAccountInterestRateChartSlabs", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private Set<DepositAccountInterestIncentives> interestIncentives = new HashSet<>();
|
private Set<DepositAccountInterestIncentives> interestIncentives = new HashSet<>();
|
||||||
|
|
||||||
protected DepositAccountInterestRateChartSlabs() {
|
protected DepositAccountInterestRateChartSlabs() {
|
||||||
|
|||||||
+34
-15
@@ -28,7 +28,9 @@ import java.math.MathContext;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -70,8 +72,6 @@ import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionDTO;
|
|||||||
import org.apache.fineract.portfolio.savings.domain.interest.PostingPeriod;
|
import org.apache.fineract.portfolio.savings.domain.interest.PostingPeriod;
|
||||||
import org.apache.fineract.portfolio.savings.service.SavingsEnumerations;
|
import org.apache.fineract.portfolio.savings.service.SavingsEnumerations;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
@@ -89,9 +89,12 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "account")
|
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "account")
|
||||||
private DepositAccountInterestRateChart chart;
|
private DepositAccountInterestRateChart chart;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "account", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "account", orphanRemoval = true)
|
private Set<RecurringDepositScheduleInstallment> depositScheduleInstallments = new HashSet<>();
|
||||||
private List<RecurringDepositScheduleInstallment> depositScheduleInstallments = new ArrayList<>();
|
|
||||||
|
private transient List<RecurringDepositScheduleInstallment> sortedDepositInstallments = null ;
|
||||||
|
|
||||||
|
private transient boolean isDepositScheduleInstallmentDirty = false ;
|
||||||
|
|
||||||
protected RecurringDepositAccount() {
|
protected RecurringDepositAccount() {
|
||||||
//
|
//
|
||||||
@@ -620,7 +623,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
if (postingTransaction == null) {
|
if (postingTransaction == null) {
|
||||||
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
|
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
|
||||||
interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
|
interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
|
||||||
this.transactions.add(newPostingTransaction);
|
addTransaction(newPostingTransaction);
|
||||||
recalucateDailyBalanceDetails = true;
|
recalucateDailyBalanceDetails = true;
|
||||||
} else {
|
} else {
|
||||||
final boolean correctionRequired = postingTransaction.hasNotAmount(interestEarnedToBePostedForPeriod);
|
final boolean correctionRequired = postingTransaction.hasNotAmount(interestEarnedToBePostedForPeriod);
|
||||||
@@ -628,7 +631,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
postingTransaction.reverse();
|
postingTransaction.reverse();
|
||||||
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
|
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
|
||||||
interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
|
interestPostingTransactionDate, interestEarnedToBePostedForPeriod);
|
||||||
this.transactions.add(newPostingTransaction);
|
addTransaction(newPostingTransaction);
|
||||||
recalucateDailyBalanceDetails = true;
|
recalucateDailyBalanceDetails = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -660,7 +663,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
if (!remainigInterestToBePosted.isZero()) {
|
if (!remainigInterestToBePosted.isZero()) {
|
||||||
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
|
final SavingsAccountTransaction newPostingTransaction = SavingsAccountTransaction.interestPosting(this, office(),
|
||||||
accountCloseDate, remainigInterestToBePosted);
|
accountCloseDate, remainigInterestToBePosted);
|
||||||
this.transactions.add(newPostingTransaction);
|
addTransaction(newPostingTransaction);
|
||||||
recalucateDailyBalance = true;
|
recalucateDailyBalance = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -751,7 +754,8 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
|
|
||||||
private Money totalInterestPosted() {
|
private Money totalInterestPosted() {
|
||||||
Money interestPostedToDate = Money.zero(this.currency);
|
Money interestPostedToDate = Money.zero(this.currency);
|
||||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
List<SavingsAccountTransaction> trans = getTransactions() ;
|
||||||
|
for (final SavingsAccountTransaction transaction : trans) {
|
||||||
if (transaction.isInterestPostingAndNotReversed()) {
|
if (transaction.isInterestPostingAndNotReversed()) {
|
||||||
interestPostedToDate = interestPostedToDate.plus(transaction.getAmount(currency));
|
interestPostedToDate = interestPostedToDate.plus(transaction.getAmount(currency));
|
||||||
}
|
}
|
||||||
@@ -1122,8 +1126,8 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void generateSchedule(final PeriodFrequencyType frequency, final Integer recurringEvery, final Calendar calendar) {
|
public void generateSchedule(final PeriodFrequencyType frequency, final Integer recurringEvery, final Calendar calendar) {
|
||||||
final List<RecurringDepositScheduleInstallment> depositScheduleInstallments = depositScheduleInstallments();
|
this.depositScheduleInstallments.clear();
|
||||||
depositScheduleInstallments.clear();
|
this.isDepositScheduleInstallmentDirty = true ;
|
||||||
LocalDate installmentDate = null;
|
LocalDate installmentDate = null;
|
||||||
if (this.isCalendarInherited()) {
|
if (this.isCalendarInherited()) {
|
||||||
installmentDate = CalendarUtils.getNextScheduleDate(calendar, accountSubmittedOrActivationDate());
|
installmentDate = CalendarUtils.getNextScheduleDate(calendar, accountSubmittedOrActivationDate());
|
||||||
@@ -1137,7 +1141,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
while (maturityDate.isAfter(installmentDate)) {
|
while (maturityDate.isAfter(installmentDate)) {
|
||||||
final RecurringDepositScheduleInstallment installment = RecurringDepositScheduleInstallment.installment(this,
|
final RecurringDepositScheduleInstallment installment = RecurringDepositScheduleInstallment.installment(this,
|
||||||
installmentNumber, installmentDate.toDate(), depositAmount);
|
installmentNumber, installmentDate.toDate(), depositAmount);
|
||||||
depositScheduleInstallments.add(installment);
|
addDepositScheduleInstallment(installment);
|
||||||
installmentDate = DepositAccountUtils.calculateNextDepositDate(installmentDate, frequency, recurringEvery);
|
installmentDate = DepositAccountUtils.calculateNextDepositDate(installmentDate, frequency, recurringEvery);
|
||||||
installmentNumber += 1;
|
installmentNumber += 1;
|
||||||
}
|
}
|
||||||
@@ -1155,10 +1159,17 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<RecurringDepositScheduleInstallment> depositScheduleInstallments() {
|
private List<RecurringDepositScheduleInstallment> depositScheduleInstallments() {
|
||||||
if (this.depositScheduleInstallments == null) {
|
if(this.isDepositScheduleInstallmentDirty || this.sortedDepositInstallments == null) {
|
||||||
this.depositScheduleInstallments = new ArrayList<>();
|
this.sortedDepositInstallments = new ArrayList<>(this.depositScheduleInstallments) ;
|
||||||
|
this.sortedDepositInstallments.sort(new RecurringDepositScheduleInstallmentComparator());
|
||||||
|
this.isDepositScheduleInstallmentDirty = false ;
|
||||||
}
|
}
|
||||||
return this.depositScheduleInstallments;
|
return this.sortedDepositInstallments ;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDepositScheduleInstallment(final RecurringDepositScheduleInstallment installment) {
|
||||||
|
this.depositScheduleInstallments.add(installment) ;
|
||||||
|
isDepositScheduleInstallmentDirty = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCalendarInherited() {
|
public boolean isCalendarInherited() {
|
||||||
@@ -1201,4 +1212,12 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
return this.recurringDetail;
|
return this.recurringDetail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class RecurringDepositScheduleInstallmentComparator implements Comparator<RecurringDepositScheduleInstallment> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compare(final RecurringDepositScheduleInstallment o1, final RecurringDepositScheduleInstallment o2) {
|
||||||
|
final int comparsion = o1.installmentNumber().compareTo(o2.installmentNumber());
|
||||||
|
return comparsion ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -241,4 +241,8 @@ public class RecurringDepositScheduleInstallment extends AbstractAuditableCustom
|
|||||||
this.depositAmount = newDepositAmount;
|
this.depositAmount = newDepositAmount;
|
||||||
this.resetDerivedFields();
|
this.resetDerivedFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer installmentNumber() {
|
||||||
|
return this.installmentNumber ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+49
-39
@@ -54,6 +54,7 @@ import javax.persistence.DiscriminatorType;
|
|||||||
import javax.persistence.DiscriminatorValue;
|
import javax.persistence.DiscriminatorValue;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.Inheritance;
|
import javax.persistence.Inheritance;
|
||||||
import javax.persistence.InheritanceType;
|
import javax.persistence.InheritanceType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
@@ -108,13 +109,10 @@ import org.apache.fineract.portfolio.tax.domain.TaxComponent;
|
|||||||
import org.apache.fineract.portfolio.tax.domain.TaxGroup;
|
import org.apache.fineract.portfolio.tax.domain.TaxGroup;
|
||||||
import org.apache.fineract.portfolio.tax.service.TaxUtils;
|
import org.apache.fineract.portfolio.tax.service.TaxUtils;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.joda.time.format.DateTimeFormat;
|
import org.joda.time.format.DateTimeFormat;
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
@@ -148,7 +146,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
@JoinColumn(name = "product_id", nullable = false)
|
@JoinColumn(name = "product_id", nullable = false)
|
||||||
protected SavingsProduct product;
|
protected SavingsProduct product;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "field_officer_id", nullable = true)
|
@JoinColumn(name = "field_officer_id", nullable = true)
|
||||||
protected Staff savingsOfficer;
|
protected Staff savingsOfficer;
|
||||||
|
|
||||||
@@ -165,7 +163,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "submittedon_date", nullable = true)
|
@Column(name = "submittedon_date", nullable = true)
|
||||||
protected Date submittedOnDate;
|
protected Date submittedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "submittedon_userid", nullable = true)
|
@JoinColumn(name = "submittedon_userid", nullable = true)
|
||||||
protected AppUser submittedBy;
|
protected AppUser submittedBy;
|
||||||
|
|
||||||
@@ -173,7 +171,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "rejectedon_date")
|
@Column(name = "rejectedon_date")
|
||||||
protected Date rejectedOnDate;
|
protected Date rejectedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "rejectedon_userid", nullable = true)
|
@JoinColumn(name = "rejectedon_userid", nullable = true)
|
||||||
protected AppUser rejectedBy;
|
protected AppUser rejectedBy;
|
||||||
|
|
||||||
@@ -181,7 +179,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "withdrawnon_date")
|
@Column(name = "withdrawnon_date")
|
||||||
protected Date withdrawnOnDate;
|
protected Date withdrawnOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "withdrawnon_userid", nullable = true)
|
@JoinColumn(name = "withdrawnon_userid", nullable = true)
|
||||||
protected AppUser withdrawnBy;
|
protected AppUser withdrawnBy;
|
||||||
|
|
||||||
@@ -189,7 +187,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "approvedon_date")
|
@Column(name = "approvedon_date")
|
||||||
protected Date approvedOnDate;
|
protected Date approvedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "approvedon_userid", nullable = true)
|
@JoinColumn(name = "approvedon_userid", nullable = true)
|
||||||
protected AppUser approvedBy;
|
protected AppUser approvedBy;
|
||||||
|
|
||||||
@@ -197,7 +195,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "activatedon_date", nullable = true)
|
@Column(name = "activatedon_date", nullable = true)
|
||||||
protected Date activatedOnDate;
|
protected Date activatedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "activatedon_userid", nullable = true)
|
@JoinColumn(name = "activatedon_userid", nullable = true)
|
||||||
protected AppUser activatedBy;
|
protected AppUser activatedBy;
|
||||||
|
|
||||||
@@ -205,7 +203,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "closedon_date")
|
@Column(name = "closedon_date")
|
||||||
protected Date closedOnDate;
|
protected Date closedOnDate;
|
||||||
|
|
||||||
@ManyToOne(optional = true)
|
@ManyToOne(optional = true, fetch=FetchType.LAZY)
|
||||||
@JoinColumn(name = "closedon_userid", nullable = true)
|
@JoinColumn(name = "closedon_userid", nullable = true)
|
||||||
protected AppUser closedBy;
|
protected AppUser closedBy;
|
||||||
|
|
||||||
@@ -294,16 +292,17 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
protected SavingsAccountSummary summary;
|
protected SavingsAccountSummary summary;
|
||||||
|
|
||||||
@OrderBy(value = "dateOf, createdDate, id")
|
@OrderBy(value = "dateOf, createdDate, id")
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true)
|
protected final Set<SavingsAccountTransaction> transactions = new HashSet<>();
|
||||||
protected final List<SavingsAccountTransaction> transactions = new ArrayList<>();
|
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
private transient List<SavingsAccountTransaction> orderedTransactions = null ;
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true)
|
|
||||||
|
private transient boolean isTransactionsDirty = false ;
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
protected Set<SavingsAccountCharge> charges = new HashSet<>();
|
protected Set<SavingsAccountCharge> charges = new HashSet<>();
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccount", orphanRemoval = true)
|
|
||||||
private Set<SavingsOfficerAssignmentHistory> savingsOfficerHistory;
|
private Set<SavingsOfficerAssignmentHistory> savingsOfficerHistory;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
@@ -500,7 +499,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
newPostingTransaction = SavingsAccountTransaction.overdraftInterest(this, office(), interestPostingTransactionDate,
|
newPostingTransaction = SavingsAccountTransaction.overdraftInterest(this, office(), interestPostingTransactionDate,
|
||||||
interestEarnedToBePostedForPeriod.negated());
|
interestEarnedToBePostedForPeriod.negated());
|
||||||
}
|
}
|
||||||
this.transactions.add(newPostingTransaction);
|
addTransaction(newPostingTransaction);
|
||||||
if (applyWithHoldTax) {
|
if (applyWithHoldTax) {
|
||||||
createWithHoldTransaction(interestEarnedToBePostedForPeriod.getAmount(), interestPostingTransactionDate);
|
createWithHoldTransaction(interestEarnedToBePostedForPeriod.getAmount(), interestPostingTransactionDate);
|
||||||
}
|
}
|
||||||
@@ -529,7 +528,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
newPostingTransaction = SavingsAccountTransaction.overdraftInterest(this, office(),
|
newPostingTransaction = SavingsAccountTransaction.overdraftInterest(this, office(),
|
||||||
interestPostingTransactionDate, interestEarnedToBePostedForPeriod.negated());
|
interestPostingTransactionDate, interestEarnedToBePostedForPeriod.negated());
|
||||||
}
|
}
|
||||||
this.transactions.add(newPostingTransaction);
|
addTransaction(newPostingTransaction);
|
||||||
if (applyWithHoldTaxForOldTransaction) {
|
if (applyWithHoldTaxForOldTransaction) {
|
||||||
createWithHoldTransaction(interestEarnedToBePostedForPeriod.getAmount(), interestPostingTransactionDate);
|
createWithHoldTransaction(interestEarnedToBePostedForPeriod.getAmount(), interestPostingTransactionDate);
|
||||||
}
|
}
|
||||||
@@ -555,7 +554,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
protected List<SavingsAccountTransaction> findWithHoldTransactions() {
|
protected List<SavingsAccountTransaction> findWithHoldTransactions() {
|
||||||
final List<SavingsAccountTransaction> withholdTransactions = new ArrayList<>();
|
final List<SavingsAccountTransaction> withholdTransactions = new ArrayList<>();
|
||||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
List<SavingsAccountTransaction> trans = getTransactions() ;
|
||||||
|
for (final SavingsAccountTransaction transaction : trans) {
|
||||||
if ((transaction.isWithHoldTaxAndNotReversed())) {
|
if ((transaction.isWithHoldTaxAndNotReversed())) {
|
||||||
withholdTransactions.add(transaction);
|
withholdTransactions.add(transaction);
|
||||||
}
|
}
|
||||||
@@ -569,7 +569,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
|
|
||||||
protected SavingsAccountTransaction findInterestPostingTransactionFor(final LocalDate postingDate) {
|
protected SavingsAccountTransaction findInterestPostingTransactionFor(final LocalDate postingDate) {
|
||||||
SavingsAccountTransaction postingTransation = null;
|
SavingsAccountTransaction postingTransation = null;
|
||||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
List<SavingsAccountTransaction> trans = getTransactions() ;
|
||||||
|
for (final SavingsAccountTransaction transaction : trans) {
|
||||||
if ((transaction.isInterestPostingAndNotReversed() || transaction.isOverdraftInterestAndNotReversed())
|
if ((transaction.isInterestPostingAndNotReversed() || transaction.isOverdraftInterestAndNotReversed())
|
||||||
&& transaction.occursOn(postingDate)) {
|
&& transaction.occursOn(postingDate)) {
|
||||||
postingTransation = transaction;
|
postingTransation = transaction;
|
||||||
@@ -598,7 +599,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
if (totalTax.compareTo(BigDecimal.ZERO) == 1) {
|
if (totalTax.compareTo(BigDecimal.ZERO) == 1) {
|
||||||
SavingsAccountTransaction withholdTransaction = SavingsAccountTransaction.withHoldTax(this, office(), date,
|
SavingsAccountTransaction withholdTransaction = SavingsAccountTransaction.withHoldTax(this, office(), date,
|
||||||
Money.of(currency, totalTax), taxSplit);
|
Money.of(currency, totalTax), taxSplit);
|
||||||
this.transactions.add(withholdTransaction);
|
addTransaction(withholdTransaction);
|
||||||
isTaxAdded = true;
|
isTaxAdded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -621,7 +622,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
withholdTransaction.reverse();
|
withholdTransaction.reverse();
|
||||||
SavingsAccountTransaction newWithholdTransaction = SavingsAccountTransaction.withHoldTax(this, office(),
|
SavingsAccountTransaction newWithholdTransaction = SavingsAccountTransaction.withHoldTax(this, office(),
|
||||||
withholdTransaction.transactionLocalDate(), Money.of(currency, totalTax), taxSplit);
|
withholdTransaction.transactionLocalDate(), Money.of(currency, totalTax), taxSplit);
|
||||||
this.transactions.add(newWithholdTransaction);
|
addTransaction(newWithholdTransaction);
|
||||||
isTaxAdded = true;
|
isTaxAdded = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -633,8 +634,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
protected SavingsAccountTransaction findLastTransaction(final LocalDate date) {
|
protected SavingsAccountTransaction findLastTransaction(final LocalDate date) {
|
||||||
|
|
||||||
SavingsAccountTransaction savingsTransaction = null;
|
SavingsAccountTransaction savingsTransaction = null;
|
||||||
|
List<SavingsAccountTransaction> trans = getTransactions() ;
|
||||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
for (final SavingsAccountTransaction transaction : trans) {
|
||||||
if (transaction.isNotReversed() && transaction.occursOn(date)) {
|
if (transaction.isNotReversed() && transaction.occursOn(date)) {
|
||||||
savingsTransaction = transaction;
|
savingsTransaction = transaction;
|
||||||
break;
|
break;
|
||||||
@@ -763,7 +764,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
orderedNonInterestPostingTransactions.add(transaction);
|
orderedNonInterestPostingTransactions.add(transaction);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
orderedNonInterestPostingTransactions.sort(new SavingsAccountTransactionComparator());
|
||||||
return orderedNonInterestPostingTransactions;
|
return orderedNonInterestPostingTransactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -819,7 +820,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
accountTransaction.updateOverdraftAmount(overdraftAmount.getAmount());
|
accountTransaction.updateOverdraftAmount(overdraftAmount.getAmount());
|
||||||
}
|
}
|
||||||
accountTransaction.updateRunningBalance(runningBalance);
|
accountTransaction.updateRunningBalance(runningBalance);
|
||||||
this.transactions.add(accountTransaction);
|
addTransaction(accountTransaction);
|
||||||
isTransactionsModified = true;
|
isTransactionsModified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,8 +903,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(this, office(), transactionDTO.getPaymentDetail(),
|
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(this, office(), transactionDTO.getPaymentDetail(),
|
||||||
transactionDTO.getTransactionDate(), amount, transactionDTO.getCreatedDate(), transactionDTO.getAppUser(),
|
transactionDTO.getTransactionDate(), amount, transactionDTO.getCreatedDate(), transactionDTO.getAppUser(),
|
||||||
savingsAccountTransactionType);
|
savingsAccountTransactionType);
|
||||||
this.transactions.add(transaction);
|
addTransaction(transaction);
|
||||||
|
|
||||||
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||||
|
|
||||||
if(this.sub_status.equals(SavingsAccountSubStatusEnum.INACTIVE.getValue())
|
if(this.sub_status.equals(SavingsAccountSubStatusEnum.INACTIVE.getValue())
|
||||||
@@ -990,8 +990,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.withdrawal(this, office(),
|
final SavingsAccountTransaction transaction = SavingsAccountTransaction.withdrawal(this, office(),
|
||||||
transactionDTO.getPaymentDetail(), transactionDTO.getTransactionDate(), transactionAmountMoney,
|
transactionDTO.getPaymentDetail(), transactionDTO.getTransactionDate(), transactionAmountMoney,
|
||||||
transactionDTO.getCreatedDate(), transactionDTO.getAppUser());
|
transactionDTO.getCreatedDate(), transactionDTO.getAppUser());
|
||||||
this.transactions.add(transaction);
|
addTransaction(transaction);
|
||||||
|
|
||||||
if (applyWithdrawFee) {
|
if (applyWithdrawFee) {
|
||||||
// auto pay withdrawal fee
|
// auto pay withdrawal fee
|
||||||
payWithdrawalFee(transactionDTO.getTransactionAmount(), transactionDTO.getTransactionDate(), transactionDTO.getAppUser());
|
payWithdrawalFee(transactionDTO.getTransactionAmount(), transactionDTO.getTransactionDate(), transactionDTO.getAppUser());
|
||||||
@@ -1410,7 +1409,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
accountingBridgeData.put("isAccountTransfer", isAccountTransfer);
|
accountingBridgeData.put("isAccountTransfer", isAccountTransfer);
|
||||||
|
|
||||||
final List<Map<String, Object>> newSavingsTransactions = new ArrayList<>();
|
final List<Map<String, Object>> newSavingsTransactions = new ArrayList<>();
|
||||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
List<SavingsAccountTransaction> trans = getTransactions() ;
|
||||||
|
for (final SavingsAccountTransaction transaction : trans) {
|
||||||
if (transaction.isReversed() && !existingReversedTransactionIds.contains(transaction.getId())) {
|
if (transaction.isReversed() && !existingReversedTransactionIds.contains(transaction.getId())) {
|
||||||
newSavingsTransactions.add(transaction.toMapData(currencyData));
|
newSavingsTransactions.add(transaction.toMapData(currencyData));
|
||||||
} else if (!existingTransactionIds.contains(transaction.getId())) {
|
} else if (!existingTransactionIds.contains(transaction.getId())) {
|
||||||
@@ -1425,8 +1425,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
public Collection<Long> findExistingTransactionIds() {
|
public Collection<Long> findExistingTransactionIds() {
|
||||||
|
|
||||||
final Collection<Long> ids = new ArrayList<>();
|
final Collection<Long> ids = new ArrayList<>();
|
||||||
|
List<SavingsAccountTransaction> trans = getTransactions() ;
|
||||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
for (final SavingsAccountTransaction transaction : trans) {
|
||||||
ids.add(transaction.getId());
|
ids.add(transaction.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1436,8 +1436,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
public Collection<Long> findExistingReversedTransactionIds() {
|
public Collection<Long> findExistingReversedTransactionIds() {
|
||||||
|
|
||||||
final Collection<Long> ids = new ArrayList<>();
|
final Collection<Long> ids = new ArrayList<>();
|
||||||
|
List<SavingsAccountTransaction> trans = getTransactions() ;
|
||||||
for (final SavingsAccountTransaction transaction : this.transactions) {
|
for (final SavingsAccountTransaction transaction : trans) {
|
||||||
if (transaction.isReversed()) {
|
if (transaction.isReversed()) {
|
||||||
ids.add(transaction.getId());
|
ids.add(transaction.getId());
|
||||||
}
|
}
|
||||||
@@ -2266,7 +2266,17 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<SavingsAccountTransaction> getTransactions() {
|
public List<SavingsAccountTransaction> getTransactions() {
|
||||||
return this.transactions;
|
if(this.orderedTransactions == null || isTransactionsDirty) {
|
||||||
|
this.orderedTransactions = new ArrayList<>(this.transactions) ;
|
||||||
|
this.orderedTransactions.sort(new SavingsAccountTransactionComparator());
|
||||||
|
this.isTransactionsDirty = false ;
|
||||||
|
}
|
||||||
|
return orderedTransactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTransaction(final SavingsAccountTransaction transaction) {
|
||||||
|
this.transactions.add(transaction);
|
||||||
|
this.isTransactionsDirty = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(final Integer status) {
|
public void setStatus(final Integer status) {
|
||||||
@@ -2555,7 +2565,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
final SavingsAccountChargePaidBy chargePaidBy = SavingsAccountChargePaidBy.instance(transaction, savingsAccountCharge, transaction
|
final SavingsAccountChargePaidBy chargePaidBy = SavingsAccountChargePaidBy.instance(transaction, savingsAccountCharge, transaction
|
||||||
.getAmount(this.getCurrency()).getAmount());
|
.getAmount(this.getCurrency()).getAmount());
|
||||||
transaction.getSavingsAccountChargesPaid().add(chargePaidBy);
|
transaction.getSavingsAccountChargesPaid().add(chargePaidBy);
|
||||||
this.getTransactions().add(transaction);
|
this.transactions.add(transaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SavingsAccountCharge getCharge(final Long savingsAccountChargeId) {
|
private SavingsAccountCharge getCharge(final Long savingsAccountChargeId) {
|
||||||
@@ -2573,7 +2583,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Set<SavingsAccountCharge> charges() {
|
public Set<SavingsAccountCharge> charges() {
|
||||||
return (this.charges == null) ? new HashSet<SavingsAccountCharge>() : this.charges;
|
return (this.charges == null) ? new HashSet<>() : this.charges;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateAccountValuesWithProduct() {
|
public void validateAccountValuesWithProduct() {
|
||||||
|
|||||||
+1
-2
@@ -27,7 +27,6 @@ import static org.apache.fineract.portfolio.savings.SavingsApiConstants.localePa
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.MathContext;
|
import java.math.MathContext;
|
||||||
import java.math.RoundingMode;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -709,7 +708,7 @@ public class SavingsAccountCharge extends AbstractPersistable<Long> {
|
|||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return new HashCodeBuilder(3, 5) //
|
return new HashCodeBuilder(3, 5) //
|
||||||
.append(getId()) //
|
.append(getId()) //
|
||||||
.append(this.charge.getId()) //
|
//.append(this.charge.getId()) //
|
||||||
.append(this.amount).append(getDueLocalDate()) //
|
.append(this.amount).append(getDueLocalDate()) //
|
||||||
.toHashCode();
|
.toHashCode();
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -21,6 +21,7 @@ package org.apache.fineract.portfolio.savings.domain;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
@@ -90,7 +91,7 @@ public final class SavingsAccountSummary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateSummary(final MonetaryCurrency currency, final SavingsAccountTransactionSummaryWrapper wrapper,
|
public void updateSummary(final MonetaryCurrency currency, final SavingsAccountTransactionSummaryWrapper wrapper,
|
||||||
final List<SavingsAccountTransaction> transactions) {
|
final Set<SavingsAccountTransaction> transactions) {
|
||||||
|
|
||||||
this.totalDeposits = wrapper.calculateTotalDeposits(currency, transactions);
|
this.totalDeposits = wrapper.calculateTotalDeposits(currency, transactions);
|
||||||
this.totalWithdrawals = wrapper.calculateTotalWithdrawals(currency, transactions);
|
this.totalWithdrawals = wrapper.calculateTotalWithdrawals(currency, transactions);
|
||||||
|
|||||||
+3
-6
@@ -31,6 +31,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -50,8 +51,6 @@ import org.apache.fineract.portfolio.savings.domain.interest.EndOfDayBalance;
|
|||||||
import org.apache.fineract.portfolio.savings.service.SavingsEnumerations;
|
import org.apache.fineract.portfolio.savings.service.SavingsEnumerations;
|
||||||
import org.apache.fineract.portfolio.tax.domain.TaxComponent;
|
import org.apache.fineract.portfolio.tax.domain.TaxComponent;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
@@ -102,8 +101,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "balance_number_of_days_derived", nullable = false)
|
@Column(name = "balance_number_of_days_derived", nullable = false)
|
||||||
private Integer balanceNumberOfDays;
|
private Integer balanceNumberOfDays;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccountTransaction", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "savingsAccountTransaction", orphanRemoval = true)
|
|
||||||
private final Set<SavingsAccountChargePaidBy> savingsAccountChargesPaid = new HashSet<>();
|
private final Set<SavingsAccountChargePaidBy> savingsAccountChargesPaid = new HashSet<>();
|
||||||
|
|
||||||
@Column(name = "overdraft_amount_derived", scale = 6, precision = 19, nullable = true)
|
@Column(name = "overdraft_amount_derived", scale = 6, precision = 19, nullable = true)
|
||||||
@@ -117,8 +115,7 @@ public final class SavingsAccountTransaction extends AbstractPersistable<Long> {
|
|||||||
@JoinColumn(name = "appuser_id", nullable = true)
|
@JoinColumn(name = "appuser_id", nullable = true)
|
||||||
private AppUser appUser;
|
private AppUser appUser;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
@JoinColumn(name = "savings_transaction_id", referencedColumnName = "id", nullable = false)
|
@JoinColumn(name = "savings_transaction_id", referencedColumnName = "id", nullable = false)
|
||||||
private final List<SavingsAccountTransactionTaxDetails> taxDetails = new ArrayList<>();
|
private final List<SavingsAccountTransactionTaxDetails> taxDetails = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
+12
-12
@@ -19,7 +19,7 @@
|
|||||||
package org.apache.fineract.portfolio.savings.domain;
|
package org.apache.fineract.portfolio.savings.domain;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
@@ -32,7 +32,7 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public final class SavingsAccountTransactionSummaryWrapper {
|
public final class SavingsAccountTransactionSummaryWrapper {
|
||||||
|
|
||||||
public BigDecimal calculateTotalDeposits(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalDeposits(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isDepositAndNotReversed() || transaction.isDividendPayoutAndNotReversed()) {
|
if (transaction.isDepositAndNotReversed() || transaction.isDividendPayoutAndNotReversed()) {
|
||||||
@@ -42,7 +42,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalWithdrawals(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalWithdrawals(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isWithdrawal() && transaction.isNotReversed()) {
|
if (transaction.isWithdrawal() && transaction.isNotReversed()) {
|
||||||
@@ -52,7 +52,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalInterestPosted(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalInterestPosted(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isInterestPostingAndNotReversed() && transaction.isNotReversed()) {
|
if (transaction.isInterestPostingAndNotReversed() && transaction.isNotReversed()) {
|
||||||
@@ -62,7 +62,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalWithdrawalFees(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalWithdrawalFees(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isWithdrawalFeeAndNotReversed() && transaction.isNotReversed()) {
|
if (transaction.isWithdrawalFeeAndNotReversed() && transaction.isNotReversed()) {
|
||||||
@@ -72,7 +72,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalAnnualFees(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalAnnualFees(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isAnnualFeeAndNotReversed() && transaction.isNotReversed()) {
|
if (transaction.isAnnualFeeAndNotReversed() && transaction.isNotReversed()) {
|
||||||
@@ -82,7 +82,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalFeesCharge(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalFeesCharge(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isFeeChargeAndNotReversed()) {
|
if (transaction.isFeeChargeAndNotReversed()) {
|
||||||
@@ -92,7 +92,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalFeesChargeWaived(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalFeesChargeWaived(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isWaiveFeeChargeAndNotReversed()) {
|
if (transaction.isWaiveFeeChargeAndNotReversed()) {
|
||||||
@@ -102,7 +102,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalPenaltyCharge(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalPenaltyCharge(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isPenaltyChargeAndNotReversed()) {
|
if (transaction.isPenaltyChargeAndNotReversed()) {
|
||||||
@@ -112,7 +112,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalPenaltyChargeWaived(final MonetaryCurrency currency, final List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalPenaltyChargeWaived(final MonetaryCurrency currency, final Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isWaivePenaltyChargeAndNotReversed()) {
|
if (transaction.isWaivePenaltyChargeAndNotReversed()) {
|
||||||
@@ -122,7 +122,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BigDecimal calculateTotalOverdraftInterest(MonetaryCurrency currency, List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalOverdraftInterest(MonetaryCurrency currency, Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isOverdraftInterestAndNotReversed()) {
|
if (transaction.isOverdraftInterestAndNotReversed()) {
|
||||||
@@ -131,7 +131,7 @@ public final class SavingsAccountTransactionSummaryWrapper {
|
|||||||
}
|
}
|
||||||
return total.getAmountDefaultedToNullIfZero();
|
return total.getAmountDefaultedToNullIfZero();
|
||||||
}
|
}
|
||||||
public BigDecimal calculateTotalWithholdTaxWithdrawal(MonetaryCurrency currency, List<SavingsAccountTransaction> transactions) {
|
public BigDecimal calculateTotalWithholdTaxWithdrawal(MonetaryCurrency currency, Set<SavingsAccountTransaction> transactions) {
|
||||||
Money total = Money.zero(currency);
|
Money total = Money.zero(currency);
|
||||||
for (final SavingsAccountTransaction transaction : transactions) {
|
for (final SavingsAccountTransaction transaction : transactions) {
|
||||||
if (transaction.isWithHoldTaxAndNotReversed()) {
|
if (transaction.isWithHoldTaxAndNotReversed()) {
|
||||||
|
|||||||
+3
-3
@@ -918,7 +918,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
final SavingsAccountTransaction newTransferTransaction = SavingsAccountTransaction.initiateTransfer(savingsAccount,
|
final SavingsAccountTransaction newTransferTransaction = SavingsAccountTransaction.initiateTransfer(savingsAccount,
|
||||||
savingsAccount.office(), transferDate, user);
|
savingsAccount.office(), transferDate, user);
|
||||||
savingsAccount.getTransactions().add(newTransferTransaction);
|
savingsAccount.addTransaction(newTransferTransaction);
|
||||||
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
@@ -951,7 +951,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
final SavingsAccountTransaction withdrawtransferTransaction = SavingsAccountTransaction.withdrawTransfer(savingsAccount,
|
final SavingsAccountTransaction withdrawtransferTransaction = SavingsAccountTransaction.withdrawTransfer(savingsAccount,
|
||||||
savingsAccount.office(), transferDate, user);
|
savingsAccount.office(), transferDate, user);
|
||||||
savingsAccount.getTransactions().add(withdrawtransferTransaction);
|
savingsAccount.addTransaction(withdrawtransferTransaction);
|
||||||
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
@@ -991,7 +991,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
|||||||
|
|
||||||
final SavingsAccountTransaction acceptTransferTransaction = SavingsAccountTransaction.approveTransfer(savingsAccount,
|
final SavingsAccountTransaction acceptTransferTransaction = SavingsAccountTransaction.approveTransfer(savingsAccount,
|
||||||
acceptedInOffice, transferDate, user);
|
acceptedInOffice, transferDate, user);
|
||||||
savingsAccount.getTransactions().add(acceptTransferTransaction);
|
savingsAccount.addTransaction(acceptTransferTransaction);
|
||||||
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
||||||
if (fieldOfficer != null) {
|
if (fieldOfficer != null) {
|
||||||
savingsAccount.reassignSavingsOfficer(fieldOfficer, transferDate);
|
savingsAccount.reassignSavingsOfficer(fieldOfficer, transferDate);
|
||||||
|
|||||||
+22
-22
@@ -18,6 +18,25 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.savings.service;
|
package org.apache.fineract.portfolio.savings.service;
|
||||||
|
|
||||||
|
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME;
|
||||||
|
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
||||||
|
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.amountParamName;
|
||||||
|
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.chargeIdParamName;
|
||||||
|
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.dueAsOfDateParamName;
|
||||||
|
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.withHoldTaxParamName;
|
||||||
|
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.withdrawBalanceParamName;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.MathContext;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService;
|
import org.apache.fineract.accounting.journalentry.service.JournalEntryWritePlatformService;
|
||||||
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
|
||||||
@@ -88,25 +107,6 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.math.MathContext;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME;
|
|
||||||
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME;
|
|
||||||
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.amountParamName;
|
|
||||||
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.chargeIdParamName;
|
|
||||||
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.dueAsOfDateParamName;
|
|
||||||
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.withdrawBalanceParamName;
|
|
||||||
import static org.apache.fineract.portfolio.savings.SavingsApiConstants.withHoldTaxParamName;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements SavingsAccountWritePlatformService {
|
public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements SavingsAccountWritePlatformService {
|
||||||
|
|
||||||
@@ -673,7 +673,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
final SavingsAccountTransaction newTransferTransaction = SavingsAccountTransaction.initiateTransfer(savingsAccount,
|
final SavingsAccountTransaction newTransferTransaction = SavingsAccountTransaction.initiateTransfer(savingsAccount,
|
||||||
savingsAccount.office(), transferDate, user);
|
savingsAccount.office(), transferDate, user);
|
||||||
savingsAccount.getTransactions().add(newTransferTransaction);
|
savingsAccount.addTransaction(newTransferTransaction);
|
||||||
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.TRANSFER_IN_PROGRESS.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
@@ -705,7 +705,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
final SavingsAccountTransaction withdrawtransferTransaction = SavingsAccountTransaction.withdrawTransfer(savingsAccount,
|
final SavingsAccountTransaction withdrawtransferTransaction = SavingsAccountTransaction.withdrawTransfer(savingsAccount,
|
||||||
savingsAccount.office(), transferDate, user);
|
savingsAccount.office(), transferDate, user);
|
||||||
savingsAccount.getTransactions().add(withdrawtransferTransaction);
|
savingsAccount.addTransaction(withdrawtransferTransaction);
|
||||||
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
||||||
final MathContext mc = MathContext.DECIMAL64;
|
final MathContext mc = MathContext.DECIMAL64;
|
||||||
boolean isInterestTransfer = false;
|
boolean isInterestTransfer = false;
|
||||||
@@ -745,7 +745,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
|||||||
|
|
||||||
final SavingsAccountTransaction acceptTransferTransaction = SavingsAccountTransaction.approveTransfer(savingsAccount,
|
final SavingsAccountTransaction acceptTransferTransaction = SavingsAccountTransaction.approveTransfer(savingsAccount,
|
||||||
acceptedInOffice, transferDate, user);
|
acceptedInOffice, transferDate, user);
|
||||||
savingsAccount.getTransactions().add(acceptTransferTransaction);
|
savingsAccount.addTransaction(acceptTransferTransaction);
|
||||||
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
savingsAccount.setStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
||||||
if (fieldOfficer != null) {
|
if (fieldOfficer != null) {
|
||||||
savingsAccount.reassignSavingsOfficer(fieldOfficer, transferDate);
|
savingsAccount.reassignSavingsOfficer(fieldOfficer, transferDate);
|
||||||
|
|||||||
+3
-6
@@ -28,6 +28,7 @@ import javax.persistence.Embedded;
|
|||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.EnumType;
|
import javax.persistence.EnumType;
|
||||||
import javax.persistence.Enumerated;
|
import javax.persistence.Enumerated;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -44,8 +45,6 @@ import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
|||||||
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
|
||||||
import org.apache.fineract.portfolio.shareproducts.domain.ShareProduct;
|
import org.apache.fineract.portfolio.shareproducts.domain.ShareProduct;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -133,8 +132,7 @@ public class ShareAccount extends AbstractPersistable<Long> {
|
|||||||
@JoinColumn(name = "savings_account_id", nullable = true)
|
@JoinColumn(name = "savings_account_id", nullable = true)
|
||||||
private SavingsAccount savingsAccount;
|
private SavingsAccount savingsAccount;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true)
|
|
||||||
private Set<ShareAccountTransaction> shareAccountTransactions;
|
private Set<ShareAccountTransaction> shareAccountTransactions;
|
||||||
|
|
||||||
@Column(name = "lockin_period_frequency")
|
@Column(name = "lockin_period_frequency")
|
||||||
@@ -151,8 +149,7 @@ public class ShareAccount extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "minimum_active_period_frequency_enum", nullable = true)
|
@Column(name = "minimum_active_period_frequency_enum", nullable = true)
|
||||||
private PeriodFrequencyType minimumActivePeriodFrequencyType;
|
private PeriodFrequencyType minimumActivePeriodFrequencyType;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true)
|
|
||||||
private Set<ShareAccountCharge> charges;
|
private Set<ShareAccountCharge> charges;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
|
|||||||
+2
-4
@@ -26,6 +26,7 @@ import java.util.Set;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -33,8 +34,6 @@ import javax.persistence.Table;
|
|||||||
import javax.persistence.Temporal;
|
import javax.persistence.Temporal;
|
||||||
import javax.persistence.TemporalType;
|
import javax.persistence.TemporalType;
|
||||||
|
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -73,8 +72,7 @@ public class ShareAccountTransaction extends AbstractPersistable<Long> {
|
|||||||
@Column(name = "is_active", nullable = false)
|
@Column(name = "is_active", nullable = false)
|
||||||
private boolean active = true ;
|
private boolean active = true ;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccountTransaction", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccountTransaction", orphanRemoval = true)
|
|
||||||
private final Set<ShareAccountChargePaidBy> shareAccountChargesPaid = new HashSet<>();
|
private final Set<ShareAccountChargePaidBy> shareAccountChargesPaid = new HashSet<>();
|
||||||
|
|
||||||
protected ShareAccountTransaction() {
|
protected ShareAccountTransaction() {
|
||||||
|
|||||||
+1
-4
@@ -46,8 +46,6 @@ import org.apache.fineract.portfolio.charge.domain.Charge;
|
|||||||
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
||||||
import org.apache.fineract.portfolio.shareproducts.data.ShareProductMarketPriceData;
|
import org.apache.fineract.portfolio.shareproducts.data.ShareProductMarketPriceData;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -102,8 +100,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
private Long maximumShares;
|
private Long maximumShares;
|
||||||
|
|
||||||
@OrderBy(value = "fromDate,id")
|
@OrderBy(value = "fromDate,id")
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product", orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "product", orphanRemoval = true)
|
|
||||||
Set<ShareProductMarketPrice> marketPrice;
|
Set<ShareProductMarketPrice> marketPrice;
|
||||||
|
|
||||||
@ManyToMany(fetch = FetchType.EAGER)
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
|
|||||||
+2
-4
@@ -26,6 +26,7 @@ import java.util.List;
|
|||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
@@ -35,8 +36,6 @@ import javax.persistence.TemporalType;
|
|||||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
||||||
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccountDividendDetails;
|
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccountDividendDetails;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -60,8 +59,7 @@ public class ShareProductDividendPayOutDetails extends AbstractAuditableCustom<A
|
|||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
@JoinColumn(name = "dividend_pay_out_id", referencedColumnName = "id", nullable = false)
|
@JoinColumn(name = "dividend_pay_out_id", referencedColumnName = "id", nullable = false)
|
||||||
private List<ShareAccountDividendDetails> accountDividendDetails = new ArrayList<>();
|
private List<ShareAccountDividendDetails> accountDividendDetails = new ArrayList<>();
|
||||||
|
|
||||||
|
|||||||
+9
-10
@@ -23,12 +23,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.ManyToOne;
|
import javax.persistence.ManyToOne;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
@@ -44,8 +47,6 @@ import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
|||||||
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
import org.apache.fineract.infrastructure.core.service.DateUtils;
|
||||||
import org.apache.fineract.portfolio.tax.api.TaxApiConstants;
|
import org.apache.fineract.portfolio.tax.api.TaxApiConstants;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@@ -76,14 +77,12 @@ public class TaxComponent extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Temporal(TemporalType.DATE)
|
@Temporal(TemporalType.DATE)
|
||||||
private Date startDate;
|
private Date startDate;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
@JoinColumn(name = "tax_component_id", referencedColumnName = "id", nullable = false)
|
@JoinColumn(name = "tax_component_id", referencedColumnName = "id", nullable = false)
|
||||||
private List<TaxComponentHistory> taxComponentHistories = new ArrayList<>();
|
private Set<TaxComponentHistory> taxComponentHistories = new HashSet<>();
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.TRUE)
|
@OneToMany(cascade = CascadeType.DETACH, mappedBy = "taxComponent", orphanRemoval = false, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.DETACH, mappedBy = "taxComponent", orphanRemoval = false)
|
private Set<TaxGroupMappings> taxGroupMappings = new HashSet<>();
|
||||||
private List<TaxGroupMappings> taxGroupMappings = new ArrayList<>();
|
|
||||||
|
|
||||||
protected TaxComponent() {
|
protected TaxComponent() {
|
||||||
|
|
||||||
@@ -182,11 +181,11 @@ public class TaxComponent extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
return target != null && target.isAfter(startDate());
|
return target != null && target.isAfter(startDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaxComponentHistory> getTaxComponentHistories() {
|
public Set<TaxComponentHistory> getTaxComponentHistories() {
|
||||||
return this.taxComponentHistories;
|
return this.taxComponentHistories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaxGroupMappings> getTaxGroupMappings() {
|
public Set<TaxGroupMappings> getTaxGroupMappings() {
|
||||||
return this.taxGroupMappings;
|
return this.taxGroupMappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-9
@@ -20,12 +20,15 @@ package org.apache.fineract.portfolio.tax.domain;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.persistence.CascadeType;
|
import javax.persistence.CascadeType;
|
||||||
import javax.persistence.Column;
|
import javax.persistence.Column;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.FetchType;
|
||||||
import javax.persistence.JoinColumn;
|
import javax.persistence.JoinColumn;
|
||||||
import javax.persistence.OneToMany;
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
@@ -36,8 +39,6 @@ import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
|
|||||||
import org.apache.fineract.portfolio.tax.api.TaxApiConstants;
|
import org.apache.fineract.portfolio.tax.api.TaxApiConstants;
|
||||||
import org.apache.fineract.portfolio.tax.exception.TaxMappingNotFoundException;
|
import org.apache.fineract.portfolio.tax.exception.TaxMappingNotFoundException;
|
||||||
import org.apache.fineract.useradministration.domain.AppUser;
|
import org.apache.fineract.useradministration.domain.AppUser;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "m_tax_group")
|
@Table(name = "m_tax_group")
|
||||||
@@ -46,25 +47,24 @@ public class TaxGroup extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "name", length = 100)
|
@Column(name = "name", length = 100)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
@JoinColumn(name = "tax_group_id", referencedColumnName = "id", nullable = false)
|
@JoinColumn(name = "tax_group_id", referencedColumnName = "id", nullable = false)
|
||||||
private List<TaxGroupMappings> taxGroupMappings = new ArrayList<>();
|
private Set<TaxGroupMappings> taxGroupMappings = new HashSet<>();
|
||||||
|
|
||||||
protected TaxGroup() {
|
protected TaxGroup() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaxGroup(final String name, final List<TaxGroupMappings> taxGroupMappings) {
|
private TaxGroup(final String name, final Set<TaxGroupMappings> taxGroupMappings) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.taxGroupMappings = taxGroupMappings;
|
this.taxGroupMappings = taxGroupMappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TaxGroup createTaxGroup(final String name, final List<TaxGroupMappings> taxGroupMappings) {
|
public static TaxGroup createTaxGroup(final String name, final Set<TaxGroupMappings> taxGroupMappings) {
|
||||||
return new TaxGroup(name, taxGroupMappings);
|
return new TaxGroup(name, taxGroupMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> update(final JsonCommand command, final List<TaxGroupMappings> taxGroupMappings) {
|
public Map<String, Object> update(final JsonCommand command, final Set<TaxGroupMappings> taxGroupMappings) {
|
||||||
final Map<String, Object> changes = new HashMap<>();
|
final Map<String, Object> changes = new HashMap<>();
|
||||||
|
|
||||||
if (command.isChangeInStringParameterNamed(TaxApiConstants.nameParamName, this.name)) {
|
if (command.isChangeInStringParameterNamed(TaxApiConstants.nameParamName, this.name)) {
|
||||||
@@ -106,7 +106,7 @@ public class TaxGroup extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaxGroupMappings> getTaxGroupMappings() {
|
public Set<TaxGroupMappings> getTaxGroupMappings() {
|
||||||
return this.taxGroupMappings;
|
return this.taxGroupMappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -266,7 +266,7 @@ public class TaxValidator {
|
|||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateTaxGroupEndDateAndTaxComponent(final TaxGroup taxGroup, final List<TaxGroupMappings> groupMappings) {
|
public void validateTaxGroupEndDateAndTaxComponent(final TaxGroup taxGroup, final Set<TaxGroupMappings> groupMappings) {
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("tax.group");
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("tax.group");
|
||||||
|
|
||||||
@@ -293,7 +293,7 @@ public class TaxValidator {
|
|||||||
public void validateTaxGroup(final TaxGroup taxGroup) {
|
public void validateTaxGroup(final TaxGroup taxGroup) {
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("tax.group");
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("tax.group");
|
||||||
List<TaxGroupMappings> groupMappings = taxGroup.getTaxGroupMappings();
|
Set<TaxGroupMappings> groupMappings = taxGroup.getTaxGroupMappings();
|
||||||
validateGroupTotal(groupMappings, baseDataValidator, "total.percentage");
|
validateGroupTotal(groupMappings, baseDataValidator, "total.percentage");
|
||||||
validateOverlappingComponents(groupMappings, baseDataValidator);
|
validateOverlappingComponents(groupMappings, baseDataValidator);
|
||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
@@ -318,7 +318,7 @@ public class TaxValidator {
|
|||||||
baseDataValidator.reset().parameter(TaxApiConstants.startDateParamName).value(startDate).validateDateAfter(existingStartDate);
|
baseDataValidator.reset().parameter(TaxApiConstants.startDateParamName).value(startDate).validateDateAfter(existingStartDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateOverlappingComponents(final List<TaxGroupMappings> taxMappings, final DataValidatorBuilder baseDataValidator) {
|
private void validateOverlappingComponents(final Set<TaxGroupMappings> taxMappings, final DataValidatorBuilder baseDataValidator) {
|
||||||
for (TaxGroupMappings groupMappingsOne : taxMappings) {
|
for (TaxGroupMappings groupMappingsOne : taxMappings) {
|
||||||
final List<TaxGroupMappings> mappings = new ArrayList<>(taxMappings);
|
final List<TaxGroupMappings> mappings = new ArrayList<>(taxMappings);
|
||||||
mappings.remove(groupMappingsOne);
|
mappings.remove(groupMappingsOne);
|
||||||
@@ -338,7 +338,7 @@ public class TaxValidator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateGroupTotal(final List<TaxGroupMappings> taxMappings, final DataValidatorBuilder baseDataValidator,
|
private void validateGroupTotal(final Set<TaxGroupMappings> taxMappings, final DataValidatorBuilder baseDataValidator,
|
||||||
final String paramenter) {
|
final String paramenter) {
|
||||||
for (TaxGroupMappings groupMappingsOne : taxMappings) {
|
for (TaxGroupMappings groupMappingsOne : taxMappings) {
|
||||||
Collection<LocalDate> dates = groupMappingsOne.getTaxComponent().allStartDates();
|
Collection<LocalDate> dates = groupMappingsOne.getTaxComponent().allStartDates();
|
||||||
|
|||||||
+5
-3
@@ -20,8 +20,10 @@ package org.apache.fineract.portfolio.tax.service;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
|
import org.apache.fineract.accounting.glaccount.domain.GLAccount;
|
||||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
|
import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
|
||||||
@@ -114,12 +116,12 @@ public class TaxAssembler {
|
|||||||
|
|
||||||
final String name = this.fromApiJsonHelper.extractStringNamed(TaxApiConstants.nameParamName, element);
|
final String name = this.fromApiJsonHelper.extractStringNamed(TaxApiConstants.nameParamName, element);
|
||||||
boolean isUpdate = false;
|
boolean isUpdate = false;
|
||||||
final List<TaxGroupMappings> groupMappings = assembleTaxGroupMappingsFrom(command, isUpdate);
|
final Set<TaxGroupMappings> groupMappings = assembleTaxGroupMappingsFrom(command, isUpdate);
|
||||||
return TaxGroup.createTaxGroup(name, groupMappings);
|
return TaxGroup.createTaxGroup(name, groupMappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TaxGroupMappings> assembleTaxGroupMappingsFrom(final JsonCommand command, boolean isUpdate) {
|
public Set<TaxGroupMappings> assembleTaxGroupMappingsFrom(final JsonCommand command, boolean isUpdate) {
|
||||||
List<TaxGroupMappings> groupMappings = new ArrayList<>();
|
Set<TaxGroupMappings> groupMappings = new HashSet<>();
|
||||||
final JsonElement element = command.parsedJson();
|
final JsonElement element = command.parsedJson();
|
||||||
|
|
||||||
final JsonObject topLevelJsonElement = element.getAsJsonObject();
|
final JsonObject topLevelJsonElement = element.getAsJsonObject();
|
||||||
|
|||||||
+3
-2
@@ -22,6 +22,7 @@ import java.math.BigDecimal;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
|
import org.apache.fineract.organisation.monetary.domain.MoneyHelper;
|
||||||
import org.apache.fineract.portfolio.tax.domain.TaxComponent;
|
import org.apache.fineract.portfolio.tax.domain.TaxComponent;
|
||||||
@@ -31,7 +32,7 @@ import org.joda.time.LocalDate;
|
|||||||
public class TaxUtils {
|
public class TaxUtils {
|
||||||
|
|
||||||
public static Map<TaxComponent, BigDecimal> splitTax(final BigDecimal amount, final LocalDate date,
|
public static Map<TaxComponent, BigDecimal> splitTax(final BigDecimal amount, final LocalDate date,
|
||||||
final List<TaxGroupMappings> taxGroupMappings, final int scale) {
|
final Set<TaxGroupMappings> taxGroupMappings, final int scale) {
|
||||||
Map<TaxComponent, BigDecimal> map = new HashMap<>(3);
|
Map<TaxComponent, BigDecimal> map = new HashMap<>(3);
|
||||||
if (amount != null) {
|
if (amount != null) {
|
||||||
final double amountVal = amount.doubleValue();
|
final double amountVal = amount.doubleValue();
|
||||||
@@ -51,7 +52,7 @@ public class TaxUtils {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BigDecimal incomeAmount(final BigDecimal amount, final LocalDate date, final List<TaxGroupMappings> taxGroupMappings,
|
public static BigDecimal incomeAmount(final BigDecimal amount, final LocalDate date, final Set<TaxGroupMappings> taxGroupMappings,
|
||||||
final int scale) {
|
final int scale) {
|
||||||
Map<TaxComponent, BigDecimal> map = splitTax(amount, date, taxGroupMappings, scale);
|
Map<TaxComponent, BigDecimal> map = splitTax(amount, date, taxGroupMappings, scale);
|
||||||
return incomeAmount(amount, map);
|
return incomeAmount(amount, map);
|
||||||
|
|||||||
+2
-2
@@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.tax.service;
|
package org.apache.fineract.portfolio.tax.service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
import org.apache.fineract.infrastructure.core.api.JsonCommand;
|
||||||
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
|
||||||
@@ -98,7 +98,7 @@ public class TaxWritePlatformServiceImpl implements TaxWritePlatformService {
|
|||||||
this.validator.validateForTaxGroupUpdate(command.json());
|
this.validator.validateForTaxGroupUpdate(command.json());
|
||||||
final TaxGroup taxGroup = this.taxGroupRepositoryWrapper.findOneWithNotFoundDetection(id);
|
final TaxGroup taxGroup = this.taxGroupRepositoryWrapper.findOneWithNotFoundDetection(id);
|
||||||
final boolean isUpdate = true;
|
final boolean isUpdate = true;
|
||||||
List<TaxGroupMappings> groupMappings = this.taxAssembler.assembleTaxGroupMappingsFrom(command, isUpdate);
|
Set<TaxGroupMappings> groupMappings = this.taxAssembler.assembleTaxGroupMappingsFrom(command, isUpdate);
|
||||||
this.validator.validateTaxGroupEndDateAndTaxComponent(taxGroup, groupMappings);
|
this.validator.validateTaxGroupEndDateAndTaxComponent(taxGroup, groupMappings);
|
||||||
Map<String, Object> changes = taxGroup.update(command, groupMappings);
|
Map<String, Object> changes = taxGroup.update(command, groupMappings);
|
||||||
this.validator.validateTaxGroup(taxGroup);
|
this.validator.validateTaxGroup(taxGroup);
|
||||||
|
|||||||
+1
-4
@@ -52,8 +52,6 @@ import org.apache.fineract.organisation.office.domain.Office;
|
|||||||
import org.apache.fineract.organisation.staff.domain.Staff;
|
import org.apache.fineract.organisation.staff.domain.Staff;
|
||||||
import org.apache.fineract.portfolio.client.domain.Client;
|
import org.apache.fineract.portfolio.client.domain.Client;
|
||||||
import org.apache.fineract.useradministration.service.AppUserConstants;
|
import org.apache.fineract.useradministration.service.AppUserConstants;
|
||||||
import org.hibernate.annotations.LazyCollection;
|
|
||||||
import org.hibernate.annotations.LazyCollectionOption;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.jpa.domain.AbstractPersistable;
|
import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||||
@@ -122,8 +120,7 @@ public class AppUser extends AbstractPersistable<Long> implements PlatformUser {
|
|||||||
@Column(name = "is_self_service_user", nullable = false)
|
@Column(name = "is_self_service_user", nullable = false)
|
||||||
private boolean isSelfServiceUser;
|
private boolean isSelfServiceUser;
|
||||||
|
|
||||||
@LazyCollection(LazyCollectionOption.FALSE)
|
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch=FetchType.EAGER)
|
||||||
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
@JoinColumn(name = "appuser_id", referencedColumnName= "id", nullable = false)
|
@JoinColumn(name = "appuser_id", referencedColumnName= "id", nullable = false)
|
||||||
private Set<AppUserClientMapping> appUserClientMappings = new HashSet<>();
|
private Set<AppUserClientMapping> appUserClientMappings = new HashSet<>();
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.fineract.portfolio.loanaccount;
|
package org.apache.fineract.portfolio.loanaccount;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
|
||||||
import org.apache.fineract.organisation.monetary.domain.Money;
|
import org.apache.fineract.organisation.monetary.domain.Money;
|
||||||
@@ -49,7 +49,7 @@ public class LoanRepaymentScheduleInstallmentBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LoanRepaymentScheduleInstallment build() {
|
public LoanRepaymentScheduleInstallment build() {
|
||||||
final List<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
final Set<LoanInterestRecalcualtionAdditionalDetails> compoundingDetails = null;
|
||||||
final LoanRepaymentScheduleInstallment installment = new LoanRepaymentScheduleInstallment(this.loan, this.installmentNumber,
|
final LoanRepaymentScheduleInstallment installment = new LoanRepaymentScheduleInstallment(this.loan, this.installmentNumber,
|
||||||
this.fromDate, this.dueDate, this.principal.getAmount(), this.interest.getAmount(), this.feeCharges.getAmount(),
|
this.fromDate, this.dueDate, this.principal.getAmount(), this.interest.getAmount(), this.feeCharges.getAmount(),
|
||||||
this.penaltyCharges.getAmount(), this.recalculatedInterestComponent, compoundingDetails);
|
this.penaltyCharges.getAmount(), this.recalculatedInterestComponent, compoundingDetails);
|
||||||
|
|||||||
Reference in New Issue
Block a user