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,52 +192,41 @@ class PaySheetTransaction(Invoice): ...@@ -192,52 +192,41 @@ 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(),
'res' : service.getRelativeUrl(),
'int_index' : model_line.getFloatIndex(),
'cell_list' : []
} }
# create cells if a value has been entered if item_dict.has_key(model_line_id):
if quantity or price: # an item for this model_line_id already exists
for salary_range in salary_range_categories: item_dict[model_line_id]['cell_list'].append(new_cell)
# Define an empty new cell
new_cell = None
new_cell = { 'axe_list' : [tax_category,salary_range]
, 'quantity' : quantity
, 'price' : price
}
# Add the cell to the conresponding paysheet item
if new_cell:
paysheet_items[service_id]['cell_list'].append(new_cell)
# Save the comment as description
if model_line.getDescription():
paysheet_items[service_id]['desc'].append(\
model_line.getDescription())
else: else:
resource_description = \ if model_line.getDescription():
model_line.getResourceValue().getDescription() desc = model_line.getDescription()
paysheet_items[service_id]['desc'].append(resource_description)
# Create a paysheet item for each service with user data in it
for item in paysheet_items.values():
if item['cell_list']:
if len(item['desc']) > 0:
desc = '\n'.join(item['desc'])
else: else:
desc = None desc = model_line.getResourceValue().getDescription()
paysheet.createPaySheetLine(
title = item['title'], model_line_id_list.append(model_line_id)
# create a new item
item_dict[model_line_id]={\
'title' : model_line.getTitleOrId(),
'res' : model_line.getResourceValue().getRelativeUrl(),
'desc' : desc,
'cell_list' : [new_cell],
'int_index' : model_line.getFloatIndex(),
'base_amount_list' : model_line.getBaseAmountList(),
}
for model_line_id in model_line_id_list:
item = item_dict[model_line_id]
paysheet.createPaySheetLine(title = item['title'],
res = item['res'], res = item['res'],
desc = desc, desc = item['desc'],
cell_list = item['cell_list'], cell_list = item['cell_list'],
int_index = item['int_index'], int_index = item['int_index'],
base_amount_list=item['base_amount_list'],) base_amount_list = item['base_amount_list'])
security.declareProtected(Permissions.ModifyPortalContent, security.declareProtected(Permissions.ModifyPortalContent,
...@@ -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