svn commit: r1767764 [4/33] - in /ofbiz/trunk: applications/accounting/groovyScripts/admin/ applications/accounting/groovyScripts/ap/invoices/ applications/accounting/groovyScripts/ar/ applications/accounting/groovyScripts/chartofaccounts/ applications...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1767764 [4/33] - in /ofbiz/trunk: applications/accounting/groovyScripts/admin/ applications/accounting/groovyScripts/ap/invoices/ applications/accounting/groovyScripts/ar/ applications/accounting/groovyScripts/chartofaccounts/ applications...

Arun Patidar-4
Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeCashFlowStatement.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeCashFlowStatement.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeCashFlowStatement.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeCashFlowStatement.groovy Wed Nov  2 19:09:13 2016
@@ -17,71 +17,71 @@
  * under the License.
  */
 
-import org.apache.ofbiz.base.util.UtilMisc;
+import org.apache.ofbiz.base.util.UtilMisc
 
-openingCashBalanceMap = [:];
-openingCashBalanceList = [];
+openingCashBalanceMap = [:]
+openingCashBalanceList = []
 openingCashBalanceList1.each { accountBalance ->
-    openingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    openingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 openingCashBalanceList2.each { accountBalance ->
-    Map openingCashAccount = (Map)openingCashBalanceMap.get(accountBalance.glAccountId);
+    Map openingCashAccount = (Map)openingCashBalanceMap.get(accountBalance.glAccountId)
     if (!openingCashAccount) {
-        openingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        openingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO))
     } else {
-        openingCashAccount.put("balance2", accountBalance.balance);
+        openingCashAccount.put("balance2", accountBalance.balance)
     }
 }
-openingCashBalanceList = UtilMisc.sortMaps(openingCashBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.openingCashBalanceList = openingCashBalanceList;
+openingCashBalanceList = UtilMisc.sortMaps(openingCashBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.openingCashBalanceList = openingCashBalanceList
 
-periodCashBalanceMap = [:];
-periodCashBalanceList = [];
+periodCashBalanceMap = [:]
+periodCashBalanceList = []
 periodCashBalanceList1.each { accountBalance ->
-    periodCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO, "D1", accountBalance.D, "C1", accountBalance.C, "D2", BigDecimal.ZERO, "C2", BigDecimal.ZERO));
+    periodCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO, "D1", accountBalance.D, "C1", accountBalance.C, "D2", BigDecimal.ZERO, "C2", BigDecimal.ZERO))
 }
 periodCashBalanceList2.each { accountBalance ->
-    Map periodCashAccount = (Map)periodCashBalanceMap.get(accountBalance.glAccountId);
+    Map periodCashAccount = (Map)periodCashBalanceMap.get(accountBalance.glAccountId)
     if (!periodCashAccount) {
-        periodCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO, "D2", accountBalance.D, "C2", accountBalance.C, "D1", BigDecimal.ZERO, "C1", BigDecimal.ZERO));
+        periodCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO, "D2", accountBalance.D, "C2", accountBalance.C, "D1", BigDecimal.ZERO, "C1", BigDecimal.ZERO))
     } else {
-        periodCashAccount.put("balance2", accountBalance.balance);
-        periodCashAccount.put("D2", accountBalance.D);
-        periodCashAccount.put("C2", accountBalance.C);
+        periodCashAccount.put("balance2", accountBalance.balance)
+        periodCashAccount.put("D2", accountBalance.D)
+        periodCashAccount.put("C2", accountBalance.C)
     }
 }
