svn commit: r792222 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/invoice/InvoiceServices.xml servicedef/services_invoice.xml webapp/ap/WEB-INF/controller.xml webapp/ap/invoices/PurchaseInvoices.ftl

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

svn commit: r792222 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/invoice/InvoiceServices.xml servicedef/services_invoice.xml webapp/ap/WEB-INF/controller.xml webapp/ap/invoices/PurchaseInvoices.ftl

ashish-18
Author: ashish
Date: Wed Jul  8 16:42:28 2009
New Revision: 792222

URL: http://svn.apache.org/viewvc?rev=792222&view=rev
Log:
Applied patch from jira issue OFBIZ-2706 -  Create a screen under AP -> Invoice, which will search for a PURCHASE_INVOICE between dates.
Following thing is covered in this patch:
– Added running total functionality for selected invoices.

Thanks Arpit, Rishi for your contribution.

Modified:
    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/WEB-INF/controller.xml
    ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl

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=792222&r1=792221&r2=792222&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 Wed Jul  8 16:42:28 2009
@@ -625,4 +625,23 @@
         </iterate>
     </simple-method>
 
+    <simple-method method-name="getInvoiceRunningTotal" short-description="calculate running total for Invoices">
+        <set field="invoiceIds" from-field="parameters.invoiceIds"/>
+        <set field="invoiceRunningTotal" type="BigDecimal" value="0"/>
+        <iterate list="invoiceIds" entry="invoiceId">
+            <entity-one entity-name="Invoice" value-field="invoice" auto-field-map="true"/>
+            <set field="serviceInMap.invoiceId" from-field="invoice.invoiceId"/>
+            <call-service service-name="getInvoicePaymentInfoList" in-map-name="serviceInMap">
+                <result-to-field result-name="invoicePaymentInfoList"/>
+            </call-service>
+            <first-from-list list="invoicePaymentInfoList" entry="invoicePaymentInfo"/>
+            <calculate field="invoiceRunningTotal">
+                <calcop operator="add" field="invoiceRunningTotal">
+                    <calcop operator="get" field="invoicePaymentInfo.outstandingAmount"/>
+                </calcop>
+            </calculate>
+        </iterate>
+        <field-to-result field="invoiceRunningTotal"/>
+    </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=792222&r1=792221&r2=792222&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Wed Jul  8 16:42:28 2009
@@ -292,4 +292,12 @@
         <description>Cancel Invoice</description>
         <attribute name="invoiceId" type="String" mode="IN" optional="false"/>
     </service>
+    
+    <service name="getInvoiceRunningTotal" engine="simple"
+            location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="getInvoiceRunningTotal" auth="true">
+        <description>calculate running total for selected Invoices</description>
+        <attribute name="invoiceIds" type="List" mode="IN" optional="false"/>
+        <attribute name="invoiceRunningTotal" type="BigDecimal" mode="OUT" optional="false"/>
+    </service>
+
 </services>

Modified: ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml?rev=792222&r1=792221&r2=792222&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/ap/WEB-INF/controller.xml Wed Jul  8 16:42:28 2009
@@ -43,6 +43,11 @@
         <security https="true" auth="true"/>
         <response name="success" type="view" value="NewPurchaseInvoice"/>
     </request-map>
+    <request-map uri="getInvoiceRunningTotal">
+        <event type="jsonservice" invoke="getInvoiceRunningTotal"/>
+        <response name="success" type="none"/>
+        <response name="error" type="none"/>
+    </request-map>
 
     <!-- ================ Vendor requests ================ -->
     <request-map uri="findVendors">

Modified: ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl?rev=792222&r1=792221&r2=792222&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl (original)
+++ ofbiz/trunk/applications/accounting/webapp/ap/invoices/PurchaseInvoices.ftl Wed Jul  8 16:42:28 2009
@@ -16,12 +16,58 @@
 specific language governing permissions and limitations
 under the License.
 -->
+<script language="JavaScript" type="text/javascript">
+<!--
+function toggleInvoiceId(master) {
+    var form = document.listPurchaseInvoices;
+    var invoices = form.elements.length;
+    for (var i = 0; i < invoices; i++) {
+        var element = form.elements[i];
+        if (element.name == "invoiceIds") {
+            element.checked = master.checked;
+        }
+    }
+    getInvoiceRunningTotal(master);
+}
+
+function getInvoiceRunningTotal(e) {
+    var form = document.listPurchaseInvoices;
+    var invoices = form.elements.length;
+    var isSingle = true;
+    for (var i = 0; i < invoices; i++) {
+        var element = form.elements[i];
+        if (element.name == "invoiceIds" && element.checked) {
+            isSingle = false;
+        }
+    }
+    if (!($(e).checked)) {
+        $('checkAllInvoices').checked = false;
+    }
+    if (!isSingle) {
+        new Ajax.Request('getInvoiceRunningTotal', {
+            asynchronous: false,
+            onSuccess: function(transport) {
+                var data = transport.responseText.evalJSON(true);
+                $('showInvoiceRunningTotal').update(data.invoiceRunningTotal);
+            }, parameters: $('listPurchaseInvoices').serialize(), requestHeaders: {Accept: 'application/json'}
+        });
+    } else {
+        $('showInvoiceRunningTotal').update("");
+    }
+}
+-->
+</script>
 
 <#if invoices?has_content >
-  <form name="ListPurchaseInvoices">
+  <div>
+    <span class="label">${uiLabelMap.AccountingRunningTotal} :</span>
+    <span class="label" id="showInvoiceRunningTotal"></span>
+  </div>
+  <form name="listPurchaseInvoices" id="listPurchaseInvoices">
     <table class="basic-table hover-bar" cellspacing="0">
       <#-- Header Begins -->
       <tr class="header-row-2">
+        <td width="8%"><input type="checkbox" id="checkAllInvoices" name="checkAllInvoices" onchange="javascript:toggleInvoiceId(this);"/> ${uiLabelMap.CommonSelectAll}</td>
         <td width="10%">${uiLabelMap.FormFieldTitle_invoiceId}</td>
         <td width="15%">${uiLabelMap.AccountingVendorParty}</td>
         <td width="10%">${uiLabelMap.CommonStatus}</td>
@@ -40,6 +86,7 @@
         <#if invoicePaymentInfo.outstandingAmount != 0>
           <#assign statusItem = invoice.getRelatedOneCache("StatusItem")>
           <tr valign="middle"<#if alt_row> class="alternate-row"</#if>>
+            <td><input type="checkbox" id="invoiceId_${invoice_index}" name="invoiceIds" value="${invoice.invoiceId}" onclick="javascript:getInvoiceRunningTotal('invoiceId_${invoice_index}');"/></td>
             <td><a class="buttontext" href="<@ofbizUrl>invoiceOverview?invoiceId=${invoice.invoiceId}</@ofbizUrl>">${invoice.get("invoiceId")}</a></td>
             <td>${Static["org.ofbiz.party.party.PartyHelper"].getPartyName(delegator, invoice.partyIdFrom, false)?if_exists}</td>
             <td>${statusItem.get("description")?if_exists}</td>