svn commit: r1767764 [3/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 [3/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/BalanceSheet.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/BalanceSheet.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/BalanceSheet.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/BalanceSheet.groovy Wed Nov  2 19:09:13 2016
@@ -29,405 +29,405 @@ import org.apache.ofbiz.party.party.Part
 
 import java.sql.Timestamp
 
-uiLabelMap = UtilProperties.getResourceBundleMap("AccountingUiLabels", locale);
+uiLabelMap = UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)
 
 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 assetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "ASSET").cache(true).queryOne();
-List assetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(assetGlAccountClass);
-GenericValue contraAssetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CONTRA_ASSET").cache(true).queryOne();
-List contraAssetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(contraAssetGlAccountClass);
-GenericValue liabilityGlAccountClass = from("GlAccountClass").where("glAccountClassId", "LIABILITY").cache(true).queryOne();
-List liabilityAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(liabilityGlAccountClass);
-GenericValue equityGlAccountClass = from("GlAccountClass").where("glAccountClassId", "EQUITY").cache(true).queryOne();
-List equityAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(equityGlAccountClass);
-GenericValue currentAssetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CURRENT_ASSET").cache(true).queryOne();
-List currentAssetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(currentAssetGlAccountClass);
-GenericValue longtermAssetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "LONGTERM_ASSET").cache(true).queryOne();
-List longtermAssetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(longtermAssetGlAccountClass);
-GenericValue currentLiabilityGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CURRENT_LIABILITY").cache(true).queryOne();
-List currentLiabilityAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(currentLiabilityGlAccountClass);
-GenericValue accumDepreciationGlAccountClass = from("GlAccountClass").where("glAccountClassId", "ACCUM_DEPRECIATION").cache(true).queryOne();
-List accumDepreciationAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(accumDepreciationGlAccountClass);
-GenericValue accumAmortizationGlAccountClass = from("GlAccountClass").where("glAccountClassId", "ACCUM_AMORTIZATION").cache(true).queryOne();
-List accumAmortizationAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(accumAmortizationGlAccountClass);
+GenericValue assetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "ASSET").cache(true).queryOne()
+List assetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(assetGlAccountClass)
+GenericValue contraAssetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CONTRA_ASSET").cache(true).queryOne()
+List contraAssetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(contraAssetGlAccountClass)
+GenericValue liabilityGlAccountClass = from("GlAccountClass").where("glAccountClassId", "LIABILITY").cache(true).queryOne()
+List liabilityAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(liabilityGlAccountClass)
+GenericValue equityGlAccountClass = from("GlAccountClass").where("glAccountClassId", "EQUITY").cache(true).queryOne()
+List equityAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(equityGlAccountClass)
+GenericValue currentAssetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CURRENT_ASSET").cache(true).queryOne()
+List currentAssetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(currentAssetGlAccountClass)
+GenericValue longtermAssetGlAccountClass = from("GlAccountClass").where("glAccountClassId", "LONGTERM_ASSET").cache(true).queryOne()
+List longtermAssetAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(longtermAssetGlAccountClass)
+GenericValue currentLiabilityGlAccountClass = from("GlAccountClass").where("glAccountClassId", "CURRENT_LIABILITY").cache(true).queryOne()
+List currentLiabilityAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(currentLiabilityGlAccountClass)
+GenericValue accumDepreciationGlAccountClass = from("GlAccountClass").where("glAccountClassId", "ACCUM_DEPRECIATION").cache(true).queryOne()
+List accumDepreciationAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(accumDepreciationGlAccountClass)
+GenericValue accumAmortizationGlAccountClass = from("GlAccountClass").where("glAccountClassId", "ACCUM_AMORTIZATION").cache(true).queryOne()
+List accumAmortizationAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(accumAmortizationGlAccountClass)
 
 // Find the last closed time period to get the fromDate for the transactions in the current period and the ending balances of the last closed period
-Map lastClosedTimePeriodResult = runService('findLastClosedDate', ["organizationPartyId": organizationPartyId, "findDate": thruDate,"userLogin": userLogin]);
-Timestamp fromDate = (Timestamp)lastClosedTimePeriodResult.lastClosedDate;
+Map lastClosedTimePeriodResult = runService('findLastClosedDate', ["organizationPartyId": organizationPartyId, "findDate": thruDate,"userLogin": userLogin])
+Timestamp fromDate = (Timestamp)lastClosedTimePeriodResult.lastClosedDate
 if (!fromDate) {
-    return;
+    return
 }
-GenericValue lastClosedTimePeriod = (GenericValue)lastClosedTimePeriodResult.lastClosedTimePeriod;
+GenericValue lastClosedTimePeriod = (GenericValue)lastClosedTimePeriodResult.lastClosedTimePeriod
 // Get the opening balances of all the accounts
