diff --git a/mifosng-provider/build.gradle b/mifosng-provider/build.gradle index accab7872..1c3270cb8 100644 --- a/mifosng-provider/build.gradle +++ b/mifosng-provider/build.gradle @@ -22,14 +22,11 @@ sourceCompatibility = JavaVersion.VERSION_1_6 /* define binary compatiblity version */ targetCompatibility = JavaVersion.VERSION_1_6 -// targetCompatibility = 1.6 -// sourceCompatibility = 1.6 - -project.ext.springVersion = '3.1.1.RELEASE' -project.ext.springSecurityVersion = '3.1.0.RELEASE' -project.ext.hibernateValidatorVersion = '4.3.0.Final' -project.ext.hibernateCoreVersion = '4.1.3.Final' -project.ext.jerseyVersion = '1.13' +project.ext.springVersion = '3.1.3.RELEASE' +project.ext.springSecurityVersion = '3.1.3.RELEASE' +project.ext.hibernateValidatorVersion = '4.3.1.Final' +project.ext.hibernateCoreVersion = '4.1.8.Final' +project.ext.jerseyVersion = '1.16' project.ext.springDataJpaVersion = '1.0.3.RELEASE' repositories { @@ -63,7 +60,7 @@ configurations { } dependencies { - def tomcatVersion = '7.0.29' + def tomcatVersion = '7.0.33' tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}", "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}" tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") { @@ -111,8 +108,8 @@ dependencies { [group: 'ch.qos.logback', name: 'logback-core', version: '1.0.6'], [group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.6'], - [group: 'mysql', name: 'mysql-connector-java', version: '5.1.21'], - [group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.29'], + [group: 'mysql', name: 'mysql-connector-java', version: '5.1.22'], + [group: 'org.apache.tomcat', name: 'tomcat-jdbc', version: '7.0.33'], [group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-core', version: '3.8.3-GA'], [group: 'pentaho-reporting-engine', name: 'pentaho-reporting-engine-classic-extensions', version: '3.8.3-GA'], diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/MonetaryCurrency.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/MonetaryCurrency.java index eafe764df..85925062e 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/MonetaryCurrency.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/MonetaryCurrency.java @@ -1,12 +1,10 @@ package org.mifosplatform.infrastructure.configuration.domain; -import java.io.Serializable; - import javax.persistence.Column; import javax.persistence.Embeddable; @Embeddable -public class MonetaryCurrency implements Serializable { +public class MonetaryCurrency { @Column(name = "currency_code", length = 3, nullable = false) private final String code; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/Money.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/Money.java index adbd3a359..dd1abaf9c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/Money.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/configuration/domain/Money.java @@ -1,6 +1,5 @@ package org.mifosplatform.infrastructure.configuration.domain; -import java.io.Serializable; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Iterator; @@ -9,15 +8,15 @@ import javax.persistence.Column; import javax.persistence.Embeddable; @Embeddable -public class Money implements Comparable, Serializable { +public class Money implements Comparable { - @Column(name = "currency_code", length=3) - private final String currencyCode; + @Column(name = "currency_code", length = 3) + private final String currencyCode; @Column(name = "currency_digits") - private final int currencyDigitsAfterDecimal; + private final int currencyDigitsAfterDecimal; - @Column(name = "amount", scale=6, precision=19) + @Column(name = "amount", scale = 6, precision = 19) private final BigDecimal amount; public static Money total(final Money... monies) { @@ -38,13 +37,13 @@ public class Money implements Comparable, Serializable { } return total; } - - public static Money of(final MonetaryCurrency currency, final BigDecimal newAmount) { - return new Money(currency.getCode(), currency.getDigitsAfterDecimal(), defaultToZeroIfNull(newAmount)); - } - + + public static Money of(final MonetaryCurrency currency, final BigDecimal newAmount) { + return new Money(currency.getCode(), currency.getDigitsAfterDecimal(), defaultToZeroIfNull(newAmount)); + } + public static Money zero(final MonetaryCurrency currency) { - return new Money(currency.getCode(), currency.getDigitsAfterDecimal(), BigDecimal.ZERO); + return new Money(currency.getCode(), currency.getDigitsAfterDecimal(), BigDecimal.ZERO); } protected Money() { @@ -56,19 +55,19 @@ public class Money implements Comparable, Serializable { private Money(final String currencyCode, final int digitsAfterDecimal, final BigDecimal amount) { this.currencyCode = currencyCode; this.currencyDigitsAfterDecimal = digitsAfterDecimal; - + final BigDecimal amountZeroed = defaultToZeroIfNull(amount); BigDecimal amountStripped = amountZeroed.stripTrailingZeros(); this.amount = amountStripped.setScale(this.currencyDigitsAfterDecimal, RoundingMode.HALF_EVEN); } - + private static BigDecimal defaultToZeroIfNull(final BigDecimal value) { - BigDecimal result = BigDecimal.ZERO; - if (value != null) { - result = value; - } - return result; - } + BigDecimal result = BigDecimal.ZERO; + if (value != null) { + result = value; + } + return result; + } public Money copy() { return new Money(this.currencyCode, this.currencyDigitsAfterDecimal, this.amount.stripTrailingZeros()); @@ -83,7 +82,7 @@ public class Money implements Comparable, Serializable { return Money.of(monetaryCurrency(), total); } - public Money plus(final Money moneyToAdd) { + public Money plus(final Money moneyToAdd) { Money toAdd = this.checkCurrencyEqual(moneyToAdd); return this.plus(toAdd.getAmount()); } @@ -170,9 +169,8 @@ public class Money implements Comparable, Serializable { @Override public int compareTo(final Money other) { Money otherMoney = other; - if (this.currencyCode.equals(otherMoney.currencyCode) == false) { - throw new UnsupportedOperationException("currencies arent different"); - } + if (this.currencyCode.equals(otherMoney.currencyCode) == false) { throw new UnsupportedOperationException( + "currencies arent different"); } return this.amount.compareTo(otherMoney.amount); } @@ -183,7 +181,7 @@ public class Money implements Comparable, Serializable { public boolean isEqualTo(final Money other) { return this.compareTo(other) == 0; } - + public boolean isNotEqualTo(final Money other) { return !isEqualTo(other); } @@ -222,17 +220,11 @@ public class Money implements Comparable, Serializable { @Override public String toString() { - return new StringBuilder() - .append(this.currencyCode) - .append(' ') - .append(this.amount.toPlainString()) - .toString(); + return new StringBuilder().append(this.currencyCode).append(' ').append(this.amount.toPlainString()).toString(); } public Money negated() { - if (this.isZero()) { - return this; - } + if (this.isZero()) { return this; } return Money.of(monetaryCurrency(), this.amount.negate()); } @@ -240,11 +232,11 @@ public class Money implements Comparable, Serializable { return this.isLessThanZero() ? this.negated() : this; } - public MonetaryCurrency getCurrency() { - return monetaryCurrency(); - } - + public MonetaryCurrency getCurrency() { + return monetaryCurrency(); + } + private MonetaryCurrency monetaryCurrency() { - return new MonetaryCurrency(this.currencyCode, this.currencyDigitsAfterDecimal); - } + return new MonetaryCurrency(this.currencyCode, this.currencyDigitsAfterDecimal); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java index a1e7ba9fb..03622b93f 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java @@ -7,8 +7,6 @@ import java.util.Set; import org.mifosng.platform.api.data.DepositAccountData; import org.mifosng.platform.api.data.DepositProductData; -import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; -import org.mifosng.platform.api.data.GroupData; import org.mifosng.platform.api.data.SavingAccountData; import org.mifosng.platform.api.data.SavingProductData; import org.mifosplatform.commands.api.data.CommandSourceData; @@ -33,6 +31,8 @@ import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.client.data.ClientIdentifierData; import org.mifosplatform.portfolio.client.data.NoteData; import org.mifosplatform.portfolio.fund.data.FundData; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData; +import org.mifosplatform.portfolio.group.data.GroupData; import org.mifosplatform.portfolio.loanaccount.data.LoanAccountData; import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData; import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionService.java index 873f0a831..8fb46776c 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionService.java @@ -6,7 +6,6 @@ import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand; import org.mifosng.platform.api.commands.DepositProductCommand; import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand; import org.mifosng.platform.api.commands.DepositStateTransitionCommand; -import org.mifosng.platform.api.commands.GroupCommand; import org.mifosng.platform.api.commands.SavingAccountCommand; import org.mifosng.platform.api.commands.SavingProductCommand; import org.mifosplatform.infrastructure.codes.command.CodeCommand; @@ -25,6 +24,7 @@ import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; import org.mifosplatform.portfolio.client.command.NoteCommand; import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.fund.command.FundCommand; +import org.mifosplatform.portfolio.group.command.GroupCommand; import org.mifosplatform.portfolio.loanaccount.command.AdjustLoanTransactionCommand; import org.mifosplatform.portfolio.loanaccount.command.LoanApplicationCommand; import org.mifosplatform.portfolio.loanaccount.command.LoanChargeCommand; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java index 74fad5af5..305f43f26 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java @@ -23,7 +23,6 @@ import org.mifosng.platform.api.commands.DepositAccountWithdrawalCommand; import org.mifosng.platform.api.commands.DepositProductCommand; import org.mifosng.platform.api.commands.DepositStateTransitionApprovalCommand; import org.mifosng.platform.api.commands.DepositStateTransitionCommand; -import org.mifosng.platform.api.commands.GroupCommand; import org.mifosng.platform.api.commands.SavingAccountCommand; import org.mifosng.platform.api.commands.SavingProductCommand; import org.mifosplatform.infrastructure.codes.command.CodeCommand; @@ -46,6 +45,7 @@ import org.mifosplatform.portfolio.client.command.ClientIdentifierCommand; import org.mifosplatform.portfolio.client.command.NoteCommand; import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.fund.command.FundCommand; +import org.mifosplatform.portfolio.group.command.GroupCommand; import org.mifosplatform.portfolio.loanaccount.command.AdjustLoanTransactionCommand; import org.mifosplatform.portfolio.loanaccount.command.LoanApplicationCommand; import org.mifosplatform.portfolio.loanaccount.command.LoanChargeCommand; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiJsonSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiJsonSerializerService.java index fcac8bc72..b6bc02c6a 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiJsonSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiJsonSerializerService.java @@ -5,8 +5,6 @@ import java.util.Set; import org.mifosng.platform.api.data.DepositAccountData; import org.mifosng.platform.api.data.DepositProductData; -import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; -import org.mifosng.platform.api.data.GroupData; import org.mifosng.platform.api.data.SavingAccountData; import org.mifosng.platform.api.data.SavingProductData; import org.mifosplatform.commands.api.data.CommandSourceData; @@ -31,6 +29,8 @@ import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.client.data.ClientIdentifierData; import org.mifosplatform.portfolio.client.data.NoteData; import org.mifosplatform.portfolio.fund.data.FundData; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData; +import org.mifosplatform.portfolio.group.data.GroupData; import org.mifosplatform.portfolio.loanaccount.data.LoanAccountData; import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData; import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/StaffAccountSummaryCollectionData.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/StaffAccountSummaryCollectionData.java index b38d446f8..d75f219f0 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/StaffAccountSummaryCollectionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/data/StaffAccountSummaryCollectionData.java @@ -3,8 +3,8 @@ package org.mifosplatform.infrastructure.staff.data; import java.util.Collection; import java.util.List; -import org.mifosng.platform.api.data.GroupAccountSummaryData; import org.mifosplatform.portfolio.client.data.ClientAccountSummaryData; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData; /** * diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java index 612820264..afe391aff 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/staff/service/StaffReadPlatformServiceImpl.java @@ -6,8 +6,6 @@ import java.util.Collection; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.GroupAccountSummaryData; -import org.mifosng.platform.group.service.GroupReadPlatformService; import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; @@ -16,6 +14,8 @@ import org.mifosplatform.infrastructure.staff.data.StaffData; import org.mifosplatform.infrastructure.staff.exception.StaffNotFoundException; import org.mifosplatform.portfolio.client.data.ClientAccountSummaryData; import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData; +import org.mifosplatform.portfolio.group.service.GroupReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java index bc02d9f6c..f138268db 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/api/ClientsApiResource.java @@ -56,9 +56,6 @@ import com.sun.jersey.core.header.FormDataContentDisposition; import com.sun.jersey.multipart.FormDataBodyPart; import com.sun.jersey.multipart.FormDataParam; -/** - * test commit. again. - */ @Path("/clients") @Component @Scope("singleton") diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/GroupsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java similarity index 96% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/GroupsApiResource.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java index e84e8c7f4..51277b360 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/GroupsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/api/GroupsApiResource.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api; +package org.mifosplatform.portfolio.group.api; import java.util.Arrays; import java.util.Collection; @@ -20,11 +20,6 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.commands.GroupCommand; -import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; -import org.mifosng.platform.api.data.GroupData; -import org.mifosng.platform.group.service.GroupReadPlatformService; -import org.mifosng.platform.group.service.GroupWritePlatformService; import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService; import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; @@ -34,6 +29,11 @@ import org.mifosplatform.infrastructure.office.service.OfficeReadPlatformService import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.client.data.ClientLookup; import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; +import org.mifosplatform.portfolio.group.command.GroupCommand; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData; +import org.mifosplatform.portfolio.group.data.GroupData; +import org.mifosplatform.portfolio.group.service.GroupReadPlatformService; +import org.mifosplatform.portfolio.group.service.GroupWritePlatformService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/GroupCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommand.java similarity index 96% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/commands/GroupCommand.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommand.java index 9527121c7..e24aa6ceb 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/commands/GroupCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommand.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.commands; +package org.mifosplatform.portfolio.group.command; import java.util.Set; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupCommandValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommandValidator.java similarity index 96% rename from mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupCommandValidator.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommandValidator.java index a6391aa34..88f827173 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupCommandValidator.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/command/GroupCommandValidator.java @@ -1,9 +1,8 @@ -package org.mifosng.platform.group.service; +package org.mifosplatform.portfolio.group.command; import java.util.ArrayList; import java.util.List; -import org.mifosng.platform.api.commands.GroupCommand; import org.mifosplatform.infrastructure.core.data.ApiParameterError; import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder; import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupAccountSummaryCollectionData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupAccountSummaryCollectionData.java similarity index 97% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupAccountSummaryCollectionData.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupAccountSummaryCollectionData.java index 22a901c41..25cf0f01e 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupAccountSummaryCollectionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupAccountSummaryCollectionData.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.portfolio.group.data; import java.util.List; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupAccountSummaryData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupAccountSummaryData.java similarity index 95% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupAccountSummaryData.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupAccountSummaryData.java index 8382a81e5..efdf2e4a4 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupAccountSummaryData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupAccountSummaryData.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.portfolio.group.data; /** * Immutable data object for group loan accounts. diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupData.java similarity index 97% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupData.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupData.java index 1b5c576ee..3076bfac0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/GroupData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/data/GroupData.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api.data; +package org.mifosplatform.portfolio.group.data; import java.util.Collection; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/Group.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/Group.java similarity index 96% rename from mifosng-provider/src/main/java/org/mifosng/platform/group/domain/Group.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/Group.java index f0dc828e0..103c48557 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/Group.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/Group.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.group.domain; +package org.mifosplatform.portfolio.group.domain; import java.util.HashSet; import java.util.Set; @@ -12,11 +12,11 @@ import javax.persistence.ManyToOne; import javax.persistence.Table; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.commands.GroupCommand; import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; import org.mifosplatform.infrastructure.office.domain.Office; import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.client.domain.Client; +import org.mifosplatform.portfolio.group.command.GroupCommand; @Entity @Table(name = "m_group") diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/GroupRepository.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupRepository.java similarity index 84% rename from mifosng-provider/src/main/java/org/mifosng/platform/group/domain/GroupRepository.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupRepository.java index 086947a66..294720e27 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/domain/GroupRepository.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/domain/GroupRepository.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.group.domain; +package org.mifosplatform.portfolio.group.domain; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GroupNotFoundException.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/exception/GroupNotFoundException.java similarity index 88% rename from mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GroupNotFoundException.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/exception/GroupNotFoundException.java index 3a7c57742..e171b4778 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/exceptions/GroupNotFoundException.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/exception/GroupNotFoundException.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.exceptions; +package org.mifosplatform.portfolio.group.exception; import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformService.java similarity index 68% rename from mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformService.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformService.java index 9c13d660f..a51430815 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformService.java @@ -1,11 +1,11 @@ -package org.mifosng.platform.group.service; +package org.mifosplatform.portfolio.group.service; import java.util.Collection; -import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; -import org.mifosng.platform.api.data.GroupAccountSummaryData; -import org.mifosng.platform.api.data.GroupData; import org.mifosplatform.portfolio.client.data.ClientLookup; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData; +import org.mifosplatform.portfolio.group.data.GroupData; public interface GroupReadPlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java similarity index 96% rename from mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformServiceImpl.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java index 406086ecf..e6d2daa75 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupReadPlatformServiceImpl.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.group.service; +package org.mifosplatform.portfolio.group.service; import java.sql.ResultSet; import java.sql.SQLException; @@ -7,10 +7,6 @@ import java.util.Collection; import java.util.List; import org.apache.commons.lang.StringUtils; -import org.mifosng.platform.api.data.GroupAccountSummaryCollectionData; -import org.mifosng.platform.api.data.GroupAccountSummaryData; -import org.mifosng.platform.api.data.GroupData; -import org.mifosng.platform.exceptions.GroupNotFoundException; import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.office.data.OfficeLookup; @@ -19,6 +15,10 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext import org.mifosplatform.portfolio.client.data.ClientLookup; import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.mifosplatform.portfolio.client.service.LoanStatusMapper; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryCollectionData; +import org.mifosplatform.portfolio.group.data.GroupAccountSummaryData; +import org.mifosplatform.portfolio.group.data.GroupData; +import org.mifosplatform.portfolio.group.exception.GroupNotFoundException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.EmptyResultDataAccessException; import org.springframework.jdbc.core.JdbcTemplate; diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupWritePlatformService.java similarity index 85% rename from mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupWritePlatformService.java index 3a9f79029..a6d07c2f0 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupWritePlatformService.java @@ -1,7 +1,7 @@ -package org.mifosng.platform.group.service; +package org.mifosplatform.portfolio.group.service; -import org.mifosng.platform.api.commands.GroupCommand; import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.portfolio.group.command.GroupCommand; import org.springframework.security.access.prepost.PreAuthorize; public interface GroupWritePlatformService { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java similarity index 94% rename from mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java index 168a23a59..8c872c1ad 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/group/service/GroupWritePlatformServiceJpaRepositoryImpl.java @@ -1,12 +1,8 @@ -package org.mifosng.platform.group.service; +package org.mifosplatform.portfolio.group.service; import java.util.HashSet; import java.util.Set; -import org.mifosng.platform.api.commands.GroupCommand; -import org.mifosng.platform.exceptions.GroupNotFoundException; -import org.mifosng.platform.group.domain.Group; -import org.mifosng.platform.group.domain.GroupRepository; import org.mifosplatform.infrastructure.core.data.EntityIdentifier; import org.mifosplatform.infrastructure.core.exception.PlatformDataIntegrityException; import org.mifosplatform.infrastructure.office.domain.Office; @@ -17,6 +13,11 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext import org.mifosplatform.portfolio.client.domain.Client; import org.mifosplatform.portfolio.client.domain.ClientRepository; import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; +import org.mifosplatform.portfolio.group.command.GroupCommand; +import org.mifosplatform.portfolio.group.command.GroupCommandValidator; +import org.mifosplatform.portfolio.group.domain.Group; +import org.mifosplatform.portfolio.group.domain.GroupRepository; +import org.mifosplatform.portfolio.group.exception.GroupNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java index 4d470aa20..940620a82 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/Loan.java @@ -26,7 +26,6 @@ import org.apache.commons.lang.StringUtils; import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; import org.joda.time.LocalDate; -import org.mifosng.platform.group.domain.Group; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.configuration.domain.Money; import org.mifosplatform.infrastructure.core.domain.AbstractAuditableCustom; @@ -35,6 +34,7 @@ import org.mifosplatform.infrastructure.user.domain.AppUser; import org.mifosplatform.portfolio.charge.exception.LoanChargeCannotBeAddedException; import org.mifosplatform.portfolio.client.domain.Client; import org.mifosplatform.portfolio.fund.domain.Fund; +import org.mifosplatform.portfolio.group.domain.Group; import org.mifosplatform.portfolio.loanaccount.command.LoanApplicationCommand; import org.mifosplatform.portfolio.loanaccount.command.LoanChargeCommand; import org.mifosplatform.portfolio.loanaccount.exception.InvalidLoanStateTransitionException; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java index 1d096df02..cd59ffef6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/domain/LoanTransaction.java @@ -6,8 +6,6 @@ import java.util.Date; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToOne; @@ -35,247 +33,251 @@ import org.springframework.format.annotation.DateTimeFormat; public class LoanTransaction extends AbstractAuditableCustom { @ManyToOne(optional = false) - @JoinColumn(name = "loan_id", nullable=false) - private Loan loan; + @JoinColumn(name = "loan_id", nullable = false) + private Loan loan; + + @Column(name = "amount", scale = 6, precision = 19, nullable = false) + private BigDecimal amount; + + @Column(name = "principal_portion_derived", scale = 6, precision = 19, nullable = true) + private BigDecimal principalPortion = BigDecimal.ZERO; + + @Column(name = "interest_portion_derived", scale = 6, precision = 19, nullable = true) + private BigDecimal interestPortion = BigDecimal.ZERO; + + @Column(name = "fee_charges_portion_derived", scale = 6, precision = 19, nullable = true) + private BigDecimal feeChargesPortion = BigDecimal.ZERO; + + @Column(name = "penalty_charges_portion_derived", scale = 6, precision = 19, nullable = true) + private BigDecimal penaltyChargesPortion = BigDecimal.ZERO; - @Column(name = "amount", scale = 6, precision = 19, nullable = false) - private BigDecimal amount; - - @Column(name = "principal_portion_derived", scale = 6, precision = 19, nullable = true) - private BigDecimal principalPortion = BigDecimal.ZERO; - - @Column(name = "interest_portion_derived", scale = 6, precision = 19, nullable = true) - private BigDecimal interestPortion = BigDecimal.ZERO; - - @Column(name = "fee_charges_portion_derived", scale = 6, precision = 19, nullable = true) - private BigDecimal feeChargesPortion = BigDecimal.ZERO; - - @Column(name = "penalty_charges_portion_derived", scale = 6, precision = 19, nullable = true) - private BigDecimal penaltyChargesPortion = BigDecimal.ZERO; - @Temporal(TemporalType.DATE) - @Column(name = "transaction_date", nullable=false) - private final Date dateOf; - - @Enumerated(EnumType.ORDINAL) - @Column(name = "transaction_type_enum", nullable = false) - private Integer typeOf; - - @OneToOne(optional=true, cascade={CascadeType.PERSIST}) - @JoinColumn(name="contra_id") + @Column(name = "transaction_date", nullable = false) + private final Date dateOf; + + @Column(name = "transaction_type_enum", nullable = false) + private Integer typeOf; + + @OneToOne(optional = true, cascade = { CascadeType.PERSIST }) + @JoinColumn(name = "contra_id") private LoanTransaction contra; - + protected LoanTransaction() { this.loan = null; this.dateOf = null; this.typeOf = null; } - + public static LoanTransaction disbursement(final Money amount, final LocalDate disbursementDate) { - return new LoanTransaction(null, LoanTransactionType.DISBURSEMENT, amount.getAmount(), disbursementDate); - } - - public static LoanTransaction repayment(final Money amount, final LocalDate paymentDate) { - return new LoanTransaction(null, LoanTransactionType.REPAYMENT, amount.getAmount(), paymentDate); - } - - public static LoanTransaction repaymentAtDisbursement(final Money amount, final LocalDate paymentDate) { - return new LoanTransaction(null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT, amount.getAmount(), paymentDate); - } - - public static LoanTransaction waiver(final Loan loan, final Money waived, final LocalDate waiveDate) { - return new LoanTransaction(loan, LoanTransactionType.WAIVE_INTEREST, waived.getAmount(), waiveDate); - } - - public static LoanTransaction waiveLoanCharge(final Loan loan, final Money waived, final LocalDate waiveDate, final Money feeChargesWaived, final Money penaltyChargesWaived) { - LoanTransaction waiver = new LoanTransaction(loan, LoanTransactionType.WAIVE_CHARGES, waived.getAmount(), waiveDate); - waiver.updateChargesComponents(feeChargesWaived, penaltyChargesWaived); - - return waiver; - } + return new LoanTransaction(null, LoanTransactionType.DISBURSEMENT, amount.getAmount(), disbursementDate); + } - private static LoanTransaction contra(final LoanTransaction originalTransaction) { - LoanTransaction contra = new LoanTransaction(null, LoanTransactionType.CONTRA, originalTransaction.getAmount().negate(), new LocalDate(originalTransaction.getDateOf())); - contra.updateContra(originalTransaction); - return contra; - } - - public static LoanTransaction writeoff(final Loan loan, final LocalDate writeOffDate) { - return new LoanTransaction(loan, LoanTransactionType.WRITEOFF, null, writeOffDate); - } - - public void updateContra(final LoanTransaction transaction) { - this.contra = transaction; - } + public static LoanTransaction repayment(final Money amount, final LocalDate paymentDate) { + return new LoanTransaction(null, LoanTransactionType.REPAYMENT, amount.getAmount(), paymentDate); + } - private LoanTransaction(final Loan loan, final LoanTransactionType type, final BigDecimal amount, final LocalDate date) { - this.loan = loan; - this.typeOf = type.getValue(); + public static LoanTransaction repaymentAtDisbursement(final Money amount, final LocalDate paymentDate) { + return new LoanTransaction(null, LoanTransactionType.REPAYMENT_AT_DISBURSEMENT, amount.getAmount(), paymentDate); + } + + public static LoanTransaction waiver(final Loan loan, final Money waived, final LocalDate waiveDate) { + return new LoanTransaction(loan, LoanTransactionType.WAIVE_INTEREST, waived.getAmount(), waiveDate); + } + + public static LoanTransaction waiveLoanCharge(final Loan loan, final Money waived, final LocalDate waiveDate, + final Money feeChargesWaived, final Money penaltyChargesWaived) { + LoanTransaction waiver = new LoanTransaction(loan, LoanTransactionType.WAIVE_CHARGES, waived.getAmount(), waiveDate); + waiver.updateChargesComponents(feeChargesWaived, penaltyChargesWaived); + + return waiver; + } + + private static LoanTransaction contra(final LoanTransaction originalTransaction) { + LoanTransaction contra = new LoanTransaction(null, LoanTransactionType.CONTRA, originalTransaction.getAmount().negate(), + new LocalDate(originalTransaction.getDateOf())); + contra.updateContra(originalTransaction); + return contra; + } + + public static LoanTransaction writeoff(final Loan loan, final LocalDate writeOffDate) { + return new LoanTransaction(loan, LoanTransactionType.WRITEOFF, null, writeOffDate); + } + + public void updateContra(final LoanTransaction transaction) { + this.contra = transaction; + } + + private LoanTransaction(final Loan loan, final LoanTransactionType type, final BigDecimal amount, final LocalDate date) { + this.loan = loan; + this.typeOf = type.getValue(); this.amount = amount; - this.dateOf = date.toDateMidnight().toDate(); + this.dateOf = date.toDateMidnight().toDate(); } public BigDecimal getAmount() { return this.amount; } - - public Money getAmount(MonetaryCurrency currency) { - return Money.of(currency, this.amount); - } - @DateTimeFormat(style="-M") + public Money getAmount(MonetaryCurrency currency) { + return Money.of(currency, this.amount); + } + + @DateTimeFormat(style = "-M") public LocalDate getTransactionDate() { return new LocalDate(this.dateOf); } - public Date getDateOf() { - return dateOf; - } + public Date getDateOf() { + return dateOf; + } - public LoanTransactionType getTypeOf() { - return LoanTransactionType.fromInt(this.typeOf); - } + public LoanTransactionType getTypeOf() { + return LoanTransactionType.fromInt(this.typeOf); + } - public boolean isRepayment() { - return LoanTransactionType.REPAYMENT.equals(getTypeOf()) && isNotContra(); - } - - public boolean isNotRepayment() { - return !isRepayment(); - } - - public boolean isNotContra() { - return this.contra == null; - } + public boolean isRepayment() { + return LoanTransactionType.REPAYMENT.equals(getTypeOf()) && isNotContra(); + } - public boolean isDisbursement() { - return LoanTransactionType.DISBURSEMENT.equals(getTypeOf()); - } - - public boolean isRepaymentAtDisbursement() { - return LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.equals(getTypeOf()); - } - - public boolean isInterestWaiver() { - return LoanTransactionType.WAIVE_INTEREST.equals(getTypeOf()) && isNotContra(); - } - - public boolean isChargesWaiver() { - return LoanTransactionType.WAIVE_CHARGES.equals(getTypeOf()) && isNotContra(); - } - - public boolean isNotInterestWaiver() { - return !isInterestWaiver(); - } - - public boolean isWaiver() { - return isInterestWaiver() || isChargesWaiver(); - } - - public boolean isNotWaiver() { - return !isInterestWaiver() && !isChargesWaiver(); - } - - public boolean isWriteOff() { - return getTypeOf().isWriteOff() && isNotContra(); - } + public boolean isNotRepayment() { + return !isRepayment(); + } - public boolean isIdentifiedBy(final Long identifier) { - return this.getId().equals(identifier); - } - - public boolean isBelongingToLoanOf(final Loan check) { - return this.loan.getId().equals(check.getId()); - } - - public boolean isNotBelongingToLoanOf(final Loan check) { - return !isBelongingToLoanOf(check); - } + public boolean isNotContra() { + return this.contra == null; + } - public void contra() { - this.contra = LoanTransaction.contra(this); - contra.updateLoan(this.loan); - } + public boolean isDisbursement() { + return LoanTransactionType.DISBURSEMENT.equals(getTypeOf()); + } + + public boolean isRepaymentAtDisbursement() { + return LoanTransactionType.REPAYMENT_AT_DISBURSEMENT.equals(getTypeOf()); + } + + public boolean isInterestWaiver() { + return LoanTransactionType.WAIVE_INTEREST.equals(getTypeOf()) && isNotContra(); + } + + public boolean isChargesWaiver() { + return LoanTransactionType.WAIVE_CHARGES.equals(getTypeOf()) && isNotContra(); + } + + public boolean isNotInterestWaiver() { + return !isInterestWaiver(); + } + + public boolean isWaiver() { + return isInterestWaiver() || isChargesWaiver(); + } + + public boolean isNotWaiver() { + return !isInterestWaiver() && !isChargesWaiver(); + } + + public boolean isWriteOff() { + return getTypeOf().isWriteOff() && isNotContra(); + } + + public boolean isIdentifiedBy(final Long identifier) { + return this.getId().equals(identifier); + } + + public boolean isBelongingToLoanOf(final Loan check) { + return this.loan.getId().equals(check.getId()); + } + + public boolean isNotBelongingToLoanOf(final Loan check) { + return !isBelongingToLoanOf(check); + } + + public void contra() { + this.contra = LoanTransaction.contra(this); + contra.updateLoan(this.loan); + } public void updateLoan(final Loan loan) { this.loan = loan; } - public boolean isNonZero() { - return this.amount.subtract(BigDecimal.ZERO).doubleValue() > 0; - } - - /** - * This updates the derived fields of a loan transaction for the principal, interest and interest waived portions. - * - * This accumulates the values passed to the already existent values for each of the portions. - */ - public void updateComponents(final Money principal, final Money interest, final Money feeCharges, final Money penaltyCharges) { - final MonetaryCurrency currency = principal.getCurrency(); - this.principalPortion = defaultToNullIfZero(getPrincipalPortion(currency).plus(principal).getAmount()); - this.interestPortion = defaultToNullIfZero(getInterestPortion(currency).plus(interest).getAmount()); - updateChargesComponents(feeCharges, penaltyCharges); - } - - private void updateChargesComponents(final Money feeCharges, final Money penaltyCharges) { - final MonetaryCurrency currency = feeCharges.getCurrency(); - this.feeChargesPortion = defaultToNullIfZero(getFeeChargesPortion(currency).plus(feeCharges).getAmount()); - this.penaltyChargesPortion = defaultToNullIfZero(getPenaltyChargesPortion(currency).plus(penaltyCharges).getAmount()); - } - - public void updateComponentsAndTotal(final Money principal, final Money interest, final Money feeCharges, final Money penaltyCharges) { - updateComponents(principal, interest, feeCharges, penaltyCharges); - - final MonetaryCurrency currency = principal.getCurrency(); - this.amount = getPrincipalPortion(currency).plus(getInterestPortion(currency)).plus(getFeeChargesPortion(currency)).plus(getPenaltyChargesPortion(currency)).getAmount(); - } - - public Money getPrincipalPortion(final MonetaryCurrency currency) { - return Money.of(currency, this.principalPortion); - } + public boolean isNonZero() { + return this.amount.subtract(BigDecimal.ZERO).doubleValue() > 0; + } - public Money getInterestPortion(final MonetaryCurrency currency) { - return Money.of(currency, this.interestPortion); - } - - public Money getFeeChargesPortion(final MonetaryCurrency currency) { - return Money.of(currency, this.feeChargesPortion); - } - - public Money getPenaltyChargesPortion(final MonetaryCurrency currency) { - return Money.of(currency, this.penaltyChargesPortion); - } + /** + * This updates the derived fields of a loan transaction for the principal, + * interest and interest waived portions. + * + * This accumulates the values passed to the already existent values for + * each of the portions. + */ + public void updateComponents(final Money principal, final Money interest, final Money feeCharges, final Money penaltyCharges) { + final MonetaryCurrency currency = principal.getCurrency(); + this.principalPortion = defaultToNullIfZero(getPrincipalPortion(currency).plus(principal).getAmount()); + this.interestPortion = defaultToNullIfZero(getInterestPortion(currency).plus(interest).getAmount()); + updateChargesComponents(feeCharges, penaltyCharges); + } - public void resetDerivedComponents() { - this.principalPortion = null; - this.interestPortion = null; - this.feeChargesPortion = null; - this.penaltyChargesPortion = null; - } + private void updateChargesComponents(final Money feeCharges, final Money penaltyCharges) { + final MonetaryCurrency currency = feeCharges.getCurrency(); + this.feeChargesPortion = defaultToNullIfZero(getFeeChargesPortion(currency).plus(feeCharges).getAmount()); + this.penaltyChargesPortion = defaultToNullIfZero(getPenaltyChargesPortion(currency).plus(penaltyCharges).getAmount()); + } - public boolean isGreaterThan(final Money monetaryAmount) { - return getAmount(monetaryAmount.getCurrency()).isGreaterThan(monetaryAmount); - } - - public boolean isGreaterThanZero(final MonetaryCurrency currency) { - return getAmount(currency).isGreaterThanZero(); - } + public void updateComponentsAndTotal(final Money principal, final Money interest, final Money feeCharges, final Money penaltyCharges) { + updateComponents(principal, interest, feeCharges, penaltyCharges); - public boolean isNotZero(final MonetaryCurrency currency) { - return !getAmount(currency).isZero(); - } - - private BigDecimal defaultToNullIfZero(final BigDecimal value) { - BigDecimal result = value; - if (BigDecimal.ZERO.compareTo(value) == 0) { - result = null; - } - return result; - } + final MonetaryCurrency currency = principal.getCurrency(); + this.amount = getPrincipalPortion(currency).plus(getInterestPortion(currency)).plus(getFeeChargesPortion(currency)) + .plus(getPenaltyChargesPortion(currency)).getAmount(); + } - public LoanTransactionData toData(final CurrencyData currencyData) { - final EnumOptionData transactionType = LoanEnumerations.transactionType(this.typeOf); - return new LoanTransactionData(this.getId(), transactionType, currencyData, getTransactionDate(), - this.amount, this.principalPortion, this.interestPortion, this.feeChargesPortion, this.penaltyChargesPortion); - } + public Money getPrincipalPortion(final MonetaryCurrency currency) { + return Money.of(currency, this.principalPortion); + } + + public Money getInterestPortion(final MonetaryCurrency currency) { + return Money.of(currency, this.interestPortion); + } + + public Money getFeeChargesPortion(final MonetaryCurrency currency) { + return Money.of(currency, this.feeChargesPortion); + } + + public Money getPenaltyChargesPortion(final MonetaryCurrency currency) { + return Money.of(currency, this.penaltyChargesPortion); + } + + public void resetDerivedComponents() { + this.principalPortion = null; + this.interestPortion = null; + this.feeChargesPortion = null; + this.penaltyChargesPortion = null; + } + + public boolean isGreaterThan(final Money monetaryAmount) { + return getAmount(monetaryAmount.getCurrency()).isGreaterThan(monetaryAmount); + } + + public boolean isGreaterThanZero(final MonetaryCurrency currency) { + return getAmount(currency).isGreaterThanZero(); + } + + public boolean isNotZero(final MonetaryCurrency currency) { + return !getAmount(currency).isZero(); + } + + private BigDecimal defaultToNullIfZero(final BigDecimal value) { + BigDecimal result = value; + if (BigDecimal.ZERO.compareTo(value) == 0) { + result = null; + } + return result; + } + + public LoanTransactionData toData(final CurrencyData currencyData) { + final EnumOptionData transactionType = LoanEnumerations.transactionType(this.typeOf); + return new LoanTransactionData(this.getId(), transactionType, currencyData, getTransactionDate(), this.amount, + this.principalPortion, this.interestPortion, this.feeChargesPortion, this.penaltyChargesPortion); + } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/GuarantorsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/gaurantor/api/GuarantorsApiResource.java similarity index 98% rename from mifosng-provider/src/main/java/org/mifosng/platform/api/GuarantorsApiResource.java rename to mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/gaurantor/api/GuarantorsApiResource.java index 0607be021..658476e64 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/GuarantorsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/gaurantor/api/GuarantorsApiResource.java @@ -1,4 +1,4 @@ -package org.mifosng.platform.api; +package org.mifosplatform.portfolio.loanaccount.gaurantor.api; import java.util.Arrays; import java.util.HashSet; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java index fa5e4aafb..f069de5a9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanAssembler.java @@ -5,9 +5,6 @@ import java.util.Arrays; import java.util.List; import java.util.Set; -import org.mifosng.platform.exceptions.GroupNotFoundException; -import org.mifosng.platform.group.domain.Group; -import org.mifosng.platform.group.domain.GroupRepository; import org.mifosplatform.infrastructure.configuration.domain.MonetaryCurrency; import org.mifosplatform.infrastructure.staff.domain.Staff; import org.mifosplatform.infrastructure.staff.domain.StaffRepository; @@ -19,6 +16,9 @@ import org.mifosplatform.portfolio.client.exception.ClientNotFoundException; import org.mifosplatform.portfolio.fund.domain.Fund; import org.mifosplatform.portfolio.fund.domain.FundRepository; import org.mifosplatform.portfolio.fund.exception.FundNotFoundException; +import org.mifosplatform.portfolio.group.domain.Group; +import org.mifosplatform.portfolio.group.domain.GroupRepository; +import org.mifosplatform.portfolio.group.exception.GroupNotFoundException; import org.mifosplatform.portfolio.loanaccount.command.LoanApplicationCommand; import org.mifosplatform.portfolio.loanaccount.domain.DefaultLoanLifecycleStateMachine; import org.mifosplatform.portfolio.loanaccount.domain.Loan; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java index af853c5ae..13c4b95e2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java @@ -7,8 +7,6 @@ import java.util.ArrayList; import java.util.Collection; import org.joda.time.LocalDate; -import org.mifosng.platform.api.data.GroupData; -import org.mifosng.platform.group.service.GroupReadPlatformService; import org.mifosplatform.infrastructure.configuration.data.CurrencyData; import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrency; import org.mifosplatform.infrastructure.configuration.domain.ApplicationCurrencyRepository; @@ -21,6 +19,8 @@ import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSourc import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.portfolio.client.data.ClientData; import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; +import org.mifosplatform.portfolio.group.data.GroupData; +import org.mifosplatform.portfolio.group.service.GroupReadPlatformService; import org.mifosplatform.portfolio.loanaccount.data.DisbursementData; import org.mifosplatform.portfolio.loanaccount.data.LoanBasicDetailsData; import org.mifosplatform.portfolio.loanaccount.data.LoanChargeData; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductMinimumRepaymentScheduleRelatedDetail.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductMinimumRepaymentScheduleRelatedDetail.java index 9b1c500de..2de4d7ebb 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductMinimumRepaymentScheduleRelatedDetail.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/domain/LoanProductMinimumRepaymentScheduleRelatedDetail.java @@ -1,13 +1,10 @@ package org.mifosplatform.portfolio.loanproduct.domain; -import java.io.Serializable; - - /** * Represents the bare minimum repayment details needed for activities related * to generating repayment schedules. */ -public interface LoanProductMinimumRepaymentScheduleRelatedDetail extends Serializable { +public interface LoanProductMinimumRepaymentScheduleRelatedDetail { Integer getRepayEvery();