|
Author: jacopoc
Date: Fri Jan 15 11:52:24 2010 New Revision: 899603 URL: http://svn.apache.org/viewvc?rev=899603&view=rev Log: When accounting transactions for depreciation of a fixed asset are posted to the GL, the total depreciation amount is updated in the corresponding FixedAsset entity. Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml?rev=899603&r1=899602&r2=899603&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml Fri Jan 15 11:52:24 2010 @@ -806,4 +806,62 @@ </else> </if-not-empty> </simple-method> + + <simple-method method-name="checkUpdateFixedAssetDepreciation" login-required="true" + short-description="If the accounting transaction is a depreciation transaction for a fixed asset, update the depreciation amount in the FixedAsset entity."> + <entity-one entity-name="AcctgTrans" value-field="acctgTrans"/> + <if> + <condition> + <and> + <if-compare field="acctgTrans.acctgTransTypeId" operator="equals" value="DEPRECIATION"/> + <not><if-empty field="acctgTrans.fixedAssetId"/></not> + </and> + </condition> + <then> + <get-related-one relation-name="FixedAsset" value-field="acctgTrans" to-value-field="fixedAsset"/> + <set field="creditCondition.debitCreditFlag" value="C"/> + <get-related relation-name="AcctgTransEntry" value-field="acctgTrans" list="creditTransactions" map="creditCondition"/> + <set field="depreciation" value="0.0" type="BigDecimal"/> + <iterate list="creditTransactions" entry="creditTransaction"> + <if-empty field="fixedAsset.purchaseCostUomId"> + <log level="warning" message="Found empty purchaseCostUomId for FixedAsset [${fixedAsset.fixedAssetId}]: setting it to ${creditTransaction.currencyUomId} to match the one used in the gl."/> + <set field="fixedAsset.purchaseCostUomId" from-field="creditTransaction.currencyUomId"/> + <store-value value-field="fixedAsset"/> + </if-empty> + <if-compare-field field="fixedAsset.purchaseCostUomId" operator="equals" to-field="creditTransaction.currencyUomId"> + <calculate field="depreciation"> + <calcop operator="add"> + <calcop operator="get" field="depreciation"/> + <calcop operator="get" field="creditTransaction.amount"/> + </calcop> + </calculate> + <else> + <if-compare-field field="fixedAsset.purchaseCostUomId" operator="equals" to-field="creditTransaction.origCurrencyUomId"> + <calculate field="depreciation"> + <calcop operator="add"> + <calcop operator="get" field="depreciation"/> + <calcop operator="get" field="creditTransaction.origAmount"/> + </calcop> + </calculate> + <else> + <log level="warning" message="Found an accounting transaction for depreciation of FixedAsset [${fixedAsset.fixedAssetId}] with a cuurency that doesn't match the currency used in the fixed asset: the depreciation total in the fixed asset will not be updated."/> + <return/> + </else> + </if-compare-field> + </else> + </if-compare-field> + </iterate> + <set field="depreciationTotal" from-field="fixedAsset.depreciation" default-value="0.0" type="BigDecimal"/> + <calculate field="depreciationTotal"> + <calcop operator="add"> + <calcop operator="get" field="depreciation"/> + <calcop operator="get" field="depreciationTotal"/> + </calcop> + </calculate> + <set field="fixedAsset.depreciation" from-field="depreciationTotal"/> + <store-value value-field="fixedAsset"/> + </then> + </if> + </simple-method> + </simple-methods> Modified: ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml?rev=899603&r1=899602&r2=899603&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/secas_ledger.xml Fri Jan 15 11:52:24 2010 @@ -132,4 +132,11 @@ <condition field-name="statusId" operator="is-not-empty"/> <action service="setGlReconciliationStatus" mode="sync"/> </eca> + + <!-- If the accounting transaction that is posted is a depreciation transaction for a fixed asset, update the depreciation amount in the FixedAsset entity --> + <eca service="postAcctgTrans" event="commit"> + <condition field-name="verifyOnly" operator="not-equals" value="true"/> + <action service="checkUpdateFixedAssetDepreciation" mode="sync"/> + </eca> + </service-eca> \ No newline at end of file Modified: ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml?rev=899603&r1=899602&r2=899603&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml Fri Jan 15 11:52:24 2010 @@ -266,6 +266,12 @@ <auto-attributes include="pk" mode="IN" optional="false"/> <auto-attributes include="nonpk" mode="IN" optional="true"/> </service> + <service name="checkUpdateFixedAssetDepreciation" default-entity-name="AcctgTrans" engine="simple" + location="component://accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml" invoke="checkUpdateFixedAssetDepreciation" auth="true"> + <description>If the accounting transaction is a depreciation transaction for a fixed asset, update the depreciation amount in the FixedAsset entity.</description> + <permission-service service-name="fixedAssetPermissionCheck" main-action="UPDATE"/> + <auto-attributes include="pk" mode="IN" optional="false"/> + </service> <service name="fixedAssetDepCalcInterface" engine="interface"> <description>Interface to describe base parameters for Depreciation Calculation Services</description> <attribute name="expEndOfLifeYear" type="Integer" mode="IN" optional="false"/> |
| Free forum by Nabble | Edit this page |