-Map assetOpeningBalances = [:];
-Map contraAssetOpeningBalances = [:];
-Map currentAssetOpeningBalances = [:];
-Map longtermAssetOpeningBalances = [:];
-Map liabilityOpeningBalances = [:];
-Map currentLiabilityOpeningBalances = [:];
-Map equityOpeningBalances = [:];
+Map assetOpeningBalances = [:]
+Map contraAssetOpeningBalances = [:]
+Map currentAssetOpeningBalances = [:]
+Map longtermAssetOpeningBalances = [:]
+Map liabilityOpeningBalances = [:]
+Map currentLiabilityOpeningBalances = [:]
+Map equityOpeningBalances = [:]
 if (lastClosedTimePeriod) {
-    List timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, assetAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    List lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    List timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, assetAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    List lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"));
-        assetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap);
+        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        assetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap)
     }
-    timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, contraAssetAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, contraAssetAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"));
-        contraAssetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap);
+        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        contraAssetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap)
     }
-    timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, liabilityAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, liabilityAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"));
-        liabilityOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap);
+        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        liabilityOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap)
     }
-    timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, equityAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, equityAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"));
-        equityOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap);
+        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        equityOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap)
     }
-    timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentAssetAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentAssetAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"));
-        currentAssetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap);
+        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        currentAssetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap)
     }
-    timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, longtermAssetAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, longtermAssetAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"));
-        longtermAssetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap);
+        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        longtermAssetOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap)
     }
-    timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentLiabilityAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentLiabilityAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"));
-        currentLiabilityOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap);
+        Map accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "D", lastTimePeriodHistory.getBigDecimal("postedDebits"), "C", lastTimePeriodHistory.getBigDecimal("postedCredits"))
+        currentLiabilityOpeningBalances.put(lastTimePeriodHistory.glAccountId, accountMap)
     }
 }
 
-List balanceTotalList = [];
+List balanceTotalList = []
 
-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 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))
 
 // ASSETS
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List assetAndExprs = mainAndExprs as LinkedList;
-assetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, assetAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(assetAndExprs).orderBy("glAccountId").queryList();
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(assetOpeningBalances);
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List assetAndExprs = mainAndExprs as LinkedList
+assetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, assetAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(assetAndExprs).orderBy("glAccountId").queryList()
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(assetOpeningBalances)
 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);
-    }
-    UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
-    BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-    BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        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)
+    BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+    BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
     // assets 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"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal + accountBalance.balance;
+    balanceTotal = balanceTotal + accountBalance.balance
 }
-context.assetAccountBalanceList = accountBalanceList;
-context.assetAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalAssets, "balance", balanceTotal));
-context.assetBalanceTotal = balanceTotal;
+context.assetAccountBalanceList = accountBalanceList
+context.assetAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalAssets, "balance", balanceTotal))
+context.assetBalanceTotal = balanceTotal
 
 // CURRENT ASSETS
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List currentAssetAndExprs = mainAndExprs as LinkedList;
-currentAssetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentAssetAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(currentAssetAndExprs).orderBy("glAccountId").queryList();
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(currentAssetOpeningBalances);
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List currentAssetAndExprs = mainAndExprs as LinkedList
+currentAssetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentAssetAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(currentAssetAndExprs).orderBy("glAccountId").queryList()
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(currentAssetOpeningBalances)
 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);
-    }
-    UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
-    BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-    BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        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)
+    BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+    BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
     // assets 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"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal + accountBalance.balance;
+    balanceTotal = balanceTotal + accountBalance.balance
 }
-context.currentAssetBalanceTotal = balanceTotal;
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingCurrentAssets", "balance", balanceTotal));
+context.currentAssetBalanceTotal = balanceTotal
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingCurrentAssets", "balance", balanceTotal))
 
 // LONGTERM ASSETS
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List longtermAssetAndExprs = mainAndExprs as LinkedList;
-longtermAssetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, longtermAssetAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(longtermAssetAndExprs).orderBy("glAccountId").queryList();
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(longtermAssetOpeningBalances);
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List longtermAssetAndExprs = mainAndExprs as LinkedList
+longtermAssetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, longtermAssetAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(longtermAssetAndExprs).orderBy("glAccountId").queryList()
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(longtermAssetOpeningBalances)
 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);
-    }
-    UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
-    BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-    BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        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)
+    BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+    BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
     // assets 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"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal + accountBalance.balance;
+    balanceTotal = balanceTotal + accountBalance.balance
 }
