svn commit: r1767764 [5/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 [5/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/SalesInvoiceByProductCategorySummary.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/SalesInvoiceByProductCategorySummary.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/SalesInvoiceByProductCategorySummary.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/SalesInvoiceByProductCategorySummary.groovy Wed Nov  2 19:09:13 2016
@@ -28,137 +28,137 @@ import org.apache.ofbiz.entity.condition
 //TODO:
 
 // get products and categories under the root category
-productMemberList = from("ProductCategoryMember").where("productCategoryId", rootProductCategoryId).orderBy("sequenceNum").queryList();
-categoryRollupList = from("ProductCategoryRollup").where("parentProductCategoryId", rootProductCategoryId).orderBy("sequenceNum").queryList();
+productMemberList = from("ProductCategoryMember").where("productCategoryId", rootProductCategoryId).orderBy("sequenceNum").queryList()
+categoryRollupList = from("ProductCategoryRollup").where("parentProductCategoryId", rootProductCategoryId).orderBy("sequenceNum").queryList()
 
 // for use in the queries
-productIdSet = [];
-productCategoryIdSet = [];
+productIdSet = []
+productCategoryIdSet = []
 
 // for use in the templates
-productList = [];
-productCategoryList = [];
+productList = []
+productCategoryList = []
 
 productMemberList.each { productMember ->
     if (!productIdSet.contains(productMember.productId)) {
-        productList.add(productMember.getRelatedOne("Product", true));
+        productList.add(productMember.getRelatedOne("Product", true))
     }
-    productIdSet.add(productMember.productId);
+    productIdSet.add(productMember.productId)
 }
 categoryRollupList.each { categoryRollup ->
     if (!productCategoryIdSet.contains(categoryRollup.productCategoryId)) {
-        productCategoryList.add(categoryRollup.getRelatedOne("CurrentProductCategory", true));
+        productCategoryList.add(categoryRollup.getRelatedOne("CurrentProductCategory", true))
     }
-    productCategoryIdSet.add(categoryRollup.productCategoryId);
+    productCategoryIdSet.add(categoryRollup.productCategoryId)
 }
 
 //NOTE: tax, etc also have productId on them, so restrict by type INV_PROD_ITEM, INV_FPROD_ITEM, INV_DPROD_ITEM, others?
-baseProductAndExprs = [];
-baseProductAndExprs.add(EntityCondition.makeCondition("invoiceTypeId", EntityOperator.EQUALS, "SALES_INVOICE"));
-baseProductAndExprs.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, ["INV_PROD_ITEM", "INV_FPROD_ITEM", "INV_DPROD_ITEM"]));
-baseProductAndExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, ["INVOICE_READY", "INVOICE_PAID"]));
-if (organizationPartyId) baseProductAndExprs.add(EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, organizationPartyId));
-if (currencyUomId) baseProductAndExprs.add(EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, currencyUomId));
-
-baseCategoryAndExprs = [];
-baseCategoryAndExprs.add(EntityCondition.makeCondition("invoiceTypeId", EntityOperator.EQUALS, "SALES_INVOICE"));
-baseCategoryAndExprs.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, ["INV_PROD_ITEM", "INV_FPROD_ITEM", "INV_DPROD_ITEM"]));
-baseCategoryAndExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, ["INVOICE_READY", "INVOICE_PAID"]));
-if (productCategoryIdSet) baseCategoryAndExprs.add(EntityCondition.makeCondition("productCategoryId", EntityOperator.IN, productCategoryIdSet));
-if (productIdSet) baseCategoryAndExprs.add(EntityCondition.makeCondition("productId", EntityOperator.NOT_IN, productIdSet));
-if (organizationPartyId) baseCategoryAndExprs.add(EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, organizationPartyId));
-if (currencyUomId) baseCategoryAndExprs.add(EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, currencyUomId));
+baseProductAndExprs = []
+baseProductAndExprs.add(EntityCondition.makeCondition("invoiceTypeId", EntityOperator.EQUALS, "SALES_INVOICE"))
+baseProductAndExprs.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, ["INV_PROD_ITEM", "INV_FPROD_ITEM", "INV_DPROD_ITEM"]))
+baseProductAndExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, ["INVOICE_READY", "INVOICE_PAID"]))
+if (organizationPartyId) baseProductAndExprs.add(EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, organizationPartyId))
+if (currencyUomId) baseProductAndExprs.add(EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, currencyUomId))
+
+baseCategoryAndExprs = []
+baseCategoryAndExprs.add(EntityCondition.makeCondition("invoiceTypeId", EntityOperator.EQUALS, "SALES_INVOICE"))
+baseCategoryAndExprs.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.IN, ["INV_PROD_ITEM", "INV_FPROD_ITEM", "INV_DPROD_ITEM"]))
+baseCategoryAndExprs.add(EntityCondition.makeCondition("statusId", EntityOperator.IN, ["INVOICE_READY", "INVOICE_PAID"]))
+if (productCategoryIdSet) baseCategoryAndExprs.add(EntityCondition.makeCondition("productCategoryId", EntityOperator.IN, productCategoryIdSet))
+if (productIdSet) baseCategoryAndExprs.add(EntityCondition.makeCondition("productId", EntityOperator.NOT_IN, productIdSet))
+if (organizationPartyId) baseCategoryAndExprs.add(EntityCondition.makeCondition("partyIdFrom", EntityOperator.EQUALS, organizationPartyId))
+if (currencyUomId) baseCategoryAndExprs.add(EntityCondition.makeCondition("currencyUomId", EntityOperator.EQUALS, currencyUomId))
 
 
 // get the Calendar object for the current month (specifed by month, year Integer values in the context)
-monthCal = Calendar.getInstance();
-monthCal.set(Calendar.YEAR, year);
-monthCal.set(Calendar.MONTH, (month - 1));
-
-nextMonthCal = Calendar.getInstance();
-nextMonthCal.setTimeInMillis(monthCal.getTimeInMillis());
-nextMonthCal.add(Calendar.MONTH, 1);
+monthCal = Calendar.getInstance()
+monthCal.set(Calendar.YEAR, year)
+monthCal.set(Calendar.MONTH, (month - 1))
+
+nextMonthCal = Calendar.getInstance()
+nextMonthCal.setTimeInMillis(monthCal.getTimeInMillis())
+nextMonthCal.add(Calendar.MONTH, 1)
 
 // iterate through the days and do the queries
-productResultMapByDayList = [];
-productNullResultByDayList = [];
-categoryResultMapByDayList = [];
-
-monthProductResultMap = [:];
-monthCategoryResultMap = [:];
-monthProductNullResult = [:];
+productResultMapByDayList = []
+productNullResultByDayList = []
+categoryResultMapByDayList = []
+
+monthProductResultMap = [:]
+monthCategoryResultMap = [:]
+monthProductNullResult = [:]
 
-daysInMonth = monthCal.getActualMaximum(Calendar.DAY_OF_MONTH);
+daysInMonth = monthCal.getActualMaximum(Calendar.DAY_OF_MONTH)
 for (int currentDay = 0; currentDay <= daysInMonth; currentDay++) {
-    currentDayCal = Calendar.getInstance();
-    currentDayCal.setTimeInMillis(monthCal.getTimeInMillis());
-    currentDayCal.set(Calendar.DAY_OF_MONTH, currentDay);
-    currentDayBegin = new java.sql.Timestamp(currentDayCal.getTimeInMillis());
-    currentDayCal.add(Calendar.DAY_OF_MONTH, 1);
-    nextDayBegin = new java.sql.Timestamp(currentDayCal.getTimeInMillis());
+    currentDayCal = Calendar.getInstance()
+    currentDayCal.setTimeInMillis(monthCal.getTimeInMillis())
+    currentDayCal.set(Calendar.DAY_OF_MONTH, currentDay)
+    currentDayBegin = new java.sql.Timestamp(currentDayCal.getTimeInMillis())
+    currentDayCal.add(Calendar.DAY_OF_MONTH, 1)
+    nextDayBegin = new java.sql.Timestamp(currentDayCal.getTimeInMillis())
 
     // do the product find
-    productAndExprs = [];
-    productAndExprs.addAll(baseProductAndExprs);
-    if (productIdSet) productAndExprs.add(EntityCondition.makeCondition("productId", EntityOperator.IN, productIdSet));
-    productAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.GREATER_THAN_EQUAL_TO, currentDayBegin));
-    productAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.LESS_THAN, nextDayBegin));
+    productAndExprs = []
+    productAndExprs.addAll(baseProductAndExprs)
+    if (productIdSet) productAndExprs.add(EntityCondition.makeCondition("productId", EntityOperator.IN, productIdSet))
+    productAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.GREATER_THAN_EQUAL_TO, currentDayBegin))
+    productAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.LESS_THAN, nextDayBegin))
 
-    productResultListIterator = select("productId", "quantityTotal", "amountTotal").from("InvoiceItemProductSummary").where(productAndExprs).cursorScrollInsensitive().cache(true).queryIterator();
-    productResultMap = [:];
+    productResultListIterator = select("productId", "quantityTotal", "amountTotal").from("InvoiceItemProductSummary").where(productAndExprs).cursorScrollInsensitive().cache(true).queryIterator()
+    productResultMap = [:]
     while ((productResult = productResultListIterator.next())) {
-        productResultMap[productResult.productId] = productResult;
-        monthProductResult = UtilMisc.getMapFromMap(monthProductResultMap, productResult.productId);
-        UtilMisc.addToBigDecimalInMap(monthProductResult, "quantityTotal", productResult.getBigDecimal("quantityTotal"));
-        UtilMisc.addToBigDecimalInMap(monthProductResult, "amountTotal", productResult.getBigDecimal("amountTotal"));
+        productResultMap[productResult.productId] = productResult
+        monthProductResult = UtilMisc.getMapFromMap(monthProductResultMap, productResult.productId)
+        UtilMisc.addToBigDecimalInMap(monthProductResult, "quantityTotal", productResult.getBigDecimal("quantityTotal"))
+        UtilMisc.addToBigDecimalInMap(monthProductResult, "amountTotal", productResult.getBigDecimal("amountTotal"))
     }
-    productResultListIterator.close();
-    productResultMapByDayList.add(productResultMap);
+    productResultListIterator.close()
+    productResultMapByDayList.add(productResultMap)
 
     // do the category find
-    categoryAndExprs = [];
-    categoryAndExprs.addAll(baseCategoryAndExprs);
-    categoryAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.GREATER_THAN_EQUAL_TO, currentDayBegin));
-    categoryAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.LESS_THAN, nextDayBegin));
+    categoryAndExprs = []
+    categoryAndExprs.addAll(baseCategoryAndExprs)
+    categoryAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.GREATER_THAN_EQUAL_TO, currentDayBegin))
+    categoryAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.LESS_THAN, nextDayBegin))
 
-    categoryResultListIterator = select("productCategoryId", "quantityTotal", "amountTotal").from("InvoiceItemCategorySummary").where(categoryAndExprs).cursorScrollInsensitive().cache(true).queryIterator();
-    categoryResultMap = [:];
+    categoryResultListIterator = select("productCategoryId", "quantityTotal", "amountTotal").from("InvoiceItemCategorySummary").where(categoryAndExprs).cursorScrollInsensitive().cache(true).queryIterator()
+    categoryResultMap = [:]
     while ((categoryResult = categoryResultListIterator.next())) {
-        categoryResultMap[categoryResult.productCategoryId] = categoryResult;
-        monthCategoryResult = UtilMisc.getMapFromMap(monthCategoryResultMap, categoryResult.productCategoryId);
-        UtilMisc.addToBigDecimalInMap(monthCategoryResult, "quantityTotal", categoryResult.getBigDecimal("quantityTotal"));
-        UtilMisc.addToBigDecimalInMap(monthCategoryResult, "amountTotal", categoryResult.getBigDecimal("amountTotal"));
+        categoryResultMap[categoryResult.productCategoryId] = categoryResult
+        monthCategoryResult = UtilMisc.getMapFromMap(monthCategoryResultMap, categoryResult.productCategoryId)
+        UtilMisc.addToBigDecimalInMap(monthCategoryResult, "quantityTotal", categoryResult.getBigDecimal("quantityTotal"))
+        UtilMisc.addToBigDecimalInMap(monthCategoryResult, "amountTotal", categoryResult.getBigDecimal("amountTotal"))
     }
-    categoryResultListIterator.close();
-    categoryResultMapByDayList.add(categoryResultMap);
+    categoryResultListIterator.close()
+    categoryResultMapByDayList.add(categoryResultMap)
 
     // do a find for InvoiceItem with a null productId
-    productNullAndExprs = [];
-    productNullAndExprs.addAll(baseProductAndExprs);
-    productNullAndExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, null));
-    productNullAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.GREATER_THAN_EQUAL_TO, currentDayBegin));
-    productNullAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.LESS_THAN, nextDayBegin));
-    productNullResultListIterator = select("productId", "quantityTotal", "amountTotal").from("InvoiceItemProductSummary").where(productNullAndExprs).cursorScrollInsensitive().cache(true).queryIterator();
+    productNullAndExprs = []
+    productNullAndExprs.addAll(baseProductAndExprs)
+    productNullAndExprs.add(EntityCondition.makeCondition("productId", EntityOperator.EQUALS, null))
+    productNullAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.GREATER_THAN_EQUAL_TO, currentDayBegin))
+    productNullAndExprs.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.LESS_THAN, nextDayBegin))
+    productNullResultListIterator = select("productId", "quantityTotal", "amountTotal").from("InvoiceItemProductSummary").where(productNullAndExprs).cursorScrollInsensitive().cache(true).queryIterator()
     // should just be 1 result
-    productNullResult = productNullResultListIterator.next();
-    productNullResultListIterator.close();
+    productNullResult = productNullResultListIterator.next()
+    productNullResultListIterator.close()
     if (productNullResult) {
-        productNullResultByDayList.add(productNullResult);
-        UtilMisc.addToBigDecimalInMap(monthProductNullResult, "quantityTotal", productNullResult.getBigDecimal("quantityTotal"));
-        UtilMisc.addToBigDecimalInMap(monthProductNullResult, "amountTotal", productNullResult.getBigDecimal("amountTotal"));
+        productNullResultByDayList.add(productNullResult)
+        UtilMisc.addToBigDecimalInMap(monthProductNullResult, "quantityTotal", productNullResult.getBigDecimal("quantityTotal"))
+        UtilMisc.addToBigDecimalInMap(monthProductNullResult, "amountTotal", productNullResult.getBigDecimal("amountTotal"))
     } else {
         // no result, add an empty Map place holder
-        productNullResultByDayList.add([:]);
+        productNullResultByDayList.add([:])
     }
 }
 
-context.productResultMapByDayList = productResultMapByDayList;
-context.productNullResultByDayList = productNullResultByDayList;
-context.categoryResultMapByDayList = categoryResultMapByDayList;
-
-context.monthProductResultMap = monthProductResultMap;
-context.monthCategoryResultMap = monthCategoryResultMap;
-context.monthProductNullResult = monthProductNullResult;
+context.productResultMapByDayList = productResultMapByDayList
+context.productNullResultByDayList = productNullResultByDayList
+context.categoryResultMapByDayList = categoryResultMapByDayList
+
+context.monthProductResultMap = monthProductResultMap
+context.monthCategoryResultMap = monthCategoryResultMap
+context.monthProductNullResult = monthProductNullResult
 
-context.productCategoryList = productCategoryList;
-context.productList = productList;
+context.productCategoryList = productCategoryList
+context.productList = productList

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/TransactionTotals.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/TransactionTotals.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/TransactionTotals.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/TransactionTotals.groovy Wed Nov  2 19:09:13 2016
@@ -28,294 +28,294 @@ import org.apache.ofbiz.entity.condition
 import java.sql.Timestamp
 
 if (!fromDate) {
-    return;
+    return
 }
 if (!thruDate) {
-    thruDate = UtilDateTime.nowTimestamp();
+    thruDate = UtilDateTime.nowTimestamp()
 }
 if (!glFiscalTypeId) {
-    return;
+    return
 }
 
 // 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": fromDate,"userLogin": userLogin]);
