svn commit: r651295 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/AcctgTransServices.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: r651295 - in /ofbiz/trunk/applications/accounting: script/org/ofbiz/accounting/ledger/AcctgTransServices.xml widget/GlForms.xml

jacopoc
Author: jacopoc
Date: Thu Apr 24 08:44:37 2008
New Revision: 651295

URL: http://svn.apache.org/viewvc?rev=651295&view=rev
Log:
Added ability to set amount in alternative currencies in manual acctg trans entries.

Modified:
    ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
    ofbiz/trunk/applications/accounting/widget/GlForms.xml

Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml?rev=651295&r1=651294&r2=651295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (original)
+++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml Thu Apr 24 08:44:37 2008
@@ -76,13 +76,37 @@
         <field-to-result field-name="newEntity.acctgTransEntrySeqId" result-name="acctgTransEntrySeqId"/>
 
         <!-- if not explicitly provided in the parameters, set the currency of the entry from PartyAcctgPreference -->
+        <set field="partyAccountingPreferencesCallMap.organizationPartyId" from-field="parameters.organizationPartyId"/>
+        <call-service service-name="getPartyAccountingPreferences" in-map-name="partyAccountingPreferencesCallMap">
+             <result-to-field result-name="partyAccountingPreference" field-name="partyAcctgPreference"/>
+        </call-service>
         <if-empty field-name="parameters.currencyUomId">
-            <set field="partyAccountingPreferencesCallMap.organizationPartyId" from-field="parameters.organizationPartyId"/>
-            <call-service service-name="getPartyAccountingPreferences" in-map-name="partyAccountingPreferencesCallMap">
-                 <result-to-field result-name="partyAccountingPreference" field-name="partyAcctgPreference"/>
-            </call-service>
             <set from-field="partyAcctgPreference.baseCurrencyUomId" field="newEntity.currencyUomId"/>
         </if-empty>
+        
+        <!-- if the amount field is empty, then determine it from the origAmount and origCurrencyUomId fields:
+             if origCurrencyUomId is different from the base currency of the organization, then the amount value will be converted -->
+        <if-empty field-name="newEntity.amount">
+            <if-not-empty field-name="newEntity.origAmount">
+                <if-empty field-name="newEntity.origCurrencyUomId">
+                    <set field="newEntity.origCurrencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/>
+                </if-empty>
+                <if-compare-field field-name="newEntity.origCurrencyUomId" operator="not-equals" to-field-name="newEntity.currencyUomId">
+                    <clear-field field-name="convertUomInMap"/>
+                    <set field="convertUomInMap.originalValue" from-field="newEntity.origAmount" type="Double"/>
+                    <set field="convertUomInMap.uomId" from-field="newEntity.origCurrencyUomId"/>
+                    <set field="convertUomInMap.uomIdTo" from-field="newEntity.currencyUomId"/>
+                    <!-- TODO: set the optional asOfDate input parameter -->
+                    <call-service service-name="convertUom" in-map-name="convertUomInMap">
+                        <result-to-field result-name="convertedValue" field-name="newEntity.amount"/>
+                    </call-service>
+                <else>
+                    <set field="newEntity.amount" from-field="newEntity.origAmount"/>
+                </else>
+                </if-compare-field>
+            </if-not-empty>
+        </if-empty>
+
         <if-empty field-name="newEntity.acctgTransEntryTypeId">
             <set field="newEntity.acctgTransEntryTypeId" value="_NA_"/>
         </if-empty>

Modified: ofbiz/trunk/applications/accounting/widget/GlForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlForms.xml?rev=651295&r1=651294&r2=651295&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/GlForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/GlForms.xml Thu Apr 24 08:44:37 2008
@@ -503,7 +503,15 @@
                 </entity-options>
             </drop-down>
         </field>
-        <field name="amount"><text size="30"/></field>
+        <field name="origAmount"><text size="30"/></field>
+        <field name="origCurrencyUomId">
+            <drop-down allow-empty="true">
+                <entity-options key-field-name="uomId" description="${abbreviation} - ${description}" entity-name="Uom">
+                    <entity-constraint name="uomTypeId" operator="equals" value="CURRENCY_MEASURE"/>
+                    <entity-order-by field-name="abbreviation"/>
+                </entity-options>
+            </drop-down>
+        </field>
         <field name="voucherRef"><text size="30"/></field>
         <field name="partyId"><text size="30"/></field>
         <field name="productId"><text size="20"/></field>