-context.longtermAssetBalanceTotal = balanceTotal;
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingLongTermAssets", "balance", balanceTotal));
+context.longtermAssetBalanceTotal = balanceTotal
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingLongTermAssets", "balance", balanceTotal))
 
 // CONTRA ASSETS
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List contraAssetAndExprs = mainAndExprs as LinkedList;
-contraAssetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, contraAssetAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(contraAssetAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List contraAssetAndExprs = mainAndExprs as LinkedList
+contraAssetAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, contraAssetAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(contraAssetAndExprs).orderBy("glAccountId").queryList()
 
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(contraAssetOpeningBalances);
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(contraAssetOpeningBalances)
 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);
-    }
-    UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
-    BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-    BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        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)
+    BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+    BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
     // contra assets are accounts of class CREDIT: the balance is given by credits minus debits
-    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"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal + accountBalance.balance;
+    balanceTotal = balanceTotal + accountBalance.balance
 }
-context.assetAccountBalanceList.addAll(accountBalanceList);
-context.assetAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalAccumulatedDepreciation, "balance", balanceTotal));
-context.contraAssetBalanceTotal = balanceTotal;
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalAccumulatedDepreciation", "balance", balanceTotal));
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalAssets", "balance", (context.currentAssetBalanceTotal + context.longtermAssetBalanceTotal + balanceTotal)));
+context.assetAccountBalanceList.addAll(accountBalanceList)
+context.assetAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalAccumulatedDepreciation, "balance", balanceTotal))
+context.contraAssetBalanceTotal = balanceTotal
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalAccumulatedDepreciation", "balance", balanceTotal))
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalAssets", "balance", (context.currentAssetBalanceTotal + context.longtermAssetBalanceTotal + balanceTotal)))
 
 // LIABILITY
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List liabilityAndExprs = mainAndExprs as LinkedList;
-liabilityAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, liabilityAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(liabilityAndExprs).orderBy("glAccountId").queryList();
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(liabilityOpeningBalances);
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List liabilityAndExprs = mainAndExprs as LinkedList
+liabilityAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, liabilityAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(liabilityAndExprs).orderBy("glAccountId").queryList()
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(liabilityOpeningBalances)
 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);
-    }
-    UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
-    BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-    BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        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)
+    BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+    BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
     // liabilities 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"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal + accountBalance.balance;
+    balanceTotal = balanceTotal + accountBalance.balance
 }
-context.liabilityAccountBalanceList = accountBalanceList;
-context.liabilityAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalLiabilities, "balance", balanceTotal));
-context.liabilityBalanceTotal = balanceTotal;
+context.liabilityAccountBalanceList = accountBalanceList
+context.liabilityAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalLiabilities, "balance", balanceTotal))
+context.liabilityBalanceTotal = balanceTotal
 
 // CURRENT LIABILITY
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List currentLiabilityAndExprs = mainAndExprs as LinkedList;
-currentLiabilityAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentLiabilityAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(currentLiabilityAndExprs).orderBy("glAccountId").queryList();
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(currentLiabilityOpeningBalances);
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List currentLiabilityAndExprs = mainAndExprs as LinkedList
+currentLiabilityAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, currentLiabilityAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(currentLiabilityAndExprs).orderBy("glAccountId").queryList()
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(currentLiabilityOpeningBalances)
 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);
-    }
-    UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
-    BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-    BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        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)
+    BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+    BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
     // liabilities 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"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal + accountBalance.balance;
+    balanceTotal = balanceTotal + accountBalance.balance
 }
-context.currentLiabilityBalanceTotal = balanceTotal;
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingCurrentLiabilities", "balance", balanceTotal));
+context.currentLiabilityBalanceTotal = balanceTotal
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingCurrentLiabilities", "balance", balanceTotal))
 
 // EQUITY
 // account balances
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List equityAndExprs = mainAndExprs as LinkedList;
-equityAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, equityAccountClassIds));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(equityAndExprs).orderBy("glAccountId").queryList();
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(equityOpeningBalances);
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List equityAndExprs = mainAndExprs as LinkedList
+equityAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, equityAccountClassIds))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(equityAndExprs).orderBy("glAccountId").queryList()
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(equityOpeningBalances)
 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);
-    }
-    UtilMisc.addToBigDecimalInMap(accountMap, transactionTotal.debitCreditFlag, transactionTotal.amount);
-    BigDecimal debitAmount = (BigDecimal)accountMap.get("D");
-    BigDecimal creditAmount = (BigDecimal)accountMap.get("C");
+        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)
+    BigDecimal debitAmount = (BigDecimal)accountMap.get("D")
+    BigDecimal creditAmount = (BigDecimal)accountMap.get("C")
     // equities 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)
 }
 // Add the "retained earnings" account
