Commit 3848a999 authored by Aurel's avatar Aurel

update test to the new amount generator way,

- categories contribution_share and salary_range are no longer 
necessary as variation is now done on the base_amount category
- defined getBaseAmountQuantity script to manage slice cases



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@41992 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a86c2476
...@@ -33,6 +33,7 @@ from Products.ERP5Type.tests.Sequence import SequenceList ...@@ -33,6 +33,7 @@ from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import reindex from Products.ERP5Type.tests.utils import reindex
from DateTime import DateTime from DateTime import DateTime
import transaction import transaction
from Products.ERP5Type.tests.utils import createZODBPythonScript
class TestPayrollMixin(TestTradeModelLineMixin): class TestPayrollMixin(TestTradeModelLineMixin):
BUSINESS_PATH_CREATION_SEQUENCE_STRING = """ BUSINESS_PATH_CREATION_SEQUENCE_STRING = """
...@@ -63,12 +64,72 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -63,12 +64,72 @@ class TestPayrollMixin(TestTradeModelLineMixin):
def getTitle(self): def getTitle(self):
return "Payroll" return "Payroll"
def setPayrollBaseAmountQuantityMethod(self, base_amount_id, text):
"""Populate TradeModelLine_getBaseAmountQuantityMethod shared script
This helper method edits the script so that:
- there's no need to do any cleanup
- data produced by previous still behaves as expected
"""
skin = self.portal.portal_skins.custom
script_id = self.amount_generator_line_portal_type.replace(' ', '') \
+ '_getBaseAmountQuantityMethod'
test = "\nif base_application.startswith(%r):\n " % base_amount_id
try:
old_text = '\n' + skin[script_id].body()
except KeyError:
old_text = ''
else:
skin._delObject(script_id)
text = "context.log('ba', base_application)\n\n" + test + '\n '.join(text.splitlines()) + old_text
createZODBPythonScript(skin, script_id, "base_application", text)
return base_amount_id
def afterSetUp(self): def afterSetUp(self):
"""Prepare the test.""" """Prepare the test."""
TestTradeModelLineMixin.afterSetUp(self) TestTradeModelLineMixin.afterSetUp(self)
self.createCategories() self.createCategories()
self.fixed_quantity = self.setBaseAmountQuantityMethod('fixed_quantity', self.fixed_quantity = self.setBaseAmountQuantityMethod('fixed_quantity',
"return lambda *args, **kw: 1") "return lambda *args, **kw: 1")
self.setPayrollBaseAmountQuantityMethod("base_amount/payroll/base/contribution",
"""\
def returnZeroQuantity(*args, **kw):
return 0
context.log('context %s, ba = %s' %(context, context.getBaseApplicationList()))
for application in context.getBaseApplicationList():
if 'salary_range' in application:
context.log('method is zeroQ')
return returnZeroQuantity
context.log('method is default')
return context.getBaseAmountQuantity
""")
self.setPayrollBaseAmountQuantityMethod("base_amount/payroll/l10n/fr/salary_range",
"""\
def getBaseAmountQuantity(delivery_amount, base_application, **kw):
quantity = 0
salary_range = base_application.split('/')[-1]
salary_range_cat = 'salary_range/france/%s' %(salary_range)
cell = delivery_amount.getSpecialiseValue().getCell(salary_range_cat)
if cell is not None:
model_slice_min = cell.getQuantityRangeMin()
model_slice_max = cell.getQuantityRangeMax()
base_application = delivery_amount.getTotalPrice(0.0)
if base_application <= model_slice_min:
# if base_application is not in the slice range, quantity is 0
quantity = 0
elif base_application-model_slice_min > 0:
if base_application <= model_slice_max:
quantity = base_application - model_slice_min
elif model_slice_max:
quantity = model_slice_max - model_slice_min
else:
quantity = delivery_amount.getTotalPrice()
context.log('quantity is', quantity)
return quantity
return getBaseAmountQuantity
""")
@reindex @reindex
def beforeTearDown(self): def beforeTearDown(self):
...@@ -124,6 +185,8 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -124,6 +185,8 @@ class TestPayrollMixin(TestTradeModelLineMixin):
'contribution_share/employee', 'contribution_share/employee',
'base_amount/payroll/base/income_tax', 'base_amount/payroll/base/income_tax',
'base_amount/payroll/base/contribution', 'base_amount/payroll/base/contribution',
'base_amount/payroll/base/contribution/employer',
'base_amount/payroll/base/contribution/employee',
'base_amount/payroll/report/salary/net', 'base_amount/payroll/report/salary/net',
'base_amount/payroll/report/salary/gross', 'base_amount/payroll/report/salary/gross',
'base_amount/payroll/l10n/fr/salary_range/a', 'base_amount/payroll/l10n/fr/salary_range/a',
...@@ -181,14 +244,13 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -181,14 +244,13 @@ class TestPayrollMixin(TestTradeModelLineMixin):
node = self.createService() node = self.createService()
node.edit(title='Urssaf', node.edit(title='Urssaf',
product_line='state_insurance', quantity_unit='time/month', product_line='state_insurance', quantity_unit='time/month',
variation_base_category_list=['contribution_share', 'salary_range'], variation_base_category_list=['base_application'],
use='payroll/tax') use='payroll/tax')
node.setVariationCategoryList(['contribution_share/employee', node.setVariationCategoryList(['base_application/base_amount/payroll/base/contribution/employee',
'contribution_share/employer', 'base_application/base_amount/payroll/base/contribution/employer'
'salary_range/france/slice_0_to_200', 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200',
'salary_range/france/slice_200_to_400', 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
'salary_range/france/slice_400_to_5000', 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000',
'salary_range/france/slice_600_to_800',
]) ])
sequence.edit(urssaf_service = node) sequence.edit(urssaf_service = node)
...@@ -210,28 +272,31 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -210,28 +272,31 @@ class TestPayrollMixin(TestTradeModelLineMixin):
def stepCreateBonusService(self, sequence=None, **kw): def stepCreateBonusService(self, sequence=None, **kw):
node = self.createService() node = self.createService()
node.edit(title='Bonus', quantity_unit='time/month', node.edit(title='Bonus', quantity_unit='time/month',
variation_base_category_list=['contribution_share'], variation_base_category_list=['base_contribution'],
product_line='labour', use='payroll/base_salary') product_line='labour', use='payroll/base_salary')
node.setVariationCategoryList(['contribution_share/employee', node.setVariationCategoryList(['base_contribution/base_amount/payroll/base/contribution/employee',
'contribution_share/employer']) 'base_contribution/base_amount/payroll/base/contribution/employer'
])
sequence.edit(bonus_service = node) sequence.edit(bonus_service = node)
def stepCreateOldAgeInsuranaceService(self, sequence=None, **kw): def stepCreateOldAgeInsuranaceService(self, sequence=None, **kw):
node = self.createService() node = self.createService()
node.edit(title='Old Age Insurance', quantity_unit='time/month', node.edit(title='Old Age Insurance', quantity_unit='time/month',
variation_base_category_list=['contribution_share', 'salary_range'], variation_base_category_list=['base_application'],
product_line='state_insurance', use='payroll/tax') product_line='state_insurance', use='payroll/tax')
node.setVariationCategoryList(['contribution_share/employee', node.setVariationCategoryList(['base_application/base_amount/payroll/base/contribution/employee',
'contribution_share/employer']) 'base_application/base_amount/payroll/base/contribution/employer'
])
sequence.edit(old_age_insurance_service = node) sequence.edit(old_age_insurance_service = node)
def stepCreateSicknessInsuranceService(self, sequence=None, **kw): def stepCreateSicknessInsuranceService(self, sequence=None, **kw):
node = self.createService() node = self.createService()
node.edit(title='Sickness Insurance', quantity_unit='time/month', node.edit(title='Sickness Insurance', quantity_unit='time/month',
variation_base_category_list=['contribution_share', 'salary_range'], variation_base_category_list=['base_application'],
product_line='state_insurance', use='payroll/tax') product_line='state_insurance', use='payroll/tax')
node.setVariationCategoryList(['contribution_share/employee', node.setVariationCategoryList(['base_application/base_amount/payroll/base/contribution/employee',
'contribution_share/employer']) 'base_application/base_amount/payroll/base/contribution/employer'
])
sequence.edit(sickness_insurance_service = node) sequence.edit(sickness_insurance_service = node)
def createModel(self): def createModel(self):
...@@ -308,11 +373,10 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -308,11 +373,10 @@ class TestPayrollMixin(TestTradeModelLineMixin):
reference='urssaf_model_line', reference='urssaf_model_line',
trade_phase='payroll/france/urssaf', trade_phase='payroll/france/urssaf',
resource_value=sequence.get('urssaf_service'), resource_value=sequence.get('urssaf_service'),
variation_category_list=['contribution_share/employee', variation_category_list = ['base_application/base_amount/payroll/base/contribution/employee',
'contribution_share/employer'], 'base_application/base_amount/payroll/base/contribution/employer'],
base_application_list=[ 'base_amount/payroll/base/contribution'], base_contribution_list=['base_amount/payroll/base/income_tax'],
base_contribution_list=['base_amount/payroll/base/income_tax']) )
#model_line.setQuantity(0.0)
sequence.edit(urssaf_model_line = model_line) sequence.edit(urssaf_model_line = model_line)
def stepModelCreateUrssafModelLineWithSlices(self, sequence=None, **kw): def stepModelCreateUrssafModelLineWithSlices(self, sequence=None, **kw):
...@@ -322,12 +386,11 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -322,12 +386,11 @@ class TestPayrollMixin(TestTradeModelLineMixin):
reference='urssaf_model_line_2', reference='urssaf_model_line_2',
trade_phase='payroll/france/urssaf', trade_phase='payroll/france/urssaf',
resource_value=sequence.get('urssaf_service'), resource_value=sequence.get('urssaf_service'),
variation_category_list=['contribution_share/employee', variation_category_list=['base_application/base_amount/payroll/base/contribution/employee',
'contribution_share/employer', 'base_application/base_amount/payroll/base/contribution/employer',
'salary_range/france/slice_0_to_200', 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200',
'salary_range/france/slice_200_to_400', 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
'salary_range/france/slice_400_to_5000'], 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000',],
base_application_list=[ 'base_amount/payroll/base/contribution',],
base_contribution_list=['base_amount/payroll/base/income_tax']) base_contribution_list=['base_amount/payroll/base/income_tax'])
sequence.edit(urssaf_model_line_with_slices = model_line) sequence.edit(urssaf_model_line_with_slices = model_line)
...@@ -338,156 +401,182 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -338,156 +401,182 @@ class TestPayrollMixin(TestTradeModelLineMixin):
reference='urssaf_model_line_3', reference='urssaf_model_line_3',
trade_phase='payroll/france/urssaf', trade_phase='payroll/france/urssaf',
resource_value=sequence.get('urssaf_service'), resource_value=sequence.get('urssaf_service'),
variation_category_list=['contribution_share/employee', variation_category_list=['base_application/base_amount/payroll/base/contribution/employer',
'contribution_share/employer', 'base_application/base_amount/payroll/base/contribution/employee',
'salary_range/france/slice_200_to_400', 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
'salary_range/france/slice_600_to_800'], 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_600_to_800',],
base_application_list=[ 'base_amount/payroll/base/contribution'],
base_contribution_list=['base_amount/payroll/base/income_tax']) base_contribution_list=['base_amount/payroll/base/income_tax'])
#model_line.setQuantity(0.0) #model_line.setQuantity(0.0)
sequence.edit(urssaf_model_line_with_slices = model_line) sequence.edit(urssaf_model_line_with_slices = model_line)
def stepPaysheetCreateUrssafModelLine(self, sequence=None, **kw):
'''The model line created here have the same reference than the model line
created in stepModelCreateUrssafModelLine. This is used for line
overloading tests'''
paysheet = sequence.get('paysheet')
model_line = self.createModelLine(paysheet)
model_line.edit(title='Urssaf',
reference='urssaf_model_line',
trade_phase='payroll/france/urssaf',
resource_value=sequence.get('urssaf_service'),
variation_category_list=['contribution_share/employee',
'contribution_share/employer'],
base_application_list=[ 'base_amount/payroll/base/contribution'],
base_contribution_list=['base_amount/payroll/base/income_tax'])
sequence.edit(urssaf_model_line = model_line)
def stepUrssafModelLineCreateMovements(self, sequence=None, **kw): def stepUrssafModelLineCreateMovements(self, sequence=None, **kw):
model_line = sequence.get('urssaf_model_line') model_line = sequence.get('urssaf_model_line')
cell1 = model_line.newCell('contribution_share/employee', cell1 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employee',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employee',
base_id='movement', base_id='movement',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(price=0.1, contribution_share='employee', quantity=None) cell1.edit(price=0.1, quantity=None)
cell2 = model_line.newCell('contribution_share/employer', cell2 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employer',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employer',
base_id='movement', base_id='movement',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.5, contribution_share='employer', quantity=None) cell2.edit(price=0.5, quantity=None)
def stepUrssafModelLineCreateMovementsWithQuantityOnly(self, sequence=None, **kw): def stepUrssafModelLineCreateMovementsWithQuantityOnly(self, sequence=None, **kw):
model_line = sequence.get('urssaf_model_line') model_line = sequence.get('urssaf_model_line')
cell1 = model_line.newCell('contribution_share/employee', cell1 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employee',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employee',
base_id='movement', base_id='movement',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(quantity=-100.0, contribution_share='employee') cell1.edit(quantity=-100.0, contribution_share='employee')
cell2 = model_line.newCell('contribution_share/employer', cell2 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employer',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employer',
base_id='movement', base_id='movement',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(quantity=-200.0, contribution_share='employer') cell2.edit(quantity=-200.0, contribution_share='employer')
def stepUrssafModelLineWithSlicesCreateMovements(self, sequence=None, **kw): def stepUrssafModelLineWithSlicesCreateMovements(self, sequence=None, **kw):
model_line = sequence.get('urssaf_model_line_with_slices') model_line = sequence.get('urssaf_model_line_with_slices')
cell1 = model_line.newCell('contribution_share/employee', cell1 = model_line.newCell(
'salary_range/france/slice_0_to_200', 'base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_0_to_200', base_application_list=[
'base_amount/payroll/base/contribution/employee',
'base_amount/payroll/l10n/fr/salary_range/slice_0_to_200',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(price=0.1, contribution_share='employee', quantity=None, cell1.edit(price=0.1, quantity=None,)
salary_range='france/slice_0_to_200')
cell2 = model_line.newCell('contribution_share/employer', cell2 = model_line.newCell(
'salary_range/france/slice_0_to_200', 'base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_0_to_200', base_application_list=[
'base_amount/payroll/base/contribution/employer',
'base_amount/payroll/l10n/fr/salary_range/slice_0_to_200',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.2, contribution_share='employer', quantity=None, cell2.edit(price=0.2, quantity=None,)
salary_range='france/slice_0_to_200')
cell3 = model_line.newCell('contribution_share/employee', cell3 = model_line.newCell(
'salary_range/france/slice_200_to_400', 'base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_200_to_400', base_application_list=[
'base_amount/payroll/base/contribution/employee',
'base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell3.edit(price=0.3, contribution_share='employee', quantity=None, cell3.edit(price=0.3,quantity=None)
salary_range='france/slice_200_to_400')
cell4 = model_line.newCell('contribution_share/employer', cell4 = model_line.newCell(
'salary_range/france/slice_200_to_400', 'base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_200_to_400', base_application_list=[
'base_amount/payroll/base/contribution/employer',
'base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell4.edit(price=0.4, contribution_share='employer', quantity=None, cell4.edit(price=0.4, quantity=None,)
salary_range='france/slice_200_to_400')
cell5 = model_line.newCell('contribution_share/employee', cell5 = model_line.newCell(
'salary_range/france/slice_400_to_5000', 'base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000', base_application_list=[
'base_amount/payroll/base/contribution/employee',
'base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell5.edit(price=0.5, contribution_share='employee', quantity=None, cell5.edit(price=0.5, quantity=None,)
salary_range='france/slice_400_to_5000')
cell6 = model_line.newCell('contribution_share/employer', cell6 = model_line.newCell(
'salary_range/france/slice_400_to_5000', 'base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000', base_application_list=[
'base_amount/payroll/base/contribution/employer',
'base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell6.edit(price=0.6, contribution_share='employer', quantity=None, cell6.edit(price=0.6, quantity=None,)
salary_range='france/slice_400_to_5000')
def stepUrssafModelLineWithComplexSlicesCreateMovements(self, def stepUrssafModelLineWithComplexSlicesCreateMovements(self,
sequence=None, **kw): sequence=None, **kw):
model_line = sequence.get('urssaf_model_line_with_slices') model_line = sequence.get('urssaf_model_line_with_slices')
cell1 = model_line.newCell('contribution_share/employee', cell1 = model_line.newCell(
'salary_range/france/slice_200_to_400', 'base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_200_to_400', base_application_list=[
mapped_value_property_list=('quantity', 'price')) 'base_amount/payroll/base/contribution/employee',
cell1.edit(price=0.1, contribution_share='employee', quantity=None, 'base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
salary_range='france/slice_200_to_400') ],
cell2 = model_line.newCell('contribution_share/employer',
'salary_range/france/slice_200_to_400',
portal_type='Pay Sheet Model Cell',
base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.2, contribution_share='employer', quantity=None,
salary_range='france/slice_200_to_400')
cell3 = model_line.newCell('contribution_share/employee',
'salary_range/france/slice_600_to_800',
portal_type='Pay Sheet Model Cell',
base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_600_to_800',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell3.edit(price=0.3, contribution_share='employee', quantity=None, cell1.edit(price=0.1, quantity=None)
salary_range='france/slice_600_to_800')
cell4 = model_line.newCell('contribution_share/employer', cell2 = model_line.newCell(
'salary_range/france/slice_600_to_800', 'base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/l10n/fr/salary_range/slice_600_to_800', base_application_list=[
'base_amount/payroll/base/contribution/employer',
'base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell4.edit(price=0.4, contribution_share='employer', quantity=None, cell2.edit(price=0.2, quantity=None)
salary_range='france/slice_600_to_800')
def stepPaysheetUrssafModelLineCreateMovements(self, sequence=None, **kw): cell3 = model_line.newCell(
model_line = sequence.get('urssaf_model_line') 'base_application/base_amount/payroll/base/contribution/employee',
cell1 = model_line.newCell('contribution_share/employee', 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_600_to_800',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application_list=[
'base_amount/payroll/base/contribution/employee',
'base_amount/payroll/l10n/fr/salary_range/slice_600_to_800',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(price=0.3, contribution_share='employee', quantity=None) cell3.edit(price=0.1, quantity=None)
cell2 = model_line.newCell('contribution_share/employer',
cell4 = model_line.newCell(
'base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_600_to_800',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application_list=[
'base_amount/payroll/base/contribution/employer',
'base_amount/payroll/l10n/fr/salary_range/slice_600_to_800',
],
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.7, contribution_share='employer', quantity=None) cell4.edit(price=0.2, quantity=None)
# def stepPaysheetUrssafModelLineCreateMovements(self, sequence=None, **kw):
# return
# model_line = sequence.get('urssaf_model_line')
# cell1 = model_line.newCell('contribution_share/employee',
# portal_type='Pay Sheet Model Cell',
# base_id='movement',
# mapped_value_property_list=('quantity', 'price'))
# cell1.edit(price=0.3, contribution_share='employee', quantity=None)
# cell2 = model_line.newCell('contribution_share/employer',
# portal_type='Pay Sheet Model Cell',
# base_id='movement',
# mapped_value_property_list=('quantity', 'price'))
# cell2.edit(price=0.7, contribution_share='employer', quantity=None)
def createPaysheet(self, sequence=None, **kw): def createPaysheet(self, sequence=None, **kw):
module = self.portal.getDefaultModule(portal_type='Pay Sheet Transaction') module = self.portal.getDefaultModule(portal_type='Pay Sheet Transaction')
...@@ -514,7 +603,8 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -514,7 +603,8 @@ class TestPayrollMixin(TestTradeModelLineMixin):
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/payroll/base/contribution', base_contribution_list=['base_amount/payroll/base/contribution/employee',
'base_amount/payroll/base/contribution/employer',
'base_amount/payroll/l10n/fr/salary_range/slice_0_to_200', 'base_amount/payroll/l10n/fr/salary_range/slice_0_to_200',
'base_amount/payroll/l10n/fr/salary_range/slice_200_to_400', 'base_amount/payroll/l10n/fr/salary_range/slice_200_to_400',
'base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000', 'base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000',
...@@ -527,23 +617,25 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -527,23 +617,25 @@ class TestPayrollMixin(TestTradeModelLineMixin):
paysheet_line = self.createPaysheetLine(paysheet) paysheet_line = self.createPaysheetLine(paysheet)
paysheet_line.edit(title='Bonus', paysheet_line.edit(title='Bonus',
resource_value=sequence.get('bonus_service'), resource_value=sequence.get('bonus_service'),
variation_category_list=['contribution_share/employee', variation_category_list=['base_contribution/base_amount/payroll/base/contribution/employer',
'contribution_share/employer'], 'base_contribution/base_amount/payroll/base/contribution/employee'],
base_contribution_list=[ 'base_amount/payroll/base/contribution']) )
sequence.edit(bonus_paysheet_line = paysheet_line) sequence.edit(bonus_paysheet_line = paysheet_line)
def stepPaysheetCreateBonusPaySheetLineMovements(self, sequence=None, **kw): def stepPaysheetCreateBonusPaySheetLineMovements(self, sequence=None, **kw):
paysheet_line = sequence.get('bonus_paysheet_line') paysheet_line = sequence.get('bonus_paysheet_line')
cell1 = paysheet_line.newCell('contribution_share/employee', cell1 = paysheet_line.newCell('base_contribution/base_amount/payroll/base/contribution/employee',
portal_type='Pay Sheet Cell', portal_type='Pay Sheet Cell',
base_contribution='base_amount/payroll/base/contribution/employee',
base_id='movement', base_id='movement',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(quantity=1000, price=1, contribution_share='employee') cell1.edit(quantity=1000, price=1)
cell2 = paysheet_line.newCell('contribution_share/employer', cell2 = paysheet_line.newCell('base_contribution/base_amount/payroll/base/contribution/employer',
portal_type='Pay Sheet Cell', portal_type='Pay Sheet Cell',
base_id='movement', base_id='movement',
base_contribution='base_amount/payroll/base/contribution/employer',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(quantity=1000, price=1, contribution_share='employer') cell2.edit(quantity=1000, price=1)
def checkUpdateAggregatedAmountListReturn(self, paysheet, def checkUpdateAggregatedAmountListReturn(self, paysheet,
expected_movement_to_delete_count, expected_movement_to_add_count): expected_movement_to_delete_count, expected_movement_to_add_count):
...@@ -594,7 +686,7 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -594,7 +686,7 @@ class TestPayrollMixin(TestTradeModelLineMixin):
def stepCheckPaysheetLineAreCreated(self, sequence=None, **kw): def stepCheckPaysheetLineAreCreated(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEqual(len(paysheet_line_list), 2) self.assertEqual(len(paysheet_line_list), 3)
self.assertEqual(len(paysheet.getMovementList(portal_type=\ self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 2) # 2 because labour line contain no movement 'Pay Sheet Cell')), 2) # 2 because labour line contain no movement
...@@ -603,15 +695,14 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -603,15 +695,14 @@ class TestPayrollMixin(TestTradeModelLineMixin):
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEqual(len(paysheet_line_list), 0) self.assertEqual(len(paysheet_line_list), 0)
self.assertEqual(len(paysheet.getMovementList(portal_type=\ self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 0) # 2 because labour line contain no movement 'Pay Sheet Cell')), 0) # 0 because labour line contain no movement
def stepCheckPaysheetLineAreCreatedUsingBonus(self, sequence=None, **kw): def stepCheckPaysheetLineAreCreatedUsingBonus(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEqual(len(paysheet_line_list), 3) self.assertEqual(len(paysheet_line_list), 4)
self.assertEqual(len(paysheet.getMovementList(portal_type=\ self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 4) # 4 because labour line contain no movement 'Pay Sheet Cell')), 4) # 2 for bonus 2 for urssaf
# 2 for bonus, and 2 for urssaf
def stepCheckThereIsOnlyOnePaysheetLine(self, sequence=None, **kw): def stepCheckThereIsOnlyOnePaysheetLine(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
...@@ -623,7 +714,7 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -623,7 +714,7 @@ class TestPayrollMixin(TestTradeModelLineMixin):
def stepCheckPaysheetLineAreCreatedUsingSlices(self, sequence=None, **kw): def stepCheckPaysheetLineAreCreatedUsingSlices(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEqual(len(paysheet_line_list), 4) self.assertEqual(len(paysheet_line_list), 7)
self.assertEqual(len(paysheet.getMovementList(portal_type=\ self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 6) # 6 because labour line contain no movement and 'Pay Sheet Cell')), 6) # 6 because labour line contain no movement and
# because of the 3 slice and 2 contribution_shares # because of the 3 slice and 2 contribution_shares
...@@ -631,7 +722,7 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -631,7 +722,7 @@ class TestPayrollMixin(TestTradeModelLineMixin):
def stepCheckPaysheetLineAreCreatedUsingComplexSlices(self, sequence=None, **kw): def stepCheckPaysheetLineAreCreatedUsingComplexSlices(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEqual(len(paysheet_line_list), 3) self.assertEqual(len(paysheet_line_list), 5)
self.assertEqual(len(paysheet.getMovementList(portal_type=\ self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 4) # 4 because labour line contain no movement and 'Pay Sheet Cell')), 4) # 4 because labour line contain no movement and
# because of the 2 slice and 2 contribution_shares # because of the 2 slice and 2 contribution_shares
...@@ -639,17 +730,14 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -639,17 +730,14 @@ class TestPayrollMixin(TestTradeModelLineMixin):
def stepCheckPaysheetLineAreCreatedUsingWith3Lines(self, sequence=None, **kw): def stepCheckPaysheetLineAreCreatedUsingWith3Lines(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEqual(len(paysheet_line_list), 3) self.assertEqual(len(paysheet_line_list), 5)
self.assertEqual(len(paysheet.getMovementList(portal_type=\ self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 4) # 4 because labour line contain no movement and 'Pay Sheet Cell')), 4) # 2 for urssaf 2 for sickness insurrance
# because of the two lines and 2 contribution_shares
# (urssaf and sickness insurance. old age
# insurance does not match predicate)
def stepCheckPaysheetLineAreCreatedAfterUpdateWithLinesWithSameResource(self, sequence=None, **kw): def stepCheckPaysheetLineAreCreatedAfterUpdateWithLinesWithSameResource(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
self.assertEqual(len(paysheet_line_list), 5) self.assertEqual(len(paysheet_line_list), 9)
self.assertEqual(len(paysheet.getMovementList(portal_type=\ self.assertEqual(len(paysheet.getMovementList(portal_type=\
'Pay Sheet Cell')), 8) # 8 because labour line contain no movement and 'Pay Sheet Cell')), 8) # 8 because labour line contain no movement and
# because of the 3 slice and 2 contribution_shares # because of the 3 slice and 2 contribution_shares
...@@ -661,12 +749,14 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -661,12 +749,14 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell1.getQuantity(), 3000) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee')
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(cell.getQuantity(), 3000)
cell2 = paysheet_line.getCell('contribution_share/employer') self.assertEquals(cell.getPrice(), 0.1)
self.assertEquals(cell2.getQuantity(), 3000) if paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getPrice(), 0.5) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer')
self.assertEquals(cell.getQuantity(), 3000)
self.assertEquals(cell.getPrice(), 0.5)
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else: else:
...@@ -678,19 +768,27 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -678,19 +768,27 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell1.getQuantity(), 4000) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer')
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(cell.getQuantity(), 4000)
cell2 = paysheet_line.getCell('contribution_share/employer') self.assertEquals(cell.getPrice(), 0.5)
self.assertEquals(cell2.getQuantity(), 4000) elif paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell2.getPrice(), 0.5) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee')
self.assertEquals(cell.getQuantity(), 4000)
self.assertEquals(cell.getPrice(), 0.1)
else:
self.fail("Unknown contribution for line %s" % paysheet_line.getBaseContribution())
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
elif service == 'Bonus': elif service == 'Bonus':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell1.getTotalPrice(), 1000) cell = paysheet_line.getCell('base_contribution/base_amount/payroll/base/contribution/employer')
cell2 = paysheet_line.getCell('contribution_share/employer') self.assertEquals(cell.getTotalPrice(), 1000)
self.assertEquals(cell2.getTotalPrice(), 1000) elif paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employee":
cell = paysheet_line.getCell('base_contribution/base_amount/payroll/base/contribution/employee')
self.assertEquals(cell.getTotalPrice(), 1000)
else:
self.fail("Unknown contribution for line %s" % paysheet_line.getBaseContribution())
else: else:
self.fail("Unknown service for line %s" % paysheet_line.getTitle()) self.fail("Unknown service for line %s" % paysheet_line.getTitle())
...@@ -700,14 +798,16 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -700,14 +798,16 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employee":
# XXX-Aurel quantity from model line is multiply by total price of labour line # XXX-Aurel quantity from model line is multiply by total price of labour line
# price remains None # price remains None
self.assertEquals(cell1.getQuantity(), -300000) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee')
self.assertEquals(cell1.getPrice(), None) self.assertEquals(cell.getQuantity(), -300000)
cell2 = paysheet_line.getCell('contribution_share/employer') self.assertEquals(cell.getPrice(), None)
self.assertEquals(cell2.getQuantity(), -600000) elif paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getPrice(), None) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer')
self.assertEquals(cell.getQuantity(), -600000)
self.assertEquals(cell.getPrice(), None)
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else: else:
...@@ -719,35 +819,45 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -719,35 +819,45 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
if paysheet_line.getSalaryRange() == 'france/slice_0_to_200': app_list = paysheet_line.getBaseApplicationList()
cell1 = paysheet_line.getCell('contribution_share/employee', if 'base_amount/payroll/base/contribution/employee' in app_list:
'salary_range/france/slice_0_to_200') if "base_amount/payroll/l10n/fr/salary_range/slice_0_to_200" in app_list:
cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200')
self.assertEquals(cell1.getQuantity(), 200) self.assertEquals(cell1.getQuantity(), 200)
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(cell1.getPrice(), 0.1)
cell2 = paysheet_line.getCell('contribution_share/employer', elif "base_amount/payroll/l10n/fr/salary_range/slice_200_to_400" in app_list:
'salary_range/france/slice_0_to_200') cell3 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
self.assertEquals(cell2.getQuantity(), 200) 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400')
self.assertEquals(cell2.getPrice(), 0.2)
elif paysheet_line.getSalaryRange() == 'france/slice_200_to_400':
cell3 = paysheet_line.getCell('contribution_share/employee',
'salary_range/france/slice_200_to_400')
self.assertEquals(cell3.getQuantity(), 200) self.assertEquals(cell3.getQuantity(), 200)
self.assertEquals(cell3.getPrice(), 0.3) self.assertEquals(cell3.getPrice(), 0.3)
cell4 = paysheet_line.getCell('contribution_share/employer', elif "base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000" in app_list:
'salary_range/france/slice_200_to_400') cell5 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
self.assertEquals(cell4.getQuantity(), 200) 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000')
self.assertEquals(cell4.getPrice(), 0.4)
elif paysheet_line.getSalaryRange() == 'france/slice_400_to_5000':
cell5 = paysheet_line.getCell('contribution_share/employee',
'salary_range/france/slice_400_to_5000')
self.assertEquals(cell5.getQuantity(), 2600) self.assertEquals(cell5.getQuantity(), 2600)
self.assertEquals(cell5.getPrice(), 0.5) self.assertEquals(cell5.getPrice(), 0.5)
cell6 = paysheet_line.getCell('contribution_share/employer', else:
'salary_range/france/slice_400_to_5000') self.fail("Unknown application %s for line %s" % (app_list,paysheet_line.getTitle()))
elif 'base_amount/payroll/base/contribution/employer' in app_list:
if "base_amount/payroll/l10n/fr/salary_range/slice_0_to_200" in app_list:
cell2 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200')
self.assertEquals(cell2.getQuantity(), 200)
self.assertEquals(cell2.getPrice(), 0.2)
elif "base_amount/payroll/l10n/fr/salary_range/slice_200_to_400" in app_list:
cell4 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400')
self.assertEquals(cell4.getQuantity(), 200)
self.assertEquals(cell4.getPrice(), 0.4)
elif "base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000" in app_list:
cell6 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000')
self.assertEquals(cell6.getQuantity(), 2600) self.assertEquals(cell6.getQuantity(), 2600)
self.assertEquals(cell6.getPrice(), 0.6) self.assertEquals(cell6.getPrice(), 0.6)
else: else:
self.fail("Unknown salary range for line %s" % paysheet_line.getTitle()) self.fail("Unknown application %s for line %s" % (app_list,paysheet_line.getTitle()))
else:
self.fail("Unknown application %s for line %s" % (app_list,paysheet_line.getTitle()))
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else: else:
...@@ -759,26 +869,35 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -759,26 +869,35 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
if paysheet_line.getSalaryRange() == 'france/slice_200_to_400': app_list = paysheet_line.getBaseApplicationList()
cell1 = paysheet_line.getCell('contribution_share/employee', if 'base_amount/payroll/base/contribution/employee' in app_list:
'salary_range/france/slice_200_to_400') if "base_amount/payroll/l10n/fr/salary_range/slice_200_to_400" in app_list:
cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400')
self.assertEquals(cell1.getQuantity(), 200) self.assertEquals(cell1.getQuantity(), 200)
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(cell1.getPrice(), 0.1)
cell2 = paysheet_line.getCell('contribution_share/employer', elif "base_amount/payroll/l10n/fr/salary_range/slice_600_to_800" in app_list:
'salary_range/france/slice_200_to_400') cell3 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_600_to_800')
self.assertEquals(cell3.getQuantity(), 200)
self.assertEquals(cell3.getPrice(), 0.1)
else:
self.fail("Unknown application %s for line %s" % (app_list,paysheet_line.getTitle()))
elif 'base_amount/payroll/base/contribution/employer' in app_list:
if "base_amount/payroll/l10n/fr/salary_range/slice_200_to_400" in app_list:
cell2 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400')
self.assertEquals(cell2.getQuantity(), 200) self.assertEquals(cell2.getQuantity(), 200)
self.assertEquals(cell2.getPrice(), 0.2) self.assertEquals(cell2.getPrice(), 0.2)
elif paysheet_line.getSalaryRange() == 'france/slice_600_to_800': elif "base_amount/payroll/l10n/fr/salary_range/slice_600_to_800" in app_list:
cell3 = paysheet_line.getCell('contribution_share/employee', cell4 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'salary_range/france/slice_600_to_800') 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_600_to_800')
self.assertEquals(cell3.getQuantity(), 200)
self.assertEquals(cell3.getPrice(), 0.3)
cell4 = paysheet_line.getCell('contribution_share/employer',
'salary_range/france/slice_600_to_800')
self.assertEquals(cell4.getQuantity(), 200) self.assertEquals(cell4.getQuantity(), 200)
self.assertEquals(cell4.getPrice(), 0.4) self.assertEquals(cell4.getPrice(), 0.2)
else: else:
self.fail("Unknown salary range for line %s" % paysheet_line.getTitle()) self.fail("Unknown application %s for line %s" % (app_list,paysheet_line.getTitle()))
else:
self.fail("Unknown application %s for line %s" % (app_list,paysheet_line.getTitle()))
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else: else:
...@@ -791,40 +910,47 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -791,40 +910,47 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
if paysheet_line.getSalaryRange() == 'france/slice_0_to_200': app_list = paysheet_line.getBaseApplicationList()
cell1 = paysheet_line.getCell('contribution_share/employee', if 'base_amount/payroll/base/contribution/employee' in app_list:
'salary_range/france/slice_0_to_200') if "base_amount/payroll/l10n/fr/salary_range/slice_0_to_200" in app_list:
cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200')
self.assertEquals(cell1.getQuantity(), 200) self.assertEquals(cell1.getQuantity(), 200)
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(cell1.getPrice(), 0.1)
cell2 = paysheet_line.getCell('contribution_share/employer', elif "base_amount/payroll/l10n/fr/salary_range/slice_200_to_400" in app_list:
'salary_range/france/slice_0_to_200') cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
self.assertEquals(cell2.getQuantity(), 200) 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400')
self.assertEquals(cell2.getPrice(), 0.2) self.assertEquals(cell1.getQuantity(), 200)
elif paysheet_line.getSalaryRange() == 'france/slice_200_to_400': self.assertEquals(cell1.getPrice(), 0.3)
cell3 = paysheet_line.getCell('contribution_share/employee', elif "base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000" in app_list:
'salary_range/france/slice_200_to_400') cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
self.assertEquals(cell3.getQuantity(), 200) 'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000')
self.assertEquals(cell3.getPrice(), 0.3) self.assertEquals(cell1.getQuantity(), 2600)
cell4 = paysheet_line.getCell('contribution_share/employer', self.assertEquals(cell1.getPrice(), 0.5)
'salary_range/france/slice_200_to_400')
self.assertEquals(cell4.getQuantity(), 200)
self.assertEquals(cell4.getPrice(), 0.4)
elif paysheet_line.getSalaryRange() == 'france/slice_400_to_5000':
cell5 = paysheet_line.getCell('contribution_share/employee',
'salary_range/france/slice_400_to_5000')
self.assertEquals(cell5.getQuantity(), 2600)
self.assertEquals(cell5.getPrice(), 0.5)
cell6 = paysheet_line.getCell('contribution_share/employer',
'salary_range/france/slice_400_to_5000')
self.assertEquals(cell6.getQuantity(), 2600)
self.assertEquals(cell6.getPrice(), 0.6)
else: else:
cell1 = paysheet_line.getCell('contribution_share/employee') cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee')
self.assertEquals(cell1.getQuantity(), 3000) self.assertEquals(cell1.getQuantity(), 3000)
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(cell1.getPrice(), 0.1)
cell2 = paysheet_line.getCell('contribution_share/employer') elif 'base_amount/payroll/base/contribution/employer' in app_list:
self.assertEquals(cell2.getQuantity(), 3000) if "base_amount/payroll/l10n/fr/salary_range/slice_0_to_200" in app_list:
self.assertEquals(cell2.getPrice(), 0.5) cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_0_to_200')
self.assertEquals(cell1.getQuantity(), 200)
self.assertEquals(cell1.getPrice(), 0.2)
elif "base_amount/payroll/l10n/fr/salary_range/slice_200_to_400" in app_list:
cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_200_to_400')
self.assertEquals(cell1.getQuantity(), 200)
self.assertEquals(cell1.getPrice(), 0.4)
elif "base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000" in app_list:
cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
'base_application/base_amount/payroll/l10n/fr/salary_range/slice_400_to_5000')
self.assertEquals(cell1.getQuantity(), 2600)
self.assertEquals(cell1.getPrice(), 0.6)
else:
cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer')
self.assertEquals(cell1.getQuantity(), 3000)
self.assertEquals(cell1.getPrice(), 0.5)
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else: else:
...@@ -836,21 +962,21 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -836,21 +962,21 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell1.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(paysheet_line.getPrice(), 0.1)
cell2 = paysheet_line.getCell('contribution_share/employer') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell2.getPrice(), 0.5) self.assertEquals(paysheet_line.getPrice(), 0.5)
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
elif service == 'Sickness Insurance': elif service == 'Sickness Insurance':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell1.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell1.getPrice(), 0.4) self.assertEquals(paysheet_line.getPrice(), 0.4)
cell2 = paysheet_line.getCell('contribution_share/employer') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell2.getPrice(), 0.3) self.assertEquals(paysheet_line.getPrice(), 0.3)
else: else:
self.fail("Unknown service for line %s" % paysheet_line.getTitle()) self.fail("Unknown service for line %s" % paysheet_line.getTitle())
...@@ -860,21 +986,21 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -860,21 +986,21 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell1.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(paysheet_line.getPrice(), 0.1)
cell2 = paysheet_line.getCell('contribution_share/employer') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell2.getPrice(), 0.5) self.assertEquals(paysheet_line.getPrice(), 0.5)
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
elif service == 'Old Age Insurance': elif service == 'Old Age Insurance':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell1.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell1.getPrice(), 0.5) self.assertEquals(paysheet_line.getPrice(), 0.5)
cell2 = paysheet_line.getCell('contribution_share/employer') if paysheet_line.getBaseContribution() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getQuantity(), 3000) self.assertEquals(paysheet_line.getQuantity(), 3000)
self.assertEquals(cell2.getPrice(), 0.8) self.assertEquals(paysheet_line.getPrice(), 0.8)
else: else:
self.fail("Unknown service for line %s" % paysheet_line.getTitle()) self.fail("Unknown service for line %s" % paysheet_line.getTitle())
...@@ -899,6 +1025,17 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -899,6 +1025,17 @@ class TestPayrollMixin(TestTradeModelLineMixin):
business_link.setSourceSectionValue(sequence.get('urssaf_roubaix')) business_link.setSourceSectionValue(sequence.get('urssaf_roubaix'))
business_link.setDeliveryBuilderList(('portal_deliveries/pay_sheet_builder',)) business_link.setDeliveryBuilderList(('portal_deliveries/pay_sheet_builder',))
sequence.edit(business_link=business_link) sequence.edit(business_link=business_link)
# Add a trade model path
business_process = sequence.get('business_process')
urssaf_roubaix = sequence.get('urssaf_roubaix')
business_process.newContent(portal_type='Trade Model Path',
trade_phase_list=['payroll/france/urssaf',
'payroll/france/labour'],
reference="paysheet_path",
efficiency=1.0,
source_section_value=urssaf_roubaix,
)
def stepModelSpecialiseBusinessProcess(self, sequence=None, **kw): def stepModelSpecialiseBusinessProcess(self, sequence=None, **kw):
model = sequence.get('model') model = sequence.get('model')
...@@ -915,10 +1052,10 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -915,10 +1052,10 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell1.getSourceSectionValue(), urssaf_roubaix) self.assertEquals(paysheet_line.getSourceSectionValue(), urssaf_roubaix)
cell2 = paysheet_line.getCell('contribution_share/employer') if paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getSourceSectionValue(), urssaf_roubaix) self.assertEquals(paysheet_line.getSourceSectionValue(), urssaf_roubaix)
elif service == 'Labour': elif service == 'Labour':
pass pass
else: else:
...@@ -1094,8 +1231,9 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -1094,8 +1231,9 @@ class TestPayrollMixin(TestTradeModelLineMixin):
int_index = 10, int_index = 10,
reference='intermediate_line', reference='intermediate_line',
price=0.2, price=0.2,
base_contribution_list=['base_amount/payroll/base/income_tax'], base_contribution_list=['base_amount/payroll/base/income_tax/employee',
base_application_list=['base_amount/payroll/base/contribution']) 'base_amount/payroll/base/income_tax/employer'],
base_application_list=['base_amount/payroll/base/contribution/employee',])
sequence.edit(intermediate_model_line = model_line) sequence.edit(intermediate_model_line = model_line)
def stepModelCreateAppliedOnTaxModelLine(self, sequence=None, **kw): def stepModelCreateAppliedOnTaxModelLine(self, sequence=None, **kw):
...@@ -1109,24 +1247,25 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -1109,24 +1247,25 @@ class TestPayrollMixin(TestTradeModelLineMixin):
trade_phase='payroll/france/urssaf', trade_phase='payroll/france/urssaf',
resource_value=sequence.get('urssaf_service'), resource_value=sequence.get('urssaf_service'),
reference='line_applied_on_intermediate_line', reference='line_applied_on_intermediate_line',
variation_category_list=['contribution_share/employee', variation_category_list=['base_application/base_amount/payroll/base/income_tax/employee',
'contribution_share/employer'], 'base_application/base_amount/payroll/base/income_tax/employer'],
base_contribution_list=['base_amount/payroll/report/salary/net'], base_contribution_list=['base_amount/payroll/report/salary/net'],)
base_application_list=['base_amount/payroll/base/income_tax'])
sequence.edit(model_line_applied_on_tax = model_line) sequence.edit(model_line_applied_on_tax = model_line)
def stepAppliedOnTaxModelLineCreateMovements(self, sequence=None, **kw): def stepAppliedOnTaxModelLineCreateMovements(self, sequence=None, **kw):
model_line = sequence.get('model_line_applied_on_tax') model_line = sequence.get('model_line_applied_on_tax')
cell1 = model_line.newCell('contribution_share/employee', cell1 = model_line.newCell('base_application/base_amount/payroll/base/income_tax/employee',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/base/income_tax/employee',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(price=0.1, quantity=None, contribution_share='employee') cell1.edit(price=0.1, quantity=None)
cell2 = model_line.newCell('contribution_share/employer', cell2 = model_line.newCell('base_application/base_amount/payroll/base/income_tax/employer',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_id='movement', base_id='movement',
base_application='base_amount/payroll/base/income_tax/employer',
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.5, quantity=None, contribution_share='employer') cell2.edit(price=0.5, quantity=None)
def stepModelCreateOldAgeInsuranceModelLine(self, sequence=None, **kw): def stepModelCreateOldAgeInsuranceModelLine(self, sequence=None, **kw):
model = sequence.get('model') model = sequence.get('model')
...@@ -1135,26 +1274,25 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -1135,26 +1274,25 @@ class TestPayrollMixin(TestTradeModelLineMixin):
trade_phase='payroll/france/urssaf', trade_phase='payroll/france/urssaf',
resource_value=sequence.get('old_age_insurance_service'), resource_value=sequence.get('old_age_insurance_service'),
reference='old_age_insurance', reference='old_age_insurance',
variation_category_list=['contribution_share/employee', variation_category_list=['base_application/base_amount/payroll/base/contribution/employee',
'contribution_share/employer'], 'base_application/base_amount/payroll/base/contribution/employer'],
base_application_list=[ 'base_amount/payroll/base/contribution'],
base_contribution_list=['base_amount/payroll/base/income_tax']) base_contribution_list=['base_amount/payroll/base/income_tax'])
sequence.edit(old_age_insurance = model_line) sequence.edit(old_age_insurance = model_line)
def stepOldAgeInsuranceModelLineCreateMovements(self, sequence=None, **kw): def stepOldAgeInsuranceModelLineCreateMovements(self, sequence=None, **kw):
model_line = sequence.get('old_age_insurance') model_line = sequence.get('old_age_insurance')
cell1 = model_line.newCell('contribution_share/employee', cell1 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employee',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employee',
base_id='movement', base_id='movement',
quantity=None,
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(price=0.5, contribution_share='employee') cell1.edit(price=0.5, quantity=None)
cell2 = model_line.newCell('contribution_share/employer', cell2 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employer',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employer',
base_id='movement', base_id='movement',
quantity=None,
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.8, contribution_share='employer') cell2.edit(price=0.8, quantity=None)
def stepModelCreateSicknessInsuranceModelLine(self, sequence=None, **kw): def stepModelCreateSicknessInsuranceModelLine(self, sequence=None, **kw):
model = sequence.get('model') model = sequence.get('model')
...@@ -1163,48 +1301,51 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -1163,48 +1301,51 @@ class TestPayrollMixin(TestTradeModelLineMixin):
trade_phase='payroll/france/urssaf', trade_phase='payroll/france/urssaf',
resource_value=sequence.get('sickness_insurance_service'), resource_value=sequence.get('sickness_insurance_service'),
reference='sickness_insurance', reference='sickness_insurance',
variation_category_list=['contribution_share/employee', variation_category_list=['base_application/base_amount/payroll/base/contribution/employee',
'contribution_share/employer'], 'base_application/base_amount/payroll/base/contribution/employer'],
base_application_list=[ 'base_amount/payroll/base/contribution'], base_contribution_list=['base_amount/payroll/base/income_tax'],)
base_contribution_list=['base_amount/payroll/base/income_tax'])
sequence.edit(sickness_insurance = model_line) sequence.edit(sickness_insurance = model_line)
def stepSicknessInsuranceModelLineCreateMovements(self, sequence=None, **kw): def stepSicknessInsuranceModelLineCreateMovements(self, sequence=None, **kw):
model_line = sequence.get('sickness_insurance') model_line = sequence.get('sickness_insurance')
cell1 = model_line.newCell('contribution_share/employee', cell1 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employee',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employee',
base_id='movement', base_id='movement',
quantity=None,
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell1.edit(price=0.4, contribution_share='employee') cell1.edit(price=0.4, quantity=None)
cell2 = model_line.newCell('contribution_share/employer', cell2 = model_line.newCell('base_application/base_amount/payroll/base/contribution/employer',
portal_type='Pay Sheet Model Cell', portal_type='Pay Sheet Model Cell',
base_application='base_amount/payroll/base/contribution/employer',
base_id='movement', base_id='movement',
quantity=None,
mapped_value_property_list=('quantity', 'price')) mapped_value_property_list=('quantity', 'price'))
cell2.edit(price=0.3, contribution_share='employer') cell2.edit(price=0.3, quantity=None)
def stepCheckPaysheetIntermediateLines(self, sequence=None, **kw): def stepCheckPaysheetIntermediateLines(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
# paysheet should contain only two lines (labour and urssaf, but not # paysheet should contain only three lines (labour and 2 urssaf, but not
# intermediate urssaf # intermediate urssaf
self.assertEquals(len(paysheet.contentValues(portal_type=\ self.assertEquals(len(paysheet.contentValues(portal_type=\
'Pay Sheet Line')), 2) 'Pay Sheet Line')), 3)
# check amounts # check amounts
paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line') paysheet_line_list = paysheet.contentValues(portal_type='Pay Sheet Line')
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseApplication() == 'base_amount/payroll/base/income_tax/employee':
cell1 = paysheet_line.getCell('base_application/base_amount/payroll/base/income_tax/employee')
self.assertEquals(cell1.getQuantity(), 600) # here it's 600 of tax self.assertEquals(cell1.getQuantity(), 600) # here it's 600 of tax
# because of the intermediate line (3000*0.2) # because of the intermediate line (3000*0.2)
self.assertEquals(cell1.getPrice(), 0.1) self.assertEquals(cell1.getPrice(), 0.1)
cell2 = paysheet_line.getCell('contribution_share/employer') elif paysheet_line.getBaseApplication() == 'base_amount/payroll/base/income_tax/employer':
cell2 = paysheet_line.getCell('base_application/base_amount/payroll/base/income_tax/employer')
self.assertEquals(cell2.getQuantity(), 600) # here it's 600 of tax self.assertEquals(cell2.getQuantity(), 600) # here it's 600 of tax
# because of the intermediate line (3000*0.2) # because of the intermediate line (3000*0.2)
self.assertEquals(cell2.getPrice(), 0.5) self.assertEquals(cell2.getPrice(), 0.5)
else:
self.fail("Unknown application for %s line %s" % (paysheet_line.getBaseApplication(), paysheet_line.getTitle()))
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else: else:
...@@ -1212,20 +1353,19 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -1212,20 +1353,19 @@ class TestPayrollMixin(TestTradeModelLineMixin):
def stepModelModifyUrssafModelLine(self, sequence=None, **kw): def stepModelModifyUrssafModelLine(self, sequence=None, **kw):
model_line = sequence.get('urssaf_model_line') model_line = sequence.get('urssaf_model_line')
# modify price on movements : cell_1 = model_line.getCell('base_application/base_amount/payroll/base/contribution/employee',
cell_1 = model_line.getCell('contribution_share/employee',
base_id='movement') base_id='movement')
self.assertNotEquals(cell_1, None) self.assertNotEquals(cell_1, None)
cell_1.edit(price=0.2) cell_1.edit(price=0.2, quantity=None)
cell_2 = model_line.getCell('contribution_share/employer', cell_2 = model_line.getCell('base_application/base_amount/payroll/base/contribution/employer',
base_id='movement') base_id='movement')
self.assertNotEquals(cell_2, None) self.assertNotEquals(cell_2, None)
cell_2.edit(price=0.6) cell_2.edit(price=0.6, quantity=None)
def stepModelDelUrssafModelLine(self, sequence=None, **kw): def stepModelDelUrssafModelLine(self, sequence=None, **kw):
model_line = sequence.get('urssaf_model_line') model_line = sequence.get('urssaf_model_line')
model = sequence.get('model') model = sequence.get('model')
model.manage_delObjects(model_line.getId()) model.manage_delObjects([model_line.getId(),])
def stepCheckPaysheetLineNewAmountsAfterUpdate(self, sequence=None, **kw): def stepCheckPaysheetLineNewAmountsAfterUpdate(self, sequence=None, **kw):
paysheet = sequence.get('paysheet') paysheet = sequence.get('paysheet')
...@@ -1233,12 +1373,14 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -1233,12 +1373,14 @@ class TestPayrollMixin(TestTradeModelLineMixin):
for paysheet_line in paysheet_line_list: for paysheet_line in paysheet_line_list:
service = paysheet_line.getResourceTitle() service = paysheet_line.getResourceTitle()
if service == 'Urssaf': if service == 'Urssaf':
cell1 = paysheet_line.getCell('contribution_share/employee') if paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employee":
self.assertEquals(cell1.getQuantity(), 3000) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employee')
self.assertEquals(cell1.getPrice(), 0.2) self.assertEquals(cell.getQuantity(), 3000)
cell2 = paysheet_line.getCell('contribution_share/employer') self.assertEquals(cell.getPrice(), 0.2)
self.assertEquals(cell2.getQuantity(), 3000) if paysheet_line.getBaseApplication() == "base_amount/payroll/base/contribution/employer":
self.assertEquals(cell2.getPrice(), 0.6) cell = paysheet_line.getCell('base_application/base_amount/payroll/base/contribution/employer')
self.assertEquals(cell.getQuantity(), 3000)
self.assertEquals(cell.getPrice(), 0.6)
elif service == 'Labour': elif service == 'Labour':
self.assertEqual(paysheet_line.getTotalPrice(), 3000.0) self.assertEqual(paysheet_line.getTotalPrice(), 3000.0)
else: else:
...@@ -1375,19 +1517,24 @@ class TestPayrollMixin(TestTradeModelLineMixin): ...@@ -1375,19 +1517,24 @@ class TestPayrollMixin(TestTradeModelLineMixin):
# if the line has cells with different tax categories, new properties are # if the line has cells with different tax categories, new properties are
# added to this line. # added to this line.
urssaf_service = sequence.get('urssaf_service') urssaf_service = sequence.get('urssaf_service')
urssaf_service.edit(variation_base_category_list=['base_contribution'])
urssaf_service.setVariationCategoryList(['base_contribution/base_amount/payroll/base/contribution/employee',
'base_contribution/base_amount/payroll/base/contribution/employer'
])
line.setResourceValue(urssaf_service) line.setResourceValue(urssaf_service)
line.setVariationCategoryList(['contribution_share/employee', line.setVariationCategoryList(['base_contribution/base_amount/payroll/base/contribution/employee',
'contribution_share/employer']) 'base_contribution/base_amount/payroll/base/contribution/employer'
cell0 = line.newCell('contribution_share/employee', ])
cell0 = line.newCell('base_contribution/base_amount/payroll/base/contribution/employee',
portal_type='Pay Sheet Cell', base_id='movement') portal_type='Pay Sheet Cell', base_id='movement')
cell0.setMappedValuePropertyList(['quantity', 'price']) cell0.setMappedValuePropertyList(['quantity', 'price'])
cell0.setVariationCategoryList(('contribution_share/employee',)) cell0.setVariationCategoryList(('base_contribution/base_amount/payroll/base/contribution/employee',))
cell0.setPrice(2.0) cell0.setPrice(2.0)
cell0.setQuantity(3.0) cell0.setQuantity(3.0)
cell1 = line.newCell('contribution_share/employer', cell1 = line.newCell('base_contribution/base_amount/payroll/base/contribution/employer',
portal_type='Pay Sheet Cell', base_id='movement') portal_type='Pay Sheet Cell', base_id='movement')
cell1.setMappedValuePropertyList(['quantity', 'price']) cell1.setMappedValuePropertyList(['quantity', 'price'])
cell1.setVariationCategoryList(('contribution_share/employer',)) cell1.setVariationCategoryList(('base_contribution/base_amount/payroll/base/contribution/employer',))
cell1.setPrice(4.0) cell1.setPrice(4.0)
cell1.setQuantity(5.0) cell1.setQuantity(5.0)
...@@ -2319,6 +2466,8 @@ class TestPayroll(TestPayrollMixin): ...@@ -2319,6 +2466,8 @@ class TestPayroll(TestPayrollMixin):
variation_base_category_list=('contribution_share',), variation_base_category_list=('contribution_share',),
variation_category_list=('contribution_share/employee', variation_category_list=('contribution_share/employee',
'contribution_share/employer')) 'contribution_share/employer'))
business_process = self.createBPMRelated()
employer = self.portal.organisation_module.newContent( employer = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
title='Employer', title='Employer',
...@@ -2481,6 +2630,8 @@ class TestPayroll(TestPayrollMixin): ...@@ -2481,6 +2630,8 @@ class TestPayroll(TestPayrollMixin):
'contribution_share/employer', 'contribution_share/employer',
'salary_range/france/slice_a', 'salary_range/france/slice_a',
'salary_range/france/slice_b')) 'salary_range/france/slice_b'))
business_process = self.createBPMRelated()
employer = self.portal.organisation_module.newContent( employer = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
title='Employer', title='Employer',
...@@ -2505,6 +2656,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2505,6 +2656,7 @@ class TestPayroll(TestPayrollMixin):
ps1 = self.portal.accounting_module.newContent( ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
title='Employee 1', title='Employee 1',
specialise_value=business_process,
destination_section_value=employer, destination_section_value=employer,
source_section_value=employee1, source_section_value=employee1,
start_date=DateTime(2006, 1, 1),) start_date=DateTime(2006, 1, 1),)
...@@ -2560,6 +2712,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2560,6 +2712,7 @@ class TestPayroll(TestPayrollMixin):
ps2 = self.portal.accounting_module.newContent( ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
title='Employee 2', title='Employee 2',
specialise_value=business_process,
destination_section_value=employer, destination_section_value=employer,
source_section_value=employee2, source_section_value=employee2,
start_date=DateTime(2006, 1, 1),) start_date=DateTime(2006, 1, 1),)
...@@ -2702,6 +2855,8 @@ class TestPayroll(TestPayrollMixin): ...@@ -2702,6 +2855,8 @@ class TestPayroll(TestPayrollMixin):
variation_base_category_list=('contribution_share',), variation_base_category_list=('contribution_share',),
variation_category_list=('contribution_share/employee', variation_category_list=('contribution_share/employee',
'contribution_share/employer')) 'contribution_share/employer'))
business_process = self.createBPMRelated()
employer = self.portal.organisation_module.newContent( employer = self.portal.organisation_module.newContent(
portal_type='Organisation', portal_type='Organisation',
title='Employer', title='Employer',
...@@ -2730,6 +2885,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2730,6 +2885,7 @@ class TestPayroll(TestPayrollMixin):
ps1 = self.portal.accounting_module.newContent( ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
title='Employee 1', title='Employee 1',
specialise_value=business_process,
destination_section_value=employer, destination_section_value=employer,
source_section_value=employee1, source_section_value=employee1,
payment_condition_source_payment_value=employee1_ba, payment_condition_source_payment_value=employee1_ba,
...@@ -2770,6 +2926,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -2770,6 +2926,7 @@ class TestPayroll(TestPayrollMixin):
ps2 = self.portal.accounting_module.newContent( ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
title='Employee 2', title='Employee 2',
specialise_value=business_process,
destination_section_value=employer, destination_section_value=employer,
source_section_value=employee2, source_section_value=employee2,
payment_condition_source_payment_value=employee2_ba, payment_condition_source_payment_value=employee2_ba,
...@@ -2841,6 +2998,39 @@ class TestPayroll(TestPayrollMixin): ...@@ -2841,6 +2998,39 @@ class TestPayroll(TestPayrollMixin):
line_list[-1], line_list[-1],
total_price=3000 + 2000 - (2000 * .5) - (3000 * .5)) total_price=3000 + 2000 - (2000 * .5) - (3000 * .5))
def createBPMRelated(self):
#raise ValueError
business_process = self.createBusinessProcess()
business_link = self.createBusinessLink(business_process)
business_process.newContent(portal_type='Trade Model Path',
trade_phase_list=['default/order',],
trade_date='trade_phase/default/order',
reference="path_order",
efficiency=1.0,
)
business_process.newContent(portal_type='Trade Model Path',
trade_phase_list=['default/delivery',],
trade_date='trade_phase/default/order',
reference="path_delivery",
efficiency=1.0,
)
business_process.newContent(portal_type='Trade Model Path',
trade_phase_list=['default/invoicing',],
trade_date='trade_phase/default/delivery',
reference="path_invoicing",
efficiency=1.0,
)
business_process.newContent(portal_type='Trade Model Path',
trade_phase_list=['default/accounting',],
trade_date='trade_phase/default/accounting',
reference="path_accounting",
efficiency=1.0,
)
return business_process
def test_AccountingLineGeneration(self): def test_AccountingLineGeneration(self):
currency_module = self.getCurrencyModule() currency_module = self.getCurrencyModule()
if not hasattr(currency_module, 'EUR'): if not hasattr(currency_module, 'EUR'):
...@@ -2895,6 +3085,8 @@ class TestPayroll(TestPayrollMixin): ...@@ -2895,6 +3085,8 @@ class TestPayroll(TestPayrollMixin):
title='Payroll Taxes', title='Payroll Taxes',
account_type='liability/payable',) account_type='liability/payable',)
business_process = self.createBPMRelated()
# create an invoice transaction rule for pay sheets. # create an invoice transaction rule for pay sheets.
rule = self.portal.portal_rules.newContent( rule = self.portal.portal_rules.newContent(
portal_type='Invoice Transaction Simulation Rule', portal_type='Invoice Transaction Simulation Rule',
...@@ -3030,6 +3222,7 @@ class TestPayroll(TestPayrollMixin): ...@@ -3030,6 +3222,7 @@ class TestPayroll(TestPayrollMixin):
ps = self.portal.accounting_module.newContent( ps = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction', portal_type='Pay Sheet Transaction',
specialise_value=business_process,
price_currency_value=eur, price_currency_value=eur,
resource_value=eur, resource_value=eur,
title='Employee 1', title='Employee 1',
......
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