svn commit: r796289 - in /ofbiz/trunk/applications/accounting: entitydef/ script/org/ofbiz/accounting/invoice/ servicedef/ webapp/ap/WEB-INF/actions/invoices/ webapp/ap/invoices/ widget/ap/ widget/ap/forms/

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

svn commit: r796289 - in /ofbiz/trunk/applications/accounting: entitydef/ script/org/ofbiz/accounting/invoice/ servicedef/ webapp/ap/WEB-INF/actions/invoices/ webapp/ap/invoices/ widget/ap/ widget/ap/forms/

apatel-2
Author: apatel
Date: Tue Jul 21 13:22:26 2009
New Revision: 796289

URL: http://svn.apache.org/viewvc?rev=796289&view=rev
Log:
Cleaned up create commission invoice process. Added new search parameters to search process.
Thanks Sumit, Rishi, Amit and Awdesh.
Patch from OFBIZ-2713

Added:
    ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy
Modified:
    ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
    ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionRun.ftl
    ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml
    ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml

Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=796289&r1=796288&r2=796289&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Tue Jul 21 13:22:26 2009
@@ -1556,6 +1556,16 @@
     </relation>
   </view-entity>
 
+    <view-entity entity-name="InvoiceAndRole" package-name="org.ofbiz.accounting.invoice">
+        <member-entity entity-alias="INV" entity-name="Invoice"/>
+        <member-entity entity-alias="INR" entity-name="InvoiceRole"/>
+        <alias-all entity-alias="INV"/>
+        <alias name="invoiceRolePartyId" entity-alias="INR" field="partyId"/>
+        <alias name="invoiceRoleTypeId" entity-alias="INR" field="roleTypeId"/>
+        <view-link entity-alias="INV" rel-entity-alias="INR" rel-optional="true">
+            <key-map field-name="invoiceId"/>
+        </view-link>
+    </view-entity>
 
   <!-- ========================================================= -->
   <!-- org.ofbiz.accounting.ledger -->

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=796289&r1=796288&r2=796289&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 Tue Jul 21 13:22:26 2009
@@ -648,5 +648,20 @@
         </iterate>
         <field-to-result field="invoiceRunningTotal"/>
     </simple-method>
+    
+    <simple-method method-name="getInvoicesFilterByAssocType" short-description="Filter invoices by invoiceItemAssocTypeId">
+        <set field="invoiceList" from-field="parameters.invoiceList"/>
+        <set field="invoiceItemAssocTypeId" from-field="parameters.invoiceItemAssocTypeId"/>
+        <iterate list="invoiceList" entry="invoice">
+            <entity-and entity-name="InvoiceItemAssoc" list="invoiceItemAssocList" filter-by-date="true">
+                <field-map field-name="invoiceIdFrom" from-field="invoice.invoiceId"/>
+                <field-map field-name="invoiceItemAssocTypeId"/>
+            </entity-and>
+            <if-empty field="invoiceItemAssocList">
+                <field-to-list field="invoice" list="filteredInvoiceList"/>
+            </if-empty>
+        </iterate>
+        <field-to-result field="filteredInvoiceList"/>
+    </simple-method>
 
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?rev=796289&r1=796288&r2=796289&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Tue Jul 21 13:22:26 2009
@@ -306,4 +306,11 @@
         <attribute name="invoiceRunningTotal" type="BigDecimal" mode="OUT" optional="false"/>
     </service>
 
+    <service name="getInvoicesFilterByAssocType" engine="simple"
+            location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="getInvoicesFilterByAssocType" auth="true">
+        <description>Filter invoices by invoiceItemAssocTypeId</description>
+        <attribute name="invoiceList" type="List" mode="IN" optional="false"/>
+        <attribute name="invoiceItemAssocTypeId" type="String" mode="IN" optional="false"/>
+        <attribute name="filteredInvoiceList" type="List" mode="OUT" optional="true"/>
+    </service>
 </services>

Added: ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy?rev=796289&view=auto
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy (added)
+++ ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy Tue Jul 21 13:22:26 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+import org.ofbiz.entity.condition.EntityCondition;
+import org.ofbiz.entity.condition.EntityOperator;
+
+fromDate = parameters.fromDate;
+thruDate = parameters.thruDate;
+partyIds = parameters.partyIds;
+
+if (fromDate) {
+    List invoiceCond = [];
+    invoiceCond.add(EntityCondition.makeCondition("invoiceTypeId", EntityOperator.EQUALS, parameters.invoiceTypeId));
+    invoiceCond.add(EntityCondition.makeCondition("statusId", EntityOperator.EQUALS, parameters.statusId));
+    invoiceCond.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.GREATER_THAN_EQUAL_TO, Timestamp.valueOf(fromDate)));
+    invoiceCond.add(EntityCondition.makeCondition("invoiceRoleTypeId", EntityOperator.EQUALS, "SALES_REP"));
+    if (thruDate) {
+        invoiceCond.add(EntityCondition.makeCondition("invoiceDate", EntityOperator.LESS_THAN_EQUAL_TO, Timestamp.valueOf(thruDate)));
+    }
+    if (partyIds) {
+        invoiceCond.add(EntityCondition.makeCondition("invoiceRolePartyId", EntityOperator.IN, partyIds));
+    }
+    invoiceList = delegator.findList("InvoiceAndRole", EntityCondition.makeCondition(invoiceCond, EntityOperator.AND), null, null, null, false);
+
+    List invoices = [];
+    if (invoiceList) {
+        resultMap = dispatcher.runSync("getInvoicesFilterByAssocType", [invoiceItemAssocTypeId : "COMMISSION_INVOICE", invoiceList : invoiceList, userLogin : userLogin]);
+        invoices = resultMap.filteredInvoiceList;
+        context.invoices = invoices;
+    }
+}

