Commit 67b5a84b authored by Fabien Morin's avatar Fabien Morin

remove some tests that were been rewrited in testNewPayroll.

In the future, testNewPayroll will replace testPayroll, but for now, old tests that are not yet rewrited for new payroll are kept as a reminder.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27454 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 63aaf0ab
...@@ -509,282 +509,6 @@ class TestPayrollMixin(ERP5ReportTestCase): ...@@ -509,282 +509,6 @@ class TestPayrollMixin(ERP5ReportTestCase):
class TestPayroll(TestPayrollMixin): class TestPayroll(TestPayrollMixin):
quiet = 0
def test_01_modelCreation(self):
'''
test the function createModel and test if the model has been well created
'''
if hasattr(self.paysheet_model_module, self.model_id):
self.paysheet_model_module.manage_delObjects([self.model_id])
model_count_before_add = \
len(self.paysheet_model_module.contentValues(portal_type=\
self.paysheet_model_portal_type))
self.model = self.createModel(self.model_id,
self.model_title,
self.person_id,
self.person_title,
self.person_career_grade,
self.organisation_id,
self.organisation_title,
self.variation_settings_category_list,
self.price_currency)
model_count_after_add = \
len(self.paysheet_model_module.contentValues(portal_type=\
self.paysheet_model_portal_type))
# check that the number of model_lines has been incremented
self.assertEqual(model_count_before_add+1, model_count_after_add)
#check model have been well created
self.model = self.paysheet_model_module._getOb(self.model_id)
self.assertEqual(self.model_id, self.model.getId())
self.assertEqual(self.model_title, self.model.getTitle())
self.assertEqual(self.organisation_title,
self.model.getDestinationSectionTitle())
self.assertEqual(self.person_title, self.model.getSourceSectionTitle())
self.assertEqual(self.variation_settings_category_list,
self.model.getVariationSettingsCategoryList(base=1))
def test_02_addModelLine(self):
'''
create a Model Line and test if it has been well created
'''
#model = self.createModel()
self.addAllSlices(self.model)
payroll_service_portal_type = 'Payroll Service'
payroll_service_module = self.portal.getDefaultModule(\
portal_type=payroll_service_portal_type)
model_line_id = 'URSSAF'
variation_category_list = self.urssaf_share_list + self.urssaf_slice_list
model_line_count_before_add = len(self.model.contentValues(portal_type=\
self.paysheet_model_line_portal_type))
returned_model_line = self.createModelLine(
model=self.model,
id=model_line_id,
variation_category_list=variation_category_list,
resource=self.urssaf,
share_list=self.urssaf_share_list,
slice_list=self.urssaf_slice_list,
values=[[[None, 0.01], [None, 0.02],[None, 0.03]], [[None, 0.04],
[None, 0.05], [None, 0.06]]],
base_application_list=['base_amount/base_salary',],
base_contribution_list=['base_amount/deductible_tax',])
model_line_count_after_add = len(self.model.contentValues(portal_type=\
self.paysheet_model_line_portal_type))
# check that the number of model_lines has been incremented
self.assertEqual(model_line_count_before_add+1, model_line_count_after_add)
model_line = self.model._getOb(model_line_id)
self.assertEqual(returned_model_line, model_line)
self.assertEqual(model_line_id, model_line.getId())
payroll_service_portal_type = 'Payroll Service'
payroll_service_module = self.portal.getDefaultModule(\
portal_type=payroll_service_portal_type)
resource = payroll_service_module._getOb(self.urssaf_id)
self.assertEqual(resource, model_line.getResourceValue())
self.assertEqual(variation_category_list,
model_line.getVariationCategoryList())
def test_03_createPaySheet(self):
'''
create a Pay Sheet with the model specialisation and verify it was well
created
'''
paysheet_id = 'my_paysheet'
paysheet_returned = self.createPaySheet(self.model, paysheet_id)
paysheet_module = self.portal.getDefaultModule(\
portal_type=self.paysheet_transaction_portal_type)
paysheet = paysheet_module._getOb(paysheet_id)
self.assertEqual(paysheet_returned, paysheet)
self.assertEqual(paysheet_id, paysheet.getId())
self.assertEqual(paysheet.getDestinationSectionTitle(),
self.model.getDestinationSectionTitle())
self.assertEqual(paysheet.getSourceSectionTitle(),
self.model.getSourceSectionTitle())
self.assertEqual(paysheet.getSpecialiseValue(), self.model)
def test_04_paySheetCalculation(self):
'''
test if the scripts called by the 'Calculation of the Pay Sheet
Transaction' action create the paysheet lines
'''
self.addAllSlices(self.model)
model_line_id1 = 'urssaf'
model_line_id2 = 'salary'
urssaf_slice_list = [ 'salary_range/'+self.france_settings_slice_a,
'salary_range/'+self.france_settings_slice_b,
'salary_range/'+self.france_settings_slice_c]
urssaf_share_list = [ 'tax_category/'+self.tax_category_employee_share,
'tax_category/'+self.tax_category_employer_share]
salary_slice_list = ['salary_range/'+self.france_settings_forfait,]
salary_share_list = ['tax_category/'+self.tax_category_employee_share,]
variation_category_list_urssaf = urssaf_share_list + urssaf_slice_list
variation_category_list_salary = salary_share_list + salary_slice_list
model_line1 = self.createModelLine(model=self.model,
id=model_line_id1,
variation_category_list=variation_category_list_urssaf,
resource=self.urssaf,
share_list=self.urssaf_share_list,
slice_list=self.urssaf_slice_list,
values=[[[None, 0.01], [None, 0.02], [None, 0.03]], [[None, 0.04],
[None, 0.05], [None, 0.06]]],
source_value=self.payroll_service_organisation,
base_application_list=[ 'base_amount/base_salary'],
base_contribution_list=['base_amount/deductible_tax',])
model_line2 = self.createModelLine(model=self.model,
id=model_line_id2,
variation_category_list=variation_category_list_salary,
resource=self.labour,
share_list=self.salary_share_list,
slice_list=self.salary_slice_list,
values=[[[10000, None],],],
base_application_list=[],
base_contribution_list=['base_amount/base_salary', 'base_amount/gross_salary'])
pay_sheet_line_count = len(self.model.contentValues(portal_type=\
self.paysheet_line_portal_type)) + 2 # because in this test, 2 lines
# are added
paysheet = self.createPaySheet(self.model)
paysheet_line_count_before_calculation = \
len(paysheet.contentValues(portal_type= \
self.paysheet_line_portal_type))
# calculate the pay sheet
pay_sheet_line_list = self.calculatePaySheet(paysheet=paysheet)
paysheet_line_count_after_calculation = \
len(paysheet.contentValues(portal_type= \
self.paysheet_line_portal_type))
self.assertEqual(paysheet_line_count_before_calculation, 0)
self.assertEqual(paysheet_line_count_after_calculation,
pay_sheet_line_count)
# check the amount in the cells of the created paysheet lines
for pay_sheet_line in pay_sheet_line_list:
service = pay_sheet_line.getResourceId()
if service == self.urssaf_id:
i = 1
correct_value_slice_list = [0, self.plafond, self.plafond*4,
self.plafond*8]
self.assertEqualAmounts(pay_sheet_line, correct_value_slice_list,
10000, i)
self.assertEquals(
[self.payroll_service_organisation.getRelativeUrl()],
pay_sheet_line._getCategoryMembershipList('source_section'))
# check the base_contribution has been copied from the pay sheet model
# to the pay sheet line
self.assertEquals(model_line1.getBaseContributionList(),
pay_sheet_line.getBaseContributionList())
elif service == self.labour_id:
cell = pay_sheet_line.getCell(\
'tax_category/'+ self.tax_category_employee_share,
'salary_range/'+ self.france_settings_forfait)
value = cell.getTotalPrice()
self.assertEqual(10000, value)
self.assertEquals([],
pay_sheet_line._getCategoryMembershipList('source_section'))
# check the base_contribution has been copied from the pay sheet model
# to the pay sheet line
self.assertEquals(model_line2.getBaseContributionList(),
pay_sheet_line.getBaseContributionList())
else:
self.fail("Unknown service for line %s" % pay_sheet_line)
def test_05_caculationWithANonNullMinimumValueSlice(self):
'''
if the is only slice B (without previous slice A), test that
the amount paid for this tax is correct
'''
self.addAllSlices(self.model)
model_line_id1 = 'urssaf'
model_line_id2 = 'salary'
base_salary = 10000
urssaf_slice_list = ['salary_range/'+self.france_settings_slice_b,]
variation_category_list_urssaf = self.urssaf_share_list + urssaf_slice_list
variation_category_list_salary = self.salary_share_list + \
self.salary_slice_list
model_line1 = self.createModelLine(model=self.model,
id=model_line_id1,
variation_category_list=variation_category_list_urssaf,
resource=self.urssaf, share_list=self.urssaf_share_list,
slice_list=urssaf_slice_list,
values=[[[None, 0.03]], [[None, 0.04]],],
base_application_list=[ 'base_amount/base_salary'],
base_contribution_list=['base_amount/deductible_tax',])
model_line2 = self.createModelLine(model=self.model,
id=model_line_id2,
variation_category_list=variation_category_list_salary,
resource=self.labour, share_list=self.salary_share_list,
slice_list=self.salary_slice_list,
values=[[[base_salary, None]],],
base_application_list=[],
base_contribution_list=['base_amount/base_salary', 'base_amount/gross_salary',])
pay_sheet_line_count = len(self.model.contentValues(portal_type=\
self.paysheet_line_portal_type)) + 2 # because in this test, 2 lines
# are added
paysheet = self.createPaySheet(self.model)
paysheet_line_count_before_calculation = \
len(paysheet.contentValues(portal_type= \
self.paysheet_line_portal_type))
# calculate the pay sheet
pay_sheet_line_list = self.calculatePaySheet(paysheet=paysheet)
paysheet_line_count_after_calculation = \
len(paysheet.contentValues(portal_type= \
self.paysheet_line_portal_type))
self.assertEqual(paysheet_line_count_before_calculation, 0)
self.assertEqual(paysheet_line_count_after_calculation,
pay_sheet_line_count)
# check the amount in the cells of the created paysheet lines
for pay_sheet_line in pay_sheet_line_list:
service = pay_sheet_line.getResourceId()
if service == self.urssaf_id:
i = 2 # the begining max slice
correct_value_slice_list = [0, self.plafond, self.plafond*4,
self.plafond*8]
self.assertEqualAmounts(pay_sheet_line, correct_value_slice_list,
base_salary, i)
elif service == self.labour_id:
cell = pay_sheet_line.getCell('tax_category/'+\
self.tax_category_employee_share,
'salary_range/'+ self.france_settings_forfait)
value = cell.getTotalPrice()
self.assertEqual(base_salary, value)
else:
self.fail("Unknown service for line %s" % pay_sheet_line)
def test_06_model_inheritance(self): def test_06_model_inheritance(self):
''' '''
...@@ -979,9 +703,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -979,9 +703,6 @@ class TestPayroll(TestPayrollMixin):
# model_d model_c # model_d model_c
# ('5', '6') ('5', '6', '7', '8') # ('5', '6') ('5', '6', '7', '8')
self.assertEqual(set(model_reference_dict[model_employee.getRelativeUrl()]), self.assertEqual(set(model_reference_dict[model_employee.getRelativeUrl()]),
set(['1', 'over_time_duration'])) set(['1', 'over_time_duration']))
self.assertEqual(set(model_reference_dict[model_company.getRelativeUrl()]), self.assertEqual(set(model_reference_dict[model_company.getRelativeUrl()]),
...@@ -1015,131 +736,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -1015,131 +736,6 @@ class TestPayroll(TestPayrollMixin):
sub_object_list = paysheet.getInheritedObjectValueList(portal_type_list) sub_object_list = paysheet.getInheritedObjectValueList(portal_type_list)
self.assertEqual(len(sub_object_list), 11) self.assertEqual(len(sub_object_list), 11)
def test_07_model_getCell(self):
'''
Model objects have a overload method called getCell. This method first
call the XMLMatrix.getCell and if the cell is not found, call
getCell method in all it's inherited model until the cell is found or
the cell have been searched on all inherited models.
TODO : Currently, the method use a Depth-First Search algorithm, it will
be better to use Breadth-First Search one.
more about this on :
- http://en.wikipedia.org/wiki/Breadth-first_search
- http://en.wikipedia.org/wiki/Depth-first_search
'''
# create 3 models
model_employee = self.paysheet_model_module.newContent(id='model_employee',
portal_type='Pay Sheet Model')
model_employee.edit(variation_settings_category_list=
self.variation_settings_category_list)
model_company = self.paysheet_model_module.newContent(id='model_company',
portal_type='Pay Sheet Model')
model_company.edit(variation_settings_category_list=
self.variation_settings_category_list)
model_company_alt = self.paysheet_model_module.newContent(
id='model_company_alt',
portal_type='Pay Sheet Model')
model_company_alt.edit(variation_settings_category_list=
self.variation_settings_category_list)
model_country = self.paysheet_model_module.newContent(id='model_country',
portal_type='Pay Sheet Model')
model_country.edit(variation_settings_category_list=
self.variation_settings_category_list)
# add some cells in the models
self.addSlice(model_employee, 'salary_range/%s' % \
self.france_settings_slice_a, 0, 1)
self.addSlice(model_company, 'salary_range/%s' % \
self.france_settings_slice_b, 2, 3)
self.addSlice(model_company_alt, 'salary_range/%s' % \
self.france_settings_forfait, 20, 30)
self.addSlice(model_country, 'salary_range/%s' % \
self.france_settings_slice_c, 4, 5)
# inherite from each other
model_employee.setSpecialiseValueList((model_company, model_company_alt))
model_company.setSpecialiseValue(model_country)
# check getCell results
# check model_employee could access all cells
cell_a = model_employee.getCell('salary_range/%s' % \
self.france_settings_slice_a)
self.assertNotEqual(cell_a, None)
self.assertEqual(cell_a.getQuantityRangeMin(), 0)
self.assertEqual(cell_a.getQuantityRangeMax(), 1)
cell_b = model_employee.getCell('salary_range/%s' % \
self.france_settings_slice_b)
self.assertNotEqual(cell_b, None)
self.assertEqual(cell_b.getQuantityRangeMin(), 2)
self.assertEqual(cell_b.getQuantityRangeMax(), 3)
cell_forfait = model_employee.getCell('salary_range/%s' % \
self.france_settings_forfait)
self.assertNotEqual(cell_forfait, None)
self.assertEqual(cell_forfait.getQuantityRangeMin(), 20)
self.assertEqual(cell_forfait.getQuantityRangeMax(), 30)
cell_c = model_employee.getCell('salary_range/%s' % \
self.france_settings_slice_c)
self.assertNotEqual(cell_c, None)
self.assertEqual(cell_c.getQuantityRangeMin(), 4)
self.assertEqual(cell_c.getQuantityRangeMax(), 5)
# check model_company and model_company_alt could access just it's own cell
# and this of the country model
cell_a = model_company.getCell('salary_range/%s' % \
self.france_settings_slice_a)
self.assertEqual(cell_a, None)
cell_b = model_company.getCell('salary_range/%s' % \
self.france_settings_slice_b)
self.assertNotEqual(cell_b, None)
self.assertEqual(cell_b.getQuantityRangeMin(), 2)
self.assertEqual(cell_b.getQuantityRangeMax(), 3)
cell_forfait = model_company_alt.getCell('salary_range/%s' % \
self.france_settings_forfait)
self.assertNotEqual(cell_forfait, None)
self.assertEqual(cell_forfait.getQuantityRangeMin(), 20)
self.assertEqual(cell_forfait.getQuantityRangeMax(), 30)
cell_c = model_company.getCell('salary_range/%s' % \
self.france_settings_slice_c)
self.assertNotEqual(cell_c, None)
self.assertEqual(cell_c.getQuantityRangeMin(), 4)
self.assertEqual(cell_c.getQuantityRangeMax(), 5)
# check model_country could access just it's own cell
# model
cell_a = model_country.getCell('salary_range/%s' % \
self.france_settings_slice_a)
self.assertEqual(cell_a, None)
cell_b = model_country.getCell('salary_range/%s' % \
self.france_settings_slice_b)
self.assertEqual(cell_b, None)
cell_forfait = model_country.getCell('salary_range/%s' % \
self.france_settings_forfait)
self.assertEqual(cell_forfait, None)
cell_c = model_country.getCell('salary_range/%s' % \
self.france_settings_slice_c)
self.assertNotEqual(cell_c, None)
self.assertEqual(cell_c.getQuantityRangeMin(), 4)
self.assertEqual(cell_c.getQuantityRangeMax(), 5)
def test_model_slice_cell_range(self): def test_model_slice_cell_range(self):
base_id = 'cell' base_id = 'cell'
model_1 = self.paysheet_model_module.newContent( model_1 = self.paysheet_model_module.newContent(
...@@ -1183,7 +779,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -1183,7 +779,6 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals(2, self.assertEquals(2,
model_2.getCell('salary_range/france/tranche_a').getQuantityRangeMax()) model_2.getCell('salary_range/france/tranche_a').getQuantityRangeMax())
def test_PaySheetTransaction_getMovementList(self): def test_PaySheetTransaction_getMovementList(self):
# Tests PaySheetTransaction_getMovementList script # Tests PaySheetTransaction_getMovementList script
pay_sheet = self.createPaySheet(self.model) pay_sheet = self.createPaySheet(self.model)
...@@ -1221,240 +816,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -1221,240 +816,6 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals(5, movement.employer_share_quantity) self.assertEquals(5, movement.employer_share_quantity)
self.assertEquals(4*5, movement.employer_share_total_price) self.assertEquals(4*5, movement.employer_share_total_price)
def test_createEditablePaySheetLine(self):
# test the creation of lines with editable lines in the model
line = self.model.newContent(
id='line',
portal_type='Pay Sheet Model Line',
resource_value=self.labour,
variation_category_list=['tax_category/employee_share'],
editable=1)
# Note that it is required that the editable line contains at least one
# cell, to know which tax_category is used (employee share or employer
# share).
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.setPrice(1)
pay_sheet = self.createPaySheet(self.model)
# PaySheetTransaction_getEditableObjectLineList is the script used as list
# method to display editable lines in the dialog listbox
editable_line_list = pay_sheet\
.PaySheetTransaction_getEditableObjectLineList()
self.assertEquals(1, len(editable_line_list))
editable_line = editable_line_list[0]
self.assertEquals(1, editable_line.employee_share_price)
self.assertEquals(0, editable_line.employee_share_quantity)
self.assertEquals('paysheet_model_module/model_one/line',
editable_line.model_line)
self.assertEquals(None, editable_line.salary_range_relative_url)
# PaySheetTransaction_createAllPaySheetLineList is the script used to create line and cells in the
# paysheet using the listbox input
pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0',
employee_share_price=1,
employee_share_quantity=2,
model_line='paysheet_model_module/model_one/line',
salary_range_relative_url='',)])
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(2, cell.getQuantity())
# if the script is called again, previous content is erased.
pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0',
employee_share_price=0.5,
employee_share_quantity=10,
model_line='paysheet_model_module/model_one/line',
salary_range_relative_url='',)])
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(0.5, cell.getPrice())
self.assertEquals(10, cell.getQuantity())
# If the user enters a null quantity, the line will not be created
pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0',
employee_share_price=1,
employee_share_quantity=0,
model_line='paysheet_model_module/model_one/line',
salary_range_relative_url='',)])
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(0, len(pay_sheet_line_list))
def test_createEditablePaySheetLineAppliedToBase(self):
# test the creation of lines with editable lines in the model, when those
# editable lines applies to a base
# line1 will contribute to 'base_salary'
line1 = self.model.newContent(
id='line1',
portal_type='Pay Sheet Model Line',
resource_value=self.labour,
variation_category_list=['tax_category/employee_share'],
base_application_list= [],
base_contribution_list=['base_amount/base_salary',
'base_amount/gross_salary'],
float_index=1,
int_index=1)
cell = line1.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement')
cell.setMappedValuePropertyList(('quantity', 'price'))
cell.setVariationCategoryList(('tax_category/employee_share',))
cell.setPrice(1)
cell.setQuantity(100)
# line2 will apply to 'base_salary', but we'll set 0 quantity in the dialog
line2 = self.model.newContent(
id='line2',
portal_type='Pay Sheet Model Line',
resource_value=self.labour,
variation_category_list=['tax_category/employee_share'],
base_application_list= [],
base_contribution_list=['base_amount/base_salary',
'base_amount/gross_salary'],
#base_amount_list=['base_salary'],
editable=1,
float_index=2,
int_index=2)
cell = line2.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement')
cell.setMappedValuePropertyList(('quantity', 'price'))
cell.setVariationCategoryList(('tax_category/employee_share',))
cell.setPrice(1)
pay_sheet = self.createPaySheet(self.model)
# PaySheetTransaction_getEditableObjectLineList is the script used as list
# method to display editable lines in the dialog listbox
editable_line_list = pay_sheet\
.PaySheetTransaction_getEditableObjectLineList()
self.assertEquals(1, len(editable_line_list))
editable_line = editable_line_list[0]
self.assertEquals(1, editable_line.employee_share_price)
self.assertEquals(0, editable_line.employee_share_quantity)
self.assertEquals('paysheet_model_module/model_one/line2',
editable_line.model_line)
self.assertEquals(None, editable_line.salary_range_relative_url)
# PaySheetTransaction_createAllPaySheetLineList is the script used to create line and cells in the
# paysheet using the listbox input
pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0',
employee_share_price=.5,
employee_share_quantity=4,
model_line='paysheet_model_module/model_one/line2',
salary_range_relative_url='',)])
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(2, len(pay_sheet_line_list))
pay_sheet_line1 = [l for l in pay_sheet_line_list
if l.getIntIndex() == 1][0]
self.assertEquals(self.labour, pay_sheet_line1.getResourceValue())
cell = pay_sheet_line1.getCell('tax_category/employee_share',
base_id='movement')
self.assertNotEquals(None, cell)
self.assertEquals(1, cell.getPrice())
self.assertEquals(100, cell.getQuantity())
pay_sheet_line2 = [l for l in pay_sheet_line_list
if l.getIntIndex() == 2][0]
self.assertEquals(self.labour, pay_sheet_line2.getResourceValue())
cell = pay_sheet_line2.getCell('tax_category/employee_share',
base_id='movement')
self.assertNotEquals(None, cell)
self.assertEquals(.5, cell.getPrice())
self.assertEquals(4, cell.getQuantity())
# if the script is called again, previous content is erased.
pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0',
employee_share_price=0.6,
employee_share_quantity=10,
model_line='paysheet_model_module/model_one/line2',
salary_range_relative_url='',)])
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(2, len(pay_sheet_line_list))
pay_sheet_line1 = [l for l in pay_sheet_line_list
if l.getIntIndex() == 1][0]
self.assertEquals(self.labour, pay_sheet_line1.getResourceValue())
cell = pay_sheet_line1.getCell('tax_category/employee_share',
base_id='movement')
self.assertNotEquals(None, cell)
self.assertEquals(1, cell.getPrice())
self.assertEquals(100, cell.getQuantity())
pay_sheet_line2 = [l for l in pay_sheet_line_list
if l.getIntIndex() == 2][0]
self.assertEquals(self.labour, pay_sheet_line2.getResourceValue())
cell = pay_sheet_line2.getCell('tax_category/employee_share',
base_id='movement')
self.assertNotEquals(None, cell)
self.assertEquals(0.6, cell.getPrice())
self.assertEquals(10, cell.getQuantity())
# If the user enters a null quantity, the line will not be created
pay_sheet.PaySheetTransaction_createAllPaySheetLineList(
listbox=[dict(listbox_key='0',
employee_share_price=1,
employee_share_quantity=0,
model_line='paysheet_model_module/model_one/line2',
salary_range_relative_url='',)])
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(1, len(pay_sheet_line_list))
pay_sheet_line1 = [l for l in pay_sheet_line_list
if l.getIntIndex() == 1][0]
self.assertEquals(self.labour, pay_sheet_line1.getResourceValue())
cell = pay_sheet_line1.getCell('tax_category/employee_share',
base_id='movement')
self.assertNotEquals(None, cell)
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'],
base_contribution_list=['base_amount/base_salary', 'base_amount/gross_salary'])
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): def test_createPaySheetLineZeroPrice(self):
# test the creation of lines when the price is set to zero: the line should # test the creation of lines when the price is set to zero: the line should
# not be created. # not be created.
...@@ -1478,37 +839,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -1478,37 +839,6 @@ class TestPayroll(TestPayrollMixin):
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line') pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(0, len(pay_sheet_line_list)) self.assertEquals(0, len(pay_sheet_line_list))
def test_paysheet_consistency(self):
# minimal test for checkConsistency on a Pay Sheet Transaction and its
# subdocuments (may have to be updated when we'll add more constraints).
paysheet = self.createPaySheet(self.model)
paysheet.setResourceValue(self.portal.currency_module.EUR)
paysheet.newContent(portal_type='Pay Sheet Line')
paysheet.newContent(portal_type='Pay Sheet Transaction Line')
paysheet.newContent(portal_type='Annotation Line')
paysheet.newContent(portal_type='Pay Sheet Model Ratio Line')
paysheet.newContent(portal_type='Payment Condition')
self.assertEquals([], paysheet.checkConsistency())
def test_paysheet_model_consistency(self):
# minimal test for checkConsistency on a Pay Sheet Model and its
# subdocuments (may have to be updated when we'll add more constraints).
model = self.model
model.newContent(portal_type='Pay Sheet Model Line') # XXX this one needs a
# resource
model.newContent(portal_type='Annotation Line')
model.newContent(portal_type='Pay Sheet Model Ratio Line')
model.newContent(portal_type='Payment Condition')
self.assertEquals([], model.checkConsistency())
def test_payroll_service_consistency(self):
# minimal test for checkConsistency on a Payroll Service
service = self.portal.payroll_service_module.newContent(
portal_type='Payroll Service')
service.setVariationBaseCategoryList(['tax_category'])
service.setVariationCategoryList(['tax_category/employee_share'])
self.assertEquals([], service.checkConsistency())
def test_apply_model(self): def test_apply_model(self):
eur = self.portal.currency_module.EUR eur = self.portal.currency_module.EUR
employee = self.portal.person_module.newContent( employee = self.portal.person_module.newContent(
...@@ -1613,60 +943,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -1613,60 +943,6 @@ class TestPayroll(TestPayrollMixin):
paysheet.PaySheetTransaction_applyModel() paysheet.PaySheetTransaction_applyModel()
self.assertEquals(2, len(paysheet.contentValues())) self.assertEquals(2, len(paysheet.contentValues()))
def test_calculate_paysheet_source_annotation_line_reference(self):
# the payroll service provider can be specified using the reference of an
# annotation line.
eur = self.portal.currency_module.EUR
employee = self.portal.person_module.newContent(
portal_type='Person',
title='Employee')
employer = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Employer')
provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Payroll Service Provider')
model = self.portal.paysheet_model_module.newContent(
portal_type='Pay Sheet Model',
source_section_value=employee,
destination_section_value=employer,
price_currency_value=eur,)
model_line = model.newContent(
portal_type='Pay Sheet Model Line',
resource_value=self.urssaf,
variation_category_list=['tax_category/employee_share'],
source_annotation_line_reference='tax1',
base_contribution_list = ['base_amount/deductible_tax',],)
cell = model_line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement')
cell.setMappedValuePropertyList(('quantity', 'price'))
cell.setPrice(10)
cell.setQuantity(10)
annotation = model.newContent(
portal_type='Annotation Line',
reference='tax1',
source_value=provider)
paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
specialise_value=model)
paysheet.PaySheetTransaction_applyModel()
paysheet.createPaySheetLineList()
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(1, len(paysheet_line_list))
paysheet_line = paysheet_line_list[0]
self.assertEquals([provider.getRelativeUrl()],
paysheet_line._getCategoryMembershipList('source_section'))
self.assertEquals(self.urssaf, paysheet_line.getResourceValue())
self.assertEquals(100, paysheet_line.getTotalPrice())
self.assertEquals(['tax_category/employee_share'],
paysheet_line.getVariationCategoryList())
def test_PayrollTaxesReport(self): def test_PayrollTaxesReport(self):
eur = self.portal.currency_module.EUR eur = self.portal.currency_module.EUR
payroll_service = self.portal.payroll_service_module.newContent( payroll_service = self.portal.payroll_service_module.newContent(
...@@ -1824,7 +1100,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -1824,7 +1100,6 @@ class TestPayroll(TestPayrollMixin):
employer_share=(3000 + 2000) * .40, employer_share=(3000 + 2000) * .40,
total=((3000 + 2000) * .50 + (3000 + 2000) * .40)) total=((3000 + 2000) * .50 + (3000 + 2000) * .40))
def test_PayrollTaxesReportDifferentSalaryRange(self): def test_PayrollTaxesReportDifferentSalaryRange(self):
eur = self.portal.currency_module.EUR eur = self.portal.currency_module.EUR
payroll_service = self.portal.payroll_service_module.newContent( payroll_service = self.portal.payroll_service_module.newContent(
...@@ -2470,101 +1745,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -2470,101 +1745,6 @@ class TestPayroll(TestPayrollMixin):
self.assertEquals(employer, line.getDestinationSectionValue()) self.assertEquals(employer, line.getDestinationSectionValue())
self.assertEquals(provider, line.getSourceSectionValue()) self.assertEquals(provider, line.getSourceSectionValue())
def test_intermediateLinesAreNotCreatedOnPaysheet(self):
'''
Intermediate lines are paysheet model lines usefull to calcul, but we
don't want to have on paysheet. So a checkbox on paysheet model lines
permit to create it or not (created by default)
'''
eur = self.portal.currency_module.EUR
model = self.paysheet_model_module.newContent( \
portal_type='Pay Sheet Model',
variation_settings_category_list=self.variation_settings_category_list)
model.setPriceCurrencyValue(eur)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_slice_a, 0, 1000)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_slice_b, 1000, 2000)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_slice_c, 2000, 10000000)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_forfait, 0, 10000000)
urssaf_slice_list = [ 'salary_range/'+self.france_settings_slice_a,]
urssaf_share_list = [ 'tax_category/'+self.tax_category_employee_share,]
salary_slice_list = ['salary_range/'+self.france_settings_forfait,]
salary_share_list = ['tax_category/'+self.tax_category_employee_share,]
variation_category_list_urssaf = urssaf_share_list + urssaf_slice_list
variation_category_list_salary = salary_share_list + salary_slice_list
model_line_1 = self.createModelLine(model=model,
id='model_line_1',
variation_category_list=variation_category_list_salary,
resource=self.labour,
share_list=salary_share_list,
slice_list=salary_slice_list,
values=[[[10000, None],],],
base_application_list=[],
base_contribution_list=['base_amount/base_salary', 'base_amount/gross_salary'])
model_line_1.setIntIndex(1)
model_line_2 = self.createModelLine(model=model,
id='model_line_2',
variation_category_list=variation_category_list_urssaf,
resource=self.urssaf,
share_list=urssaf_share_list,
slice_list=urssaf_slice_list,
values=[[[None, 0.8]],],
source_value=self.payroll_service_organisation,
base_application_list=[ 'base_amount/base_salary',],
base_contribution_list=['base_amount/net_salary',])
model_line_2.setIntIndex(2)
model_line_3 = self.createModelLine(model=model,
id='model_line_3',
variation_category_list=variation_category_list_urssaf,
resource=self.urssaf,
share_list=urssaf_share_list,
slice_list=urssaf_slice_list,
values=[[[None, -0.1]],],
source_value=self.payroll_service_organisation,
base_application_list=[ 'base_amount/net_salary',],
base_contribution_list=['base_amount/deductible_tax',])
model_line_3.setIntIndex(3)
# create a paysheet with two lines
paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
specialise_value=model)
paysheet.PaySheetTransaction_applyModel()
self.assertEquals(len(paysheet.contentValues(portal_type='Pay Sheet Line')), 0)
# calculate the pay sheet
pay_sheet_line_list = self.calculatePaySheet(paysheet=paysheet)
self.assertEquals(len(paysheet.contentValues(portal_type='Pay Sheet Line')), 3)
# check values on the paysheet
line_list = paysheet.contentValues()
self.assertEquals(line_list[0].contentValues()[0].getTotalPrice(), 10000)
self.assertEquals(line_list[1].contentValues()[0].getTotalPrice(), 8000)
self.assertEquals(line_list[2].contentValues()[0].getTotalPrice(), -800)
# create a paysheet with one normal line and an intermediate line
model_line_2.setCreatePaysheetLine(False)
paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
specialise_value=model)
paysheet.PaySheetTransaction_applyModel()
self.assertEquals(len(paysheet.contentValues(portal_type='Pay Sheet Line')), 0)
# calculate the pay sheet
pay_sheet_line_list = self.calculatePaySheet(paysheet=paysheet)
# now only one line should be created
self.assertEquals(len(paysheet.contentValues(portal_type='Pay Sheet Line')), 2)
# check values on the paysheet
self.assertEquals(paysheet.contentValues()[0].contentValues()[0].getTotalPrice(), 10000)
self.assertEquals(paysheet.contentValues()[1].contentValues()[0].getTotalPrice(), -800)
def testModelWithoutRefValidity(self): def testModelWithoutRefValidity(self):
''' '''
If no reference are defined on a model, the behavior is that this model is If no reference are defined on a model, the behavior is that this model is
...@@ -2617,7 +1797,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -2617,7 +1797,6 @@ class TestPayroll(TestPayrollMixin):
# check values on the paysheet # check values on the paysheet
self.assertEquals(paysheet.contentValues()[0].contentValues()[0].getTotalPrice(), 10000) self.assertEquals(paysheet.contentValues()[0].contentValues()[0].getTotalPrice(), 10000)
def testModelWithoutDateValidity(self): def testModelWithoutDateValidity(self):
''' '''
If no date are defined on a model, the behavior is that this model If no date are defined on a model, the behavior is that this model
......
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