svn commit: r735949 - in /ofbiz/trunk/applications/accounting: data/ script/org/ofbiz/accounting/invoice/ webapp/accounting/WEB-INF/ webapp/accounting/WEB-INF/actions/invoice/ webapp/accounting/invoice/ widget/

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

svn commit: r735949 - in /ofbiz/trunk/applications/accounting: data/ script/org/ofbiz/accounting/invoice/ webapp/accounting/WEB-INF/ webapp/accounting/WEB-INF/actions/invoice/ webapp/accounting/invoice/ widget/

hansbak-2
Author: hansbak
Date: Mon Jan 19 23:15:19 2009
New Revision: 735949

URL: http://svn.apache.org/viewvc?rev=735949&view=rev
Log:
first part of payrol, be able to create a payrol invoice see issue: OFBIZ-2117

Added:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml   (with props)
    ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl   (with props)
Modified:
    ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
    ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml
    ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml

Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=735949&r1=735948&r2=735949&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Mon Jan 19 23:15:19 2009
@@ -576,6 +576,46 @@
     
     <InvoiceItemTypeMap invoiceTypeId="INTEREST_INVOICE" invoiceItemMapKey="INT_INV_CHRG" invoiceItemTypeId="INV_INTRST_CHRG"/>
 
+<!--New invoiceType: "Payrol"-->
+    <InvoiceType description="Payrol" hasTable="N" invoiceTypeId="PAYROL_INVOICE" parentTypeId="PURCHASE_INVOICE"/>
+<!--    invoiceItem Types:-->
+    <InvoiceItemType description="Payrol" hasTable="N" invoiceItemTypeId="PAYROL" parentTypeId=""/><!-- to group the itemType parentId's -->
+    
+    <InvoiceItemType description="Earnings and Hours" hasTable="N" invoiceItemTypeId="PAYROL_EARN_HOURS" parentTypeId="PAYROL"/>
+    <InvoiceItemType description="Hourly Rate" hasTable="N" invoiceItemTypeId="PAYROL_HRLY_RATE" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Sick Hourly Rate" hasTable="N" invoiceItemTypeId="PAYROL_HRLY_RATE_SIC" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Salary" hasTable="N" invoiceItemTypeId="PAYROL_SALARY" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Vacation Salary" hasTable="N" invoiceItemTypeId="PAYROL_SALARY_VAC" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Sick Salary" hasTable="N" invoiceItemTypeId="PAYROL_SALARY_SICK" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Bonus" hasTable="N" invoiceItemTypeId="PAYROL_BONUS" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Commission" hasTable="N" invoiceItemTypeId="PAYROL_COMMISSION" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Advance Pay" hasTable="N" invoiceItemTypeId="PAYROL_ADV_PAY" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Mileage Reimboursement" hasTable="N" invoiceItemTypeId="PAYROL_MIL_REIMB" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Office Exp. reimboursement" hasTable="N" invoiceItemTypeId="PAYROL_OFF_EXP_REIMB" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Pay Period adj(over pay)" hasTable="N" invoiceItemTypeId="PAYROL_PAYPER_OVRPAY" parentTypeId="PAYROL_EARN_HOURS" />
+    <InvoiceItemType description="Pay Period adj pay" hasTable="N" invoiceItemTypeId="PAYROL_PAYPER_PAY" parentTypeId="PAYROL_EARN_HOURS" />
+    
+    <InvoiceItemType description="Deductions from Gross" hasTable="N" invoiceItemTypeId="PAYROL_DD_FROM_GROSS" parentTypeId="PAYROL"/>
+    <InvoiceItemType description="125*Compy. Contr Other Prem." hasTable="N" invoiceItemTypeId="PAYROL_DD_125COMPY" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>/>
+    <InvoiceItemType description="125*PPO (pre tax)" hasTable="N" invoiceItemTypeId="PAYROL_DD_125PPO" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="125*HSA Contribution (pre tax)" hasTable="N" invoiceItemTypeId="PAYROL_DD_125HSA" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="401K Emp." hasTable="N" invoiceItemTypeId="PAYROL_DD_401K" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Advance Repayment" hasTable="N" invoiceItemTypeId="PAYROL_DD_REPAY" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Charity Donation" hasTable="N" invoiceItemTypeId="PAYROL_DD_CHAR_DONAT" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Child Support Garnishment" hasTable="N" invoiceItemTypeId="PAYROL_DD_CHILD_SUPP" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Miscellaneous Deduction" hasTable="N" invoiceItemTypeId="PAYROL_DD_MISC" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Roth 401k Emp." hasTable="N" invoiceItemTypeId="PAYROL_DD_ROTH_401K" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Simple IRA emp." hasTable="N" invoiceItemTypeId="PAYROL_DD_SIMP_IRA" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Union Dues" hasTable="N" invoiceItemTypeId="PAYROL_DD_UNION" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Unpaid Salary Time off." hasTable="N" invoiceItemTypeId="PAYROL_DD_SAL_TIMOFF" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    <InvoiceItemType description="Wage Garnishment" hasTable="N" invoiceItemTypeId="PAYROL_DD_WAG_GARN" parentTypeId="PAYROL_DD_FROM_GROSS" defaultGlAccountId=""/>
+    
+    <InvoiceItemType description="Taxes" hasTable="N" invoiceItemTypeId="PAYROL_TAXES" parentTypeId="PAYROL"/>
+    <InvoiceItemType description="Federal Witholding" hasTable="N" invoiceItemTypeId="PAYROL_TAX_FEDERAL" parentTypeId="PAYROL_TAXES" defaultGlAccountId=""/>
+    <InvoiceItemType description="Social Security Employee" hasTable="N" invoiceItemTypeId="PAYROL_SOC_SEC_EMPL" parentTypeId="PAYROL_TAXES" defaultGlAccountId=""/>
+    <InvoiceItemType description="Medicare Employee" hasTable="N" invoiceItemTypeId="PAYROL_TAX_MED_EMPL" parentTypeId="PAYROL_TAXES" defaultGlAccountId=""/>
+    <InvoiceItemType description="MD Withholding" hasTable="N" invoiceItemTypeId="PAYROL_TAX_MD_WITHOL" parentTypeId="PAYROL_TAXES" defaultGlAccountId=""/>
+    
     <!-- An Enumeration to identify the taxable invoice item types.  For these, the only important fields are enumId and enumTypeId. -->
     <EnumerationType description="Taxable Invoice Item Types" enumTypeId="TAXABLE_INV_ITM_TY" hasTable="N" parentTypeId=""/>
     <Enumeration description="Sales Invoice Sales Tax" enumCode="INV_SALES_TAX" enumId="INV_SALES_TAX" sequenceId="01" enumTypeId="TAXABLE_INV_ITM_TY"/>