-Timestamp lastClosedDate = (Timestamp)lastClosedTimePeriodResult.lastClosedDate;
-GenericValue lastClosedTimePeriod = null;
+Map lastClosedTimePeriodResult = runService('findLastClosedDate', ["organizationPartyId": parameters.get('ApplicationDecorator|organizationPartyId'), "findDate": fromDate,"userLogin": userLogin])
+Timestamp lastClosedDate = (Timestamp)lastClosedTimePeriodResult.lastClosedDate
+GenericValue lastClosedTimePeriod = null
 if (lastClosedDate) {
-    lastClosedTimePeriod = (GenericValue)lastClosedTimePeriodResult.lastClosedTimePeriod;
+    lastClosedTimePeriod = (GenericValue)lastClosedTimePeriodResult.lastClosedTimePeriod
 }
 
 // POSTED
 // Posted transactions totals and grand totals
-postedTotals = [];
-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, glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-List postedTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andExprs).orderBy("glAccountId").queryList();
+postedTotals = []
+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, glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate))
+List postedTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andExprs).orderBy("glAccountId").queryList()
 if (postedTransactionTotals) {
     Map postedTransactionTotalsMap = [:]
     postedTransactionTotals.each { postedTransactionTotal ->
-        Map accountMap = (Map)postedTransactionTotalsMap.get(postedTransactionTotal.glAccountId);
+        Map accountMap = (Map)postedTransactionTotalsMap.get(postedTransactionTotal.glAccountId)
         if (!accountMap) {
-            GenericValue glAccount = from("GlAccount").where("glAccountId", postedTransactionTotal.glAccountId).cache(true).queryOne();
+            GenericValue glAccount = from("GlAccount").where("glAccountId", postedTransactionTotal.glAccountId).cache(true).queryOne()
             if (glAccount) {
-                boolean isDebitAccount = UtilAccounting.isDebitAccount(glAccount);
+                boolean isDebitAccount = UtilAccounting.isDebitAccount(glAccount)
                 // Get the opening balances at the end of the last closed time period
                 if (UtilAccounting.isAssetAccount(glAccount) || UtilAccounting.isLiabilityAccount(glAccount) || UtilAccounting.isEquityAccount(glAccount)) {
                     if (lastClosedTimePeriod) {
-                        lastTimePeriodHistory = from("GlAccountAndHistory").where("organizationPartyId", parameters.get('ApplicationDecorator|organizationPartyId'), "glAccountId", postedTransactionTotal.glAccountId, "customTimePeriodId", lastClosedTimePeriod.customTimePeriodId).queryFirst();
+                        lastTimePeriodHistory = from("GlAccountAndHistory").where("organizationPartyId", parameters.get('ApplicationDecorator|organizationPartyId'), "glAccountId", postedTransactionTotal.glAccountId, "customTimePeriodId", lastClosedTimePeriod.customTimePeriodId).queryFirst()
                         if (lastTimePeriodHistory) {
-                            accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "openingD", lastTimePeriodHistory.getBigDecimal("postedDebits"), "openingC", lastTimePeriodHistory.getBigDecimal("postedCredits"), "D", BigDecimal.ZERO, "C", BigDecimal.ZERO);
+                            accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "openingD", lastTimePeriodHistory.getBigDecimal("postedDebits"), "openingC", lastTimePeriodHistory.getBigDecimal("postedCredits"), "D", BigDecimal.ZERO, "C", BigDecimal.ZERO)
                         }
                     }
                 }
             }
             if (!accountMap) {
-                accountMap = UtilMisc.makeMapWritable(postedTransactionTotal);
-                accountMap.put("openingD", BigDecimal.ZERO);
-                accountMap.put("openingC", BigDecimal.ZERO);
-                accountMap.put("D", BigDecimal.ZERO);
-                accountMap.put("C", BigDecimal.ZERO);
-                accountMap.put("balance", BigDecimal.ZERO);
+                accountMap = UtilMisc.makeMapWritable(postedTransactionTotal)
+                accountMap.put("openingD", BigDecimal.ZERO)
+                accountMap.put("openingC", BigDecimal.ZERO)
+                accountMap.put("D", BigDecimal.ZERO)
+                accountMap.put("C", BigDecimal.ZERO)
+                accountMap.put("balance", BigDecimal.ZERO)
             }
             //
-            List mainAndExprs = [];
-            mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-            mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
-            mainAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, postedTransactionTotal.glAccountId));
-            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, lastClosedDate));
-            mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, fromDate));
-            transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(mainAndExprs).orderBy("glAccountId").queryList();
+            List mainAndExprs = []
+            mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+            mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"))
+            mainAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, postedTransactionTotal.glAccountId))
+            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, lastClosedDate))
+            mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, fromDate))
+            transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(mainAndExprs).orderBy("glAccountId").queryList()
             transactionTotals.each { transactionTotal ->
-                UtilMisc.addToBigDecimalInMap(accountMap, "opening" + transactionTotal.debitCreditFlag, transactionTotal.amount);
+                UtilMisc.addToBigDecimalInMap(accountMap, "opening" + transactionTotal.debitCreditFlag, transactionTotal.amount)
             }
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, postedTransactionTotal.debitCreditFlag, postedTransactionTotal.amount);
-        postedTransactionTotalsMap.put(postedTransactionTotal.glAccountId, accountMap);
+        UtilMisc.addToBigDecimalInMap(accountMap, postedTransactionTotal.debitCreditFlag, postedTransactionTotal.amount)
+        postedTransactionTotalsMap.put(postedTransactionTotal.glAccountId, accountMap)
     }
-    postedTotals = postedTransactionTotalsMap.values().asList();
+    postedTotals = postedTransactionTotalsMap.values().asList()
 }
 // Posted grand total for Debits
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "D"));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-List postedDebitTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList();
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "D"))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate))
+List postedDebitTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList()
 if (postedDebitTransactionTotals) {
-    postedDebitTransactionTotal = postedDebitTransactionTotals.first();
+    postedDebitTransactionTotal = postedDebitTransactionTotals.first()
     if (postedDebitTransactionTotal && postedDebitTransactionTotal.amount) {
-        postedTotalDebit = postedDebitTransactionTotal.amount;
+        postedTotalDebit = postedDebitTransactionTotal.amount
     }
 }
 // Posted grand total for Credits
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "C"));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-List postedCreditTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList();
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "Y"))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "C"))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate))
+List postedCreditTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList()
 if (postedCreditTransactionTotals) {
-    postedCreditTransactionTotal = postedCreditTransactionTotals.first();
+    postedCreditTransactionTotal = postedCreditTransactionTotals.first()
     if (postedCreditTransactionTotal && postedCreditTransactionTotal.amount) {
-        postedTotalCredit = postedCreditTransactionTotal.amount;
+        postedTotalCredit = postedCreditTransactionTotal.amount
     }
 }
-postedTotals.add(["D":postedTotalDebit, "C":postedTotalCredit]);
-context.postedTransactionTotals = postedTotals;
+postedTotals.add(["D":postedTotalDebit, "C":postedTotalCredit])
+context.postedTransactionTotals = postedTotals
 
 // UNPOSTED
 // Unposted transactions totals and grand totals
