ofbiz-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hans...@apache.org
Subject svn commit: r691001 - in /ofbiz/trunk: applications/workeffort/script/org/ofbiz/workeffort/timesheet/ specialpurpose/projectmgr/script/org/ofbiz/project/ specialpurpose/projectmgr/servicedef/ specialpurpose/projectmgr/widget/forms/
Date Mon, 01 Sep 2008 15:47:12 GMT
Author: hansbak
Date: Mon Sep  1 08:47:11 2008
New Revision: 691001

URL: http://svn.apache.org/viewvc?rev=691001&view=rev
Log:
re-generate an invoice from project, to be able to correct errors

Modified:
    ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml
    ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml
    ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml
    ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml

Modified: ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml?rev=691001&r1=691000&r2=691001&view=diff
==============================================================================
--- ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml
(original)
+++ ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml
Mon Sep  1 08:47:11 2008
@@ -121,20 +121,24 @@
                 <result-to-field result-name="invoiceId" field-name="parameters.invoiceId"/>
             </call-service>
             <field-to-result field-name="parameters.invoiceId" result-name="invoiceId"/>
-            <!-- find the currency of the receiving party -->
-            <entity-one entity-name="Party" value-name="party">
-                <field-map field-name="partyId" value="${invoice.partyId}"/>
-            </entity-one>
-            <set field="invoice.currencyUomId" from-field="party.preferredCurrencyUomId"/>
-            <if-empty field="invoice.currencyUomId">
-                <property-to-field field-name="invoice.currencyUomId" resource="general"
property="currency.uom.id.default" default="USD"/>
-            </if-empty>                
         </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>
+        <!-- update currency, can be changed with regenerate -->
+        <!-- find the currency of the receiving party -->
+        <entity-one entity-name="Party" value-name="party">
+        	<field-map field-name="partyId" value="${invoice.partyId}"/>
+        </entity-one>
+        <set field="updateInvoiceMap.invoiceId" from-field="parameters.invoiceId"/>
+        <set field="updateInvoiceMap.currencyUomId" from-field="party.preferredCurrencyUomId"/>
+        <if-empty field="updateInvoiceMap.currencyUomId">
+        	<property-to-field field-name="invoice.currencyUomId" resource="general" property="currency.uom.id.default"
default="USD"/>
+        </if-empty>                
+        <call-service service-name="updateInvoice" in-map-name="updateInvoiceMap"/>
+        
         <call-simple-method method-name="createTimeEntryInvoiceItemsInline"/>
     </simple-method>
     <simple-method method-name="createTimeEntryInvoiceItemsInline" short-description="createTimeEntryInvoiceItemsInline">
@@ -202,6 +206,7 @@
                             <set field="invoiceItemMap.description" from-field="workEffort.workEffortName"/>
                         </if-empty>
                         <set field="invoiceItemMap.quantity" from-field="timeEntry.hours"
default-value="0.0" type="Double"/>
+                        <clear-field field-name="invoiceItemMap.invoiceItemSeqId"/><!--
make sure a new one is created -->
                         <call-service service-name="createInvoiceItem" in-map-name="invoiceItemMap">
                             <result-to-field result-name="invoiceItemSeqId" field-name="invoiceItemMap.invoiceItemSeqId"/>
                         </call-service>
@@ -297,7 +302,6 @@
                 <set field="rateAmount" from-field="workEffortAssignmentRate.rate"/>
             </if-not-empty>
         </if-not-empty>
-        
         <!-- no rateAmount yet, try PartyRate if partyId not provided try the timesheet-->
         <if-empty field="rateAmount">
             <if-empty field="timeEntry.partyId">
@@ -323,7 +327,6 @@
                 <set field="rateAmount" from-field="partyRate.rate"/>
             </if-not-empty>
         </if-empty>
-        
         <field-to-result field-name="rateAmount"/>
     </simple-method>
     

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=691001&r1=691000&r2=691001&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/script/org/ofbiz/project/ProjectServices.xml Mon
Sep  1 08:47:11 2008
@@ -964,6 +964,31 @@
     </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. -->