-Map netIncomeResult = runService('prepareIncomeStatement', ["organizationPartyId": organizationPartyId, "glFiscalTypeId": glFiscalTypeId, "fromDate": fromDate, "thruDate": thruDate, "userLogin": userLogin]);
-BigDecimal netIncome = (BigDecimal)netIncomeResult.totalNetIncome;
-GenericValue retainedEarningsAccount = from("GlAccountTypeDefault").where("glAccountTypeId", "RETAINED_EARNINGS", "organizationPartyId", organizationPartyId).cache(true).queryOne();
+Map netIncomeResult = runService('prepareIncomeStatement', ["organizationPartyId": organizationPartyId, "glFiscalTypeId": glFiscalTypeId, "fromDate": fromDate, "thruDate": thruDate, "userLogin": userLogin])
+BigDecimal netIncome = (BigDecimal)netIncomeResult.totalNetIncome
+GenericValue retainedEarningsAccount = from("GlAccountTypeDefault").where("glAccountTypeId", "RETAINED_EARNINGS", "organizationPartyId", organizationPartyId).cache(true).queryOne()
 if (retainedEarningsAccount) {
-    GenericValue retainedEarningsGlAccount = retainedEarningsAccount.getRelatedOne("GlAccount", false);
-    transactionTotalsMap.put(retainedEarningsGlAccount.glAccountId, UtilMisc.toMap("glAccountId", retainedEarningsGlAccount.glAccountId,"accountName", retainedEarningsGlAccount.accountName, "accountCode", retainedEarningsGlAccount.accountCode, "balance", netIncome));
+    GenericValue retainedEarningsGlAccount = retainedEarningsAccount.getRelatedOne("GlAccount", false)
+    transactionTotalsMap.put(retainedEarningsGlAccount.glAccountId, UtilMisc.toMap("glAccountId", retainedEarningsGlAccount.glAccountId,"accountName", retainedEarningsGlAccount.accountName, "accountCode", retainedEarningsGlAccount.accountCode, "balance", netIncome))
 }
-accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal + accountBalance.balance;
+    balanceTotal = balanceTotal + accountBalance.balance
 }
-context.equityAccountBalanceList = accountBalanceList;
-context.equityAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalEquities, "balance", balanceTotal));
-context.equityBalanceTotal = balanceTotal;
+context.equityAccountBalanceList = accountBalanceList
+context.equityAccountBalanceList.add(UtilMisc.toMap("accountName", uiLabelMap.AccountingTotalEquities, "balance", balanceTotal))
+context.equityBalanceTotal = balanceTotal
 
 context.liabilityEquityBalanceTotal = context.liabilityBalanceTotal + context.equityBalanceTotal
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingEquities", "balance", context.equityBalanceTotal));
-balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalLiabilitiesAndEquities", "balance", context.liabilityEquityBalanceTotal));
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingEquities", "balance", context.equityBalanceTotal))
+balanceTotalList.add(UtilMisc.toMap("totalName", "AccountingTotalLiabilitiesAndEquities", "balance", context.liabilityEquityBalanceTotal))
 
-context.balanceTotalList = balanceTotalList;
+context.balanceTotalList = balanceTotalList

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/CashFlowStatement.groovy Wed Nov  2 19:09:13 2016
@@ -30,193 +30,193 @@ import org.apache.ofbiz.party.party.Part
 import java.sql.Timestamp
 
 if (!fromDate) {
-    return;
+    return
 }
 if (!thruDate) {
-    thruDate = UtilDateTime.nowTimestamp();
+    thruDate = UtilDateTime.nowTimestamp()
 }
 if (!parameters.glFiscalTypeId) {
-    parameters.glFiscalTypeId = "ACTUAL";
+    parameters.glFiscalTypeId = "ACTUAL"
 }
 
-uiLabelMap = UtilProperties.getResourceBundleMap("AccountingUiLabels", locale);
-parametersFromDate = fromDate;
+uiLabelMap = UtilProperties.getResourceBundleMap("AccountingUiLabels", locale)
+parametersFromDate = fromDate
 
 // Setup the divisions for which the report is executed
-List partyIds = PartyWorker.getAssociatedPartyIdsByRelationshipType(delegator, parameters.get('ApplicationDecorator|organizationPartyId'), 'GROUP_ROLLUP');
-partyIds.add(parameters.get('ApplicationDecorator|organizationPartyId'));
+List partyIds = PartyWorker.getAssociatedPartyIdsByRelationshipType(delegator, parameters.get('ApplicationDecorator|organizationPartyId'), 'GROUP_ROLLUP')
+partyIds.add(parameters.get('ApplicationDecorator|organizationPartyId'))
 
 // Get the group of account classes that will be used to position accounts in the proper section of the  Cash Flow statement
-GenericValue glAccountClass = from("GlAccountClass").where("glAccountClassId", "CASH_EQUIVALENT").cache(true).queryOne();
-List glAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(glAccountClass);
+GenericValue glAccountClass = from("GlAccountClass").where("glAccountClassId", "CASH_EQUIVALENT").cache(true).queryOne()
+List glAccountClassIds = UtilAccounting.getDescendantGlAccountClassIds(glAccountClass)
 
