You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by le...@apache.org on 2008/06/04 13:14:02 UTC

svn commit: r663063 - in /ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions: admin/ chartofaccounts/ fixedasset/ invoice/

Author: lektran
Date: Wed Jun  4 04:14:02 2008
New Revision: 663063

URL: http://svn.apache.org/viewvc?rev=663063&view=rev
Log:
Another pass of groovy tidy-ups for the accounting app

Modified:
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/listInvoiceItemTypesGlAccount.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/printChecks.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/EditGlobalGlAccount.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/FindGlobalGlAccount.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/addTotalAmount.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/createApplicationList.groovy

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/listInvoiceItemTypesGlAccount.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/listInvoiceItemTypesGlAccount.groovy?rev=663063&r1=663062&r2=663063&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/listInvoiceItemTypesGlAccount.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/listInvoiceItemTypesGlAccount.groovy Wed Jun  4 04:14:02 2008
@@ -25,13 +25,13 @@
 import org.ofbiz.base.util.UtilMisc;
 
 // Optional prefix parameter to filter InvoiceItemTypes by (i.e. "INV" or "PINV") defaults to INV
-invItemTypePrefix = context.invItemTypePrefix ? context.invItemTypePrefix : "INV";
+invItemTypePrefix = context.invItemTypePrefix ?: "INV";
 invItemTypePrefix += "_%"
 
 organizationPartyId = parameters.organizationPartyId;
 
 List invoiceItemTypes = delegator.findList("InvoiceItemType", EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.LIKE, invItemTypePrefix), null, null, null, false);
