Commit e4fd4cc3 authored by Jérome Perrin's avatar Jérome Perrin

Previously, if ratio was set to 0 or None on a model line, it was assumed that

the ratio was 100%. We want to separate it in two different cases:
 - ratio is 0 -> the line should not be created.
 - ratio is not set (ie. None) -> this means that no ratio apply here, it's a
   simple amount, so ratio default to 100%
Move this in the default calculation script so that it's possible to
change the behaviour.
Add tests for those two cases (price = None and price = 0)



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@21632 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5d4d67bd
......@@ -195,9 +195,6 @@ class PaySheetTransaction(Invoice):
# create cell_list
for cell in good_cell_list:
paycell = payline.newCell(base_id=base_id, *cell['category_list'])
# if the price aven't be completed, it should be set to 1 (=100%)
if not cell['price']:
cell['price'] = 1
paycell.edit(mapped_value_property_list=('price', 'quantity'),
force_update=1,
**cell)
......@@ -483,7 +480,7 @@ class PaySheetTransaction(Invoice):
quantity = cell_dict['quantity']
price = cell_dict['price']
if quantity:
if quantity and price:
cell_list.append(cell_dict)
# update the base_participation
......
......@@ -224,7 +224,7 @@ class TestPayrollMixin(ERP5ReportTestCase):
'base_amount/%s' % self.base_amount_base_salary,
'grade/%s' % self.grade_worker,
'grade/%s' % self.grade_engineer,
'quantity_unit/time/mounth',
'quantity_unit/time/month',
'group/demo_group',
'product_line/base_salary',
'product_line/payroll_tax_1',
......@@ -1373,6 +1373,57 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals(1, cell.getPrice())
self.assertEquals(100, cell.getQuantity())
def test_createPaySheetLineNonePrice(self):
# test the creation of lines when the price is not set, but only the
# quantity. This means that no ratio is applied on this line.
line = self.model.newContent(
id='line',
portal_type='Pay Sheet Model Line',
resource_value=self.labour,
variation_category_list=['tax_category/employee_share'],)
line.updateCellRange(base_id='movement')
cell = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement')
cell.setMappedValuePropertyList(('quantity', 'price'))
cell.setVariationCategoryList(('tax_category/employee_share',))
cell.setQuantity(5)
pay_sheet = self.createPaySheet(self.model)
pay_sheet.PaySheetTransaction_createAllPaySheetLineList()
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(1, len(pay_sheet_line_list))
pay_sheet_line = pay_sheet_line_list[0]
self.assertEquals(self.labour, pay_sheet_line.getResourceValue())
cell = pay_sheet_line.getCell('tax_category/employee_share',
base_id='movement')
self.assertNotEquals(None, cell)
self.assertEquals(1, cell.getPrice())
self.assertEquals(5, cell.getQuantity())
def test_createPaySheetLineZeroPrice(self):
# test the creation of lines when the price is set to zero: the line should
# not be created.
line = self.model.newContent(
id='line',
portal_type='Pay Sheet Model Line',
resource_value=self.labour,
variation_category_list=['tax_category/employee_share'],)
line.updateCellRange(base_id='movement')
cell = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement')
cell.setMappedValuePropertyList(('quantity', 'price'))
cell.setVariationCategoryList(('tax_category/employee_share',))
cell.setQuantity(5)
cell.setPrice(0)
pay_sheet = self.createPaySheet(self.model)
pay_sheet.PaySheetTransaction_createAllPaySheetLineList()
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(0, len(pay_sheet_line_list))
def test_paysheet_consistency(self):
# minimal test for checkConsistency on a Pay Sheet Transaction and its
......
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