[Erp5-report] r21632 - in /erp5/trunk/products/ERP5: Document/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Tue Jun 17 10:38:18 CEST 2008
Author: jerome
Date: Tue Jun 17 10:38:17 2008
New Revision: 21632
URL: http://svn.erp5.org?rev=21632&view=rev
Log:
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)
Modified:
erp5/trunk/products/ERP5/Document/PaySheetTransaction.py
erp5/trunk/products/ERP5/tests/testPayroll.py
Modified: erp5/trunk/products/ERP5/Document/PaySheetTransaction.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/PaySheetTransaction.py?rev=21632&r1=21631&r2=21632&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/PaySheetTransaction.py (original)
+++ erp5/trunk/products/ERP5/Document/PaySheetTransaction.py Tue Jun 17 10:38:17 2008
@@ -195,9 +195,6 @@
# 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 @@
quantity = cell_dict['quantity']
price = cell_dict['price']
- if quantity:
+ if quantity and price:
cell_list.append(cell_dict)
# update the base_participation
Modified: erp5/trunk/products/ERP5/tests/testPayroll.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testPayroll.py?rev=21632&r1=21631&r2=21632&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testPayroll.py (original)
+++ erp5/trunk/products/ERP5/tests/testPayroll.py Tue Jun 17 10:38:17 2008
@@ -224,7 +224,7 @@
'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 @@
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
More information about the Erp5-report
mailing list