svn commit: r702696 - in /ofbiz/trunk/specialpurpose/projectmgr: entitydef/entitymodel.xml script/org/ofbiz/project/ProjectServices.xml widget/forms/ProjectForms.xml

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

svn commit: r702696 - in /ofbiz/trunk/specialpurpose/projectmgr: entitydef/entitymodel.xml script/org/ofbiz/project/ProjectServices.xml widget/forms/ProjectForms.xml

hansbak-2
Author: hansbak
Date: Tue Oct  7 21:39:46 2008
New Revision: 702696

URL: http://svn.apache.org/viewvc?rev=702696&view=rev
Log:
optimize the creation of an invoice of the timeentry hours of a project.

Modified:
    ofbiz/trunk/specialpurpose/projectmgr/entitydef/entitymodel.xml
    ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml
    ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml

Modified: ofbiz/trunk/specialpurpose/projectmgr/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/entitydef/entitymodel.xml?rev=702696&r1=702695&r2=702696&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/entitydef/entitymodel.xml Tue Oct  7 21:39:46 2008
@@ -155,6 +155,47 @@
     </relation>
   </view-entity>
   
+  <view-entity entity-name="ProjectPhaseTaskAndTimeEntryTimeSheet"
+    package-name="org.ofbiz.workeffort.project"
+    title="WorkEffort for use in project -> phase -> task">
+    <member-entity entity-alias="WEP" entity-name="WorkEffort"/><!--project -->
+    <member-entity entity-alias="WEPH" entity-name="WorkEffort"/><!-- phase -->
+    <member-entity entity-alias="WET" entity-name="WorkEffort"/><!-- task -->
+    <member-entity entity-alias="TE" entity-name="TimeEntry"/>
+    <member-entity entity-alias="TS" entity-name="Timesheet"/>
+    <alias-all entity-alias="WET"/>
+    <alias-all entity-alias="TE">
+        <exclude field="workEffortId"/>
+    </alias-all>
+    <alias entity-alias="WEP" field="workEffortId" name="projectId"/>
+    <alias entity-alias="WEP" field="workEffortName" name="projectName"/>
+    <alias entity-alias="WEPH" field="workEffortId" name="phaseId"/>
+    <alias entity-alias="WEPH" field="workEffortName" name="phaseName"/>
+    <alias entity-alias="TS" field="statusId" name="timesheetStatusId"/>
+    <alias entity-alias="TS" field="partyId" name="resourcePartyId"/>
+    <view-link entity-alias="WEP" rel-entity-alias="WEPH">
+      <key-map field-name="workEffortId" rel-field-name="workEffortParentId"/>
+    </view-link>
+    <view-link entity-alias="WEPH" rel-entity-alias="WET">
+      <key-map field-name="workEffortId" rel-field-name="workEffortParentId"/>
+    </view-link>
+    <view-link entity-alias="WET" rel-entity-alias="TE">
+      <key-map field-name="workEffortId"/>
+    </view-link>
+    <view-link entity-alias="TE" rel-entity-alias="TS">
+      <key-map field-name="timesheetId"/>
+    </view-link>
+    <relation type="many" rel-entity-name="WorkEffortSkillStandard">
+      <key-map field-name="workEffortId"/>
+    </relation>
+    <relation type="many" rel-entity-name="WorkEffortPartyAssignment">
+      <key-map field-name="workEffortId"/>
+    </relation>
+    <relation type="one" rel-entity-name="Invoice">
+      <key-map field-name="invoiceId"/>
+    </relation>
+  </view-entity>
+  
   <view-entity entity-name="TimesheetAndTimeEntry"
     package-name="org.ofbiz.workeffort.project"
     title="Time entry for Timesheets, time entries always have a timesheet and are always for one day only and recording the hours for one person which is defined on the timesheet. A timesheet will always have at least one time entry.">

Modified: ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml?rev=702696&r1=702695&r2=702696&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml Tue Oct  7 21:39:46 2008
@@ -968,32 +968,47 @@
     </simple-method>
 
     <simple-method method-name="addProjectTimeToNewInvoice" short-description="add all reported time on all completed timesheets from all workefforts for a project">
- <!-- recreate the invoice if still in preparation in order to correct errors. -->
+        <!-- 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-name="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>
+            <entity-one entity-name="Invoice" value-name="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>
- <entity-and list-name="entries" entity-name="TimeEntry">
- <field-map field-name="invoiceId" env-name="parameters.invoiceId"/>
- </entity-and>
- <iterate list-name="entries" entry-name="timeEntry">        
-       <clear-field field-name="timeEntry.invoiceId"/>
-           <clear-field field-name="timeEntry.invoiceItemSeqId"/>
-           <store-value value-name="timeEntry"/>
-         </iterate>
-         <set field="removeItems.invoiceId" from-field="parameters.invoiceId"/>
-         <remove-by-and entity-name="InvoiceItem" map-name="removeItems"/>
-         <set field="notFirst" value="Y"/><!-- do not create, only add -->
+                <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>
+            <entity-and list-name="entries" entity-name="TimeEntry">
+                <field-map field-name="invoiceId" env-name="parameters.invoiceId"/>
+            </entity-and>
+            <iterate list-name="entries" entry-name="timeEntry">                    
+                   <clear-field field-name="timeEntry.invoiceId"/>
+                   <clear-field field-name="timeEntry.invoiceItemSeqId"/>
+                   <store-value value-name="timeEntry"/>
+            </iterate>
+            <set field="removeItems.invoiceId" from-field="parameters.invoiceId"/>
+            <remove-by-and entity-name="InvoiceItem" map-name="removeItems"/>
+            <set field="notFirst" value="Y"/><!-- do not create, only add -->
         </if-compare>
