Author: jacopoc
Date: Tue Jan 19 11:24:34 2010
New Revision: 900727

URL: http://svn.apache.org/viewvc?rev=900727&view=rev
Log:
First step in the implementation of automatic transactions for fixed assets:
* new entity to setup account mappings for all assets, by asset type or for a 
specific asset
* screen to setup mappings for a specific asset


Modified:
    ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
    
ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml
    ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml
    ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
    ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml
    ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml

Modified: ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml?rev=900727&r1=900726&r2=900727&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml (original)
+++ ofbiz/trunk/applications/accounting/entitydef/entitymodel.xml Tue Jan 19 
11:24:34 2010
@@ -896,6 +896,46 @@
       <field name="description" type="description"></field>
       <prim-key field="fixedAssetProductTypeId"/>
     </entity>
+    <entity entity-name="FixedAssetTypeGlAccount"
+            package-name="org.ofbiz.accounting.fixedasset"
+            title="Gl Account Mapping For Fixed Asset Or Fixed Asset Types">
+      <field name="fixedAssetTypeId" type="id-ne"><description>The fixed asset 
type for the mappings. This field can be set to _NA_ in order to define a 
mapping for all types or for a specific asset (specified by the id in the 
fixedAssetId field).</description></field>
+      <field name="fixedAssetId" type="id-ne"><description>The fixed asset id 
for the mappings. This field can be set to _NA_ in order to define a mapping 
for all assets of a given type (specified by the id in the fixedAssetTypeId 
field).</description></field>
+      <field name="organizationPartyId" type="id-ne"></field>
+      <field name="assetGlAccountId" type="id"><description>The (debit) 
account for the initial asset value (purchase cost)</description></field>
+      <field name="accDepGlAccountId" type="id"><description>The (credit) 
account for the accumulated depreciation</description></field>
+      <field name="depGlAccountId" type="id"><description>The (debit) account 
for the depreciation expense (matches the 
accDepGlAccountId)</description></field>
+      <field name="profitGlAccountId" type="id"><description>The (credit) 
account for the eventual profit derived from the sale of the 
asset</description></field>
+      <field name="lossGlAccountId" type="id"><description>The (debit) account 
for the eventual loss derived from the sale of the asset</description></field>
+      <prim-key field="fixedAssetTypeId"/>
+      <prim-key field="fixedAssetId"/>
+      <prim-key field="organizationPartyId"/>
+      <relation type="one-nofk" rel-entity-name="FixedAssetType">
+        <key-map field-name="fixedAssetTypeId"/>
+      </relation>
+      <relation type="one-nofk" rel-entity-name="FixedAsset">
+        <key-map field-name="fixedAssetId"/>
+      </relation>
+      <relation type="one" fk-name="FATGL_OP" rel-entity-name="Party">
+        <key-map field-name="organizationPartyId" rel-field-name="partyId"/>
+      </relation>
+      <relation type="one" fk-name="FATGL_AGL" title="Asset" 
rel-entity-name="GlAccount">
+        <key-map field-name="assetGlAccountId" rel-field-name="glAccountId"/>
+      </relation>
+      <relation type="one" fk-name="FATGL_ACCDGL" 
title="AccumulatedDepreciation" rel-entity-name="GlAccount">
+        <key-map field-name="accDepGlAccountId" rel-field-name="glAccountId"/>
+      </relation>
+      <relation type="one" fk-name="FATGL_DGL" title="Depreciation" 
rel-entity-name="GlAccount">
+        <key-map field-name="depGlAccountId" rel-field-name="glAccountId"/>
+      </relation>
+      <relation type="one" fk-name="FATGL_PGL" title="Profit" 
rel-entity-name="GlAccount">
+        <key-map field-name="profitGlAccountId" rel-field-name="glAccountId"/>
+      </relation>
+      <relation type="one" fk-name="FATGL_LGL" title="Loss" 
rel-entity-name="GlAccount">
+        <key-map field-name="lossGlAccountId" rel-field-name="glAccountId"/>
+      </relation>
+    </entity>
+
     <entity entity-name="FixedAssetRegistration" 
