Author: apatel
Date: Mon Jul 27 15:42:54 2009 New Revision: 798193 URL: http://svn.apache.org/viewvc?rev=798193&view=rev Log: Cleaning up code for posting accounting gl transaction when invoices is voided. Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/invoice/InvoiceServices.xml ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml 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=798193&r1=798192&r2=798193&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 Mon Jul 27 15:42:54 2009 @@ -600,35 +600,9 @@ <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> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml?rev=798193&r1=798192&r2=798193&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml Mon Jul 27 15:42:54 2009 @@ -520,4 +520,36 @@ <field-to-result field="openingBalanceCredit"/> <field-to-result field="debitCreditDifference"/> </simple-method> + + <simple-method method-name="revertAcctgTransOnRemovePaymentApplications" short-description="Create Reverse Accounting Transaction and Entries on removing PaymentApplication records."> + <entity-one entity-name="PaymentApplication" value-field="paymentApplication"/> + <entity-condition entity-name="AcctgTrans" list="acctgTransPaymentList"> + <condition-list combine="and"> + <condition-expr field-name="invoiceId" from-field="paymentApplication.invoiceId"/> + <condition-expr field-name="paymentId" from-field="paymentApplication.paymentId"/> + </condition-list> + </entity-condition> + <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"/> + <clear-field field="copyAcctgTransCtx"/> + </iterate> + </simple-method> + + <simple-method method-name="revertAcctgTransOnCancelInvoice" short-description="Reverting Accounting Transaction And Entries on Canceling an Invoice"> + <entity-condition entity-name="AcctgTrans" list="acctgTransInvoiceList"> + <condition-list combine="and"> + <condition-expr field-name="paymentId" operator="equals" from-field="nullField"/> + <condition-expr field-name="invoiceId" operator="equals" from-field="parameters.invoiceId"/> + </condition-list> + </entity-condition> + <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"/> + <clear-field field="copyAcctgTransCtx"/> + </iterate> + </simple-method> + </simple-methods> \ No newline at end of file Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=798193&r1=798192&r2=798193&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Mon Jul 27 15:42:54 2009 @@ -131,5 +131,8 @@ <condition field-name="statusId" operator="equals" value="INVOICE_CANCELLED"/> <action service="cancelInvoice" mode="sync"/> </eca> - + <!-- On canceling invoice reverse its Accounting Transactions --> + <eca service="cancelInvoice" event="invoke"> + <action service="revertAcctgTransOnCancelInvoice" mode="sync"/> + </eca> </service-eca> \ No newline at end of file Modified: ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml?rev=798193&r1=798192&r2=798193&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/secas_payment.xml Mon Jul 27 15:42:54 2009 @@ -53,4 +53,9 @@ <condition field-name="statusId" operator="equals" value="FINACT_TRNS_CANCELED"/> <action service="updatePaymentOnFinAccTransStatusSetToCancel" mode="sync"/> </eca> + + <!-- Create Reverse Accouting Transaction and Entries on removing PaymentApplication --> + <eca service="removePaymentApplication" event="invoke"> + <action service="revertAcctgTransOnRemovePaymentApplications" mode="sync"/> + </eca> </service-eca> Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=798193&r1=798192&r2=798193&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Mon Jul 27 15:42:54 2009 @@ -598,4 +598,16 @@ <attribute name="openingBalanceCredit" type="BigDecimal" mode="OUT"/> <attribute name="debitCreditDifference" type="BigDecimal" mode="OUT"/> </service> + + <service name="revertAcctgTransOnCancelInvoice" engine="simple" + location="component://accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml" invoke="revertAcctgTransOnCancelInvoice" auth="true"> + <description>Reverting Accounting Transaction And Entries on Canceling an Invoice</description> + <attribute name="invoiceId" mode="IN" type="String" optional="false"/> + </service> + <service name="revertAcctgTransOnRemovePaymentApplications" engine="simple" + location="component://accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml" invoke="revertAcctgTransOnRemovePaymentApplications" auth="true"> + <description>Create Reverse Accounting Transaction and Entries on removing PaymentApplication records.</description> + <attribute name="paymentApplicationId" mode="IN" type="String" optional="false"/> + </service> + </services> |
Free forum by Nabble | Edit this page |