svn commit: r599351 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas_ledger.xml servicedef/services_ledger.xml widget/GlForms.xml

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

svn commit: r599351 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas_ledger.xml servicedef/services_ledger.xml widget/GlForms.xml

jacopoc
Author: jacopoc
Date: Thu Nov 29 01:14:12 2007
New Revision: 599351

URL: http://svn.apache.org/viewvc?rev=599351&view=rev
Log:
Refactored way auto posting is done for gl transactions of sales shipment: now an accounting transaction is created everytime inventory is issued.

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml
    ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml
    ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
    ofbiz/trunk/applications/accounting/widget/GlForms.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=599351&r1=599350&r2=599351&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 Thu Nov 29 01:14:12 2007
@@ -460,6 +460,66 @@
 
     <!-- Services for the automatic creation of accounting transactions based on business transactions
          Typically, these services are triggered by SECAs -->
+
+    <simple-method method-name="createAcctgTransForSalesShipmentIssuance" short-description="Create an accounting transactions for a sales shipment issuance (D: INVENTORY_ACCOUNT, C: COGS_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"/>
+        <log level="info" message="Using ledger decimals [${ledgerDecimals}] and rounding [${roundingMode}]"/>
+
+        <entity-one entity-name="ItemIssuance" value-name="itemIssuance"/>
+        <get-related-one value-name="itemIssuance" relation-name="InventoryItem" to-value-name="inventoryItem"/>
+        <entity-and entity-name="OrderRole" list-name="billToCustomers">
+            <field-map field-name="orderId" env-name="itemIssuance.orderId"/>
+            <field-map field-name="roleTypeId" value="BILL_TO_CUSTOMER"/>
+        </entity-and>
+        <first-from-list list-name="billToCustomers" entry-name="billToCustomer"/>
+        <!-- TODO: handle serialized inventory -->
+        <calculate field-name="origAmount" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
+            <calcop operator="multiply">
+                <calcop operator="get" field-name="itemIssuance.quantity"/>
+                <calcop operator="get" field-name="inventoryItem.unitCost"/>
+            </calcop>
+        </calculate>
+        <!-- prepare the doble posting (D/C) entries (AcctgTransEntry) -->
+        <!-- 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"/>
+        <if-not-empty field-name="billToCustomer">
+            <set field="creditEntry.partyId" from-field="billToCustomer.partyId"/>
+            <set field="creditEntry.roleTypeId" from-field="billToCustomer.roleTypeId"/>
+        </if-not-empty>
+        <set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/>
+        <!-- Debit -->
+        <make-value entity-name="AcctgTransEntry" value-name="debitEntry"/>
+        <set field="debitEntry.debitCreditFlag" value="D"/>
+        <set field="debitEntry.glAccountTypeId" value="COGS_ACCOUNT"/>
+        <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"/>
+        <if-not-empty field-name="billToCustomer">
+            <set field="debitEntry.partyId" from-field="billToCustomer.partyId"/>
+            <set field="debitEntry.roleTypeId" from-field="billToCustomer.roleTypeId"/>
+        </if-not-empty>
+        <set field="acctgTransEntries[]" from-field="debitEntry" type="Object"/>
+        <!-- Set header fields (AcctgTrans) -->
+        <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" value="ACTUAL"/>
+        <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" value="SALES_SHIPMENT"/>
+        <set field="createAcctgTransAndEntriesInMap.shipmentId" from-field="itemIssuance.shipmentId"/>
+        <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>
+
+    <!-- DEPRECATED: use createAcctgTransForSalesShipmentIssuance instead -->
     <simple-method method-name="createAcctgTransForSalesShipment" short-description="Create accounting transactions for issuances for a sales shipment (D: INVENTORY_ACCOUNT, C: COGS_ACCOUNT)">
         <!-- retrieve ledger rounding properties -->
         <property-to-field resource="arithmetic" property="ledger.decimals" field-name="ledgerDecimals"/>

Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=599351&r1=599350&r2=599351&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Thu Nov 29 01:14:12 2007
@@ -21,14 +21,20 @@
 <service-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/service-eca.xsd">
 
-    <!-- create the accounting transactions for a sales shipment when the status changes to SHIPMENT_PACKED -->
+    <!-- create the accounting transactions for a sales shipment issuance every time the inventory is issued to the shipment -->
+    <eca service="createItemIssuance" event="commit">
+        <condition field-name="shipmentId" operator="is-not-empty"/>
+        <action service="createAcctgTransForSalesShipmentIssuance" mode="sync"/>
+    </eca>
+    <!--
     <eca service="updateShipment" event="commit">
         <condition field-name="shipmentTypeId" operator="equals" value="SALES_SHIPMENT"/>
         <condition-field field-name="statusId" operator="not-equals" to-field-name="oldStatusId"/>
         <condition field-name="statusId" operator="equals" value="SHIPMENT_PACKED"/>
-        <action service="createAcctgTransForSalesShipment" mode="sync"/>        
+        <action service="createAcctgTransForSalesShipment" mode="sync"/>
     </eca>
-    <!-- this eca automatically post the accounting transactions to GL -->
+    -->
+    <!-- this eca automatically posts the accounting transactions to GL -->
     <eca service="createAcctgTransAndEntries" event="commit">
         <condition field-name="acctgTransId" operator="is-not-empty"/>
         <action service="postAcctgTrans" mode="sync"/>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=599351&r1=599350&r2=599351&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Thu Nov 29 01:14:12 2007
@@ -305,6 +305,12 @@
         <attribute name="shipmentId" type="String" mode="IN" optional="false"/>
         <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
     </service>
+    <service name="createAcctgTransForSalesShipmentIssuance" engine="simple"  auth="true"
+        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForSalesShipmentIssuance">
+        <description>Create an accounting transaction for for a sales shipment issuance (D: INVENTORY_ACCOUNT, C: COGS_ACCOUNT)</description>
+        <attribute name="itemIssuanceId" type="String" mode="IN" optional="false"/>
+        <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
+    </service>
 
     <!-- FinAccountTypeGlAccount Services -->
     <service name="createFinAccountTypeGlAccount" default-entity-name="FinAccountTypeGlAccount" engine="simple"

Modified: ofbiz/trunk/applications/accounting/widget/GlForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlForms.xml?rev=599351&r1=599350&r2=599351&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/GlForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/GlForms.xml Thu Nov 29 01:14:12 2007
@@ -225,8 +225,8 @@
                     <condition-expr field-name="transactionDate" operator="greater-equals" env-name="parameters.fromDate" ignore-if-empty="true"/>
                     <condition-expr field-name="transactionDate" operator="less" env-name="parameters.thruDate" ignore-if-empty="true"/>
                 </condition-list>
-                <order-by field-name="-transactionDate"/>
                 <order-by field-name="glAccountId"/>
+                <order-by field-name="-transactionDate"/>
             </entity-condition>
         </actions>
         <row-actions>