Author: pgil
Date: Sat Sep 17 11:56:04 2016
New Revision: 1761202

URL: http://svn.apache.org/viewvc?rev=1761202&view=rev
Log:
Implemented: Add tasks from different project on the same invoice (OFBIZ-8116)

This new feature allow to bill task time entries from several projects into one 
unique Invoice.

Thanks Florian Montalbano for your contribution, i did apply some light 
improvments in your patch

Modified:
    ofbiz/trunk/specialpurpose/projectmgr/config/ProjectMgrUiLabels.xml
    ofbiz/trunk/specialpurpose/projectmgr/minilang/ProjectServices.xml
    ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml
    
ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/controller.xml
    ofbiz/trunk/specialpurpose/projectmgr/widget/ProjectScreens.xml
    ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml

Modified: ofbiz/trunk/specialpurpose/projectmgr/config/ProjectMgrUiLabels.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/config/ProjectMgrUiLabels.xml?rev=1761202&r1=1761201&r2=1761202&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/config/ProjectMgrUiLabels.xml 
(original)
+++ ofbiz/trunk/specialpurpose/projectmgr/config/ProjectMgrUiLabels.xml Sat Sep 
17 11:56:04 2016
@@ -347,7 +347,7 @@
     <property key="PageTitleAddProjectTimeToNewInvoice">
         <value xml:lang="de">Füge alle gemeldeten/genehmigten Aufgabenzeiten 
einer neuen Abrechnung hinzu</value>
         <value xml:lang="en">Add all reported/approved task time to a new 
invoice</value>
-        <value xml:lang="fr">Ajouter tout le temps de la tâche 
rapporté/approuvé à une nouvelle facture/</value>
+        <value xml:lang="fr">Ajouter tout le temps de la tâche 
rapporté/approuvé à une nouvelle facture</value>
         <value xml:lang="it">Aggiungi tutte le timbrature approvate ad una 
nuova fattura</value>
         <value xml:lang="ja">新規請求書にすべてのå 
±å‘Šæ¸ˆ/承認済タスク時間を追加</value>
         <value xml:lang="nl">Alle gerapporteerde/goedgekeurde uren toevoegen 
aan nieuwe faktuur</value>
@@ -355,6 +355,10 @@
         <value xml:lang="zh">把全部已报告/已批准的任务时间添加
到一个新的发票</value>
         <value xml:lang="zh-TW">把全部已報告/å·²æ 
¸å‡†çš„任務時間增加到一個新的發票</value>
     </property>
+    <property key="PageTitleAddProjectTimeToInvoice">
+        <value xml:lang="en">Add all reported/approved task time to an 
existing invoice</value>
+        <value xml:lang="fr">Ajouter tout le temps de la tâche 
rapporté/approuvé à une facture existante</value>
+    </property>
     <property key="PageTitleAddResource">
         <value xml:lang="de">Neue Ressource hinzufügen</value>
         <value xml:lang="en">Add a Resource</value>

Modified: ofbiz/trunk/specialpurpose/projectmgr/minilang/ProjectServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/minilang/ProjectServices.xml?rev=1761202&r1=1761201&r2=1761202&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/minilang/ProjectServices.xml 
(original)
+++ ofbiz/trunk/specialpurpose/projectmgr/minilang/ProjectServices.xml Sat Sep 
17 11:56:04 2016
@@ -1401,12 +1401,9 @@
                 </add-error>
                 <check-errors/>
             </if-empty>
-            <if-compare field="invoice.statusId" operator="not-equals" 
value="INVOICE_IN_PROCESS">
-                <add-error>
-                    <fail-property resource="ProjectMgrUiLabels" 
property="ProjectMgrCannotAddInvoiceToTimesheet"/>
-                </add-error>
-                <check-errors/>
-            </if-compare>
+
+            <call-simple-method method-name="InvoiceStatusInProgress" 
xml-resource="component://accounting/minilang/invoice/InvoiceServices.xml"/>
+
             <entity-and list="entries" entity-name="TimeEntry">
                 <field-map field-name="invoiceId" 