-unpostedTotals = [];
-unpostedTotalDebit = BigDecimal.ZERO;
-unpostedTotalCredit = BigDecimal.ZERO;
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, 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 unpostedTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andExprs).orderBy("glAccountId").queryList();
+unpostedTotals = []
+unpostedTotalDebit = BigDecimal.ZERO
+unpostedTotalCredit = BigDecimal.ZERO
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, 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 unpostedTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andExprs).orderBy("glAccountId").queryList()
 if (unpostedTransactionTotals) {
     Map unpostedTransactionTotalsMap = [:]
     unpostedTransactionTotals.each { unpostedTransactionTotal ->
-        Map accountMap = (Map)unpostedTransactionTotalsMap.get(unpostedTransactionTotal.glAccountId);
+        Map accountMap = (Map)unpostedTransactionTotalsMap.get(unpostedTransactionTotal.glAccountId)
         if (!accountMap) {
-            GenericValue glAccount = from("GlAccount").where("glAccountId", unpostedTransactionTotal.glAccountId).cache(true).queryOne();
+            GenericValue glAccount = from("GlAccount").where("glAccountId", unpostedTransactionTotal.glAccountId).cache(true).queryOne()
             if (glAccount) {
-                boolean isDebitAccount = UtilAccounting.isDebitAccount(glAccount);
+                boolean isDebitAccount = UtilAccounting.isDebitAccount(glAccount)
                 // Get the opening balances at the end of the last closed time period
                 if (UtilAccounting.isAssetAccount(glAccount) || UtilAccounting.isLiabilityAccount(glAccount) || UtilAccounting.isEquityAccount(glAccount)) {
                     if (lastClosedTimePeriod) {
-                        lastTimePeriodHistory = from("GlAccountAndHistory").where("organizationPartyId", parameters.get('ApplicationDecorator|organizationPartyId'), "glAccountId", unpostedTransactionTotal.glAccountId, "customTimePeriodId", lastClosedTimePeriod.customTimePeriodId).queryFirst();
+                        lastTimePeriodHistory = from("GlAccountAndHistory").where("organizationPartyId", parameters.get('ApplicationDecorator|organizationPartyId'), "glAccountId", unpostedTransactionTotal.glAccountId, "customTimePeriodId", lastClosedTimePeriod.customTimePeriodId).queryFirst()
                         if (lastTimePeriodHistory) {
-                            accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "openingD", lastTimePeriodHistory.getBigDecimal("postedDebits"), "openingC", lastTimePeriodHistory.getBigDecimal("postedCredits"), "D", BigDecimal.ZERO, "C", BigDecimal.ZERO);
+                            accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "openingD", lastTimePeriodHistory.getBigDecimal("postedDebits"), "openingC", lastTimePeriodHistory.getBigDecimal("postedCredits"), "D", BigDecimal.ZERO, "C", BigDecimal.ZERO)
                         }
                     }
                 }
             }
             if (!accountMap) {
-                accountMap = UtilMisc.makeMapWritable(unpostedTransactionTotal);
-                accountMap.put("openingD", BigDecimal.ZERO);
-                accountMap.put("openingC", BigDecimal.ZERO);
-                accountMap.put("D", BigDecimal.ZERO);
-                accountMap.put("C", BigDecimal.ZERO);
-                accountMap.put("balance", BigDecimal.ZERO);
+                accountMap = UtilMisc.makeMapWritable(unpostedTransactionTotal)
+                accountMap.put("openingD", BigDecimal.ZERO)
+                accountMap.put("openingC", BigDecimal.ZERO)
+                accountMap.put("D", BigDecimal.ZERO)
+                accountMap.put("C", BigDecimal.ZERO)
+                accountMap.put("balance", BigDecimal.ZERO)
             }
             //
-            List mainAndExprs = [];
-            mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-            mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
-            mainAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, unpostedTransactionTotal.glAccountId));
-            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, lastClosedDate));
-            mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, fromDate));
-            transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(mainAndExprs).orderBy("glAccountId").queryList();
+            List mainAndExprs = []
+            mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+            mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"))
+            mainAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, unpostedTransactionTotal.glAccountId))
+            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, lastClosedDate))
+            mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, fromDate))
+            transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(mainAndExprs).orderBy("glAccountId").queryList()
             transactionTotals.each { transactionTotal ->
-                UtilMisc.addToBigDecimalInMap(accountMap, "opening" + transactionTotal.debitCreditFlag, transactionTotal.amount);
+                UtilMisc.addToBigDecimalInMap(accountMap, "opening" + transactionTotal.debitCreditFlag, transactionTotal.amount)
             }
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, unpostedTransactionTotal.debitCreditFlag, unpostedTransactionTotal.amount);
-        unpostedTransactionTotalsMap.put(unpostedTransactionTotal.glAccountId, accountMap);
+        UtilMisc.addToBigDecimalInMap(accountMap, unpostedTransactionTotal.debitCreditFlag, unpostedTransactionTotal.amount)
+        unpostedTransactionTotalsMap.put(unpostedTransactionTotal.glAccountId, accountMap)
     }
-    unpostedTotals = unpostedTransactionTotalsMap.values().asList();
+    unpostedTotals = unpostedTransactionTotalsMap.values().asList()
 }
 // Unposted grand total for Debits
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "D"));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-List unpostedDebitTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList();
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "D"))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate))
+List unpostedDebitTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList()
 if (unpostedDebitTransactionTotals) {
-    unpostedDebitTransactionTotal = unpostedDebitTransactionTotals.first();
+    unpostedDebitTransactionTotal = unpostedDebitTransactionTotals.first()
     if (unpostedDebitTransactionTotal && unpostedDebitTransactionTotal.amount) {
-        unpostedTotalDebit = unpostedDebitTransactionTotal.amount;
+        unpostedTotalDebit = unpostedDebitTransactionTotal.amount
     }
 }
 // Unposted grand total for Credits
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "C"));
-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 unpostedCreditTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList();
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "C"))
+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 unpostedCreditTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList()
 if (unpostedCreditTransactionTotals) {
-    unpostedCreditTransactionTotal = unpostedCreditTransactionTotals.first();
+    unpostedCreditTransactionTotal = unpostedCreditTransactionTotals.first()
     if (unpostedCreditTransactionTotal && unpostedCreditTransactionTotal.amount) {
-        unpostedTotalCredit = unpostedCreditTransactionTotal.amount;
+        unpostedTotalCredit = unpostedCreditTransactionTotal.amount
     }
 }
-unpostedTotals.add(["D":unpostedTotalDebit, "C":unpostedTotalCredit]);
-context.unpostedTransactionTotals = unpostedTotals;
+unpostedTotals.add(["D":unpostedTotalDebit, "C":unpostedTotalCredit])
+context.unpostedTransactionTotals = unpostedTotals
 
 // POSTED AND UNPOSTED
 // Posted and unposted transactions totals and grand totals
-allTotals = [];
-allTotalDebit = BigDecimal.ZERO;
-allTotalCredit = BigDecimal.ZERO;
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, 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 allTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andExprs).orderBy("glAccountId").queryList();
+allTotals = []
+allTotalDebit = BigDecimal.ZERO
+allTotalCredit = BigDecimal.ZERO
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, 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 allTransactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(andExprs).orderBy("glAccountId").queryList()
 if (allTransactionTotals) {
     Map allTransactionTotalsMap = [:]
     allTransactionTotals.each { allTransactionTotal ->
-        Map accountMap = (Map)allTransactionTotalsMap.get(allTransactionTotal.glAccountId);
+        Map accountMap = (Map)allTransactionTotalsMap.get(allTransactionTotal.glAccountId)
         if (!accountMap) {
-            GenericValue glAccount = from("GlAccount").where("glAccountId", allTransactionTotal.glAccountId).cache(true).queryOne();
+            GenericValue glAccount = from("GlAccount").where("glAccountId", allTransactionTotal.glAccountId).cache(true).queryOne()
             if (glAccount) {
-                boolean isDebitAccount = UtilAccounting.isDebitAccount(glAccount);
+                boolean isDebitAccount = UtilAccounting.isDebitAccount(glAccount)
                 // Get the opening balances at the end of the last closed time period
                 if (UtilAccounting.isAssetAccount(glAccount) || UtilAccounting.isLiabilityAccount(glAccount) || UtilAccounting.isEquityAccount(glAccount)) {
                     if (lastClosedTimePeriod) {
-                        List timePeriodAndExprs = [];
-                        timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.EQUALS, parameters.get('ApplicationDecorator|organizationPartyId')));
-                        timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, allTransactionTotal.glAccountId));
-                        timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId));
-                        lastTimePeriodHistory = from("GlAccountAndHistory").where(timePeriodAndExprs).queryFirst();
+                        List timePeriodAndExprs = []
+                        timePeriodAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.EQUALS, parameters.get('ApplicationDecorator|organizationPartyId')))
+                        timePeriodAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, allTransactionTotal.glAccountId))
+                        timePeriodAndExprs.add(EntityCondition.makeCondition("customTimePeriodId", EntityOperator.EQUALS, lastClosedTimePeriod.customTimePeriodId))
+                        lastTimePeriodHistory = from("GlAccountAndHistory").where(timePeriodAndExprs).queryFirst()
                         if (lastTimePeriodHistory) {
-                            accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "openingD", lastTimePeriodHistory.getBigDecimal("postedDebits"), "openingC", lastTimePeriodHistory.getBigDecimal("postedCredits"), "D", BigDecimal.ZERO, "C", BigDecimal.ZERO);
+                            accountMap = UtilMisc.toMap("glAccountId", lastTimePeriodHistory.glAccountId, "accountCode", lastTimePeriodHistory.accountCode, "accountName", lastTimePeriodHistory.accountName, "balance", lastTimePeriodHistory.getBigDecimal("endingBalance"), "openingD", lastTimePeriodHistory.getBigDecimal("postedDebits"), "openingC", lastTimePeriodHistory.getBigDecimal("postedCredits"), "D", BigDecimal.ZERO, "C", BigDecimal.ZERO)
                         }
                     }
                 }
             }
             if (!accountMap) {
-                accountMap = UtilMisc.makeMapWritable(allTransactionTotal);
-                accountMap.put("openingD", BigDecimal.ZERO);
-                accountMap.put("openingC", BigDecimal.ZERO);
-                accountMap.put("D", BigDecimal.ZERO);
-                accountMap.put("C", BigDecimal.ZERO);
-                accountMap.put("balance", BigDecimal.ZERO);
+                accountMap = UtilMisc.makeMapWritable(allTransactionTotal)
+                accountMap.put("openingD", BigDecimal.ZERO)
+                accountMap.put("openingC", BigDecimal.ZERO)
+                accountMap.put("D", BigDecimal.ZERO)
+                accountMap.put("C", BigDecimal.ZERO)
+                accountMap.put("balance", BigDecimal.ZERO)
             }
             //
