[Erp5-report] r27384 - /erp5/trunk/products/ERP5/tests/testNewPayroll.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Fri Jun 5 10:42:21 CEST 2009
Author: fabien
Date: Fri Jun 5 10:42:18 2009
New Revision: 27384
URL: http://svn.erp5.org?rev=27384&view=rev
Log:
add test to check slices works
Modified:
erp5/trunk/products/ERP5/tests/testNewPayroll.py
Modified: erp5/trunk/products/ERP5/tests/testNewPayroll.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testNewPayroll.py?rev=27384&r1=27383&r2=27384&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testNewPayroll.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testNewPayroll.py [utf8] Fri Jun 5 10:42:18 2009
@@ -101,6 +101,9 @@
'salary_range/france/slice_b',
'salary_range/france/slice_c',
'salary_range/france/forfait',
+ 'salary_range/france/slice_0_to_200',
+ 'salary_range/france/slice_200_to_400',
+ 'salary_range/france/slice_400_to_5000',
)
def getBusinessTemplateList(self):
@@ -167,6 +170,27 @@
employee = sequence.get('employee')
model.edit(destination_section_value=employer,
source_section_value=employee)
+ sequence.edit(model = model)
+
+ def addSlice(self, model, slice, min_value, max_value, base_id='cell'):
+ '''add a new slice in the model'''
+ slice_value = model.newCell(slice, portal_type='Pay Sheet Model Slice',
+ base_id=base_id)
+ slice_value.setQuantityRangeMax(max_value)
+ slice_value.setQuantityRangeMin(min_value)
+ return slice_value
+
+ def stepCreateModelWithSlices(self, sequence=None, **kw):
+ model = self.createModel()
+ employer = sequence.get('employer')
+ employee = sequence.get('employee')
+ model.edit(destination_section_value=employer,
+ source_section_value=employee)
+ model.setVariationSettingsCategoryList(\
+ ['salary_range/france'])
+ self.addSlice(model, 'salary_range/france/slice_0_to_200', 0, 200)
+ self.addSlice(model, 'salary_range/france/slice_200_to_400', 200, 400)
+ self.addSlice(model, 'salary_range/france/slice_400_to_5000', 400, 5000)
sequence.edit(model = model)
def createModelLine(self, document, **kw):
@@ -186,6 +210,23 @@
base_contribution_list=['base_amount/deductible_tax'])
sequence.edit(urssaf_model_line = model_line)
+ def stepModelCreateUrssafModelLineWithSlices(self, sequence=None, **kw):
+ model = sequence.get('model')
+ model_line = self.createModelLine(model)
+ model_line.edit(title='Urssaf',
+ int_index=2,
+ reference='urssaf_model_line',
+ trade_phase='trade_phase/payroll/france/urssaf',
+ resource_value=sequence.get('urssaf_payroll_service'),
+ variation_category_list=['tax_category/employee_share',
+ 'tax_category/employer_share',
+ 'salary_range/france/slice_0_to_200',
+ 'salary_range/france/slice_200_to_400',
+ 'salary_range/france/slice_400_to_5000'],
+ base_application_list=[ 'base_amount/base_salary'],
+ base_contribution_list=['base_amount/deductible_tax'])
+ sequence.edit(urssaf_model_line_with_slices = model_line)
+
def stepPaysheetCreateUrssafModelLine(self, sequence=None, **kw):
paysheet = sequence.get('paysheet')
model_line = self.createModelLine(paysheet)
@@ -213,6 +254,51 @@
mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.5, tax_category='employer_share')
+ def stepUrssafModelLineWithSlicesCreateMovements(self, sequence=None, **kw):
+ model_line = sequence.get('urssaf_model_line_with_slices')
+ cell1 = model_line.newCell('tax_category/employee_share',
+ 'salary_range/france/slice_0_to_200',
+ portal_type='Pay Sheet Model Cell',
+ base_id='movement',
+ mapped_value_property_list=('quantity', 'price'))
+ cell1.edit(price=0.1, tax_category='employee_share',
+ salary_range='france/slice_0_to_200')
+ cell2 = model_line.newCell('tax_category/employer_share',
+ 'salary_range/france/slice_0_to_200',
+ portal_type='Pay Sheet Model Cell',
+ base_id='movement',
+ mapped_value_property_list=('quantity', 'price'))
+ cell2.edit(price=0.2, tax_category='employer_share',
+ salary_range='france/slice_0_to_200')
+ cell3 = model_line.newCell('tax_category/employee_share',
+ 'salary_range/france/slice_200_to_400',
+ portal_type='Pay Sheet Model Cell',
+ base_id='movement',
+ mapped_value_property_list=('quantity', 'price'))
+ cell3.edit(price=0.3, tax_category='employee_share',
+ salary_range='france/slice_200_to_400')
+ cell4 = model_line.newCell('tax_category/employer_share',
+ 'salary_range/france/slice_200_to_400',
+ portal_type='Pay Sheet Model Cell',
+ base_id='movement',
+ mapped_value_property_list=('quantity', 'price'))
+ cell4.edit(price=0.4, tax_category='employer_share',
+ salary_range='france/slice_200_to_400')
+ cell5 = model_line.newCell('tax_category/employee_share',
+ 'salary_range/france/slice_400_to_5000',
+ portal_type='Pay Sheet Model Cell',
+ base_id='movement',
+ mapped_value_property_list=('quantity', 'price'))
+ cell5.edit(price=0.5, tax_category='employee_share',
+ salary_range='france/slice_400_to_5000')
+ cell6 = model_line.newCell('tax_category/employer_share',
+ 'salary_range/france/slice_400_to_5000',
+ portal_type='Pay Sheet Model Cell',
+ base_id='movement',
+ mapped_value_property_list=('quantity', 'price'))
+ cell6.edit(price=0.6, tax_category='employer_share',
+ salary_range='france/slice_400_to_5000')
+
def stepPaysheetUrssafModelLineCreateMovements(self, sequence=None, **kw):
model_line = sequence.get('urssaf_model_line')
cell1 = model_line.newCell('tax_category/employee_share',
@@ -266,6 +352,12 @@
paysheet = sequence.get('paysheet')
self.checkUpdateAggregatedAmountListReturn(model, paysheet, 0, 2)
+ def stepCheckUpdateAggregatedAmountListReturnUsingSlices(self,
+ sequence=None, **kw):
+ model = sequence.get('model')
+ paysheet = sequence.get('paysheet')
+ self.checkUpdateAggregatedAmountListReturn(model, paysheet, 0, 6)
+
def stepPaysheetApplyTransformation(self, sequence=None, **kw):
paysheet = sequence.get('paysheet')
paysheet.applyTransformation()
@@ -276,6 +368,14 @@
self.assertEqual(len(paysheet_line_list), 2)
self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 2) # 2 because labour line contain no movement
+
+ def stepCheckPaysheetLineAreCreatedUsingSlices(self, sequence=None, **kw):
+ paysheet = sequence.get('paysheet')
+ paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
+ self.assertEqual(len(paysheet_line_list), 2)
+ self.assertEqual(len(paysheet.getMovementList(portal_type=\
+ 'Pay Sheet Cell')), 6) # 6 because labour line contain no movement and
+ # because of the 3 slice and 2 tax_categories
def stepCheckPaysheetLineAmounts(self, sequence=None, **kw):
paysheet = sequence.get('paysheet')
@@ -289,6 +389,41 @@
cell2 = paysheet_line.getCell('tax_category/employer_share')
self.assertEquals(cell2.getQuantity(), 3000)
self.assertEquals(cell2.getPrice(), 0.5)
+ elif service == 'Labour':
+ self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
+ else:
+ self.fail("Unknown service for line %s" % paysheet_line.getTitle())
+
+ def stepCheckPaysheetLineAmountsUsingSlices(self, sequence=None, **kw):
+ paysheet = sequence.get('paysheet')
+ paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
+ for paysheet_line in paysheet_line_list:
+ service = paysheet_line.getResourceTitle()
+ if service == 'Urssaf':
+ cell1 = paysheet_line.getCell('tax_category/employee_share',
+ 'salary_range/france/slice_0_to_200')
+ self.assertEquals(cell1.getQuantity(), 200)
+ self.assertEquals(cell1.getPrice(), 0.1)
+ cell2 = paysheet_line.getCell('tax_category/employer_share',
+ 'salary_range/france/slice_0_to_200')
+ self.assertEquals(cell2.getQuantity(), 200)
+ self.assertEquals(cell2.getPrice(), 0.2)
+ cell3 = paysheet_line.getCell('tax_category/employee_share',
+ 'salary_range/france/slice_200_to_400')
+ self.assertEquals(cell3.getQuantity(), 200)
+ self.assertEquals(cell3.getPrice(), 0.3)
+ cell4 = paysheet_line.getCell('tax_category/employer_share',
+ 'salary_range/france/slice_200_to_400')
+ self.assertEquals(cell4.getQuantity(), 200)
+ self.assertEquals(cell4.getPrice(), 0.4)
+ cell5 = paysheet_line.getCell('tax_category/employee_share',
+ 'salary_range/france/slice_400_to_5000')
+ self.assertEquals(cell5.getQuantity(), 2600)
+ self.assertEquals(cell5.getPrice(), 0.5)
+ cell6 = paysheet_line.getCell('tax_category/employer_share',
+ 'salary_range/france/slice_400_to_5000')
+ self.assertEquals(cell6.getQuantity(), 2600)
+ self.assertEquals(cell6.getPrice(), 0.6)
elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else:
@@ -889,6 +1024,36 @@
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
+ def test_sliceOnModelLine(self):
+ '''
+ It's possible to define some slices on model, and use it on model lines.
+ Check that works and that after appy transformation, amounts are goods
+ '''
+ sequence_list = SequenceList()
+ sequence_string = self.COMMON_BASIC_DOCUMENT_CREATION_SEQUENCE_STRING + """
+ CreateUrssafPayrollService
+ CreateLabourPayrollService
+ CreateEmployer
+ CreateEmployee
+ CreateModelWithSlices
+ Tic
+ ModelCreateUrssafModelLineWithSlices
+ Tic
+ UrssafModelLineWithSlicesCreateMovements
+ CreateBasicPaysheet
+ PaysheetCreateLabourPaySheetLine
+ """ + self.BUSINESS_PATH_CREATION_SEQUENCE_STRING + """
+ CheckUpdateAggregatedAmountListReturnUsingSlices
+ PaysheetApplyTransformation
+ Tic
+ CheckPaysheetLineAreCreatedUsingSlices
+ CheckPaysheetLineAmountsUsingSlices
+ CheckUpdateAggregatedAmountListReturnNothing
+ CheckPaysheetLineAmountsUsingSlices
+ """
+ sequence_list.addSequenceString(sequence_string)
+ sequence_list.play(self)
+
import unittest
def test_suite():
suite = unittest.TestSuite()
More information about the Erp5-report
mailing list