Author: jleroux
Date: Tue May 15 08:19:58 2012
New Revision: 1338591
URL: http://svn.apache.org/viewvc?rev=1338591&view=rev
Log:
A patch from Pierre Smits "Rates don't start on the first moment of a day and
don't last till the latest moment of a day"
https://issues.apache.org/jira/browse/OFBIZ-4676
Currently rates for persons have a fromDate that starts on the moment the rate
is created but not on the first moment of the day. This increases the
difficulty to use rates in calculations. Rates should start on the first moment
of a day (eg 01-02-2012 00:00:00.000). Thus rates must end on the last moment
(eb 31-01-2012 23:59:59 999) of the day previous to the day a new rate starts.
Modified:
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/rate/RateServices.xml
Modified:
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/rate/RateServices.xml
URL:
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/rate/RateServices.xml?rev=1338591&r1=1338590&r2=1338591&view=diff
==============================================================================
---
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/rate/RateServices.xml
(original)
+++
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/rate/RateServices.xml
Tue May 15 08:19:58 2012
@@ -67,7 +67,7 @@ under the License.
<make-value entity-name="RateAmount" value-field="newEntity"/>
<set-pk-fields map="parameters" value-field="newEntity"/>
<set-nonpk-fields map="parameters" value-field="newEntity"/>
- <now-timestamp field="newEntity.fromDate"/>
+ <set field="newEntity.fromDate" value="${groovy:
org.ofbiz.base.util.UtilDateTime.getDayStart(nowTimestamp)}" type="Timestamp"/>
<clear-field field="newEntity.thruDate"/>
<create-value value-field="newEntity"/>
</simple-method>
@@ -99,7 +99,9 @@ under the License.
<entity-one entity-name="RateAmount" value-field="rateAmount"/>
<if-not-empty field="rateAmount">
- <now-timestamp field="rateAmount.thruDate"/>
+ <now-timestamp field="nowTimestamp"/>
+ <set field ="previousDay" value="${groovy:
org.ofbiz.base.util.UtilDateTime.adjustTimestamp(nowTimestamp,5,-1)}"
type="Timestamp"/>
+ <set field="rateAmount.thruDate" value="${groovy:
org.ofbiz.base.util.UtilDateTime.getDayEnd(previousDay)}" type="Timestamp"/>
<store-value value-field="rateAmount"/>
<else>
<add-error>