svn commit: r599365 - in /ofbiz/trunk/applications/accounting: data/AccountingTypeData.xml data/DemoGlSetupData.xml script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas_ledger.xml servicedef/services_ledger.xml

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

svn commit: r599365 - in /ofbiz/trunk/applications/accounting: data/AccountingTypeData.xml data/DemoGlSetupData.xml script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml servicedef/secas_ledger.xml servicedef/services_ledger.xml

jacopoc
Author: jacopoc
Date: Thu Nov 29 02:18:11 2007
New Revision: 599365

URL: http://svn.apache.org/viewvc?rev=599365&view=rev
Log:
Implemented gl auto posting service for shipment/inventory receipts.

Modified:
    ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
    ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml
    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

Modified: ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml?rev=599365&r1=599364&r2=599365&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/AccountingTypeData.xml Thu Nov 29 02:18:11 2007
@@ -43,6 +43,7 @@
     <AcctgTransType acctgTransTypeId="INVENTORY_RETURN" description="Inventory from Return" hasTable="N" parentTypeId="EXTERNAL_ACCTG_TRANS"/>
 
     <AcctgTransType acctgTransTypeId="SALES_SHIPMENT" parentTypeId="" hasTable="N" description="Sales Shipment"/>
+    <AcctgTransType acctgTransTypeId="SHIPMENT_RECEIPT" parentTypeId="" hasTable="N" description="Shipment Receipt"/>
 
     <AcctgTransEntryType acctgTransEntryTypeId="_NA_" description="Not Applicable" hasTable="N" parentTypeId=""/>
 

Modified: ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml?rev=599365&r1=599364&r2=599365&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml Thu Nov 29 02:18:11 2007
@@ -34,10 +34,12 @@
     <GlAccountOrganization organizationPartyId="Company" glAccountId="140000" fromDate="2001-01-01 00:00:00.0"/>
     <GlAccountOrganization organizationPartyId="Company" glAccountId="213200" fromDate="2001-01-01 00:00:00.0"/>
     <GlAccountOrganization organizationPartyId="Company" glAccountId="213500" fromDate="2001-01-01 00:00:00.0"/>
+    <GlAccountOrganization organizationPartyId="Company" glAccountId="214000" fromDate="2001-01-01 00:00:00.0"/>
     <GlAccountOrganization organizationPartyId="Company" glAccountId="500000" fromDate="2001-01-01 00:00:00.0"/>
     
     <!-- Default mapping between account types and account ids -->
     <GlAccountTypeDefault organizationPartyId="Company" glAccountTypeId="INVENTORY_ACCOUNT" glAccountId="140000" />
+    <GlAccountTypeDefault organizationPartyId="Company" glAccountTypeId="UNINVOICED_SHIP_RCPT" glAccountId="214000"/>
     <GlAccountTypeDefault organizationPartyId="Company" glAccountTypeId="COGS_ACCOUNT" glAccountId="500000" />
 
     <!-- Specific mapping between financial account types and account ids -->

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=599365&r1=599364&r2=599365&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 02:18:11 2007
@@ -519,6 +519,63 @@
         <field-to-result field-name="acctgTransId" result-name="acctgTransId"/>        
     </simple-method>
 
+    <simple-method method-name="createAcctgTransForShipmentReceipt" short-description="Create an accounting transactions for a shipment receipt (D: INVENTORY_ACCOUNT, C: UNINVOICED_SHIP_RCPT or COGS_ACCOUNT for returns)">
+        <!-- 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="ShipmentReceipt" value-name="shipmentReceipt"/>
+        <get-related-one value-name="shipmentReceipt" relation-name="InventoryItem" to-value-name="inventoryItem"/>
+        <get-related-one value-name="shipmentReceipt" relation-name="Shipment" to-value-name="shipment"/>
+        <if-not-empty field-name="shipmentReceipt.returnId">
+            <set field="creditAccountTypeId" value="COGS_ACCOUNT"/>
+        <else>
+            <set field="creditAccountTypeId" value="UNINVOICED_SHIP_RCPT"/>
+        </else>
+        </if-not-empty>
+        <!-- TODO: handle serialized inventory -->
+        <calculate field-name="origAmount" type="BigDecimal" decimal-scale="${ledgerDecimals}" rounding-mode="${roundingMode}">
+            <calcop operator="multiply">
+                <calcop operator="get" field-name="shipmentReceipt.quantityAccepted"/>
+                <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" from-field="creditAccountTypeId"/>
+        <set field="creditEntry.organizationPartyId" from-field="inventoryItem.ownerPartyId"/>
+        <set field="creditEntry.partyId" from-field="shipment.partyIdFrom"/>
+        <set field="creditEntry.roleTypeId" value="BILL_FROM_VENDOR"/>
+        <set field="creditEntry.productId" from-field="inventoryItem.productId"/>
+        <set field="creditEntry.origAmount" from-field="origAmount"/>
+        <set field="creditEntry.origCurrencyUomId" from-field="inventoryItem.currencyUomId"/>
+        <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="INVENTORY_ACCOUNT"/>
+        <set field="debitEntry.organizationPartyId" from-field="inventoryItem.ownerPartyId"/>
+        <set field="debitEntry.partyId" from-field="shipment.partyIdFrom"/>
+        <set field="debitEntry.roleTypeId" value="BILL_FROM_VENDOR"/>
+        <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="debitEntry" type="Object"/>
+        <!-- Set header fields (AcctgTrans) -->
+        <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" value="ACTUAL"/>
+        <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" value="SHIPMENT_RECEIPT"/>
+        <set field="createAcctgTransAndEntriesInMap.shipmentId" from-field="shipmentReceipt.shipmentId"/>
+        <set field="createAcctgTransAndEntriesInMap.partyId" from-field="shipment.partyIdFrom"/>
+        <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 -->

Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=599365&r1=599364&r2=599365&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Thu Nov 29 02:18:11 2007
@@ -26,7 +26,7 @@
         <condition field-name="shipmentId" operator="is-not-empty"/>
         <action service="createAcctgTransForSalesShipmentIssuance" mode="sync"/>
     </eca>
-    <!--
+    <!-- DEPRECATED
     <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"/>
@@ -34,6 +34,11 @@
         <action service="createAcctgTransForSalesShipment" mode="sync"/>
     </eca>
     -->
+    <!-- create the accounting transactions for a shipment receipt every time the inventory is received -->
+    <eca service="createShipmentReceipt" event="commit">
+        <action service="createAcctgTransForShipmentReceipt" mode="sync"/>
+    </eca>
+
     <!-- this eca automatically posts the accounting transactions to GL -->
     <eca service="createAcctgTransAndEntries" event="commit">
         <condition field-name="acctgTransId" operator="is-not-empty"/>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=599365&r1=599364&r2=599365&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Thu Nov 29 02:18:11 2007
@@ -299,16 +299,23 @@
 
     <!-- Services for the automatic creation of accounting transactions based on business transactions
          Typically, these services are triggered by SECAs -->
+    <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>
+    <!-- DEPRECATED: use createAcctgTransForSalesShipmentIssuance instead -->
     <service name="createAcctgTransForSalesShipment" engine="simple"  auth="true"
         location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForSalesShipment">
         <description>Create accounting transactions for issuances for a sales shipment (D: INVENTORY_ACCOUNT, C: COGS_ACCOUNT)</description>
         <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"/>
+    <service name="createAcctgTransForShipmentReceipt" engine="simple"  auth="true"
+        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForShipmentReceipt">
+        <description>Create an accounting transactions for a shipment receipt (D: INVENTORY_ACCOUNT, C: UNINVOICED_SHIP_RCPT or COGS_ACCOUNT for returns)</description>
+        <attribute name="receiptId" type="String" mode="IN" optional="false"/>
         <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/>
     </service>