-            List mainAndExprs = [];
-            mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-            mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"));
-            mainAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, allTransactionTotal.glAccountId));
-            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, lastClosedDate));
-            mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, fromDate));
-            transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(mainAndExprs).orderBy("glAccountId").queryList();
+            List mainAndExprs = []
+            mainAndExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+            mainAndExprs.add(EntityCondition.makeCondition("isPosted", EntityOperator.EQUALS, "N"))
+            mainAndExprs.add(EntityCondition.makeCondition("glAccountId", EntityOperator.EQUALS, allTransactionTotal.glAccountId))
+            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, lastClosedDate))
+            mainAndExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN, fromDate))
+            transactionTotals = select("glAccountId", "accountName", "accountCode", "debitCreditFlag", "amount").from("AcctgTransEntrySums").where(mainAndExprs).orderBy("glAccountId").queryList()
             transactionTotals.each { transactionTotal ->
-                UtilMisc.addToBigDecimalInMap(accountMap, "opening" + transactionTotal.debitCreditFlag, transactionTotal.amount);
+                UtilMisc.addToBigDecimalInMap(accountMap, "opening" + transactionTotal.debitCreditFlag, transactionTotal.amount)
             }
         }
-        UtilMisc.addToBigDecimalInMap(accountMap, allTransactionTotal.debitCreditFlag, allTransactionTotal.amount);
-        allTransactionTotalsMap.put(allTransactionTotal.glAccountId, accountMap);
+        UtilMisc.addToBigDecimalInMap(accountMap, allTransactionTotal.debitCreditFlag, allTransactionTotal.amount)
+        allTransactionTotalsMap.put(allTransactionTotal.glAccountId, accountMap)
     }
-    allTotals = allTransactionTotalsMap.values().asList();
+    allTotals = allTransactionTotalsMap.values().asList()
 }
 // Posted and unposted grand total for Debits
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "D"));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate));
-andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate));
-List allDebitTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList();
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "D"))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.GREATER_THAN_EQUAL_TO, fromDate))
+andExprs.add(EntityCondition.makeCondition("transactionDate", EntityOperator.LESS_THAN_EQUAL_TO, thruDate))
+List allDebitTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList()
 if (allDebitTransactionTotals) {
-    allDebitTransactionTotal = allDebitTransactionTotals.first();
+    allDebitTransactionTotal = allDebitTransactionTotals.first()
     if (allDebitTransactionTotal && allDebitTransactionTotal.amount) {
-        allTotalDebit = allDebitTransactionTotal.amount;
+        allTotalDebit = allDebitTransactionTotal.amount
     }
 }
 // Posted and unposted grand total for Credits
-andExprs = [];
-andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds));
-andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId));
-andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "C"));
-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 allCreditTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList();
+andExprs = []
+andExprs.add(EntityCondition.makeCondition("organizationPartyId", EntityOperator.IN, partyIds))
+andExprs.add(EntityCondition.makeCondition("glFiscalTypeId", EntityOperator.EQUALS, glFiscalTypeId))
+andExprs.add(EntityCondition.makeCondition("debitCreditFlag", EntityOperator.EQUALS, "C"))
+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 allCreditTransactionTotals = select("amount").from("AcctgTransEntrySums").where(andExprs).queryList()
 if (allCreditTransactionTotals) {
-    allCreditTransactionTotal = allCreditTransactionTotals.first();
+    allCreditTransactionTotal = allCreditTransactionTotals.first()
     if (allCreditTransactionTotal && allCreditTransactionTotal.amount) {
-        allTotalCredit = allCreditTransactionTotal.amount;
+        allTotalCredit = allCreditTransactionTotal.amount
     }
 }
-allTotals.add(["D":allTotalDebit, "C":allTotalCredit]);
-context.allTransactionTotals = allTotals;
+allTotals.add(["D":allTotalDebit, "C":allTotalCredit])
+context.allTransactionTotals = allTotals

Modified: ofbiz/trunk/applications/accounting/groovyScripts/reports/TrialBalance.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/reports/TrialBalance.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/reports/TrialBalance.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/reports/TrialBalance.groovy Wed Nov  2 19:09:13 2016
@@ -19,29 +19,29 @@
 
 import org.apache.ofbiz.entity.condition.EntityCondition
 import org.apache.ofbiz.entity.condition.EntityOperator
-import org.apache.ofbiz.party.party.PartyHelper;
+import org.apache.ofbiz.party.party.PartyHelper
 
-partyNameList = [];
+partyNameList = []
 parties.each { party ->
-    partyName = PartyHelper.getPartyName(party);
-    partyNameList.add(partyName);
+    partyName = PartyHelper.getPartyName(party)
+    partyNameList.add(partyName)
 }
