Commit c88e69e3 authored by Fabien Morin's avatar Fabien Morin

move and update some test from testPayroll to testNewPayroll


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@27619 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d9e1a629
...@@ -119,6 +119,7 @@ class TestNewPayrollMixin(ERP5ReportTestCase, TestBPMMixin): ...@@ -119,6 +119,7 @@ class TestNewPayrollMixin(ERP5ReportTestCase, TestBPMMixin):
'salary_range/france/slice_600_to_800', 'salary_range/france/slice_600_to_800',
'marital_status/married', 'marital_status/married',
'marital_status/single', 'marital_status/single',
'group/demo_group',
) )
def getBusinessTemplateList(self): def getBusinessTemplateList(self):
...@@ -1814,6 +1815,548 @@ class TestNewPayroll(TestNewPayrollMixin): ...@@ -1814,6 +1815,548 @@ class TestNewPayroll(TestNewPayrollMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_PayrollTaxesReport(self):
currency_module = self.getCurrencyModule()
if not hasattr(currency_module, 'EUR'):
currency_module.newContent(
portal_type = 'Currency',
reference = "EUR", id = "EUR", base_unit_quantity=0.001 )
eur = self.portal.currency_module.EUR
service = self.portal.service_module.newContent(
portal_type='Service',
title='PS1',
variation_base_category_list=('tax_category',),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
employer = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Employer',
price_currency_value=eur,
group_value=self.portal.portal_categories.group.demo_group)
employee1 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee One',
career_reference='E1',
career_subordination_value=employer)
employee2 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee Two',
career_reference='E2',
career_subordination_value=employer)
provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Service Provider')
other_provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Another Service Provider')
ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 1',
destination_section_value=employer,
source_section_value=employee1,
start_date=DateTime(2006, 1, 1),)
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
# (destination is set by PaySheetTransaction.createPaySheetLine)
destination_value=employee1,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=2000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=2000, tax_category='employer_share')
ps1.plan()
ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 2',
destination_section_value=employer,
source_section_value=employee2,
start_date=DateTime(2006, 1, 1),)
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee2,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=3000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=3000, tax_category='employer_share')
other_line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
destination_value=employee2,
source_section_value=other_provider,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = other_line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.46, quantity=2998, tax_category='employee_share')
cell_employer = other_line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.42, quantity=2998, tax_category='employer_share')
transaction.commit()
self.tic()
# AccountingTransactionModule_getPaySheetMovementMirrorSectionItemList is
# used in the report dialog to display possible organisations.
self.assertEquals(
[('', ''),
(other_provider.getTitle(), other_provider.getRelativeUrl()),
(provider.getTitle(), provider.getRelativeUrl())],
self.portal.accounting_module\
.AccountingTransactionModule_getPaySheetMovementMirrorSectionItemList())
# set request variables and render
request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned']
request_form['resource'] = service.getRelativeUrl()
request_form['mirror_section'] = provider.getRelativeUrl()
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountingTransactionModule_viewPaySheetLineReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list))
# base_unit_quantity for EUR is set to 0.001 in createCurrencies, so the
# precision is 3
precision = self.portal.REQUEST.get('precision')
self.assertEquals(3, precision)
self.checkLineProperties(data_line_list[0],
id=1,
employee_career_reference='E1',
employee_title='Employee One',
base=2000,
employee_share=2000 * .50,
employer_share=2000 * .40,
total=(2000 * .50 + 2000 * .40))
self.checkLineProperties(data_line_list[1],
id=2,
employee_career_reference='E2',
employee_title='Employee Two',
base=3000,
employee_share=3000 * .50,
employer_share=3000 * .40,
total=(3000 * .50 + 3000 * .40))
# stat line
self.checkLineProperties(line_list[-1],
base=3000 + 2000,
employee_share=(3000 + 2000) * .50,
employer_share=(3000 + 2000) * .40,
total=((3000 + 2000) * .50 + (3000 + 2000) * .40))
def test_PayrollTaxesReportDifferentSalaryRange(self):
currency_module = self.getCurrencyModule()
if not hasattr(currency_module, 'EUR'):
currency_module.newContent(
portal_type = 'Currency',
reference = "EUR", id = "EUR", base_unit_quantity=0.001 )
eur = self.portal.currency_module.EUR
service = self.portal.service_module.newContent(
portal_type='Service',
title='PS1',
variation_base_category_list=('tax_category',
'salary_range'),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share',
'salary_range/france/slice_a',
'salary_range/france/slice_b'))
employer = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Employer',
price_currency_value=eur,
group_value=self.portal.portal_categories.group.demo_group)
employee1 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee One',
career_reference='E1',
career_subordination_value=employer)
employee2 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee Two',
career_reference='E2',
career_subordination_value=employer)
provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Service Provider')
other_provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Another Service Provider')
ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 1',
destination_section_value=employer,
source_section_value=employee1,
start_date=DateTime(2006, 1, 1),)
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
# (destination is set by PaySheetTransaction.createPaySheetLine)
destination_value=employee1,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share',
'salary_range/france/slice_a',
'salary_range/france/slice_b'))
cell_employee_a = line.newCell('tax_category/employee_share',
'salary_range/france/slice_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_a.edit(price=-.50, quantity=1000,
tax_category='employee_share',
salary_range='france/slice_a')
cell_employee_b = line.newCell('tax_category/employee_share',
'salary_range/france/slice_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_b.edit(price=-.20, quantity=500,
tax_category='employee_share',
salary_range='france/slice_b')
cell_employer_a = line.newCell('tax_category/employer_share',
'salary_range/france/slice_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_a.edit(price=-.40, quantity=1000,
tax_category='employer_share',
salary_range='france/slice_a')
cell_employer_b = line.newCell('tax_category/employer_share',
'salary_range/france/slice_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_b.edit(price=-.32, quantity=500,
tax_category='employer_share',
salary_range='france/slice_b')
ps1.plan()
ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 2',
destination_section_value=employer,
source_section_value=employee2,
start_date=DateTime(2006, 1, 1),)
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee2,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share',
'salary_range/france/slice_a',
'salary_range/france/slice_b'))
cell_employee_a = line.newCell('tax_category/employee_share',
'salary_range/france/slice_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_a.edit(price=-.50, quantity=1000,
salary_range='france/slice_a',
tax_category='employee_share')
cell_employee_b = line.newCell('tax_category/employee_share',
'salary_range/france/slice_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_b.edit(price=-.20, quantity=3000,
salary_range='france/slice_b',
tax_category='employee_share')
cell_employer_a = line.newCell('tax_category/employer_share',
'salary_range/france/slice_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_a.edit(price=-.40, quantity=1000,
salary_range='france/slice_a',
tax_category='employer_share')
cell_employer_b = line.newCell('tax_category/employer_share',
'salary_range/france/slice_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_b.edit(price=-.32, quantity=3000,
salary_range='france/slice_b',
tax_category='employer_share')
transaction.commit()
self.tic()
# set request variables and render
request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned']
request_form['resource'] = service.getRelativeUrl()
request_form['mirror_section'] = provider.getRelativeUrl()
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountingTransactionModule_viewPaySheetLineReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(6, len(data_line_list))
self.checkLineProperties(data_line_list[0],
id=1,
employee_career_reference='E1',
employee_title='Employee One',
base=1000,
employee_share=1000 * .50,
employer_share=1000 * .40,
total=(1000 * .50 + 1000 * .40))
self.checkLineProperties(data_line_list[1],
id=2,
employee_career_reference='E2',
employee_title='Employee Two',
base=1000,
employee_share=1000 * .50,
employer_share=1000 * .40,
total=(1000 * .50 + 1000 * .40))
self.checkLineProperties(data_line_list[2],
employee_title='Total Slice A',
base=2000,
employee_share=2000 * .50,
employer_share=2000 * .40,
#total=(2000 * .50 + 2000 * .40)
)
self.checkLineProperties(data_line_list[3],
id=3,
employee_career_reference='E1',
employee_title='Employee One',
base=500,
employee_share=500 * .20,
employer_share=500 * .32,
total=(500 * .20 + 500 * .32))
self.checkLineProperties(data_line_list[4],
id=4,
employee_career_reference='E2',
employee_title='Employee Two',
base=3000,
employee_share=3000 * .20,
employer_share=3000 * .32,
total=(3000 * .20 + 3000 * .32))
self.checkLineProperties(data_line_list[5],
employee_title='Total Slice B',
base=3500,
employee_share=3500 * .20,
employer_share=3500 * .32,
#total=(3500 * .20 + 3500 * .32),
)
# stat line
self.checkLineProperties(line_list[-1],
base=2000 + 3500,
employee_share=(2000 * .50 + 3500 * .20),
employer_share=(2000 * .40 + 3500 * .32),
total=((2000 * .50 + 3500 * .20) +
(2000 * .40 + 3500 * .32)))
def test_NetSalaryReport(self):
currency_module = self.getCurrencyModule()
if not hasattr(currency_module, 'EUR'):
currency_module.newContent(
portal_type = 'Currency',
reference = "EUR", id = "EUR", base_unit_quantity=0.001 )
eur = self.portal.currency_module.EUR
salary_service = self.portal.service_module.newContent(
portal_type='Service',
title='Gross Salary',
variation_base_category_list=('tax_category',),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
service = self.portal.service_module.newContent(
portal_type='Service',
title='PS1',
variation_base_category_list=('tax_category',),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
employer = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Employer',
price_currency_value=eur,
group_value=self.portal.portal_categories.group.demo_group)
employee1 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee One',
career_reference='E1',
career_subordination_value=employer)
employee1_ba = employee1.newContent(portal_type='Bank Account',
title='Bank 1')
employee2 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee Two',
career_reference='E2',
career_subordination_value=employer)
employee2_ba = employee2.newContent(portal_type='Bank Account',
title='Bank 2')
provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Service Provider')
other_provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Another Service Provider')
ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 1',
destination_section_value=employer,
source_section_value=employee1,
payment_condition_source_payment_value=employee1_ba,
start_date=DateTime(2006, 1, 1),)
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=salary_service,
destination_value=employee1,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=1, quantity=2000, tax_category='employee_share')
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee1,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=2000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=2000, tax_category='employer_share')
ps1.plan()
ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 2',
destination_section_value=employer,
source_section_value=employee2,
payment_condition_source_payment_value=employee2_ba,
start_date=DateTime(2006, 1, 1),)
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=salary_service,
destination_value=employee2,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=1, quantity=3000, tax_category='employee_share')
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee2,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=3000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=3000, tax_category='employer_share')
transaction.commit()
self.tic()
# set request variables and render
request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned']
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountingTransactionModule_viewNetSalaryReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list))
# base_unit_quantity for EUR is set to 0.001 in createCurrencies, so the
# precision is 3
precision = self.portal.REQUEST.get('precision')
self.assertEquals(3, precision)
self.checkLineProperties(data_line_list[0],
employee_career_reference='E1',
employee_title='Employee One',
employee_bank_account='Bank 1',
total_price=2000 - (2000 * .5),)
self.checkLineProperties(data_line_list[1],
employee_career_reference='E2',
employee_title='Employee Two',
employee_bank_account='Bank 2',
total_price=3000 - (3000 * .5),)
# stat line
self.checkLineProperties(
line_list[-1],
total_price=3000 + 2000 - (2000 * .5) - (3000 * .5))
import unittest import unittest
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -576,533 +576,6 @@ class TestPayroll(TestPayrollMixin): ...@@ -576,533 +576,6 @@ class TestPayroll(TestPayrollMixin):
pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line') pay_sheet_line_list = pay_sheet.contentValues(portal_type='Pay Sheet Line')
self.assertEquals(0, len(pay_sheet_line_list)) self.assertEquals(0, len(pay_sheet_line_list))
def test_PayrollTaxesReport(self):
eur = self.portal.currency_module.EUR
service = self.portal.service_module.newContent(
portal_type='Service',
title='PS1',
variation_base_category_list=('tax_category',),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
employer = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Employer',
price_currency_value=eur,
group_value=self.portal.portal_categories.group.demo_group)
employee1 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee One',
career_reference='E1',
career_subordination_value=employer)
employee2 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee Two',
career_reference='E2',
career_subordination_value=employer)
provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Service Provider')
other_provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Another Service Provider')
ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 1',
destination_section_value=employer,
source_section_value=employee1,
start_date=DateTime(2006, 1, 1),)
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
# (destination is set by PaySheetTransaction.createPaySheetLine)
destination_value=employee1,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=2000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=2000, tax_category='employer_share')
ps1.plan()
ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 2',
destination_section_value=employer,
source_section_value=employee2,
start_date=DateTime(2006, 1, 1),)
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee2,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=3000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=3000, tax_category='employer_share')
other_line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
destination_value=employee2,
source_section_value=other_provider,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = other_line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.46, quantity=2998, tax_category='employee_share')
cell_employer = other_line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.42, quantity=2998, tax_category='employer_share')
transaction.commit()
self.tic()
# AccountingTransactionModule_getPaySheetMovementMirrorSectionItemList is
# used in the report dialog to display possible organisations.
self.assertEquals(
[('', ''),
(other_provider.getTitle(), other_provider.getRelativeUrl()),
(provider.getTitle(), provider.getRelativeUrl())],
self.portal.accounting_module\
.AccountingTransactionModule_getPaySheetMovementMirrorSectionItemList())
# set request variables and render
request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned']
request_form['resource'] = service.getRelativeUrl()
request_form['mirror_section'] = provider.getRelativeUrl()
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountingTransactionModule_viewPaySheetLineReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list))
# base_unit_quantity for EUR is set to 0.001 in createCurrencies, so the
# precision is 3
precision = self.portal.REQUEST.get('precision')
self.assertEquals(3, precision)
self.checkLineProperties(data_line_list[0],
id=1,
employee_career_reference='E1',
employee_title='Employee One',
base=2000,
employee_share=2000 * .50,
employer_share=2000 * .40,
total=(2000 * .50 + 2000 * .40))
self.checkLineProperties(data_line_list[1],
id=2,
employee_career_reference='E2',
employee_title='Employee Two',
base=3000,
employee_share=3000 * .50,
employer_share=3000 * .40,
total=(3000 * .50 + 3000 * .40))
# stat line
self.checkLineProperties(line_list[-1],
base=3000 + 2000,
employee_share=(3000 + 2000) * .50,
employer_share=(3000 + 2000) * .40,
total=((3000 + 2000) * .50 + (3000 + 2000) * .40))
def test_PayrollTaxesReportDifferentSalaryRange(self):
eur = self.portal.currency_module.EUR
service = self.portal.service_module.newContent(
portal_type='Service',
title='PS1',
variation_base_category_list=('tax_category',
'salary_range'),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share',
'salary_range/france/tranche_a',
'salary_range/france/tranche_b'))
employer = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Employer',
price_currency_value=eur,
group_value=self.portal.portal_categories.group.demo_group)
employee1 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee One',
career_reference='E1',
career_subordination_value=employer)
employee2 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee Two',
career_reference='E2',
career_subordination_value=employer)
provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Service Provider')
other_provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Another Service Provider')
ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 1',
destination_section_value=employer,
source_section_value=employee1,
start_date=DateTime(2006, 1, 1),)
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
# (destination is set by PaySheetTransaction.createPaySheetLine)
destination_value=employee1,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share',
'salary_range/france/tranche_a',
'salary_range/france/tranche_b'))
cell_employee_a = line.newCell('tax_category/employee_share',
'salary_range/france/tranche_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_a.edit(price=-.50, quantity=1000,
tax_category='employee_share',
salary_range='france/tranche_a')
cell_employee_b = line.newCell('tax_category/employee_share',
'salary_range/france/tranche_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_b.edit(price=-.20, quantity=500,
tax_category='employee_share',
salary_range='france/tranche_b')
cell_employer_a = line.newCell('tax_category/employer_share',
'salary_range/france/tranche_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_a.edit(price=-.40, quantity=1000,
tax_category='employer_share',
salary_range='france/tranche_a')
cell_employer_b = line.newCell('tax_category/employer_share',
'salary_range/france/tranche_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_b.edit(price=-.32, quantity=500,
tax_category='employer_share',
salary_range='france/tranche_b')
ps1.plan()
ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 2',
destination_section_value=employer,
source_section_value=employee2,
start_date=DateTime(2006, 1, 1),)
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee2,
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share',
'salary_range/france/tranche_a',
'salary_range/france/tranche_b'))
cell_employee_a = line.newCell('tax_category/employee_share',
'salary_range/france/tranche_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_a.edit(price=-.50, quantity=1000,
salary_range='france/tranche_a',
tax_category='employee_share')
cell_employee_b = line.newCell('tax_category/employee_share',
'salary_range/france/tranche_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee_b.edit(price=-.20, quantity=3000,
salary_range='france/tranche_b',
tax_category='employee_share')
cell_employer_a = line.newCell('tax_category/employer_share',
'salary_range/france/tranche_a',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_a.edit(price=-.40, quantity=1000,
salary_range='france/tranche_a',
tax_category='employer_share')
cell_employer_b = line.newCell('tax_category/employer_share',
'salary_range/france/tranche_b',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer_b.edit(price=-.32, quantity=3000,
salary_range='france/tranche_b',
tax_category='employer_share')
transaction.commit()
self.tic()
# set request variables and render
request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned']
request_form['resource'] = service.getRelativeUrl()
request_form['mirror_section'] = provider.getRelativeUrl()
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountingTransactionModule_viewPaySheetLineReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(6, len(data_line_list))
self.checkLineProperties(data_line_list[0],
id=1,
employee_career_reference='E1',
employee_title='Employee One',
base=1000,
employee_share=1000 * .50,
employer_share=1000 * .40,
total=(1000 * .50 + 1000 * .40))
self.checkLineProperties(data_line_list[1],
id=2,
employee_career_reference='E2',
employee_title='Employee Two',
base=1000,
employee_share=1000 * .50,
employer_share=1000 * .40,
total=(1000 * .50 + 1000 * .40))
self.checkLineProperties(data_line_list[2],
employee_title='Total Tranche A',
base=2000,
employee_share=2000 * .50,
employer_share=2000 * .40,
#total=(2000 * .50 + 2000 * .40)
)
self.checkLineProperties(data_line_list[3],
id=3,
employee_career_reference='E1',
employee_title='Employee One',
base=500,
employee_share=500 * .20,
employer_share=500 * .32,
total=(500 * .20 + 500 * .32))
self.checkLineProperties(data_line_list[4],
id=4,
employee_career_reference='E2',
employee_title='Employee Two',
base=3000,
employee_share=3000 * .20,
employer_share=3000 * .32,
total=(3000 * .20 + 3000 * .32))
self.checkLineProperties(data_line_list[5],
employee_title='Total Tranche B',
base=3500,
employee_share=3500 * .20,
employer_share=3500 * .32,
#total=(3500 * .20 + 3500 * .32),
)
# stat line
self.checkLineProperties(line_list[-1],
base=2000 + 3500,
employee_share=(2000 * .50 + 3500 * .20),
employer_share=(2000 * .40 + 3500 * .32),
total=((2000 * .50 + 3500 * .20) +
(2000 * .40 + 3500 * .32)))
def test_NetSalaryReport(self):
eur = self.portal.currency_module.EUR
salary_service = self.portal.service_module.newContent(
portal_type='Service',
title='Gross Salary',
variation_base_category_list=('tax_category',),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
service = self.portal.service_module.newContent(
portal_type='Service',
title='PS1',
variation_base_category_list=('tax_category',),
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
employer = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Employer',
price_currency_value=eur,
group_value=self.portal.portal_categories.group.demo_group)
employee1 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee One',
career_reference='E1',
career_subordination_value=employer)
employee1_ba = employee1.newContent(portal_type='Bank Account',
title='Bank 1')
employee2 = self.portal.person_module.newContent(
portal_type='Person',
title='Employee Two',
career_reference='E2',
career_subordination_value=employer)
employee2_ba = employee2.newContent(portal_type='Bank Account',
title='Bank 2')
provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Service Provider')
other_provider = self.portal.organisation_module.newContent(
portal_type='Organisation',
title='Another Service Provider')
ps1 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 1',
destination_section_value=employer,
source_section_value=employee1,
payment_condition_source_payment_value=employee1_ba,
start_date=DateTime(2006, 1, 1),)
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=salary_service,
destination_value=employee1,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=1, quantity=2000, tax_category='employee_share')
line = ps1.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee1,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=2000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=2000, tax_category='employer_share')
ps1.plan()
ps2 = self.portal.accounting_module.newContent(
portal_type='Pay Sheet Transaction',
title='Employee 2',
destination_section_value=employer,
source_section_value=employee2,
payment_condition_source_payment_value=employee2_ba,
start_date=DateTime(2006, 1, 1),)
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=salary_service,
destination_value=employee2,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=1, quantity=3000, tax_category='employee_share')
line = ps2.newContent(portal_type='Pay Sheet Line',
resource_value=service,
source_section_value=provider,
destination_value=employee2,
base_contribution_list=['base_amount/net_salary',],
variation_category_list=('tax_category/employee_share',
'tax_category/employer_share'))
cell_employee = line.newCell('tax_category/employee_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employee.edit(price=-.50, quantity=3000, tax_category='employee_share')
cell_employer = line.newCell('tax_category/employer_share',
portal_type='Pay Sheet Cell',
base_id='movement',
mapped_value_property_list=('price',
'quantity'),)
cell_employer.edit(price=-.40, quantity=3000, tax_category='employer_share')
transaction.commit()
self.tic()
# set request variables and render
request_form = self.portal.REQUEST
request_form['at_date'] = DateTime(2006, 2, 2)
request_form['section_category'] = 'group/demo_group'
request_form['simulation_state'] = ['draft', 'planned']
report_section_list = self.getReportSectionList(
self.portal.accounting_module,
'AccountingTransactionModule_viewNetSalaryReport')
self.assertEquals(1, len(report_section_list))
line_list = self.getListBoxLineList(report_section_list[0])
data_line_list = [l for l in line_list if l.isDataLine()]
self.assertEquals(2, len(data_line_list))
# base_unit_quantity for EUR is set to 0.001 in createCurrencies, so the
# precision is 3
precision = self.portal.REQUEST.get('precision')
self.assertEquals(3, precision)
self.checkLineProperties(data_line_list[0],
employee_career_reference='E1',
employee_title='Employee One',
employee_bank_account='Bank 1',
total_price=2000 - (2000 * .5),)
self.checkLineProperties(data_line_list[1],
employee_career_reference='E2',
employee_title='Employee Two',
employee_bank_account='Bank 2',
total_price=3000 - (3000 * .5),)
# stat line
self.checkLineProperties(
line_list[-1],
total_price=3000 + 2000 - (2000 * .5) - (3000 * .5))
def test_AccountingLineGeneration(self): def test_AccountingLineGeneration(self):
# create services # create services
base_salary = self.portal.service_module.newContent( base_salary = self.portal.service_module.newContent(
......
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