-        <entity-and entity-name="ProjectAndPhaseAndTask" list-name="tasks">
-            <field-map field-name="projectId" env-name="parameters.projectId"/>
-        </entity-and>
+        <if-empty field="parameters.thruDate">
+            <set field="parameters.thruDate" value="9999-12-31 00:00:00.000" type="Timestamp"/>
+        </if-empty>
+        <entity-condition entity-name="ProjectPhaseTaskAndTimeEntryTimeSheet" list-name="tasks">
+            <condition-list combine="and">
+                <condition-expr field-name="projectId" operator="equals" env-name="parameters.projectId"/>
+                <condition-expr field-name="invoiceId" operator="equals" env-name="null"/>
+                <condition-expr field-name="timesheetStatusId" operator="equals" value="TIMESHEET_COMPLETED"/>
+                <condition-expr field-name="fromDate" operator="less" env-name="parameters.thruDate"/>
+            </condition-list>
+            <order-by field-name="workEffortId"/>
+        </entity-condition>
+        <if-empty field="tasks">
+            <add-error>
+                <fail-message message="No timeentry items found"/>
+            </add-error>
+            <check-errors/>
+        </if-empty>
         <iterate entry-name="task" list-name="tasks">
             <if-empty field="notFirst">
                 <!-- first time so create invoice -->
@@ -1001,18 +1016,30 @@
                 <set field="addTaskToNewInvoice.workEffortId" from-field="task.workEffortId"/>
                 <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-name="parameters.invoiceId"/>
+                <call-service service-name="addWorkEffortTimeToNewInvoice" in-map-name="addTaskToNewInvoice">
+                    <result-to-field result-name="invoiceId" field-name="parameters.invoiceId"/>
                 </call-service>
                 <set field="addTaskToInvoice.combineInvoiceItem" value="Y"/>
-                <set field="notFirst" value="Y"/>
                 <field-to-result field-name="parameters.invoiceId" result-name="invoiceId"/>
+                <set field="notFirst" value="Y"/>
                 <else>
-                    <!-- add to created invoice -->
-                <set field="addTaskToInvoice.combineInvoiceItem" value="Y"/>
-                    <set field="addTaskToInvoice.invoiceId" from-field="parameters.invoiceId"/>
-                    <set field="addTaskToInvoice.workEffortId" from-field="task.workEffortId"/>
-                    <call-service service-name="addWorkEffortTimeToInvoice" in-map-name="addTaskToInvoice"/>
+                    <if>
+                        <condition>
+                            <or>
+                                <if-empty field="oldWorkeffortId"/>
+                                <if-compare-field operator="not-equals" field="oldWorkeffortId" to-field="task.workEffortId"/>
+                            </or>
+                        </condition>
+                        <then>
+                            <!-- add to created invoice -->
+                            <set field="addTaskToInvoice.combineInvoiceItem" value="Y"/>
+                            <set field="addTaskToInvoice.invoiceId" from-field="parameters.invoiceId"/>
+                            <set field="addTaskToInvoice.workEffortId" from-field="task.workEffortId"/>
+                            <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.workEffortId"/>
                 </else>
             </if-empty>
         </iterate>

Modified: ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml?rev=702696&r1=702695&r2=702696&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml Tue Oct  7 21:39:46 2008
@@ -521,7 +521,7 @@
         <field name="projectId"><hidden value="${parameters.projectId}"/></field>
         <field name="partyIdFrom" title="${uiLabelMap.WorkEffortTimeBillFromParty}"><lookup target-form-name="LookupPartyName"/></field>
         <field name="partyId" title="${uiLabelMap.WorkEffortTimeBillToParty}"><lookup target-form-name="LookupPartyName" default-value="${timesheet.clientPartyId}"/></field>
-        <field name="thruDate"><text/></field>
+        <field name="thruDate" title="${uiLabelMap.CommonThruDate}"><date-time type="timestamp"/></field>
         <field name="invoiceId"><hidden/></field>
         <field name="reCreate" position="1" title="re-create Invoice: ${context.invoiceId}" use-when="context.get(&quot;invoiceId&quot;)!=null">
          <drop-down no-current-selected-key="N">