Commit 292c7d84 authored by Kevin Deldycke's avatar Kevin Deldycke

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
parent b3dc7067
...@@ -70,67 +70,56 @@ ...@@ -70,67 +70,56 @@
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <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 global paysheet\n
paysheet = context.getObject()\n paysheet = context.getObject()\n
paysheet_type = paysheet.getPortalType()\n paysheet_type = paysheet.getPortalType()\n
\n \n
employee = paysheet.getDestinationSection()\n employee = paysheet.getDestinationSectionValue()\n
employee_object = paysheet.getDestinationSectionValue()\n company = paysheet.getSourceSectionValue()\n
employer = paysheet.getSourceSection()\n
employer_object = paysheet.getSourceSectionValue()\n
\n \n
# Get Paysheet datas\n
gross_salary = abs(paysheet.getGrossSalary())\n gross_salary = abs(paysheet.getGrossSalary())\n
start_date = paysheet.getStartDate()\n
stop_date = paysheet.getStopDate()\n
\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 \n
### This part of the script define usefull variables to help us calculate dynamic rates\n ### This part of the script define usefull variables to help us calculate dynamic rates\n
\n \n
# each year, look at http://www.urssaf.fr to complete the table\n # Each year, look at http://www.urssaf.fr to complete the table\n
ceiling_salary_list = { 2003 : 2432.0\n ceiling_salary_list = { 2003: 2432.0\n
, 2004 : 2476.0\n , 2004: 2476.0\n
, 2005 : 2516.0\n , 2005: 2516.0\n
, 2006 : 2589.0\n , 2006: 2589.0\n
}\n }\n
# the default ceiling salary is the last one\n # The default ceiling salary is the last one\n
paysheet_year = paysheet.getStartDate().year()\n paysheet_year = start_date.year()\n
ceiling_salary_available_years = ceiling_salary_list.keys()\n ceiling_salary_available_years = ceiling_salary_list.keys()\n
if paysheet_year not in ceiling_salary_available_years:\n if paysheet_year not in ceiling_salary_available_years:\n
paysheet_year = ceiling_salary_available_years[-1]\n paysheet_year = ceiling_salary_available_years[-1]\n
ceiling_salary = ceiling_salary_list[paysheet_year]\n ceiling_salary = ceiling_salary_list[paysheet_year]\n
\n \n
# limited salary = salaire plafonnee\n # Limited salary = salaire plafonnee\n
if gross_salary < ceiling_salary:\n if gross_salary < ceiling_salary:\n
limited_salary = gross_salary\n limited_salary = gross_salary\n
else:\n else:\n
limited_salary = ceiling_salary\n limited_salary = ceiling_salary\n
\n \n
# check if the employee is executive or not\n # Check if the employee is executive or not\n
if employee_object.getCareerGrade().split(\'/\')[-1:][0] in (\'engineer\'):\n if employee.getCareerGrade().endswith(\'engineer\'):\n
executive = True\n executive = True\n
else:\n else:\n
executive = False\n executive = False\n
\n \n
company_birth = employer_object.getCreationDate()\n # Get company related data\n
\n company_birth = company.getCreationDate()\n
employer_region = employer_object.getDefaultAddress().getZipCode()[:2]\n employee_list = company.Organisation_getEmployeeList( start_date = start_date\n
\n , stop_date = stop_date\n
# get the number of person which are employed by the company ,\n )\n
# sub_list = employer_object.getSubordinationRelatedValueList()\n company_size = len(employee_list)\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
\n \n
# Get the list of all slice the employee fall in\n # Get the list of all slice the employee fall in\n
salary_slices = {}\n salary_slices = {}\n
...@@ -164,7 +153,7 @@ else:\n ...@@ -164,7 +153,7 @@ else:\n
else:\n else:\n
salary_slices[\'2\'] = slice_2_value\n salary_slices[\'2\'] = slice_2_value\n
\n \n
# age-slice of the company\n # Age-slice of the company\n
old_limit = DateTime(1997, 1, 1)\n old_limit = DateTime(1997, 1, 1)\n
if company_birth < old_limit:\n if company_birth < old_limit:\n
comp_type = \'old\'\n comp_type = \'old\'\n
...@@ -176,12 +165,11 @@ else:\n ...@@ -176,12 +165,11 @@ else:\n
\n \n
default = {}\n default = {}\n
\n \n
# initialize all variables to None\n # Initialize all variables to None\n
paysheet_services = []\n paysheet_services = []\n
erp5site = context.portal_url.getPortalObject()\n erp5site = context.portal_url.getPortalObject()\n
\n \n
# during 06/2005 service module has been renamed service_module\n # During 06/2005 service module has been renamed service_module: both names are supported.\n
# both names are supported\n
if hasattr(erp5site, \'service_module\'):\n if hasattr(erp5site, \'service_module\'):\n
service_module = erp5site.service_module\n service_module = erp5site.service_module\n
else :\n else :\n
...@@ -202,10 +190,13 @@ for serv in paysheet_services:\n ...@@ -202,10 +190,13 @@ for serv in paysheet_services:\n
for base in range_cat:\n for base in range_cat:\n
mycategory = context.portal_categories.resolveCategory(base)\n mycategory = context.portal_categories.resolveCategory(base)\n
if mycategory is None:\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 else:\n
new_name = serv.getId() + \'/\' + mycategory.getId()\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 \n
# Sickness insurance = Assurance maladie\n # Sickness insurance = Assurance maladie\n
if executive:\n if executive:\n
...@@ -269,16 +260,14 @@ if not executive:\n ...@@ -269,16 +260,14 @@ if not executive:\n
# , \'base\' : limited_salary\n # , \'base\' : limited_salary\n
# }\n # }\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 # 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 if company_size > 9:\n
# transport_payment_rate = 1.80\n default[\'transport_payment/salaire_brut\'] = \\\n
# if company_size > 9:\n { \'employer_rate\' : 1.80\n
# default[\'transport_payment/salaire_brut\'] = \\\n , \'employee_rate\' : None\n
# { \'employer_rate\' : transport_payment_rate\n , \'base\' : gross_salary\n
# , \'employee_rate\' : None\n }\n
# , \'base\' : gross_salary\n
# }\n
\n \n
# CSG\n # CSG\n
default[\'csg_deductible/salaire_brut_csg\'] = \\\n default[\'csg_deductible/salaire_brut_csg\'] = \\\n
...@@ -467,11 +456,11 @@ if executive:\n ...@@ -467,11 +456,11 @@ if executive:\n
# TOD0: We can\'t take the decision based on the CollectiveAgreementTitle since each\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 # 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 # 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 if col_agr not in (None, \'\') and \'syntec\' in col_agr.lower():\n
# set the syntec rate according to the employee marital status\n # set the syntec rate according to the employee marital status\n
syntec_rate = 0.96\n syntec_rate = 0.96\n
if employee_object.getMaritalStatusId() == \'married\':\n if employee.getMaritalStatusId() == \'married\':\n
syntec_rate *= 2\n syntec_rate *= 2\n
default[\'syntec_insurance/salaire_plafonne_syntec\'] = \\\n default[\'syntec_insurance/salaire_plafonne_syntec\'] = \\\n
{ \'employer_rate\' : syntec_rate\n { \'employer_rate\' : syntec_rate\n
...@@ -508,12 +497,6 @@ return default\n ...@@ -508,12 +497,6 @@ return default\n
<key> <string>_filepath</string> </key> <key> <string>_filepath</string> </key>
<value> <string>Script (Python):/nexedi/portal_skins/erp5_payroll/PaySheetTransaction_preCalculation_l10n_fr_2006</string> </value> <value> <string>Script (Python):/nexedi/portal_skins/erp5_payroll/PaySheetTransaction_preCalculation_l10n_fr_2006</string> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -547,11 +530,11 @@ return default\n ...@@ -547,11 +530,11 @@ return default\n
<string>paysheet</string> <string>paysheet</string>
<string>paysheet_type</string> <string>paysheet_type</string>
<string>employee</string> <string>employee</string>
<string>employee_object</string> <string>company</string>
<string>employer</string>
<string>employer_object</string>
<string>abs</string> <string>abs</string>
<string>gross_salary</string> <string>gross_salary</string>
<string>start_date</string>
<string>stop_date</string>
<string>ceiling_salary_list</string> <string>ceiling_salary_list</string>
<string>paysheet_year</string> <string>paysheet_year</string>
<string>ceiling_salary_available_years</string> <string>ceiling_salary_available_years</string>
...@@ -562,7 +545,8 @@ return default\n ...@@ -562,7 +545,8 @@ return default\n
<string>executive</string> <string>executive</string>
<string>False</string> <string>False</string>
<string>company_birth</string> <string>company_birth</string>
<string>employer_region</string> <string>employee_list</string>
<string>len</string>
<string>company_size</string> <string>company_size</string>
<string>salary_slices</string> <string>salary_slices</string>
<string>slice_a_value</string> <string>slice_a_value</string>
......
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