You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ap...@apache.org on 2007/12/04 00:39:17 UTC

svn commit: r600730 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas.xml servicedef/services_ledger.xml

Author: apatel
Date: Mon Dec  3 15:39:14 2007
New Revision: 600730

URL: http://svn.apache.org/viewvc?rev=600730&view=rev
Log:
Implement an automatic GL posting service triggered when InventoryItem.unitCost is changed.

Jyotsna Rathore, Thanks for providing implementation. And also our thanks to Vikas Mayur, Ashish Vijaywargiya, Mridul Pathak, Pankaj Savita and others for managing and helping the team implementing these services.

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
    ofbiz/trunk/applications/accounting/servicedef/secas.xml
    ofbiz/trunk/applications/accounting/servicedef/services_ledger.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=600730&r1=600729&r2=600730&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 Mon Dec  3 15:39:14 2007
@@ -598,5 +598,59 @@
         </call-service>
         <field-to-result field-name="acctgTransId" result-name="acctgTransId"/>        
     </simple-method>
+    
+    <simple-method method-name="createAcctgTransForInventoryItemCostChange" short-description="Create accounting transaction when item cost is changed (D: INV_ADJ_VAL, C: INVENTORY_ACCOUNT)">
+        <!-- retrieve ledger rounding properties -->        
+        <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/>
+        <property-to-field resource="arithmetic" property="ledger.rounding" field-name="roundingMode"/>
+        <entity-one entity-name="InventoryItemDetail" value-name="newInventoryItemDetail"/>
+        <entity-condition entity-name="InventoryItemDetail" list-name="inventoryItemDetails">
+            <condition-list>
+                <condition-expr field-name="unitCost" operator="not-equals" value="0.00"/>
+                <condition-expr field-name="inventoryItemDetailSeqId" operator="not-equals" env-name="parameters.inventoryItemDetailSeqId"/>
+            </condition-list>
+            <order-by field-name="-effectiveDate"/>
+        </entity-condition>
+        <first-from-list list-name="inventoryItemDetails" entry-name="oldInventoryItemDetail"/>
+        <if-not-empty field-name="oldInventoryItemDetail">
+            <calculate field-name="origAmount" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
+                <calcop operator="multiply" field-name="newinventoryItem.quantityOnHandTotal">
+                    <calcop operator="subtract">
+                        <calcop operator="get" field-name="oldInventoryItemDetail.unitCost"/>
+                        <calcop operator="get" field-name="newInventoryItemDetail.unitCost"/>
+                    </calcop>
+                </calcop>
+            </calculate>
+        </if-not-empty>
+        <get-related-one value-name="newInventoryItemDetail" relation-name="InventoryItem" to-value-name="inventoryItem"/>
+        <!-- Credit -->
+        <make-value entity-name="AcctgTransEntry" value-name="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-name="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.shipmentId" 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-name="acctgTransId" result-name="acctgTransId"/>
+    </simple-method>
 
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/secas.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas.xml?rev=600730&r1=600729&r2=600730&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/secas.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/secas.xml Mon Dec  3 15:39:14 2007
@@ -157,4 +157,11 @@
         <condition field-name="productTypeId" operator="equals" value="ASSET_USAGE"/>
         <action service="createFixedAssetAndLinkToProduct" mode="sync"/>
     </eca>
+    
+    <!--creating inventory item detail when unitCost is not empty and recieptId is  empty-->
+    <eca service="createInventoryItemDetail" event="commit">
+        <condition field-name="unitCost" operator="is-not-empty"/>        
+        <condition field-name="receiptId" operator="is-empty"/>
+        <action service="createAcctgTransForInventoryItemCostChange" 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=600730&r1=600729&r2=600730&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Mon Dec  3 15:39:14 2007
@@ -306,6 +306,13 @@
         <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/>
         <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
     </service>
+    <service name="createAcctgTransForInventoryItemCostChange" engine="simple" auth="true"
+        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForInventoryItemCostChange">
+        <description>Create accounting transaction when item cost is changed (D: INV_ADJ_VAL, C: INVENTORY_ACCOUNT)</description>
+        <attribute name="inventoryItemId" type="String" mode="IN" optional="false"/>
+        <attribute name="inventoryItemDetailSeqId" type="String" mode="IN" optional="false"/>
+        <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
+    </service>
     <!-- DEPRECATED: use createAcctgTransForSalesShipmentIssuance instead -->
     <service name="createAcctgTransForSalesShipment" engine="simple"  auth="true"
         location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForSalesShipment">