svn commit: r790926 - in /ofbiz/trunk/applications/accounting: data/AccountingTypeData.xml script/org/ofbiz/accounting/invoice/InvoiceServices.xml servicedef/secas_ledger.xml servicedef/services_invoice.xml webapp/accounting/invoice/InvoiceSubTabBar.ftl

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

svn commit: r790926 - in /ofbiz/trunk/applications/accounting: data/AccountingTypeData.xml script/org/ofbiz/accounting/invoice/InvoiceServices.xml servicedef/secas_ledger.xml servicedef/services_invoice.xml webapp/accounting/invoice/InvoiceSubTabBar.ftl

ashish-18
Author: ashish
Date: Fri Jul  3 14:26:57 2009
New Revision: 790926

URL: http://svn.apache.org/viewvc?rev=790926&view=rev
Log:
Applied patch from jira issue OFBIZ-2695 (Imporve service on when set invoice status to cancel)
Thanks Surya & Sumit Pandit for  your contribution.

Modified:
    ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml
    ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml
    ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
    ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceSubTabBar.ftl

Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=790926&r1=790925&r2=790926&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Fri Jul  3 14:26:57 2009
@@ -845,7 +845,7 @@
     <StatusValidChange condition="" statusId="INVOICE_READY" statusIdTo="INVOICE_PAID" transitionName="Pay"/>
     <StatusValidChange condition="" statusId="INVOICE_READY" statusIdTo="INVOICE_WRITEOFF" transitionName="Write Off"/>
     <StatusValidChange condition="" statusId="INVOICE_PAID" statusIdTo="INVOICE_READY" transitionName="Unpay"/>
-
+    <StatusValidChange condition="" statusId="INVOICE_READY" statusIdTo="INVOICE_CANCELLED" transitionName="Cancel"/>
 
     <!-- payment status -->
     <StatusType description="Payment Status" hasTable="N" parentTypeId="" statusTypeId="PMNT_STATUS"/>
@@ -863,6 +863,8 @@
     <StatusValidChange condition="" statusId="PMNT_SENT" statusIdTo="PMNT_VOID" transitionName="Payment Voided"/>
     <StatusValidChange condition="" statusId="PMNT_RECEIVED" statusIdTo="PMNT_VOID" transitionName="Payment Voided"/>
     <StatusValidChange condition="" statusId="PMNT_NOT_PAID" statusIdTo="PMNT_VOID" transitionName="Payment Voided"/>
+    <StatusValidChange condition="" statusId="PMNT_SENT" statusIdTo="PMNT_NOT_PAID" transitionName="Payment Not Paid"/>
+    <StatusValidChange condition="" statusId="PMNT_RECEIVED" statusIdTo="PMNT_NOT_PAID" transitionName="Payment Not Paid"/>
 
     <SettlementTerm settlementTermId="COD" termName="Cash Due on Delivery" termValue="0" uomId="TF_day"/>
     <SettlementTerm settlementTermId="NET_15" termName="Net Due in 15 Days" termValue="15" uomId="TF_day"/>

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=790926&r1=790925&r2=790926&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 Fri Jul  3 14:26:57 2009
@@ -503,20 +503,6 @@
                         <call-service service-name="createPaymentApplication" in-map-name="payAppl"/>
                     </if-compare>
                 </if-compare>
-
-                <!-- 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>
@@ -598,4 +584,45 @@
            <call-service service-name="updateInvoice" in-map-name="updateInvoiceCtx"/>
        </iterate>
    </simple-method>