+        <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>
+            <if-compare field="invoice.statusId" operator="not-equals" value="INVOICE_IN_PROCESS">

+        	    <add-error><fail-message message="Could not find invoice with ID [${parameters.invoiceId}],
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>
+        <log level="always" message="==============invoice items deleted"/>
         <entity-and entity-name="ProjectAndPhaseAndTask" list-name="tasks">
             <field-map field-name="projectId" env-name="parameters.projectId"/>
         </entity-and>
@@ -971,17 +996,21 @@
             <if-empty field="notFirst">
                 <!-- first time so create invoice -->
                 <set-service-fields service-name="addWorkEffortTimeToNewInvoice" map-name="parameters"
to-map-name="addtaskToNewInvoice"/>
-                <set field="addtaskToNewInvoice.workEffortId" from-field="task.workEffortId"/>
+                <set field="addTaskToNewInvoice.workEffortId" from-field="task.workEffortId"/>
                 <set field="addtaskToNewInvoice.combineInvoiceItem" value="Y"/>
-                <call-service service-name="addWorkEffortTimeToNewInvoice" in-map-name="addtaskToNewInvoice">
-                    <result-to-field result-name="invoiceId" field-name="addTaskToInvoice.invoiceId"/>
+   	        	<set field="addtaskToNewInvoice.invoiceId" from-field="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="addTaskToInvoice.invoiceId" result-name="invoiceId"/>
+                <field-to-result field-name="parameters.invoiceId" result-name="invoiceId"/>
                 <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"/>
+        <log level="always" message="==============add workeffort iwth data ${addTaskToInvoice}"/>
                     <call-service service-name="addWorkEffortTimeToInvoice" in-map-name="addTaskToInvoice"/>
                 </else>
             </if-empty>

Modified: ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml?rev=691001&r1=691000&r2=691001&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/servicedef/services.xml Mon Sep  1 08:47:11 2008
@@ -227,9 +227,10 @@
         location="org/ofbiz/project/ProjectServices.xml" invoke="addProjectTimeToNewInvoice">
         <description>Add Project Time to a new Invoice</description>
         <attribute name="projectId" type="String" mode="IN" optional="false"/>
-        <attribute name="partyIdFrom" type="String" mode="IN" optional="false"/>
-        <attribute name="partyId" type="String" mode="IN" optional="false"/>
-        <attribute name="invoiceId" type="String" mode="OUT" optional="true"/>
+        <attribute name="partyIdFrom" type="String" mode="IN" optional="true"/>
+        <attribute name="partyId" type="String" mode="IN" optional="true"/>
+        <attribute name="invoiceId" type="String" mode="INOUT" optional="true"/>
+        <attribute name="reCreate" type="String" mode="IN" optional="true"/>
     </service>
 
 </services>

Modified: ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml?rev=691001&r1=691000&r2=691001&view=diff
==============================================================================
--- ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml (original)
+++ ofbiz/trunk/specialpurpose/projectmgr/widget/forms/ProjectForms.xml Mon Sep  1 08:47:11
2008
@@ -518,10 +518,16 @@
         <field name="submitButton" title="${uiLabelMap.CommonAdd}" widget-style="smallSubmit"><submit
button-type="button"/></field>
     </form>
     <form name="AddProjectTimeToNewInvoice" target="addProjectTimeToNewInvoice" title=""
type="single">
-        <field name="combineInvoiceItem"><hidden value="Y"/></field>
         <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="reCreate">
+        	<drop-down no-current-selected-key="N">
+        		<option key="Y" description="Yes"/>
+        		<option key="N" description="No"/>
+        	</drop-down>
+       	</field>
+        <field name="invoiceId" position="2"><text/></field>
         <field name="submitButton" title="${uiLabelMap.PageTitleAddProjectTimeToNewInvoice}"
widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
 </forms>
\ No newline at end of file



Mime
View raw message