Added check and test for negative argument.
diff --git a/component-test/src/main/java/io/mifos/portfolio/TestAccountingInteractionInLoanWorkflow.java b/component-test/src/main/java/io/mifos/portfolio/TestAccountingInteractionInLoanWorkflow.java
index b9ceeaf..cc2c74c 100644
--- a/component-test/src/main/java/io/mifos/portfolio/TestAccountingInteractionInLoanWorkflow.java
+++ b/component-test/src/main/java/io/mifos/portfolio/TestAccountingInteractionInLoanWorkflow.java
@@ -94,7 +94,6 @@
step8Close();
}
-
@Test
public void workflowWithTwoNearlyEqualRepayments() throws InterruptedException {
step1CreateProduct();
@@ -109,6 +108,15 @@
step8Close();
}
+ @Test(expected = IllegalArgumentException.class)
+ public void workflowWithNegativePaymentSize() throws InterruptedException {
+ step1CreateProduct();
+ step2CreateCase();
+ step3OpenCase();
+ step4ApproveCase();
+ step5Disburse(BigDecimal.valueOf(-2).setScale(MINOR_CURRENCY_UNIT_DIGITS, BigDecimal.ROUND_HALF_EVEN));
+ }
+
//Create product and set charges to fixed fees.
private void step1CreateProduct() throws InterruptedException {
logger.info("step1CreateProduct");
diff --git a/service/src/main/java/io/mifos/portfolio/service/rest/CaseRestController.java b/service/src/main/java/io/mifos/portfolio/service/rest/CaseRestController.java
index 44e7e7d..f2a4ed5 100644
--- a/service/src/main/java/io/mifos/portfolio/service/rest/CaseRestController.java
+++ b/service/src/main/java/io/mifos/portfolio/service/rest/CaseRestController.java
@@ -196,6 +196,10 @@
{
checkThatCaseExists(productIdentifier, caseIdentifier);
+ if (forPaymentSize != null && forPaymentSize.compareTo(BigDecimal.ZERO) < 0)
+ throw ServiceException.badRequest("forpaymentsize can''t be negative.");
+
+
return caseService.getActionCostComponentsForCase(productIdentifier, caseIdentifier, actionIdentifier, forAccountDesignators, forPaymentSize);
}