-periodCashBalanceList = UtilMisc.sortMaps(periodCashBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
+periodCashBalanceList = UtilMisc.sortMaps(periodCashBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
 
-context.periodCashBalanceList = periodCashBalanceList;
-closingCashBalanceMap = [:];
-closingCashBalanceList = [];
+context.periodCashBalanceList = periodCashBalanceList
+closingCashBalanceMap = [:]
+closingCashBalanceList = []
 closingCashBalanceList1.each { accountBalance ->
-    closingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    closingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 closingCashBalanceList2.each { accountBalance ->
-    Map closingCashAccount = (Map)closingCashBalanceMap.get(accountBalance.glAccountId);
+    Map closingCashAccount = (Map)closingCashBalanceMap.get(accountBalance.glAccountId)
     if (!closingCashAccount) {
-        closingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        closingCashBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO))
     } else {
-        closingCashAccount.put("balance2", accountBalance.balance);
+        closingCashAccount.put("balance2", accountBalance.balance)
     }
 }
-closingCashBalanceList = UtilMisc.sortMaps(closingCashBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.closingCashBalanceList = closingCashBalanceList;
+closingCashBalanceList = UtilMisc.sortMaps(closingCashBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.closingCashBalanceList = closingCashBalanceList
 
-balanceTotalMap = [:];
-cashFlowBalanceTotalList = [];
+balanceTotalMap = [:]
+cashFlowBalanceTotalList = []
 cashFlowBalanceTotalList1.each { accountBalance ->
-    balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 cashFlowBalanceTotalList2.each { accountBalance ->
-    Map cashFlowBalanceAccount = (Map)balanceTotalMap.get(accountBalance.totalName);
+    Map cashFlowBalanceAccount = (Map)balanceTotalMap.get(accountBalance.totalName)
     if (!cashFlowBalanceAccount) {
-        balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO))
     } else {
-        cashFlowBalanceAccount.put("balance2", accountBalance.balance);
+        cashFlowBalanceAccount.put("balance2", accountBalance.balance)
     }
 }
-cashFlowBalanceTotalList = balanceTotalMap.values().asList();
-context.cashFlowBalanceTotalList = cashFlowBalanceTotalList;
+cashFlowBalanceTotalList = balanceTotalMap.values().asList()
+context.cashFlowBalanceTotalList = cashFlowBalanceTotalList
 

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeIncomeStatement.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeIncomeStatement.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeIncomeStatement.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeIncomeStatement.groovy Wed Nov  2 19:09:13 2016
@@ -17,68 +17,68 @@
  * under the License.
  */
 
-import org.apache.ofbiz.base.util.UtilMisc;
+import org.apache.ofbiz.base.util.UtilMisc
 
-revenueAccountBalanceMap = [:];
-revenueAccountBalanceList = [];
+revenueAccountBalanceMap = [:]
+revenueAccountBalanceList = []
 revenueAccountBalanceList1.each { accountBalance ->
-    revenueAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    revenueAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 revenueAccountBalanceList2.each { accountBalance ->
-    Map assetAccount = (Map)revenueAccountBalanceMap.get(accountBalance.glAccountId);
+    Map assetAccount = (Map)revenueAccountBalanceMap.get(accountBalance.glAccountId)
     if (!assetAccount) {
-        revenueAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        revenueAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO))
     } else {
-        assetAccount.put("balance2", accountBalance.balance);
+        assetAccount.put("balance2", accountBalance.balance)
     }
 }
-revenueAccountBalanceList = UtilMisc.sortMaps(revenueAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.revenueAccountBalanceList = revenueAccountBalanceList;
+revenueAccountBalanceList = UtilMisc.sortMaps(revenueAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.revenueAccountBalanceList = revenueAccountBalanceList
 
-expenseAccountBalanceMap = [:];
-expenseAccountBalanceList = [];
+expenseAccountBalanceMap = [:]
+expenseAccountBalanceList = []
 expenseAccountBalanceList1.each { accountBalance ->
-    expenseAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    expenseAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 expenseAccountBalanceList2.each { accountBalance ->
-    Map assetAccount = (Map)expenseAccountBalanceMap.get(accountBalance.glAccountId);
+    Map assetAccount = (Map)expenseAccountBalanceMap.get(accountBalance.glAccountId)
     if (!assetAccount) {
-        expenseAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        expenseAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO))
     } else {
-        assetAccount.put("balance2", accountBalance.balance);
+        assetAccount.put("balance2", accountBalance.balance)
     }
 }
-expenseAccountBalanceList = UtilMisc.sortMaps(expenseAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.expenseAccountBalanceList = expenseAccountBalanceList;
+expenseAccountBalanceList = UtilMisc.sortMaps(expenseAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.expenseAccountBalanceList = expenseAccountBalanceList
 
-incomeAccountBalanceMap = [:];
-incomeAccountBalanceList = [];
+incomeAccountBalanceMap = [:]
+incomeAccountBalanceList = []
 incomeAccountBalanceList1.each { accountBalance ->
-    incomeAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    incomeAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 incomeAccountBalanceList2.each { accountBalance ->
-    Map assetAccount = (Map)incomeAccountBalanceMap.get(accountBalance.glAccountId);
+    Map assetAccount = (Map)incomeAccountBalanceMap.get(accountBalance.glAccountId)
     if (!assetAccount) {
-        incomeAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        incomeAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO))
     } else {
-        assetAccount.put("balance2", accountBalance.balance);
+        assetAccount.put("balance2", accountBalance.balance)
     }
 }
-incomeAccountBalanceList = UtilMisc.sortMaps(incomeAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.incomeAccountBalanceList = incomeAccountBalanceList;
+incomeAccountBalanceList = UtilMisc.sortMaps(incomeAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.incomeAccountBalanceList = incomeAccountBalanceList
 
-balanceTotalMap = [:];
-balanceTotalList = [];
+balanceTotalMap = [:]
+balanceTotalList = []
 balanceTotalList1.each { accountBalance ->
-    balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 balanceTotalList2.each { accountBalance ->
-    Map assetAccount = (Map)balanceTotalMap.get(accountBalance.totalName);
+    Map assetAccount = (Map)balanceTotalMap.get(accountBalance.totalName)
     if (!assetAccount) {
-        balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        balanceTotalMap.put(accountBalance.totalName, UtilMisc.toMap("totalName", accountBalance.totalName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO))
     } else {
-        assetAccount.put("balance2", accountBalance.balance);
+        assetAccount.put("balance2", accountBalance.balance)
     }
 }
-balanceTotalList = balanceTotalMap.values().asList();
-context.balanceTotalList = balanceTotalList;
+balanceTotalList = balanceTotalMap.values().asList()
+context.balanceTotalList = balanceTotalList

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/CostCenters.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/CostCenters.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/CostCenters.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/CostCenters.groovy Wed Nov  2 19:09:13 2016
@@ -24,52 +24,52 @@ import org.apache.ofbiz.entity.condition
 import org.apache.ofbiz.entity.condition.EntityOperator
 
 if (!fromDate) {
-    return;
+    return
 }
 if (!thruDate) {
-    thruDate = UtilDateTime.nowTimestamp();
+    thruDate = UtilDateTime.nowTimestamp()
 }
 if (!parameters.glFiscalTypeId) {
-    parameters.glFiscalTypeId = "ACTUAL";
+    parameters.glFiscalTypeId = "ACTUAL"
 }
 
 // POSTED
 // Posted transactions totals and grand totals
-postedTotalDebit = BigDecimal.ZERO;
-postedTotalCredit = BigDecimal.ZERO;
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, parameters.glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND);
-List postedTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andCond).orderBy("glAccountId").queryList();
+postedTotalDebit = BigDecimal.ZERO
+postedTotalCredit = BigDecimal.ZERO
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, parameters.glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate))
+andCond = EntityCondition.makeCondition(andExprs, EntityOperator.AND)
+List postedTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andCond).orderBy("glAccountId").queryList()
 if (postedTransactionTotals) {
-    glAccountCategories = from("GlAccountCategory").where("glAccountCategoryTypeId", "COST_CENTER").orderBy("glAccountCategoryId").queryList();
-    context.glAccountCategories = glAccountCategories;
+    glAccountCategories = from("GlAccountCategory").where("glAccountCategoryTypeId", "COST_CENTER").orderBy("glAccountCategoryId").queryList()
+    context.glAccountCategories = glAccountCategories
     Map postedTransactionTotalsMap = [:]
     postedTransactionTotals.each { postedTransactionTotal ->
-        Map accountMap = (Map)postedTransactionTotalsMap.get(postedTransactionTotal.glAccountId);
+        Map accountMap = (Map)postedTransactionTotalsMap.get(postedTransactionTotal.glAccountId)
         if (!accountMap) {
-            accountMap = UtilMisc.makeMapWritable(postedTransactionTotal);
-            accountMap.put("D", BigDecimal.ZERO);
-            accountMap.put("C", BigDecimal.ZERO);
+            accountMap = UtilMisc.makeMapWritable(postedTransactionTotal)
+            accountMap.put("D", BigDecimal.ZERO)
+            accountMap.put("C", BigDecimal.ZERO)
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, postedTransactionTotal.debitCreditFlag, postedTransactionTotal.amount);
-        postedTransactionTotalsMap.put(postedTransactionTotal.glAccountId, accountMap);
-        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
-        BigDecimal balance = debitAmount.subtract(creditAmount);
-        accountMap.put("balance", balance);
+        UtilMisc.addToBigDecimalInMap(accountMap, postedTransactionTotal.debitCreditFlag, postedTransactionTotal.amount)
+        postedTransactionTotalsMap.put(postedTransactionTotal.glAccountId, accountMap)
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
+        BigDecimal balance = debitAmount.subtract(creditAmount)
+        accountMap.put("balance", balance)
         glAccountCategories.each { glAccountCategory ->
-            glAccountCategoryMember = from("GlAccountCategoryMember").where("glAccountCategoryId", glAccountCategory.glAccountCategoryId, "glAccountId", postedTransactionTotal.glAccountId).orderBy("glAccountCategoryId").filterByDate().queryFirst();
+            glAccountCategoryMember = from("GlAccountCategoryMember").where("glAccountCategoryId", glAccountCategory.glAccountCategoryId, "glAccountId", postedTransactionTotal.glAccountId).orderBy("glAccountCategoryId").filterByDate().queryFirst()
             if (glAccountCategoryMember) {
-                BigDecimal glAccountCategorySharePercentage = glAccountCategoryMember.amountPercentage;
+                BigDecimal glAccountCategorySharePercentage = glAccountCategoryMember.amountPercentage
                 if (glAccountCategorySharePercentage && glAccountCategorySharePercentage != BigDecimal.ZERO ) {
-                    glAccountCategoryShareFraction = glAccountCategorySharePercentage.divide(new BigDecimal("100.00"));
-                    BigDecimal glAccountCategoryShare = balance.multiply(glAccountCategoryShareFraction);
-                    accountMap.put(glAccountCategory.glAccountCategoryId,glAccountCategoryShare);
+                    glAccountCategoryShareFraction = glAccountCategorySharePercentage.divide(new BigDecimal("100.00"))
+                    BigDecimal glAccountCategoryShare = balance.multiply(glAccountCategoryShareFraction)
+                    accountMap.put(glAccountCategory.glAccountCategoryId,glAccountCategoryShare)
                 }
             }
         }

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/GlAccountTrialBalance.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/GlAccountTrialBalance.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/GlAccountTrialBalance.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/GlAccountTrialBalance.groovy Wed Nov  2 19:09:13 2016
@@ -25,79 +25,79 @@ import org.apache.ofbiz.base.util.UtilVa
 import java.sql.Timestamp
 
 if (parameters.get('ApplicationDecorator|organizationPartyId')) {
-    onlyIncludePeriodTypeIdList = [];
-    onlyIncludePeriodTypeIdList.add("FISCAL_YEAR");
-    customTimePeriodResults = runService('findCustomTimePeriods', [findDate : UtilDateTime.nowTimestamp(), organizationPartyId : parameters.get('ApplicationDecorator|organizationPartyId'), onlyIncludePeriodTypeIdList : onlyIncludePeriodTypeIdList, userLogin : userLogin]);
-    customTimePeriodList = customTimePeriodResults.customTimePeriodList;
+    onlyIncludePeriodTypeIdList = []
+    onlyIncludePeriodTypeIdList.add("FISCAL_YEAR")
+    customTimePeriodResults = runService('findCustomTimePeriods', [findDate : UtilDateTime.nowTimestamp(), organizationPartyId : parameters.get('ApplicationDecorator|organizationPartyId'), onlyIncludePeriodTypeIdList : onlyIncludePeriodTypeIdList, userLogin : userLogin])
+    customTimePeriodList = customTimePeriodResults.customTimePeriodList
     if (UtilValidate.isNotEmpty(customTimePeriodList)) {
-        context.timePeriod = customTimePeriodList.first().customTimePeriodId;
+        context.timePeriod = customTimePeriodList.first().customTimePeriodId
     }
-    decimals = UtilNumber.getBigDecimalScale("ledger.decimals");
-    rounding = UtilNumber.getBigDecimalRoundingMode("ledger.rounding");
-    context.currentOrganization = from("PartyNameView").where("partyId", parameters.get('ApplicationDecorator|organizationPartyId')).queryOne();
+    decimals = UtilNumber.getBigDecimalScale("ledger.decimals")
+    rounding = UtilNumber.getBigDecimalRoundingMode("ledger.rounding")
+    context.currentOrganization = from("PartyNameView").where("partyId", parameters.get('ApplicationDecorator|organizationPartyId')).queryOne()
     if (parameters.glAccountId) {
-        glAccount = from("GlAccount").where("glAccountId", parameters.glAccountId).queryOne();
-        isDebitAccount = UtilAccounting.isDebitAccount(glAccount);
-        context.isDebitAccount = isDebitAccount;
-        context.glAccount = glAccount;
+        glAccount = from("GlAccount").where("glAccountId", parameters.glAccountId).queryOne()
+        isDebitAccount = UtilAccounting.isDebitAccount(glAccount)
+        context.isDebitAccount = isDebitAccount
+        context.glAccount = glAccount
     }
 
-    currentTimePeriod = null;
-    BigDecimal balanceOfTheAcctgForYear = BigDecimal.ZERO;
+    currentTimePeriod = null
+    BigDecimal balanceOfTheAcctgForYear = BigDecimal.ZERO
 
     if (parameters.timePeriod) {
-        currentTimePeriod = from("CustomTimePeriod").where("customTimePeriodId", parameters.timePeriod).queryOne();
-        previousTimePeriodResult = runService('getPreviousTimePeriod', [customTimePeriodId : parameters.timePeriod, userLogin : userLogin]);
-        previousTimePeriod = previousTimePeriodResult.previousTimePeriod;
+        currentTimePeriod = from("CustomTimePeriod").where("customTimePeriodId", parameters.timePeriod).queryOne()
+        previousTimePeriodResult = runService('getPreviousTimePeriod', [customTimePeriodId : parameters.timePeriod, userLogin : userLogin])
+        previousTimePeriod = previousTimePeriodResult.previousTimePeriod
         if (UtilValidate.isNotEmpty(previousTimePeriod)) {
-            glAccountHistory = from("GlAccountHistory").where("customTimePeriodId", previousTimePeriod.customTimePeriodId, "glAccountId", parameters.glAccountId, "organizationPartyId", parameters.get('ApplicationDecorator|organizationPartyId')).queryOne();
+            glAccountHistory = from("GlAccountHistory").where("customTimePeriodId", previousTimePeriod.customTimePeriodId, "glAccountId", parameters.glAccountId, "organizationPartyId", parameters.get('ApplicationDecorator|organizationPartyId')).queryOne()
             if (glAccountHistory && glAccountHistory.endingBalance != null) {
-                context.openingBalance = glAccountHistory.endingBalance;
-                balanceOfTheAcctgForYear = glAccountHistory.endingBalance;
+                context.openingBalance = glAccountHistory.endingBalance
+                balanceOfTheAcctgForYear = glAccountHistory.endingBalance
             } else {
-                context.openingBalance = BigDecimal.ZERO;
+                context.openingBalance = BigDecimal.ZERO
             }
         }
     }
 
     if (currentTimePeriod) {
-        context.currentTimePeriod = currentTimePeriod;
-        customTimePeriodStartDate = UtilDateTime.getMonthStart(UtilDateTime.toTimestamp(currentTimePeriod.fromDate), timeZone, locale);
-        customTimePeriodEndDate = UtilDateTime.getMonthEnd(UtilDateTime.toTimestamp(currentTimePeriod.fromDate), timeZone, locale);
-
-        Calendar calendarTimePeriodStartDate = UtilDateTime.toCalendar(customTimePeriodStartDate);
-        glAcctgTrialBalanceList = [];
-        BigDecimal totalOfYearToDateDebit = BigDecimal.ZERO;
-        BigDecimal totalOfYearToDateCredit = BigDecimal.ZERO;
-        isPosted = parameters.isPosted;
+        context.currentTimePeriod = currentTimePeriod
+        customTimePeriodStartDate = UtilDateTime.getMonthStart(UtilDateTime.toTimestamp(currentTimePeriod.fromDate), timeZone, locale)
+        customTimePeriodEndDate = UtilDateTime.getMonthEnd(UtilDateTime.toTimestamp(currentTimePeriod.fromDate), timeZone, locale)
+
+        Calendar calendarTimePeriodStartDate = UtilDateTime.toCalendar(customTimePeriodStartDate)
+        glAcctgTrialBalanceList = []
+        BigDecimal totalOfYearToDateDebit = BigDecimal.ZERO
+        BigDecimal totalOfYearToDateCredit = BigDecimal.ZERO
+        isPosted = parameters.isPosted
 
         while (customTimePeriodEndDate <= currentTimePeriod.thruDate) {
             if ("ALL".equals(isPosted)) {
-                isPosted = "";
+                isPosted = ""
             }
             acctgTransEntriesAndTransTotal = runService('getAcctgTransEntriesAndTransTotal',
-                    [customTimePeriodStartDate : customTimePeriodStartDate, customTimePeriodEndDate : customTimePeriodEndDate, organizationPartyId : parameters.get('ApplicationDecorator|organizationPartyId'), glAccountId : parameters.glAccountId, isPosted : isPosted, userLogin : userLogin]);
-            totalOfYearToDateDebit = totalOfYearToDateDebit + acctgTransEntriesAndTransTotal.debitTotal;
-            acctgTransEntriesAndTransTotal.totalOfYearToDateDebit = totalOfYearToDateDebit.setScale(decimals, rounding);
-            totalOfYearToDateCredit = totalOfYearToDateCredit + acctgTransEntriesAndTransTotal.creditTotal;
-            acctgTransEntriesAndTransTotal.totalOfYearToDateCredit = totalOfYearToDateCredit.setScale(decimals, rounding);
+                    [customTimePeriodStartDate : customTimePeriodStartDate, customTimePeriodEndDate : customTimePeriodEndDate, organizationPartyId : parameters.get('ApplicationDecorator|organizationPartyId'), glAccountId : parameters.glAccountId, isPosted : isPosted, userLogin : userLogin])
+            totalOfYearToDateDebit = totalOfYearToDateDebit + acctgTransEntriesAndTransTotal.debitTotal
+            acctgTransEntriesAndTransTotal.totalOfYearToDateDebit = totalOfYearToDateDebit.setScale(decimals, rounding)
+            totalOfYearToDateCredit = totalOfYearToDateCredit + acctgTransEntriesAndTransTotal.creditTotal
+            acctgTransEntriesAndTransTotal.totalOfYearToDateCredit = totalOfYearToDateCredit.setScale(decimals, rounding)
 
             if (isDebitAccount) {
-                acctgTransEntriesAndTransTotal.balance = acctgTransEntriesAndTransTotal.debitCreditDifference;
+                acctgTransEntriesAndTransTotal.balance = acctgTransEntriesAndTransTotal.debitCreditDifference
             } else {
-                acctgTransEntriesAndTransTotal.balance = -1 * acctgTransEntriesAndTransTotal.debitCreditDifference;
+                acctgTransEntriesAndTransTotal.balance = -1 * acctgTransEntriesAndTransTotal.debitCreditDifference
             }
-            balanceOfTheAcctgForYear = balanceOfTheAcctgForYear + acctgTransEntriesAndTransTotal.balance;
-            acctgTransEntriesAndTransTotal.balanceOfTheAcctgForYear = balanceOfTheAcctgForYear.setScale(decimals, rounding);
+            balanceOfTheAcctgForYear = balanceOfTheAcctgForYear + acctgTransEntriesAndTransTotal.balance
+            acctgTransEntriesAndTransTotal.balanceOfTheAcctgForYear = balanceOfTheAcctgForYear.setScale(decimals, rounding)
 
-            glAcctgTrialBalanceList.add(acctgTransEntriesAndTransTotal);
+            glAcctgTrialBalanceList.add(acctgTransEntriesAndTransTotal)
 
-            calendarTimePeriodStartDate.add(Calendar.MONTH, 1);
-            Timestamp retStampStartDate = new Timestamp(calendarTimePeriodStartDate.getTimeInMillis());
-            retStampStartDate.setNanos(0);
-            customTimePeriodStartDate = retStampStartDate;
-            customTimePeriodEndDate = UtilDateTime.getMonthEnd(UtilDateTime.toTimestamp(retStampStartDate), timeZone, locale);
+            calendarTimePeriodStartDate.add(Calendar.MONTH, 1)
+            Timestamp retStampStartDate = new Timestamp(calendarTimePeriodStartDate.getTimeInMillis())
+            retStampStartDate.setNanos(0)
+            customTimePeriodStartDate = retStampStartDate
+            customTimePeriodEndDate = UtilDateTime.getMonthEnd(UtilDateTime.toTimestamp(retStampStartDate), timeZone, locale)
         }
-        context.glAcctgTrialBalanceList = glAcctgTrialBalanceList;
+        context.glAcctgTrialBalanceList = glAcctgTrialBalanceList
     }
 }

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/IncomeStatement.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/IncomeStatement.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/IncomeStatement.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/IncomeStatement.groovy Wed Nov  2 19:09:13 2016
@@ -17,372 +17,372 @@
  * under the License.
  */
 
-import org.apache.ofbiz.base.util.UtilDateTime;
-import org.apache.ofbiz.base.util.UtilMisc;
-import org.apache.ofbiz.entity.GenericValue;
-import org.apache.ofbiz.entity.condition.EntityCondition;
-import org.apache.ofbiz.entity.condition.EntityOperator;
-import org.apache.ofbiz.accounting.util.UtilAccounting;
-import org.apache.ofbiz.party.party.PartyWorker;
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.base.util.UtilMisc
+import org.apache.ofbiz.entity.GenericValue
+import org.apache.ofbiz.entity.condition.EntityCondition
+import org.apache.ofbiz.entity.condition.EntityOperator
+import org.apache.ofbiz.accounting.util.UtilAccounting
+import org.apache.ofbiz.party.party.PartyWorker
 
 if (!fromDate) {
-    return;
+    return
 }
 if (!thruDate) {
-    thruDate = UtilDateTime.nowTimestamp();
+    thruDate = UtilDateTime.nowTimestamp()
 }
 if (!glFiscalTypeId) {
-    return;
+    return
 }
 organizationPartyId =null
 if(context.organizationPartyId) {
-    organizationPartyId = context.organizationPartyId;
+    organizationPartyId = context.organizationPartyId
 } else {
     organizationPartyId = parameters.get('ApplicationDecorator|organizationPartyId')
 }
 
 // Setup the divisions for which the report is executed
-List partyIds = PartyWorker.getAssociatedPartyIdsByRelationshipType(delegator, organizationPartyId, 'GROUP_ROLLUP');
-partyIds.add(organizationPartyId);
+List partyIds = PartyWorker.getAssociatedPartyIdsByRelationshipType(delegator, organizationPartyId, 'GROUP_ROLLUP')
+partyIds.add(organizationPartyId)
 
 // Get the group of account classes that will be used to position accounts in the proper section of the financial statement
-GenericValue revenueGlAccountClass = from("GlAccountClass").where("glAccountClassId", "REVENUE").cache(true).queryOne();
-List revenueAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(revenueGlAccountClass);
-GenericValue contraRevenueGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CONTRA_REVENUE").cache(true).queryOne();
-List contraRevenueAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(contraRevenueGlAccountClass);
-GenericValue incomeGlAccountClass = from("GlAccountClass").where("glAccountClassId", "INCOME").cache(true).queryOne();
-List incomeAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(incomeGlAccountClass);
-GenericValue expenseGlAccountClass = from("GlAccountClass").where("glAccountClassId", "EXPENSE").cache(true).queryOne();
-List expenseAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(expenseGlAccountClass);
-GenericValue cogsExpenseGlAccountClass = from("GlAccountClass").where("glAccountClassId", "COGS_EXPENSE").cache(true).queryOne();
-List cogsExpenseAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(cogsExpenseGlAccountClass);
-GenericValue sgaExpenseGlAccountClass = from("GlAccountClass").where("glAccountClassId", "SGA_EXPENSE").cache(true).queryOne();
-List sgaExpenseAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(sgaExpenseGlAccountClass);
-GenericValue depreciationGlAccountClass = from("GlAccountClass").where("glAccountClassId", "DEPRECIATION").cache(true).queryOne();
-List depreciationAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(depreciationGlAccountClass);
-
-List mainAndExprs = [];
-mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
-mainAndExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId));
-mainAndExprs.add(EntityCondition.makeCondition("acctgTransTypeId", EntityOperator.NOT_EQUAL, "PERIOD_CLOSING"));
-mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
-mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, thruDate));
+GenericValue revenueGlAccountClass = from("GlAccountClass").where("glAccountClassId", "REVENUE").cache(true).queryOne()
+List revenueAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(revenueGlAccountClass)
+GenericValue contraRevenueGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CONTRA_REVENUE").cache(true).queryOne()
+List contraRevenueAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(contraRevenueGlAccountClass)
+GenericValue incomeGlAccountClass = from("GlAccountClass").where("glAccountClassId", "INCOME").cache(true).queryOne()
+List incomeAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(incomeGlAccountClass)
+GenericValue expenseGlAccountClass = from("GlAccountClass").where("glAccountClassId", "EXPENSE").cache(true).queryOne()
+List expenseAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(expenseGlAccountClass)
+GenericValue cogsExpenseGlAccountClass = from("GlAccountClass").where("glAccountClassId", "COGS_EXPENSE").cache(true).queryOne()
+List cogsExpenseAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(cogsExpenseGlAccountClass)
+GenericValue sgaExpenseGlAccountClass = from("GlAccountClass").where("glAccountClassId", "SGA_EXPENSE").cache(true).queryOne()
+List sgaExpenseAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(sgaExpenseGlAccountClass)
+GenericValue depreciationGlAccountClass = from("GlAccountClass").where("glAccountClassId", "DEPRECIATION").cache(true).queryOne()
+List depreciationAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(depreciationGlAccountClass)
+
+List mainAndExprs = []
+mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"))
+mainAndExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId))
+mainAndExprs.add(EntityCondition.makeCondition("acctgTransTypeId", EntityOperator.NOT_EQUAL, "PERIOD_CLOSING"))
+mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate))
+mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, thruDate))
 
