You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ha...@apache.org on 2011/07/05 10:15:37 UTC

svn commit: r1142915 [8/28] - in /ofbiz/trunk/specialpurpose: ./ scrum/ scrum/config/ scrum/data/ scrum/data/helpdata/ scrum/data/hookscripts/ scrum/documents/ scrum/dtd/ scrum/entitydef/ scrum/lib/ scrum/patches/ scrum/script/ scrum/script/org/ scrum/...

Added: ofbiz/trunk/specialpurpose/scrum/script/org/ofbiz/scrum/ScrumServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/scrum/script/org/ofbiz/scrum/ScrumServices.xml?rev=1142915&view=auto
==============================================================================
--- ofbiz/trunk/specialpurpose/scrum/script/org/ofbiz/scrum/ScrumServices.xml (added)
+++ ofbiz/trunk/specialpurpose/scrum/script/org/ofbiz/scrum/ScrumServices.xml Tue Jul  5 08:15:32 2011
@@ -0,0 +1,2950 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<simple-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd">
+    <simple-method method-name="updateSprintBacklogseq"
+        short-description="Update the portal page sequence numbers">
+        <if-compare field="parameters.statusId" operator="equals" value="Any">
+            <clear-field field="parameters.statusId"/>
+        </if-compare>
+        <if-compare field="parameters.mode" value="UP" operator="equals">
+            <!-- check custRequestTypeId -->
+            <entity-one value-field="custRequest" entity-name="CustRequest"/>
+            <if-compare field="custRequest.custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG">
+                <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId"/>
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <condition-list combine="or">
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                        </condition-list>
+                    </condition-list>
+                </entity-count>
+                <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId" />
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <!--<condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>-->
+                        <condition-list combine="and">
+                            <condition-list combine="or">
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                            </condition-list>
+                        </condition-list>
+                    </condition-list>
+                    <order-by field-name="sequenceNum" />
+                </entity-condition>
+                <else>
+                    <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId"/>
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                        </condition-list>
+                    </entity-count>
+                    <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId" />
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>
+                        </condition-list>
+                        <order-by field-name="sequenceNum" />
+                    </entity-condition>
+                </else>
+            </if-compare>
+            <loop count="${getNum}" field="i">
+                <if-compare operator="equals" value="${parameters.custRequestId}"
+                    field="custReq[i].custRequestId">
+                    <if-compare operator="not-equals" value="0" field="i">
+                        <set field="temp" from-field="custReq[i].sequenceNum" /><log level="always" message="$$$$$$$$$ temp : ${temp}"></log>
+                        <set field="custReq[i].sequenceNum" from-field="custReq[i-1].sequenceNum" />
+                        <set field="custReq[i-1].sequenceNum" from-field="temp" />
+
+                        <entity-one value-field="firstup" entity-name="CustRequest">
+                            <field-map field-name="custRequestId" from-field="custReq[i].custRequestId" />
+                        </entity-one><log level="always" message="666666666666666666666 firstup : ${firstup}"></log>
+                        <set field="firstup.sequenceNum" from-field="custReq[i].sequenceNum" />
+                        <if-empty field="firstup">
+                            <add-error><fail-message message="Cannot find with ID [${custReq[i].custRequestId}] and sequenceNum [${custReq[i].sequenceNum}]"/></add-error>
+                            <check-errors/>
+                                <else>
+                                    <store-value value-field="firstup" />
+                                </else>
+                        </if-empty>
+
+                        <entity-one value-field="lastup" entity-name="CustRequest">
+                            <field-map field-name="custRequestId" from-field="custReq[i-1].custRequestId" />
+                        </entity-one>
+                        <set field="lastup.sequenceNum" from-field="custReq[i-1].sequenceNum" />
+                        <if-empty field="lastup">
+                            <add-error><fail-message message="Cannot find with ID [${custReq[i-1].custRequestId}] and sequenceNum [${custReq[i-1].sequenceNum}]"/></add-error>
+                            <check-errors/>
+                                <else>
+                                    <store-value value-field="lastup" />
+                                </else>
+                        </if-empty>
+                    </if-compare>
+                </if-compare>
+            </loop>
+        </if-compare>
+        <!-- DOWN -->
+        <if-compare field="parameters.mode" value="DWN" operator="equals">
+            <entity-one value-field="custRequest" entity-name="CustRequest"/>
+            <if-compare field="custRequest.custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG">
+                <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId"/>
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <condition-list combine="or">
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                        </condition-list>
+                    </condition-list>
+                </entity-count>
+                <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId" />
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <!--<condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>-->
+                        <condition-list combine="and">
+                            <condition-list combine="or">
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                            </condition-list>
+                        </condition-list>
+                    </condition-list>
+                    <order-by field-name="sequenceNum" />
+                </entity-condition>
+                <else>
+                    <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId"/>
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                        </condition-list>
+                    </entity-count>
+                    <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId" />
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>
+                        </condition-list>
+                        <order-by field-name="sequenceNum" />
+                    </entity-condition>
+                </else>
+            </if-compare>
+            <loop count="${getNum-1}" field="i">
+                <if-compare operator="equals" value="${parameters.custRequestId}"
+                    field="custReq[i].custRequestId">
+                    <if-compare operator="not-equals" value="${getnum-1}"
+                        field="i">
+                        <set field="temp" from-field="custReq[i].sequenceNum" />
+                        <set field="custReq[i].sequenceNum" from-field="custReq[i+1].sequenceNum" />
+                        <set field="custReq[i+1].sequenceNum" from-field="temp" />
+
+                        <entity-one value-field="first" entity-name="CustRequest">
+                            <field-map field-name="custRequestId" from-field="custReq[i].custRequestId" />
+                        </entity-one>
+                        <set field="first.sequenceNum" from-field="custReq[i].sequenceNum" />
+                        <if-empty field="first">
+                            <add-error><fail-message message="Cannot find with ID [${custReq[i].custRequestId}] and sequenceNum [${custReq[i].sequenceNum}]"/></add-error>
+                            <check-errors/>
+                                <else>
+                                    <store-value value-field="first" />
+                                </else>
+                        </if-empty>
+
+                        <entity-one value-field="last" entity-name="CustRequest">
+                            <field-map field-name="custRequestId" from-field="custReq[i+1].custRequestId" />
+                        </entity-one>
+                        <set field="last.sequenceNum" from-field="custReq[i+1].sequenceNum" />
+                        <if-empty field="last">
+                            <add-error><fail-message message="Cannot find with ID [${custReq[i+1].custRequestId}] and sequenceNum [${custReq[i+1].sequenceNum}]"/></add-error>
+                            <check-errors/>
+                                <else>
+                                    <store-value value-field="last" />
+                                </else>
+                        </if-empty>
+                    </if-compare>
+                </if-compare>
+            </loop>
+        </if-compare>
+        <!-- TOP -->
+        <if-compare field="parameters.mode" value="TOP" operator="equals">
+            <entity-one value-field="custRequest" entity-name="CustRequest"/>
+            <if-compare field="custRequest.custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG">
+                <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId"/>
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <condition-list combine="or">
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                        </condition-list>
+                    </condition-list>
+                </entity-count>
+                <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId" />
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <!--<condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>-->
+                        <condition-list combine="and">
+                            <condition-list combine="or">
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                            </condition-list>
+                        </condition-list>
+                    </condition-list>
+                    <order-by field-name="sequenceNum" />
+                </entity-condition>
+                <else>
+                    <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId"/>
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                        </condition-list>
+                    </entity-count>
+                    <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId" />
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>
+                        </condition-list>
+                        <order-by field-name="sequenceNum" />
+                    </entity-condition>
+                </else>
+            </if-compare>
+            <set field="index" value="${getNum}" />
+            <set field="topCustReq" from-field="custReq[0]" />
+            <!-- loop search selected custReq -->
+            <loop count="${index}" field="i">
+                <if-compare operator="equals" value="${parameters.custRequestId}"
+                    field="custReq[i].custRequestId">
+                    <set field="selectedCustReq" from-field="custReq[i]" />
+                    <set field="diffIndex" value="${index-i}" />
+                    <set field="selectedIndex" from-field="i" />
+                </if-compare>
+            </loop>
+            <loop count="${selectedIndex}" field="j">
+                <entity-one value-field="custReqBottom" entity-name="CustRequest">
+                    <field-map field-name="custRequestId" from-field="custReq[j].custRequestId" />
+                </entity-one>
+                <set field="custReqBottom.sequenceNum" from-field="custReq[j+1].sequenceNum"
+                    type="Long" />
+                <if-empty field="custReqBottom">
+                    <add-error><fail-message message="Cannot find with ID [${custReq[j].custRequestId}] and sequenceNum [${custReq[j+1].sequenceNum}]"/></add-error>
+                    <check-errors/>
+                        <else>
+                            <store-value value-field="custReqBottom" />
+                        </else>
+                </if-empty>
+            </loop>
+
+            <entity-one value-field="updatetop" entity-name="CustRequest">
+                <field-map field-name="custRequestId" from-field="selectedCustReq.custRequestId" />
+            </entity-one>
+            <set field="updatetop.sequenceNum" from-field="topCustReq.sequenceNum"
+                type="Long" />
+            <if-empty field="updatetop">
+                <add-error><fail-message message="Cannot find with ID [${selectedCustReq.custRequestId}] and sequenceNum [${topCustReq.sequenceNum}]"/></add-error>
+                <check-errors/>
+                    <else>
+                        <store-value value-field="updatetop" />
+                    </else>
+            </if-empty>
+        </if-compare>
+        <!-- buttom -->
+        <if-compare field="parameters.mode" value="BOT" operator="equals">
+            <entity-one value-field="custRequest" entity-name="CustRequest"/>
+            <if-compare field="custRequest.custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG">
+                <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId"/>
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <condition-list combine="or">
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                        </condition-list>
+                    </condition-list>
+                </entity-count>
+                <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                    <condition-list combine="and">
+                        <condition-expr field-name="productId" from-field="parameters.productId" />
+                        <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_UNPLAN_BACKLOG"/>
+                        <!--<condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>-->
+                        <condition-list combine="and">
+                            <condition-list combine="or">
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                                <condition-expr field-name="statusId" operator="equals" value="CRQ_REVIEWED"/>
+                            </condition-list>
+                        </condition-list>
+                    </condition-list>
+                    <order-by field-name="sequenceNum" />
+                </entity-condition>
+                <else>
+                    <entity-count count-field="getNum" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId"/>
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" operator="equals" value="CRQ_ACCEPTED"/>
+                        </condition-list>
+                    </entity-count>
+                    <entity-condition list="custReq" entity-name="CustRequestAndCustRequestItem">
+                        <condition-list combine="and">
+                            <condition-expr field-name="productId" from-field="parameters.productId" />
+                            <condition-expr field-name="custRequestTypeId" operator="equals" value="RF_PROD_BACKLOG"/>
+                            <condition-expr field-name="statusId" from-field="parameters.statusId" ignore-if-empty="true"/>
+                        </condition-list>
+                        <order-by field-name="sequenceNum" />
+                    </entity-condition>
+                </else>
+            </if-compare>
+            <set field="index" value="${getNum-1}" />
+            <set field="bottomCustReq" from-field="custReq[index]" />
+            <!-- loop search selected custReq -->
+            <loop count="${index}" field="i"><log level="always" message="////////// i : ${i}"></log>
+                <if-compare-field operator="equals"
+                    field="parameters.custRequestId" to-field="custReq[i].custRequestId">
+                    <set field="selectedCustReq" from-field="custReq[i]" />
+                    <set field="diffIndex" value="${index-i}" />
+                    <set field="selectedIndex" from-field="i" />
+                </if-compare-field>
+            </loop>
+            <loop count="${diffIndex}" field="j"><log level="always" message="////////// j : ${j}"></log>
+                <set field="lowerSeqNum" from-field="custReq[j+selectedIndex].sequenceNum" />
+
+                <entity-one value-field="update" entity-name="CustRequest">
+                    <field-map field-name="custRequestId"
+                        from-field="custReq[j+selectedIndex+1].custRequestId" />
+                </entity-one>
+                <if-empty field="update">
+                    <!--
+                    <add-error><fail-message message="Cannot find with ID [${custReq[j+selectedIndex+1]}]"/></add-error>
+                    <check-errors/>
+                    -->
+                    <else>
+                        <set field="update.sequenceNum" from-field="lowerSeqNum" type="Long" />
+                        <store-value value-field="update" />
+                    </else>
+                </if-empty>
+            </loop>
+            <entity-one value-field="update2" entity-name="CustRequest">
+                <field-map field-name="custRequestId" from-field="selectedCustReq.custRequestId" />
+            </entity-one>
+            <if-empty field="update2">
+                <!--
+                <add-error><fail-message message="Cannot find with ID [${selectedCustReq.custRequestId}] and sequenceNum [${bottomCustReq.sequenceNum}]"/></add-error>
+                <check-errors/>
+                -->
+                    <else>
+                        <set field="update2.sequenceNum" from-field="bottomCustReq.sequenceNum" type="Long" />
+                        <store-value value-field="update2" />
+                    </else>
+            </if-empty>
+        </if-compare>
+    </simple-method>
+
+    <simple-method method-name="getProjectInfoFromTask"
+        short-description="Get the projectId when a sprint backlog or task is provided."
+        login-required="true">
+        <if-empty field="parameters.taskId">
+            <if-empty field="parameters.sprintId">
+                <return />
+            </if-empty>
+        </if-empty>
+        <if-not-empty field="parameters.taskId"><!-- taskId is provided -->
+            <entity-one entity-name="WorkEffort" value-field="task">
+                <field-map field-name="workEffortId" from-field="parameters.taskId" />
+            </entity-one>
+            <if-not-empty field="task">
+                <entity-condition list="sprintList" entity-name="ProjectSprintBacklogAndTask">
+                    <condition-list combine="and">
+                        <condition-expr field-name="taskId" from-field="parameters.taskId"/>
+                        <condition-expr field-name="sprintTypeId" operator="equals" value="SCRUM_SPRINT"/>
+                    </condition-list>
+                </entity-condition>
+                <entity-one value-field="sprint" entity-name="WorkEffort">
+                    <field-map field-name="workEffortId" from-field="sprintList[0].sprintId"/>
+                </entity-one>
+                <else>
+                    <return />
+                </else>
+            </if-not-empty>
+            <else><!-- phaseId is provided -->
+                <entity-one entity-name="WorkEffort" value-field="sprint">
+                    <field-map field-name="workEffortId" from-field="parameters.sprintId" />
+                </entity-one>
+            </else>
+        </if-not-empty>
+        
+        <!-- get project info -->
+        <if-not-empty field="sprint">
+            <!-- get project from sprint -->
+            <entity-condition list="projectList" entity-name="ProjectSprintBacklogAndTask">
+                <condition-list combine="and">
+                    <condition-expr field-name="sprintId" from-field="sprint.workEffortId"/>
+                    <condition-expr field-name="sprintTypeId" operator="equals" value="SCRUM_SPRINT"/>
+                    <condition-expr field-name="taskId" from-field="parameters.taskId"/>
+                </condition-list>
+            </entity-condition>
+            <first-from-list entry="project" list="projectList"/>
+            <field-to-result field="project.projectId"
+                result-name="projectId" />
+            <field-to-result field="project.projectName"
+                result-name="projectName" />
+            <field-to-result field="sprint.workEffortId"
+                result-name="sprintId" />
+            <field-to-result field="sprint.workEffortName"
+                result-name="sprintName" />
+            <field-to-result field="task.workEffortId"
+                result-name="taskId" />
+            <field-to-result field="task.workEffortName"
+                result-name="taskName" />
+            <!-- return backlogId and backlogName as result -->
+            <field-to-result field="project.custRequestId"
+                result-name="backlogId" />
+            <field-to-result field="project.description"
+                result-name="backlogName" />
+            <set field="taskWbsId"
+                value="${project.projectId}.${sprint.sequenceNum}.${task.sequenceNum}" />
+            <field-to-result field="taskWbsId" />
+            <else>
+                <entity-condition list="tasksDetail" entity-name="ProjectSprintBacklogTaskAndParty">
+                    <condition-list combine="and">
+                        <condition-expr field-name="taskId" from-field="task.workEffortId"/>
+                    </condition-list>
+                </entity-condition>
+                <field-to-result field="task.workEffortId" result-name="taskId" />
+                <field-to-result field="task.workEffortName" result-name="taskName" />
+                <field-to-result field="tasksDetail[0].custRequestId" result-name="backlogId" />
+                <field-to-result field="tasksDetail[0].description" result-name="backlogName" />
+            </else>
+        </if-not-empty>
+    </simple-method>
+
+    <simple-method method-name="updateTimesheetEntryByWorkeffort"
+        short-description="Update workeffort by workeffortId and timesheetId ">
+        <field-to-result field="parameters.timesheetId"
+            result-name="timesheetId" />
+        <if-empty field="parameters.workEffortId">
+            <return />
+        </if-empty>
+        <if-compare field="parameters.workEffortId" operator="equals"
+            value="Totals">
+            <return />
+        </if-compare>
+        
+        <!-- Check : if parameter of workEffortId is leaveTypeId in EmplLeaveType -->
+        <entity-one value-field="emplLeaveTypeMap" entity-name="EmplLeaveType">
+            <field-map field-name="leaveTypeId" from-field="parameters.workEffortId"/>
+        </entity-one>
+        <if-not-empty field="emplLeaveTypeMap">
+            <!-- Check role -->
+            <entity-one entity-name="Timesheet" value-field="timesheet" />
+            <entity-one entity-name="UserLogin" value-field="systemUserLogin">
+                <field-map field-name="userLoginId" value="system"/>
+            </entity-one>
+            <entity-one value-field="partyRoleMap" entity-name="PartyRole">
+                <field-map field-name="partyId" from-field="timesheet.partyId"/>
+                <field-map field-name="roleTypeId" value="EMPLOYEE"/>
+            </entity-one>
+            <if-empty field="partyRoleMap">
+                <set field="partyRoleMap.partyId" from-field="timesheet.partyId"/>
+                <set field="partyRoleMap.roleTypeId" value="EMPLOYEE"/>
+                <set field="partyRoleMap.userLogin" from-field="systemUserLogin"/>
+                <call-service service-name="createPartyRole" in-map-name="partyRoleMap"/>
+            </if-empty>
+            <loop count="7" field="dayNr">
+                <if>
+                    <condition>
+                        <and>
+                            <if-compare field="parameters.hoursDay${dayNr}" value="-999999" operator="not-equals" />
+                        </and>
+                    </condition>
+                    <then>
+                        <if-not-empty field="parameters.hoursDay${dayNr}">
+                            <!-- check day -->
+                            <set field="fromDate" from-field="timesheet.fromDate"/>
+                            <set field="days" value="${dayNr}" type="Integer"/>
+                            <set field="hours" from-field="parameters.hoursDay${dayNr}" type="Integer" default-value="0"/>
+                            <!-- for fromDate and thuDate with time-->
+                            <set field="leaveFromDate" value="${groovy:import java.sql.Timestamp;
+                                return new Timestamp(fromDate.getTime() + ((int) (24L*60L*60L*1000L*days)));}"/>
+                            <set field="emplLeaveFromDate" from-field="leaveFromDate" type="Timestamp"/>
+                            <set field="leaveThruDate" value="${groovy:import java.sql.Timestamp;
+                                return new Timestamp(emplLeaveFromDate.getTime() + ((int) (60L*60L*1000L*hours)));}"/>
+                            <set field="emplLeaveThruDate" from-field="leaveThruDate" type="Timestamp"/>
+                            <entity-one value-field="emplLeaveMap" entity-name="EmplLeave">
+                                <field-map field-name="partyId" from-field="timesheet.partyId"/>
+                                <field-map field-name="leaveTypeId" from-field="parameters.workEffortId"/>
+                                <field-map field-name="fromDate" from-field="emplLeaveFromDate"/>
+                            </entity-one>
+                            <if-not-empty field="emplLeaveMap">
+                                <if-compare field="emplLeaveMap.leaveStatus" operator="not-equals" value="LEAVE_APPROVED" >
+                                    <if-compare field="parameters.checkComplete" value="Y" operator="equals">
+                                        <set field="emplLeaveMap.leaveStatus" value="LEAVE_APPROVED"/>
+                                        <else>
+                                            <set field="emplLeaveMap.leaveStatus" value="LEAVE_CREATED"/>
+                                        </else>
+                                    </if-compare>
+                                    <set field="emplLeaveMap.thruDate" from-field="emplLeaveThruDate"/>
+                                    <store-value value-field="emplLeaveMap"/>
+                                </if-compare>
+                                <else>
+                                    <set field="leaveMap.partyId" from-field="timesheet.partyId"/>
+                                    <set field="leaveMap.leaveTypeId" from-field="emplLeaveTypeMap.leaveTypeId"/>
+                                    <set field="leaveMap.fromDate" from-field="emplLeaveFromDate"/>
+                                    <set field="leaveMap.thruDate" from-field="emplLeaveThruDate"/>
+                                    <set field="leaveMap.approverPartyId" value="admin"/>
+                                    <if-compare field="parameters.checkComplete" value="Y" operator="equals">
+                                        <set field="leaveMap.leaveStatus" value="LEAVE_APPROVED"/>
+                                        <else>
+                                            <set field="leaveMap.leaveStatus" value="LEAVE_CREATED"/>
+                                        </else>
+                                    </if-compare>
+                                    <set field="leaveMap.description" from-field="emplLeaveTypeMap.description"/>
+                                    <set field="leaveMap.userLogin" from-field="systemUserLogin"/>
+                                    <if-compare-field field="emplLeaveThruDate" operator="not-equals" to-field="emplLeaveFromDate" type="Timestamp">
+                                        <call-service service-name="createEmplLeave" in-map-name="leaveMap"/>
+                                    </if-compare-field>
+                                </else>
+                            </if-not-empty>
+                            <else>
+                                <set field="fromDate" from-field="timesheet.fromDate"/>
+                                <set field="days" value="${dayNr}" type="Integer"/>
+                                <set field="hours" from-field="parameters.hoursDay${dayNr}" type="Integer" default-value="0"/>
+                                <set field="leaveFromDate" value="${groovy:import java.sql.Timestamp;
+                                    return new Timestamp(fromDate.getTime() + ((int) (24L*60L*60L*1000L*days)));}"/>
+                                <set field="emplLeaveFromDate" from-field="leaveFromDate" type="Timestamp"/>
+                                <set field="leaveThruDate" value="${groovy:import java.sql.Timestamp;
+                                return new Timestamp(emplLeaveFromDate.getTime() + ((int) (60L*60L*1000L*hours)));}"/>
+                                <set field="emplLeaveThruDate" from-field="leaveThruDate" type="Timestamp"/>
+                                <entity-one value-field="emplLeave" entity-name="EmplLeave">
+                                    <field-map field-name="partyId" from-field="timesheet.partyId"/>
+                                    <field-map field-name="leaveTypeId" from-field="parameters.workEffortId"/>
+                                    <field-map field-name="fromDate" from-field="emplLeaveFromDate"/>
+                                </entity-one>
+                                <!-- remove Leave Transaction -->
+                                 <if-not-empty field="emplLeave">
+                                    <if-compare-field field="emplLeaveThruDate" operator="equals" to-field="emplLeaveFromDate" type="Timestamp">
+                                        <remove-value value-field="emplLeave"/>
+                                     </if-compare-field>
+                                 </if-not-empty>
+                            </else>
+                        </if-not-empty>
+                    </then>
+                </if>
+            </loop>
+            <else>
+                <entity-one entity-name="Timesheet" value-field="timesheet" />
+                <entity-one entity-name="WorkEffort" value-field="taskStatus">
+                    <field-map field-name="workEffortId" from-field="parameters.workEffortId" />
+                </entity-one>
+
+                <!-- check if party assigned to task, when not add with roletype of project, if assigned check status -->
+                <entity-and entity-name="WorkEffortPartyAssignment" list="assigns" filter-by-date="true">
+                    <field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
+                    <field-map field-name="partyId" from-field="timesheet.partyId"/>
+                </entity-and>
+                <entity-and entity-name="ProjectSprintBacklogAndTask" list="meetingTasks">
+                    <field-map field-name="taskId" from-field="parameters.workEffortId"/>
+                    <field-map field-name="sprintTypeId" value="SCRUM_SPRINT"/>
+                    <field-map field-name="custRequestTypeId" value="RF_SCRUM_MEETINGS"/>
+                </entity-and>
+                <set field="parameters.partyId" from-field="timesheet.partyId"/>
+                <set field="isTaskAssings" value="Y"/>
+                <set field="isTaskMeeting" value="N"/>
+                <if-not-empty field="meetingTasks">
+                    <set field="isTaskMeeting" value="Y"/>
+                </if-not-empty>
+                <if-empty field="assigns">
+                    <set field="isTaskAssings" value="N"/>
+                </if-empty>
+                <check-errors />
+                <!-- check if the task don't assign to partyId -->
+                <if-compare operator="equals" value="Y" field="isTaskAssings">
+                <!-- check if the actual start date is set, when not set it to todays date -->
+                <if-empty field="project.actualStartDate">
+                    <entity-one entity-name="WorkEffort" value-field="workEffort" />
+                    <now-timestamp field="workEffort.actualStartDate" />
+                    <store-value value-field="workEffort" />
+                </if-empty>
+
+                <get-related value-field="timesheet" relation-name="TimeEntry" list="timeEntries" />
+                <!-- update existing entries -->
+                <if-compare field="taskStatus.currentStatusId" value="STS_COMPLETED" operator="not-equals">
+                    <set field="hours" value="0" type="Double" />
+                    <set field="planHours" value="0" type="Double" />
+                    <if-not-empty field="timeEntries">
+                        <iterate entry="timeEntry" list="timeEntries">
+                            <if-compare-field field="timeEntry.workEffortId" to-field="parameters.workEffortId" operator="equals">
+                                <if-compare-field field="timeEntry.timesheetId" to-field="parameters.timesheetId" operator="equals">
+                                <if-compare-field field="timeEntry.partyId" to-field="parameters.partyId" operator="equals">
+                                    <if>
+                                        <condition>
+                                            <or>
+                                                <not>
+                                                    <if-empty field="timeEntry.hours" />
+                                                </not>
+                                                <not>
+                                                    <if-empty field="timeEntry.planHours" />
+                                                </not>
+                                            </or>
+                                        </condition>
+                                        <then>
+                                            <remove-value value-field="timeEntry" />
+                                        </then>
+                                        <else>
+                                            <!-- translate the date into the day number -->
+                                            <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="getIntervalInDays" ret-field="dayNumber">
+                                                <field field="timesheet.fromDate" type="java.sql.Timestamp" />
+                                                <field field="timeEntry.fromDate" type="java.sql.Timestamp" />
+                                            </call-class-method>
+                                            <!-- get the related field -->
+                                            <if-not-empty field="parameters.hoursDay${dayNumber}">
+                                                <set field="hours" from-field="parameters.hoursDay${dayNumber}" type="Double" />
+                                                <else>
+                                                    <set field="hours" value="0" type="Double" />
+                                                </else>
+                                            </if-not-empty>
+                                            <if-not-empty field="parameters.planHoursDay${dayNumber}">
+                                                <set field="planHours" from-field="parameters.planHoursDay${dayNumber}" type="Double" />
+                                                <else>
+                                                    <set field="planHours" value="0" type="Double" />
+                                                </else>
+                                            </if-not-empty>
+
+                                            <!-- update the time entry -->
+                                            <call-simple-method method-name="updateTimeEntry" />
+
+                                            <set field="parameters.hoursDay${dayNumber}" value="-999999" type="Double" />
+                                            <set field="parameters.planHoursDay${dayNumber}" value="-999999" type="Double" />
+                                        </else>
+                                    </if>
+                                    </if-compare-field>
+                                </if-compare-field>
+                            </if-compare-field>
+                        </iterate>
+                    </if-not-empty>
+
+                    <!-- process not yet done fields -->
+                    <loop count="7" field="dayNr">
+                        <if>
+                            <condition>
+                                <and>
+                                    <if-compare field="parameters.hoursDay${dayNr}" value="-999999" operator="not-equals" />
+                                    <if-compare field="parameters.planHoursDay${dayNr}" value="-999999" operator="not-equals" />
+                                    <or>
+                                        <not>
+                                            <if-empty field="parameters.hoursDay${dayNr}" />
+                                        </not>
+                                        <not>
+                                            <if-empty field="parameters.planHoursDay${dayNr}" />
+                                        </not>
+                                    </or>
+                                </and>
+                            </condition>
+                            <then>
+                                <if-empty field="parameters.hoursDay${dayNr}">
+                                    <set field="hours" value="0" type="Double" />
+                                    <else>
+                                        <set field="hours" from-field="parameters.hoursDay${dayNr}" type="Double" />
+                                    </else>
+                                </if-empty>
+                                <if-empty field="parameters.planHoursDay${dayNr}">
+                                    <entity-one entity-name="WorkEffort" value-field="task" />
+                                    <set field="planHours" value="${task.estimatedMilliSeconds/1000/60/60}"
+                                        type="Double" />
+                                    <else>
+                                        <set field="planHours" from-field="parameters.planHoursDay${dayNr}"
+                                            type="Double" />
+                                    </else>
+                                </if-empty>
+                                <call-class-method class-name="org.ofbiz.base.util.UtilDateTime"
+                                    method-name="addDaysToTimestamp" ret-field="fromDate">
+                                    <field field="timesheet.fromDate" type="java.sql.Timestamp" />
+                                    <field field="dayNr" type="int" />
+                                </call-class-method>
+                                <!-- update the time entry -->
+                                <call-simple-method method-name="updateTimeEntry" />
+                            </then>
+                        </if>
+                    </loop>
+                    <else>
+                        <!-- update the time entry on task completed -->
+                        <if-not-empty field="timeEntries">
+                            <iterate entry="timeEntry" list="timeEntries">
+                                <if-compare-field field="timeEntry.workEffortId" to-field="parameters.workEffortId" operator="equals">
+                                    <if-compare-field field="timeEntry.timesheetId" to-field="parameters.timesheetId" operator="equals">
+                                        <if-compare-field field="timeEntry.partyId" to-field="parameters.partyId" operator="equals">
+                                            <set field="timeEntry.rateTypeId" from-field="parameters.rateTypeId" />
+                                            <store-value value-field="timeEntry"/>
+                                        </if-compare-field>
+                                    </if-compare-field>
+                                </if-compare-field>
+                            </iterate>
+                        </if-not-empty>
+                    </else>
+                </if-compare>
+        
+                <if-empty field="parameters.planHours">
+                    <set field="parameters.planHours" from-field="planHours" />
+                </if-empty>
+                <!-- Update plan hour -->
+                <if-not-empty field="parameters.planHours">
+                    <!-- Check plan hour -->
+                    <if-compare operator="less" value="0" field="parameters.planHours"
+                        type="Double">
+                        <property-to-field resource="scrumUiLabels"
+                            property="ScrumNotAllowSetActualHours" field="scrumNotAllowSetActualHours" />
+                        <add-error>
+                            <fail-message
+                                message="Don't allow plan hours is less than zero on Task Id : ${parameters.workEffortId}" />
+                        </add-error>
+                        <check-errors />
+                    </if-compare>
+                    <if-compare field="parameters.checkComplete" value="Y" operator="equals">
+                        <if-compare field="taskStatus.currentStatusId" value="STS_COMPLETED" operator="equals">
+                            <if-compare-field operator="not-equals" field="parameters.planHours" to-field="parameters.actualHours" type="Double">
+                                <set field="parameters.planHours" from-field="parameters.actualHours" />
+                            </if-compare-field>
+                            <else>
+                                <set field="actualMap.taskId" from-field="parameters.workEffortId" />
+                                
+                                <if-compare operator="equals" field="isTaskMeeting" value="Y">
+                                    <set field="actualMap.partyId" from-field="userLogin.partyId" />
+                                </if-compare>
+                                <call-service service-name="getScrumActualHour" in-map-name="actualMap">
+                                    <result-to-field result-name="actualHours" />
+                                </call-service>
+                                <if-compare-field operator="not-equals" field="parameters.planHours" to-field="actualHours" type="Double">
+                                    <set field="parameters.planHours" from-field="actualHours" />
+                                </if-compare-field>
+                            </else>
+                        </if-compare>
+                    </if-compare>
+                    <now-timestamp field="nowTimestamp" />
+                    <call-class-method class-name="org.ofbiz.base.util.UtilDateTime"
+                        method-name="getDayStart" ret-field="dayStart">
+                        <field field="nowTimestamp" type="java.sql.Timestamp" />
+                    </call-class-method>
+                    <call-class-method class-name="org.ofbiz.base.util.UtilDateTime"
+                        method-name="getDayEnd" ret-field="dayEnd">
+                        <field field="nowTimestamp" type="java.sql.Timestamp" />
+                    </call-class-method>
+                    <entity-condition entity-name="TimeEntry" list="lastTimeEntrys">
+                        <condition-list combine="and">
+                            <condition-expr field-name="workEffortId" from-field="parameters.workEffortId" />
+                            <condition-expr field-name="partyId" from-field="userLogin.partyId" />
+                        </condition-list>
+                        <order-by field-name="-fromDate" />
+                    </entity-condition>
+                    <first-from-list entry="lastTimeEntry" list="lastTimeEntrys" />
+                    <if-not-empty field="lastTimeEntry">
+                        <set field="lastTimeEntry.planHours" from-field="parameters.planHours" />
+                        <set field="lastTimeEntry.rateTypeId" from-field="parameters.rateTypeId" />
+                        <store-value value-field="lastTimeEntry" />
+                        <!--<else>
+                            <set-service-fields service-name="createTimeEntry" map="parameters" to-map="teCreMap" />
+                            <set field="teCreMap.fromDate" from-field="dayStart" />
+                            <set field="teCreMap.partyId" from-field="userLogin.partyId"/>
+                            <call-service service-name="createTimeEntry" in-map-name="teCreMap" />
+                        </else>-->
+                    </if-not-empty>
+                </if-not-empty>
+                <!-- Check actual hour -->
+                <set field="taskActualMap.taskId" from-field="parameters.workEffortId" />
+                <set field="taskActualMap.partyId" from-field="userLogin.partyId" />
+                <call-service service-name="getScrumActualHour"
+                    in-map-name="taskActualMap">
+                    <result-to-field result-name="actualHours" />
+                </call-service>
+                <set field="taskPlanMap.taskId" from-field="parameters.workEffortId" />
+                <set field="taskPlanMap.partyId" from-field="userLogin.partyId" />
+                <call-service service-name="getScrumPlanHour" in-map-name="taskPlanMap">
+                    <result-to-field result-name="planHours" />
+                </call-service>
+                <if-compare-field field="actualHours" operator="greater" type="Double" to-field="planHours">
+                    <property-to-field resource="scrumUiLabels"
+                        property="ScrumNotAllowSetActualHours" field="scrumNotAllowSetActualHours" />
+                    <add-error>
+                        <fail-message message="${scrumNotAllowSetActualHours} on Task Id : ${parameters.workEffortId}" />
+                    </add-error>
+                    <check-errors />
+                </if-compare-field>
+                <!-- update the assignment status if required -->
+                <if-compare field="parameters.checkComplete" value="Y" operator="equals">
+                    <if-compare field="hours" operator="not-equals" value="0">
+                            <entity-and entity-name="WorkEffortPartyAssignment" list="assigns" filter-by-date="true">
+                                <field-map field-name="workEffortId" from-field="parameters.workEffortId" />
+                                <field-map field-name="partyId" from-field="timesheet.partyId" />
+                            </entity-and>
+                            <if-compare operator="not-equals" value="SCAS_COMPLETED" field="assigns[0].statusId">
+                            <first-from-list entry="alreadyAssign" list="assigns" />
+                            <if-compare field="alreadyAssign.statusId" value="SCAS_COMPLETED" operator="not-equals">
+                                <set field="upStat.partyId" from-field="timesheet.partyId" />
+                                <set field="upStat.statusId" value="SCAS_COMPLETED" />
+                                <set field="upStat.roleTypeId" from-field="alreadyAssign.roleTypeId" />
+                                <set field="upStat.workEffortId" from-field="parameters.workEffortId" />
+                                <set field="upStat.fromDate" from-field="alreadyAssign.fromDate" />
+                                <set field="upStat.webSiteId" from-field="parameters.webSiteId" />
+                                <call-service service-name="updateScrumTaskAssigment" in-map-name="upStat" />
+                            </if-compare>
+                        </if-compare>
+                    </if-compare>
+                </if-compare>
+                    <else>
+                        <get-related value-field="timesheet" relation-name="TimeEntry" list="timeEntries" />
+                        <!-- update the time entry on task completed -->
+                        <if-not-empty field="timeEntries">
+                            <iterate entry="timeEntry" list="timeEntries">
+                                <if-compare-field field="timeEntry.workEffortId" to-field="parameters.workEffortId" operator="equals">
+                                    <if-compare-field field="timeEntry.timesheetId" to-field="parameters.timesheetId" operator="equals">
+                                        <if-compare-field field="timeEntry.partyId" to-field="parameters.partyId" operator="equals">
+                                            <set field="timeEntry.rateTypeId" from-field="parameters.rateTypeId" />
+                                            <store-value value-field="timeEntry"/>
+                                        </if-compare-field>
+                                    </if-compare-field>
+                                </if-compare-field>
+                            </iterate>
+                        </if-not-empty>
+                    </else>
+                </if-compare>
+                
+                <!--if plan hours(from task) more than first plan hours -->
+                <entity-and list="custRequestWorkEffortList" entity-name="CustRequestWorkEffort">
+                    <field-map field-name="workEffortId" from-field="parameters.workEffortId"/>
+                </entity-and>
+                <first-from-list entry="custRequestWorkEffortMap" list="custRequestWorkEffortList"/>
+                <set field="backlogPlanMap.custRequestId" from-field="custRequestWorkEffortMap.custRequestId" />
+                <set field="taskPlanMap.custRequestId" from-field="custRequestWorkEffortMap.custRequestId" />
+                <call-service service-name="getScrumPlanHour" in-map-name="backlogPlanMap">
+                    <result-to-field result-name="planHours" />
+                </call-service>
+                <call-service service-name="getScrumPlanHour" in-map-name="taskPlanMap">
+                    <result-to-field result-name="initPlanHours"/>
+                </call-service>
+                <if-compare-field field="planHours"  operator="greater" to-field="initPlanHours"  type="Double">
+                    <entity-one value-field="custRequestMap" entity-name="CustRequest">
+                        <field-map field-name="custRequestId" from-field="custRequestWorkEffortMap.custRequestId"/>
+                    </entity-one>
+                    <set field="planHoursIn" from-field="planHours" type="Double"/>
+                    <set field="custRequestMap.estimatedMilliSeconds" value="${groovy:planHoursIn*1000*60*60}" type="Double"/>
+                    <store-value value-field="custRequestMap"/>
+                    <else>
+                        <if-compare-field field="initPlanHours"  operator="greater" to-field="planHours"  type="Double">
+                            <entity-one value-field="custRequestMap" entity-name="CustRequest">
+                                <field-map field-name="custRequestId" from-field="custRequestWorkEffortMap.custRequestId"/>
+                            </entity-one>
+                            <set field="planHoursIn" from-field="planHours" type="Double"/>
+                            <set field="custRequestMap.estimatedMilliSeconds" value="${groovy:planHoursIn*1000*60*60}" type="Double"/>
+                            <store-value value-field="custRequestMap"/>
+                        </if-compare-field>
+                    </else>
+                </if-compare-field>
+            </else>
+        </if-not-empty>
+    </simple-method>
+
+    <simple-method method-name="updateTimeEntry"
+        short-description="">
+        <if-compare field="hours" value="-1" operator="equals">
+            <return />
+        </if-compare>
+        <if-not-empty field="timeEntry.timeEntryId">
+            <if-compare field="hours" operator="equals" value="0" type="Double">
+                <set field="teDelMap.timeEntryId" from-field="timeEntry.timeEntryId" />
+                <call-service service-name="deleteTimeEntry"
+                    in-map-name="teDelMap" />
+                <else>
+                    <clear-field field="teUpdMap" />
+                    <set field="teUpdMap.hours" from-field="hours" type="Double" />
+                    <set field="teUpdMap.planHours" from-field="planHours" type="Double" />
+                    <set field="teUpdMap.timeEntryId" from-field="timeEntry.timeEntryId" />
+                    <set field="teUpdMap.workEffortId" from-field="parameters.workEffortId" />
+                    <set field="teUpdMap.timesheetId" from-field="parameters.timesheetId" />
+                    <set field="teUpdMap.rateTypeId" from-field="parameters.rateTypeId" />
+                    <set field="teUpdMap.partyId" from-field="parameters.partyId"/>
+                    <call-service service-name="updateTimeEntry"
+                        in-map-name="teUpdMap" />
+                </else>
+            </if-compare>
+            <else>
+                <if>
+                    <condition>
+                        <or>
+                            <not>
+                                <if-empty field="hours" />
+                            </not>
+                            <not>
+                                <if-empty field="planHours" />
+                            </not>
+                        </or>
+                    </condition>
+                    <then>
+                        <if-compare field="hours" operator="greater" value="0" type="Double">
+                            <set-service-fields service-name="createTimeEntry"
+                                map="parameters" to-map="teCreMap" />
+                            <set field="teCreMap.planHours" from-field="planHours" type="Double" />
+                            <set field="teCreMap.hours" from-field="hours" type="Double" />
+                            <set field="teCreMap.fromDate" from-field="fromDate" />
+                            <set field="teCreMap.partyId" from-field="parameters.partyId"/>
+                            <set field="teCreMap.workEffortId" from-field="parameters.workEffortId" />
+                            <set field="teCreMap.timesheetId" from-field="parameters.timesheetId" />
+                            <call-service service-name="createTimeEntry"
+                                in-map-name="teCreMap" />
+                       </if-compare>
+                    </then>
+                </if>
+            </else>
+        </if-not-empty>
+    </simple-method>
+
+    <simple-method method-name="getScrumActualHour"
+        short-description="Get actual hour from (Project, Sprint , Sprint Backlog and Task).">
+        <if>
+            <condition>
+                <or>
+                    <not>
+                        <if-empty field="parameters.projectId" />
+                    </not>
+                    <not>
+                        <if-empty field="parameters.sprintId" />
+                    </not>
+                    <not>
+                        <if-empty field="parameters.custRequestId" />
+                    </not>
+                </or>
+            </condition>
+            <then>
+                <if-not-empty field="parameters.custRequestId">
+                    <entity-and entity-name="CustRequest" list="resultCustType">
+                        <field-map field-name="custRequestId" from-field="parameters.custRequestId" />
+                        <field-map field-name="custRequestTypeId" value="RF_UNPLAN_BACKLOG" />
+                    </entity-and>
+                </if-not-empty>
+                <if-empty field="resultCustType">
+                    <entity-condition list="tasks" entity-name="ProjectSprintBacklogAndTask">
+                        <condition-list combine="and">
+                            <condition-expr field-name="projectId" operator="equals" from-field="parameters.projectId" ignore-if-empty="true" />
+                            <condition-expr field-name="sprintId" operator="equals" from-field="parameters.sprintId" ignore-if-empty="true" />
+                            <condition-expr field-name="custRequestId" operator="equals" from-field="parameters.custRequestId" ignore-if-empty="true" />
+                            <condition-expr field-name="sprintTypeId" operator="equals" value="SCRUM_SPRINT" />
+                            <condition-list combine="or">
+                                <condition-expr field-name="taskTypeId" operator="equals" value="SCRUM_TASK_ERROR" />
+                                <condition-expr field-name="taskTypeId" operator="equals" value="SCRUM_TASK_IMPL" />
+                                <condition-expr field-name="taskTypeId" operator="equals" value="SCRUM_TASK_INST" />
+                                <condition-expr field-name="taskTypeId" operator="equals" value="SCRUM_TASK_TEST" />
+                            </condition-list>
+                        </condition-list>
+                    </entity-condition>
+                    <if-not-empty field="tasks">
+                        <iterate entry="task" list="tasks">
+                            <set field="taskIdCond[+0]" from-field="task.taskId" />
+                        </iterate>
+                        <entity-condition list="timeEntries" entity-name="TimeEntry">
+                            <condition-expr field-name="workEffortId" operator="in" from-field="taskIdCond" />
+                            <order-by field-name="workEffortId" />
+                        </entity-condition>
+                    </if-not-empty>
+                    <else>
+                        <entity-condition list="tasks" entity-name="UnPlannedBacklogsAndTasks">
+                            <condition-list combine="and">
+                                <condition-expr field-name="custRequestId" from-field="parameters.custRequestId"/>
+                                <condition-expr field-name="custRequestTypeId" value="RF_UNPLAN_BACKLOG"/>
+                                <condition-list combine="or">
+                                    <condition-expr field-name="workEffortTypeId" operator="equals" value="SCRUM_TASK_ERROR" />
+                                    <condition-expr field-name="workEffortTypeId" operator="equals" value="SCRUM_TASK_IMPL" />
+                                    <condition-expr field-name="workEffortTypeId" operator="equals" value="SCRUM_TASK_INST" />
+                                    <condition-expr field-name="workEffortTypeId" operator="equals" value="SCRUM_TASK_TEST" />
+                                </condition-list>
+                            </condition-list>
+                        </entity-condition>
+                        <if-not-empty field="tasks">
+                            <iterate entry="task" list="tasks">
+                                <set field="taskIdCond[+0]" from-field="task.workEffortId" />
+                            </iterate>
+                            <entity-condition list="timeEntries" entity-name="TimeEntry">
+                                <condition-expr field-name="workEffortId" operator="in" from-field="taskIdCond" />
+                                <order-by field-name="workEffortId" />
+                            </entity-condition>
+                        </if-not-empty>
+                    </else>
+                </if-empty>
+            </then>
+        </if>
+        
+        <!-- get time entry from task -->
+        <if-not-empty field="parameters.taskId">
+            <entity-condition list="timeEntries" entity-name="TimeEntry">
+                <condition-list combine="and">
+                    <condition-expr field-name="workEffortId" from-field="parameters.taskId"/>
+                    <condition-expr field-name="partyId" from-field="parameters.partyId" ignore-if-empty="true"/>
+                </condition-list>
+            </entity-condition>
+        <else>
+            <if-not-empty field="taskIdCond">
+                <entity-condition list="timeEntries" entity-name="TimeEntry">
+                    <condition-list combine="and">
+                        <condition-expr field-name="workEffortId" operator="in" from-field="taskIdCond"/>
+                    </condition-list>
+                </entity-condition>
+                <entity-condition list="listTimeEntriesNotBill" entity-name="TimeEntry">
+                    <condition-list combine="and">
+                        <condition-expr field-name="workEffortId" operator="in" from-field="taskIdCond"/>
+                        <condition-expr field-name="invoiceId" operator="equals" from-field="nullField"/>
+                    </condition-list>
+                </entity-condition>
+            </if-not-empty>
+        </else>
+        </if-not-empty>
+        <set field="actualHours" type="Double" value="0.0" />
+        <if-not-empty field="timeEntries">
+            <iterate entry="timeEntry" list="timeEntries">
+                <if-not-empty field="timeEntry.hours">
+                    <calculate field="actualHours" type="Double">
+                        <calcop operator="add" field="timeEntry.hours">
+                            <calcop operator="get" field="actualHours" />
+                        </calcop>
+                    </calculate>
+                </if-not-empty>
+            </iterate>
+        </if-not-empty>
+        <set field="actualHoursNotBillYet" type="Double" value="0.0" />
+        <if-not-empty field="listTimeEntriesNotBill">
+            <iterate entry="timeEntryNotBill" list="listTimeEntriesNotBill">
+                <if-not-empty field="timeEntryNotBill.partyId">
+                    <entity-and entity-name="PartyRate" list="partyRates" filter-by-date="true">
+                        <field-map field-name="rateTypeId" from-field="timeEntryNotBill.rateTypeId"/>
+                        <field-map field-name="partyId" from-field="timeEntryNotBill.partyId"/>
+                    </entity-and>
+                    <if-not-empty field="partyRates">
+                        <first-from-list entry="partyRate" list="partyRates"/>
+                        <if-not-empty field="partyRate.percentageUsed">
+                            <calculate field="timeEntryNotBill.hours" type="Double">
+                                <calcop operator="multiply" field="timeEntryNotBill.hours">
+                                    <calcop operator="get" field="partyRate.percentageUsed"/>
+                                </calcop>
+                            </calculate>
+                            <calculate field="timeEntryNotBill.hours" type="Double">
+                                <calcop operator="divide" field="timeEntryNotBill.hours">
+                                    <number value="100"/>
+                                </calcop>
+                            </calculate>
+                        </if-not-empty>
+                    </if-not-empty>
+                </if-not-empty>
+                <if-not-empty field="timeEntryNotBill.hours">
+                    <calculate field="actualHoursNotBillYet" type="Double">
+                        <calcop operator="add" field="timeEntryNotBill.hours">
+                            <calcop operator="get" field="actualHoursNotBillYet" />
+                        </calcop>
+                    </calculate>
+                </if-not-empty>
+            </iterate>
+        </if-not-empty>
+        <field-to-result field="actualHours" result-name="actualHours" />
+        <field-to-result field="actualHoursNotBillYet" result-name="actualHoursNotBillYet" />
+    </simple-method>
+
+    <simple-method method-name="getScrumActualHourByTimesheet" short-description=" Get actual hour from (TimeSheet).">
+        <if-not-empty field="parameters.timesheetId">
+            <entity-condition list="timeEntries" entity-name="TimeEntry">
+                <condition-list combine="and">
+                    <condition-expr field-name="timesheetId" from-field="parameters.timesheetId"/>
+                </condition-list>
+            </entity-condition>
+        </if-not-empty>
+        <set field="actualHours" type="Double" value="0.0" />
+        <if-not-empty field="timeEntries">
+            <iterate entry="timeEntry" list="timeEntries">
+                <calculate field="actualHours" type="Double">
+                    <calcop operator="add" field="timeEntry.hours">
+                        <calcop operator="get" field="actualHours" />
+                    </calcop>
+                </calculate>
+            </iterate>
+        </if-not-empty>
+        <field-to-result field="actualHours" result-name="actualHours" />
+    </simple-method>
+
+    <simple-method method-name="updateScrumTaskAssigment"
+        short-description="Update task to resource assignment, if required create a new one by re-assigment"
+        login-required="true">
+        <field-to-result field="parameters.workEffortId"
+            result-name="workEffortId" />
+        <if>
+            <!-- check if a change in partyId Or roletypeId: need to delete and create new -->
+            <condition>
+                <or>
+                    <and>
+                        <not>
+                            <if-empty field="parameters.newPartyId" />
+                        </not>
+                        <if-compare-field field="parameters.partyId"
+                            to-field="parameters.newPartyId" operator="not-equals" />
+                    </and>
+                    <and>
+                        <not>
+                            <if-empty field="parameters.newRoleTypeId" />
+                        </not>
+                        <if-compare-field field="parameters.roleTypeId"
+                            to-field="parameters.newRoleTypeId" operator="not-equals" />
+                    </and>
+                </or>
+            </condition>
+            <then>
+                <!-- roleType and/or partyId changed: end old and create new assign -->
+                <entity-one entity-name="WorkEffortPartyAssignment"
+                    value-field="workEffortPartyAssignment" />
+                <set field="workEffortPartyAssignment.delegateReasonEnumId"
+                    from-field="parameters.delegateReasonEnumId" />
+                <set field="workEffortPartyAssignment.comments" from-field="parameters.comments" />
+                <set field="workEffortPartyAssignment.assignedByUserLoginId"
+                    from-field="userLogin.userLoginId" />
+                <now-timestamp field="workEffortPartyAssignment.thruDate" />
+                <store-value value-field="workEffortPartyAssignment" />
+                <!-- create a new one -->
+                <make-value value-field="newAssign" entity-name="WorkEffortPartyAssignment" />
+                <set field="newAssign.workEffortId" from-field="parameters.workEffortId" />
+                <set field="newAssign.partyId" from-field="parameters.newPartyId" />
+                <set field="newAssign.roleTypeId" from-field="parameters.newRoleTypeId" />
+                <set field="newAssign.assignedByUserLoginId" from-field="userLogin.userLoginId" />
+                <now-timestamp field="newAssign.fromDate" />
+                <set field="newAssign.statusId" value="SCAS_ASSIGNED" />
+                <create-value value-field="newAssign" />
+            </then>
+            <else>
+                <set field="fromDate" from-field="parameters.fromDate" type="Timestamp" />
+                <entity-one entity-name="WorkEffortPartyAssignment"
+                    value-field="assignment">
+                    <field-map field-name="workEffortId" from-field="parameters.workEffortId" />
+                    <field-map field-name="partyId" from-field="parameters.partyId" />
+                    <field-map field-name="roleTypeId" from-field="parameters.roleTypeId" />
+                    <field-map field-name="fromDate" from-field="fromDate" />
+                </entity-one>
+                <if-not-empty field="assignment">
+                    <!-- status changed or assignment ended -->
+                    <set-nonpk-fields value-field="assignment" map="parameters" />
+                    <store-value value-field="assignment" />
+                    <if-compare field="assignment.statusId" value="SCAS_COMPLETED"
+                        operator="equals">
+                        <call-simple-method method-name="updateScrumTaskStatusToComplete" />
+                    </if-compare>
+                    <else>
+                        <!-- new assignment -->
+                        <call-simple-method method-name="assignPartyToWorkEffort"
+                            xml-resource="component://workeffort/script/org/ofbiz/workeffort/workeffort/WorkEffortSimpleServices.xml" />
+                    </else>
+                </if-not-empty>
+            </else>
+        </if>
+    </simple-method>
+
+    <simple-method method-name="updateScrumTaskStatusToComplete"
+        short-description="Check partyassignments on a task, if all completes set task status to completed and set actual completiondate to now">
+        <entity-and entity-name="WorkEffortPartyAssignment" list="assignments"
+            filter-by-date="true">
+            <field-map field-name="workEffortId" from-field="parameters.workEffortId" />
+        </entity-and>
+        <!-- check if all open assignments were completed -->
+        <if-not-empty field="assignments">
+            <iterate entry="assignment" list="assignments">
+                <if-compare field="assignment.statusId" value="SCAS_COMPLETED" operator="not-equals">
+                    <set field="status" value="notcomplete" />
+                </if-compare>
+            </iterate>
+        </if-not-empty>
+        <if-empty field="status">
+            <now-timestamp field="parameters.actualCompletionDate" />
+            <set field="update.workEffortId" from-field="parameters.workEffortId" />
+            <set field="update.currentStatusId" value="STS_COMPLETED"/>
+            <set field="update.webSiteId" from-field="parameters.webSiteId" />
+            <call-service service-name="updateWorkEffort" in-map-name="update" />
+        </if-empty>
+    </simple-method>
+    <simple-method method-name="addProductTimeToNewInvoice"
+        short-description="add all reported time on all completed timesheets from all workefforts for a product">
+        <!-- recreate the invoice if still in preparation in order to correct errors. -->
+        <if-compare operator="equals" value="Y" field="parameters.reCreate">
+            <entity-one entity-name="Invoice" value-field="invoice" />
+            <if-empty field="invoice">
+                <add-error>
+                    <fail-message
+                        message="Could not find invoice with ID [${parameters.invoiceId}], not adding Timesheet Entries to it." />
+                </add-error>
+                <check-errors />
+            </if-empty>
+            <if-compare field="invoice.statusId" operator="not-equals"
+                value="INVOICE_IN_PROCESS">
+                <add-error>
+                    <fail-message
+                        message="Invoice with ID [${parameters.invoiceId}], has the wrong status, not adding Timesheet Entries to it." />
+                </add-error>
+                <check-errors />
+            </if-compare>
+            <set field="invoice.partyId" from-field="parameters.partyId"/>
+            <store-value value-field="invoice"/>
+            <entity-and list="entries" entity-name="TimeEntry">
+                <field-map field-name="invoiceId" from-field="parameters.invoiceId" />
+            </entity-and>
+            <iterate list="entries" entry="timeEntry">
+                <clear-field field="timeEntry.invoiceId" />
+                <clear-field field="timeEntry.invoiceItemSeqId" />
+                <store-value value-field="timeEntry" />
+            </iterate>
+            <set field="removeItems.invoiceId" from-field="parameters.invoiceId" />
+            <remove-by-and entity-name="InvoiceItem" map="removeItems" />
+            <set field="notFirst" value="Y" /><!-- do not create, only add -->
+        </if-compare>
+        <!-- get partyId in Company -->
+        <entity-condition list="listPartyIdInCompany" entity-name="PartyRelationship">
+            <condition-list combine="and">
+                <condition-expr field-name="partyIdFrom" from-field="parameters.partyIdFrom"/>
+                <condition-expr field-name="roleTypeIdFrom" value="ACCOUNT" />
+                <condition-expr field-name="roleTypeIdTo" value="CONTACT" />
+                <condition-expr field-name="partyRelationshipTypeId" value="EMPLOYMENT" />
+            </condition-list>
+            <select-field field-name="partyIdTo"/>
+        </entity-condition>
+        <iterate entry="partyRelationship" list="listPartyIdInCompany">
+            <set field="partyIdAllInCompany[+0]" from-field="partyRelationship.partyIdTo"/>
+        </iterate>
+        <if-empty field="partyIdAllInCompany">
+            <add-error>
+                <fail-message message="There is no party in this company" />
+            </add-error>
+            <check-errors />
+        </if-empty>
+        <if-compare field="parameters.includeMeeting" operator="equals" value="N">
+            <set field="custRequestTypeId" value="RF_SCRUM_MEETINGS"/>
+        </if-compare>
+        <!-- get tasks from backlog item -->
+        <entity-condition entity-name="ProjectSprintBacklogTaskAndTimeEntryTimeSheet"
+            list="sprintTasks">
+            <condition-list combine="and">
+                <condition-expr field-name="productId" operator="equals" from-field="parameters.productId" />
+                <condition-expr field-name="invoiceId" operator="equals" from-field="nullField" />
+                <condition-expr field-name="timesheetStatusId" operator="equals" value="TIMESHEET_COMPLETED" />
+                <condition-expr field-name="custRequestTypeId" operator="not-equals" from-field="custRequestTypeId" ignore-if-empty="true"/>
+                <condition-expr field-name="fromDate" operator="greater-equals" from-field="parameters.fromDate" ignore-if-empty="true" />
+                <condition-expr field-name="fromDate" operator="less" from-field="parameters.thruDate" ignore-if-empty="true" />
+                <condition-expr field-name="partyId" operator="in" from-field="partyIdAllInCompany" />
+            </condition-list>
+            <order-by field-name="productId" />
+        </entity-condition>
+        <!-- get unplanned task -->
+        <entity-condition list="unplannedTasks" entity-name="UnPlannedBacklogsTaskAndTimeEntryTimeSheet">
+            <condition-list combine="and">
+                <condition-expr field-name="productId" operator="equals" from-field="parameters.productId" />
+                <condition-expr field-name="invoiceId" operator="equals" from-field="nullField" />
+                <condition-expr field-name="timesheetStatusId" operator="equals" value="TIMESHEET_COMPLETED" />
+                <condition-expr field-name="custRequestTypeId" operator="not-equals" from-field="custRequestTypeId" ignore-if-empty="true"/>
+                <condition-expr field-name="fromDate" operator="greater-equals" from-field="parameters.fromDate" ignore-if-empty="true" />
+                <condition-expr field-name="fromDate" operator="less" from-field="parameters.thruDate" ignore-if-empty="true" />
+                <condition-expr field-name="partyId" operator="in" from-field="partyIdAllInCompany" />
+            </condition-list>
+        </entity-condition>
+        <call-class-method class-name="javolution.util.FastList" method-name="newInstance" ret-field="tasks"/>
+        <set field="isAddAll" value="${groovy:tasks.addAll(sprintTasks)}"/>
+        <set field="isAddAll" value="${groovy:tasks.addAll(unplannedTasks)}"/>
+        <if-empty field="tasks">
+            <add-error>
+                <fail-message message="No timeentry items found" />
+            </add-error>
+            <check-errors />
+        </if-empty>
+        <iterate entry="task" list="tasks">
+            <if-empty field="notFirst">
+                <!-- first time so create invoice -->
+                <set-service-fields service-name="addWorkEffortTimeToNewInvoice"
+                    map="parameters" to-map="addTaskToNewInvoice" />
+                <set field="addTaskToNewInvoice.workEffortId" from-field="task.taskId" />
+                <set field="addTaskToNewInvoice.combineInvoiceItem" value="Y" />
+                <set field="addTaskToNewInvoice.thruDate" from-field="parameters.thruDate" />
+                <call-service service-name="addWorkEffortTimeToNewInvoice"
+                    in-map-name="addTaskToNewInvoice">
+                    <result-to-field result-name="invoiceId" field="parameters.invoiceId" />
+                </call-service>
+                <set field="addTaskToInvoice.combineInvoiceItem" value="Y" />
+                <field-to-result field="parameters.invoiceId"
+                    result-name="invoiceId" />
+                <set field="notFirst" value="Y" />
+                <else>
+                    <if>
+                        <condition>
+                            <or>
+                                <if-empty field="oldWorkeffortId" />
+                                <if-compare-field operator="not-equals" field="oldWorkeffortId"
+                                    to-field="task.taskId" />
+                            </or>
+                        </condition>
+                        <then>
+                            <!-- add to created invoice -->
+                            <set field="addTaskToInvoice.combineInvoiceItem" value="Y" />
+                            <set field="addTaskToInvoice.invoiceId" from-field="parameters.invoiceId" />
+                            <set field="addTaskToInvoice.invoiceDate" from-field="parameters.invoiceDate" />
+                            <set field="addTaskToInvoice.workEffortId" from-field="task.taskId" />
+                            <set field="addTaskToInvoice.thruDate" from-field="parameters.thruDate" />
+                            <call-service service-name="addWorkEffortTimeToInvoice"
+                                in-map-name="addTaskToInvoice" />
+                        </then>
+                    </if>
+                    <set field="oldWorkeffortId" from-field="task.taskId" />
+                </else>
+            </if-empty>
+        </iterate>
+    </simple-method>
+    <simple-method method-name="removeInvoiceInTimeEntry" short-description="Remove Invoice In TimeEntry">
+        <entity-and list="timeEntryList" entity-name="TimeEntry">
+            <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
+        </entity-and>
+        <if-not-empty field="timeEntryList">
+            <iterate entry="timeEntryMap" list="timeEntryList">
+                <set field="timeEntryMap.invoiceId" from-field="nullField"/>
+                <set field="timeEntryMap.invoiceItemSeqId" from-field="nullField"/>
+                <log level="info" message="Upadte value === >>> timeEntryId = ${timeEntryMap}"></log>
+                <store-value value-field="timeEntryMap"/>
+            </iterate>
+        </if-not-empty>
+    </simple-method>
+
+    <simple-method method-name="getScrumPlanHour"
+        short-description="Get plan hour of backlog">
+        <set field="planHours" type="Double" value="0.0" />
+        <set field="initPlanHours" type="Double" value="0.0" />
+        <!-- Get by CustRequest -->
+        <if-not-empty field="parameters.projectId">
+            <call-simple-method method-name="getScrumProjectPlanHour" />
+            <set field="planHours" type="Double" from-field="projectPlanHours" />
+            <call-simple-method method-name="getScrumProjectInitPlanHour" />
+            <set field="initPlanHours" type="Double" from-field="projectInitPlanHours" />
+            <else>
+                <if-not-empty field="parameters.sprintId">
+                    <call-simple-method method-name="getScrumSprintPlanHour" />
+                    <set field="planHours" type="Double" from-field="sprintPlanHours" />
+                    <call-simple-method method-name="getScrumSprintInitPlanHour" />
+                    <set field="initPlanHours" type="Double" from-field="sprintInitPlanHours" />
+                    <else>
+                        <if-not-empty field="parameters.custRequestId">
+                            <call-simple-method method-name="getScrumBacklogPlanHour" />
+                            <set field="planHours" type="Double" from-field="backlogPlanHours" />
+                            <call-simple-method method-name="getScrumBacklogInitPlanHour" />
+                            <set field="initPlanHours" type="Double" from-field="backlogInitPlanHours" />
+                            <else>
+                                <if-not-empty field="parameters.taskId">
+                                    <call-simple-method method-name="getScrumTaskPlanHour" />
+                                    <set field="planHours" type="Double" from-field="taskPlanHours" />
+                                    <set field="initPlanHours" type="Double" from-field="taskPlanHours" />
+                                </if-not-empty>
+                            </else>
+                        </if-not-empty>
+                    </else>
+                </if-not-empty>
+            </else>
+        </if-not-empty>
+        <field-to-result field="initPlanHours" />
+        <field-to-result field="planHours" />
+    </simple-method>
+
+    <simple-method method-name="getScrumTaskPlanHour"
+        short-description="Get Scrum Task Plan Hour">
+        <!-- Get plan hours in a task -->
+        <set field="taskPlanHours" type="Double" value="0" />
+        <entity-condition entity-name="TimeEntry" list="timeEntries">
+            <condition-list combine="and">
+                <condition-expr field-name="planHours" operator="greater" value="0" />
+                <condition-expr field-name="workEffortId" operator="equals" from-field="parameters.taskId" />
+            </condition-list>

[... 1573 lines stripped ...]