-List cashFlowBalanceTotalList = [];
+List cashFlowBalanceTotalList = []
 
 // Find the last closed time period to get the fromDate for the transactions in the current period and the ending balances of the last closed period
-Map lastClosedTimePeriodResult = runService('findLastClosedDate', ["organizationPartyId":parameters.get('ApplicationDecorator|organizationPartyId'), "findDate": parametersFromDate,"userLogin":userLogin]);
-Timestamp periodClosingFromDate = (Timestamp)lastClosedTimePeriodResult.lastClosedDate;
+Map lastClosedTimePeriodResult = runService('findLastClosedDate', ["organizationPartyId":parameters.get('ApplicationDecorator|organizationPartyId'), "findDate": parametersFromDate,"userLogin":userLogin])
+Timestamp periodClosingFromDate = (Timestamp)lastClosedTimePeriodResult.lastClosedDate
 if (!periodClosingFromDate) {
-    return;
+    return
 }
-GenericValue lastClosedTimePeriod = (GenericValue)lastClosedTimePeriodResult.lastClosedTimePeriod;
+GenericValue lastClosedTimePeriod = (GenericValue)lastClosedTimePeriodResult.lastClosedTimePeriod
 // Get the opening balances of Cash Account
-Map openingCashBalances = [:];
+Map openingCashBalances = [:]
 if (lastClosedTimePeriod) {
-    List timePeriodAndExprs = [];
-    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, glAccountClassIds));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO));
-    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-    List lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList();
+    List timePeriodAndExprs = []
+    timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, glAccountClassIds))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("endingBalance", EntityOperator.NOT_EQUAL, BigDecimal.ZERO))
+    timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+    List lastTimePeriodHistories = from("GlAccountAndHistory").where(timePeriodAndExprs).queryList()
     lastTimePeriodHistories.each { lastTimePeriodHistory ->
-        Map accountMap = ["glAccountId":lastTimePeriodHistory.glAccountId, "accountCode":lastTimePeriodHistory.accountCode, "accountName":lastTimePeriodHistory.accountName, "balance":lastTimePeriodHistory.getBigDecimal("endingBalance"), "D":lastTimePeriodHistory.getBigDecimal("postedDebits"), "C":lastTimePeriodHistory.getBigDecimal("postedCredits")];
-        openingCashBalances.(lastTimePeriodHistory.glAccountId) = accountMap;
+        Map accountMap = ["glAccountId":lastTimePeriodHistory.glAccountId, "accountCode":lastTimePeriodHistory.accountCode, "accountName":lastTimePeriodHistory.accountName, "balance":lastTimePeriodHistory.getBigDecimal("endingBalance"), "D":lastTimePeriodHistory.getBigDecimal("postedDebits"), "C":lastTimePeriodHistory.getBigDecimal("postedCredits")]
+        openingCashBalances.(lastTimePeriodHistory.glAccountId) = accountMap
     }
 }
-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, parameters.glFiscalTypeId));
-mainAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, glAccountClassIds));
+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, parameters.glFiscalTypeId))
+mainAndExprs.add(EntityCondition.makeCondition("glAccountClassId", EntityOperator.IN, glAccountClassIds))
 
 // All GlAccount's transactions (from last closing period to parameter's fromDate)
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List openingCashBalanceAndExprs = mainAndExprs as LinkedList;
-openingCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, periodClosingFromDate));
-openingCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, parametersFromDate));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(openingCashBalanceAndExprs).orderBy("glAccountId").queryList();
-transactionTotalsMap = [:];
-transactionTotalsMap.putAll(openingCashBalances);
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List openingCashBalanceAndExprs = mainAndExprs as LinkedList
+openingCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, periodClosingFromDate))
+openingCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, parametersFromDate))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(openingCashBalanceAndExprs).orderBy("glAccountId").queryList()
+transactionTotalsMap = [:]
+transactionTotalsMap.putAll(openingCashBalances)
 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.D = BigDecimal.ZERO;