-List balanceTotalList = [];
+List balanceTotalList = []
 
 // REVENUE
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List revenueAndExprs = mainAndExprs as LinkedList;
-revenueAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, revenueAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(revenueAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List revenueAndExprs = mainAndExprs as LinkedList
+revenueAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, revenueAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(revenueAndExprs).orderBy("glAccountId").queryList()
 if (transactionTotals) {
-    Map transactionTotalsMap = [:];
-    balanceTotalCredit = BigDecimal.ZERO;
-    balanceTotalDebit = BigDecimal.ZERO;
+    Map transactionTotalsMap = [:]
+    balanceTotalCredit = BigDecimal.ZERO
+    balanceTotalDebit = BigDecimal.ZERO
     transactionTotals.each { transactionTotal ->
-        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId);
+        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId)
         if (!accountMap) {
-            accountMap = UtilMisc.makeMapWritable(transactionTotal);
-            accountMap.remove("debitCreditFlag");
-            accountMap.remove("amount");
-            accountMap.put("D", BigDecimal.ZERO);
-            accountMap.put("C", BigDecimal.ZERO);
-            accountMap.put("balance", BigDecimal.ZERO);
+            accountMap = UtilMisc.makeMapWritable(transactionTotal)
+            accountMap.remove("debitCreditFlag")
+            accountMap.remove("amount")
+            accountMap.put("D", BigDecimal.ZERO)
+            accountMap.put("C", BigDecimal.ZERO)
+            accountMap.put("balance", BigDecimal.ZERO)
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
+        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount)
         if ("D".equals(transactionTotal.debitCreditFlag)) {
-            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount);
+            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount)
         } else {
-            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount);
+            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount)
         }