from-field="parameters.invoiceId"/>
             </entity-and>
@@ -1470,6 +1467,56 @@
         </iterate>
     </simple-method>
 
+    <simple-method method-name="addProjectTimeToInvoice" 
short-description="add all reported time on all completed timesheets
+        from all workefforts for a project to an existing invoice">
+        <entity-one entity-name="Invoice" value-field="invoice"/>
+        <if-empty field="invoice">
+            <add-error>
+                <fail-property resource="WorkEffortUiLabels" 
property="WorkEffortTimesheetCannotFindInvoice"/>
+            </add-error>
+            <check-errors/>
+        </if-empty>
+
+        <call-simple-method method-name="InvoiceStatusInProgress" 
xml-resource="component://accounting/minilang/invoice/InvoiceServices.xml"/>
+
+        <entity-condition entity-name="ProjectPhaseTaskAndTimeEntryTimeSheet" 
list="tasks">
+            <condition-list combine="and">
+                <condition-expr field-name="projectId" operator="equals" 
from-field="parameters.projectId"/>
+                <condition-expr field-name="invoiceId" operator="equals" 
from-field="nullField"/>
+                <condition-expr field-name="timesheetStatusId" 
operator="equals" value="TIMESHEET_COMPLETED"/>
+                <condition-expr field-name="fromDate" operator="less" 
from-field="parameters.thruDate" ignore-if-empty="true"/>
+            </condition-list>
+            <order-by field-name="workEffortId"/>
+        </entity-condition>
+
+        <if-empty field="tasks">
+            <add-error>
+                <fail-property resource="ProjectMgrUiLabels" 
property="ProjectMgrNoTimeentryItemsFound"/>
+            </add-error>
+            <check-errors/>
+        </if-empty>
+
+        <iterate entry="task" list="tasks">
+            <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"/>
+        </iterate>
+    </simple-method>
+
     <simple-method method-name="addValidationPartiesToTask" 
short-description="SECA to add either project-testing or -approval parties to a 
task when a task is set to complete">
         <!-- check if this is the last party which completed his task -->
         <entity-condition entity-name="WorkEffortPartyAssignment" 
list="openTasks" filter-by-date="true">

Modified: ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml?rev=1761202&r1=1761201&r2=1761202&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml Sat Sep 17 
11:56:04 2016
@@ -265,6 +265,14 @@ under the License.
         <attribute name="invoiceId" type="String" mode="INOUT" 
optional="true"/>
         <attribute name="reCreate" type="String" mode="IN" optional="true"/>
     </service>
+    <service name="addProjectTimeToInvoice" engine="simple" auth="true"
+        location="component://projectmgr/minilang/ProjectServices.xml" 
invoke="addProjectTimeToInvoice">
+        <description>Add Project Time to an existing Invoice. The billed party 
must be the same between the two invoice.</description>
+        <attribute name="projectId" type="String" mode="IN" optional="false"/>
+        <attribute name="invoiceId" type="String" mode="IN" optional="false"/>
+        <attribute name="billedPartyId" type="String" mode="IN" 
optional="false"/>
+        <attribute name="thruDate" type="Timestamp" mode="IN" optional="true"/>
+    </service>
     <service name="addValidationPartiesToTask" engine="simple" auth="true"
         location="component://projectmgr/minilang/ProjectServices.xml" 
invoke="addValidationPartiesToTask">
         <description>SECA to add either project-testing or -approval parties 
to a task when a task is set to complete</description>

Modified: 
ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/controller.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/controller.xml?rev=1761202&r1=1761201&r2=1761202&view=diff
==============================================================================
--- 
ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/controller.xml 
(original)
+++ 
ofbiz/trunk/specialpurpose/projectmgr/webapp/projectmgr/WEB-INF/controller.xml 
Sat Sep 17 11:56:04 2016
@@ -73,6 +73,12 @@
         <response name="success" type="view" value="projectBilling"/>
         <response name="error" type="view" value="projectBilling"/>
     </request-map>