-        accountMap.C = BigDecimal.ZERO;
-        accountMap.balance = BigDecimal.ZERO;
+        accountMap = UtilMisc.makeMapWritable(transactionTotal)
+        accountMap.remove("debitCreditFlag")
+        accountMap.remove("amount")
+        accountMap.D = BigDecimal.ZERO
+        accountMap.C = BigDecimal.ZERO
+        accountMap.balance = BigDecimal.ZERO
     }
     if (accountMap.debitCreditFlag && accountMap.amount) {
-        accountMap.remove("debitCreditFlag");
-        accountMap.remove("amount");
+        accountMap.remove("debitCreditFlag")
+        accountMap.remove("amount")
     }
     if (transactionTotal.debitCreditFlag == "C") {
-        accountMap.C = ((BigDecimal)accountMap.get("C")).add(transactionTotal.amount);
-        accountMap.balance = (accountMap.balance).subtract(transactionTotal.amount);
+        accountMap.C = ((BigDecimal)accountMap.get("C")).add(transactionTotal.amount)
+        accountMap.balance = (accountMap.balance).subtract(transactionTotal.amount)
     } else {
-        accountMap.D = ((BigDecimal)accountMap.get("D")).add(transactionTotal.amount);
-        accountMap.balance = (accountMap.balance).add(transactionTotal.amount);
+        accountMap.D = ((BigDecimal)accountMap.get("D")).add(transactionTotal.amount)
+        accountMap.balance = (accountMap.balance).add(transactionTotal.amount)
     }
 
-    transactionTotalsMap.put(transactionTotal.glAccountId, accountMap);
+    transactionTotalsMap.put(transactionTotal.glAccountId, accountMap)
 }
-glAccountIdList = [];
-accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+glAccountIdList = []
+accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal.add(accountBalance.balance);
+    balanceTotal = balanceTotal.add(accountBalance.balance)
 }
-openingCashBalanceTotal = balanceTotal;
-context.openingCashBalanceList = accountBalanceList;
-cashFlowBalanceTotalList.add("totalName":"AccountingOpeningCashBalance", "balance":balanceTotal);
-openingTransactionKeySet = transactionTotalsMap.keySet();
+openingCashBalanceTotal = balanceTotal
+context.openingCashBalanceList = accountBalanceList
+cashFlowBalanceTotalList.add("totalName":"AccountingOpeningCashBalance", "balance":balanceTotal)
+openingTransactionKeySet = transactionTotalsMap.keySet()
 
 // PERIOD CASH BALANCE
 // GlAccounts from parameter's fromDate to parameter's thruDate.
-accountBalanceList = [];
-transactionTotals = [];
-balanceTotal = BigDecimal.ZERO;
-List periodCashBalanceAndExprs = mainAndExprs as LinkedList;
-periodCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, parametersFromDate));
-periodCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, thruDate));
-transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(periodCashBalanceAndExprs).orderBy("glAccountId").queryList();
+accountBalanceList = []
+transactionTotals = []
+balanceTotal = BigDecimal.ZERO
+List periodCashBalanceAndExprs = mainAndExprs as LinkedList
+periodCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, parametersFromDate))
+periodCashBalanceAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, thruDate))
+transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(periodCashBalanceAndExprs).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.D = BigDecimal.ZERO;
-            accountMap.C = BigDecimal.ZERO;
-            accountMap.balance = BigDecimal.ZERO;
+            accountMap = UtilMisc.makeMapWritable(transactionTotal)
+            accountMap.remove("debitCreditFlag")
+            accountMap.remove("amount")
+            accountMap.D = BigDecimal.ZERO
+            accountMap.C = BigDecimal.ZERO
+            accountMap.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.D;
-        BigDecimal creditAmount = (BigDecimal)accountMap.C;
-        BigDecimal balance = debitAmount.subtract(creditAmount);
-        accountMap.balance = balance;
-        transactionTotalsMap.(transactionTotal.glAccountId) = accountMap;
-    }
-    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
-    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit);
-}
-periodCashBalanceTotal = balanceTotal;
-context.periodCashBalanceList = accountBalanceList;
-context.periodCashBalanceList.add("accountName":uiLabelMap.AccountingTotalPeriodCashBalance, "balance":balanceTotal);
-cashFlowBalanceTotalList.add("totalName":"AccountingPeriodCashBalance", "balance":balanceTotal);
+        BigDecimal debitAmount = (BigDecimal)accountMap.D
+        BigDecimal creditAmount = (BigDecimal)accountMap.C
+        BigDecimal balance = debitAmount.subtract(creditAmount)
+        accountMap.balance = balance
+        transactionTotalsMap.(transactionTotal.glAccountId) = accountMap
+    }
+    accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
+    balanceTotal = balanceTotalDebit.subtract(balanceTotalCredit)
+}
+periodCashBalanceTotal = balanceTotal
+context.periodCashBalanceList = accountBalanceList
+context.periodCashBalanceList.add("accountName":uiLabelMap.AccountingTotalPeriodCashBalance, "balance":balanceTotal)
+cashFlowBalanceTotalList.add("totalName":"AccountingPeriodCashBalance", "balance":balanceTotal)
 
 // CLOSING BALANCE
 // GlAccounts from parameter's fromDate to parameter's thruDate.