-        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
         // revenues are accounts of class CREDIT: the balance is given by credits minus debits
-        BigDecimal balance = creditAmount.subtract(debitAmount);
-        accountMap.put("balance", balance);
-        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+        BigDecimal balance = creditAmount.subtract(debitAmount)
+        accountMap.put("balance", balance)
+        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
     }
-    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
     // revenues are accounts of class CREDIT: the balance is given by credits minus debits
-    balanceTotal = balanceTotalCredit.subtract(balanceTotalDebit);
+    balanceTotal = balanceTotalCredit.subtract(balanceTotalDebit)
 }
-context.revenueAccountBalanceList = accountBalanceList;
-context.revenueAccountBalanceList.add(UtilMisc.toMap("accountName", "TOTAL REVENUES", "balance", balanceTotal));
-context.revenueBalanceTotal = balanceTotal;
+context.revenueAccountBalanceList = accountBalanceList
+context.revenueAccountBalanceList.add(UtilMisc.toMap("accountName", "TOTAL REVENUES", "balance", balanceTotal))
+context.revenueBalanceTotal = balanceTotal
 
 // CONTRA REVENUE
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List contraRevenueAndExprs = mainAndExprs as LinkedList;
-contraRevenueAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, contraRevenueAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(contraRevenueAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List contraRevenueAndExprs = mainAndExprs as LinkedList
+contraRevenueAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, contraRevenueAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(contraRevenueAndExprs).orderBy("glAccountId").queryList()
 if (transactionTotals) {
-    Map transactionTotalsMap = [:];
-    balanceTotalCredit = BigDecimal.ZERO;
-    balanceTotalDebit = BigDecimal.ZERO;
+    Map transactionTotalsMap = [:]
+    balanceTotalCredit = BigDecimal.ZERO
+    balanceTotalDebit = BigDecimal.ZERO
     transactionTotals.each { transactionTotal ->
-        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId);
+        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId)
         if (!accountMap) {
-            accountMap = UtilMisc.makeMapWritable(transactionTotal);
-            accountMap.remove("debitCreditFlag");
-            accountMap.remove("amount");
-            accountMap.put("D", BigDecimal.ZERO);
-            accountMap.put("C", BigDecimal.ZERO);
-            accountMap.put("balance", BigDecimal.ZERO);
+            accountMap = UtilMisc.makeMapWritable(transactionTotal)
+            accountMap.remove("debitCreditFlag")
+            accountMap.remove("amount")
+            accountMap.put("D", BigDecimal.ZERO)
+            accountMap.put("C", BigDecimal.ZERO)
+            accountMap.put("balance", BigDecimal.ZERO)
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
+        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount)
         if ("D".equals(transactionTotal.debitCreditFlag)) {
-            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount);
+            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount)
         } else {
-            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount);
+            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount)
         }
