Author: hansbak
Date: Sat Aug 30 18:16:17 2008 New Revision: 690624 URL: http://svn.apache.org/viewvc?rev=690624&view=rev Log: some improvements of adding timeentries to an invoice Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml ofbiz/trunk/applications/workeffort/script/org/ofbiz/workeffort/timesheet/TimesheetServices.xml ofbiz/trunk/applications/workeffort/servicedef/services_timesheet.xml Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml?rev=690624&r1=690623&r2=690624&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml Sat Aug 30 18:16:17 2008 @@ -249,7 +249,7 @@ <set-nonpk-fields map-name="parameters" value-name="newEntity"/> <if-empty field="newEntity.invoiceItemSeqId"> <make-next-seq-id value-name="newEntity" seq-field-name="invoiceItemSeqId"/> <!-- this finds the next sub-sequence ID --> - <!--field-to-result field-name="newEntity.invoiceItemSeqId" result-name="invoiceItemSeqId"/--> + <field-to-result field-name="newEntity.invoiceItemSeqId" result-name="invoiceItemSeqId"/> </if-empty> <!-- if there is no amount and a productItem is supplied fill the amount(price) and description from the product record TODO: there are return adjustments now that make this code very broken. The check for price was added as a quick fix. --> 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=690624&r1=690623&r2=690624&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 Sat Aug 30 18:16:17 2008 @@ -18,8 +18,8 @@ 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-methods xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/simple-methods.xsd"> <!-- Timesheet Services --> <simple-method method-name="createTimesheet" short-description="Create Timesheet"> @@ -112,102 +112,100 @@ <simple-method method-name="addWorkEffortTimeToInvoice" short-description="Add Work Effort Time to Invoice"> <check-permission permission="WORKEFFORTMGR" action="_CREATE"><fail-message message="You do not have permission to perform this operation: ${methodShortDescription}."/></check-permission> <check-errors/> - <entity-one entity-name="WorkEffort" value-name="workEffort"/> - <if-empty field="parameters.invoiceId"> <set-service-fields service-name="createInvoice" map-name="parameters" to-map-name="createInvoiceMap"/> <set field="createInvoiceMap.invoiceTypeId" value="SALES_INVOICE"/> <set field="createInvoiceMap.statusId" value="INVOICE_IN_PROCESS"/> <call-service service-name="createInvoice" in-map-name="createInvoiceMap"> - <result-to-field result-name="invoiceId"/> + <result-to-field result-name="invoiceId" field-name="parameters.invoiceId"/> </call-service> - <field-to-result field-name="invoiceId"/> - <else> - <set field="invoiceId" from-field="parameters.invoiceId"/> - </else> </if-empty> - + <field-to-result field-name="parameters.invoiceId" result-name="invoiceId"/> <entity-one entity-name="Invoice" value-name="invoice"/> <if-empty field="invoice"> - <add-error><fail-message message="Could not find invoice with ID [${invoiceId}], not adding Timesheet Entries to it."/></add-error> + <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> - <call-simple-method method-name="createTimeEntryInvoiceItemsInline"/> </simple-method> <simple-method method-name="createTimeEntryInvoiceItemsInline" short-description="createTimeEntryInvoiceItemsInline"> - <log level="always" message="=========input: ${parameters.combineInvoiceItem}"/> <set field="orderBy[]" value="rateTypeId"/> <get-related value-name="workEffort" relation-name="TimeEntry" list-name="timeEntryList" order-by-list-name="orderBy"/> - <set field="invoiceItemMap.invoiceId" from-field="invoiceId"/> + <set field="invoiceItemMap.invoiceId" from-field="parameters.invoiceId"/> <set field="invoiceItemMap.taxableFlag" value="N"/> <set field="invoiceItemMap.invoiceItemTypeId" value="INV_TE_ITEM"/> <set field="invoiceItemMap.uomId" value="TF_hr"/> <iterate entry-name="timeEntry" list-name="timeEntryList"> - - <!-- only add to invoice if it is not already on an invoice; may want to make this smarter in the future to see if invoice cancelled or some such --> - <if-empty field="timeEntry.invoiceId"> - - <!-- check if the RateTypeId changed or the first record --> - <if> - <condition> - <or> - <if-empty field="oldRateTypeId"/> - <and> - <not><if-empty field="oldRateTypeId"/></not> - <if-compare-field field="timeEntry.rateTypeId" operator="not-equals" to-field="oldRateTypeId"/> - </and> - </or> - </condition> - <then> - <set field="getTimeEntryRate.timeEntryId" from-field="timeEntry.timeEntryId"/> - <call-service service-name="getTimeEntryRate" in-map-name="getTimeEntryRate"> - <result-to-field result-name="rateAmount"/> - </call-service> - <set field="invoiceItemMap.amount" from-field="rateAmount" default-value="0.0" type="Double"/> - <if-compare field="parameters.combineInvoiceItem" operator="equals" value="Y" > - <log level="always" message="===== first line of rateTypeId with hours: ${timeEntry.hours}"/> - <set field="invoiceItemMap.quantity" from-field="timeEntry.hours" default-value="0.0" type="Double"/> - <call-service service-name="createInvoiceItem" in-map-name="invoiceItemMap"> - <result-to-field result-name="invoiceItemSeqId" field-name="invoiceItemMap.invoiceItemSeqId"/> - </call-service> - </if-compare> - </then> - <else> - <if-compare field="parameters.combineInvoiceItem" operator="equals" value="Y" > - <log level="always" message="===== following lines with hours: ${timeEntry.hours}"/> - <!-- or combine them when it is the same rate --> - <calculate field-name="invoiceItemMap.quantity"> - <calcop operator="get" field-name="invoiceItemMap.quantity"/> - <calcop operator="add" field-name="timeEntry.hours"/> - </calculate> - <call-service service-name="updateInvoiceItem" in-map-name="invoiceItemMap"/> - </if-compare> - </else> - </if> - <set field="oldRateTypeId" from-field="timeEntry.rateTypeId"/> - - <set field="invoiceItemMap.description" from-field="timeEntry.comments"/> - <if-empty field="invoiceItemMap.description"> - <set field="invoiceItemMap.description" from-field="workEffort.workEffortName"/> - </if-empty> - - <!-- create an invoiceitem for every time entry --> - <if-compare field="parameters.combineInvoiceItem" operator="not-equals" value="Y" > - <log level="always" message="===== always create item lines with hours: ${timeEntry.hours}"/> - <set field="invoiceItemMap.quantity" from-field="timeEntry.hours" default-value="0.0" type="Double"/> - <call-service service-name="createInvoiceItem" in-map-name="invoiceItemMap"> - <result-to-field result-name="invoiceItemSeqId" field-name="invoiceItemMap.invoiceItemSeqId"/> - </call-service> - </if-compare> - - <!-- update the timeentry --> - <set field="timeEntry.invoiceId" from-field="invoiceId"/> - <set field="timeEntry.invoiceItemSeqId" from-field="invoiceItemMap.invoiceItemSeqId"/> - <store-value value-name="timeEntry"/> - - </if-empty> + <!-- check invoice --> + <if-compare field="invoice.statusId" operator="equals" value="INVOICE_IN_PROCESS"> + <!-- only add to invoice if it is not already on an invoice--> + <if-empty field="timeEntry.invoiceId"> + <!-- check if the RateTypeId changed or the first time entry record --> + <if> + <condition> + <or> + <if-empty field="oldRateTypeId"/> + <and> + <not><if-empty field="oldRateTypeId"/></not> + <if-compare-field field="timeEntry.rateTypeId" operator="not-equals" to-field="oldRateTypeId"/> + </and> + </or> + </condition> + <then> + <set field="getTimeEntryRate.timeEntryId" from-field="timeEntry.timeEntryId"/> + <call-service service-name="getTimeEntryRate" in-map-name="getTimeEntryRate"> + <result-to-field result-name="rateAmount"/> + </call-service> + <set field="invoiceItemMap.amount" from-field="rateAmount" default-value="0.0" type="Double"/> + <if-compare field="parameters.combineInvoiceItem" operator="equals" value="Y" > + <set field="invoiceItemMap.quantity" from-field="timeEntry.hours" default-value="0.0" type="Double"/> + <call-service service-name="createInvoiceItem" in-map-name="invoiceItemMap"> + <result-to-field result-name="invoiceItemSeqId" field-name="invoiceItemMap.invoiceItemSeqId"/> + </call-service> + </if-compare> + </then> + <else> + <if-compare field="parameters.combineInvoiceItem" operator="equals" value="Y" > + <!-- or combine them when it is the same rate --> + <calculate field-name="invoiceItemMap.quantity"> + <calcop operator="get" field-name="invoiceItemMap.quantity"/> + <calcop operator="add" field-name="timeEntry.hours"/> + </calculate> + <call-service service-name="updateInvoiceItem" in-map-name="invoiceItemMap"/> + </if-compare> + </else> + </if> + <set field="oldRateTypeId" from-field="timeEntry.rateTypeId"/> + + <set field="invoiceItemMap.description" from-field="timeEntry.comments"/> + <if-empty field="invoiceItemMap.description"> + <set field="invoiceItemMap.description" from-field="workEffort.workEffortName"/> + </if-empty> + + <!-- create an invoiceitem for every time entry --> + <if-compare field="parameters.combineInvoiceItem" operator="not-equals" value="Y" > + <set field="invoiceItemMap.quantity" from-field="timeEntry.hours" default-value="0.0" type="Double"/> + <call-service service-name="createInvoiceItem" in-map-name="invoiceItemMap"> + <result-to-field result-name="invoiceItemSeqId" field-name="invoiceItemMap.invoiceItemSeqId"/> + </call-service> + </if-compare> + + <!-- update the timeentry --> + <set field="timeEntry.invoiceId" from-field="invoiceId"/> + <set field="timeEntry.invoiceItemSeqId" from-field="invoiceItemMap.invoiceItemSeqId"/> + <store-value value-name="timeEntry"/> + <else> + <log level="info" message="Timeentry: ${timeEntry.timeEntryId} already connected to invoiceId: ${timeEntry.invoiceId}...not added to invoiceItem added"/> + </else> + </if-empty> + <else> + <set field="errMsg" value="Invoice ${invoiceId} should have the status 'in progress', the status is however: ${inoice.statusId}"/> + <log level="error" message="${errMsg}"/> + <add-error error-list-name="errorMessageList"><fail-message message="${errMsg}"/></add-error> + <return response-code="error"/> + </else> + </if-compare> </iterate> </simple-method> Modified: ofbiz/trunk/applications/workeffort/servicedef/services_timesheet.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/workeffort/servicedef/services_timesheet.xml?rev=690624&r1=690623&r2=690624&view=diff ============================================================================== --- ofbiz/trunk/applications/workeffort/servicedef/services_timesheet.xml (original) +++ ofbiz/trunk/applications/workeffort/servicedef/services_timesheet.xml Sat Aug 30 18:16:17 2008 @@ -84,7 +84,7 @@ <service name="addWorkEffortTimeToInvoice" default-entity-name="Timesheet" engine="simple" auth="true" location="org/ofbiz/workeffort/timesheet/TimesheetServices.xml" invoke="addWorkEffortTimeToInvoice"> - <description>Add WorkEffort Time to Invoice, with the option to combine all timeentries with the same rateType into one invoiceItem </description> + <description>Add WorkEffort Time to existing Invoice, with the option to combine all timeentries with the same rateType into one invoiceItem </description> <permission-service service-name="workEffortGenericPermission" main-action="CREATE"/> <attribute name="workEffortId" type="String" mode="IN" optional="false"/> <attribute name="invoiceId" type="String" mode="IN" optional="false"/> @@ -92,11 +92,12 @@ </service> <service name="addWorkEffortTimeToNewInvoice" default-entity-name="Timesheet" engine="simple" auth="true" location="org/ofbiz/workeffort/timesheet/TimesheetServices.xml" invoke="addWorkEffortTimeToInvoice"> - <description>Add WorkEffort Time to Invoice</description> + <description>Add WorkEffort Time to a new Invoice with the option to combine all timeentries with the same rateType into one invoiceItem</description> <attribute name="workEffortId" 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="false"/> + <attribute name="combineInvoiceItem" mode="IN" type="String" optional="true"/> </service> <!-- TimesheetRole Services --> |
Free forum by Nabble | Edit this page |