+    <request-map uri="addProjectTimeToInvoice">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="addProjectTimeToInvoice"/>
+        <response name="success" type="view" value="projectBilling"/>
+        <response name="error" type="view" value="projectBilling"/>
+    </request-map>
     <request-map uri="createProject">
         <security https="true" auth="true"/>
         <event type="service" invoke="createProject"/>

Modified: ofbiz/trunk/specialpurpose/projectmgr/widget/ProjectScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/widget/ProjectScreens.xml?rev=1761202&r1=1761201&r2=1761202&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/widget/ProjectScreens.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/widget/ProjectScreens.xml Sat Sep 17 
11:56:04 2016
@@ -121,6 +121,9 @@ under the License.
                         <screenlet 
title="${uiLabelMap.PageTitleAddProjectTimeToNewInvoice}">
                             <include-form name="AddProjectTimeToNewInvoice" 
location="component://projectmgr/widget/forms/ProjectForms.xml"/>
                         </screenlet>
+                        <screenlet 
title="${uiLabelMap.PageTitleAddProjectTimeToInvoice}">
+                            <include-form name="AddProjectTimeToInvoice" 
location="component://projectmgr/widget/forms/ProjectForms.xml"/>
+                        </screenlet>
                     </decorator-section>
                 </decorator-screen>
             </widgets>

Modified: ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml?rev=1761202&r1=1761201&r2=1761202&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml 
(original)
+++ ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml Sat Sep 
17 11:56:04 2016
@@ -848,6 +848,28 @@
            </field>
         <field name="submitButton" 
title="${uiLabelMap.PageTitleAddProjectTimeToNewInvoice}" 
widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
+    <form name="AddProjectTimeToInvoice" target="addProjectTimeToInvoice" 
title="" type="single">
+        <actions>
+            <entity-and entity-name="WorkEffortPartyAssignment" 
list="assignBilling" filter-by-date="true">
+                <field-map field-name="workEffortId" 
from-field="parameters.projectId"/>
+                <field-map field-name="roleTypeId" value="CLIENT_BILLING"/>
+            </entity-and>
+            <set field="billedPartyId" value="${assignBilling[0].partyId}"/>
+        </actions>
+        <field name="projectId"><hidden 
value="${parameters.projectId}"/></field>
+        <field name="billedPartyId" 
title="${uiLabelMap.WorkEffortTimeBillToParty}"><display-entity 
entity-name="PartyNameView" key-field-name="partyId" 
description="${groupName}"/></field>
+        <field name="invoiceId">
+            <drop-down allow-empty="false">
+                <entity-options entity-name="Invoice" 
description="${invoiceId} -- ${description}">
+                    <entity-constraint name="statusId" operator="equals" 
value="INVOICE_IN_PROCESS"/>
+                    <entity-constraint name="partyId" operator="equals" 
value="${billedPartyId}"/>
+                    <entity-order-by field-name="-invoiceDate"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="thruDate" title="${uiLabelMap.CommonThruDate}"><date-time 
type="timestamp"/></field>
+        <field name="submitButton" 
title="${uiLabelMap.PageTitleAddProjectTimeToInvoice}" 
widget-style="smallSubmit"><submit button-type="button"/></field>
+    </form>
     <form name="ListContents" extends="ListWorkEffortContents" 
extends-resource="component://workeffort/widget/WorkEffortForms.xml" 
default-entity-name="WorkEffortContent">
         <field name="contentId" 
use-when="headerItem.equals(&quot;EditProjectContents&quot;)">
             <display-entity entity-name="Content" key-field-name="contentId" 
description="${contentName}" also-hidden="true">


Reply via email to