-        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
         // contra revenues are accounts of class DEBIT: the balance is given by debits minus credits
-        BigDecimal balance = debitAmount.subtract(creditAmount);
-        accountMap.put("balance", balance);
-        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+        BigDecimal balance = debitAmount.subtract(creditAmount)
+        accountMap.put("balance", balance)
+        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
     }
-    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
     // contra revenues are accounts of class DEBIT: the balance is given by debits minus credits
-    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit);
+    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit)
 }
-context.contraRevenueBalanceTotal = balanceTotal;
-balanceTotalList.add(UtilMisc.toMap("totalName", "TOTAL CONTRA REVENUE", "balance", balanceTotal));
+context.contraRevenueBalanceTotal = balanceTotal
+balanceTotalList.add(UtilMisc.toMap("totalName", "TOTAL CONTRA REVENUE", "balance", balanceTotal))
 
 // EXPENSE
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List expenseAndExprs = mainAndExprs as LinkedList;
-expenseAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, expenseAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(expenseAndExprs).queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List expenseAndExprs = mainAndExprs as LinkedList
+expenseAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, expenseAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(expenseAndExprs).queryList()
 if (transactionTotals) {
-    Map transactionTotalsMap = [:];
-    balanceTotalCredit = BigDecimal.ZERO;
-    balanceTotalDebit = BigDecimal.ZERO;
+    Map transactionTotalsMap = [:]
+    balanceTotalCredit = BigDecimal.ZERO
+    balanceTotalDebit = BigDecimal.ZERO
     transactionTotals.each { transactionTotal ->
-        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId);
+        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId)
         if (!accountMap) {
-            accountMap = UtilMisc.makeMapWritable(transactionTotal);
-            accountMap.remove("debitCreditFlag");
-            accountMap.remove("amount");
-            accountMap.put("D", BigDecimal.ZERO);
-            accountMap.put("C", BigDecimal.ZERO);
-            accountMap.put("balance", BigDecimal.ZERO);
+            accountMap = UtilMisc.makeMapWritable(transactionTotal)
+            accountMap.remove("debitCreditFlag")
+            accountMap.remove("amount")
+            accountMap.put("D", BigDecimal.ZERO)
+            accountMap.put("C", BigDecimal.ZERO)
+            accountMap.put("balance", BigDecimal.ZERO)
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
+        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount)
         if ("D".equals(transactionTotal.debitCreditFlag)) {
-            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount);
+            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount)
         } else {
-            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount);
+            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount)
         }
