Author: jleroux
Date: Sun Apr 17 10:15:23 2011
New Revision: 1094126

URL: http://svn.apache.org/viewvc?rev=1094126&view=rev
Log:
A patch from Pierre Gaudin "Error in stock reception on same inventory item 
with same unit price" https://issues.apache.org/jira/browse/OFBIZ-4250

During the reception of stock, if the reception is made on a line of stock 
which already exists with the same unit price, an accounting transaction due to 
the stock price value change is created with an amount of debit and credit of 0.

This is not normal and generate an error in the service postAcctgTrans.

This aim of this patch is to avoid creation of accounting transaction linked to 
the stock price value change if the unit price does not change.

Modified:
    
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml

Modified: 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=1094126&r1=1094125&r2=1094126&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
 (original)
+++ 
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
 Sun Apr 17 10:15:23 2011
@@ -1436,35 +1436,38 @@ under the License.
                     </calcop>
                 </calcop>
             </calculate>
-            <get-related-one value-field="newInventoryItemDetail" 
relation-name="InventoryItem" to-value-field="inventoryItem"/>
-            <!-- Credit -->
-            <make-value entity-name="AcctgTransEntry" 
value-field="creditEntry"/>
-            <set field="creditEntry.debitCreditFlag" value="C"/>
-            <set field="creditEntry.glAccountTypeId" 
value="INVENTORY_ACCOUNT"/>
-            <set field="creditEntry.organizationPartyId" 
from-field="inventoryItem.ownerPartyId"/>
-            <set field="creditEntry.productId" 
from-field="inventoryItem.productId"/>
-            <set field="creditEntry.origAmount" from-field="origAmount"/>
-            <set field="creditEntry.origCurrencyUomId" 
from-field="inventoryItem.currencyUomId"/>
-            <!-- Debit -->
-            <make-value entity-name="AcctgTransEntry" 
value-field="debitEntry"/>
-            <set field="debitEntry.debitCreditFlag" value="D"/>
-            <set field="debitEntry.glAccountTypeId" value="INV_ADJ_VAL"/>
-            <set field="debitEntry.organizationPartyId" 
from-field="inventoryItem.ownerPartyId"/>
-            <set field="debitEntry.productId" 
from-field="inventoryItem.productId"/>
-            <set field="debitEntry.origAmount" from-field="origAmount"/>
-            <set field="debitEntry.origCurrencyUomId" 
from-field="inventoryItem.currencyUomId"/>
-
-            <set field="acctgTransEntries[]" from-field="creditEntry" 
type="Object"/>
-            <set field="acctgTransEntries[]" from-field="debitEntry" 
type="Object"/>
-
-            <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" 
value="ACTUAL"/>
-            <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" 
value="INVENTORY"/>
-            <set field="createAcctgTransAndEntriesInMap.inventoryItemId" 
from-field="parameters.inventoryItemId"/>
-            <set field="createAcctgTransAndEntriesInMap.acctgTransEntries" 
from-field="acctgTransEntries"/>
-            <call-service service-name="createAcctgTransAndEntries" 
in-map-name="createAcctgTransAndEntriesInMap">
-                <result-to-field result-name="acctgTransId"/>
-            </call-service>
-            <field-to-result field="acctgTransId" result-name="acctgTransId"/>
+            <!-- if originAmount is equals to 0 do not create transaction, 
this is causing error in postAcctgTrans -->
+            <if-compare operator="not-equals" field="origAmount" value="0">
+                <get-related-one value-field="newInventoryItemDetail" 
relation-name="InventoryItem" to-value-field="inventoryItem"/>
+                <!-- Credit -->
+                <make-value entity-name="AcctgTransEntry" 
value-field="creditEntry"/>
+                <set field="creditEntry.debitCreditFlag" value="C"/>
+                <set field="creditEntry.glAccountTypeId" 
value="INVENTORY_ACCOUNT"/>
+                <set field="creditEntry.organizationPartyId" 
from-field="inventoryItem.ownerPartyId"/>
+                <set field="creditEntry.productId" 
from-field="inventoryItem.productId"/>
+                <set field="creditEntry.origAmount" from-field="origAmount"/>
+                <set field="creditEntry.origCurrencyUomId" 
from-field="inventoryItem.currencyUomId"/>
+                <!-- Debit -->
+                <make-value entity-name="AcctgTransEntry" 
value-field="debitEntry"/>
+                <set field="debitEntry.debitCreditFlag" value="D"/>
+                <set field="debitEntry.glAccountTypeId" value="INV_ADJ_VAL"/>
+                <set field="debitEntry.organizationPartyId" 
from-field="inventoryItem.ownerPartyId"/>
+                <set field="debitEntry.productId" 
from-field="inventoryItem.productId"/>
+                <set field="debitEntry.origAmount" from-field="origAmount"/>
+                <set field="debitEntry.origCurrencyUomId" 
from-field="inventoryItem.currencyUomId"/>
+    
+                <set field="acctgTransEntries[]" from-field="creditEntry" 
type="Object"/>
+                <set field="acctgTransEntries[]" from-field="debitEntry" 
type="Object"/>
+    
+                <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" 
value="ACTUAL"/>
+                <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" 
value="INVENTORY"/>
+                <set field="createAcctgTransAndEntriesInMap.inventoryItemId" 
from-field="parameters.inventoryItemId"/>
+                <set field="createAcctgTransAndEntriesInMap.acctgTransEntries" 
from-field="acctgTransEntries"/>
+                <call-service service-name="createAcctgTransAndEntries" 
in-map-name="createAcctgTransAndEntriesInMap">
+                    <result-to-field result-name="acctgTransId"/>
+                </call-service>
+                <field-to-result field="acctgTransId" 
result-name="acctgTransId"/>
+            </if-compare>
         </if-not-empty>
     </simple-method>
 


Reply via email to