Modified: ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionRun.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionRun.ftl?rev=796289&r1=796288&r2=796289&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionRun.ftl (original)
+++ ofbiz/trunk/applications/accounting/webapp/ap/invoices/CommissionRun.ftl Tue Jul 21 13:22:26 2009
@@ -60,7 +60,7 @@
       <#list invoices as invoice>
         <#assign invoicePaymentInfoList = dispatcher.runSync("getInvoicePaymentInfoList", Static["org.ofbiz.base.util.UtilMisc"].toMap("invoiceId", invoice.invoiceId, "userLogin", userLogin))/>
         <#assign invoicePaymentInfo = invoicePaymentInfoList.get("invoicePaymentInfoList").get(0)?if_exists>
-        <#assign statusItem = invoice.getRelatedOneCache("StatusItem")>
+        <#assign statusItem = delegator.findOne("StatusItem", {"statusId" : invoice.statusId}, false)?if_exists/>
         <tr valign="middle"<#if alt_row> class="alternate-row"</#if>>
           <td><input type="checkbox" id="invoiceId_${invoice_index}" name="invoiceIds" value="${invoice.invoiceId}"/></td>
           <td><a class="buttontext" href="<@ofbizUrl>invoiceOverview?invoiceId=${invoice.invoiceId}</@ofbizUrl>">${invoice.get("invoiceId")}</a></td>

Modified: ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml?rev=796289&r1=796288&r2=796289&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ap/InvoiceScreens.xml Tue Jul 21 13:22:26 2009
@@ -157,17 +157,8 @@
             <actions>
                 <set field="titleProperty" value="AccountingFindSalesInvoicesForCommissionRun"/>
                 <set field="tabButtonItem" value="commissionRun"/>
-                <set field="parameters.sortField" from-field="parameters.sortField" default-value="-invoiceDate"/>
-                <entity-condition entity-name="Invoice" list="invoices">
-                    <condition-list combine="and">
-                        <condition-expr field-name="invoiceId" operator="equals" from-field="parameters.invoiceId" ignore-if-empty="true"/>
-                        <condition-expr field-name="invoiceTypeId" operator="equals" from-field="parameters.invoiceTypeId" ignore-if-empty="false"/>
-                        <condition-expr field-name="invoiceDate" operator="greater-equals" from-field="parameters.fromInvoiceDate" ignore-if-empty="true"/>
-                        <condition-expr field-name="invoiceDate" operator="less-equals" from-field="parameters.thruInvoiceDate" ignore-if-empty="true"/>
-                        <condition-expr field-name="statusId" operator="equals" from-field="parameters.statusId" ignore-if-empty="true"/>
-                    </condition-list>
-                    <order-by field-name="invoiceId"/>
-                </entity-condition>
+                <script location="component://accounting/webapp/ap/WEB-INF/actions/invoices/CommissionRun.groovy"/>
+                <set field="parameters.partyIds" value=""/>
             </actions>
             <widgets>
                 <decorator-screen name="CommonApInvoiceDecorator" location="component://accounting/widget/ap/CommonScreens.xml">
@@ -191,4 +182,4 @@
             </widgets>
         </section>
     </screen>
-</screens>
\ No newline at end of file
+</screens>

Modified: ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml?rev=796289&r1=796288&r2=796289&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ap/forms/InvoiceForms.xml Tue Jul 21 13:22:26 2009
@@ -143,7 +143,7 @@
     </form>
 
     <form name="CommissionRun" type="single" target="CommissionRun">
-        <field name="partyId" required-field="true">
+        <field name="partyIds" field-name="partyId" title="${uiLabelMap.PartyPartyId}">
             <drop-down allow-multiple="true">
                 <entity-options entity-name="PartyRole" description="${partyId}">
                     <entity-constraint name="roleTypeId" operator="equals" value="SALES_REP"/>
@@ -152,8 +152,8 @@
         </field>
         <field name="invoiceTypeId"><hidden value="SALES_INVOICE"/></field>
         <field name="statusId"><hidden value="INVOICE_PAID"/></field>
-        <field name="fromInvoiceDate" position="1"><date-time/></field>
-        <field name="thruInvoiceDate" position="2"><date-time/></field>
+        <field name="fromDate" position="1"><date-time/></field>
+        <field name="thruDate" position="2"><date-time/></field>
         <field name="search" widget-style="smallSubmit"><submit button-type="button"/></field>
     </form>
 </forms>