-        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
         // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-        BigDecimal balance = debitAmount.subtract(creditAmount);
-        accountMap.put("balance", balance);
-        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+        BigDecimal balance = debitAmount.subtract(creditAmount)
+        accountMap.put("balance", balance)
+        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
     }
-    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
     // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit);
+    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit)
 }
-context.expenseAccountBalanceList = accountBalanceList;
-context.expenseAccountBalanceList.add(UtilMisc.toMap("accountName", "TOTAL EXPENSES", "balance", balanceTotal));
-context.expenseBalanceTotal = balanceTotal;
+context.expenseAccountBalanceList = accountBalanceList
+context.expenseAccountBalanceList.add(UtilMisc.toMap("accountName", "TOTAL EXPENSES", "balance", balanceTotal))
+context.expenseBalanceTotal = balanceTotal
 
 // COST OF GOODS SOLD (COGS_EXPENSE)
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List cogsExpenseAndExprs = mainAndExprs as LinkedList;
-cogsExpenseAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, cogsExpenseAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(cogsExpenseAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List cogsExpenseAndExprs = mainAndExprs as LinkedList
+cogsExpenseAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, cogsExpenseAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(cogsExpenseAndExprs).orderBy("glAccountId").queryList()
 if (transactionTotals) {
-    Map transactionTotalsMap = [:];
-    balanceTotalCredit = BigDecimal.ZERO;
-    balanceTotalDebit = BigDecimal.ZERO;
+    Map transactionTotalsMap = [:]
+    balanceTotalCredit = BigDecimal.ZERO
+    balanceTotalDebit = BigDecimal.ZERO
     transactionTotals.each { transactionTotal ->
-        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId);
+        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId)
         if (!accountMap) {
-            accountMap = UtilMisc.makeMapWritable(transactionTotal);
-            accountMap.remove("debitCreditFlag");
-            accountMap.remove("amount");
-            accountMap.put("D", BigDecimal.ZERO);
-            accountMap.put("C", BigDecimal.ZERO);
-            accountMap.put("balance", BigDecimal.ZERO);
+            accountMap = UtilMisc.makeMapWritable(transactionTotal)
+            accountMap.remove("debitCreditFlag")
+            accountMap.remove("amount")
+            accountMap.put("D", BigDecimal.ZERO)
+            accountMap.put("C", BigDecimal.ZERO)
+            accountMap.put("balance", BigDecimal.ZERO)
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
+        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount)
         if ("D".equals(transactionTotal.debitCreditFlag)) {
-            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount);
+            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount)
         } else {
-            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount);
+            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount)
         }