package-name="org.ofbiz.accounting.fixedasset" title="Fixed Asset Registration 
Entity">
         <field name="fixedAssetId" type="id-ne"></field>
         <field name="fromDate" type="date-time"></field>

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=900727&r1=900726&r2=900727&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
 Tue Jan 19 11:24:34 2010
@@ -864,4 +864,17 @@
         </if>
     </simple-method>
 
+    <simple-method method-name="createFixedAssetTypeGlAccount" 
short-description="Create a Fixed Asset Type Gl Account Mapping">
+        <make-value entity-name="FixedAssetTypeGlAccount" 
value-field="newEntity"/>
+        <set-pk-fields value-field="newEntity" map="parameters"/>
+        <set-nonpk-fields value-field="newEntity" map="parameters"/>
+        <if-empty field="newEntity.fixedAssetId">
+            <set field="newEntity.fixedAssetId" from-field="_NA_"/>
+        </if-empty>
+        <if-empty field="newEntity.fixedAssetTypeId">
+            <set field="newEntity.fixedAssetTypeId" from-field="_NA_"/>
+        </if-empty>
+        <create-value value-field="newEntity"/>
+    </simple-method>
+
 </simple-methods>

Modified: ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml?rev=900727&r1=900726&r2=900727&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml 
(original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_fixedasset.xml Tue 
Jan 19 11:24:34 2010
@@ -303,6 +303,20 @@
         <attribute name="assetNBVAfterDepreciation" type="List" mode="OUT" 
optional="true"/>
         <attribute name="assetDepreciationInfoList" type="List" mode="OUT" 
optional="true"/>
     </service>
+    <service name="createFixedAssetTypeGlAccount" engine="simple" 
default-entity-name="FixedAssetTypeGlAccount"
+                
location="component://accounting/script/org/ofbiz/accounting/fixedasset/FixedAssetServices.xml"
 invoke="createFixedAssetTypeGlAccount" auth="true">
+        <description>Create a Fixed Asset Type Gl Account Mapping</description>
+        <permission-service service-name="fixedAssetPermissionCheck" 
main-action="CREATE"/>
+        <auto-attributes include="nonpk" mode="IN" optional="true"/>
+        <attribute name="fixedAssetTypeId" type="String" mode="IN" 
optional="true"/>
+        <attribute name="fixedAssetId" type="String" mode="IN" 
optional="true"/>
+        <attribute name="organizationPartyId" type="String" mode="IN" 
optional="false"/>
+    </service>
+    <service name="deleteFixedAssetTypeGlAccount" 
default-entity-name="FixedAssetTypeGlAccount" engine="entity-auto" 
invoke="delete" auth="true">
+        <description>Delete a Fixed Asset Type Gl Account Mapping</description>
+        <permission-service service-name="fixedAssetPermissionCheck" 
main-action="DELETE"/>
+        <auto-attributes include="pk" mode="IN" optional="false"/>
+    </service>
 
     <!-- FixedAssetGeoPoint services -->
     <service name="createFixedAssetGeoPoint" 
default-entity-name="FixedAssetGeoPoint" engine="entity-auto" invoke="create" 
auth="true">

Modified: 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml?rev=900727&r1=900726&r2=900727&view=diff
==============================================================================
--- 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml 
(original)
+++ 
ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml 
Tue Jan 19 11:24:34 2010
@@ -2324,7 +2324,18 @@
         <response name="success" type="view" 
value="ShowFixedAssetDepreciation"/>
         <response name="error" type="view" value="ShowFixedAssetDepreciation"/>
     </request-map>
-
+    <request-map uri="createFixedAssetTypeGlAccountForFixedAsset">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="createFixedAssetTypeGlAccount"/>
+        <response name="success" type="view" 
value="ShowFixedAssetDepreciation"/>
+        <response name="error" type="view" value="ShowFixedAssetDepreciation"/>
+    </request-map>
+    <request-map uri="deleteFixedAssetTypeGlAccountForFixedAsset">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="deleteFixedAssetTypeGlAccount"/>
+        <response name="success" type="view" 
value="ShowFixedAssetDepreciation"/>
+        <response name="error" type="view" value="ShowFixedAssetDepreciation"/>
+    </request-map>
     <!-- Commented out for now WIP
     <request-map uri="taxAuthorityVATReport">
         <security https="true" auth="true"/>

Modified: ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml?rev=900727&r1=900726&r2=900727&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/FixedAssetForms.xml Tue Jan 19 
11:24:34 2010
@@ -642,4 +642,107 @@
         <field name="debitCreditFlag"><display/></field>
         <field name="isPosted"><display/></field>
     </form>
+    <form name="AddFixedAssetTypeGlAccount" type="single" 
target="createFixedAssetTypeGlAccountForFixedAsset" title=""
+        header-row-style="header-row" default-table-style="basic-table">
+        <auto-fields-service service-name="createFixedAssetTypeGlAccount" 
default-field-type="edit"/>
+        <field name="fixedAssetId"><hidden/></field>
+        <field name="fixedAssetTypeId"><hidden value="_NA_"/></field>
+        <field name="organizationPartyId"><hidden 
value="${fixedAsset.partyId}"/></field>
+        <field name="assetGlAccountId">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="GlAccountOrganizationAndClass" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]">
+                    <entity-constraint name="organizationPartyId" 
operator="equals" value="${fixedAsset.partyId}"/>
+                    <entity-constraint name="glAccountClassId" 
operator="equals" value="LONGTERM_ASSET"/>
+                    <entity-order-by field-name="accountCode"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="accDepGlAccountId">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="GlAccountOrganizationAndClass" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]">
+                    <entity-constraint name="organizationPartyId" 
operator="equals" value="${fixedAsset.partyId}"/>
+                    <entity-constraint name="glAccountClassId" 
operator="equals" value="ACCUM_DEPRECIATION"/>
+                    <entity-order-by field-name="accountCode"/>
+                </entity-options>
+                <entity-options entity-name="GlAccountOrganizationAndClass" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]">
+                    <entity-constraint name="organizationPartyId" 
operator="equals" value="${fixedAsset.partyId}"/>
+                    <entity-constraint name="glAccountClassId" 
operator="equals" value="ACCUM_AMORTIZATION"/>
+                    <entity-order-by field-name="accountCode"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="depGlAccountId">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="GlAccountOrganizationAndClass" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]">
+                    <entity-constraint name="organizationPartyId" 
operator="equals" value="${fixedAsset.partyId}"/>
+                    <entity-constraint name="glAccountClassId" 
operator="equals" value="DEPRECIATION"/>
+                    <entity-order-by field-name="accountCode"/>
+                </entity-options>
+                <entity-options entity-name="GlAccountOrganizationAndClass" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]">
+                    <entity-constraint name="organizationPartyId" 
operator="equals" value="${fixedAsset.partyId}"/>
+                    <entity-constraint name="glAccountClassId" 
operator="equals" value="AMORTIZATION"/>
+                    <entity-order-by field-name="accountCode"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="profitGlAccountId">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="GlAccountOrganizationAndClass" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]">
+                    <entity-constraint name="organizationPartyId" 
operator="equals" value="${fixedAsset.partyId}"/>
+                    <entity-constraint name="glAccountClassId" 
operator="equals" value="CASH_INCOME"/>
+                    <entity-order-by field-name="accountCode"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="lossGlAccountId">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="GlAccountOrganizationAndClass" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]">
+                    <entity-constraint name="organizationPartyId" 
operator="equals" value="${fixedAsset.partyId}"/>
+                    <entity-constraint name="glAccountClassId" 
operator="equals" value="SGA_EXPENSE"/>
+                    <entity-order-by field-name="accountCode"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="submitButton" title="${uiLabelMap.CommonAdd}" 
widget-style="smallSubmit"><submit button-type="button"/></field>
+    </form>
+    <form name="GlobalFixedAssetTypeGlAccounts" type="list"
+        odd-row-style="alternate-row" header-row-style="header-row-2" 
default-table-style="basic-table hover-bar">
+        <actions>
+            <entity-condition entity-name="FixedAssetTypeGlAccount" 
list="globalFixedAssetTypeGlAccounts">
+                <condition-list combine="and">
+                    <condition-expr field-name="fixedAssetId" value="_NA_"/>
+                    <condition-list combine="or">
+                        <condition-expr field-name="fixedAssetTypeId" 
from-field="fixedAsset.fixedAssetTypeId"/>
+                        <condition-expr field-name="fixedAssetTypeId" 
value="_NA_"/>
+                    </condition-list>
+                </condition-list>
+            </entity-condition>
+        </actions>
+        <field name="fixedAssetTypeId"><display-entity 
entity-name="FixedAssetType"/></field>
+        <field name="assetGlAccountId"><display-entity entity-name="GlAccount" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]"/></field>
+        <field name="accDepGlAccountId"><display-entity 
entity-name="GlAccount" key-field-name="glAccountId" 
description="${accountCode} - ${accountName} [${glAccountId}]"/></field>
+        <field name="depGlAccountId"><display-entity entity-name="GlAccount" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]"/></field>
+        <field name="profitGlAccountId"><display-entity 
entity-name="GlAccount" key-field-name="glAccountId" 
description="${accountCode} - ${accountName} [${glAccountId}]"/></field>
+        <field name="lossGlAccountId"><display-entity entity-name="GlAccount" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]"/></field>
+    </form>
+    <form name="FixedAssetTypeGlAccounts" type="list"
+        odd-row-style="alternate-row" header-row-style="header-row-2" 
default-table-style="basic-table hover-bar">
+        <actions>
+            <entity-condition entity-name="FixedAssetTypeGlAccount" 
list="fixedAssetTypeGlAccounts">
+                <condition-expr field-name="fixedAssetId" 
from-field="fixedAssetId"/>
+            </entity-condition>
+        </actions>
+        <field name="assetGlAccountId"><display-entity entity-name="GlAccount" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]"/></field>
+        <field name="accDepGlAccountId"><display-entity 
entity-name="GlAccount" key-field-name="glAccountId" 
description="${accountCode} - ${accountName} [${glAccountId}]"/></field>
+        <field name="depGlAccountId"><display-entity entity-name="GlAccount" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]"/></field>
+        <field name="profitGlAccountId"><display-entity 
entity-name="GlAccount" key-field-name="glAccountId" 
description="${accountCode} - ${accountName} [${glAccountId}]"/></field>
+        <field name="lossGlAccountId"><display-entity entity-name="GlAccount" 
key-field-name="glAccountId" description="${accountCode} - ${accountName} 
[${glAccountId}]"/></field>
+        <field name="deleteLink" title="${uiLabelMap.CommonEmptyHeader}" 
widget-style="buttontext">
+            <hyperlink target="deleteFixedAssetTypeGlAccountForFixedAsset" 
description="${uiLabelMap.CommonDelete}" also-hidden="false">
+                <parameter param-name="fixedAssetTypeId"/>
+                <parameter param-name="fixedAssetId"/>
+                <parameter param-name="organizationPartyId"/>
+            </hyperlink>
+        </field>
+    </form>
 </forms>

Modified: ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml
URL: 
http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml?rev=900727&r1=900726&r2=900727&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/FixedAssetScreens.xml Tue Jan 19 
11:24:34 2010
@@ -544,6 +544,13 @@
                                         </screenlet>
                                     </fail-widgets>
                                 </section>
+                                <screenlet title="GL Mappings">
+                                    <include-form 
name="AddFixedAssetTypeGlAccount" 
location="component://accounting/widget/FixedAssetForms.xml"/>
+                                    <label style="h3">Fixed Asset 
Mappings</label>
+                                    <include-form 
name="FixedAssetTypeGlAccounts" 
location="component://accounting/widget/FixedAssetForms.xml"/>
+                                    <label style="h3">Global Mappings</label>
+                                    <include-form 
name="GlobalFixedAssetTypeGlAccounts" 
location="component://accounting/widget/FixedAssetForms.xml"/>
+                                </screenlet>
                                 <screenlet 
title="${uiLabelMap.AccountingTransactions}">
                                     <include-form 
name="FixedAssetTransactions" 
location="component://accounting/widget/FixedAssetForms.xml"/>
                                 </screenlet>


Reply via email to