Commit 74385fe6 authored by Fabien Morin's avatar Fabien Morin

save the created cell in a dict and give the dict to the newCell method.

That's more simple and in this way, it's make possible the caclulation script
to return other things than quantity and price (categories for example).


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18292 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c19d17ac
...@@ -117,7 +117,7 @@ class PaySheetTransaction(Invoice): ...@@ -117,7 +117,7 @@ class PaySheetTransaction(Invoice):
var_cat_list = [] var_cat_list = []
for cell in good_cell_list: for cell in good_cell_list:
# Don't add a variation category if already in it # Don't add a variation category if already in it
for category in cell['axe_list']: for category in cell['category_list']:
if category not in var_cat_list: if category not in var_cat_list:
var_cat_list.append(category) var_cat_list.append(category)
...@@ -125,14 +125,15 @@ class PaySheetTransaction(Invoice): ...@@ -125,14 +125,15 @@ class PaySheetTransaction(Invoice):
description = None description = None
if len(desc) > 0: if len(desc) > 0:
description = desc#'\n'.join(desc) description = desc#'\n'.join(desc)
source = self.getPortalObject().restrictedTraverse(res).getSource()
# Add a new Pay Sheet Line # Add a new Pay Sheet Line
payline = self.newContent( payline = self.newContent(
portal_type = 'Pay Sheet Line', portal_type = 'Pay Sheet Line',
title = title, title = title,
description = description, description = description,
destination = self.getSourceSection(), destination = self.getSourceSection(),
source_section = \ source_section = source,
self.getPortalObject().restrictedTraverse(res).getSource(),
resource = res, resource = res,
destination_section = self.getDestinationSection(), destination_section = self.getDestinationSection(),
variation_base_category_list = ('tax_category', 'salary_range'), variation_base_category_list = ('tax_category', 'salary_range'),
...@@ -145,19 +146,13 @@ class PaySheetTransaction(Invoice): ...@@ -145,19 +146,13 @@ class PaySheetTransaction(Invoice):
a = payline.updateCellRange(base_id = base_id) a = payline.updateCellRange(base_id = base_id)
# create cell_list # create cell_list
for cell in good_cell_list: for cell in good_cell_list:
cell_cat_list = cell['axe_list'] paycell = payline.newCell(base_id = base_id, *cell['category_list'])
paycell = payline.newCell(base_id = base_id, *cell_cat_list)
# if the price aven't be completed, it should be set to 1 (=100%) # if the price aven't be completed, it should be set to 1 (=100%)
if cell['price']: if not cell['price']:
price = cell['price'] cell['price'] = 1
else:
price = 1
paycell.edit( mapped_value_property_list = ('price', 'quantity'), paycell.edit( mapped_value_property_list = ('price', 'quantity'),
quantity = cell['quantity'],
price = price,
force_update = 1, force_update = 1,
category_list = cell_cat_list, **cell)
)
return payline return payline
...@@ -406,18 +401,14 @@ class PaySheetTransaction(Invoice): ...@@ -406,18 +401,14 @@ class PaySheetTransaction(Invoice):
quantity=0 quantity=0
price=0 price=0
#LOG('script_name :', 0, script_name) #LOG('script_name :', 0, script_name)
result = calculation_script(base_amount_dict=base_amount_dict, cell=cell,) cell_dict = calculation_script(base_amount_dict=base_amount_dict,
cell=cell,)
cell_dict.update({'category_list':tuple})
quantity = result['quantity'] quantity = cell_dict['quantity']
price = result['price'] price = cell_dict['price']
# Cell creation : cell_list.append(cell_dict)
# Define an empty new cell
new_cell = { 'axe_list' : tuple, # share, slice
'quantity' : quantity,
'price' : price,
}
cell_list.append(new_cell)
# update the base_participation # update the base_participation
base_participation_list = service.getBaseAmountList(base=1) base_participation_list = service.getBaseAmountList(base=1)
......
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