-        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
         // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-        BigDecimal balance = debitAmount.subtract(creditAmount);
-        accountMap.put("balance", balance);
-        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+        BigDecimal balance = debitAmount.subtract(creditAmount)
+        accountMap.put("balance", balance)
+        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
     }
-    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
     // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit);
+    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit)
 }
-context.cogsExpense = balanceTotal;
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingCostOfGoodsSold", "balance", balanceTotal));
+context.cogsExpense = balanceTotal
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingCostOfGoodsSold", "balance", balanceTotal))
 
 // OPERATING EXPENSES (SGA_EXPENSE)
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List sgaExpenseAndExprs = mainAndExprs as LinkedList;
-sgaExpenseAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, sgaExpenseAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(sgaExpenseAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List sgaExpenseAndExprs = mainAndExprs as LinkedList
+sgaExpenseAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, sgaExpenseAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(sgaExpenseAndExprs).orderBy("glAccountId").queryList()
 if (transactionTotals) {
-    Map transactionTotalsMap = [:];
-    balanceTotalCredit = BigDecimal.ZERO;
-    balanceTotalDebit = BigDecimal.ZERO;
+    Map transactionTotalsMap = [:]
+    balanceTotalCredit = BigDecimal.ZERO
+    balanceTotalDebit = BigDecimal.ZERO
     transactionTotals.each { transactionTotal ->
-        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId);
+        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId)
         if (!accountMap) {
-            accountMap = UtilMisc.makeMapWritable(transactionTotal);
-            accountMap.remove("debitCreditFlag");
-            accountMap.remove("amount");
-            accountMap.put("D", BigDecimal.ZERO);
-            accountMap.put("C", BigDecimal.ZERO);
-            accountMap.put("balance", BigDecimal.ZERO);
+            accountMap = UtilMisc.makeMapWritable(transactionTotal)
+            accountMap.remove("debitCreditFlag")
+            accountMap.remove("amount")
+            accountMap.put("D", BigDecimal.ZERO)
+            accountMap.put("C", BigDecimal.ZERO)
+            accountMap.put("balance", BigDecimal.ZERO)
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
+        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount)
         if ("D".equals(transactionTotal.debitCreditFlag)) {
-            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount);
+            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount)
         } else {
-            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount);
+            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount)
         }
-        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
         // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-        BigDecimal balance = debitAmount.subtract(creditAmount);
-        accountMap.put("balance", balance);
-        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+        BigDecimal balance = debitAmount.subtract(creditAmount)
+        accountMap.put("balance", balance)
+        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
     }
-    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
     // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit);
+    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit)
 }
-sgaExpense = balanceTotal;
+sgaExpense = balanceTotal
 
 //DEPRECIATION (DEPRECIATION)
 //account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List depreciationAndExprs = mainAndExprs as LinkedList;
-depreciationAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, depreciationAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(depreciationAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List depreciationAndExprs = mainAndExprs as LinkedList
+depreciationAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, depreciationAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(depreciationAndExprs).orderBy("glAccountId").queryList()
 if (transactionTotals) {
-Map transactionTotalsMap = [:];
-balanceTotalCredit = BigDecimal.ZERO;
-balanceTotalDebit = BigDecimal.ZERO;
+Map transactionTotalsMap = [:]
+balanceTotalCredit = BigDecimal.ZERO
+balanceTotalDebit = BigDecimal.ZERO
 transactionTotals.each { transactionTotal ->
-   Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId);
+   Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId)
    if (!accountMap) {
-       accountMap = UtilMisc.makeMapWritable(transactionTotal);
-       accountMap.remove("debitCreditFlag");
-       accountMap.remove("amount");
-       accountMap.put("D", BigDecimal.ZERO);
-       accountMap.put("C", BigDecimal.ZERO);
-       accountMap.put("balance", BigDecimal.ZERO);
+       accountMap = UtilMisc.makeMapWritable(transactionTotal)
+       accountMap.remove("debitCreditFlag")
+       accountMap.remove("amount")
+       accountMap.put("D", BigDecimal.ZERO)
+       accountMap.put("C", BigDecimal.ZERO)
+       accountMap.put("balance", BigDecimal.ZERO)
    }
-   UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
+   UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount)
    if ("D".equals(transactionTotal.debitCreditFlag)) {
-       balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount);
+       balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount)
    } else {
-       balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount);
+       balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount)
    }
-   BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-   BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+   BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+   BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
    // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-   BigDecimal balance = debitAmount.subtract(creditAmount);
-   accountMap.put("balance", balance);
-   transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+   BigDecimal balance = debitAmount.subtract(creditAmount)
+   accountMap.put("balance", balance)
+   transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
 }
-accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
 // expenses are accounts of class DEBIT: the balance is given by debits minus credits
-balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit);
+balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit)
 }
