svn commit: r791883 - in /ofbiz/trunk/applications/accounting: config/ script/org/ofbiz/accounting/payment/ servicedef/ webapp/ar/WEB-INF/ webapp/ar/payment/ widget/ar/

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

svn commit: r791883 - in /ofbiz/trunk/applications/accounting: config/ script/org/ofbiz/accounting/payment/ servicedef/ webapp/ar/WEB-INF/ webapp/ar/payment/ widget/ar/

ashish-18
Author: ashish
Date: Tue Jul  7 15:57:44 2009
New Revision: 791883

URL: http://svn.apache.org/viewvc?rev=791883&view=rev
Log:
Applied patch from jira issue OFBIZ-2699 - Create Payment Batches for Ar Payment
Following things are covered in this section:
– Added running total functionality .
– Improvement in existing code and service logic

Thanks Awdesh, Rishi, Sumit & Anil for your contribution.

Modified:
    ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
    ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/controller.xml
    ofbiz/trunk/applications/accounting/webapp/ar/payment/batchPayments.ftl
    ofbiz/trunk/applications/accounting/widget/ar/ArMenus.xml
    ofbiz/trunk/applications/accounting/widget/ar/CommonScreens.xml

Modified: ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml?rev=791883&r1=791882&r2=791883&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml (original)
+++ ofbiz/trunk/applications/accounting/config/AccountingUiLabels.xml Tue Jul  7 15:57:44 2009
@@ -5997,9 +5997,6 @@
         <value xml:lang="th">ข้อมูลการชำระเงิน</value>
         <value xml:lang="zh">支付信息</value>
     </property>
-    <property key="AccountingPaymentIsAlreadyBatched">
-        <value xml:lang="en">PaymentId ${paymentId} Is Already Batched</value>
-    </property>
     <property key="AccountingPaymentLessRequested">
         <value xml:lang="en">Payment [${paymentId}] has  ${paymentApplyAvailable?currency(${isoCode})} to apply but ${amountApplied?currency(${isoCode})} is requested</value>
         <value xml:lang="es">Pago [${paymentId}] tiene ${paymentApplyAvailable?currency(${isoCode})} para aplicar pero ${amountApplied?currency(${isoCode})} es requerido</value>
@@ -6772,6 +6769,9 @@
         <value xml:lang="th">หมายเลข Routing</value>
         <value xml:lang="zh">路由号码</value>
     </property>
+    <property key="AccountingRunningTotal">
+        <value xml:lang="en">Running Total</value>
+    </property>
     <property key="AccountingSalesInvoiceToRevenue">
         <value xml:lang="en">Sales Invoice type to Revenue GL Account Number assignment list</value>
         <value xml:lang="es">Lista de asignación tipo de factura de venta a número de cuenta de LM</value>

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml?rev=791883&r1=791882&r2=791883&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml Tue Jul  7 15:57:44 2009
@@ -430,29 +430,33 @@
 
     <simple-method method-name="createPaymentBatch" short-description="create a batch of payments">
         <now-timestamp field="nowTimestamp"/>
-        <set field="paymentId" from-field="parameters.paymentId"/>
-        <entity-and entity-name="PaymentGroupMember" list="paymentGroupMembers">
-            <field-map field-name="paymentId"/>
-        </entity-and>
-        <if-not-empty field="paymentGroupMembers">
-            <add-error><fail-property resource="AccountingUiLabels" property="AccountingPaymentIsAlreadyBatched"/></add-error>
-            <check-errors/>
-        </if-not-empty>
-        <set field="paymentGroupId" from-field="parameters.paymentGroupId"/>
-        <set field="paymentGroupName" from-field="parameters.paymentGroupName"/>
-        <if-empty field="paymentGroupId">
-            <if-not-empty field="paymentGroupName">
-                <set field="createPaymentGroupCtx.paymentGroupName" from-field="paymentGroupName"/>
-                <set field="createPaymentGroupCtx.paymentGroupTypeId" value="BATCH_PAYMENT"/>
-                <call-service service-name="createPaymentGroup" in-map-name="createPaymentGroupCtx">
-                    <result-to-field result-name="paymentGroupId"/>
-                </call-service>
-            </if-not-empty>
-        </if-empty>
-        <set field="createPaymentGroupMemberCtx.paymentId" from-field="paymentId"/>
-        <set field="createPaymentGroupMemberCtx.paymentGroupId" from-field="paymentGroupId"/>
-        <set field="createPaymentGroupMemberCtx.fromDate" from-field="nowTimestamp"/>
-        <call-service service-name="createPaymentGroupMember" in-map-name="createPaymentGroupMemberCtx"/>
+        <set field="createPaymentGroupCtx.paymentGroupName" from-field="parameters.paymentGroupName"/>
+        <set field="createPaymentGroupCtx.paymentGroupTypeId" value="BATCH_PAYMENT"/>
+        <call-service service-name="createPaymentGroup" in-map-name="createPaymentGroupCtx">
+            <result-to-field result-name="paymentGroupId"/>
+        </call-service>
+        <set field="paymentIds" from-field="parameters.paymentIds"/>
+        <iterate list="paymentIds" entry="paymentId">
+            <set field="createPaymentGroupMemberCtx.paymentId" from-field="paymentId"/>
+            <set field="createPaymentGroupMemberCtx.paymentGroupId" from-field="paymentGroupId"/>
+            <set field="createPaymentGroupMemberCtx.fromDate" from-field="nowTimestamp"/>
+            <call-service service-name="createPaymentGroupMember" in-map-name="createPaymentGroupMemberCtx"/>
+        </iterate>
         <field-to-result field="paymentGroupId"/>
     </simple-method>
+    <simple-method method-name="getPaymentRunningTotal" short-description="calculate running total for payments">
+        <set field="paymentIds" from-field="parameters.paymentIds"/>
+        <set field="paymentRunningTotal" type="BigDecimal" value="0"/>
+        <iterate list="paymentIds" entry="paymentId">
+            <entity-one entity-name="Payment" value-field="payment">
+                <field-map field-name="paymentId" from-field="paymentId"/>
+            </entity-one>
+            <calculate field="paymentRunningTotal">
+                <calcop operator="add" field="paymentRunningTotal">
+                    <calcop operator="get" field="payment.amount"/>
+                </calcop>
+            </calculate>
+        </iterate>
+        <field-to-result field="paymentRunningTotal"/>
+    </simple-method>
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_payment.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_payment.xml?rev=791883&r1=791882&r2=791883&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_payment.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_payment.xml Tue Jul  7 15:57:44 2009
@@ -150,9 +150,15 @@
     </service>
     <service name="createPaymentBatch" engine="simple"
             location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="createPaymentBatch" auth="true">
-        <description>Create a batch for payment</description>
-        <attribute name="paymentId" type="String" mode="IN" optional="false"/>
+        <description>create batch for payments</description>
+        <attribute name="paymentIds" type="List" mode="IN" optional="false"/>
         <attribute name="paymentGroupName" type="String" mode="IN" optional="false"/>
-        <attribute name="paymentGroupId" type="String" mode="INOUT" optional="true"/>
+        <attribute name="paymentGroupId" type="String" mode="OUT" optional="false"/>
+    </service>
+    <service name="getPaymentRunningTotal" engine="simple"
+            location="component://accounting/script/org/ofbiz/accounting/payment/PaymentServices.xml" invoke="getPaymentRunningTotal" auth="true">
+        <description>calculate running total for payments</description>
+        <attribute name="paymentIds" type="List" mode="IN" optional="false"/>
+        <attribute name="paymentRunningTotal" type="BigDecimal" mode="OUT" optional="false"/>
     </service>
 </services>