Added: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml?rev=735949&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml (added)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml Mon Jan 19 23:15:19 2009
@@ -0,0 +1,613 @@
+<?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="getNextInvoiceId" short-description="Get Next invoiceId">
+        <!-- try to find PartyAcctgPreference for parameters.partyId, see if we need any special invoice number sequencing -->
+        <entity-one entity-name="PartyAcctgPreference" value-field="partyAcctgPreference" auto-field-map="false">
+            <field-map field-name="partyId" from-field="parameters.partyId"/>
+        </entity-one>
+        <log level="info" message="In getNextInvoiceId partyId is [${parameters.partyId}], partyAcctgPreference: ${partyAcctgPreference}"/>
+
+        <if>
+            <condition>
+                <if-compare field="partyAcctgPreference.invoiceSequenceEnumId" operator="equals" value="INVSQ_ENF_SEQ"/>
+            </condition>
+            <then>
+                <log level="info" message="In createInvoice sequence enum INVSQ_ENF_SEQ"/>
+                <!-- this is sequential sequencing, we can't skip a number, also it must be a unique sequence per partyIdFrom -->
+                <if-not-empty field="partyAcctgPreference.lastInvoiceNumber">
+                    <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long">
+                        <calcop operator="add" field="partyAcctgPreference.lastInvoiceNumber"/>
+                        <number value="1"/>
+                    </calculate>
+                    <else>
+                        <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
+                    </else>
+                </if-not-empty>
+                <store-value value-field="partyAcctgPreference"/>
+                <set from-field="partyAcctgPreference.lastInvoiceNumber" field="invoiceIdTemp"/>
+            </then>
+            <else-if>
+                <condition>
+                    <if-compare field="partyAcctgPreference.invoiceSequenceEnumId" operator="equals" value="INVSQ_RESTARTYR"/>
+                </condition>
+                <then>
+                    <log level="info" message="In createInvoice sequence enum INVSQ_RESTARTYR"/>
+                    <!-- this is sequential sequencing, we can't skip a number; except that it is restarted each fiscal year -->
+
+                    <now-timestamp field="nowTimestamp"/>
+                    <if-empty field="partyAcctgPreference.lastInvoiceRestartDate">
+                        <!-- if no lastInvoiceRestartDate then it's easy, just start now with 1 -->
+                        <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
+                        <set from-field="nowTimestamp" field="partyAcctgPreference.lastInvoiceRestartDate"/>
+                        <else>
+                            <!-- first figure out if we need to reset the lastInvoiceNumber; is the lastInvoiceRestartDate after the fiscalYearStartMonth/Day for this year? -->
+                            <calculate field="zeroLong" type="Long"><number value="0"/></calculate>
+                            <call-class-method class-name="org.ofbiz.base.util.UtilDateTime" method-name="getYearStart" ret-field="curYearFiscalStartDate">
+                                <field field="nowTimestamp" type="java.sql.Timestamp"/>
+                                <field field="partyAcctgPreference.fiscalYearStartDay" type="java.lang.Number"/>
+                                <field field="partyAcctgPreference.fiscalYearStartMonth" type="java.lang.Number"/>
+                                <field field="zeroLong" type="java.lang.Number"/>
+                            </call-class-method>
+                            <if>
+                                <condition>
+                                    <and>
+                                        <if-compare-field field="partyAcctgPreference.lastInvoiceRestartDate" to-field="curYearFiscalStartDate" operator="less" type="Timestamp"/>
+                                        <if-compare-field field="nowTimestamp" to-field="curYearFiscalStartDate" operator="greater-equals" type="Timestamp"/>
+                                    </and>
+                                </condition>
+                                <then>
+                                    <!-- less than fiscal year start, we need to reset it -->
+                                    <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long"><number value="1"/></calculate>
+                                    <set from-field="nowTimestamp" field="partyAcctgPreference.lastInvoiceRestartDate"/>
+                                </then>
+                                <else>
+                                    <!-- greater than or equal to fiscal year start or nowTimestamp hasn't yet hit the current year fiscal start date, we're okay, just increment -->
+                                    <calculate field="partyAcctgPreference.lastInvoiceNumber" type="Long">
+                                        <calcop operator="add" field="partyAcctgPreference.lastInvoiceNumber"/>
+                                        <number value="1"/>
+                                    </calculate>
+                                </else>
+                            </if>
+                        </else>
+                    </if-empty>
+                    <store-value value-field="partyAcctgPreference"/>
+
+                    <!-- get the current year string for prefix, etc; simple 4 digit year date string (using system defaults) -->
+                    <set field="curYearString" value="${str:toString(date:year(partyAcctgPreference.lastInvoiceRestartDate, util:defaultTimeZone(), util:defaultLocale()))}"/>
+                    <set field="invoiceIdTemp" value="${curYearString}-${str:toString(partyAcctgPreference.lastInvoiceNumber)}"/>
+                </then>
+            </else-if>
+            <else>
+                <log level="info" message="In createInvoice sequence enum INVSQ_STANDARD"/>
+                <!-- default to the default sequencing: INVSQ_STANDARD -->
+                <set from-field="parameters.invoiceId" field="invoiceIdTemp"/>
+                <if-empty field="invoiceIdTemp">
+                    <sequenced-id sequence-name="Invoice" field="invoiceIdTemp"/>
+                    <else>
+                        <!-- check the provided ID -->
+                        <check-id field="invoiceIdTemp"/>
+                        <check-errors/>
+                    </else>
+                </if-empty>
+            </else>
+        </if>
+
+        <!-- use invoiceIdTemp along with the invoiceIdPrefix to create the real ID -->
+        <set field="invoiceId" value="${partyAcctgPreference.invoiceIdPrefix}${str:toString(invoiceIdTemp)}"/>
+        <field-to-result field="invoiceId" result-name="invoiceId"/>
+    </simple-method>
+
+
+    <simple-method method-name="createInvoice" short-description="Create a new Invoice">
+        <now-timestamp field="nowTimestamp"/>
+
+        <make-value value-field="newEntity" entity-name="Invoice"/>
+        <set-nonpk-fields map="parameters" value-field="newEntity"/>
+
+        <!-- call getNextInvoiceId service with the parameters.partyIdFrom when invoice Id is not suplied
+                            else use it from the input -->
+        <if-empty field="parameters.invoiceId">
+            <set field="getNextInvoiceIdMap.partyId" from-field="parameters.partyIdFrom"/>
+            <call-service service-name="getNextInvoiceId" in-map-name="getNextInvoiceIdMap">
+                <result-to-field result-name="invoiceId" field="newEntity.invoiceId"/>
+            </call-service>
+            <else>
+                <set field="newEntity.invoiceId" from-field="parameters.invoiceId"/>
+            </else>
+        </if-empty>
+        <field-to-result field="newEntity.invoiceId" result-name="invoiceId"/>
+
+        <if-empty field="parameters.invoiceDate">
+            <set from-field="nowTimestamp" field="newEntity.invoiceDate"/>
+        </if-empty>
+        <if-empty field="parameters.currencyUomId">
+            <!-- if provided set the default currency to the receiving party -->
+            <entity-one entity-name="Party" value-field="party"/>
+            <if-not-empty field="party.preferredCurrencyUomId">
+                <set field="newEntity.currencyUomId" from-field="party.preferredCurrencyUomId"/>
+                <else>
+                    <set field="newEntity.currencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/>
+                </else>
+            </if-not-empty>
+        </if-empty>
+
+        <create-value value-field="newEntity"/>
+
+        <!-- create new status entry, and set lastStatusUpdate date -->
+        <make-value value-field="newInvoiceStatus" entity-name="InvoiceStatus"/>
+        <set from-field="newEntity.invoiceId" field="newInvoiceStatus.invoiceId"/>
+        <set from-field="newEntity.statusId" field="newInvoiceStatus.statusId"/>
+        <set from-field="nowTimestamp" field="newInvoiceStatus.statusDate"/>
+        <create-value value-field="newInvoiceStatus"/>
+    </simple-method>
+
+    <simple-method method-name="copyInvoice" short-description="Create a new Invoice from an existing invoice">
+        <set field="invoiceLookup.invoiceId" from-field="parameters.invoiceIdToCopyFrom"/>
+        <call-service service-name="getInvoice" in-map-name="invoiceLookup">
+            <result-to-field result-name="invoice" field="invoice"/>
+            <result-to-field result-name="invoiceItems" field="invoiceItems"/>
+        </call-service>
+        <set field="invoice.invoiceId" from-field="parameters.invoiceId"/>
+        <now-timestamp field="nowTimestamp"/>
+        <set field="invoice.invoiceDate" from-field="nowTimestamp"/>
+        <set field="invoice.statusId" value="INVOICE_IN_PROCESS"/>
+        <if-not-empty field="parameters.invoiceTypeId">
+            <set field="invoice.invoiceTypeId" from-field="parameters.invoiceTypeId"/>
+        </if-not-empty>
+        <set-service-fields service-name="createInvoice" map="invoice" to-map="newInvoice"/>
+        <clear-field field="newInvoice.invoiceId"/>
+        <call-service service-name="createInvoice" in-map-name="newInvoice">
+            <result-to-field result-name="invoiceId" field="invoiceId"/>
+        </call-service>
+        <field-to-result field="invoiceId" result-name="invoiceId"/>
+        <field-to-request field="invoiceId" request-name="invoiceId"/>
+        <iterate entry="invoiceItem" list="invoiceItems">
+            <set-service-fields service-name="createInvoiceItem" map="invoiceItem" to-map="createInvoiceItem"/>
+            <set field="createInvoiceItem.invoiceId" from-field="invoiceId"/>
+            <call-service service-name="createInvoiceItem" in-map-name="createInvoiceItem"/>
+        </iterate>
+    </simple-method>
+
+    <simple-method method-name="getInvoice" short-description="Retrieve an invoice and the items">
+        <!-- find the invoice record -->
+        <make-value value-field="lookupPKMap" entity-name="Invoice"/>
+        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
+        <find-by-primary-key entity-name="Invoice" map="lookupPKMap" value-field="invoiceValue"/>
+        <field-to-result field="invoiceValue" result-name="invoice"/>
+        <!-- and the items -->
+        <get-related value-field="invoiceValue" relation-name="InvoiceItem" list="invoiceItemValues"/>
+        <field-to-result field="invoiceItemValues" result-name="invoiceItems"/>
+    </simple-method>
+
+    <simple-method method-name="updateInvoice" short-description="Update the header of an existing Invoice">
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+        <!-- find the current record -->
+        <make-value value-field="lookupPKMap" entity-name="Invoice"/>
+        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
+        <find-by-primary-key entity-name="Invoice" map="lookupPKMap" value-field="lookedUpValue"/>
+
+        <!-- only try to update content if the status is in process.... -->
+        <if-compare field="lookedUpValue.statusId" operator="equals" value="INVOICE_IN_PROCESS">
+            <clone-value value-field="lookedUpValue" new-value-field="savedValue"/>
+            <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
+
+            <!-- only save if something has changed, do not update status here -->
+            <set from-field="savedValue.statusId" field="lookedUpValue.statusId"/>  <!-- get old status back -->
+            <if-compare-field field="lookedUpValue" to-field="savedValue" operator="not-equals" type="Object">
+                <store-value value-field="lookedUpValue"/> <!-- update all non status and key fields -->
+            </if-compare-field>
+            <else>
+                <add-error><fail-message message="Can only update Invoice, when status is in-process...current status: ${lookedUpValue.statusId}"/></add-error>
+                <log level="error" message="Can only update Invoice, when status is in-process...current Status: ${lookedUpValue.statusId}"/>
+                <check-errors/>
+            </else>
+        </if-compare>
+
+        <!-- check if there is a requested status change if yes call invoice status update service -->
+        <if-not-empty field="parameters.statusId">
+        <if-compare-field field="parameters.statusId" to-field="savedValue.statusId" operator="not-equals">
+            <set from-field="parameters.invoiceId" field="inputMap.invoiceId"/>
+            <set from-field="parameters.statusId" field="inputMap.statusId"/>
+             <now-timestamp field="inputMap.statusDate"/>
+             <call-service service-name="setInvoiceStatus" in-map-name="inputMap"/>
+         </if-compare-field>
+        </if-not-empty>
+    </simple-method>
+
+    <simple-method method-name="sendInvoicePerEmail" short-description="Send an invoice per Email">
+        <set-service-fields service-name="sendMailFromScreen" map="parameters" to-map="emailParams"/>
+        <set field="emailParams.xslfoAttachScreenLocation" value="component://accounting/widget/AccountingPrintScreens.xml#InvoicePDF"/>
+        <set field="emailParams.bodyParameters.invoiceId" from-field="parameters.invoiceId"/>
+        <set field="emailParams.bodyParameters.userLogin" from-field="parameters.userLogin"/>
+        <set field="emailParams.bodyParameters.other" from-field="parameters.other"/><!-- to to print in 'other currency' -->
+        <call-service-asynch service-name="sendMailFromScreen" in-map-name="emailParams"/>
+        <property-to-field resource="AccountingUiLabels" property="AccountingEmailScheduledToSend" field="successMessage"/>
+    </simple-method>
+    
+    <simple-method method-name="createInvoiceItemPayrol" short-description="Create a new Invoice Item with Payrol Item Type">
+        <entity-condition entity-name="InvoiceItemType" list="PayrolGroup">
+            <condition-expr field-name="parentTypeId" value="PAYROL"/>
+        </entity-condition>
+        <entity-condition entity-name="InvoiceItemType" list="PayrolList"></entity-condition>
+        <iterate entry="payrolGroup" list="PayrolGroup">
+            <iterate entry="payrolList" list="PayrolList">
+                <if-compare field="payrolList.parentTypeId" value="${payrolGroup.invoiceItemTypeId}" operator="equals">
+                    <set field="AddInvoiceItem" value="N"/>
+                    <set field="createInvoiceItem.invoiceId" from-field="parameters.invoiceId"/>
+                    <set field="createInvoiceItem.invoiceItemTypeId" from-field="payrolList.invoiceItemTypeId"/>
+                    <set field="createInvoiceItem.description" value="${payrolGroup.description} : ${payrolList.description}"/>
+                    <!--                    <set field="createInvoiceItem.overrideGlAccountId" from-field=""/>-->
+                    <!--                    <set field="createInvoiceItem.inventoryItemId" from-field=""/>-->
+                    <!--                    <set field="createInvoiceItem.productId" from-field=""/>-->
+                    <!--                    <set field="createInvoiceItem.productFeatureId" from-field=""/>-->
+                    <set field="createInvoiceItem.quantity" from-field="parameters.${payrolList.invoiceItemTypeId}_Quantity"/>
+                    <if-not-empty field="parameters.${payrolList.invoiceItemTypeId}_Quantity">
+                        <set field="AddInvoiceItem" value="Y"/>
+                    </if-not-empty>
+                    <!--                    <set field="createInvoiceItem.uomId" from-field=""/>-->
+                    <set field="createInvoiceItem.amount" from-field="parameters.${payrolList.invoiceItemTypeId}_Amount"/>
+                    <if-not-empty field="parameters.${payrolList.invoiceItemTypeId}_Amount">
+                        <set field="AddInvoiceItem" value="Y"/>
+                    </if-not-empty>
+                    <!--                    <set field="createInvoiceItem.taxableFlag" from-field=""/>-->
+                    <if-compare field="AddInvoiceItem" value="Y" operator="equals">
+                        <call-service service-name="createInvoiceItem" in-map-name="createInvoiceItem"/>
+                    </if-compare>
+                </if-compare>
+            </iterate>
+        </iterate>
+    </simple-method>
+
+    <simple-method method-name="createInvoiceItem" short-description="Create a new Invoice Item">
+        <set field="invoiceId" from-field="parameters.invoiceId"/>
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+        <make-value value-field="newEntity" entity-name="InvoiceItem"/>
+        <set-pk-fields map="parameters" value-field="newEntity"/>
+        <set-nonpk-fields map="parameters" value-field="newEntity"/>
+        <if-empty field="newEntity.invoiceItemSeqId">
+            <make-next-seq-id value-field="newEntity" seq-field-name="invoiceItemSeqId"/> <!-- this finds the next sub-sequence ID -->
+            <field-to-result field="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. -->
+        <if-empty field="parameters.amount">
+            <if-not-empty field="parameters.productId">
+                <entity-one entity-name="Product" value-field="product"/>
+                <set from-field="product.description" field="newEntity.description"/>
+                <set from-field="product" field="calculateProductPriceMap.product"/>
+                <call-service service-name="calculateProductPrice" in-map-name="calculateProductPriceMap">
+                    <result-to-field result-name="price" field="newEntity.amount"/>
+                </call-service>
+            </if-not-empty>
+        </if-empty>
+        <if-not-empty field="parameters.productId">
+            <if-empty field="parameters.quantity">
+                <set field="newEntity.quantity" value="1.0" type="BigDecimal"/>
+             </if-empty>
+        </if-not-empty>
+        <if-empty field="newEntity.amount">
+            <add-error>
+                <fail-message message="The amount value is mandatory"/>
+            </add-error>
+        </if-empty>
+        <create-value value-field="newEntity"/>
+    </simple-method>
+    <simple-method method-name="updateInvoiceItem"
+        short-description="Update an existing Invoice Item">
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+        <make-value value-field="lookupPKMap" entity-name="InvoiceItem"/>
+        <set-pk-fields map="parameters" value-field="lookupPKMap"/>
+
+        <find-by-primary-key entity-name="InvoiceItem" map="lookupPKMap" value-field="lookedUpValue"/>
+        <clone-value value-field="lookedUpValue" new-value-field="savedValue"/>
+
+        <!-- set all parameters -->
+        <set-nonpk-fields map="parameters" value-field="lookedUpValue"/>
+
+        <!-- check if the productNumber is updated, when yes retrieve product description and price -->
+        <if-not-empty field="productId">
+        <if-compare-field to-field="lookedUpValue.productId" field="savedValue.productId" operator="not-equals">
+            <entity-one entity-name="Product" value-field="product"/>
+            <set from-field="product.description" field="lookedUpValue.description"/>
+
+            <set from-field="product" field="calculateProductPriceMap.product"/>
+            <call-service service-name="calculateProductPrice" in-map-name="calculateProductPriceMap">
+                <result-to-field result-name="price" field="lookedUpValue.amount"/>
+            </call-service>
+        </if-compare-field>
+        </if-not-empty>
+        <if-empty field="newEntity.amount">
+            <add-error>
+                <fail-message message="The amount value is mandatory"/>
+            </add-error>
+        </if-empty>
+        <if-compare-field field="lookedUpValue" to-field="savedValue" operator="not-equals" type="Object">
+            <store-value value-field="lookedUpValue"/>
+        </if-compare-field>
+    </simple-method>
+    <simple-method method-name="removeInvoiceItem" short-description="Remove an existing Invoice Item">
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+        <set field="invoiceId" from-field="parameters.invoiceId"/>
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+
+        <set field="paymentApplicationMap.invoiceId" from-field="parameters.invoiceId"/>
+        <set field="paymentApplicationMap.invoiceItemSeqId" from-field="parameters.invoiceItemSeqId"/>
+        <if-not-empty field="parameters.invoiceItemSeqId">
+            <!-- check if there are specific item paymentApplications when yes remove those -->
+            <remove-by-and entity-name="PaymentApplication" map="paymentApplicationMap"/>
+            <else><!-- update global application with a null sequence number -->
+                <!-- TODO: reduce amount on global paymentApplication record -->
+            </else>
+        </if-not-empty>
+
+        <entity-one entity-name="InvoiceItem" value-field="lookedUpValue"/>
+        <remove-value value-field="lookedUpValue"/>
+    </simple-method>
+
+    <simple-method method-name="removePaymentApplication" short-description="Remove an existing payment application">
+        <entity-one entity-name="PaymentApplication" value-field="paymentApplication">
+            <field-map field-name="paymentApplicationId" value="${parameters.paymentApplicationId}"/>
+        </entity-one>
+        <if-empty field="paymentApplication">
+            <add-error>
+                <fail-message message="Cannot find payment application record [${parameters.paymentApplicationId}]"/>
+            </add-error>
+            <check-errors/>
+        </if-empty>
+        <!-- payment -->
+        <set field="currencyUomId" value=""/><!-- currency of the paymentApplication -->
+        <if-not-empty field="paymentApplication.paymentId">
+            <entity-one entity-name="Payment" value-field="payment">
+                <field-map field-name="paymentId" value="${paymentApplication.paymentId}"/>
+            </entity-one>
+            <if-not-empty field="payment">
+                <if-compare field="payment.statusId" operator="equals" value="PMNT_CONFIRMED">
+                    <add-error><fail-message message="PaymentID [${payment.paymentId}] has status 'confirmed', cannot remove application."/></add-error>
+                </if-compare>
+                <check-errors/>
+            </if-not-empty>
+            <field-to-result field="paymentApplication.paymentId" result-name="paymentId"/>
+            <set field="currencyUomId" from-field="paymentId.currencyUomId"/>
+        </if-not-empty>
+        <!-- check invoice -->
+        <if-not-empty field="paymentApplication.invoiceId">
+            <entity-one entity-name="Invoice" value-field="invoice">
+                <field-map field-name="invoiceId" value="${paymentApplication.invoiceId}"/>
+            </entity-one>
+            <if-empty field="invoice">
+                <add-error><fail-message message="Invoice not found, invoice Id: ${paymentApplication.invoiceId}"/></add-error>
+                <log level="info" message="Invoice not found, invoice Id: ${invoiceId}"/>
+                <check-errors/>
+            </if-empty>
+            <set field="currencyUomId" from-field="invoice.currencyUomId"/>
+            <!-- if the invoice is already PAID, then set it back to READY and clear out the paidDate -->
+            <if-compare field="invoice.statusId" operator="equals" value="INVOICE_PAID">
+                <set field="invoiceStatusMap.invoiceId" value="${paymentApplication.invoiceId}" />
+                <set field="invoiceStatusMap.statusId" value="INVOICE_READY"/>
+                <now-timestamp field="nowTimestamp"/>
+                <set field="invoiceStatusMap.statusDate" from-field="nowTimestamp" />
+                <call-service service-name="setInvoiceStatus" in-map-name="invoiceStatusMap" />
+            </if-compare>
+            <check-errors/>
+            <field-to-result field="paymentApplication.invoiceId" result-name="invoiceId"/>
+            <property-to-field resource="AccountingUiLabels" property="AccountingPaymentApplToInvoice" field="toMessage"/>
+        </if-not-empty>
+        <!-- invoice item -->
+        <if-not-empty field="paymentApplication.invoiceItemSeqId">
+            <field-to-result field="paymentApplication.invoiceItemSeqId" result-name="invoiceItemSeqId"/>
+            <property-to-field resource="AccountingUiLabels" property="AccountingApplicationToInvoiceItem" field="toMessage"/>
+        </if-not-empty>
+        <!-- toPayment -->
+        <if-not-empty field="paymentApplication.toPaymentId">
+            <entity-one entity-name="Payment" value-field="toPayment">
+                <field-map field-name="paymentId" value="${paymentApplication.toPaymentId}"/>
+            </entity-one>
+            <if-not-empty field="toPayment">
+                <if-compare field="toPayment.statusId" operator="equals" value="PMNT_CONFIRMED">
+                    <add-error><fail-message message="Related payment [${toPayment.paymentId}] has status 'confirmed', cannot remove application."/></add-error>
+                </if-compare>
+                <check-errors/>
+            </if-not-empty>
+            <property-to-field resource="AccountingUiLabels" property="AccountingPaymentApplToPayment" field="toMessage"/>
+            <field-to-result field="paymentApplication.toPaymentId" result-name="toPaymentId"/>
+        </if-not-empty>
+        <!-- billing account -->
+        <if-not-empty field="paymentApplication.billingAccountId">
+            <field-to-result field="paymentApplication.billingAccountId" result-name="billingAccountId"/>
+            <property-to-field resource="AccountingUiLabels" property="AccountingPaymentApplToBillingAccount" field="toMessage"/>
+            <entity-one entity-name="BillingAccount" value-field="billingAccount">
+                <field-map field-name="billingAccountId" from-field="paymentApplication.billingAccountId"/>
+            </entity-one>
+            <set field="currencyUomId" from-field="billingAccount.accountCurrencyUomId"/>
+        </if-not-empty>
+        <!-- tax authority -->
+        <if-not-empty field="paymentApplication.taxAuthGeoId">
+            <field-to-result field="paymentApplication.taxAuthGeoId" result-name="taxAuthGeoId"/>
+            <property-to-field resource="AccountingUiLabels" property="AccountingPaymentApplToTaxAuth" field="toMessage"/>
+        </if-not-empty>
+        <!-- finally delete application -->
+        <property-to-field resource="AccountingUiLabels" property="AccountingPaymentApplRemoved" field="successMessage"/>
+        <string-append field="successMessage" string=" ${toMessage}"/>
+        <remove-value value-field="paymentApplication"/>
+    </simple-method>
+
+    <simple-method method-name="createInvoiceRole" short-description="Create a Invoice Role">
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+        <make-value value-field="newEntity" entity-name="InvoiceRole"/>
+        <set-nonpk-fields map="parameters" value-field="newEntity"/>
+        <set-pk-fields map="parameters" value-field="newEntity"/>
+        <if-empty field="newEntity.datetimePerformed"><now-timestamp field="newEntity.datetimePerformed"/></if-empty>
+        <create-value value-field="newEntity"/>
+    </simple-method>
+
+    <simple-method method-name="removeInvoiceRole" short-description="Remove existing Invoice Role">
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+        <entity-one entity-name="InvoiceRole" value-field="lookedUpValue"/>
+        <remove-value value-field="lookedUpValue"/>
+    </simple-method>
+
+    <simple-method method-name="setInvoiceStatus" short-description="Set The Invoice Status">
+        <entity-one entity-name="Invoice" value-field="invoice"/>
+        <field-to-result field="invoice.statusId" result-name="oldStatusId"/>
+        <if-compare-field field="invoice.statusId" to-field="parameters.statusId" operator="not-equals">
+            <entity-one entity-name="StatusValidChange" value-field="statusChange" auto-field-map="false">
+                <field-map field-name="statusId" from-field="invoice.statusId"/>
+                <field-map field-name="statusIdTo" from-field="parameters.statusId"/>
+            </entity-one>
+            <if-empty field="statusChange">
+                <add-error><fail-message message="Status is not a valid change"/></add-error>
+                <log level="error" message="Cannot change from ${invoice.statusId} to ${parameters.statusId}"/>
+                <check-errors/>
+            <else>
+                <!-- if new status is paid check if the complete invoice is applied. -->
+                <if-compare field="parameters.statusId" operator="equals" value="INVOICE_PAID">
+                    <set field="notApplied" type="BigDecimal" value="${bsh:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(invoice)}"/>
+                    <if-compare field="notApplied" operator="not-equals" value="0.00" type="BigDecimal">
+                        <add-error><fail-message message="Cannot change status to 'paid', invoice ${invoice.invoiceId} has an unapplied balance of [${notApplied}]"/></add-error>
+                        <check-errors/>
+                    </if-compare>
+
+                    <!-- if it's OK to mark invoice paid, use parameter for paidDate -->
+                    <if-empty field="parameters.paidDate">
+                       <now-timestamp field="nowTimestamp"/>
+                       <set from-field="nowTimestamp" field="invoice.paidDate"/>
+                    <else>
+                       <set from-field="parameters.paidDate" field="invoice.paidDate"/>
+                    </else>
+                    </if-empty>
+                </if-compare>
+
+                <if-not-empty field="invoice.paidDate">
+                   <if-compare field="parameters.statusId" operator="equals" value="INVOICE_READY">
+                       <clear-field field="invoice.paidDate" />
+                   </if-compare>
+                </if-not-empty>
+
+                <set from-field="parameters.statusId" field="invoice.statusId"/>
+                <store-value value-field="invoice"/>
+
+                <make-value value-field="newEntity" entity-name="InvoiceStatus"/>
+                <set-nonpk-fields map="parameters" value-field="newEntity"/>
+                <set-pk-fields map="parameters" value-field="newEntity"/>
+
+                <if-empty field="newEntity.statusDate">
+                    <now-timestamp field="newEntity.statusDate"/>
+                </if-empty>
+                <create-value value-field="newEntity"/>
+
+                <!-- if new status is cancelled remove existing payment applications and time entries. -->
+                <if-compare field="parameters.statusId" operator="equals" value="INVOICE_CANCELLED">
+                    <set field="removePaymentApplicationMap.invoiceId" from-field="parameters.invoiceId"/>
+                    <remove-by-and entity-name="PaymentApplication" map="removePaymentApplicationMap"/>
+                    <entity-and entity-name="TimeEntry" list="entries">
+                        <field-map field-name="invoiceId" from-field="parameters.invoiceId"/>
+                    </entity-and>
+                    <iterate entry="entry" list="entries">
+                        <clear-field field="entry.invoiceId"/>                        
+                        <clear-field field="entry.invoiceItemSeqId"/>
+                        <store-value value-field="entry"/>
+                    </iterate>
+                </if-compare>
+            </else>
+            </if-empty>
+        </if-compare-field>
+    </simple-method>
+
+    <simple-method method-name="createInvoiceTerm" short-description="Create a Invoice Term">
+        <call-simple-method method-name="InvoiceStatusInProgress"/>
+
+        <make-value value-field="newEntity" entity-name="InvoiceTerm"/>
+        <set-nonpk-fields map="parameters" value-field="newEntity"/>
+
+        <sequenced-id sequence-name="InvoiceTerm" field="newEntity.invoiceTermId"/>
+        <field-to-result field="newEntity.invoiceTermId" result-name="invoiceTermId"/>
+
+        <create-value value-field="newEntity"/>
+    </simple-method>
+
+    <simple-method method-name="copyInvoiceToTemplate" short-description="copy a invoice to a InvoiceType starting with 'template'">
+        <set field="parameters.invoiceIdToCopyFrom" from-field="parameters.invoiceId"/>
+        <if-compare field="parameters.invoiceTypeId" operator="equals" value="SALES_INVOICE">
+            <set field="parameters.invoiceTypeId" value="SALES_INV_TEMPLATE"/>
+        </if-compare>
+        <if-compare field="parameters.invoiceTypeId" operator="equals" value="PURCHASE_INVOICE">
+            <set field="parameters.invoiceTypeId" value="PUR_INV_TEMPLATE"/>
+        </if-compare>
+        <call-simple-method method-name="copyInvoice"/>
+    </simple-method>
+
+    <!-- ===============subroutine services =================-->
+    <simple-method method-name="InvoiceStatusInProgress" short-description="Check if the invoiceStatus is in progress">
+        <!-- find the current header record -->
+        <entity-one entity-name="Invoice" value-field="headerValue"/>
+        <if-empty field="headerValue">
+            <add-error><fail-message message="Invoice not found, invoice Id: ${invoiceId}"/></add-error>
+            <log level="info" message="Invoice not found, invoice Id: ${invoiceId}"/>
+            <check-errors/>
+        </if-empty>
+        <!-- check if the status is in progress... -->
+        <if-compare field="headerValue.statusId" operator="not-equals" value="INVOICE_IN_PROCESS">
+            <add-error><fail-message message="Can only update Invoice, when status is in-process...is now: ${headerValue.statusId}"/></add-error>
+            <log level="info" message="Can only update Invoice, when status is in-process...is now: ${headerValue.statusId}"/>
+        </if-compare>
+        <check-errors/>
+    </simple-method>
+    <simple-method method-name="createInvoiceContactMech" short-description="Create a ContactMech for an invoice">
+        <make-value value-field="invoiceContactMech" entity-name="InvoiceContactMech"/>
+        <set-pk-fields map="parameters" value-field="invoiceContactMech"/>
+        <create-value value-field="invoiceContactMech"/>
+        <field-to-result field="contactMechId" result-name="invoiceContactMech" />
+    </simple-method>
+    
+    <simple-method method-name="updateInvoiceItemType"  short-description="Updates a InvoiceItemType Record">
+        <entity-one entity-name="InvoiceItemType" value-field="lookedUpValue"/>
+        <set-nonpk-fields value-field="lookedUpValue" map="parameters"/>
+        <store-value value-field="lookedUpValue"/>
+   </simple-method>
+
+   <simple-method method-name="autoGenerateInvoiceFromExistingInvoice" short-description="Scheduled service to generate Invoice from an existing Invoice">
+       <entity-and entity-name="Invoice" list="invoices">
+            <field-map field-name="recurrenceInfoId" from-field="parameters.recurrenceInfoId"/>
+       </entity-and>
+       <iterate list="invoices" entry="invoice">
+           <set-service-fields service-name="copyInvoice" map="invoice" to-map="copyInvoiceCtx"/>
+           <set field="copyInvoiceCtx.invoiceIdToCopyFrom" from-field="invoice.invoiceId"/>
+           <call-service service-name="copyInvoice" in-map-name="copyInvoiceCtx">
+               <result-to-field result-name="invoiceId" field="invoiceId"/>
+           </call-service>
+           <set-service-fields service-name="updateInvoice" map="invoice" to-map="updateInvoiceCtx"/>
+           <set field="updateInvoiceCtx.invoiceId" from-field="invoiceId"/>
+           <if-compare field="updateInvoiceCtx.invoiceTypeId" operator="equals" value="SALES_INV_TEMPLATE">
+               <set field="updateInvoiceCtx.invoiceTypeId" value="SALES_INVOICE"/>
+           </if-compare>
+           <if-compare field="updateInvoiceCtx.invoiceTypeId" operator="equals" value="PUR_INV_TEMPLATE">
+               <set field="updateInvoiceCtx.invoiceTypeId" value="PURCHASE_INVOICE"/>
+           </if-compare>
+           <clear-field field="invoice"/>
+           <clear-field field="parameters.invoiceIdToCopyFrom"/>
+           <clear-field field="updateInvoiceCtx.recurrenceInfoId"/>
+           <call-service service-name="updateInvoice" in-map-name="updateInvoiceCtx"/>
+       </iterate>
+   </simple-method>
+</simple-methods>