+    
+    <simple-method method-name="cancelInvoice" short-description="Service to cancel the Invoices">
+        <entity-one entity-name="Invoice" value-field="invoice"/>
+        <if-empty field="invoice">
+            <add-error><fail-message message="${uiLabelMap.AccountingInvoiceNotFound}"/></add-error>
+            <check-errors/>
+        </if-empty>
+        <get-related relation-name="AcctgTrans" list="acctgTransInvoiceList" value-field="invoice"/>
+        <iterate list="acctgTransInvoiceList" entry="acctgTransInvoice">
+            <set field="copyAcctgTransCtx.fromAcctgTransId" from-field="acctgTransInvoice.acctgTransId"/>
+            <set field="copyAcctgTransCtx.revert" value="Y"/>
+            <call-service service-name="copyAcctgTransAndEntries" in-map-name="copyAcctgTransCtx"/>
+        </iterate>            
+        <get-related relation-name="PaymentApplication" value-field="invoice" list="paymentApplications"/>
+        <iterate list="paymentApplications" entry="paymentApplication">
+            <get-related-one relation-name="Payment" value-field="paymentApplication" to-value-field="payment"/>
+            <if>
+                <condition>
+                    <or>
+                        <if-compare field="updatePaymentCtx.statusId" operator="equals" value="PMNT_SENT"/>
+                        <if-compare field="updatePaymentCtx.statusId" operator="equals" value="PMNT_RECEIVED"/>
+                    </or>
+                </condition>
+                <then>
+                    <set field="paymentStatusCtx.paymentId" from-field="payment.paymentId"/>
+                    <set field="paymentStatusCtx.statusId" value="PMNT_NOT_PAID"/>
+                    <call-service service-name="setPaymentStatus" in-map-name="paymentStatusCtx"/>
+                    <get-related relation-name="AcctgTrans" value-field="payment" list="acctgTransPaymentList"/>
+                    <clear-field field="copyAcctgTransCtx"/>
+                    <iterate list="acctgTransPaymentList" entry="acctgTransPayment">
+                        <set field="copyAcctgTransCtx.fromAcctgTransId" from-field="acctgTransPayment.acctgTransId"/>
+                        <set field="copyAcctgTransCtx.revert" value="Y"/>
+                        <call-service service-name="copyAcctgTransAndEntries" in-map-name="copyAcctgTransCtx"/>
+                    </iterate>
+                </then>
+            </if>
+            <set field="removePaymentApplicationCtx.paymentApplicationId" from-field="paymentApplication.paymentApplicationId"/>
+            <call-service service-name="removePaymentApplication" in-map-name="removePaymentApplicationCtx"/>
+        </iterate>
+    </simple-method>
+
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=790926&r1=790925&r2=790926&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Fri Jul  3 14:26:57 2009
@@ -125,5 +125,11 @@
         <condition field-name="oldStatusId" operator="not-equals" value="PMNT_SENT"/>
         <action service="createAcctgTransAndEntriesForOutgoingPayment" mode="sync"/>
     </eca>
+    
+    <eca service="setInvoiceStatus" event="commit">
+        <condition field-name="invoiceId" operator="is-not-empty"/>
+        <condition field-name="statusId" operator="equals" value="INVOICE_CANCELLED"/>
+        <action service="cancelInvoice" mode="sync"/>
+    </eca>
 
 </service-eca>
\ No newline at end of file

Modified: ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml?rev=790926&r1=790925&r2=790926&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_invoice.xml Fri Jul  3 14:26:57 2009
@@ -286,4 +286,10 @@
         <description>Scheduled service to generate Invoice from an existing Invoice</description>
         <attribute name="recurrenceInfoId" mode="IN" type="String" optional="false"/>
     </service>
+    
+    <service name="cancelInvoice" engine="simple"
+            location="component://accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml" invoke="cancelInvoice">
+        <description>Cancel Invoice</description>
+        <attribute name="invoiceId" type="String" mode="IN" optional="false"/>
+    </service>
 </services>

Modified: ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceSubTabBar.ftl
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceSubTabBar.ftl?rev=790926&r1=790925&r2=790926&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceSubTabBar.ftl (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/invoice/InvoiceSubTabBar.ftl Fri Jul  3 14:26:57 2009
@@ -93,7 +93,7 @@
           </form>
         </li>
       </#if>
-      <#if invoice.statusId == "INVOICE_SENT" || invoice.statusId == "INVOICE_RECEIVED" || invoice.statusId == "INVOICE_IN_PROCESS">
+      <#if invoice.statusId == "INVOICE_SENT" || invoice.statusId == "INVOICE_RECEIVED" || invoice.statusId == "INVOICE_IN_PROCESS" || invoice.statusId == "INVOICE_READY">
         <li>
           <a href="javascript:confirmActionFormLink('You want to cancel this invoice number ${invoice.invoiceId}?','InvoiceSubTabBar_statusToCancelled')" class="buttontext">${uiLabelMap.AccountingInvoiceStatusToCancelled}</a>
           <form method="post" action="<@ofbizUrl>setInvoiceStatus</@ofbizUrl>" onSubmit="javascript:submitFormDisableSubmits(this)" name="InvoiceSubTabBar_statusToCancelled">