Author: bibryam
Date: Fri Nov 28 03:16:07 2008 New Revision: 721431 URL: http://svn.apache.org/viewvc?rev=721431&view=rev Log: Added purposeEnumId field to UomConversionDated entity. This will allow having different currency exchange rates for different on purposea. Also extended convertUom service to search rates by purpose. If a rate with specified purposeEnumId is not found, then the conversion is done based on rates w/o purpose. Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/admin/AcctgAdminServices.xml ofbiz/trunk/applications/accounting/servicedef/services_admin.xml ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml ofbiz/trunk/framework/common/data/CommonTypeData.xml ofbiz/trunk/framework/common/entitydef/entitymodel.xml ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/admin/AcctgAdminServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/admin/AcctgAdminServices.xml?rev=721431&r1=721430&r2=721431&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/admin/AcctgAdminServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/admin/AcctgAdminServices.xml Fri Nov 28 03:16:07 2008 @@ -112,10 +112,13 @@ </if-empty> <!-- find the existing exchange rates for this currency pair --> - <entity-and entity-name="UomConversionDated" list-name="uomConversions" filter-by-date="true"> - <field-map env-name="parameters.uomId" field-name="uomId"/> - <field-map env-name="parameters.uomIdTo" field-name="uomIdTo"/> - </entity-and> + <entity-condition entity-name="UomConversionDated" list-name="uomConversions" filter-by-date="true"> + <condition-list> + <condition-expr field-name="uomId" operator="equals" env-name="parameters.uomId" /> + <condition-expr field-name="uomIdTo" operator="equals" env-name="parameters.uomIdTo" /> + <condition-expr field-name="purposeEnumId" operator="equals" env-name="parameters.purposeEnumId" ignore-if-empty="true"/> + </condition-list> + </entity-condition> <!-- expire all of them --> <iterate list-name="uomConversions" entry-name="uomConversion"> Modified: ofbiz/trunk/applications/accounting/servicedef/services_admin.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_admin.xml?rev=721431&r1=721430&r2=721431&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_admin.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_admin.xml Fri Nov 28 03:16:07 2008 @@ -70,6 +70,7 @@ <attribute type="String" mode="IN" name="uomId" optional="false"/> <attribute type="String" mode="IN" name="uomIdTo" optional="false"/> <attribute type="Double" mode="IN" name="conversionFactor" optional="false"/> + <attribute type="String" mode="IN" name="purposeEnumId" optional="true"/> <attribute type="Timestamp" mode="IN" name="asOfTimestamp" optional="true"/> </service> Modified: ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml?rev=721431&r1=721430&r2=721431&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml (original) +++ ofbiz/trunk/applications/accounting/widget/GlSetupForms.xml Fri Nov 28 03:16:07 2008 @@ -307,6 +307,7 @@ odd-row-style="alternate-row" header-row-style="header-row-2" default-table-style="basic-table hover-bar"> <field name="uomId" title="${uiLabelMap.CommonFrom} ${uiLabelMap.CommonCurrency}"><display/></field> <field name="uomIdTo" title="${uiLabelMap.CommonTo} ${uiLabelMap.CommonCurrency}"><display/></field> + <field name="purposeEnumId" title="${uiLabelMap.CommonPurpose}"><display-entity entity-name="Enumeration" key-field-name="enumId" description="${description}"/></field> <field name="conversionFactor"><display/></field> <field name="fromDate" title="${uiLabelMap.CommonFrom}"><display/></field> <field name="thruDate" title="${uiLabelMap.CommonThru}"><display/></field> @@ -331,6 +332,14 @@ </entity-options> </drop-down> </field> + <field name="purposeEnumId" title="${uiLabelMap.CommonPurpose}"> + <drop-down allow-empty="true"> + <entity-options entity-name="Enumeration" description="${description}" key-field-name="enumId"> + <entity-constraint name="enumTypeId" operator="equals" value="CONVERSION_PURPOSE"/> + <entity-order-by field-name="sequenceId"/> + </entity-options> + </drop-down> + </field> <field name="conversionFactor"><text/></field> <field name="submitButton" title="${uiLabelMap.AccountingUpdateFX}"><submit/></field> </form> Modified: ofbiz/trunk/framework/common/data/CommonTypeData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/data/CommonTypeData.xml?rev=721431&r1=721430&r2=721431&view=diff ============================================================================== --- ofbiz/trunk/framework/common/data/CommonTypeData.xml (original) +++ ofbiz/trunk/framework/common/data/CommonTypeData.xml Fri Nov 28 03:16:07 2008 @@ -116,4 +116,9 @@ <VisualThemeResource visualThemeId="DEFAULT" resourceTypeEnumId="VT_FTR_TMPLT_LOC" resourceValue="component://common/webcommon/includes/footer.ftl" sequenceId="01"/> <VisualThemeResource visualThemeId="DEFAULT" resourceTypeEnumId="VT_SCREENSHOT" resourceValue="/images/default-screenshot.gif" sequenceId="01"/> + <!-- Uom Conversion Purposes --> + <EnumerationType enumTypeId="CONVERSION_PURPOSE" description="Conversion Purpose"/> + <Enumeration enumId="INTERNAL_CONVERSION" enumTypeId="CONVERSION_PURPOSE" enumCode="INTERNAL" sequenceId="10" description="Internal Conversion"/> + <Enumeration enumId="EXTERNAL_CONVERSION" enumTypeId="CONVERSION_PURPOSE" enumCode="EXTERNAL" sequenceId="20" description="External Conversion"/> + </entity-engine-xml> Modified: ofbiz/trunk/framework/common/entitydef/entitymodel.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/entitydef/entitymodel.xml?rev=721431&r1=721430&r2=721431&view=diff ============================================================================== --- ofbiz/trunk/framework/common/entitydef/entitymodel.xml (original) +++ ofbiz/trunk/framework/common/entitydef/entitymodel.xml Fri Nov 28 03:16:07 2008 @@ -458,6 +458,7 @@ <field name="customMethodId" type="id-ne"></field> <field name="decimalScale" type="numeric"></field> <field name="roundingMode" type="id"></field> + <field name="purposeEnumId" type="id"></field> <prim-key field="uomId"/> <prim-key field="uomIdTo"/> <prim-key field="fromDate"/> @@ -470,6 +471,9 @@ <relation type="one" fk-name="UOMD_CUSTOM_METHOD" title="uomCustomMethod" rel-entity-name="CustomMethod"> <key-map field-name="customMethodId" rel-field-name="customMethodId"/> </relation> + <relation type="one" fk-name="UOMD_PURPOSE_ENUM" title="Purpose" rel-entity-name="Enumeration"> + <key-map field-name="purposeEnumId" rel-field-name="enumId"/> + </relation> </entity> <entity entity-name="UomType" package-name="org.ofbiz.common.uom" Modified: ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml?rev=721431&r1=721430&r2=721431&view=diff ============================================================================== --- ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml (original) +++ ofbiz/trunk/framework/common/script/org/ofbiz/common/CommonServices.xml Fri Nov 28 03:16:07 2008 @@ -83,6 +83,7 @@ <condition-list combine="and"> <condition-expr field-name="uomId" env-name="parameters.uomId"/> <condition-expr field-name="uomIdTo" env-name="parameters.uomIdTo"/> + <condition-expr field-name="purposeEnumId" operator="equals" env-name="parameters.purposeEnumId" ignore-if-empty="true"/> <condition-expr field-name="fromDate" operator="less-equals" env-name="asOfDate"/> <condition-list combine="or"> <condition-expr field-name="thruDate" operator="greater-equals" env-name="asOfDate"/> @@ -93,6 +94,25 @@ <order-by field-name="-fromDate"/> </entity-condition> <first-from-list list-name="uomConversions" entry-name="uomConversion"/> + + <!-- if no conversion found with specified purpose, try w/o purpose --> + <if-empty field="uomConversion"> + <if-not-empty field="parameters.purposeEnumId"> + <entity-condition entity-name="UomConversionDated" list-name="uomConversions" use-cache="true"> + <condition-list combine="and"> + <condition-expr field-name="uomId" env-name="parameters.uomId"/> + <condition-expr field-name="uomIdTo" env-name="parameters.uomIdTo"/> + <condition-expr field-name="fromDate" operator="less-equals" env-name="asOfDate"/> + <condition-list combine="or"> + <condition-expr field-name="thruDate" operator="greater-equals" env-name="asOfDate"/> + <condition-expr field-name="thruDate" operator="equals" env-name="nullField"/> + </condition-list> + </condition-list> + <order-by field-name="-fromDate"/> + </entity-condition> + <first-from-list list-name="uomConversions" entry-name="uomConversion"/> + </if-not-empty> + </if-empty> </if-empty> <log level="verbose" message="using conversion factor=${uomConversion.conversionFactor}"/> |
Free forum by Nabble | Edit this page |