Commit 1ea46477 authored by Fabien Morin's avatar Fabien Morin

- fix failling test on testPayroll_l10n_fr and rewrite it using sequences

- add new step, move some constant to the mixin
- remove unused imports
- use business template list from the mixin


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27750 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 76727c9c
...@@ -38,6 +38,29 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin): ...@@ -38,6 +38,29 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin):
normal_resource_use_category_list = ['payroll/base_salary'] normal_resource_use_category_list = ['payroll/base_salary']
invoicing_resource_use_category_list = ['payroll/tax'] invoicing_resource_use_category_list = ['payroll/tax']
BUSINESS_PATH_CREATION_SEQUENCE_STRING = """
CreateBusinessProcess
CreateBusinessPath
CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase
ModelSpecialiseBusinessProcess
Tic
"""
COMMON_BASIC_DOCUMENT_CREATION_SEQUENCE_STRING = """
CreateUrssafService
CreateLabourService
CreateEmployer
CreateEmployee
CreatePriceCurrency
CreateBasicModel
ModelCreateUrssafModelLine
UrssafModelLineCreateMovements
CreateBasicPaysheet
PaysheetCreateLabourPaySheetLine
Tic
""" + BUSINESS_PATH_CREATION_SEQUENCE_STRING
def getTitle(self): def getTitle(self):
return "Payroll" return "Payroll"
...@@ -251,6 +274,11 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin): ...@@ -251,6 +274,11 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin):
slice_value.setQuantityRangeMin(min_value) slice_value.setQuantityRangeMin(min_value)
return slice_value return slice_value
def stepSetCurrencyOnModel(self, sequence=None, **kw):
model = sequence.get('model')
currency = sequence.get('price_currency')
model.setPriceCurrencyValue(currency)
def stepCreateModelWithSlices(self, sequence=None, **kw): def stepCreateModelWithSlices(self, sequence=None, **kw):
model = self.createModel() model = self.createModel()
employer = sequence.get('employer') employer = sequence.get('employer')
...@@ -469,7 +497,8 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin): ...@@ -469,7 +497,8 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin):
price=20, price=20,
quantity=150, quantity=150,
resource_value=sequence.get('labour_service'), resource_value=sequence.get('labour_service'),
base_contribution_list=[ 'base_amount/base_salary']) base_contribution_list=['base_amount/base_salary',
'base_amount/gross_salary'])
sequence.edit(labour_paysheet_line = paysheet_line) sequence.edit(labour_paysheet_line = paysheet_line)
def stepPaysheetCreateBonusPaySheetLine(self, sequence=None, **kw): def stepPaysheetCreateBonusPaySheetLine(self, sequence=None, **kw):
...@@ -1883,28 +1912,6 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin): ...@@ -1883,28 +1912,6 @@ class TestPayrollMixin(ERP5ReportTestCase, TestBPMMixin):
class TestPayroll(TestPayrollMixin): class TestPayroll(TestPayrollMixin):
BUSINESS_PATH_CREATION_SEQUENCE_STRING = """
CreateBusinessProcess
CreateBusinessPath
CreateUrssafRoubaixOrganisation
ModifyBusinessPathTradePhase
ModelSpecialiseBusinessProcess
Tic
"""
COMMON_BASIC_DOCUMENT_CREATION_SEQUENCE_STRING = """
CreateUrssafService
CreateLabourService
CreateEmployer
CreateEmployee
CreatePriceCurrency
CreateBasicModel
ModelCreateUrssafModelLine
UrssafModelLineCreateMovements
CreateBasicPaysheet
PaysheetCreateLabourPaySheetLine
Tic
""" + BUSINESS_PATH_CREATION_SEQUENCE_STRING
def test_modelGetCell(self): def test_modelGetCell(self):
''' '''
Model objects have a overload method called getCell. This method first Model objects have a overload method called getCell. This method first
......
...@@ -29,133 +29,79 @@ ...@@ -29,133 +29,79 @@
test cases related to french localisation (tranche A for example) test cases related to french localisation (tranche A for example)
""" """
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.Sequence import SequenceList
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_parent
from Products.ERP5.tests.testPayroll import TestPayrollMixin from Products.ERP5.tests.testPayroll import TestPayrollMixin
from DateTime import DateTime
import transaction
class TestPayroll_l10n_fr(TestPayrollMixin): class TestPayroll_l10n_fr(TestPayrollMixin):
PAYSHEET_WITH_SLICE_SEQUENCE_STRING = '''
CreateBasicPaysheet
PaysheetSetModelAndApplyIt
PaysheetCreateLabourPaySheetLine
''' + TestPayrollMixin.BUSINESS_PATH_CREATION_SEQUENCE_STRING + '''
CheckUpdateAggregatedAmountListReturnUsingSlices
PaysheetApplyTransformation
Tic
CheckPaysheetLineAreCreatedUsingSlices
CheckPaysheetLineAmountsUsingSlices
CheckUpdateAggregatedAmountListReturnNothing
CheckPaysheetLineAmountsUsingSlices
'''
def getTitle(self): def getTitle(self):
return "Payroll_l10n_fr" return "Payroll_l10n_fr"
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
""" """ """ """
return ('erp5_base', 'erp5_pdm', 'erp5_trade', 'erp5_accounting', return TestPayrollMixin.getBusinessTemplateList(self) +\
'erp5_payroll', 'erp5_payroll_l10n_fr') ('erp5_payroll_l10n_fr',)
def stepCheckYearToDateSliceAmount(self, sequence=None, **kw):
paysheet_module = self.portal.getDefaultModule(portal_type=\
'Pay Sheet Transaction')
paysheet_list = paysheet_module.contentValues(portal_type=\
'Pay Sheet Transaction')
self.assertEquals(len(paysheet_list), 2) # 2 paysheet have been created
# for this test
for paysheet in paysheet_list:
# the script used for calculation only take into account stopped or
# delivered paysheet
paysheet.stop()
self.stepTic()
# here, check how much is contributed to the slices
self.assertEquals(400, # 200 from the 1st paysheet + 200 from the 2e
paysheet_list[1].PaySheetTransaction_getYearToDateSlice(\
'salary_range/france/slice_0_to_200'))
self.assertEquals(400, # 200 from the 1st paysheet + 200 from the 2e
paysheet_list[1].PaySheetTransaction_getYearToDateSlice(\
'salary_range/france/slice_200_to_400'))
self.assertEquals(5200, # (3000 - 400)*2
paysheet_list[1].PaySheetTransaction_getYearToDateSlice(\
'salary_range/france/slice_400_to_5000'))
def test_01_getYearToDateSlice(self): def test_01_getYearToDateSlice(self):
''' '''
that slices works and we can caculate the total amount spend on a slice that slices works and we can caculate the total amount spend on a slice
''' '''
eur = self.portal.currency_module.EUR sequence_list = SequenceList()
model = self.paysheet_model_module.newContent( \ sequence_string = """
portal_type='Pay Sheet Model', CreateUrssafService
variation_settings_category_list=self.variation_settings_category_list) CreateLabourService
model.setPriceCurrencyValue(eur) CreateEmployer
CreateEmployee
self.addSlice(model, 'salary_range/%s' % \ CreatePriceCurrency
self.france_settings_slice_a, 0, 1000) CreateModelWithSlices
self.addSlice(model, 'salary_range/%s' % \ SetCurrencyOnModel
self.france_settings_slice_b, 1000, 2000) ModelCreateUrssafModelLineWithSlices
self.addSlice(model, 'salary_range/%s' % \ UrssafModelLineWithSlicesCreateMovements
self.france_settings_slice_c, 2000, 10000000) """ + self.PAYSHEET_WITH_SLICE_SEQUENCE_STRING +\
self.addSlice(model, 'salary_range/%s' % \ self.PAYSHEET_WITH_SLICE_SEQUENCE_STRING + """
self.france_settings_forfait, 0, 10000000) CheckYearToDateSliceAmount
"""
urssaf_slice_list = [ 'salary_range/'+self.france_settings_slice_a,] sequence_list.addSequenceString(sequence_string)
urssaf_share_list = [ 'tax_category/'+self.tax_category_employee_share,] sequence_list.play(self)
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.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.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,
start_date=DateTime(2009, 07, 1),
stop_date=DateTime(2009, 07, 31))
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)
paysheet.stop()
# create anoter paysheet with two lines
paysheet_2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
specialise_value=model,
start_date=DateTime(2009, 8, 1),
stop_date=DateTime(2009, 8, 31))
paysheet_2.PaySheetTransaction_applyModel()
self.assertEquals(len(paysheet_2.contentValues(portal_type='Pay Sheet Line')), 0)
# calculate the pay sheet
pay_sheet_line_list = self.calculatePaySheet(paysheet=paysheet_2)
self.assertEquals(len(paysheet.contentValues(portal_type='Pay Sheet Line')), 3)
# check values on the paysheet
line_list = paysheet_2.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)
transaction.commit()
self.tic()
# here, check how much is contributed to the slices
self.assertEquals(2000, # 1000 from the 1st paysheet + 1000 from the 2e
paysheet_2.PaySheetTransaction_getYearToDateSlice(\
'salary_range/france/tranche_a'))
self.assertEquals(2000, # 1000 from the 1st paysheet + 1000 from the 2e
paysheet_2.PaySheetTransaction_getYearToDateSlice(\
'salary_range/france/tranche_b'))
self.assertEquals(16000, # (10000 - 1000 - 1000)*2
paysheet_2.PaySheetTransaction_getYearToDateSlice(\
'salary_range/france/tranche_c'))
import unittest import unittest
def test_suite(): def test_suite():
......
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