Commit 04983254 authored by Fabien Morin's avatar Fabien Morin

- typo

- revrite createEditablePaySheetLineList function


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17911 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 98d05420
...@@ -74,7 +74,6 @@ class PaySheetTransaction(Invoice): ...@@ -74,7 +74,6 @@ class PaySheetTransaction(Invoice):
def getRatioQuantityFromReference(self, ratio_reference=None): def getRatioQuantityFromReference(self, ratio_reference=None):
""" """
return the ratio value correponding to the ratio_reference, return the ratio value correponding to the ratio_reference,
or description if ratio value is empty,
None if ratio_reference not found None if ratio_reference not found
""" """
object_ratio_list = self.contentValues(portal_type=\ object_ratio_list = self.contentValues(portal_type=\
...@@ -147,16 +146,16 @@ class PaySheetTransaction(Invoice): ...@@ -147,16 +146,16 @@ class PaySheetTransaction(Invoice):
for cell in good_cell_list: for cell in good_cell_list:
cell_cat_list = cell['axe_list'] cell_cat_list = cell['axe_list']
paycell = payline.newCell(base_id = base_id, *cell_cat_list) paycell = payline.newCell(base_id = base_id, *cell_cat_list)
# if the quantity 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 cell['price']:
price = cell['price'] price = cell['price']
else: else:
price = 1 price = 1
paycell.edit( mapped_value_property_list = ('price', 'quantity') paycell.edit( mapped_value_property_list = ('price', 'quantity'),
, quantity = cell['quantity'] quantity = cell['quantity'],
, price = price price = price,
, force_update = 1 force_update = 1,
, category_list = cell_cat_list category_list = cell_cat_list,
) )
return payline return payline
...@@ -171,18 +170,19 @@ class PaySheetTransaction(Invoice): ...@@ -171,18 +170,19 @@ class PaySheetTransaction(Invoice):
the values of the editables lines and create corresponding the values of the editables lines and create corresponding
PaySheetLines with this values PaySheetLines with this values
''' '''
paysheet = self paysheet = self
item_dict = {}
paysheet_items = {} model_line_id_list = []
for line in listbox: for cell in listbox:
model_line = paysheet.getPortalObject().restrictedTraverse(\ model_line = paysheet.getPortalObject().restrictedTraverse(\
line['model_line']) cell['model_line'])
model_line_id = model_line.getId()
service = model_line.getResourceValue() service = model_line.getResourceValue()
service_id = service.getId() service_id = service.getId()
quantity = line['quantity'] quantity = cell['quantity']
price = line['price'] price = cell['price']
tax_category = line['tax_category_relative_url'] tax_category = cell['tax_category_relative_url']
salary_range = cell['salary_range_relative_url']
variation_category_list = model_line.getVariationCategoryList(\ variation_category_list = model_line.getVariationCategoryList(\
base_category_list='salary_range') base_category_list='salary_range')
...@@ -192,53 +192,42 @@ class PaySheetTransaction(Invoice): ...@@ -192,53 +192,42 @@ class PaySheetTransaction(Invoice):
if category.startswith('salary_range/'): if category.startswith('salary_range/'):
salary_range_categories.append(category) salary_range_categories.append(category)
# perhaps here it will be necesary to raise an error ? new_cell = { 'axe_list' : [tax_category,salary_range],
if not paysheet_items.has_key(service_id): 'quantity' : quantity,
paysheet_items[service_id] = { 'price' : price,
'title' : model_line.getTitleOrId(), }
'desc' : [],
'base_amount_list' : model_line.getBaseAmountList(), if item_dict.has_key(model_line_id):
'res' : service.getRelativeUrl(), # an item for this model_line_id already exists
'int_index' : model_line.getFloatIndex(), item_dict[model_line_id]['cell_list'].append(new_cell)
'cell_list' : [] else:
} if model_line.getDescription():
desc = model_line.getDescription()
# create cells if a value has been entered else:
if quantity or price: desc = model_line.getResourceValue().getDescription()
for salary_range in salary_range_categories:
# Define an empty new cell model_line_id_list.append(model_line_id)
new_cell = None # create a new item
new_cell = { 'axe_list' : [tax_category,salary_range] item_dict[model_line_id]={\
, 'quantity' : quantity 'title' : model_line.getTitleOrId(),
, 'price' : price 'res' : model_line.getResourceValue().getRelativeUrl(),
} 'desc' : desc,
# Add the cell to the conresponding paysheet item 'cell_list' : [new_cell],
if new_cell: 'int_index' : model_line.getFloatIndex(),
paysheet_items[service_id]['cell_list'].append(new_cell) 'base_amount_list' : model_line.getBaseAmountList(),
# Save the comment as description }
if model_line.getDescription():
paysheet_items[service_id]['desc'].append(\ for model_line_id in model_line_id_list:
model_line.getDescription()) item = item_dict[model_line_id]
else: paysheet.createPaySheetLine(title = item['title'],
resource_description = \ res = item['res'],
model_line.getResourceValue().getDescription() desc = item['desc'],
paysheet_items[service_id]['desc'].append(resource_description) cell_list = item['cell_list'],
int_index = item['int_index'],
# Create a paysheet item for each service with user data in it base_amount_list = item['base_amount_list'])
for item in paysheet_items.values():
if item['cell_list']:
if len(item['desc']) > 0:
desc = '\n'.join(item['desc'])
else:
desc = None
paysheet.createPaySheetLine(
title = item['title'],
res = item['res'],
desc = desc,
cell_list = item['cell_list'],
int_index = item['int_index'],
base_amount_list=item['base_amount_list'],)
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
'createNotEditablePaySheetLineList') 'createNotEditablePaySheetLineList')
...@@ -364,7 +353,7 @@ class PaySheetTransaction(Invoice): ...@@ -364,7 +353,7 @@ class PaySheetTransaction(Invoice):
calculation_script = getattr(self, script_name, None) calculation_script = getattr(self, script_name, None)
quantity=0 quantity=0
price=0 price=0
LOG('script_name :', 0, script_name) #LOG('script_name :', 0, script_name)
result = calculation_script(\ result = calculation_script(\
base_amount_current_value_dict=base_amount_current_value_dict, base_amount_current_value_dict=base_amount_current_value_dict,
model_slice_min=model_slice_min, model_slice_min=model_slice_min,
......
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