Propchange: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceEvents.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy?rev=735949&r1=735948&r2=735949&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy Mon Jan 19 23:15:19 2009
@@ -51,6 +51,17 @@
     itemTypesCond = EntityCondition.makeCondition(itemTypes, EntityOperator.OR);
     invoiceItemTypes = delegator.findList("InvoiceItemType", itemTypesCond, null, ["parentTypeId", "invoiceItemTypeId"], null, false);
     glAccountOrganizationAndClassList = delegator.findByAnd("GlAccountOrganizationAndClass", [organizationPartyId : invoice.partyId]);
+} else if ("PAYROL_INVOICE".equals(invoice.invoiceTypeId)) {
+    List itemTypes = FastList.newInstance();
+    itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PAYROL_EARN_HOURS"));
+    itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PAYROL_EARN_HOURS"));
+    itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PAYROL_DD_FROM_GROSS"));
+    itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PAYROL_DD_FROM_GROSS"));
+    itemTypes.add(EntityCondition.makeCondition("invoiceItemTypeId", EntityOperator.EQUALS, "PAYROL_TAXES"));
+    itemTypes.add(EntityCondition.makeCondition("parentTypeId", EntityOperator.EQUALS, "PAYROL_TAXES"));
+    itemTypesCond = EntityCondition.makeCondition(itemTypes, EntityOperator.OR);
+    invoiceItemTypes = delegator.findList("InvoiceItemType", itemTypesCond, null, ["parentTypeId", "invoiceItemTypeId"], null, false);
+    glAccountOrganizationAndClassList = delegator.findByAnd("GlAccountOrganizationAndClass", [organizationPartyId : invoice.partyId]);
 } else {
     map = delegator.findByAndCache("InvoiceItemTypeMap", [invoiceTypeId : invoice.invoiceTypeId]);
     invoiceItemTypes = EntityUtil.getRelated("InvoiceItemType", map);

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml?rev=735949&r1=735948&r2=735949&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Mon Jan 19 23:15:19 2009
@@ -192,6 +192,12 @@
         <response name="success" type="view" value="listInvoiceItems"/>
         <response name="error" type="view" value="listInvoiceItems"/>
     </request-map>
+    <request-map uri="createInvoiceItemPayrol">
+        <security https="true" auth="true"/>
+        <event type="simple" invoke="createInvoiceItemPayrol" path="org/ofbiz/accounting/invoice/InvoiceEvents.xml"/>
+        <response name="success" type="view" value="listInvoiceItems"/>
+        <response name="error" type="view" value="listInvoiceItems"/>
+    </request-map>
     <request-map uri="updateInvoiceItem">
         <security https="true" auth="true"/>
         <event type="service" invoke="updateInvoiceItem"/>

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml?rev=735949&r1=735948&r2=735949&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceForms.xml Mon Jan 19 23:15:19 2009
@@ -196,10 +196,9 @@
             </drop-down>
         </field>
         <field position="1" name="organizationPartyId" parameter-name="partyIdFrom">
-            <drop-down allow-empty="false">
-                <entity-options description="${partyId}" entity-name="PartyRole" key-field-name="partyId">
-                    <entity-constraint name="roleTypeId" value="INTERNAL_ORGANIZATIO"/>
-                    <entity-order-by field-name="partyId"/>
+            <drop-down allow-empty="false" no-current-selected-key="${defaultOrganizationPartyId}">
+                <entity-options description="${groupName}" entity-name="PartyAcctgPrefAndGroup" key-field-name="partyId">
+                    <entity-order-by field-name="groupName"/>
                 </entity-options>
             </drop-down>
         </field>
@@ -220,10 +219,9 @@
             </drop-down>
         </field>
         <field position="1" name="organizationPartyId" parameter-name="partyId">
-            <drop-down allow-empty="false">
-                <entity-options description="${partyId}" entity-name="PartyRole" key-field-name="partyId">
-                    <entity-constraint name="roleTypeId" value="INTERNAL_ORGANIZATIO"/>
-                    <entity-order-by field-name="partyId"/>
+            <drop-down allow-empty="false" no-current-selected-key="${defaultOrganizationPartyId}">
+                <entity-options description="${groupName}" entity-name="PartyAcctgPrefAndGroup" key-field-name="partyId">
+                    <entity-order-by field-name="groupName"/>
                 </entity-options>
             </drop-down>
         </field>

Added: ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl?rev=735949&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl (added)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl Mon Jan 19 23:15:19 2009
@@ -0,0 +1,74 @@
+<#--
+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.
+-->
+<form method="post" action="/accounting/control/createInvoiceItemPayrol">
+<input type="hidden" name="invoiceId" value="${invoice.invoiceId}">
+<table class="basic-table hover-bar" cellspacing="0">
+
+<#if PayrolGroup?has_content>
+<#list PayrolGroup as payrolGroup>
+<tr class="header-row" >
+ <td>
+ [${payrolGroup.description}]
+ </td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+</tr>
+<tr class="header-row">
+
+<td width="50%" align="center">Description</td>
+<td width="10px" align="center">Quantity</td>
+<td width="10px" align="center">Amount</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+</tr>
+ <#if PayrolList?has_content>
+ <#list PayrolList as payrolList>
+ <#if payrolList.parentTypeId?if_exists == payrolGroup.invoiceItemTypeId?if_exists>
+<tr>
+ <td align="right">
+ ${payrolList.description} :
+ </td>
+ <td ><input type="text" size=10 name="${payrolList.invoiceItemTypeId}_Quantity"/></td>
+ <td ><input type="text" size=10 name="${payrolList.invoiceItemTypeId}_Amount"/></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+</tr>
+ </#if>
+ </#list>
+ </#if>
+</#list>
+</#if>
+<tr class="header-row">
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+<td>&nbsp;</td>
+</tr>
+<tr >
+ <td align="right"><b>Add all values : </b></td>
+ <td align="center" ><input type="submit" value="Add"></td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+ <td>&nbsp;</td>
+</tr>
+</table>
+</form>

Propchange: ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml?rev=735949&r1=735948&r2=735949&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/InvoiceScreens.xml Mon Jan 19 23:15:19 2009
@@ -38,7 +38,7 @@
                             </condition>
                             <widgets>
                                 <section>
-                                    <condition><not><if-empty field-name="parameters.invoiceId"/></not></condition>
+                                    <condition><not><if-empty field="parameters.invoiceId"/></not></condition>
                                     <widgets>
                                         <include-menu name="InvoiceTabBar" location="component://accounting/widget/Menus.xml"/>
                                         <include-menu name="InvoiceSubTabBar" location="component://accounting/widget/Menus.xml"/>
@@ -93,7 +93,7 @@
         <section>
             <actions>
                 <set field="titleProperty" value="AccountingCreateNewInvoice"/>
-                <entity-one entity-name="Invoice" value-name="invoice"/>
+                <entity-one entity-name="Invoice" value-field="invoice"/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonInvoiceDecorator" location="${parameters.invoiceDecoratorLocation}">
@@ -143,8 +143,8 @@
                 <set field="tabButtonItem" value="editInvoice"/>
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
                 <property-to-field field="defaultCurrencyUomId" resource="general" property="currency.uom.id.default" default="USD" />
-                <entity-one entity-name="Invoice" value-name="invoice"/>
-                <entity-one entity-name="InvoiceType" value-name="invoiceType">
+                <entity-one entity-name="Invoice" value-field="invoice"/>
+                <entity-one entity-name="InvoiceType" value-field="invoiceType">
                     <field-map field-name="invoiceTypeId" env-name="invoice.invoiceTypeId"/>
                 </entity-one>
             </actions>
@@ -153,7 +153,7 @@
                     <decorator-section name="body">
                         <section>
                             <condition>
-                                <if-compare field-name="invoice.statusId" operator="equals" value="INVOICE_IN_PROCESS"/>
+                                <if-compare field="invoice.statusId" operator="equals" value="INVOICE_IN_PROCESS"/>
                             </condition>
                             <widgets>
                                 <container style="screenlet">
@@ -200,20 +200,20 @@
                 <set field="titleProperty" value="PageTitleInvoiceOverview"/>
                 <set field="tabButtonItem" value="invoiceOverview"/>
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
-                <entity-one entity-name="Invoice" value-name="invoice"/>
-                <entity-and entity-name="InvoiceRole" list-name="invoiceRoles">
+                <entity-one entity-name="Invoice" value-field="invoice"/>
+                <entity-and entity-name="InvoiceRole" list="invoiceRoles">
                     <field-map env-name="parameters.invoiceId" field-name="invoiceId"/>
                     <order-by field-name="partyId"/>
                 </entity-and>
-                <entity-and entity-name="InvoiceStatus" list-name="invoiceStatus">
+                <entity-and entity-name="InvoiceStatus" list="invoiceStatus">
                     <field-map env-name="parameters.invoiceId" field-name="invoiceId"/>
                     <order-by field-name="statusDate"/>
                 </entity-and>
-                <entity-and entity-name="InvoiceTerm" list-name="invoiceTerms">
+                <entity-and entity-name="InvoiceTerm" list="invoiceTerms">
                     <field-map env-name="parameters.invoiceId" field-name="invoiceId"/>
                     <order-by field-name="invoiceTermId"/>
                 </entity-and>
-                <entity-and entity-name="TimeEntry" list-name="timeEntries">
+                <entity-and entity-name="TimeEntry" list="timeEntries">
                     <field-map env-name="parameters.invoiceId" field-name="invoiceId"/>
                     <order-by field-name="invoiceItemSeqId"/>
                 </entity-and>
@@ -228,7 +228,7 @@
                     <decorator-section name="body">
                         <section>
                             <condition>
-                                <if-compare field-name="invoice.statusId" operator="equals" value="INVOICE_IN_PROCESS"/>
+                                <if-compare field="invoice.statusId" operator="equals" value="INVOICE_IN_PROCESS"/>
                             </condition>
                             <widgets>
                                 <screenlet title="${uiLabelMap.AccountingInvoiceHeader}">
@@ -304,8 +304,8 @@
                 <set field="titleProperty" value="PageTitleListInvoices"/>
                 <set field="tabButtonItem" value="invoiceStatus"/>
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
-                <entity-one entity-name="Invoice" value-name="invoice" auto-field-map="true"/>
-                <entity-and entity-name="InvoiceStatus" list-name="invoiceStatus">
+                <entity-one entity-name="Invoice" value-field="invoice" auto-field-map="true"/>
+                <entity-and entity-name="InvoiceStatus" list="invoiceStatus">
                     <field-map env-name="invoice.invoiceId" field-name="invoiceId"/>
                     <order-by field-name="statusDate"/>
                 </entity-and>
@@ -340,7 +340,7 @@
                 <set field="tabButtonItem" value="editInvoiceApplications"/>
                 
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
-                <entity-one entity-name="Invoice" value-name="invoice"/>
+                <entity-one entity-name="Invoice" value-field="invoice"/>
                 <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/CreateApplicationList.groovy"/>
                 <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/ListNotAppliedPayments.groovy"/>
                 <set field="invoiceAmount" value="${bsh:org.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceTotal(invoice)}" type="BigDecimal"/>
@@ -352,7 +352,7 @@
                     <decorator-section name="body">
                         <section>
                             <condition>
-                                <if-compare field-name="notAppliedAmount" operator="greater" value="0"/>
+                                <if-compare field="notAppliedAmount" operator="greater" value="0"/>
                             </condition>
                             <widgets>
                                 <screenlet title="${uiLabelMap.AccountingPaymentsApplied} ${appliedAmount?currency(${invoice.currencyUomId})} ${uiLabelMap.AccountingOpenPayments} ${notAppliedAmount?currency(${invoice.currencyUomId})}">
@@ -360,7 +360,7 @@
                                 </screenlet>
                                 <section>
                                     <condition>
-                                        <if-empty field-name="invoiceApplications"/>
+                                        <if-empty field="invoiceApplications"/>
                                     </condition>
                                     <widgets>
                                         <container><label style="h3" text="${uiLabelMap.AccountingNoPaymentsApplicationsfound}"></label></container>
@@ -369,15 +369,15 @@
                                 <section>
                                     <condition>
                                         <or>
-                                            <not><if-empty field-name="payments"/></not>
-                                            <not><if-empty field-name="paymentsActualCurrency"/></not>
+                                            <not><if-empty field="payments"/></not>
+                                            <not><if-empty field="paymentsActualCurrency"/></not>
                                         </or>
                                     </condition>
                                     <widgets>
                                         <screenlet title="${uiLabelMap.AccountingListPaymentsNotYetApplied} [${invoice.partyIdFrom}] ${uiLabelMap.AccountingPaymentSentForm} [${invoice.partyId}]">
                                         <section>
                                             <condition>
-                                                <not><if-empty field-name="payments"/></not>
+                                                <not><if-empty field="payments"/></not>
                                             </condition>
                                             <widgets>
                                                 <include-form name="ListPaymentsNotApplied" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
@@ -385,7 +385,7 @@
                                         </section>
                                         <section>
                                             <condition>
-                                                <not><if-empty field-name="paymentsActualCurrency"/></not>
+                                                <not><if-empty field="paymentsActualCurrency"/></not>
                                             </condition>
                                             <widgets>
                                                 <include-form name="ListPaymentsNotAppliedForeignCurrency" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
@@ -415,7 +415,7 @@
                                 </screenlet>
                                 <section>
                                     <condition>
-                                        <if-empty field-name="invoiceApplications"/>
+                                        <if-empty field="invoiceApplications"/>
                                     </condition>
                                     <widgets>
                                         <container><label style="h3" text="${uiLabelMap.AccountingNoPaymentsApplicationsfound}"></label></container>
@@ -437,13 +437,17 @@
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
                 <set field="invoiceItemSeqd" from-field="parameters.invoiceItemSeqId"/>
                 <property-to-field field="defaultCurrencyUomId" resource="general" property="currency.uom.id.default" default="USD" />
-                <entity-one entity-name="Invoice" value-name="invoice"/>
-                <entity-one entity-name="InvoiceItem" value-name="invoiceItem"/>
-                <entity-and entity-name="InvoiceItem" list-name="invoiceItems">
+                <entity-one entity-name="Invoice" value-field="invoice" />
+                <entity-one entity-name="InvoiceItem" value-field="invoiceItem"/>
+                <entity-and entity-name="InvoiceItem" list="invoiceItems">
                     <field-map field-name="invoiceId" env-name="parameters.invoiceId"/>
                     <order-by field-name="invoiceItemSeqId"/>
                 </entity-and>
                 <script location="component://accounting/webapp/accounting/WEB-INF/actions/invoice/GetInvoiceItemTypes.groovy"/>
+                <entity-condition entity-name="InvoiceItemType" list="PayrolGroup">
+                    <condition-expr field-name="parentTypeId" value="PAYROL"/>
+                </entity-condition>
+                <entity-condition entity-name="InvoiceItemType" list="PayrolList"></entity-condition>
             </actions>
             <widgets>
                 <decorator-screen name="CommonInvoiceDecorator" location="${parameters.invoiceDecoratorLocation}">
@@ -470,9 +474,15 @@
                             </container>
                             <container style="screenlet-body">
                                 <section>
-                                    <widgets>    
+                                    <condition>
+                                        <not><if-compare field="invoice.invoiceTypeId" operator="equals" value="PAYROL_INVOICE"/></not>
+                                    </condition>
+                                    <widgets>  
                                         <include-form name="EditInvoiceItem" location="component://accounting/webapp/accounting/invoice/InvoiceForms.xml"/>
                                     </widgets>
+                                    <fail-widgets>
+                                        <platform-specific><html><html-template location="component://accounting/webapp/accounting/invoice/InvoiceItemsPayrol.ftl"/></html></platform-specific>
+                                    </fail-widgets>
                                 </section>
                             </container>
                         </container>
@@ -488,8 +498,8 @@
                 <set field="titleProperty" value="PageTitleListInvoiceTimeEntries"/>
                 <set field="tabButtonItem" value="EditInvoiceTimeEntries"/>
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
-                <entity-one entity-name="Invoice" value-name="invoice"/>
-                <entity-and entity-name="TimeEntry" list-name="timeEntries">
+                <entity-one entity-name="Invoice" value-field="invoice"/>
+                <entity-and entity-name="TimeEntry" list="timeEntries">
                     <field-map field-name="invoiceId" env-name="parameters.invoiceId"/>
                     <order-by field-name="timeEntryId"/>
                 </entity-and>
@@ -523,8 +533,8 @@
                 <set field="titleProperty" value="PageTitleListInvoiceRoles"/>
                 <set field="tabButtonItem" value="invoiceRoles"/>
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
-                <entity-one entity-name="Invoice" value-name="invoice"/>
-                <entity-and entity-name="InvoiceRole" list-name="invoiceRoles">
+                <entity-one entity-name="Invoice" value-field="invoice"/>
+                <entity-and entity-name="InvoiceRole" list="invoiceRoles">
                     <field-map env-name="invoiceId" field-name="invoiceId"/>
                     <order-by field-name="partyId"/>
                 </entity-and>
@@ -547,7 +557,7 @@
             <actions>
                 <set field="titleProperty" value="PageTitleSendInvoicePerEmail"/>
                 <set field="invoiceId" from-field="parameters.invoiceId"/>
-                <entity-one entity-name="Invoice" value-name="invoice"/>
+                <entity-one entity-name="Invoice" value-field="invoice"/>
                 <set field="tabButtonItem" value="sendPerEmail"/>
             </actions>
             <widgets>