-List allTypes = new LinkedList();
+List allTypes = [];
 invoiceItemTypes.each { invoiceItemType ->
     String activeGlDescription = "";
     String remove = " ";

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/printChecks.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/printChecks.groovy?rev=663063&r1=663062&r2=663063&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/printChecks.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/admin/printChecks.groovy Wed Jun  4 04:14:02 2008
@@ -22,13 +22,11 @@
 import org.ofbiz.accounting.util.UtilAccounting;
 
 // rounding mode
-int decimals = UtilAccounting.getBigDecimalScale("invoice.decimals");
-int rounding = UtilAccounting.getBigDecimalRoundingMode("invoice.rounding");
+decimals = UtilAccounting.getBigDecimalScale("invoice.decimals");
+rounding = UtilAccounting.getBigDecimalRoundingMode("invoice.rounding");
 context.decimals = decimals;
 context.rounding = rounding;
 
-// list of payments
-payments = new ArrayList();
 
 // first ensure ability to print
 if (!security.hasEntityPermission("ACCOUNTING", "_PRINT_CHECKS", session)) {
@@ -36,6 +34,8 @@
     return;
 }
 
+// list of payments
+payments = [];
 // in the case of a single payment, the paymentId will be supplied
 paymentId = context.paymentId;
 if (paymentId) {

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/EditGlobalGlAccount.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/EditGlobalGlAccount.groovy?rev=663063&r1=663062&r2=663063&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/EditGlobalGlAccount.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/EditGlobalGlAccount.groovy Wed Jun  4 04:14:02 2008
@@ -21,11 +21,7 @@
 import org.ofbiz.entity.*;
 import org.ofbiz.widget.html.*;
 
-if(security.hasEntityPermission("ACCOUNTING", "_VIEW", session)) {
-    context.hasPermission = true;
-} else {
-    context.hasPermission = false;
-}
+context.hasPermission = security.hasEntityPermission("ACCOUNTING", "_VIEW", session);
 
 glAccountId = request.getParameter("glAccountId");
 glAccount = delegator.findByPrimaryKey("GlAccount", [glAccountId : glAccountId]);

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/FindGlobalGlAccount.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/FindGlobalGlAccount.groovy?rev=663063&r1=663062&r2=663063&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/FindGlobalGlAccount.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/chartofaccounts/FindGlobalGlAccount.groovy Wed Jun  4 04:14:02 2008
@@ -17,11 +17,6 @@
  * under the License.
  */
 
-if (security.hasEntityPermission("ACCOUNTING", "_VIEW", session)) {
-    context.hasPermission = true;
-} else {
-    context.hasPermission = false;
-}
+context.hasPermission = security.hasEntityPermission("ACCOUNTING", "_VIEW", session);
 
-glAccounts = delegator.findList("GlAccount", null, null, null, null, false);
-context.glAccounts = glAccounts;
+context.glAccounts = delegator.findList("GlAccount", null, null, null, null, false);

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy?rev=663063&r1=663062&r2=663063&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/fixedasset/month.groovy Wed Jun  4 04:14:02 2008
@@ -30,10 +30,10 @@
 fixedAssetId = parameters.fixedAssetId;
 fixedAsset = delegator.findByPrimaryKeyCache("FixedAsset", [fixedAssetId: fixedAssetId]);
 
-String startMonth = parameters.month; //optional command to change the month
-Timestamp currentMonth = session.getAttribute("currentMonth");    // the month displayed the last time.
+startMonth = parameters.month; //optional command to change the month
+currentMonth = session.getAttribute("currentMonth");    // the month displayed the last time.
 
-Timestamp now = null;
+now = null;
 if (!startMonth || !currentMonth)    // a fresh start
     now = UtilDateTime.getMonthStart(UtilDateTime.nowTimestamp());
 else if (startMonth.equals("1") && currentMonth)
@@ -50,13 +50,13 @@
 currentMonth = now;
 nextMonth = UtilDateTime.getMonthStart(UtilDateTime.getMonthStart(now, 35));
 
-condition = new ArrayList();
+condition = [];
 condition.add(EntityCondition.makeCondition("calendarId", EntityOperator.EQUALS, fixedAsset.getString("calendarId")));
 condition.add(EntityCondition.makeCondition("exceptionDateStartTime",EntityOperator.GREATER_THAN, now));
 condition.add(EntityCondition.makeCondition("exceptionDateStartTime",EntityOperator.LESS_THAN, nextMonth));
-EntityConditionList ecl = EntityCondition.makeCondition(condition, EntityOperator.AND);
-List allDates = delegator.findList("TechDataCalendarExcDay", ecl, null, null, null, false);
-Iterator dbInt = allDates.iterator();
+ecl = EntityCondition.makeCondition(condition, EntityOperator.AND);
+allDates = delegator.findList("TechDataCalendarExcDay", ecl, null, null, null, false);
+dbInt = allDates.iterator();
 dbValid = false;    // flag to see if the current dbInt is ok
 excDayRecord = null;
 if (dbInt.hasNext())    {
@@ -67,20 +67,20 @@
 calendarStartWeek = UtilDateTime.getWeekStart(now);
 calendarEndDay = UtilDateTime.getWeekStart(nextMonth);
 
-Timestamp currentWeek = calendarStartWeek;
-weeks = new ArrayList();
+currentWeek = calendarStartWeek;
+weeks = [];
 while ( currentWeek.compareTo(calendarEndDay) <= 0 ){
-    days = UtilMisc.toMap("week",UtilDateTime.weekNumber(currentWeek));
+    days = [week : UtilDateTime.weekNumber(currentWeek)];
     
     for (int day = 1; day < 8 ; day++)    {
         String extraText = "";
         available = "N/A";
         if (dbValid == true && UtilDateTime.getDayStart(currentWeek,day).compareTo(excDayRecord.getTimestamp("exceptionDateStartTime")) == 0) {
-            if (fixedAsset.get("productionCapacity") != null && fixedAsset.getDouble("productionCapacity").doubleValue() != 0)
-                available = fixedAsset.getString("productionCapacity") + "*"; // default value
-            if (excDayRecord.get("exceptionCapacity") != null && excDayRecord.getDouble("exceptionCapacity").doubleValue() != 0)
-                available = excDayRecord.getString("exceptionCapacity");
-            extraText = "Avail.: " + available + "<br/>Allocated: " + excDayRecord.getString("usedCapacity");
+            if (fixedAsset.productionCapacity)
+                available = fixedAsset.productionCapacity + "*"; // default value
+            if (excDayRecord.exceptionCapacity)
+                available = excDayRecord.exceptionCapacity;
+            extraText = "Avail.: " + available + "<br/>Allocated: " + excDayRecord.usedCapacity;
             if (dbInt.hasNext()) {
                 excDayRecord = dbInt.next();
                 dbValid = true;
@@ -95,7 +95,7 @@
     weeks.add(days);
     currentWeek = UtilDateTime.getWeekStart(currentWeek,7);
 }
-int monthNr = NumberFormat.getNumberInstance().parse(now.toString().substring(5,7)).intValue();
+monthNr = NumberFormat.getNumberInstance().parse(now.toString().substring(5,7)).intValue();
 context.month = UtilDateTime.months[monthNr-1];
 context.year = now.toString().substring(0,4);
 context.weeks = weeks;

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/addTotalAmount.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/addTotalAmount.groovy?rev=663063&r1=663062&r2=663063&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/addTotalAmount.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/addTotalAmount.groovy Wed Jun  4 04:14:02 2008
@@ -42,6 +42,6 @@
     newInvoice.putAll(invoice);
 }
 
-newInvoice.invoiceAmount = new Double(invoiceTotal);
+newInvoice.invoiceAmount = invoiceTotal;
 context.invoiceExt = newInvoice;
 context.invoiceId = invoiceId;

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/createApplicationList.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/createApplicationList.groovy?rev=663063&r1=663062&r2=663063&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/createApplicationList.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/createApplicationList.groovy Wed Jun  4 04:14:02 2008
@@ -28,12 +28,11 @@
 import java.text.*;
 import java.text.NumberFormat;
 
-int decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
-int rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
+decimals = UtilNumber.getBigDecimalScale("invoice.decimals");
+rounding = UtilNumber.getBigDecimalRoundingMode("invoice.rounding");
 ZERO = BigDecimal.ZERO;
 
-invoiceId = request.getParameter("invoiceId");
-if (!invoiceId) invoiceId = context.invoiceId;
+invoiceId = request.getParameter("invoiceId") ?: context.invoiceId;
 invoice = delegator.findByPrimaryKey("Invoice", [invoiceId : invoiceId]);
 tabButtonItem = context.tabButtonItem;
 
@@ -107,4 +106,4 @@
 	context.invoiceId = invoiceId;
 }
 
-if(invoiceItems) context.put("invoiceApplications",invoiceItems);
+if(invoiceItems) context.invoiceApplications = invoiceItems;