From 292c7d84ef11d63c97ac06e98c75fe0cd9aa0ef1 Mon Sep 17 00:00:00 2001 From: Kevin Deldycke <kevin@nexedi.com> Date: Thu, 15 Jun 2006 14:49:59 +0000 Subject: [PATCH] Get Company employees number dynamically. Activate Transportation tax. Delete some unused variables. Add comments. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7736 20353a03-c40f-0410-a6d1-a30d3c3de9de --- ...ransaction_preCalculation_l10n_fr_2006.xml | 110 ++++++++---------- 1 file changed, 47 insertions(+), 63 deletions(-) diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_preCalculation_l10n_fr_2006.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_preCalculation_l10n_fr_2006.xml index d15846ce06..8b70905b50 100644 --- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_preCalculation_l10n_fr_2006.xml +++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_preCalculation_l10n_fr_2006.xml @@ -70,67 +70,56 @@ <key> <string>_body</string> </key> <value> <string encoding="cdata"><![CDATA[ -#\n +"""\n + This script define all rates to apply in 2006 to calculate an entire paysheet\n + according french fiscal & social rules for a SME.\n +"""\n global paysheet\n paysheet = context.getObject()\n paysheet_type = paysheet.getPortalType()\n \n -employee = paysheet.getDestinationSection()\n -employee_object = paysheet.getDestinationSectionValue()\n -employer = paysheet.getSourceSection()\n -employer_object = paysheet.getSourceSectionValue()\n +employee = paysheet.getDestinationSectionValue()\n +company = paysheet.getSourceSectionValue()\n \n +# Get Paysheet datas\n gross_salary = abs(paysheet.getGrossSalary())\n +start_date = paysheet.getStartDate()\n +stop_date = paysheet.getStopDate()\n \n -######\n -# This script define all rates to apply in 2006 to calculate an entire paysheet\n -# according french fiscal & social rules for a SME.\n -######\n \n ### This part of the script define usefull variables to help us calculate dynamic rates\n \n -# each year, look at http://www.urssaf.fr to complete the table\n -ceiling_salary_list = { 2003 : 2432.0\n - , 2004 : 2476.0\n - , 2005 : 2516.0\n - , 2006 : 2589.0\n +# Each year, look at http://www.urssaf.fr to complete the table\n +ceiling_salary_list = { 2003: 2432.0\n + , 2004: 2476.0\n + , 2005: 2516.0\n + , 2006: 2589.0\n }\n -# the default ceiling salary is the last one\n -paysheet_year = paysheet.getStartDate().year()\n +# The default ceiling salary is the last one\n +paysheet_year = start_date.year()\n ceiling_salary_available_years = ceiling_salary_list.keys()\n if paysheet_year not in ceiling_salary_available_years:\n paysheet_year = ceiling_salary_available_years[-1]\n ceiling_salary = ceiling_salary_list[paysheet_year]\n \n -# limited salary = salaire plafonnee\n +# Limited salary = salaire plafonnee\n if gross_salary < ceiling_salary:\n limited_salary = gross_salary\n else:\n limited_salary = ceiling_salary\n \n -# check if the employee is executive or not\n -if employee_object.getCareerGrade().split(\'/\')[-1:][0] in (\'engineer\'):\n +# Check if the employee is executive or not\n +if employee.getCareerGrade().endswith(\'engineer\'):\n executive = True\n else:\n executive = False\n \n -company_birth = employer_object.getCreationDate()\n -\n -employer_region = employer_object.getDefaultAddress().getZipCode()[:2]\n -\n -# get the number of person which are employed by the company ,\n -# sub_list = employer_object.getSubordinationRelatedValueList()\n -# company_size = 0\n -# for person in sub_list:\n -# if person.getPortalType() == \'Person\': # add condition: if current role == internal and defaultCareerEnd and defaultCareerStart fit in the current year\n -# #print repr(person) + repr(person.getTitle())\n -# company_size += 1\n -#\n -# print repr(company_size)\n -#\n -# return printed\n -\n -company_size = 3\n +# Get company related data\n +company_birth = company.getCreationDate()\n +employee_list = company.Organisation_getEmployeeList( start_date = start_date\n + , stop_date = stop_date\n + )\n +company_size = len(employee_list)\n \n # Get the list of all slice the employee fall in\n salary_slices = {}\n @@ -164,7 +153,7 @@ else:\n else:\n salary_slices[\'2\'] = slice_2_value\n \n -# age-slice of the company\n +# Age-slice of the company\n old_limit = DateTime(1997, 1, 1)\n if company_birth < old_limit:\n comp_type = \'old\'\n @@ -176,12 +165,11 @@ else:\n \n default = {}\n \n -# initialize all variables to None\n +# Initialize all variables to None\n paysheet_services = []\n erp5site = context.portal_url.getPortalObject()\n \n -# during 06/2005 service module has been renamed service_module\n -# both names are supported\n +# During 06/2005 service module has been renamed service_module: both names are supported.\n if hasattr(erp5site, \'service_module\'):\n service_module = erp5site.service_module\n else :\n @@ -202,10 +190,13 @@ for serv in paysheet_services:\n for base in range_cat:\n mycategory = context.portal_categories.resolveCategory(base)\n if mycategory is None:\n - context.log("PaySheetTransaction_preCalculation","WARNING! Category not found : %s" % base)\n + context.log("PaySheetTransaction_preCalculation", "WARNING! Category not found: %s" % base)\n else:\n new_name = serv.getId() + \'/\' + mycategory.getId()\n - default[new_name] = {\'employer_rate\':None,\'employee_rate\':None,\'base\':None}\n + default[new_name] = { \'employer_rate\': None\n + , \'employee_rate\': None\n + , \'base\' : None\n + }\n \n # Sickness insurance = Assurance maladie\n if executive:\n @@ -269,16 +260,14 @@ if not executive:\n # , \'base\' : limited_salary\n # }\n \n -# transport payment\n +# Transport payment\n # TODO: rate depending of the town, 1.80 is the \'default\' value (when the town isn\'t referenced by laws)\n -# if transport_payment_rate in (\'\', 0, None):\n -# transport_payment_rate = 1.80\n -# if company_size > 9:\n -# default[\'transport_payment/salaire_brut\'] = \\\n -# { \'employer_rate\' : transport_payment_rate\n -# , \'employee_rate\' : None\n -# , \'base\' : gross_salary\n -# }\n +if company_size > 9:\n + default[\'transport_payment/salaire_brut\'] = \\\n + { \'employer_rate\' : 1.80\n + , \'employee_rate\' : None\n + , \'base\' : gross_salary\n + }\n \n # CSG\n default[\'csg_deductible/salaire_brut_csg\'] = \\\n @@ -467,11 +456,11 @@ if executive:\n # TOD0: We can\'t take the decision based on the CollectiveAgreementTitle since each\n # employee has the right to choose if they want benefit from the insurance or not.\n # We can use instead the social_contract property of the (near-)future HR-related stuff.\n -col_agr = employee_object.getCareerCollectiveAgreementTitle()\n +col_agr = employee.getCareerCollectiveAgreementTitle()\n if col_agr not in (None, \'\') and \'syntec\' in col_agr.lower():\n # set the syntec rate according to the employee marital status\n syntec_rate = 0.96\n - if employee_object.getMaritalStatusId() == \'married\':\n + if employee.getMaritalStatusId() == \'married\':\n syntec_rate *= 2\n default[\'syntec_insurance/salaire_plafonne_syntec\'] = \\\n { \'employer_rate\' : syntec_rate\n @@ -508,12 +497,6 @@ return default\n <key> <string>_filepath</string> </key> <value> <string>Script (Python):/nexedi/portal_skins/erp5_payroll/PaySheetTransaction_preCalculation_l10n_fr_2006</string> </value> </item> - <item> - <key> <string>_owner</string> </key> - <value> - <none/> - </value> - </item> <item> <key> <string>_params</string> </key> <value> <string></string> </value> @@ -547,11 +530,11 @@ return default\n <string>paysheet</string> <string>paysheet_type</string> <string>employee</string> - <string>employee_object</string> - <string>employer</string> - <string>employer_object</string> + <string>company</string> <string>abs</string> <string>gross_salary</string> + <string>start_date</string> + <string>stop_date</string> <string>ceiling_salary_list</string> <string>paysheet_year</string> <string>ceiling_salary_available_years</string> @@ -562,7 +545,8 @@ return default\n <string>executive</string> <string>False</string> <string>company_birth</string> - <string>employer_region</string> + <string>employee_list</string> + <string>len</string> <string>company_size</string> <string>salary_slices</string> <string>slice_a_value</string> -- 2.30.9