diff --git a/product/ERP5/Document/PaySheetTransaction.py b/product/ERP5/Document/PaySheetTransaction.py index 310c217fc5cbac157e40af03d9e66a8c7dc73110..0818818c73a8652a1878174e7fe226c7badfb630 100644 --- a/product/ERP5/Document/PaySheetTransaction.py +++ b/product/ERP5/Document/PaySheetTransaction.py @@ -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 diff --git a/product/ERP5/tests/testPayroll.py b/product/ERP5/tests/testPayroll.py index b0d436287d895f93bd9628bf2b35ac31b24878c5..7d8d8cb1014ad0e376825b52494cd1f433cd959f 100644 --- a/product/ERP5/tests/testPayroll.py +++ b/product/ERP5/tests/testPayroll.py @@ -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