Commit c4ba8b9a authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: order Supply Predicate matching

parent 4b65e8d7
...@@ -6,11 +6,13 @@ def sort_key_method(e): ...@@ -6,11 +6,13 @@ def sort_key_method(e):
having source_function only having source_function only
others others
""" """
return 0
parent = e.getParentValue() parent = e.getParentValue()
if parent.getPortalType().endswith('Line'): if parent.getPortalType().endswith('Line'):
parent = parent.getParentValue() parent = parent.getParentValue()
return 0 - 1 * int(parent.hasSourceFunction()) - 2 * int(parent.hasGroup()) minus = 0
else:
minus = -0.5
return 0 - 1 * int(parent.hasDestination()) + minus
def filter_method(currency, destination_project, group): def filter_method(currency, destination_project, group):
def filter_by_source_function_and_group(l): def filter_by_source_function_and_group(l):
...@@ -38,6 +40,7 @@ def filter_method(currency, destination_project, group): ...@@ -38,6 +40,7 @@ def filter_method(currency, destination_project, group):
#if parent.getGroup() not in (None, group): #if parent.getGroup() not in (None, group):
# continue # continue
ret.append(i) ret.append(i)
return ret return ret
return filter_by_source_function_and_group return filter_by_source_function_and_group
source = context.getSourceValue() source = context.getSourceValue()
...@@ -47,13 +50,6 @@ else: ...@@ -47,13 +50,6 @@ else:
group = source.getGroup() group = source.getGroup()
kw['filter_method'] = filter_method(context.getPriceCurrency(), context.getDestinationProject(), group) kw['filter_method'] = filter_method(context.getPriceCurrency(), context.getDestinationProject(), group)
"""
def filter_couscous(predicate_list):
raise NotImplementedError(predicate_list)
return predicate_list
kw['filter_method'] = filter_couscous
"""
kw['sort_key_method'] = sort_key_method kw['sort_key_method'] = sort_key_method
resource = context.getResourceValue() resource = context.getResourceValue()
...@@ -63,7 +59,6 @@ if resource is not None: ...@@ -63,7 +59,6 @@ if resource is not None:
if product_line: if product_line:
kw['categories'] = kw.get('categories', []) + ['product_line/%s' % product_line] kw['categories'] = kw.get('categories', []) + ['product_line/%s' % product_line]
#raise NotImplementedError(str(kw))
return resource.getPriceCalculationOperandDict( return resource.getPriceCalculationOperandDict(
default=default, context=context, **kw) default=default, context=context, **kw)
......
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