fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From my...@apache.org
Subject [fineract-cn-accounting] 29/36: implementation for financial condition
Date Mon, 22 Jan 2018 15:44:05 GMT
This is an automated email from the ASF dual-hosted git repository.

myrle pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract-cn-accounting.git

commit 174f4dfa2f420fc0a0926bf196193c9b542fefa2
Author: mgeiss <mgeiss@mifos.org>
AuthorDate: Thu Oct 12 10:31:44 2017 +0200

    implementation for financial condition
---
 .../accounting/api/v1/PermittableGroupIds.java     |   1 +
 .../accounting/api/v1/client/LedgerManager.java    |  13 +-
 .../statement/FinancialCondition.java}             |  46 +++----
 .../statement/FinancialConditionEntry.java}        |   6 +-
 .../statement/FinancialConditionSection.java}      |  23 ++--
 .../{ => financial/statement}/IncomeStatement.java |   2 +-
 .../statement}/IncomeStatementEntry.java           |   2 +-
 .../statement}/IncomeStatementSection.java         |   2 +-
 .../{ => financial/statement}/TrialBalance.java    |   2 +-
 .../statement}/TrialBalanceEntry.java              |   4 +-
 .../mifos/accounting/TestFinancialCondition.java   | 142 +++++++++++++++++++++
 .../io/mifos/accounting/TestIncomeStatement.java   |   2 +-
 .../java/io/mifos/accounting/TestTrialBalance.java |   2 +-
 .../command/handler/MigrationCommandHandler.java   |   3 -
 .../service/FinancialConditionService.java         |  90 +++++++++++++
 .../internal/service/IncomeStatementService.java   |   6 +-
 .../internal/service/TrialBalanceService.java      |   4 +-
 ...ller.java => FinancialConditionController.java} |  20 +--
 .../service/rest/IncomeStatementController.java    |   2 +-
 .../service/rest/TrialBalanceController.java       |   2 +-
 20 files changed, 303 insertions(+), 71 deletions(-)

diff --git a/api/src/main/java/io/mifos/accounting/api/v1/PermittableGroupIds.java b/api/src/main/java/io/mifos/accounting/api/v1/PermittableGroupIds.java
index 6c5cb2e..5972be4 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/PermittableGroupIds.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/PermittableGroupIds.java
@@ -23,5 +23,6 @@ public interface PermittableGroupIds {
   String THOTH_JOURNAL = "accounting__v1__journal";
   String THOTH_TX_TYPES = "accounting__v1__tx_types";
   String THOTH_INCOME_STMT = "accounting__v1__income_stmt";
+  String THOTH_FIN_CONDITION = "accounting__v1__fin_condition";
 
 }
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/client/LedgerManager.java b/api/src/main/java/io/mifos/accounting/api/v1/client/LedgerManager.java
index 7959d19..2eaada7 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/client/LedgerManager.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/client/LedgerManager.java
@@ -21,13 +21,14 @@ import io.mifos.accounting.api.v1.domain.AccountEntry;
 import io.mifos.accounting.api.v1.domain.AccountEntryPage;
 import io.mifos.accounting.api.v1.domain.AccountPage;
 import io.mifos.accounting.api.v1.domain.ChartOfAccountEntry;
-import io.mifos.accounting.api.v1.domain.IncomeStatement;
 import io.mifos.accounting.api.v1.domain.JournalEntry;
 import io.mifos.accounting.api.v1.domain.Ledger;
 import io.mifos.accounting.api.v1.domain.LedgerPage;
 import io.mifos.accounting.api.v1.domain.TransactionType;
 import io.mifos.accounting.api.v1.domain.TransactionTypePage;
-import io.mifos.accounting.api.v1.domain.TrialBalance;
+import io.mifos.accounting.api.v1.domain.financial.statement.FinancialCondition;
+import io.mifos.accounting.api.v1.domain.financial.statement.IncomeStatement;
+import io.mifos.accounting.api.v1.domain.financial.statement.TrialBalance;
 import io.mifos.core.api.annotation.ThrowsException;
 import io.mifos.core.api.annotation.ThrowsExceptions;
 import io.mifos.core.api.util.CustomFeignClientsConfiguration;
@@ -407,4 +408,12 @@ public interface LedgerManager {
       consumes = {MediaType.APPLICATION_JSON_VALUE}
   )
   IncomeStatement getIncomeStatement();
+
+  @RequestMapping(
+      value = "/financialcondition",
+      method = RequestMethod.GET,
+      produces = {MediaType.ALL_VALUE},
+      consumes = {MediaType.APPLICATION_JSON_VALUE}
+  )
+  FinancialCondition getFinancialCondition();
 }
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatement.java b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialCondition.java
similarity index 51%
copy from api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatement.java
copy to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialCondition.java
index 8ed5678..8377ccd 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatement.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialCondition.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
 
 import org.hibernate.validator.constraints.NotEmpty;
 
@@ -22,20 +22,18 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
-public class IncomeStatement {
+public class FinancialCondition {
 
   @NotEmpty
   private String date;
   @NotEmpty
-  private List<IncomeStatementSection> incomeStatementSections = new ArrayList<>();
+  private List<FinancialConditionSection> financialConditionSections = new ArrayList<>();
   @NotNull
-  private BigDecimal grossProfit;
+  private BigDecimal totalAssets;
   @NotNull
-  private BigDecimal totalExpenses;
-  @NotNull
-  private BigDecimal netIncome;
+  private BigDecimal totalEquitiesAndLiabilities;
 
-  public IncomeStatement() {
+  public FinancialCondition() {
     super();
   }
 
@@ -47,35 +45,27 @@ public class IncomeStatement {
     this.date = date;
   }
 
-  public List<IncomeStatementSection> getIncomeStatementSections() {
-    return this.incomeStatementSections;
-  }
-
-  public BigDecimal getGrossProfit() {
-    return this.grossProfit;
-  }
-
-  public void setGrossProfit(final BigDecimal grossProfit) {
-    this.grossProfit = grossProfit;
+  public List<FinancialConditionSection> getFinancialConditionSections() {
+    return this.financialConditionSections;
   }
 
-  public BigDecimal getTotalExpenses() {
-    return this.totalExpenses;
+  public BigDecimal getTotalAssets() {
+    return this.totalAssets;
   }
 
-  public void setTotalExpenses(final BigDecimal totalExpenses) {
-    this.totalExpenses = totalExpenses;
+  public void setTotalAssets(final BigDecimal totalAssets) {
+    this.totalAssets = totalAssets;
   }
 
-  public BigDecimal getNetIncome() {
-    return this.netIncome;
+  public BigDecimal getTotalEquitiesAndLiabilities() {
+    return this.totalEquitiesAndLiabilities;
   }
 
-  public void setNetIncome(final BigDecimal netIncome) {
-    this.netIncome = netIncome;
+  public void setTotalEquitiesAndLiabilities(final BigDecimal totalEquitiesAndLiabilities)
{
+    this.totalEquitiesAndLiabilities = totalEquitiesAndLiabilities;
   }
 
-  public void add(final IncomeStatementSection incomeStatementSection) {
-    this.incomeStatementSections.add(incomeStatementSection);
+  public void add(final FinancialConditionSection financialConditionSection) {
+    this.financialConditionSections.add(financialConditionSection);
   }
 }
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementEntry.java
b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialConditionEntry.java
similarity index 89%
copy from api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementEntry.java
copy to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialConditionEntry.java
index 6ee34dc..9a06dcf 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementEntry.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialConditionEntry.java
@@ -13,21 +13,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
 
 import org.hibernate.validator.constraints.NotEmpty;
 
 import javax.validation.constraints.NotNull;
 import java.math.BigDecimal;
 
-public class IncomeStatementEntry {
+public class FinancialConditionEntry {
 
   @NotEmpty
   private String description;
   @NotNull
   private BigDecimal value;
 
-  public IncomeStatementEntry() {
+  public FinancialConditionEntry() {
     super();
   }
 
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementSection.java
b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialConditionSection.java
similarity index 69%
copy from api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementSection.java
copy to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialConditionSection.java
index cbe21f9..9ca3d69 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementSection.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/FinancialConditionSection.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
 
 import org.hibernate.validator.constraints.NotEmpty;
 
@@ -22,11 +22,12 @@ import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
-public class IncomeStatementSection {
+public class FinancialConditionSection {
 
   public enum Type {
-    INCOME,
-    EXPENSES
+    ASSET,
+    EQUITY,
+    LIABILITY
   }
 
   @NotEmpty
@@ -34,11 +35,11 @@ public class IncomeStatementSection {
   @NotEmpty
   private String description;
   @NotEmpty
-  private List<IncomeStatementEntry> incomeStatementEntries = new ArrayList<>();
+  private List<FinancialConditionEntry> financialConditionEntries = new ArrayList<>();
   @NotNull
   private BigDecimal subtotal = BigDecimal.ZERO;
 
-  public IncomeStatementSection() {
+  public FinancialConditionSection() {
     super();
   }
 
@@ -58,16 +59,16 @@ public class IncomeStatementSection {
     this.description = description;
   }
 
-  public List<IncomeStatementEntry> getIncomeStatementEntries() {
-    return this.incomeStatementEntries;
+  public List<FinancialConditionEntry> getFinancialConditionEntries() {
+    return this.financialConditionEntries;
   }
 
   public BigDecimal getSubtotal() {
     return this.subtotal;
   }
 
-  public void add(final IncomeStatementEntry incomeStatementEntry) {
-    this.incomeStatementEntries.add(incomeStatementEntry);
-    this.subtotal = this.subtotal.add(incomeStatementEntry.getValue());
+  public void add(final FinancialConditionEntry financialConditionEntry) {
+    this.financialConditionEntries.add(financialConditionEntry);
+    this.subtotal = this.subtotal.add(financialConditionEntry.getValue());
   }
 }
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatement.java b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatement.java
similarity index 97%
rename from api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatement.java
rename to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatement.java
index 8ed5678..0244f4e 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatement.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatement.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
 
 import org.hibernate.validator.constraints.NotEmpty;
 
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementEntry.java
b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatementEntry.java
similarity index 95%
rename from api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementEntry.java
rename to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatementEntry.java
index 6ee34dc..11f1b6f 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementEntry.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatementEntry.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
 
 import org.hibernate.validator.constraints.NotEmpty;
 
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementSection.java
b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatementSection.java
similarity index 96%
rename from api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementSection.java
rename to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatementSection.java
index cbe21f9..3f41c4a 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/IncomeStatementSection.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/IncomeStatementSection.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
 
 import org.hibernate.validator.constraints.NotEmpty;
 
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/TrialBalance.java b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/TrialBalance.java
similarity index 96%
rename from api/src/main/java/io/mifos/accounting/api/v1/domain/TrialBalance.java
rename to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/TrialBalance.java
index f942ccd..f73e9d7 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/TrialBalance.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/TrialBalance.java
@@ -13,7 +13,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/api/src/main/java/io/mifos/accounting/api/v1/domain/TrialBalanceEntry.java b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/TrialBalanceEntry.java
similarity index 91%
rename from api/src/main/java/io/mifos/accounting/api/v1/domain/TrialBalanceEntry.java
rename to api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/TrialBalanceEntry.java
index 3c11116..589fcb3 100644
--- a/api/src/main/java/io/mifos/accounting/api/v1/domain/TrialBalanceEntry.java
+++ b/api/src/main/java/io/mifos/accounting/api/v1/domain/financial/statement/TrialBalanceEntry.java
@@ -13,7 +13,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package io.mifos.accounting.api.v1.domain;
+package io.mifos.accounting.api.v1.domain.financial.statement;
+
+import io.mifos.accounting.api.v1.domain.Ledger;
 
 @SuppressWarnings("WeakerAccess")
 public class TrialBalanceEntry {
diff --git a/component-test/src/main/java/io/mifos/accounting/TestFinancialCondition.java
b/component-test/src/main/java/io/mifos/accounting/TestFinancialCondition.java
new file mode 100644
index 0000000..cc09071
--- /dev/null
+++ b/component-test/src/main/java/io/mifos/accounting/TestFinancialCondition.java
@@ -0,0 +1,142 @@
+/*
+ * 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.accounting;
+
+import io.mifos.accounting.api.v1.EventConstants;
+import io.mifos.accounting.api.v1.domain.Account;
+import io.mifos.accounting.api.v1.domain.AccountType;
+import io.mifos.accounting.api.v1.domain.JournalEntry;
+import io.mifos.accounting.api.v1.domain.Ledger;
+import io.mifos.accounting.api.v1.domain.financial.statement.FinancialCondition;
+import io.mifos.accounting.util.AccountGenerator;
+import io.mifos.accounting.util.JournalEntryGenerator;
+import io.mifos.accounting.util.LedgerGenerator;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.math.BigDecimal;
+
+public class TestFinancialCondition extends AbstractAccountingTest {
+
+  public TestFinancialCondition() {
+    super();
+  }
+
+  @Test
+  public void shouldReturnFinancialCondition() throws Exception {
+    this.fixtures();
+    this.sampleJournalEntries();
+
+    final BigDecimal totalAssets = BigDecimal.valueOf(250.00D);
+    final BigDecimal expectedEquitiesAndLiabilities = BigDecimal.valueOf(250.00D);
+
+    final FinancialCondition financialCondition = super.testSubject.getFinancialCondition();
+    Assert.assertTrue(financialCondition.getTotalAssets().compareTo(totalAssets) == 0);
+    Assert.assertTrue(financialCondition.getTotalEquitiesAndLiabilities().compareTo(expectedEquitiesAndLiabilities)
== 0);
+  }
+
+  private void fixtures() throws Exception {
+    final Ledger assetLedger = LedgerGenerator.createLedger("7000", AccountType.ASSET);
+    assetLedger.setName("Assets");
+    super.testSubject.createLedger(assetLedger);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, assetLedger.getIdentifier()));
+
+    final Ledger assetSubLedger7010 = LedgerGenerator.createLedger("7010", AccountType.ASSET);
+    assetSubLedger7010.setParentLedgerIdentifier(assetLedger.getParentLedgerIdentifier());
+    assetSubLedger7010.setName("Loans to Members");
+    super.testSubject.addSubLedger(assetLedger.getIdentifier(), assetSubLedger7010);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, assetSubLedger7010.getIdentifier()));
+
+    final Ledger assetSubLedger7020 = LedgerGenerator.createLedger("7020", AccountType.ASSET);
+    assetSubLedger7020.setParentLedgerIdentifier(assetLedger.getParentLedgerIdentifier());
+    assetSubLedger7020.setName("Lines of Credit to Members");
+    super.testSubject.addSubLedger(assetLedger.getIdentifier(), assetSubLedger7020);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, assetSubLedger7020.getIdentifier()));
+
+    final Account firstAssetAccount =
+        AccountGenerator.createAccount(assetSubLedger7010.getIdentifier(), "7011", AccountType.ASSET);
+    super.testSubject.createAccount(firstAssetAccount);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_ACCOUNT, firstAssetAccount.getIdentifier()));
+
+    final Account secondAssetAccount =
+        AccountGenerator.createAccount(assetSubLedger7020.getIdentifier(), "7021", AccountType.ASSET);
+    super.testSubject.createAccount(secondAssetAccount);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_ACCOUNT, secondAssetAccount.getIdentifier()));
+
+    final Ledger liabilityLedger = LedgerGenerator.createLedger("8000", AccountType.LIABILITY);
+    liabilityLedger.setName("Liabilities");
+    super.testSubject.createLedger(liabilityLedger);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, liabilityLedger.getIdentifier()));
+
+    final Ledger liabilitySubLedger8100 = LedgerGenerator.createLedger("8100", AccountType.LIABILITY);
+    liabilitySubLedger8100.setParentLedgerIdentifier(liabilityLedger.getParentLedgerIdentifier());
+    liabilitySubLedger8100.setName("Accounts Payable");
+    super.testSubject.addSubLedger(liabilityLedger.getIdentifier(), liabilitySubLedger8100);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, liabilitySubLedger8100.getIdentifier()));
+
+    final Ledger liabilitySubLedger8200 = LedgerGenerator.createLedger("8200", AccountType.LIABILITY);
+    liabilitySubLedger8200.setParentLedgerIdentifier(liabilityLedger.getParentLedgerIdentifier());
+    liabilitySubLedger8200.setName("Interest Payable");
+    super.testSubject.addSubLedger(liabilityLedger.getIdentifier(), liabilitySubLedger8200);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, liabilitySubLedger8200.getIdentifier()));
+
+    final Account firstLiabilityAccount =
+        AccountGenerator.createAccount(liabilitySubLedger8100.getIdentifier(), "8110", AccountType.LIABILITY);
+    super.testSubject.createAccount(firstLiabilityAccount);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_ACCOUNT, firstLiabilityAccount.getIdentifier()));
+
+    final Account secondLiabilityAccount =
+        AccountGenerator.createAccount(liabilitySubLedger8200.getIdentifier(), "8210", AccountType.LIABILITY);
+    super.testSubject.createAccount(secondLiabilityAccount);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_ACCOUNT, secondLiabilityAccount.getIdentifier()));
+
+    final Ledger equityLedger = LedgerGenerator.createLedger("9000", AccountType.EQUITY);
+    equityLedger.setName("Equities");
+    super.testSubject.createLedger(equityLedger);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, equityLedger.getIdentifier()));
+
+    final Ledger equitySubLedger9100 = LedgerGenerator.createLedger("9100", AccountType.EQUITY);
+    equitySubLedger9100.setParentLedgerIdentifier(equityLedger.getParentLedgerIdentifier());
+    equitySubLedger9100.setName("Member Savings");
+    super.testSubject.addSubLedger(equityLedger.getIdentifier(), equitySubLedger9100);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_LEDGER, equitySubLedger9100.getIdentifier()));
+
+    final Account firstEquityAccount =
+        AccountGenerator.createAccount(equitySubLedger9100.getIdentifier(), "9110", AccountType.EQUITY);
+    super.testSubject.createAccount(firstEquityAccount);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_ACCOUNT, firstEquityAccount.getIdentifier()));
+  }
+
+  private void sampleJournalEntries() throws Exception {
+    final JournalEntry firstTransaction =
+        JournalEntryGenerator
+            .createRandomJournalEntry("7011", "150.00", "8110", "150.00");
+    super.testSubject.createJournalEntry(firstTransaction);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_JOURNAL_ENTRY, firstTransaction.getTransactionIdentifier()));
+
+    final JournalEntry secondTransaction =
+        JournalEntryGenerator
+            .createRandomJournalEntry("7021", "100.00", "8210", "100.00");
+    super.testSubject.createJournalEntry(secondTransaction);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_JOURNAL_ENTRY, secondTransaction.getTransactionIdentifier()));
+
+    final JournalEntry thirdTransaction =
+        JournalEntryGenerator
+            .createRandomJournalEntry("8210", "50.00", "9110", "50.00");
+    super.testSubject.createJournalEntry(thirdTransaction);
+    Assert.assertTrue(super.eventRecorder.wait(EventConstants.POST_JOURNAL_ENTRY, thirdTransaction.getTransactionIdentifier()));
+  }
+}
diff --git a/component-test/src/main/java/io/mifos/accounting/TestIncomeStatement.java b/component-test/src/main/java/io/mifos/accounting/TestIncomeStatement.java
index 801c492..a27c4d8 100644
--- a/component-test/src/main/java/io/mifos/accounting/TestIncomeStatement.java
+++ b/component-test/src/main/java/io/mifos/accounting/TestIncomeStatement.java
@@ -18,9 +18,9 @@ package io.mifos.accounting;
 import io.mifos.accounting.api.v1.EventConstants;
 import io.mifos.accounting.api.v1.domain.Account;
 import io.mifos.accounting.api.v1.domain.AccountType;
-import io.mifos.accounting.api.v1.domain.IncomeStatement;
 import io.mifos.accounting.api.v1.domain.JournalEntry;
 import io.mifos.accounting.api.v1.domain.Ledger;
+import io.mifos.accounting.api.v1.domain.financial.statement.IncomeStatement;
 import io.mifos.accounting.util.AccountGenerator;
 import io.mifos.accounting.util.JournalEntryGenerator;
 import io.mifos.accounting.util.LedgerGenerator;
diff --git a/component-test/src/main/java/io/mifos/accounting/TestTrialBalance.java b/component-test/src/main/java/io/mifos/accounting/TestTrialBalance.java
index 17bbabd..f82d078 100644
--- a/component-test/src/main/java/io/mifos/accounting/TestTrialBalance.java
+++ b/component-test/src/main/java/io/mifos/accounting/TestTrialBalance.java
@@ -20,7 +20,7 @@ import io.mifos.accounting.api.v1.domain.Account;
 import io.mifos.accounting.api.v1.domain.AccountType;
 import io.mifos.accounting.api.v1.domain.JournalEntry;
 import io.mifos.accounting.api.v1.domain.Ledger;
-import io.mifos.accounting.api.v1.domain.TrialBalance;
+import io.mifos.accounting.api.v1.domain.financial.statement.TrialBalance;
 import io.mifos.accounting.util.AccountGenerator;
 import io.mifos.accounting.util.JournalEntryGenerator;
 import io.mifos.accounting.util.LedgerGenerator;
diff --git a/service/src/main/java/io/mifos/accounting/service/internal/command/handler/MigrationCommandHandler.java
b/service/src/main/java/io/mifos/accounting/service/internal/command/handler/MigrationCommandHandler.java
index ac3142b..5359fcc 100644
--- a/service/src/main/java/io/mifos/accounting/service/internal/command/handler/MigrationCommandHandler.java
+++ b/service/src/main/java/io/mifos/accounting/service/internal/command/handler/MigrationCommandHandler.java
@@ -21,9 +21,7 @@ import io.mifos.accounting.api.v1.EventConstants;
 import io.mifos.accounting.service.ServiceConstants;
 import io.mifos.accounting.service.internal.command.AddAmountToLedgerTotalCommand;
 import io.mifos.accounting.service.internal.command.InitializeServiceCommand;
-import io.mifos.accounting.service.internal.repository.AccountEntity;
 import io.mifos.accounting.service.internal.repository.AccountRepository;
-import io.mifos.accounting.service.internal.service.AccountService;
 import io.mifos.core.cassandra.core.CassandraJourney;
 import io.mifos.core.cassandra.core.CassandraJourneyFactory;
 import io.mifos.core.cassandra.core.CassandraJourneyRoute;
@@ -45,7 +43,6 @@ import javax.sql.DataSource;
 import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.List;
-import java.util.stream.Stream;
 
 @SuppressWarnings({
     "unused"
diff --git a/service/src/main/java/io/mifos/accounting/service/internal/service/FinancialConditionService.java
b/service/src/main/java/io/mifos/accounting/service/internal/service/FinancialConditionService.java
new file mode 100644
index 0000000..db03761
--- /dev/null
+++ b/service/src/main/java/io/mifos/accounting/service/internal/service/FinancialConditionService.java
@@ -0,0 +1,90 @@
+/*
+ * 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.accounting.service.internal.service;
+
+import io.mifos.accounting.api.v1.domain.AccountType;
+import io.mifos.accounting.api.v1.domain.financial.statement.FinancialCondition;
+import io.mifos.accounting.api.v1.domain.financial.statement.FinancialConditionEntry;
+import io.mifos.accounting.api.v1.domain.financial.statement.FinancialConditionSection;
+import io.mifos.accounting.service.internal.repository.LedgerRepository;
+import io.mifos.core.lang.DateConverter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.time.Clock;
+import java.time.LocalDateTime;
+import java.util.EnumSet;
+
+@Service
+public class FinancialConditionService {
+
+  private final LedgerRepository ledgerRepository;
+
+  @Autowired
+  public FinancialConditionService(final LedgerRepository ledgerRepository) {
+    super();
+    this.ledgerRepository = ledgerRepository;
+  }
+
+  public FinancialCondition getFinancialCondition() {
+    final FinancialCondition financialCondition = new FinancialCondition();
+    financialCondition.setDate(DateConverter.toIsoString(LocalDateTime.now(Clock.systemUTC())));
+
+    this.createFinancialConditionSection(financialCondition, AccountType.ASSET, FinancialConditionSection.Type.ASSET);
+    this.createFinancialConditionSection(financialCondition, AccountType.EQUITY, FinancialConditionSection.Type.EQUITY);
+    this.createFinancialConditionSection(financialCondition, AccountType.LIABILITY, FinancialConditionSection.Type.LIABILITY);
+
+    financialCondition.setTotalAssets(
+        this.calculateTotal(financialCondition,
+            EnumSet.of(FinancialConditionSection.Type.ASSET))
+    );
+    financialCondition.setTotalEquitiesAndLiabilities(
+        this.calculateTotal(financialCondition,
+            EnumSet.of(FinancialConditionSection.Type.EQUITY, FinancialConditionSection.Type.LIABILITY))
+    );
+
+    return financialCondition;
+  }
+
+  private void createFinancialConditionSection(final FinancialCondition financialCondition,
final AccountType accountType,
+                                               final FinancialConditionSection.Type financialConditionType)
{
+    this.ledgerRepository.findByParentLedgerIsNullAndType(accountType.name()).forEach(ledgerEntity
-> {
+      final FinancialConditionSection financialConditionSection = new FinancialConditionSection();
+      financialConditionSection.setType(financialConditionType.name());
+      financialConditionSection.setDescription(ledgerEntity.getName());
+      financialCondition.add(financialConditionSection);
+
+      this.ledgerRepository.findByParentLedgerOrderByIdentifier(ledgerEntity).forEach(subLedgerEntity
-> {
+        final FinancialConditionEntry financialConditionEntry = new FinancialConditionEntry();
+        financialConditionEntry.setDescription(subLedgerEntity.getName());
+        final BigDecimal totalValue = subLedgerEntity.getTotalValue() != null ? subLedgerEntity.getTotalValue()
: BigDecimal.ZERO;
+        financialConditionEntry.setValue(totalValue);
+        financialConditionSection.add(financialConditionEntry);
+      });
+    });
+  }
+
+  private BigDecimal calculateTotal(final FinancialCondition financialCondition,
+                                    final EnumSet<FinancialConditionSection.Type> financialConditionTypes)
{
+    return financialCondition.getFinancialConditionSections()
+        .stream()
+        .filter(financialConditionSection ->
+            financialConditionTypes.contains(FinancialConditionSection.Type.valueOf(financialConditionSection.getType())))
+        .map(FinancialConditionSection::getSubtotal)
+        .reduce(BigDecimal.ZERO, BigDecimal::add);
+  }
+}
diff --git a/service/src/main/java/io/mifos/accounting/service/internal/service/IncomeStatementService.java
b/service/src/main/java/io/mifos/accounting/service/internal/service/IncomeStatementService.java
index 6ac379c..39732c6 100644
--- a/service/src/main/java/io/mifos/accounting/service/internal/service/IncomeStatementService.java
+++ b/service/src/main/java/io/mifos/accounting/service/internal/service/IncomeStatementService.java
@@ -16,9 +16,9 @@
 package io.mifos.accounting.service.internal.service;
 
 import io.mifos.accounting.api.v1.domain.AccountType;
-import io.mifos.accounting.api.v1.domain.IncomeStatement;
-import io.mifos.accounting.api.v1.domain.IncomeStatementEntry;
-import io.mifos.accounting.api.v1.domain.IncomeStatementSection;
+import io.mifos.accounting.api.v1.domain.financial.statement.IncomeStatement;
+import io.mifos.accounting.api.v1.domain.financial.statement.IncomeStatementEntry;
+import io.mifos.accounting.api.v1.domain.financial.statement.IncomeStatementSection;
 import io.mifos.accounting.service.internal.repository.LedgerRepository;
 import io.mifos.core.lang.DateConverter;
 import org.springframework.beans.factory.annotation.Autowired;
diff --git a/service/src/main/java/io/mifos/accounting/service/internal/service/TrialBalanceService.java
b/service/src/main/java/io/mifos/accounting/service/internal/service/TrialBalanceService.java
index efd14ab..e2fec3c 100644
--- a/service/src/main/java/io/mifos/accounting/service/internal/service/TrialBalanceService.java
+++ b/service/src/main/java/io/mifos/accounting/service/internal/service/TrialBalanceService.java
@@ -16,8 +16,8 @@
 package io.mifos.accounting.service.internal.service;
 
 import io.mifos.accounting.api.v1.domain.AccountType;
-import io.mifos.accounting.api.v1.domain.TrialBalance;
-import io.mifos.accounting.api.v1.domain.TrialBalanceEntry;
+import io.mifos.accounting.api.v1.domain.financial.statement.TrialBalance;
+import io.mifos.accounting.api.v1.domain.financial.statement.TrialBalanceEntry;
 import io.mifos.accounting.service.internal.mapper.LedgerMapper;
 import io.mifos.accounting.service.internal.repository.AccountRepository;
 import io.mifos.accounting.service.internal.repository.LedgerRepository;
diff --git a/service/src/main/java/io/mifos/accounting/service/rest/IncomeStatementController.java
b/service/src/main/java/io/mifos/accounting/service/rest/FinancialConditionController.java
similarity index 69%
copy from service/src/main/java/io/mifos/accounting/service/rest/IncomeStatementController.java
copy to service/src/main/java/io/mifos/accounting/service/rest/FinancialConditionController.java
index fb25d73..eabb7fd 100644
--- a/service/src/main/java/io/mifos/accounting/service/rest/IncomeStatementController.java
+++ b/service/src/main/java/io/mifos/accounting/service/rest/FinancialConditionController.java
@@ -16,8 +16,8 @@
 package io.mifos.accounting.service.rest;
 
 import io.mifos.accounting.api.v1.PermittableGroupIds;
-import io.mifos.accounting.api.v1.domain.IncomeStatement;
-import io.mifos.accounting.service.internal.service.IncomeStatementService;
+import io.mifos.accounting.api.v1.domain.financial.statement.FinancialCondition;
+import io.mifos.accounting.service.internal.service.FinancialConditionService;
 import io.mifos.anubis.annotation.AcceptedTokenType;
 import io.mifos.anubis.annotation.Permittable;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,25 +29,25 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
 @RestController
-@RequestMapping("/incomestatement")
-public class IncomeStatementController {
+@RequestMapping("/financialcondition")
+public class FinancialConditionController {
 
-  private final IncomeStatementService incomeStatementService;
+  private final FinancialConditionService financialConditionService;
 
   @Autowired
-  public IncomeStatementController(final IncomeStatementService incomeStatementService) {
+  public FinancialConditionController(final FinancialConditionService financialConditionService)
{
     super();
-    this.incomeStatementService = incomeStatementService;
+    this.financialConditionService = financialConditionService;
   }
 
-  @Permittable(value = AcceptedTokenType.TENANT, groupId = PermittableGroupIds.THOTH_INCOME_STMT)
+  @Permittable(value = AcceptedTokenType.TENANT, groupId = PermittableGroupIds.THOTH_FIN_CONDITION)
   @RequestMapping(
       method = RequestMethod.GET,
       produces = {MediaType.APPLICATION_JSON_VALUE},
       consumes = {MediaType.ALL_VALUE}
   )
   @ResponseBody
-  public ResponseEntity<IncomeStatement> getIncomeStatement() {
-    return ResponseEntity.ok(this.incomeStatementService.getIncomeStatement());
+  public ResponseEntity<FinancialCondition> getFinancialCondition() {
+    return ResponseEntity.ok(this.financialConditionService.getFinancialCondition());
   }
 }
diff --git a/service/src/main/java/io/mifos/accounting/service/rest/IncomeStatementController.java
b/service/src/main/java/io/mifos/accounting/service/rest/IncomeStatementController.java
index fb25d73..239b9e3 100644
--- a/service/src/main/java/io/mifos/accounting/service/rest/IncomeStatementController.java
+++ b/service/src/main/java/io/mifos/accounting/service/rest/IncomeStatementController.java
@@ -16,7 +16,7 @@
 package io.mifos.accounting.service.rest;
 
 import io.mifos.accounting.api.v1.PermittableGroupIds;
-import io.mifos.accounting.api.v1.domain.IncomeStatement;
+import io.mifos.accounting.api.v1.domain.financial.statement.IncomeStatement;
 import io.mifos.accounting.service.internal.service.IncomeStatementService;
 import io.mifos.anubis.annotation.AcceptedTokenType;
 import io.mifos.anubis.annotation.Permittable;
diff --git a/service/src/main/java/io/mifos/accounting/service/rest/TrialBalanceController.java
b/service/src/main/java/io/mifos/accounting/service/rest/TrialBalanceController.java
index 83e9ca6..c6037ff 100644
--- a/service/src/main/java/io/mifos/accounting/service/rest/TrialBalanceController.java
+++ b/service/src/main/java/io/mifos/accounting/service/rest/TrialBalanceController.java
@@ -16,7 +16,7 @@
 package io.mifos.accounting.service.rest;
 
 import io.mifos.accounting.api.v1.PermittableGroupIds;
-import io.mifos.accounting.api.v1.domain.TrialBalance;
+import io.mifos.accounting.api.v1.domain.financial.statement.TrialBalance;
 import io.mifos.accounting.service.internal.service.TrialBalanceService;
 import io.mifos.anubis.annotation.AcceptedTokenType;
 import io.mifos.anubis.annotation.Permittable;

-- 
To stop receiving notification emails like this one, please contact
myrle@apache.org.

Mime
View raw message