-depreciation = balanceTotal;
+depreciation = balanceTotal
 
 // INCOME
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List incomeAndExprs = mainAndExprs as LinkedList;
-incomeAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, incomeAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(incomeAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List incomeAndExprs = mainAndExprs as LinkedList
+incomeAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, incomeAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(incomeAndExprs).orderBy("glAccountId").queryList()
 if (transactionTotals) {
-    Map transactionTotalsMap = [:];
-    balanceTotalCredit = BigDecimal.ZERO;
-    balanceTotalDebit = BigDecimal.ZERO;
+    Map transactionTotalsMap = [:]
+    balanceTotalCredit = BigDecimal.ZERO
+    balanceTotalDebit = BigDecimal.ZERO
     transactionTotals.each { transactionTotal ->
-        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId);
+        Map accountMap = (Map)transactionTotalsMap.get(transactionTotal.glAccountId)
         if (!accountMap) {
-            accountMap = UtilMisc.makeMapWritable(transactionTotal);
-            accountMap.remove("debitCreditFlag");
-            accountMap.remove("amount");
-            accountMap.put("D", BigDecimal.ZERO);
-            accountMap.put("C", BigDecimal.ZERO);
-            accountMap.put("balance", BigDecimal.ZERO);
+            accountMap = UtilMisc.makeMapWritable(transactionTotal)
+            accountMap.remove("debitCreditFlag")
+            accountMap.remove("amount")
+            accountMap.put("D", BigDecimal.ZERO)
+            accountMap.put("C", BigDecimal.ZERO)
+            accountMap.put("balance", BigDecimal.ZERO)
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
+        UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount)
         if ("D".equals(transactionTotal.debitCreditFlag)) {
-            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount);
+            balanceTotalDebit = balanceTotalDebit.add(transactionTotal.amount)
         } else {
-            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount);
+            balanceTotalCredit = balanceTotalCredit.add(transactionTotal.amount)
         }
-        BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-        BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+        BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
         // income are accounts of class CREDIT: the balance is given by credits minus debits
-        BigDecimal balance = creditAmount.subtract(debitAmount);
-        accountMap.put("balance", balance);
-        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+        BigDecimal balance = creditAmount.subtract(debitAmount)
+        accountMap.put("balance", balance)
+        transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
     }
-    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));    
+    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
     // incomes are accounts of class CREDIT: the balance is given by credits minus debits
-    balanceTotal = balanceTotalCredit.subtract(balanceTotalDebit);
+    balanceTotal = balanceTotalCredit.subtract(balanceTotalDebit)
 }
-context.incomeAccountBalanceList = accountBalanceList;
-context.incomeAccountBalanceList.add(UtilMisc.toMap("accountName", "TOTAL INCOME", "balance", balanceTotal));
-context.incomeBalanceTotal = balanceTotal;
+context.incomeAccountBalanceList = accountBalanceList
+context.incomeAccountBalanceList.add(UtilMisc.toMap("accountName", "TOTAL INCOME", "balance", balanceTotal))
+context.incomeBalanceTotal = balanceTotal
 
 // NET SALES = REVENUES - CONTRA REVENUES
-context.netSales = (context.revenueBalanceTotal).subtract(context.contraRevenueBalanceTotal);
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalNetSales", "balance", context.netSales));
+context.netSales = (context.revenueBalanceTotal).subtract(context.contraRevenueBalanceTotal)
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalNetSales", "balance", context.netSales))
 // GROSS MARGIN = NET SALES - COSTS OF GOODS SOLD
-context.grossMargin = (context.netSales).subtract(context.cogsExpense);
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingGrossMargin", "balance", context.grossMargin));
+context.grossMargin = (context.netSales).subtract(context.cogsExpense)
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingGrossMargin", "balance", context.grossMargin))
 // OPERATING EXPENSES
-context.sgaExpense = sgaExpense;
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingOperatingExpenses", "balance", context.sgaExpense));
+context.sgaExpense = sgaExpense
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingOperatingExpenses", "balance", context.sgaExpense))
 // DEPRECIATION
-context.depreciation = depreciation;
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingDepreciation", "balance", context.depreciation));
+context.depreciation = depreciation
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingDepreciation", "balance", context.depreciation))
 // INCOME FROM OPERATIONS = GROSS MARGIN - OPERATING EXPENSES
-context.incomeFromOperations = (context.grossMargin).subtract(context.sgaExpense);
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingIncomeFromOperations", "balance", context.incomeFromOperations));
+context.incomeFromOperations = (context.grossMargin).subtract(context.sgaExpense)
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingIncomeFromOperations", "balance", context.incomeFromOperations))
 // NET INCOME
-context.netIncome = (context.netSales).add(context.incomeBalanceTotal).subtract(context.expenseBalanceTotal);
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingNetIncome", "balance", context.netIncome));
+context.netIncome = (context.netSales).add(context.incomeBalanceTotal).subtract(context.expenseBalanceTotal)
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingNetIncome", "balance", context.netIncome))
 
-context.balanceTotalList = balanceTotalList;
+context.balanceTotalList = balanceTotalList

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/MonthSelection.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/MonthSelection.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/MonthSelection.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/MonthSelection.groovy Wed Nov  2 19:09:13 2016
@@ -17,13 +17,13 @@
  * under the License.
  */
 
-import org.apache.ofbiz.base.util.UtilDateTime;
-import org.apache.ofbiz.service.calendar.ExpressionUiHelper;
+import org.apache.ofbiz.base.util.UtilDateTime
+import org.apache.ofbiz.service.calendar.ExpressionUiHelper
 
 if (parameters.selectedMonth) {
-  selectedMonth = Integer.valueOf(parameters.selectedMonth);
-  selectedMonthDate = UtilDateTime.toTimestamp((selectedMonth + 1), 1, UtilDateTime.getYear(UtilDateTime.nowTimestamp(), timeZone, locale), 0, 0, 0);
-  context.fromDate = UtilDateTime.getMonthStart(selectedMonthDate, timeZone, locale);
-  context.thruDate = UtilDateTime.getMonthEnd(selectedMonthDate, timeZone, locale);
+  selectedMonth = Integer.valueOf(parameters.selectedMonth)
+  selectedMonthDate = UtilDateTime.toTimestamp((selectedMonth + 1), 1, UtilDateTime.getYear(UtilDateTime.nowTimestamp(), timeZone, locale), 0, 0, 0)
+  context.fromDate = UtilDateTime.getMonthStart(selectedMonthDate, timeZone, locale)
+  context.thruDate = UtilDateTime.getMonthEnd(selectedMonthDate, timeZone, locale)
 }
-context.monthList = ExpressionUiHelper.getMonthValueList(locale);
+context.monthList = ExpressionUiHelper.getMonthValueList(locale)