svn commit: r1818549 - /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/period/PeriodServices.java

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

svn commit: r1818549 - /ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/period/PeriodServices.java

mbrohl
Author: mbrohl
Date: Mon Dec 18 10:23:09 2017
New Revision: 1818549

URL: http://svn.apache.org/viewvc?rev=1818549&view=rev
Log:
Improved: General refactoring and code improvements, package
org.apache.ofbiz.accounting.period.
(OFBIZ-9885)

Thanks Julian Leichert for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/period/PeriodServices.java

Modified: ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/period/PeriodServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/period/PeriodServices.java?rev=1818549&r1=1818548&r2=1818549&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/period/PeriodServices.java (original)
+++ ofbiz/ofbiz-framework/trunk/applications/accounting/src/main/java/org/apache/ofbiz/accounting/period/PeriodServices.java Mon Dec 18 10:23:09 2017
@@ -38,12 +38,13 @@ import org.apache.ofbiz.service.Dispatch
 import org.apache.ofbiz.service.ServiceUtil;
 
 public class PeriodServices {
-    
+
     public static final String module = PeriodServices.class.getName();
     public static final String resource = "AccountingUiLabels";
 
-    /* find the date of the last closed CustomTimePeriod, or, if none available, the earliest date available of any
-     * CustomTimePeriod
+    /*
+     * find the date of the last closed CustomTimePeriod, or, if none available, the
+     * earliest date available of any CustomTimePeriod
      */
     public static Map<String, Object> findLastClosedDate(DispatchContext dctx, Map<String, ?> context) {
         Delegator delegator = dctx.getDelegator();
@@ -57,28 +58,31 @@ public class PeriodServices {
             findDate = UtilDateTime.nowTimestamp();
         }
 
-        Timestamp lastClosedDate = null;          // return parameters
+        Timestamp lastClosedDate = null; // return parameters
         GenericValue lastClosedTimePeriod = null;
         Map<String, Object> result = ServiceUtil.returnSuccess();
 
         try {
-            // try to get the ending date of the most recent accounting time period before findDate which has been closed
-            List<EntityCondition> findClosedConditions = UtilMisc.toList(EntityCondition.makeConditionMap("organizationPartyId", organizationPartyId),
+            // try to get the ending date of the most recent accounting time period before
+            // findDate which has been closed
+            List<EntityCondition> findClosedConditions = UtilMisc.toList(
+                    EntityCondition.makeConditionMap("organizationPartyId", organizationPartyId),
                     EntityCondition.makeCondition("thruDate", EntityOperator.LESS_THAN_EQUAL_TO, findDate),
                     EntityCondition.makeConditionMap("isClosed", "Y"));
             if (UtilValidate.isNotEmpty(periodTypeId)) {
                 // if a periodTypeId was supplied, use it
                 findClosedConditions.add(EntityCondition.makeConditionMap("periodTypeId", periodTypeId));
             }
-            GenericValue closedTimePeriod = EntityQuery.use(delegator).from("CustomTimePeriod").select("customTimePeriodId", "periodTypeId", "isClosed", "fromDate", "thruDate")
+            GenericValue closedTimePeriod = EntityQuery.use(delegator).from("CustomTimePeriod")
+                    .select("customTimePeriodId", "periodTypeId", "isClosed", "fromDate", "thruDate")
                     .where(findClosedConditions).orderBy("thruDate DESC").queryFirst();
 
             if (UtilValidate.isNotEmpty(closedTimePeriod) && UtilValidate.isNotEmpty(closedTimePeriod.get("thruDate"))) {
                 lastClosedTimePeriod = closedTimePeriod;
                 lastClosedDate = lastClosedTimePeriod.getTimestamp("thruDate");
             } else {
-                // uh oh, no time periods have been closed?  in that case, just find the earliest beginning of a time period for this organization
-                // and optionally, for this period type
+                // uh oh, no time periods have been closed? in that case, just find the earliest
+                // beginning of a time period for this organization and optionally, for this period type
                 Map<String, String> findParams = UtilMisc.toMap("organizationPartyId", organizationPartyId);
                 if (UtilValidate.isNotEmpty(periodTypeId)) {
                     findParams.put("periodTypeId", periodTypeId);
@@ -91,11 +95,11 @@ public class PeriodServices {
                 }
             }
 
-            result.put("lastClosedTimePeriod", lastClosedTimePeriod);  // ok if this is null - no time periods have been closed
-            result.put("lastClosedDate", lastClosedDate);  // should have a value - not null
+            result.put("lastClosedTimePeriod", lastClosedTimePeriod); // ok if this is null - no time periods have been closed
+            result.put("lastClosedDate", lastClosedDate); // should have a value - not null
             return result;
         } catch (GenericEntityException ex) {
-            return(ServiceUtil.returnError(ex.getMessage()));
+            return (ServiceUtil.returnError(ex.getMessage()));
         }
     }
 }