Modified: ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/controller.xml?rev=791883&r1=791882&r2=791883&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/ar/WEB-INF/controller.xml Tue Jul  7 15:57:44 2009
@@ -47,10 +47,15 @@
     </request-map>
     <request-map uri="createPaymentBatch">
         <security https="true" auth="true"/>
-        <event type="service-multi" invoke="createPaymentBatch"/>
-        <response name="success" type="view" value="BatchPayments"/>
+        <event type="service" invoke="createPaymentBatch"/>
+        <response name="success" type="view" value="EditPaymentGroup"/>
         <response name="error" type="view" value="BatchPayments"/>
     </request-map>
+    <request-map uri="getPaymentRunningTotal">
+        <event type="jsonservice" invoke="getPaymentRunningTotal"/>
+        <response name="success" type="none"/>
+        <response name="error" type="none"/>
+    </request-map>
     <!-- end of request mappings -->
 
     <!-- View Mappings -->

Modified: ofbiz/trunk/applications/accounting/webapp/ar/payment/batchPayments.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/ar/payment/batchPayments.ftl?rev=791883&r1=791882&r2=791883&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/ar/payment/batchPayments.ftl (original)
+++ ofbiz/trunk/applications/accounting/webapp/ar/payment/batchPayments.ftl Tue Jul  7 15:57:44 2009
@@ -16,16 +16,49 @@
 specific language governing permissions and limitations
 under the License.
 -->
+
+<script language="JavaScript" type="text/javascript">
+<!-- //
+
+function togglePaymentId(master) {
+    var form = document.paymentBatchForm;
+    var payments = form.elements.length;
+    for (var i = 0; i < payments; i++) {
+        var element = form.elements[i];
+        if (element.name == "paymentIds") {
+            element.checked = master.checked;
+        }
+    }
+    getPaymentRunningTotal(master);
+}
+function getPaymentRunningTotal(e) {
+    if (!($(e).checked)) {
+        $('checkAllPayments').checked = false;
+    }
+    new Ajax.Request('getPaymentRunningTotal', {
+        asynchronous: false,
+        onSuccess: function(transport) {
+            var data = transport.responseText.evalJSON(true);
+            $('showPaymentRunningTotal').update(data.paymentRunningTotal);
+        }, parameters: $('paymentBatchForm').serialize(), requestHeaders: {Accept: 'application/json'}
+    });
+}
+// -->
+
+</script>
 <div class="screenlet">
     <div class="screenlet-body">
-        <form method="post" action="<@ofbizUrl>createPaymentBatch</@ofbizUrl>" name='paymentBatchForm'>
-            <input type="hidden" name="_useRowSubmit" value="Y">
+        <form id="paymentBatchForm" name="paymentBatchForm" method="post" action="<@ofbizUrl>createPaymentBatch</@ofbizUrl>">
             <#if paymentList?has_content>
                 <div>
                     <span class="label">${uiLabelMap.AccountingPayment} ${uiLabelMap.PartyPartyGroupName}</span>
                     <input type="text" size='25' name='paymentGroupName'>
                     <input type="hidden" name='organizationPartyId' value="${organizationPartyId?if_exists}">
                 </div>
+                <div>
+                    <span class="label">${uiLabelMap.AccountingRunningTotal} :</span>
+                    <span class="label" id="showPaymentRunningTotal"></span>
+                </div>
                 <table class="basic-table">
                     <tr class="header-row">
                         <td>${uiLabelMap.FormFieldTitle_paymentId}</td>
@@ -34,11 +67,10 @@
                         <td>${uiLabelMap.CommonDate}</td>
                         <td align="right">
                             ${uiLabelMap.ProductSelectAll}&nbsp;
-                            <input id="selectAll" type="checkbox" name="selectAll" value="Y" onclick="javascript:toggleAll(this, 'paymentBatchForm');"/>
+                            <input type="checkbox" id="checkAllPayments" name="checkAllPayments" onchange="javascript:togglePaymentId(this);"/>
                         </td>
                     </tr>
                     <#list paymentList as payment>