-context.partyNameList = partyNameList;
+context.partyNameList = partyNameList
 
 if (parameters.customTimePeriodId) {
-    customTimePeriod = from("CustomTimePeriod").where("customTimePeriodId", parameters.customTimePeriodId).cache(true).queryOne();
-    exprList = [];
+    customTimePeriod = from("CustomTimePeriod").where("customTimePeriodId", parameters.customTimePeriodId).cache(true).queryOne()
+    exprList = []
     exprList.add(EntityCondition.makeCondition('organizationPartyId', EntityOperator.IN, partyIds))
     exprList.add(EntityCondition.makeCondition('fromDate', EntityOperator.LESS_THAN, customTimePeriod.getTimestamp('thruDate')))
     exprList.add(EntityCondition.makeCondition(EntityCondition.makeCondition('thruDate', EntityOperator.GREATER_THAN_EQUAL_TO, customTimePeriod.getTimestamp('fromDate')), EntityOperator.OR, EntityCondition.makeCondition('thruDate', EntityOperator.EQUALS, null)))
-    List organizationGlAccounts = from("GlAccountOrganizationAndClass").where(exprList).orderBy("accountCode").queryList();
+    List organizationGlAccounts = from("GlAccountOrganizationAndClass").where(exprList).orderBy("accountCode").queryList()
 
     accountBalances = []
     postedDebitsTotal = 0
     postedCreditsTotal = 0
     organizationGlAccounts.each { organizationGlAccount ->
         accountBalance = [:]
-        accountBalance = runService('computeGlAccountBalanceForTimePeriod', [organizationPartyId: organizationGlAccount.organizationPartyId, customTimePeriodId: customTimePeriod.customTimePeriodId, glAccountId: organizationGlAccount.glAccountId]);
+        accountBalance = runService('computeGlAccountBalanceForTimePeriod', [organizationPartyId: organizationGlAccount.organizationPartyId, customTimePeriodId: customTimePeriod.customTimePeriodId, glAccountId: organizationGlAccount.glAccountId])
         if (accountBalance.postedDebits != 0 || accountBalance.postedCredits != 0) {
             accountBalance.glAccountId = organizationGlAccount.glAccountId
             accountBalance.accountCode = organizationGlAccount.accountCode

Modified: ofbiz/trunk/applications/accounting/groovyScripts/transaction/AuthorizeTransaction.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/transaction/AuthorizeTransaction.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/transaction/AuthorizeTransaction.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/transaction/AuthorizeTransaction.groovy Wed Nov  2 19:09:13 2016
@@ -16,31 +16,31 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import org.apache.ofbiz.order.order.OrderReadHelper;
+import org.apache.ofbiz.order.order.OrderReadHelper
 
-orderId = context.orderId;
-orderPaymentPreferenceId = context.orderPaymentPreferenceId;
+orderId = context.orderId
+orderPaymentPreferenceId = context.orderPaymentPreferenceId
 
-if ((!orderId) || (!orderPaymentPreferenceId)) return;
+if ((!orderId) || (!orderPaymentPreferenceId)) return
 
 if (orderId) {
-   orderHeader = from("OrderHeader").where("orderId", orderId).queryOne();
-   context.orderHeader = orderHeader;
+   orderHeader = from("OrderHeader").where("orderId", orderId).queryOne()
+   context.orderHeader = orderHeader
 }
 
 if (orderHeader) {
-   orh = new OrderReadHelper(orderHeader);
-   context.orh = orh;
-   context.overrideAmount = orh.getOrderGrandTotal();
+   orh = new OrderReadHelper(orderHeader)
+   context.orh = orh
+   context.overrideAmount = orh.getOrderGrandTotal()
 }
 
 if (orderPaymentPreferenceId) {
-   orderPaymentPreference = from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
-   context.orderPaymentPreference = orderPaymentPreference;
+   orderPaymentPreference = from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne()
+   context.orderPaymentPreference = orderPaymentPreference
 }
 
 if (orderPaymentPreference) {
-   paymentMethodType = orderPaymentPreference.getRelatedOne("PaymentMethodType", true);
-   context.paymentMethodType = paymentMethodType;
-   context.overrideAmount = orderPaymentPreference.getBigDecimal("maxAmount");
+   paymentMethodType = orderPaymentPreference.getRelatedOne("PaymentMethodType", true)
+   context.paymentMethodType = paymentMethodType
+   context.overrideAmount = orderPaymentPreference.getBigDecimal("maxAmount")
 }

Modified: ofbiz/trunk/applications/accounting/groovyScripts/transaction/CaptureTransaction.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/transaction/CaptureTransaction.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/transaction/CaptureTransaction.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/transaction/CaptureTransaction.groovy Wed Nov  2 19:09:13 2016
@@ -21,38 +21,38 @@ import org.apache.ofbiz.entity.condition
 import org.apache.ofbiz.entity.condition.EntityOperator
 import org.apache.ofbiz.entity.util.EntityUtil
 
-orderId = context.orderId;
-orderPaymentPreferenceId = context.orderPaymentPreferenceId;
+orderId = context.orderId
+orderPaymentPreferenceId = context.orderPaymentPreferenceId
 
-if ((!orderId) || (!orderPaymentPreferenceId)) return;
+if ((!orderId) || (!orderPaymentPreferenceId)) return
 
 if (orderId) {
-   orderHeader = from("OrderHeader").where("orderId", orderId).queryOne();
-   context.orderHeader = orderHeader;
+   orderHeader = from("OrderHeader").where("orderId", orderId).queryOne()
+   context.orderHeader = orderHeader
 }
 
 if (orderPaymentPreferenceId) {
-   orderPaymentPreference = from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
-   context.orderPaymentPreference = orderPaymentPreference;
+   orderPaymentPreference = from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne()
+   context.orderPaymentPreference = orderPaymentPreference
 }
 
 if (orderPaymentPreference) {
-   paymentMethodType = orderPaymentPreference.getRelatedOne("PaymentMethodType", true);
-   context.paymentMethodType = paymentMethodType;
+   paymentMethodType = orderPaymentPreference.getRelatedOne("PaymentMethodType", true)
+   context.paymentMethodType = paymentMethodType
 }
 
 if (orderPaymentPreference) {
-    context.paymentTypeId = "CUSTOMER_PAYMENT";
+    context.paymentTypeId = "CUSTOMER_PAYMENT"
 }
 
 if (orderPaymentPreference) {
     // we retrieve the captureAmount by looking at the latest authorized gateway response for this orderPaymentPreference
-    gatewayResponses = orderPaymentPreference.getRelated("PaymentGatewayResponse", null, ["transactionDate DESC"], false);
-    EntityUtil.filterByCondition(gatewayResponses, EntityCondition.makeCondition("transCodeEnumId", EntityOperator.EQUALS, "PGT_AUTHORIZE"));
+    gatewayResponses = orderPaymentPreference.getRelated("PaymentGatewayResponse", null, ["transactionDate DESC"], false)
+    EntityUtil.filterByCondition(gatewayResponses, EntityCondition.makeCondition("transCodeEnumId", EntityOperator.EQUALS, "PGT_AUTHORIZE"))
 
     if (gatewayResponses) {
-        latestAuth = gatewayResponses[0];
-        context.captureAmount = latestAuth.getBigDecimal("amount");
+        latestAuth = gatewayResponses[0]
+        context.captureAmount = latestAuth.getBigDecimal("amount")
     } else {
         // todo: some kind of error telling user to re-authorize
     }

Modified: ofbiz/trunk/applications/accounting/groovyScripts/transaction/ViewGatewayResponse.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/groovyScripts/transaction/ViewGatewayResponse.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/groovyScripts/transaction/ViewGatewayResponse.groovy (original)
+++ ofbiz/trunk/applications/accounting/groovyScripts/transaction/ViewGatewayResponse.groovy Wed Nov  2 19:09:13 2016
@@ -30,30 +30,30 @@ import org.apache.ofbiz.entity.condition
 import org.apache.ofbiz.entity.util.EntityUtil
 
 // get this field first, it determines which purpose this script satisfies
-orderPaymentPreferenceId = context.orderPaymentPreferenceId;
+orderPaymentPreferenceId = context.orderPaymentPreferenceId
 
 // first purpose: retrieve orderId and paymentPreferenceId
 if (!orderPaymentPreferenceId) {
-  paymentGatewayResponse = context.paymentGatewayResponse;
-  orderPaymentPreference = paymentGatewayResponse.getRelatedOne("OrderPaymentPreference", false);
-  context.orderId = orderPaymentPreference.orderId;
-  context.orderPaymentPreferenceId = orderPaymentPreference.orderPaymentPreferenceId;
+  paymentGatewayResponse = context.paymentGatewayResponse
+  orderPaymentPreference = paymentGatewayResponse.getRelatedOne("OrderPaymentPreference", false)
+  context.orderId = orderPaymentPreference.orderId
+  context.orderPaymentPreferenceId = orderPaymentPreference.orderPaymentPreferenceId
 } else {
     // second purpose: grab the latest gateway response of the orderpaymentpreferenceId
-    orderPaymentPreference = from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne();
-    gatewayResponses = orderPaymentPreference.getRelated("PaymentGatewayResponse", null, ["transactionDate DESC"], false);
-    EntityUtil.filterByCondition(gatewayResponses, EntityCondition.makeCondition("transCodeEnumId", EntityOperator.EQUALS, "PGT_AUTHORIZE"));
+    orderPaymentPreference = from("OrderPaymentPreference").where("orderPaymentPreferenceId", orderPaymentPreferenceId).queryOne()
+    gatewayResponses = orderPaymentPreference.getRelated("PaymentGatewayResponse", null, ["transactionDate DESC"], false)
+    EntityUtil.filterByCondition(gatewayResponses, EntityCondition.makeCondition("transCodeEnumId", EntityOperator.EQUALS, "PGT_AUTHORIZE"))
     
     if (gatewayResponses) {
-        latestAuth = gatewayResponses[0];
-        context.paymentGatewayResponse = latestAuth;
+        latestAuth = gatewayResponses[0]
+        context.paymentGatewayResponse = latestAuth
     } else {
         // todo: some kind of error telling user to re-authorize
     }
     
-    context.orderId = orderPaymentPreference.orderId;
+    context.orderId = orderPaymentPreference.orderId
 }
 // get the list of payments associated to gateway response
 if (context.paymentGatewayResponse) {
-    context.payments = context.paymentGatewayResponse.getRelated("Payment", null, null, false);
+    context.payments = context.paymentGatewayResponse.getRelated("Payment", null, null, false)
 }

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/agreement/GetPartyNameForDate.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/agreement/GetPartyNameForDate.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/agreement/GetPartyNameForDate.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/agreement/GetPartyNameForDate.groovy Wed Nov  2 19:09:13 2016
@@ -1,5 +1,5 @@
-partyIdFrom = parameters.partyIdFrom;
-partyIdTo = parameters.partyIdTo;
+partyIdFrom = parameters.partyIdFrom
+partyIdTo = parameters.partyIdTo
 if (partyIdFrom) {
     context.partyNameResultFrom = runService("getPartyNameForDate", [partyId: partyIdFrom, compareDate: agreementDate, lastNameFirst: "Y"])
 }

Modified: ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/ChangeOrgPartyId.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/ChangeOrgPartyId.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/ChangeOrgPartyId.groovy (original)
+++ ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/ChangeOrgPartyId.groovy Wed Nov  2 19:09:13 2016
@@ -18,17 +18,17 @@
  */
 
 //partyAcctgPrefAndGroupList
-partyAcctgPrefAndGroupList = [];
-partyAcctgPrefAndGroup = delegator.findList("PartyAcctgPrefAndGroup", null, null, null, null, false);
-iter = partyAcctgPrefAndGroup.iterator();
+partyAcctgPrefAndGroupList = []
+partyAcctgPrefAndGroup = delegator.findList("PartyAcctgPrefAndGroup", null, null, null, null, false)
+iter = partyAcctgPrefAndGroup.iterator()
 while (iter.hasNext()) {
    group = iter.next()
-   partyAcctgPrefAndGroupList.add(["key":group.partyId,"value":group.groupName]);
+   partyAcctgPrefAndGroupList.add(["key":group.partyId,"value":group.groupName])
 }
-globalContext.PartyAcctgPrefAndGroupList = partyAcctgPrefAndGroupList;
-globalContext.companyListSize = partyAcctgPrefAndGroupList.size();
+globalContext.PartyAcctgPrefAndGroupList = partyAcctgPrefAndGroupList
+globalContext.companyListSize = partyAcctgPrefAndGroupList.size()
 //hiddenFileds
-hiddenFields = [];
-hiddenFields.add([name : "userPrefTypeId", value : "ORGANIZATION_PARTY"]);
-hiddenFields.add([name : "userPrefGroupTypeId", value : "GLOBAL_PREFERENCES"]);
-globalContext.hiddenFields = hiddenFields;
+hiddenFields = []
+hiddenFields.add([name : "userPrefTypeId", value : "ORGANIZATION_PARTY"])
+hiddenFields.add([name : "userPrefGroupTypeId", value : "GLOBAL_PREFERENCES"])
+globalContext.hiddenFields = hiddenFields

Modified: ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy (original)
+++ ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/FindFacility.groovy Wed Nov  2 19:09:13 2016
@@ -16,44 +16,44 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- import org.apache.ofbiz.entity.util.EntityUtil;
+ import org.apache.ofbiz.entity.util.EntityUtil
 
-findResult = delegator.findByAnd("Facility", [ownerPartyId: partyId], null, false);
-findResultSize = findResult.size();
+findResult = delegator.findByAnd("Facility", [ownerPartyId: partyId], null, false)
+findResultSize = findResult.size()
 if (findResultSize == 1) {
-    context.showScreen = "one";
-    facility = findResult.get(0);
-    context.facility = facility;
-    context.parameters.facilityId = context.facility.facilityId;
+    context.showScreen = "one"
+    facility = findResult.get(0)
+    context.facility = facility
+    context.parameters.facilityId = context.facility.facilityId
 }
 if ((findResultSize > 1 ) && (findResultSize <= 10)) {
-    context.showScreen = "ten";
+    context.showScreen = "ten"
 } else if ((findResultSize > 10 ) || (findResultSize <= 0)) {
-    context.showScreen = "more";
+    context.showScreen = "more"
 }
 
-listPartyPostalAddress = delegator.findByAnd("PartyAndPostalAddress", [partyId: partyId], null, false);
-partyPostalAddress = EntityUtil.getFirst(EntityUtil.filterByDate(listPartyPostalAddress));
-context.partyPostalAddress = partyPostalAddress;
+listPartyPostalAddress = delegator.findByAnd("PartyAndPostalAddress", [partyId: partyId], null, false)
+partyPostalAddress = EntityUtil.getFirst(EntityUtil.filterByDate(listPartyPostalAddress))
+context.partyPostalAddress = partyPostalAddress
 
 if("productstore".equals(tabButtonItemTop)){
     if(findResultSize == 0){
-        request.setAttribute("_ERROR_MESSAGE_", "Facility not set!");
-        context.showScreen = "message";
-        return;
+        request.setAttribute("_ERROR_MESSAGE_", "Facility not set!")
+        context.showScreen = "message"
+        return
     }else{
-        context.showScreen = "origin";
+        context.showScreen = "origin"
     }
 }else if("facility".equals(tabButtonItemTop)){
-    facilityId = parameters.facilityId;
+    facilityId = parameters.facilityId
     if (!facilityId && request.getAttribute("facilityId")) {
-      facilityId = request.getAttribute("facilityId");
+      facilityId = request.getAttribute("facilityId")
     }
-    facility = delegator.findOne("Facility", [facilityId : facilityId], false);
+    facility = delegator.findOne("Facility", [facilityId : facilityId], false)
     if(facility){
-        facilityType = facility.getRelatedOne("FacilityType", false);
-        context.facilityType = facilityType;
+        facilityType = facility.getRelatedOne("FacilityType", false)
+        context.facilityType = facilityType
     }
-    context.facility = facility;
-    context.facilityId = facilityId;
+    context.facility = facility
+    context.facilityId = facilityId
 }

Modified: ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy (original)
+++ ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProdCatalog.groovy Wed Nov  2 19:09:13 2016
@@ -16,109 +16,109 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- import org.apache.ofbiz.base.util.UtilValidate;
- import org.apache.ofbiz.entity.util.EntityUtil;
- import org.apache.ofbiz.product.catalog.CatalogWorker;
+ import org.apache.ofbiz.base.util.UtilValidate
+ import org.apache.ofbiz.entity.util.EntityUtil
+ import org.apache.ofbiz.product.catalog.CatalogWorker
 
- prodCatalog = null;
- prodCatalogId = parameters.prodCatalogId;
- showScreen = "origin";
- List errMsgList = [];
+ prodCatalog = null
+ prodCatalogId = parameters.prodCatalogId
+ showScreen = "origin"
+ List errMsgList = []
 
- productStore = EntityUtil.getFirst(delegator.findByAnd("ProductStore", [payToPartyId: partyId], null, false));
+ productStore = EntityUtil.getFirst(delegator.findByAnd("ProductStore", [payToPartyId: partyId], null, false))
  if(productStore){
-     context.productStoreId = productStore.productStoreId;
+     context.productStoreId = productStore.productStoreId
  }
  if(UtilValidate.isEmpty(productStore)){
-     errMsgList.add("Product Store not set!");
-     showScreen = "message";
+     errMsgList.add("Product Store not set!")
+     showScreen = "message"
  } else {
-     facility = delegator.findOne("Facility", [facilityId : productStore.inventoryFacilityId], false);
-     webSite = EntityUtil.getFirst(delegator.findByAnd("WebSite", [productStoreId: productStore.productStoreId], null, false));
+     facility = delegator.findOne("Facility", [facilityId : productStore.inventoryFacilityId], false)
+     webSite = EntityUtil.getFirst(delegator.findByAnd("WebSite", [productStoreId: productStore.productStoreId], null, false))
     
      if(UtilValidate.isEmpty(facility)){
-         errMsgList.add("Facility not set!");
-         showScreen = "message";
+         errMsgList.add("Facility not set!")
+         showScreen = "message"
      }
      if(UtilValidate.isEmpty(webSite)){
-         errMsgList.add("WebSite not set!");
-         showScreen = "message";
+         errMsgList.add("WebSite not set!")
+         showScreen = "message"
      }
  }
  if (errMsgList) {
-    request.setAttribute("_ERROR_MESSAGE_LIST_", errMsgList);
-    return;
+    request.setAttribute("_ERROR_MESSAGE_LIST_", errMsgList)
+    return
  }
 
- productStoreCatalog = EntityUtil.getFirst(delegator.findByAnd("ProductStoreCatalog", [productStoreId: productStore.productStoreId], null, false));
+ productStoreCatalog = EntityUtil.getFirst(delegator.findByAnd("ProductStoreCatalog", [productStoreId: productStore.productStoreId], null, false))
  if(productStoreCatalog){
-     prodCatalog = productStoreCatalog.getRelatedOne("ProdCatalog", false);
-     prodCatalogId = prodCatalog.prodCatalogId;
+     prodCatalog = productStoreCatalog.getRelatedOne("ProdCatalog", false)
+     prodCatalogId = prodCatalog.prodCatalogId
  }
- context.prodCatalog = prodCatalog;
+ context.prodCatalog = prodCatalog
  context.prodCatalogId = prodCatalogId
- context.showScreen = showScreen;
+ context.showScreen = showScreen
 
  if(("productcategory".equals(tabButtonItem)) || ("product".equals(tabButtonItem))){
-     productCategory = null;
-     productCategoryId = parameters.productCategoryId;
-     showErrorMsg = "N";
+     productCategory = null
+     productCategoryId = parameters.productCategoryId
+     showErrorMsg = "N"
     
      if(UtilValidate.isEmpty(prodCatalogId)){
-         errMsgList.add("Product Catalog not set!");
-         showErrorMsg = "Y";
+         errMsgList.add("Product Catalog not set!")
+         showErrorMsg = "Y"
      }
     
-     prodCatalogCategory  = EntityUtil.getFirst(delegator.findByAnd("ProdCatalogCategory", [prodCatalogId: prodCatalogId, sequenceNum: new Long(1)], null, false));
+     prodCatalogCategory  = EntityUtil.getFirst(delegator.findByAnd("ProdCatalogCategory", [prodCatalogId: prodCatalogId, sequenceNum: new Long(1)], null, false))
      if(prodCatalogCategory){
-         productCategory = EntityUtil.getFirst(delegator.findByAnd("ProductCategory", [primaryParentCategoryId : prodCatalogCategory.productCategoryId], null, false));
+         productCategory = EntityUtil.getFirst(delegator.findByAnd("ProductCategory", [primaryParentCategoryId : prodCatalogCategory.productCategoryId], null, false))
          if(productCategory){
-             productCategoryId = productCategory.productCategoryId;
+             productCategoryId = productCategory.productCategoryId
          }
      }
-     context.productCategoryId = productCategoryId;
-     context.productCategory = productCategory;
+     context.productCategoryId = productCategoryId
+     context.productCategory = productCategory
     
      if("product".equals(tabButtonItem)){
-         productId = parameters.productId;
-         product = null;
+         productId = parameters.productId
+         product = null
         
          if(UtilValidate.isEmpty(productCategoryId)){
-             errMsgList.add("Product Category not set!");
-             showErrorMsg = "Y";
+             errMsgList.add("Product Category not set!")
+             showErrorMsg = "Y"
          }
          /**************** get product from ProductCategory ******************/
-         productCategoryMember  = EntityUtil.getFirst(delegator.findByAnd("ProductCategoryMember", [productCategoryId: productCategoryId], null, false));
+         productCategoryMember  = EntityUtil.getFirst(delegator.findByAnd("ProductCategoryMember", [productCategoryId: productCategoryId], null, false))
          if(productCategoryMember){
-             product = productCategoryMember.getRelatedOne("Product", false);
-             productId = product.productId;
+             product = productCategoryMember.getRelatedOne("Product", false)
+             productId = product.productId
              // Average cost
-             averageCostValues = delegator.findByAnd("ProductPrice", [productId : productId, productPricePurposeId : "PURCHASE", productPriceTypeId : "AVERAGE_COST"], null, false);
+             averageCostValues = delegator.findByAnd("ProductPrice", [productId : productId, productPricePurposeId : "PURCHASE", productPriceTypeId : "AVERAGE_COST"], null, false)
              if(averageCostValues){
-                 averageCostValue = EntityUtil.getFirst(EntityUtil.filterByDate(averageCostValues));
+                 averageCostValue = EntityUtil.getFirst(EntityUtil.filterByDate(averageCostValues))
                  if (averageCostValue?.price != null) {
-                     context.averageCost = averageCostValue.price;
+                     context.averageCost = averageCostValue.price
                  }
              }
              //    Default cost
-             defaultPriceValues = delegator.findByAnd("ProductPrice", [productId : productId, productPricePurposeId : "PURCHASE", productPriceTypeId : "DEFAULT_PRICE"], null, false);
+             defaultPriceValues = delegator.findByAnd("ProductPrice", [productId : productId, productPricePurposeId : "PURCHASE", productPriceTypeId : "DEFAULT_PRICE"], null, false)
              if(defaultPriceValues){
-                 defaultPrice = EntityUtil.getFirst(EntityUtil.filterByDate(defaultPriceValues));
+                 defaultPrice = EntityUtil.getFirst(EntityUtil.filterByDate(defaultPriceValues))
                  if (defaultPrice?.price != null) {
-                     context.defaultPrice = defaultPrice.price;
+                     context.defaultPrice = defaultPrice.price
                  }
              }
          }
          // get promotion category
-         promoCat = CatalogWorker.getCatalogPromotionsCategoryId(request, prodCatalogId);
-         context.productId = productId;
-         context.product = product;
-         context.promoCat = promoCat;
+         promoCat = CatalogWorker.getCatalogPromotionsCategoryId(request, prodCatalogId)
+         context.productId = productId
+         context.product = product
+         context.promoCat = promoCat
      }
     
      if (errMsgList) {
-        request.setAttribute("_ERROR_MESSAGE_LIST_", errMsgList);
-        return;
+        request.setAttribute("_ERROR_MESSAGE_LIST_", errMsgList)
+        return
      }
-     context.showErrorMsg = showErrorMsg;
+     context.showErrorMsg = showErrorMsg
  }

Modified: ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy?rev=1767764&r1=1767763&r2=1767764&view=diff
==============================================================================
--- ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy (original)
+++ ofbiz/trunk/applications/commonext/groovyScripts/ofbizsetup/GetProductStoreAndWebSite.groovy Wed Nov  2 19:09:13 2016
@@ -16,25 +16,25 @@
  * specific language governing permissions and limitations
  * under the License.
  */
- import org.apache.ofbiz.entity.util.EntityUtil;
+ import org.apache.ofbiz.entity.util.EntityUtil
 
- productStoreId = null;
+ productStoreId = null
 
-productStore = EntityUtil.getFirst(delegator.findByAnd("ProductStore", [payToPartyId: partyId], null, false));
+productStore = EntityUtil.getFirst(delegator.findByAnd("ProductStore", [payToPartyId: partyId], null, false))
 if(productStore){
     productStoreId = productStore.productStoreId
 }
-context.productStoreId = productStoreId;
-context.productStore = productStore;
+context.productStoreId = productStoreId
+context.productStore = productStore
 
 if("website".equals(tabButtonItemTop)){
     if(productStoreId != null){
-        webSite = EntityUtil.getFirst(delegator.findByAnd("WebSite", [productStoreId: productStoreId], null, false));
-        context.showScreen = "origin";
+        webSite = EntityUtil.getFirst(delegator.findByAnd("WebSite", [productStoreId: productStoreId], null, false))
+        context.showScreen = "origin"
     }else{
-        request.setAttribute("_ERROR_MESSAGE_", "Product Store not set!");
-        context.showScreen = "message";
-        return;
+        request.setAttribute("_ERROR_MESSAGE_", "Product Store not set!")
+        context.showScreen = "message"
+        return
     }
-    context.webSite = webSite;
+    context.webSite = webSite
 }