You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2015/02/11 07:43:56 UTC
svn commit: r1658885 - in /ofbiz/branches/release14.12: ./
applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
Author: jacopoc
Date: Wed Feb 11 06:43:56 2015
New Revision: 1658885
URL: http://svn.apache.org/r1658885
Log:
Applied fix from trunk for revision: 1657514
===
A series of changes required to properly manage foreign exchange gain and losses when a payment is sent before the purchase invoice is received.
Modified:
ofbiz/branches/release14.12/ (props changed)
ofbiz/branches/release14.12/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
Propchange: ofbiz/branches/release14.12/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 11 06:43:56 2015
@@ -8,4 +8,4 @@
/ofbiz/branches/json-integration-refactoring:1634077-1635900
/ofbiz/branches/multitenant20100310:921280-927264
/ofbiz/branches/release13.07:1547657
-/ofbiz/trunk:1649393,1649742,1650240,1650583,1650642,1650678,1650882,1650887,1650938,1651593,1652361,1652706,1652725,1652731,1652739,1653248,1653456,1654175,1654273,1654509,1655046,1655668,1655979,1656185,1656198,1656445,1656983,1657323,1657506-1657507,1657714,1657790,1658364,1658662
+/ofbiz/trunk:1649393,1649742,1650240,1650583,1650642,1650678,1650882,1650887,1650938,1651593,1652361,1652706,1652725,1652731,1652739,1653248,1653456,1654175,1654273,1654509,1655046,1655668,1655979,1656185,1656198,1656445,1656983,1657323,1657506-1657507,1657514,1657714,1657790,1658364,1658662
Modified: ofbiz/branches/release14.12/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/branches/release14.12/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=1658885&r1=1658884&r2=1658885&view=diff
==============================================================================
--- ofbiz/branches/release14.12/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml (original)
+++ ofbiz/branches/release14.12/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml Wed Feb 11 06:43:56 2015
@@ -2180,6 +2180,40 @@ under the License.
<result-to-field result-name="acctgTransId"/>
</call-service>
<field-to-result field="acctgTransId" result-name="acctgTransId"/>
+
+ <!-- Now create accounting transactions for the payment applications -->
+ <entity-and entity-name="PaymentApplication" list="paymentApplications">
+ <field-map field-name="invoiceId" from-field="invoice.invoiceId"/>
+ </entity-and>
+ <log level="warning" message="APPLICAZIONI"/>
+ <iterate list="paymentApplications" entry="paymentApplication">
+ <log level="warning" message="applicazione ${paymentApplication}"/>
+ <get-related-one value-field="paymentApplication" relation-name="Payment" to-value-field="payment"/>
+ <log level="warning" message="payment ${payment}"/>
+ <if>
+ <condition>
+ <or>
+ <if-compare field="payment.statusId" operator="equals" value="PMNT_SENT"/>
+ <if-compare field="payment.statusId" operator="equals" value="PMNT_CONFIRMED"/>
+ </or>
+ </condition>
+ <then>
+ <log level="warning" message="processing payment ${payment.paymentId}"/>
+ <set field="createAcctgTransAndEntriesForPaymentApplicationInMap.paymentApplicationId" from-field="paymentApplication.paymentApplicationId"/>
+ <if-compare field="payment.paymentTypeId" operator="equals" value="CUSTOMER_REFUND">
+ <call-service service-name="createAcctgTransAndEntriesForCustomerRefundPaymentApplication" in-map-name="createAcctgTransAndEntriesForPaymentApplicationInMap">
+ <result-to-field result-name="acctgTransId"/>
+ </call-service>
+ <else>
+ <call-service service-name="createAcctgTransAndEntriesForPaymentApplication" in-map-name="createAcctgTransAndEntriesForPaymentApplicationInMap">
+ <result-to-field result-name="acctgTransId"/>
+ </call-service>
+ </else>
+ </if-compare>
+ <log level="info" message="Accounting transaction ${acctgTransId} created for payment application ${paymentApplication.paymentApplicationId}"/>
+ </then>
+ </if>
+ </iterate>
</if-compare>
</simple-method>
@@ -2411,18 +2445,29 @@ under the License.
<field-map field-name="paymentId" from-field="payment.paymentId"/>
</entity-and>
<iterate list="paymentApplications" entry="paymentApplication">
- <set field="createAcctgTransAndEntriesForPaymentApplicationInMap.paymentApplicationId" from-field="paymentApplication.paymentApplicationId"/>
- <if-compare field="payment.paymentTypeId" operator="equals" value="CUSTOMER_REFUND">
- <call-service service-name="createAcctgTransAndEntriesForCustomerRefundPaymentApplication" in-map-name="createAcctgTransAndEntriesForPaymentApplicationInMap">
- <result-to-field result-name="acctgTransId"/>
- </call-service>
- <else>
- <call-service service-name="createAcctgTransAndEntriesForPaymentApplication" in-map-name="createAcctgTransAndEntriesForPaymentApplicationInMap">
- <result-to-field result-name="acctgTransId"/>
- </call-service>
- </else>
- </if-compare>
- <log level="info" message="Accounting transaction ${acctgTransId} created for payment application ${paymentApplication.paymentApplicationId}"/>
+ <get-related-one value-field="paymentApplication" relation-name="Invoice" to-value-field="invoice"/>
+ <if>
+ <condition>
+ <or>
+ <condition field-name="invoice.statusId" operator="equals" value="INVOICE_READY"/>
+ <condition field-name="invoice.statusId" operator="equals" value="INVOICE_PAID"/>
+ </or>
+ </condition>
+ <then>
+ <set field="createAcctgTransAndEntriesForPaymentApplicationInMap.paymentApplicationId" from-field="paymentApplication.paymentApplicationId"/>
+ <if-compare field="payment.paymentTypeId" operator="equals" value="CUSTOMER_REFUND">
+ <call-service service-name="createAcctgTransAndEntriesForCustomerRefundPaymentApplication" in-map-name="createAcctgTransAndEntriesForPaymentApplicationInMap">
+ <result-to-field result-name="acctgTransId"/>
+ </call-service>
+ <else>
+ <call-service service-name="createAcctgTransAndEntriesForPaymentApplication" in-map-name="createAcctgTransAndEntriesForPaymentApplicationInMap">
+ <result-to-field result-name="acctgTransId"/>
+ </call-service>
+ </else>
+ </if-compare>
+ <log level="info" message="Accounting transaction ${acctgTransId} created for payment application ${paymentApplication.paymentApplicationId}"/>
+ </then>
+ </if>
</iterate>
</if-compare>
</simple-method>
@@ -2575,6 +2620,13 @@ under the License.
<if-compare field="paymentGlAccountTypeMap.glAccountTypeId" operator="equals" value="ACCOUNTS_PAYABLE">
<return/>
</if-compare>
+
+ <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getGlExchangeRateOfPurchaseInvoice" ret-field="invoiceExchangeRate">
+ <field field="paymentApplication" type="org.ofbiz.entity.GenericValue"/>
+ </call-class-method>
+ <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getGlExchangeRateOfOutgoingPayment" ret-field="paymentExchangeRate">
+ <field field="paymentApplication" type="org.ofbiz.entity.GenericValue"/>
+ </call-class-method>
<!--Credit -->
<make-value entity-name="AcctgTransEntry" value-field="creditEntry"/>
<set field="creditEntry.debitCreditFlag" value="C"/>
@@ -2583,15 +2635,10 @@ under the License.
<set field="creditEntry.roleTypeId" value="BILL_FROM_VENDOR"/>
<set field="creditEntry.origAmount" from-field="paymentApplication.amountApplied"/>
<set field="creditEntry.origCurrencyUomId" from-field="payment.currencyUomId"/>
+ <set field="creditEntry.amount" value="${paymentApplication.amountApplied * paymentExchangeRate}"/>
<set field="creditEntry.glAccountId" from-field="payment.overrideGlAccountId"/>
<set field="creditEntry.glAccountTypeId" from-field="paymentGlAccountTypeMap.glAccountTypeId"/>
<!-- Debit -->
- <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getGlExchangeRateOfPurchaseInvoice" ret-field="invoiceExchangeRate">
- <field field="paymentApplication" type="org.ofbiz.entity.GenericValue"/>
- </call-class-method>
- <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getGlExchangeRateOfOutgoingPayment" ret-field="paymentExchangeRate">
- <field field="paymentApplication" type="org.ofbiz.entity.GenericValue"/>
- </call-class-method>
<make-value entity-name="AcctgTransEntry" value-field="debitEntry"/>
<if-compare-field field="invoiceExchangeRate" operator="not-equals" to-field="paymentExchangeRate">
<set field="debitEntry.debitCreditFlag" value="D"/>
@@ -2599,14 +2646,6 @@ under the License.
<set field="debitEntry.partyId" from-field="payment.partyIdTo"/>
<set field="debitEntry.roleTypeId" value="BILL_FROM_VENDOR"/>
<set field="debitEntry.amount" value="${paymentApplication.amountApplied * (paymentExchangeRate - invoiceExchangeRate)}"/>
- <set field="debitEntry.origCurrencyUomId" from-field="payment.currencyUomId"/>
- <!--
- <entity-one entity-name="GlAccountTypeDefault" value-field="currencyExchangeRateGainLossAccount" use-cache="true">
- <field-map field-name="organizationPartyId" from-field="parameters.organizationPartyId"/>
- <field-map field-name="glAccountTypeId" value="FX_GAIN_LOSS_ACCT"/>
- </entity-one>
- <set field="debitEntry.glAccountId" from-field="currencyExchangeRateGainLossAccount.glAccountId"/>
- -->
<set field="debitEntry.glAccountTypeId" value="FX_GAIN_LOSS_ACCT"/>
<set field="acctgTransEntries[]" from-field="debitEntry" type="Object"/>
<clear-field field="debitEntry"/>