Commit b867e63d authored by Fabien Morin's avatar Fabien Morin

update the file to check that slices works and we can caculate the total amount spend on a slice


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@26067 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b504399f
......@@ -26,31 +26,22 @@
#
##############################################################################
"""
Tests paysheet creation using paysheet model.
TODO:
this test currently just verify that this bt could be installed,
test method must be add to verify things specific to this localised bt.
test cases related to french localisation (tranche A for example)
"""
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Acquisition import aq_parent
from Products.ERP5.tests.testPayroll import TestPayrollMixin
from DateTime import DateTime
import transaction
class TestPayroll_l10n_fr(ERP5TypeTestCase):
run_all_test = 1
quiet = 1
class TestPayroll_l10n_fr(TestPayrollMixin):
def getTitle(self):
return "Payroll_l10n_fr"
def afterSetUp(self):
"""Prepare the test."""
self.portal = self.getPortal()
self.login()
def login(self, quiet=0, run=1):
def login(self):
uf = self.getPortal().acl_users
uf._doAddUser('admin', 'admin', ['Manager', 'Assignee', 'Assignor',
'Associate', 'Auditor', 'Author'], [])
......@@ -63,16 +54,125 @@ class TestPayroll_l10n_fr(ERP5TypeTestCase):
'erp5_payroll', 'erp5_payroll_l10n_fr')
def test_01_btInstallation(self, quiet=0, run=run_all_test):
def test_01_btInstallation(self):
'''
this test must be replace with real test
it's just here because a test method must be present to launch test
'''
if not run: return
if not quiet:
self.logMessage('BT Installation')
pass
def test_01_getYearToDateSlice(self):
'''
that slices works and we can caculate the total amount spend on a slice
'''
eur = self.portal.currency_module.EUR
model = self.paysheet_model_module.newContent( \
portal_type='Pay Sheet Model',
variation_settings_category_list=self.variation_settings_category_list)
model.setPriceCurrencyValue(eur)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_slice_a, 0, 1000)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_slice_b, 1000, 2000)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_slice_c, 2000, 10000000)
self.addSlice(model, 'salary_range/%s' % \
self.france_settings_forfait, 0, 10000000)
urssaf_slice_list = [ 'salary_range/'+self.france_settings_slice_a,]
urssaf_share_list = [ 'tax_category/'+self.tax_category_employee_share,]
salary_slice_list = ['salary_range/'+self.france_settings_forfait,]
salary_share_list = ['tax_category/'+self.tax_category_employee_share,]
variation_category_list_urssaf = urssaf_share_list + urssaf_slice_list
variation_category_list_salary = salary_share_list + salary_slice_list
model_line_1 = self.createModelLine(model=model,
id='model_line_1',
variation_category_list=variation_category_list_salary,
resource=self.labour,
share_list=salary_share_list,
slice_list=salary_slice_list,
values=[[[10000, None],],],
base_application_list=[],
base_contribution_list=['base_amount/base_salary',
'base_amount/gross_salary'])
model_line_1.setIntIndex(1)
model_line_2 = self.createModelLine(model=model,
id='model_line_2',
variation_category_list=variation_category_list_urssaf,
resource=self.urssaf,
share_list=urssaf_share_list,
slice_list=urssaf_slice_list,
values=[[[None, 0.8]],],
source_value=self.payroll_service_organisation,
base_application_list=[ 'base_amount/base_salary',],
base_contribution_list=['base_amount/net_salary',])
model_line_2.setIntIndex(2)
model_line_3 = self.createModelLine(model=model,
id='model_line_3',
variation_category_list=variation_category_list_urssaf,
resource=self.urssaf,
share_list=urssaf_share_list,
slice_list=urssaf_slice_list,
values=[[[None, -0.1]],],
source_value=self.payroll_service_organisation,
base_application_list=[ 'base_amount/net_salary',],
base_contribution_list=['base_amount/deductible_tax',])
model_line_3.setIntIndex(3)
# create a paysheet with two lines
paysheet = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
specialise_value=model,
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
def test_suite():
suite = unittest.TestSuite()
......
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