-                        <input type="hidden" name="paymentId_o_${payment_index}" value="${payment.paymentId}"/>
                         <tr>
                             <td><a href="<@ofbizUrl>paymentOverview?paymentId=${payment.paymentId}</@ofbizUrl>">${payment.paymentId}</a></td>
                             <td>
@@ -52,7 +84,7 @@
                             <td><@ofbizCurrency amount=payment.amount isoCode=payment.currencyUomId/></td>
                             <td>${payment.effectiveDate?if_exists}</td>
                             <td align="right">
-                                <input type="checkbox" name="_rowSubmit_o_${payment_index}" value="Y" onclick="javascript:checkToggle(this, 'paymentBatchForm');">
+                                <input type="checkbox" id="paymentId_${payment_index}" name="paymentIds" value="${payment.paymentId}" onclick="javascript:getPaymentRunningTotal('paymentId_${payment_index}');"/>
                             </td>
                         </tr>
                     </#list>

Modified: ofbiz/trunk/applications/accounting/widget/ar/ArMenus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ar/ArMenus.xml?rev=791883&r1=791882&r2=791883&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ar/ArMenus.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ar/ArMenus.xml Tue Jul  7 15:57:44 2009
@@ -23,6 +23,7 @@
         <menu-item name="agreements" title="${uiLabelMap.AccountingAgreements}"><link target="FindAgreement"/></menu-item>
         <menu-item name="invoices" title="${uiLabelMap.AccountingInvoicesMenu}"><link target="findInvoices"/></menu-item>
         <menu-item name="payments" title="${uiLabelMap.AccountingPaymentsMenu}"><link target="findPayments"/></menu-item>
+        <menu-item name="PaymentGroup" title="${uiLabelMap.AccountingPaymentGroup}"><link target="FindPaymentGroup"/></menu-item>
         <menu-item name="reports" title="${uiLabelMap.AccountingReports}"><link target="ListReports"/></menu-item>
     </menu>
     <menu name="ArPaymentTabBar" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml">

Modified: ofbiz/trunk/applications/accounting/widget/ar/CommonScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ar/CommonScreens.xml?rev=791883&r1=791882&r2=791883&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ar/CommonScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ar/CommonScreens.xml Tue Jul  7 15:57:44 2009
@@ -117,4 +117,45 @@
             </widgets>
         </section>
     </screen>
+    <screen name="CommonPaymentGroupDecorator">
+        <section>
+            <actions>
+                <set field="headerItem" value="PaymentGroup"/>
+                <set field="paymentGroupId" from-field="parameters.paymentGroupId"/>
+                <entity-one entity-name="PaymentGroup" value-field="paymentGroup"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="main-decorator">
+                    <decorator-section name="pre-body">
+                        <section>
+                            <widgets>
+                                <include-menu name="PaymentGroupTabBar" location="component://accounting/widget/Menus.xml"/>
+                            </widgets>
+                        </section>
+                    </decorator-section>
+                    <decorator-section name="body">
+                        <section>
+                            <widgets>
+                                <section>
+                                    <condition>
+                                        <not><if-empty field="paymentGroup"/></not>
+                                    </condition>
+                                    <widgets>
+                                        <container style="h1"><label>${uiLabelMap[titleProperty]} ${uiLabelMap.CommonFor} ${paymenGroup.paymentGroupName} [${paymentGroupId}]</label></container>
+                                        <container style="button-bar">
+                                            <link target="EditPaymentGroup" text="${uiLabelMap.AccountingCreateNewPaymentGroup}" style="buttontext"/>
+                                        </container>
+                                    </widgets>
+                                    <fail-widgets>
+                                        <container style="h1"><label>${uiLabelMap.AccountingNewPaymentGroup}</label></container>
+                                    </fail-widgets>
+                                </section>
+                                <decorator-section-include name="body"/>
+                            </widgets>
+                        </section>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
 </screens>
\ No newline at end of file