-accountBalanceList = [];
-balanceTotal = BigDecimal.ZERO;
-List transactionTotals = [];
-transactionTotals.addAll(new LinkedList(context.openingCashBalanceList));
-transactionTotals.addAll(new LinkedList(context.periodCashBalanceList));
-transactionTotals = UtilMisc.sortMaps(transactionTotals, UtilMisc.toList("accountCode"));
-closingTransactionKeySet = [];
+accountBalanceList = []
+balanceTotal = BigDecimal.ZERO
+List transactionTotals = []
+transactionTotals.addAll(new LinkedList(context.openingCashBalanceList))
+transactionTotals.addAll(new LinkedList(context.periodCashBalanceList))
+transactionTotals = UtilMisc.sortMaps(transactionTotals, UtilMisc.toList("accountCode"))
+closingTransactionKeySet = []
 if (transactionTotals) {
-    Map transactionTotalsMap = [:];
-    balanceTotalCredit = BigDecimal.ZERO;
-    balanceTotalDebit = BigDecimal.ZERO;
+    Map transactionTotalsMap = [:]
+    balanceTotalCredit = BigDecimal.ZERO
+    balanceTotalDebit = BigDecimal.ZERO
     transactionTotals.each { transactionTotal ->
         if (transactionTotal.D != null) {
             if (transactionTotalsMap.(transactionTotal.glAccountId)) {
-                totalDebitBalance = (transactionTotal.D).add(transactionTotalsMap.(transactionTotal.glAccountId).D);
-                totalCreditBalance = (transactionTotal.C).add(transactionTotalsMap.(transactionTotal.glAccountId).C);
+                totalDebitBalance = (transactionTotal.D).add(transactionTotalsMap.(transactionTotal.glAccountId).D)
+                totalCreditBalance = (transactionTotal.C).add(transactionTotalsMap.(transactionTotal.glAccountId).C)
                 if (transactionTotalsMap.(transactionTotal.glAccountId).D == 0 && transactionTotalsMap.(transactionTotal.glAccountId).C == 0) {
-                    transactionTotalsMap.(transactionTotal.glAccountId).balance = (transactionTotal.balance).add(transactionTotalsMap.(transactionTotal.glAccountId).balance);
+                    transactionTotalsMap.(transactionTotal.glAccountId).balance = (transactionTotal.balance).add(transactionTotalsMap.(transactionTotal.glAccountId).balance)
                 } else {
-                    transactionTotalsMap.(transactionTotal.glAccountId).D = totalDebitBalance;
-                    transactionTotalsMap.(transactionTotal.glAccountId).C = totalCreditBalance;
-                    transactionTotalsMap.(transactionTotal.glAccountId).balance = totalDebitBalance.subtract(totalCreditBalance);
+                    transactionTotalsMap.(transactionTotal.glAccountId).D = totalDebitBalance
+                    transactionTotalsMap.(transactionTotal.glAccountId).C = totalCreditBalance
+                    transactionTotalsMap.(transactionTotal.glAccountId).balance = totalDebitBalance.subtract(totalCreditBalance)
                 }
             } else {
-                transactionTotalsMap.(transactionTotal.glAccountId) = transactionTotal;
+                transactionTotalsMap.(transactionTotal.glAccountId) = transactionTotal
             }
-            accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"));
+            accountBalanceList = UtilMisc.sortMaps(transactionTotalsMap.values().asList(), UtilMisc.toList("accountCode"))
         }
     }
-    closingTransactionKeySet = transactionTotalsMap.keySet();
+    closingTransactionKeySet = transactionTotalsMap.keySet()
 }
 accountBalanceList.each { accountBalance ->
-    balanceTotal = balanceTotal.add(accountBalance.balance);
+    balanceTotal = balanceTotal.add(accountBalance.balance)
 }
-context.closingCashBalanceList = accountBalanceList;
-context.closingCashBalanceList.add("accountName":uiLabelMap.AccountingTotalClosingCashBalance, "balance":balanceTotal);
+context.closingCashBalanceList = accountBalanceList
+context.closingCashBalanceList.add("accountName":uiLabelMap.AccountingTotalClosingCashBalance, "balance":balanceTotal)
 
 // Get differences of glAccount in closing and opening list and then add difference to opening list.
 if (closingTransactionKeySet) {
-    closingTransactionKeySet.removeAll(openingTransactionKeySet);
+    closingTransactionKeySet.removeAll(openingTransactionKeySet)
     closingTransactionKeySet.each { closingTransactionKey ->
-        glAccount = from("GlAccount").where("glAccountId", closingTransactionKey).cache(true).queryOne();
-        context.openingCashBalanceList.add(["glAccountId":glAccount.glAccountId, "accountName":glAccount.accountName, accountCode:glAccount.accountCode, balance:BigDecimal.ZERO, D:BigDecimal.ZERO, C:BigDecimal.ZERO]);
+        glAccount = from("GlAccount").where("glAccountId", closingTransactionKey).cache(true).queryOne()
+        context.openingCashBalanceList.add(["glAccountId":glAccount.glAccountId, "accountName":glAccount.accountName, accountCode:glAccount.accountCode, balance:BigDecimal.ZERO, D:BigDecimal.ZERO, C:BigDecimal.ZERO])
     }
 }
