testPayroll_l10n_fr.py 4.89 KB
Newer Older
1 2
##############################################################################
#
3
# Copyright (c) 2007-2009 Nexedi SA and Contributors. All Rights Reserved.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#          Fabien Morin <fabien.morin@gmail.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
"""
29 30
  test cases related to french localisation. Scripts inclued in
  erp5_payroll_l10n_fr will be tested here.
31 32
"""

33
from Products.ERP5Type.tests.Sequence import SequenceList
34
from Products.ERP5.tests.testPayroll import TestPayrollMixin
35
from DateTime import DateTime
36

37
class TestPayroll_l10n_fr(TestPayrollMixin):
38

39 40 41 42 43 44 45 46 47 48 49 50 51 52
  PAYSHEET_WITH_SLICE_SEQUENCE_STRING = '''
               CreateBasicPaysheet
               PaysheetSetModelAndApplyIt
               PaysheetCreateLabourPaySheetLine
  ''' + TestPayrollMixin.BUSINESS_PATH_CREATION_SEQUENCE_STRING + '''
               CheckUpdateAggregatedAmountListReturnUsingSlices
               PaysheetApplyTransformation
               Tic
               CheckPaysheetLineAreCreatedUsingSlices
               CheckPaysheetLineAmountsUsingSlices
               CheckUpdateAggregatedAmountListReturnNothing
               CheckPaysheetLineAmountsUsingSlices
  '''

53 54 55 56 57
  def getTitle(self):
    return "Payroll_l10n_fr"

  def getBusinessTemplateList(self):
    """ """
58 59 60 61 62 63 64 65 66 67
    return TestPayrollMixin.getBusinessTemplateList(self) +\
          ('erp5_payroll_l10n_fr',)

  def stepCheckYearToDateSliceAmount(self, sequence=None, **kw):
    paysheet_module = self.portal.getDefaultModule(portal_type=\
        'Pay Sheet Transaction')
    paysheet_list = paysheet_module.contentValues(portal_type=\
        'Pay Sheet Transaction')
    self.assertEquals(len(paysheet_list), 2) # 2 paysheet have been created
                                             # for this test
68 69 70 71 72 73

    # set nice date on paysheet (ie. one paysheet per month)
    paysheet_list[0].setStartDate(DateTime('2009/06/01'))
    paysheet_list[0].setStopDate(DateTime('2009/06/30'))
    paysheet_list[1].setStartDate(DateTime('2009/07/01'))
    paysheet_list[1].setStopDate(DateTime('2009/07/31'))
74 75 76 77
    for paysheet in paysheet_list:
      # the script used for calculation only take into account stopped or
      # delivered paysheet
      paysheet.stop()
78
    self.tic()
79 80

    # here, check how much is contributed to the slices
81 82 83 84 85
    # the slices defined for this tax are :
    # - 0 to 200
    # - 200 to 400
    # - 400 to 5000
    # the salary is of 3000
86 87 88 89 90 91 92 93 94
    self.assertEquals(400, # 200 from the 1st paysheet + 200 from the 2e
        paysheet_list[1].PaySheetTransaction_getYearToDateSlice(\
            'salary_range/france/slice_0_to_200'))
    self.assertEquals(400, # 200 from the 1st paysheet + 200 from the 2e
        paysheet_list[1].PaySheetTransaction_getYearToDateSlice(\
            'salary_range/france/slice_200_to_400'))
    self.assertEquals(5200, # (3000 - 400)*2
        paysheet_list[1].PaySheetTransaction_getYearToDateSlice(\
            'salary_range/france/slice_400_to_5000'))
95

96
  def test_01_getYearToDateSlice(self):
97 98
    '''Check that is possible to calculate the total amount spend on a slice
    since the begining of the year.
99
    '''
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
    sequence_list = SequenceList()
    sequence_string = """
               CreateUrssafService
               CreateLabourService
               CreateEmployer
               CreateEmployee
               CreatePriceCurrency
               CreateModelWithSlices
               SetCurrencyOnModel
               ModelCreateUrssafModelLineWithSlices
               UrssafModelLineWithSlicesCreateMovements
    """ + self.PAYSHEET_WITH_SLICE_SEQUENCE_STRING +\
          self.PAYSHEET_WITH_SLICE_SEQUENCE_STRING + """
               CheckYearToDateSliceAmount
    """
    sequence_list.addSequenceString(sequence_string)
    sequence_list.play(self)
117

118 119 120 121 122
import unittest
def test_suite():
  suite = unittest.TestSuite()
  suite.addTest(unittest.makeSuite(TestPayroll_l10n_fr))
  return suite