Commit dacb32ea authored by Mame Coumba Sall's avatar Mame Coumba Sall

2008-12-12 mame

*add script to convert currency exchange line into predicates
* modify script so that if no base price is found on predicate, skip it

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24879 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 313ae51e
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
<tuple/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>start_date = context.getStartDate()\n
stop_date = context.getStopDate()\n
identity_criterion = {\'start_date\':(start_date,stop_date)}\n
return context.asContext(_range_criterion=identity_criterion,\n
membership_criterion_base_category=[\'price_currency\',\'resource\'],\n
membership_criterion_category=[\'resource/%s\' % context.getParentValue().getRelativeUrl(),\n
\'price_currency/%s\' % context.getPriceCurrency()])\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>start_date</string>
<string>stop_date</string>
<string>identity_criterion</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>CurrencyExchangeLine_asPredicate</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -53,7 +53,9 @@ ...@@ -53,7 +53,9 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>"""\n <value> <string encoding="cdata"><![CDATA[
"""\n
Search for all predicates that corresponds to this particular context\n Search for all predicates that corresponds to this particular context\n
and returns the base price of the resource\n and returns the base price of the resource\n
This script derives form getPriceCalculationOperandDict and is invoked by getPrice.\n This script derives form getPriceCalculationOperandDict and is invoked by getPrice.\n
...@@ -63,18 +65,34 @@ This script derives form getPriceCalculationOperandDict and is invoked by getPri ...@@ -63,18 +65,34 @@ This script derives form getPriceCalculationOperandDict and is invoked by getPri
**kw -- dictionary containing all information of the transaction\n **kw -- dictionary containing all information of the transaction\n
\n \n
"""\n """\n
\n
def sort_by_date(a, b):\n
if a.getStartDateRangeMin() > b.getStartDateRangeMin() :\n
return -1\n
return 1\n
\n
#If getPrice is directly called on a resource, call directly\n #If getPrice is directly called on a resource, call directly\n
#Resource_getPriceCalculationOperandDict on the resource\n #Resource_getPriceCalculationOperandDict on the resource\n
if movement is None:\n if movement is None:\n
return context.Resource_getPriceCalculationOperandDict(**kw)\n return context.Resource_getPriceCalculationOperandDict(**kw)\n
else:\n else:\n
predicate_list = context.portal_domains.searchPredicateList(\n predicate_list = context.portal_domains.searchPredicateList(\n
context=movement,portal_type=\'Currency Exchange Line\')\n context=movement,\n
portal_type=\'Currency Exchange Line\',\n
validation_state=\'validated\',\n
test =1,\n
sort_method=sort_by_date,**kw )\n
\n
\n
\n
# For each predicate(i.e: Currency Exchange Line) found, get the exchange rate\n # For each predicate(i.e: Currency Exchange Line) found, get the exchange rate\n
# with the reference currency\n # with the reference currency\n
for predicate in predicate_list:\n for predicate in predicate_list:\n
if predicate.Resource_getPriceCalculationOperandDict(movement=predicate,**kw) is not None:\n
return predicate.Resource_getPriceCalculationOperandDict(movement=predicate,**kw)\n return predicate.Resource_getPriceCalculationOperandDict(movement=predicate,**kw)\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -114,6 +132,7 @@ else:\n ...@@ -114,6 +132,7 @@ else:\n
<string>movement</string> <string>movement</string>
<string>REQUEST</string> <string>REQUEST</string>
<string>kw</string> <string>kw</string>
<string>sort_by_date</string>
<string>None</string> <string>None</string>
<string>_apply_</string> <string>_apply_</string>
<string>_getattr_</string> <string>_getattr_</string>
......
491 499
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment