Merge pull request #42 from myrle-krantz/develop
minor fixes
diff --git a/api/src/main/java/io/mifos/portfolio/api/v1/domain/InterestRange.java b/api/src/main/java/io/mifos/portfolio/api/v1/domain/InterestRange.java
deleted file mode 100644
index d119bd7..0000000
--- a/api/src/main/java/io/mifos/portfolio/api/v1/domain/InterestRange.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2017 The Mifos Initiative.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.mifos.portfolio.api.v1.domain;
-
-import org.hibernate.validator.constraints.ScriptAssert;
-
-import javax.validation.constraints.DecimalMax;
-import javax.validation.constraints.DecimalMin;
-import java.math.BigDecimal;
-
-/**
- * @author Myrle Krantz
- */
-@SuppressWarnings({"WeakerAccess", "unused"})
-@ScriptAssert(lang = "javascript", script = "_this.maximum != null && _this.minimum != null && _this.maximum.compareTo(_this.minimum) >= 0 && _this.minimum.scale() <= 2 && _this.maximum.scale() <= 2")
-public class InterestRange {
- @DecimalMin(value = "0.00")
- @DecimalMax(value = "999.99")
- private BigDecimal minimum;
- @DecimalMin(value = "0.00")
- @DecimalMax(value = "999.99")
- private BigDecimal maximum;
-
- public InterestRange() {
- }
-
- public InterestRange(BigDecimal minimum, BigDecimal maximum) {
- this.minimum = minimum;
- this.maximum = maximum;
- }
-
- public BigDecimal getMinimum() {
- return minimum;
- }
-
- public void setMinimum(BigDecimal minimum) {
- this.minimum = minimum;
- }
-
- public BigDecimal getMaximum() {
- return maximum;
- }
-
- public void setMaximum(BigDecimal maximum) {
- this.maximum = maximum;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- InterestRange that = (InterestRange) o;
-
- return minimum != null ? minimum.equals(that.minimum) : that.minimum == null && (maximum != null ? maximum.equals(that.maximum) : that.maximum == null);
-
- }
-
- @Override
- public int hashCode() {
- int result = minimum != null ? minimum.hashCode() : 0;
- result = 31 * result + (maximum != null ? maximum.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "InterestRange{" +
- "minimum=" + minimum +
- ", maximum=" + maximum +
- '}';
- }
-}
diff --git a/api/src/main/java/io/mifos/portfolio/api/v1/domain/Product.java b/api/src/main/java/io/mifos/portfolio/api/v1/domain/Product.java
index 0e7274d..6f34f9b 100644
--- a/api/src/main/java/io/mifos/portfolio/api/v1/domain/Product.java
+++ b/api/src/main/java/io/mifos/portfolio/api/v1/domain/Product.java
@@ -43,9 +43,6 @@
@Valid
private BalanceRange balanceRange;
@NotNull
- @Valid
- private InterestRange interestRange;
- @NotNull
private InterestBasis interestBasis;
@NotNull
@ValidIdentifier(maxLength = 512)
@@ -104,14 +101,6 @@
this.balanceRange = balanceRange;
}
- public InterestRange getInterestRange() {
- return interestRange;
- }
-
- public void setInterestRange(InterestRange interestRange) {
- this.interestRange = interestRange;
- }
-
public InterestBasis getInterestBasis() {
return interestBasis;
}
@@ -210,7 +199,6 @@
Objects.equals(name, product.name) &&
Objects.equals(termRange, product.termRange) &&
Objects.equals(balanceRange, product.balanceRange) &&
- Objects.equals(interestRange, product.interestRange) &&
interestBasis == product.interestBasis &&
Objects.equals(patternPackage, product.patternPackage) &&
Objects.equals(description, product.description) &&
@@ -221,7 +209,7 @@
@Override
public int hashCode() {
- return Objects.hash(identifier, name, termRange, balanceRange, interestRange, interestBasis, patternPackage, description, currencyCode, minorCurrencyUnitDigits, accountAssignments, parameters);
+ return Objects.hash(identifier, name, termRange, balanceRange, interestBasis, patternPackage, description, currencyCode, minorCurrencyUnitDigits, accountAssignments, parameters);
}
@Override
@@ -231,7 +219,6 @@
", name='" + name + '\'' +
", termRange=" + termRange +
", balanceRange=" + balanceRange +
- ", interestRange=" + interestRange +
", interestBasis=" + interestBasis +
", patternPackage='" + patternPackage + '\'' +
", description='" + description + '\'' +
diff --git a/api/src/test/java/io/mifos/Fixture.java b/api/src/test/java/io/mifos/Fixture.java
index c253395..f45d457 100644
--- a/api/src/test/java/io/mifos/Fixture.java
+++ b/api/src/test/java/io/mifos/Fixture.java
@@ -55,7 +55,6 @@
product.setDescription("Loan for seeds or agricultural equipment");
product.setTermRange(new TermRange(ChronoUnit.MONTHS, 12));
product.setBalanceRange(new BalanceRange(fixScale(BigDecimal.ZERO), fixScale(new BigDecimal(10000))));
- product.setInterestRange(new InterestRange(BigDecimal.valueOf(3, 2), BigDecimal.valueOf(12, 2)));
product.setInterestBasis(InterestBasis.CURRENT_BALANCE);
product.setCurrencyCode("XXX");
diff --git a/api/src/test/java/io/mifos/portfolio/api/v1/domain/InterestRangeTest.java b/api/src/test/java/io/mifos/portfolio/api/v1/domain/InterestRangeTest.java
deleted file mode 100644
index 0f4a851..0000000
--- a/api/src/test/java/io/mifos/portfolio/api/v1/domain/InterestRangeTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2017 The Mifos Initiative.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.mifos.portfolio.api.v1.domain;
-
-import io.mifos.core.test.domain.ValidationTest;
-import io.mifos.core.test.domain.ValidationTestCase;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * @author Myrle Krantz
- */
-@RunWith(Parameterized.class)
-public class InterestRangeTest extends ValidationTest<InterestRange> {
- public InterestRangeTest(ValidationTestCase<InterestRange> testCase) {
- super(testCase);
- }
-
- @Override
- protected InterestRange createValidTestSubject() {
- return new InterestRange(BigDecimal.valueOf(0.02d).setScale(2, BigDecimal.ROUND_UNNECESSARY),
- BigDecimal.valueOf(0.03d).setScale(2, BigDecimal.ROUND_UNNECESSARY));
- }
-
- @Parameterized.Parameters
- public static Collection testCases() {
- final Collection<ValidationTestCase> ret = new ArrayList<>();
- ret.add(new ValidationTestCase<InterestRange>("basicCase")
- .adjustment(x -> {})
- .valid(true));
- ret.add(new ValidationTestCase<InterestRange>("5 and 10")
- .adjustment(x -> {
- x.setMinimum(BigDecimal.valueOf(5L).setScale(2, BigDecimal.ROUND_UNNECESSARY));
- x.setMaximum(BigDecimal.valueOf(10L).setScale(2, BigDecimal.ROUND_UNNECESSARY));
- })
- .valid(true));
- ret.add(new ValidationTestCase<InterestRange>("5 and 5")
- .adjustment(x -> {
- x.setMinimum(BigDecimal.valueOf(5L).setScale(2, BigDecimal.ROUND_UNNECESSARY));
- x.setMaximum(BigDecimal.valueOf(5L).setScale(2, BigDecimal.ROUND_UNNECESSARY));
- })
- .valid(true));
- ret.add(new ValidationTestCase<InterestRange>("maxNull")
- .adjustment((x) -> x.setMaximum(null))
- .valid(false));
- ret.add(new ValidationTestCase<InterestRange>("maximim smaller than minimum")
- .adjustment(x -> {
- x.setMinimum(BigDecimal.valueOf(10L).setScale(2, BigDecimal.ROUND_UNNECESSARY));
- x.setMaximum(BigDecimal.valueOf(5L).setScale(2, BigDecimal.ROUND_UNNECESSARY));
- })
- .valid(false));
- ret.add(new ValidationTestCase<InterestRange>("too large scale")
- .adjustment(x ->
- x.setMinimum(x.getMinimum().setScale(3, BigDecimal.ROUND_UNNECESSARY)))
- .valid(false));
- ret.add(new ValidationTestCase<InterestRange>("smaller scale")
- .adjustment(x ->
- x.setMinimum(x.getMinimum().setScale(1, BigDecimal.ROUND_HALF_EVEN)))
- .valid(true));
- return ret;
- }
-}
\ No newline at end of file
diff --git a/api/src/test/java/io/mifos/portfolio/api/v1/domain/ProductTest.java b/api/src/test/java/io/mifos/portfolio/api/v1/domain/ProductTest.java
index 3ab8947..9ab2448 100644
--- a/api/src/test/java/io/mifos/portfolio/api/v1/domain/ProductTest.java
+++ b/api/src/test/java/io/mifos/portfolio/api/v1/domain/ProductTest.java
@@ -80,22 +80,6 @@
ret.add(new ValidationTestCase<Product>("switchedBalanceRangeMinMax")
.adjustment(product -> product.setBalanceRange(new BalanceRange(Fixture.fixScale(BigDecimal.TEN), Fixture.fixScale(BigDecimal.ZERO))))
.valid(false));
- ret.add(new ValidationTestCase<Product>("nullInterestRange")
- .adjustment(product -> product.setInterestRange(null))
- .valid(false));
- //noinspection BigDecimalMethodWithoutRoundingCalled
- ret.add(new ValidationTestCase<Product>("switchedInterestRangeMinMax")
- .adjustment(product -> product.setInterestRange(new InterestRange(BigDecimal.valueOf(200, 2), BigDecimal.valueOf(0.9).setScale(2))))
- .valid(false));
- ret.add(new ValidationTestCase<Product>("tooBigMaximumInterestRange")
- .adjustment(product -> product.setInterestRange(new InterestRange(new BigDecimal("999.99"), new BigDecimal("1000.00"))))
- .valid(false));
- ret.add(new ValidationTestCase<Product>("negativeMinimumInterestRange")
- .adjustment(product -> product.setInterestRange(new InterestRange(BigDecimal.valueOf(-1, 2), BigDecimal.valueOf(1, 2))))
- .valid(false));
- ret.add(new ValidationTestCase<Product>("tooManyDigitsAfterTheDecimalInterestRange")
- .adjustment(product -> product.setInterestRange(new InterestRange(BigDecimal.valueOf(1, 2), new BigDecimal("1.001"))))
- .valid(false));
ret.add(new ValidationTestCase<Product>("nullInterestBasis")
.adjustment(product -> product.setInterestBasis(null))
.valid(false));
diff --git a/component-test/src/main/java/io/mifos/portfolio/Fixture.java b/component-test/src/main/java/io/mifos/portfolio/Fixture.java
index 777a327..5b3785e 100644
--- a/component-test/src/main/java/io/mifos/portfolio/Fixture.java
+++ b/component-test/src/main/java/io/mifos/portfolio/Fixture.java
@@ -52,7 +52,6 @@
product.setDescription("Loan for seeds or agricultural equipment");
product.setTermRange(new TermRange(ChronoUnit.MONTHS, 12));
product.setBalanceRange(new BalanceRange(fixScale(BigDecimal.ZERO), fixScale(new BigDecimal(10000))));
- product.setInterestRange(new InterestRange(BigDecimal.valueOf(3, 2), BigDecimal.valueOf(12, 2)));
product.setInterestBasis(InterestBasis.CURRENT_BALANCE);
product.setCurrencyCode("XXX");
diff --git a/component-test/src/main/java/io/mifos/portfolio/TestProducts.java b/component-test/src/main/java/io/mifos/portfolio/TestProducts.java
index 876d07a..f370f90 100644
--- a/component-test/src/main/java/io/mifos/portfolio/TestProducts.java
+++ b/component-test/src/main/java/io/mifos/portfolio/TestProducts.java
@@ -332,7 +332,6 @@
product.setDescription(StringUtils.repeat("x", 4096));
product.setTermRange(new TermRange(ChronoUnit.MONTHS, 12));
product.setBalanceRange(new BalanceRange(BigDecimal.ZERO.setScale(4, BigDecimal.ROUND_UNNECESSARY), new BigDecimal(10000).setScale(4, BigDecimal.ROUND_UNNECESSARY)));
- product.setInterestRange(new InterestRange(new BigDecimal("999.98"), new BigDecimal("999.99")));
product.setInterestBasis(InterestBasis.CURRENT_BALANCE);
product.setCurrencyCode("XTS");
product.setMinorCurrencyUnitDigits(4);
diff --git a/service/src/main/java/io/mifos/individuallending/internal/service/CostComponentService.java b/service/src/main/java/io/mifos/individuallending/internal/service/CostComponentService.java
index 51898aa..d84fc63 100644
--- a/service/src/main/java/io/mifos/individuallending/internal/service/CostComponentService.java
+++ b/service/src/main/java/io/mifos/individuallending/internal/service/CostComponentService.java
@@ -189,7 +189,7 @@
final BigDecimal currentBalance = accountingAdapter.getCurrentBalance(customerLoanAccountIdentifier);
if (dataContextOfAction.getCaseParameters().getMaximumBalance().compareTo(
- currentBalance.add(requestedDisbursalSize)) > 0)
+ currentBalance.add(requestedDisbursalSize)) < 0)
throw ServiceException.conflict("Cannot disburse over the maximum balance.");
final Optional<LocalDateTime> optionalStartOfTerm = accountingAdapter.getDateOfOldestEntryContainingMessage(
@@ -373,13 +373,6 @@
dataContextOfAction.getCompoundIdentifer()));
}
- private CostComponentsForRepaymentPeriod getCostComponentsForMarkLate(final DataContextOfAction dataContextOfAction) {
- return null;
- }
- private CostComponentsForRepaymentPeriod getCostComponentsForWriteOff(final DataContextOfAction dataContextOfAction) {
- return null;
- }
-
public CostComponentsForRepaymentPeriod getCostComponentsForClose(final DataContextOfAction dataContextOfAction) {
final DesignatorToAccountIdentifierMapper designatorToAccountIdentifierMapper
= new DesignatorToAccountIdentifierMapper(dataContextOfAction);
@@ -419,6 +412,14 @@
true);
}
+ private CostComponentsForRepaymentPeriod getCostComponentsForMarkLate(final DataContextOfAction dataContextOfAction) {
+ return null;
+ }
+
+ private CostComponentsForRepaymentPeriod getCostComponentsForWriteOff(final DataContextOfAction dataContextOfAction) {
+ return null;
+ }
+
private CostComponentsForRepaymentPeriod getCostComponentsForRecover(final DataContextOfAction dataContextOfAction) {
return null;
}
diff --git a/service/src/main/java/io/mifos/portfolio/service/internal/mapper/ProductMapper.java b/service/src/main/java/io/mifos/portfolio/service/internal/mapper/ProductMapper.java
index 4e470b3..40d85d8 100644
--- a/service/src/main/java/io/mifos/portfolio/service/internal/mapper/ProductMapper.java
+++ b/service/src/main/java/io/mifos/portfolio/service/internal/mapper/ProductMapper.java
@@ -43,8 +43,6 @@
productEntity.getTermRangeMaximum()));
product.setBalanceRange(
new BalanceRange(productEntity.getBalanceRangeMinimum().setScale(productEntity.getMinorCurrencyUnitDigits(), BigDecimal.ROUND_HALF_EVEN), productEntity.getBalanceRangeMaximum().setScale(productEntity.getMinorCurrencyUnitDigits(), BigDecimal.ROUND_HALF_EVEN)));
- product.setInterestRange(
- new InterestRange(productEntity.getInterestRangeMinimum(), productEntity.getInterestRangeMaximum()));
product.setInterestBasis(productEntity.getInterestBasis());
product.setPatternPackage(productEntity.getPatternPackage());
product.setDescription(productEntity.getDescription());
@@ -72,8 +70,8 @@
ret.setTermRangeMaximum(product.getTermRange().getMaximum());
ret.setBalanceRangeMinimum(product.getBalanceRange().getMinimum());
ret.setBalanceRangeMaximum(product.getBalanceRange().getMaximum());
- ret.setInterestRangeMinimum(product.getInterestRange().getMinimum());
- ret.setInterestRangeMaximum(product.getInterestRange().getMaximum());
+ ret.setInterestRangeMinimum(BigDecimal.ZERO);
+ ret.setInterestRangeMaximum(BigDecimal.valueOf(999.99));
ret.setInterestBasis(product.getInterestBasis());
ret.setPatternPackage(product.getPatternPackage());
ret.setDescription(product.getDescription());