-context.openingCashBalanceList.add(["accountName":uiLabelMap.AccountingTotalOpeningCashBalance, "balance":openingCashBalanceTotal]);
+context.openingCashBalanceList.add(["accountName":uiLabelMap.AccountingTotalOpeningCashBalance, "balance":openingCashBalanceTotal])
 
 // CASH FLOW STATEMENT ENDING BALANCE
 // ENDING BALANCE = OPENING CASH BALANCE + PERIOD CASH BALANCE
-endingCashBalanceTotal = openingCashBalanceTotal.add(periodCashBalanceTotal);
-cashFlowBalanceTotalList.add("totalName":"AccountingEndingCashBalance", "balance":endingCashBalanceTotal);
-context.cashFlowBalanceTotalList = cashFlowBalanceTotalList;
+endingCashBalanceTotal = openingCashBalanceTotal.add(periodCashBalanceTotal)
+cashFlowBalanceTotalList.add("totalName":"AccountingEndingCashBalance", "balance":endingCashBalanceTotal)
+context.cashFlowBalanceTotalList = cashFlowBalanceTotalList

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeBalanceSheet.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeBalanceSheet.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeBalanceSheet.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/ComparativeBalanceSheet.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
 
-assetAccountBalanceMap = [:];
-assetAccountBalanceList = [];
+assetAccountBalanceMap = [:]
+assetAccountBalanceList = []
 assetAccountBalanceList1.each { accountBalance ->
-    assetAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    assetAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 assetAccountBalanceList2.each { accountBalance ->
-    Map assetAccount = (Map)assetAccountBalanceMap.get(accountBalance.glAccountId);
+    Map assetAccount = (Map)assetAccountBalanceMap.get(accountBalance.glAccountId)
     if (!assetAccount) {
-        assetAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        assetAccountBalanceMap.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)
     }
 }
-assetAccountBalanceList = UtilMisc.sortMaps(assetAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.assetAccountBalanceList = assetAccountBalanceList;
+assetAccountBalanceList = UtilMisc.sortMaps(assetAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.assetAccountBalanceList = assetAccountBalanceList
 
-liabilityAccountBalanceMap = [:];
-liabilityAccountBalanceList = [];
+liabilityAccountBalanceMap = [:]
+liabilityAccountBalanceList = []
 liabilityAccountBalanceList1.each { accountBalance ->
-    liabilityAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    liabilityAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 liabilityAccountBalanceList2.each { accountBalance ->
-    Map assetAccount = (Map)liabilityAccountBalanceMap.get(accountBalance.glAccountId);
+    Map assetAccount = (Map)liabilityAccountBalanceMap.get(accountBalance.glAccountId)
     if (!assetAccount) {
-        liabilityAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        liabilityAccountBalanceMap.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)
     }
 }
-liabilityAccountBalanceList = UtilMisc.sortMaps(liabilityAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.liabilityAccountBalanceList = liabilityAccountBalanceList;
+liabilityAccountBalanceList = UtilMisc.sortMaps(liabilityAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.liabilityAccountBalanceList = liabilityAccountBalanceList
 
-equityAccountBalanceMap = [:];
-equityAccountBalanceList = [];
+equityAccountBalanceMap = [:]
+equityAccountBalanceList = []
 equityAccountBalanceList1.each { accountBalance ->
-    equityAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO));
+    equityAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance1", accountBalance.balance, "balance2", BigDecimal.ZERO))
 }
 equityAccountBalanceList2.each { accountBalance ->
-    Map assetAccount = (Map)equityAccountBalanceMap.get(accountBalance.glAccountId);
+    Map assetAccount = (Map)equityAccountBalanceMap.get(accountBalance.glAccountId)
     if (!assetAccount) {
-        equityAccountBalanceMap.put(accountBalance.glAccountId, UtilMisc.toMap("glAccountId", accountBalance.glAccountId, "accountCode", accountBalance.accountCode, "accountName", accountBalance.accountName, "balance2", accountBalance.balance, "balance1", BigDecimal.ZERO));
+        equityAccountBalanceMap.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)
     }
 }
-equityAccountBalanceList = UtilMisc.sortMaps(equityAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"));
-context.equityAccountBalanceList = equityAccountBalanceList;
+equityAccountBalanceList = UtilMisc.sortMaps(equityAccountBalanceMap.values().asList(), UtilMisc.toList("accountCode"))
+context.equityAccountBalanceList = equityAccountBalanceList
 
-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