Commit 8552e978 authored by Kevin Deldycke's avatar Kevin Deldycke

Move PaySheetTransaction_preCalculation code to PaySheetTransaction_initializePreview script.

Move generic code of _preCalculation_l10n_fr to PaySheetTransaction_initializePreview.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10832 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 82b39eab
...@@ -68,113 +68,154 @@ ...@@ -68,113 +68,154 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string>import random\n <value> <string>"""\n
This script create the data structure of the pay sheet preview (= the PaySheetTransaction_viewPreview fast input).\n
Then it fill this data structure with rates and amounts of money from the localized pre calculation script.\n
"""\n
\n
import random\n
from Products.ERP5Type.Document import newTempBase\n from Products.ERP5Type.Document import newTempBase\n
from string import zfill\n from string import zfill\n
\n \n
global portal_object, num, l\n
portal_object = context.getPortalObject()\n
num = 0\n
l = []\n
\n \n
# get all pre-calculated rates and bases\n
default_values = context.PaySheetTransaction_preCalculation()\n
\n \n
# function to create a new preview line\n ##########################\n
def createPreviewLine( new_id = None\n # This part of the script create the data structure designed to hold the result of pre calculation.\n
, new_title = None\n ##########################\n
, new_base = None\n
, new_base_name = None\n
, new_employee_rate = None\n
, new_employer_rate = None\n
, new_service_url = None\n
, new_organisation_url = None\n
, new_salary_range_cat = None\n
, new_tax_cat = None\n
):\n
\n \n
global portal_object, num, l\n # \'d\' is the dict which contain the default values of the Pay Sheet fast input\n
num += 1\n # TODO: Bad name ! Find something more explicit.\n
int_len = 3\n d = {}\n
o = newTempBase(portal_object, new_id)\n
o.setUid( \'new_%s\' % zfill(num, int_len)) # XXX There is a security issue here\n
o.edit(uid=\'new_%s\' % zfill(num, int_len)) # XXX There is a security issue here\n
o.edit( id = new_id\n
, title = new_title\n
, base = new_base\n
, base_name = new_base_name\n
, employee_share_rate = new_employee_rate\n
, employer_share_rate = new_employer_rate\n
, service_url = new_service_url\n
, organisation_url = new_organisation_url\n
, salary_range_cat = new_salary_range_cat\n
, tax_cat = new_tax_cat\n
)\n
l.append(o)\n
\n \n
# get all services related to pay sheet transaction\n # During 06/2005 service module has been renamed service_module\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 # both names are supported\n
# XXX This should definitly use portal_catalog !!!\n # XXX This should definitly use portal_catalog !!!\n
if hasattr(erp5site, \'payroll_service_module\') :\n # XXX The following code will be deprecated when the Payroll Service portal type will be used.\n
erp5site = context.portal_url.getPortalObject()\n
if hasattr(erp5site, \'payroll_service_module\'):\n
service_module = erp5site.payroll_service_module\n service_module = erp5site.payroll_service_module\n
elif hasattr(erp5site, \'service_module\') :\n elif hasattr(erp5site, \'service_module\'):\n
service_module = erp5site.service_module\n service_module = erp5site.service_module\n
else :\n else:\n
service_module = erp5site.service\n service_module = erp5site.service\n
\n \n
\n # Get all services related to pay sheet transaction\n
# TODO: Only choose services of the current localisation.\n
paysheet_services = []\n
for service in service_module.objectValues():\n for service in service_module.objectValues():\n
base_cat = service.getVariationBaseCategoryList()\n # Check service validity\n
# A service is related to paysheet transaction if it has\n # TODO: Use a validation workflow on Payroll Service and check the validity of a Service there\n
# \'tax_category\' and \'salary_range\' as base category.\n base_categories = service.getVariationBaseCategoryList()\n
if \'tax_category\' in base_cat and \'salary_range\' in base_cat and service.getId() != \'labour\':\n if \'salary_range\' in base_categories and \'tax_category\' in base_categories:\n
# XXX add "and service.getId() != \'labour\':" ??\n
paysheet_services.append(service)\n paysheet_services.append(service)\n
\n \n
# Sort the service list by id\n # Create the pre-calculation data structure\n
paysheet_services.sort(lambda x, y: cmp(x.getId(), y.getId()))\n for service in paysheet_services:\n
\n # XXX Is there a better way to get categorylist ? Something like getCategoryList(base=\'tax_category\')\n
# generate all lines for the preview form\n # will be nice to have.\n
for serv in paysheet_services:\n service_categories = service.getCategoryList()\n
cat_list = serv.getCategoryList()\n tax_categories = []\n
# store all categories of the service into lists\n salary_range_categories = []\n
tax_cat = []\n for category in service_categories:\n
range_cat = []\n if category.startswith(\'tax_category/\'): tax_categories.append(category)\n
for cat in cat_list:\n elif category.startswith(\'salary_range/\'): salary_range_categories.append(category)\n
if str(cat).find(\'tax_category\') != -1:\n # Create a preview line for each salary_range of the service.\n
tax_cat.append(cat)\n # This method is valid as long as we assume each line is composed of a base, an employee share\n
if str(cat).find(\'salary_range\') != -1:\n # and an employer share only.\n
range_cat.append(cat)\n for salary_range in salary_range_categories:\n
# create a line for every salary_range of the service\n salary_range_object = context.portal_categories.resolveCategory(salary_range)\n
for base in range_cat:\n if salary_range_object is None:\n
mycategory=context.portal_categories.resolveCategory(base)\n context.log( "PaySheetTransaction_initializePreview"\n
if mycategory is None:\n , "WARNING! Category not found: %s" % salary_range\n
context.log("PaySheetTransaction_initializePreview","WARNING : category not found : %s" % base)\n )\n
else:\n else:\n
name = serv.getId() + \'/\' + mycategory.getId()\n preview_line_uid = "%s/%s" % (service.getId(), salary_range_object.getId())\n
# a preview line is composed of a base calculation, an employee share rate and an employer share rate\n d[preview_line_uid] = { \'service\' : service\n
if default_values.has_key(name):\n , \'tax_categories\': tax_categories\n
new_base = default_values[name][\'base\']\n , \'salary_range\' : salary_range\n
new_employee_rate = default_values[name][\'employee_rate\']\n , \'employer_share\': None\n
new_employer_rate = default_values[name][\'employer_rate\']\n , \'employee_share\': None\n
# create a preview line for every salary_range value of the service\n , \'base\' : None\n
createPreviewLine( new_id = serv.getId()\n }\n
, new_title = serv.getTitleOrId()\n \n
, new_base = new_base\n \n
, new_base_name = context.portal_categories.resolveCategory(base).getTitleOrId()\n \n
, new_employee_rate = new_employee_rate\n #########################################\n
, new_employer_rate = new_employer_rate\n # This part of the script select the right localized version of PaySheetTransaction_preCalculation_l10n script.\n
, new_service_url = serv.getRelativeUrl()\n # TODO: implement here a generic method to get the right precalculation script automaticcaly.\n
, new_organisation_url = serv.getSource()\n #########################################\n
, new_salary_range_cat = base\n \n
, new_tax_cat = tax_cat\n # Force which script to use - BAD\n
)\n country = \'fr\'\n
year = \'2006\'\n
\n
script_name = \'_\'.join([ "PaySheetTransaction_preCalculation_l10n"\n
, country\n
, year\n
])\n
calculation_method = getattr(context, script_name)\n
\n
pre_calculation = calculation_method()\n
\n
# Merge pre_calculation and preview line dict\n
preview_line_keys = d.items()[0][1].keys()\n
for k in pre_calculation.keys():\n
if k in d.keys():\n
for required_key in preview_line_keys:\n
if not pre_calculation[k].has_key(required_key):\n
pre_calculation[k][required_key] = d[k][required_key]\n
else:\n
context.log( "PaySheetTransaction_initializePreview"\n
, "Preview line key \'%s\' not found in default services" % k\n
)\n
# Remove line\n
del pre_calculation[k]\n
\n
# Because all rates in the localized file are written in percents, we must convert them in pure floats.\n
for preview_line_uid in pre_calculation.keys():\n
# Only \'Fixed\' (or \'Forfait\' in french) base are expressed in percents\n
# TODO: base this test on "/forfait" string is bad. A more generic way must be found.\n
preview_line = pre_calculation[preview_line_uid]\n
if not preview_line_uid.endswith(\'/forfait\'):\n
# Fix percents\n
for share_type in [\'employer_share\', \'employee_share\']:\n
share_value = preview_line[share_type]\n
if share_value not in (\'\', None):\n
preview_line[share_type] = share_value / 100.0\n
# Normalize the value of \'Fixed\' (or \'Forfait\' in french) base to 1.0\n
else:\n
preview_line[\'base\'] = 1.0\n
pre_calculation[preview_line_uid] = preview_line\n
\n
# Create a preview line for every salary_range value of the service\n
portal_object = context.getPortalObject()\n
preview_line_list = []\n
num = 0\n
INT_LEN = 3\n
for (preview_line_id, preview_line_item) in pre_calculation.items():\n
num += 1\n
context.log("Kev dfsdfsdfsdff", repr((preview_line_id, preview_line_item)))\n
service = preview_line_item[\'service\']\n
salary_range = preview_line_item[\'salary_range\']\n
service_id = service.getId()\n
o = newTempBase(portal_object, service_id)\n
o.setUid( \'new_%s\' % zfill(num, INT_LEN)) # XXX There is a security issue here\n
o.edit(uid=\'new_%s\' % zfill(num, INT_LEN)) # XXX There is a security issue here\n
o.edit( id = service_id\n
, base = preview_line_item[\'base\']\n
, employer_share = preview_line_item[\'employer_share\']\n
, employee_share = preview_line_item[\'employee_share\']\n
, service_title = service.getTitleOrId()\n
, service_id = service_id\n
, salary_range = salary_range\n
, salary_range_title = context.portal_categories.resolveCategory(salary_range).getTitleOrId()\n
, tax_category = preview_line_item[\'tax_categories\']\n
)\n
preview_line_list.append(o)\n
\n \n
# return the list of preview lines\n # return the list of preview lines\n
return l\n return preview_line_list\n
</string> </value> </string> </value>
</item> </item>
<item> <item>
...@@ -237,34 +278,47 @@ return l\n ...@@ -237,34 +278,47 @@ return l\n
<string>newTempBase</string> <string>newTempBase</string>
<string>string</string> <string>string</string>
<string>zfill</string> <string>zfill</string>
<string>d</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal_object</string>
<string>num</string>
<string>l</string>
<string>default_values</string>
<string>None</string>
<string>createPreviewLine</string>
<string>paysheet_services</string>
<string>erp5site</string> <string>erp5site</string>
<string>hasattr</string> <string>hasattr</string>
<string>service_module</string> <string>service_module</string>
<string>paysheet_services</string>
<string>_getiter_</string> <string>_getiter_</string>
<string>service</string> <string>service</string>
<string>base_cat</string> <string>base_categories</string>
<string>serv</string> <string>service_categories</string>
<string>cat_list</string> <string>tax_categories</string>
<string>tax_cat</string> <string>salary_range_categories</string>
<string>range_cat</string> <string>category</string>
<string>cat</string> <string>salary_range</string>
<string>str</string> <string>salary_range_object</string>
<string>base</string> <string>None</string>
<string>mycategory</string> <string>preview_line_uid</string>
<string>name</string> <string>_write_</string>
<string>country</string>
<string>year</string>
<string>script_name</string>
<string>getattr</string>
<string>calculation_method</string>
<string>pre_calculation</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>new_base</string> <string>preview_line_keys</string>
<string>new_employee_rate</string> <string>k</string>
<string>new_employer_rate</string> <string>required_key</string>
<string>preview_line</string>
<string>share_type</string>
<string>share_value</string>
<string>portal_object</string>
<string>preview_line_list</string>
<string>num</string>
<string>INT_LEN</string>
<string>preview_line_id</string>
<string>preview_line_item</string>
<string>repr</string>
<string>service_id</string>
<string>o</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string># This script must select the right localized version of PaySheetTransaction_preCalculation\n
# depending of given parameters.\n
\n
# Force which script to use manually.\n
country = \'fr\'\n
year = \'2006\'\n
\n
script_name = \'_\'.join([ "PaySheetTransaction_preCalculation_l10n"\n
, country\n
, year\n
])\n
calculation_method = getattr(context, script_name)\n
\n
return calculation_method(**kw)\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>**kw</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>kw</string>
<string>country</string>
<string>year</string>
<string>_getattr_</string>
<string>script_name</string>
<string>getattr</string>
<string>context</string>
<string>calculation_method</string>
<string>_apply_</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_preCalculation</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -75,6 +75,7 @@ ...@@ -75,6 +75,7 @@
according french fiscal & social rules for a SME.\n according french fiscal & social rules for a SME.\n
"""\n """\n
\n \n
kw = {}\n
\n \n
\n \n
##########################\n ##########################\n
...@@ -82,7 +83,6 @@ ...@@ -82,7 +83,6 @@
# This part depend mostly of the current localisation.\n # This part depend mostly of the current localisation.\n
##########################\n ##########################\n
\n \n
global paysheet\n
paysheet = context.getObject()\n paysheet = context.getObject()\n
paysheet_type = paysheet.getPortalType()\n paysheet_type = paysheet.getPortalType()\n
\n \n
...@@ -168,66 +168,13 @@ else:\n ...@@ -168,66 +168,13 @@ else:\n
\n \n
\n \n
##########################\n ##########################\n
# This part of the script create the data structure designed to hold the result of pre calculation.\n
# TODO: This part must be generic to be moved outside this localized script. Probably in PaySheetTransaction_preCalculation.\n
##########################\n
\n
# \'d\' is the dict which contain the default values of the Pay Sheet fast input\n
d = {}\n
\n
# During 06/2005 service module has been renamed service_module\n
# both names are supported\n
# XXX This should definitly use portal_catalog !!!\n
# XXX The following code will be deprecated when the Payroll Service portal type will be used\n
erp5site = context.portal_url.getPortalObject()\n
if hasattr(erp5site, \'payroll_service_module\'):\n
service_module = erp5site.payroll_service_module\n
elif hasattr(erp5site, \'service_module\'):\n
service_module = erp5site.service_module\n
else:\n
service_module = erp5site.service\n
\n
# Check service validity\n
# TODO: Use a validation workflow on Payroll Service and check the validity of a Service there\n
# TODO: Only choose services of the current localisation.\n
paysheet_services = []\n
for service in service_module.objectValues():\n
base_cat = service.getVariationRangeBaseCategoryList()\n
if \'tax_category\' in base_cat and \'salary_range\' in base_cat:\n
paysheet_services.append(service)\n
\n
\n
for service in paysheet_services:\n
# XXX Is there a better way to get categorylist ? Something like getCategoryList(base=\'tax_category\') will be nice to have.\n
service_categories = service.getCategoryList()\n
tax_categories = []\n
salary_range_categories = []\n
for category in service_categories:\n
if category.startswith(\'tax_category/\'): tax_categories.append(category)\n
elif category.startswith(\'salary_range/\'): salary_range_categories.append(category)\n
for salary_range in salary_range_categories:\n
salary_range_object = context.portal_categories.resolveCategory(salary_range)\n
if salary_range_object is None:\n
context.log( "PaySheetTransaction_preCalculation"\n
, "WARNING! Category not found: %s" % salary_range\n
)\n
else:\n
preview_line_uid = "%s/%s" % (service.getId(), salary_range_object.getId())\n
d[preview_line_uid] = { \'employer_rate\': None\n
, \'employee_rate\': None\n
, \'base\' : None\n
}\n
\n
\n
\n
##########################\n
# This part of the script calculate the default salaey range and rates.\n # This part of the script calculate the default salaey range and rates.\n
# This part is the core of the script: all rates and amounts are defined below.\n # This part is the core of the script: all rates and amounts are defined below.\n
#\n #\n
# Here is a model of a line definition:\n # Here is a model of a line definition:\n
# d[\'payroll_service_id/salary_range_category_id\'] = \\\n # kw[\'payroll_service_id/salary_range_category_id\'] = \\\n
# { \'employer_rate\' : employer_rate_in_percent\n # { \'employer_share\': employer_rate_in_percent\n
# , \'employee_rate\' : employee_rate_in_percent\n # , \'employee_share\': employee_rate_in_percent\n
# , \'base\' : contribution_base_in_currency\n # , \'base\' : contribution_base_in_currency\n
# }\n # }\n
# Rates and base must be floats.\n # Rates and base must be floats.\n
...@@ -241,93 +188,93 @@ if executive:\n ...@@ -241,93 +188,93 @@ if executive:\n
else:\n else:\n
employer_rate = 13.10\n employer_rate = 13.10\n
employee_rate = 0.75\n employee_rate = 0.75\n
d[\'sickness_insurance/salaire_brut\'] = \\\n kw[\'sickness_insurance/salaire_brut\'] = \\\n
{ \'employer_rate\' : employer_rate\n { \'employer_share\': employer_rate\n
, \'employee_rate\' : employee_rate\n , \'employee_share\': employee_rate\n
, \'base\' : gross_salary\n , \'base\' : gross_salary\n
}\n }\n
\n \n
# Old-age insurance = Assurance vieillesse\n # Old-age insurance = Assurance vieillesse\n
if executive:\n if executive:\n
d[\'oldage_insurance/salaire_plafonne\'] = \\\n kw[\'oldage_insurance/salaire_plafonne\'] = \\\n
{ \'employer_rate\' : None\n { \'employer_share\': None\n
, \'employee_rate\' : 6.65\n , \'employee_share\': 6.65\n
, \'base\' : limited_salary\n , \'base\' : limited_salary\n
}\n }\n
else:\n else:\n
d[\'oldage_insurance/salaire_brut\'] = \\\n kw[\'oldage_insurance/salaire_brut\'] = \\\n
{ \'employer_rate\' : 1.60\n { \'employer_share\': 1.60\n
, \'employee_rate\' : 0.10\n , \'employee_share\': 0.10\n
, \'base\' : gross_salary\n , \'base\' : gross_salary\n
}\n }\n
d[\'oldage_insurance/salaire_plafonne\'] = \\\n kw[\'oldage_insurance/salaire_plafonne\'] = \\\n
{ \'employer_rate\' : 8.30\n { \'employer_share\': 8.30\n
, \'employee_rate\' : 6.65\n , \'employee_share\': 6.65\n
, \'base\' : limited_salary\n , \'base\' : limited_salary\n
}\n }\n
\n \n
# Family benefits = Allocations familliale\n # Family benefits = Allocations familliale\n
if not executive:\n if not executive:\n
d[\'family_benefits/salaire_brut\'] = \\\n kw[\'family_benefits/salaire_brut\'] = \\\n
{ \'employer_rate\' : 5.40\n { \'employer_share\': 5.40\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : gross_salary\n , \'base\' : gross_salary\n
}\n }\n
\n \n
# Industrial accident = Accidents du travail\n # Industrial accident = Accidents du travail\n
if not executive:\n if not executive:\n
d[\'industrial_accident/salaire_brut\'] = \\\n kw[\'industrial_accident/salaire_brut\'] = \\\n
{ \'employer_rate\' : 1.10\n { \'employer_share\': 1.10\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : gross_salary\n , \'base\' : gross_salary\n
}\n }\n
\n \n
# Lodging helps = Aide au logemenent\n # Lodging helps = Aide au logemenent\n
# if company_size > 9:\n # if company_size > 9:\n
# d[\'lodging_helps/salaire_brut\'] = \\\n # kw[\'lodging_helps/salaire_brut\'] = \\\n
# { \'employer_rate\' : 0.40\n # { \'employer_share\': 0.40\n
# , \'employee_rate\' : None\n # , \'employee_share\': None\n
# , \'base\' : gross_salary\n # , \'base\' : gross_salary\n
# }\n # }\n
# else:\n # else:\n
# d[\'lodging_helps/salaire_plafonne\'] = \\\n # kw[\'lodging_helps/salaire_plafonne\'] = \\\n
# { \'employer_rate\' : 0.10\n # { \'employer_share\': 0.10\n
# , \'employee_rate\' : None\n # , \'employee_share\': None\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 company_size > 9:\n if company_size > 9:\n
d[\'transport_payment/salaire_brut\'] = \\\n kw[\'transport_payment/salaire_brut\'] = \\\n
{ \'employer_rate\' : 1.80\n { \'employer_share\': 1.80\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : gross_salary\n , \'base\' : gross_salary\n
}\n }\n
\n \n
# CSG\n # CSG\n
d[\'csg_deductible/salaire_brut_csg\'] = \\\n kw[\'csg_deductible/salaire_brut_csg\'] = \\\n
{ \'employer_rate\' : None\n { \'employer_share\': None\n
, \'employee_rate\' : 5.10\n , \'employee_share\': 5.10\n
, \'base\' : 0.97 * gross_salary\n , \'base\' : 0.97 * gross_salary\n
}\n }\n
d[\'csg_non_deductible/salaire_brut_csg\'] = \\\n kw[\'csg_non_deductible/salaire_brut_csg\'] = \\\n
{ \'employer_rate\' : None\n { \'employer_share\': None\n
, \'employee_rate\' : 2.9\n , \'employee_share\': 2.9\n
, \'base\' : 0.97 * gross_salary\n , \'base\' : 0.97 * gross_salary\n
}\n }\n
\n \n
# CRDS\n # CRDS\n
# d[\'crds/salaire_brut_crds\'] = \\\n # kw[\'crds/salaire_brut_crds\'] = \\\n
# { \'employer_rate\' : None\n # { \'employer_share\': None\n
# , \'employee_rate\' : 0.50\n # , \'employee_share\': 0.50\n
# , \'base\' : 0.97 * gross_salary\n # , \'base\' : 0.97 * gross_salary\n
# }\n # }\n
\n \n
# Unemployment insurance = Assurance chomage\n # Unemployment insurance = Assurance chomage\n
d[\'unemployment_insurance/salaire_brut\'] = \\\n kw[\'unemployment_insurance/salaire_brut\'] = \\\n
{ \'employer_rate\' : 4.04\n { \'employer_share\': 4.04\n
, \'employee_rate\' : 2.44\n , \'employee_share\': 2.44\n
, \'base\' : gross_salary\n , \'base\' : gross_salary\n
}\n }\n
\n \n
...@@ -336,18 +283,18 @@ d[\'unemployment_insurance/salaire_brut\'] = \\\n ...@@ -336,18 +283,18 @@ d[\'unemployment_insurance/salaire_brut\'] = \\\n
fngs_employer_rate = 0.25\n fngs_employer_rate = 0.25\n
if start_date >= DateTime(2006, 7, 1):\n if start_date >= DateTime(2006, 7, 1):\n
fngs_employer_rate = 0.15\n fngs_employer_rate = 0.15\n
d[\'fngs/salaire_brut\'] = \\\n kw[\'fngs/salaire_brut\'] = \\\n
{ \'employer_rate\' : fngs_employer_rate\n { \'employer_share\': fngs_employer_rate\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : gross_salary\n , \'base\' : gross_salary\n
}\n }\n
\n \n
# ARRCO\n # ARRCO\n
if not executive:\n if not executive:\n
if salary_slices.has_key(\'1\'):\n if salary_slices.has_key(\'1\'):\n
d[\'arrco/tranche_1\'] = \\\n kw[\'arrco/tranche_1\'] = \\\n
{ \'employer_rate\' : 4.5\n { \'employer_share\': 4.5\n
, \'employee_rate\' : 3.0\n , \'employee_share\': 3.0\n
, \'base\' : salary_slices[\'1\']\n , \'base\' : salary_slices[\'1\']\n
}\n }\n
if salary_slices.has_key(\'2\'):\n if salary_slices.has_key(\'2\'):\n
...@@ -357,43 +304,43 @@ if not executive:\n ...@@ -357,43 +304,43 @@ if not executive:\n
else:\n else:\n
employee_share_rate = 8.0\n employee_share_rate = 8.0\n
employer_share_rate = 12.0\n employer_share_rate = 12.0\n
d[\'arrco/tranche_2\'] = \\\n kw[\'arrco/tranche_2\'] = \\\n
{ \'employer_rate\' : employer_share_rate\n { \'employer_share\': employer_share_rate\n
, \'employee_rate\' : employee_share_rate\n , \'employee_share\': employee_share_rate\n
, \'base\' : salary_slices[\'2\']\n , \'base\' : salary_slices[\'2\']\n
}\n }\n
elif salary_slices.has_key(\'A\'):\n elif salary_slices.has_key(\'A\'):\n
d[\'arrco/tranche_a\'] = \\\n kw[\'arrco/tranche_a\'] = \\\n
{ \'employer_rate\' : 4.5\n { \'employer_share\': 4.5\n
, \'employee_rate\' : 3.0\n , \'employee_share\': 3.0\n
, \'base\' : salary_slices[\'A\']\n , \'base\' : salary_slices[\'A\']\n
}\n }\n
\n \n
# AGFF\n # AGFF\n
if executive:\n if executive:\n
if salary_slices.has_key(\'A\'):\n if salary_slices.has_key(\'A\'):\n
d[\'agff_tranche_a/tranche_a\'] = \\\n kw[\'agff_tranche_a/tranche_a\'] = \\\n
{ \'employer_rate\' : 1.20\n { \'employer_share\': 1.20\n
, \'employee_rate\' : 0.80\n , \'employee_share\': 0.80\n
, \'base\' : salary_slices[\'A\']\n , \'base\' : salary_slices[\'A\']\n
}\n }\n
if salary_slices.has_key(\'B\'):\n if salary_slices.has_key(\'B\'):\n
d[\'agff_tranche_b/tranche_b\'] = \\\n kw[\'agff_tranche_b/tranche_b\'] = \\\n
{ \'employer_rate\' : 1.30\n { \'employer_share\': 1.30\n
, \'employee_rate\' : 0.90\n , \'employee_share\': 0.90\n
, \'base\' : salary_slices[\'B\']\n , \'base\' : salary_slices[\'B\']\n
}\n }\n
else:\n else:\n
if salary_slices.has_key(\'1\'):\n if salary_slices.has_key(\'1\'):\n
d[\'agff_tranche_a/tranche_1\'] = \\\n kw[\'agff_tranche_a/tranche_1\'] = \\\n
{ \'employer_rate\' : 1.20\n { \'employer_share\': 1.20\n
, \'employee_rate\' : 0.80\n , \'employee_share\': 0.80\n
, \'base\' : salary_slices[\'1\']\n , \'base\' : salary_slices[\'1\']\n
}\n }\n
if salary_slices.has_key(\'2\'):\n if salary_slices.has_key(\'2\'):\n
d[\'agff_tranche_b/tranche_2\'] = \\\n kw[\'agff_tranche_b/tranche_2\'] = \\\n
{ \'employer_rate\' : 1.30\n { \'employer_share\': 1.30\n
, \'employee_rate\' : 0.90\n , \'employee_share\': 0.90\n
, \'base\' : salary_slices[\'2\']\n , \'base\' : salary_slices[\'2\']\n
}\n }\n
\n \n
...@@ -401,82 +348,82 @@ else:\n ...@@ -401,82 +348,82 @@ else:\n
# TODO: fix the repartition of share rate in case of slice C\n # TODO: fix the repartition of share rate in case of slice C\n
if executive:\n if executive:\n
if salary_slices.has_key(\'B\'):\n if salary_slices.has_key(\'B\'):\n
d[\'argic/tranche_b\'] = \\\n kw[\'argic/tranche_b\'] = \\\n
{ \'employer_rate\' : 12.60\n { \'employer_share\': 12.60\n
, \'employee_rate\' : 7.70\n , \'employee_share\': 7.70\n
, \'base\' : salary_slices[\'B\']\n , \'base\' : salary_slices[\'B\']\n
}\n }\n
if salary_slices.has_key(\'C\'):\n if salary_slices.has_key(\'C\'):\n
# free repartition (20.30% to share between employee & employer)\n # free repartition (20.30% to share between employee & employer)\n
d[\'argic/tranche_c\'] = \\\n kw[\'argic/tranche_c\'] = \\\n
{ \'employer_rate\' : 10.15\n { \'employer_share\': 10.15\n
, \'employee_rate\' : 10.15\n , \'employee_share\': 10.15\n
, \'base\' : salary_slices[\'C\']\n , \'base\' : salary_slices[\'C\']\n
}\n }\n
\n \n
# CET\n # CET\n
if executive:\n if executive:\n
if salary_slices.has_key(\'A\'):\n if salary_slices.has_key(\'A\'):\n
d[\'cet/tranche_a\'] = \\\n kw[\'cet/tranche_a\'] = \\\n
{ \'employer_rate\' : 0.22\n { \'employer_share\': 0.22\n
, \'employee_rate\' : 0.13\n , \'employee_share\': 0.13\n
, \'base\' : salary_slices[\'A\']\n , \'base\' : salary_slices[\'A\']\n
}\n }\n
if salary_slices.has_key(\'B\'):\n if salary_slices.has_key(\'B\'):\n
d[\'cet/tranche_b\'] = \\\n kw[\'cet/tranche_b\'] = \\\n
{ \'employer_rate\' : 0.22\n { \'employer_share\': 0.22\n
, \'employee_rate\' : 0.13\n , \'employee_share\': 0.13\n
, \'base\' : salary_slices[\'B\']\n , \'base\' : salary_slices[\'B\']\n
}\n }\n
if salary_slices.has_key(\'C\'):\n if salary_slices.has_key(\'C\'):\n
d[\'cet/tranche_c\'] = \\\n kw[\'cet/tranche_c\'] = \\\n
{ \'employer_rate\' : 0.22\n { \'employer_share\': 0.22\n
, \'employee_rate\' : 0.13\n , \'employee_share\': 0.13\n
, \'base\' : salary_slices[\'C\']\n , \'base\' : salary_slices[\'C\']\n
}\n }\n
\n \n
# Life insurance = Assurance vie\n # Life insurance = Assurance vie\n
# if executive == True and salary_slices.has_key(\'A\'):\n # if executive == True and salary_slices.has_key(\'A\'):\n
# d[\'life_insurance/tranche_a\'] = \\\n # kw[\'life_insurance/tranche_a\'] = \\\n
# { \'employer_rate\' : 1.5\n # { \'employer_share\': 1.5\n
# , \'employee_rate\' : None\n # , \'employee_share\': None\n
# , \'base\' : salary_slices[\'A\']\n # , \'base\' : salary_slices[\'A\']\n
# }\n # }\n
\n \n
# APEC forfaitaire\n # APEC forfaitaire\n
if executive:\n if executive:\n
d[\'apec/forfait\'] = \\\n kw[\'apec/forfait\'] = \\\n
{ \'employer_rate\' : 3.72\n { \'employer_share\': 3.72\n
, \'employee_rate\' : 2.49\n , \'employee_share\': 2.49\n
, \'base\' : 1.0\n , \'base\' : 1.0\n
}\n }\n
if salary_slices.has_key(\'B\'):\n if salary_slices.has_key(\'B\'):\n
d[\'apec/tranche_b\'] = \\\n kw[\'apec/tranche_b\'] = \\\n
{ \'employer_rate\' : 0.036\n { \'employer_share\': 0.036\n
, \'employee_rate\' : 0.024\n , \'employee_share\': 0.024\n
, \'base\' : salary_slices[\'B\']\n , \'base\' : salary_slices[\'B\']\n
}\n }\n
\n \n
# Retirement = Retraite Cadre forfaitaire\n # Retirement = Retraite Cadre forfaitaire\n
if executive:\n if executive:\n
d[\'cavcic/forfait\'] = \\\n kw[\'cavcic/forfait\'] = \\\n
{ \'employer_rate\' : 35.62\n { \'employer_share\': 35.62\n
, \'employee_rate\' : 21.21\n , \'employee_share\': 21.21\n
, \'base\' : 1.0\n , \'base\' : 1.0\n
}\n }\n
\n \n
# construction tax\n # construction tax\n
# if company_size > 9:\n # if company_size > 9:\n
# d[\'construction_tax/salaire_brut\'] = \\\n # kw[\'construction_tax/salaire_brut\'] = \\\n
# { \'employer_rate\' : 0.45\n # { \'employer_share\': 0.45\n
# , \'employee_rate\' : None\n # , \'employee_share\': None\n
# , \'base\' : gross_salary\n # , \'base\' : gross_salary\n
# }\n # }\n
\n \n
# training tax\n # training tax\n
# d[\'training_tax/salaire_brut\'] = \\\n # kw[\'training_tax/salaire_brut\'] = \\\n
# { \'employer_rate\' : 0.50\n # { \'employer_share\': 0.50\n
# , \'employee_rate\' : None\n # , \'employee_share\': None\n
# , \'base\' : gross_salary\n # , \'base\' : gross_salary\n
# }\n # }\n
\n \n
...@@ -485,9 +432,9 @@ if executive:\n ...@@ -485,9 +432,9 @@ if executive:\n
# rate = 0.15\n # rate = 0.15\n
# else:\n # else:\n
# rate = 1.5\n # rate = 1.5\n
# d[\'courses_tax/salaire_brut\'] = \\\n # kw[\'courses_tax/salaire_brut\'] = \\\n
# { \'employer_rate\' : rate\n # { \'employer_share\': rate\n
# , \'employee_rate\' : None\n # , \'employee_share\': None\n
# , \'base\' : gross_salary\n # , \'base\' : gross_salary\n
# }\n # }\n
\n \n
...@@ -501,9 +448,9 @@ if col_agr not in (None, \'\') and \'syntec\' in col_agr.lower():\n ...@@ -501,9 +448,9 @@ if col_agr not in (None, \'\') and \'syntec\' in col_agr.lower():\n
syntec_rate = 0.96\n syntec_rate = 0.96\n
if employee.getMaritalStatusId() == \'married\':\n if employee.getMaritalStatusId() == \'married\':\n
syntec_rate *= 2\n syntec_rate *= 2\n
d[\'syntec_insurance/salaire_plafonne_syntec\'] = \\\n kw[\'syntec_insurance/salaire_plafonne_syntec\'] = \\\n
{ \'employer_rate\' : syntec_rate\n { \'employer_share\': syntec_rate\n
, \'employee_rate\' : syntec_rate\n , \'employee_share\': syntec_rate\n
, \'base\' : ceiling_salary\n , \'base\' : ceiling_salary\n
}\n }\n
\n \n
...@@ -513,19 +460,19 @@ if col_agr not in (None, \'\') and \'syntec\' in col_agr.lower():\n ...@@ -513,19 +460,19 @@ if col_agr not in (None, \'\') and \'syntec\' in col_agr.lower():\n
# * non-working days (= absences)\n # * non-working days (= absences)\n
# Thanks to this, the accountant has the freedom to add the missing amount of money\n # Thanks to this, the accountant has the freedom to add the missing amount of money\n
# that this script can\'t guess.\n # that this script can\'t guess.\n
d[\'retenue_maladie/forfait\'] = \\\n kw[\'retenue_maladie/forfait\'] = \\\n
{ \'employer_rate\' : None\n { \'employer_share\': None\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : 1.0\n , \'base\' : 1.0\n
}\n }\n
d[\'primes/forfait\'] = \\\n kw[\'primes/forfait\'] = \\\n
{ \'employer_rate\' : None\n { \'employer_share\': None\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : 1.0\n , \'base\' : 1.0\n
}\n }\n
d[\'absences/forfait\'] = \\\n kw[\'absences/forfait\'] = \\\n
{ \'employer_rate\' : None\n { \'employer_share\': None\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : 1.0\n , \'base\' : 1.0\n
}\n }\n
\n \n
...@@ -533,27 +480,13 @@ d[\'absences/forfait\'] = \\\n ...@@ -533,27 +480,13 @@ d[\'absences/forfait\'] = \\\n
# This tax can be calculated automaticcaly.\n # This tax can be calculated automaticcaly.\n
# Because of lack of time we just let the accountant do the work.\n # Because of lack of time we just let the accountant do the work.\n
# See coresponding service description for more details.\n # See coresponding service description for more details.\n
d[\'reduction_fillon_forfait/forfait\'] = \\\n kw[\'reduction_fillon_forfait/forfait\'] = \\\n
{ \'employer_rate\' : None\n { \'employer_share\': None\n
, \'employee_rate\' : None\n , \'employee_share\': None\n
, \'base\' : 1.0\n , \'base\' : 1.0\n
}\n }\n
\n \n
# Because all rates above are written in percents, we must convert them in pure floats.\n return kw\n
# TODO: this part is generic, so move it to PaySheetTransaction_preCalculation script.\n
for line_id in d.keys():\n
# Only \'Fixed\' (or \'Forfait\' in french) base are expressed in percents\n
if not line_id.endswith(\'/forfait\'):\n
# Fix percents\n
for share_type in [\'employer_rate\', \'employee_rate\']:\n
share_value = d[line_id][share_type]\n
if share_value not in (\'\', None):\n
d[line_id][share_type] = share_value / 100.0\n
# Normalize the value of \'Fixed\' (or \'Forfait\' in french) base to 1.0\n
else:\n
d[line_id][\'base\'] = 1.0\n
\n
return d\n
]]></string> </value> ]]></string> </value>
...@@ -610,6 +543,7 @@ return d\n ...@@ -610,6 +543,7 @@ return d\n
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>kw</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>paysheet</string> <string>paysheet</string>
...@@ -644,22 +578,7 @@ return d\n ...@@ -644,22 +578,7 @@ return d\n
<string>DateTime</string> <string>DateTime</string>
<string>old_limit</string> <string>old_limit</string>
<string>comp_type</string> <string>comp_type</string>
<string>d</string>
<string>erp5site</string>
<string>hasattr</string>
<string>service_module</string>
<string>paysheet_services</string>
<string>_getiter_</string>
<string>service</string>
<string>base_cat</string>
<string>service_categories</string>
<string>tax_categories</string>
<string>salary_range_categories</string>
<string>category</string>
<string>salary_range</string>
<string>salary_range_object</string>
<string>None</string> <string>None</string>
<string>preview_line_uid</string>
<string>employer_rate</string> <string>employer_rate</string>
<string>employee_rate</string> <string>employee_rate</string>
<string>fngs_employer_rate</string> <string>fngs_employer_rate</string>
...@@ -667,9 +586,6 @@ return d\n ...@@ -667,9 +586,6 @@ return d\n
<string>employer_share_rate</string> <string>employer_share_rate</string>
<string>col_agr</string> <string>col_agr</string>
<string>syntec_rate</string> <string>syntec_rate</string>
<string>line_id</string>
<string>share_type</string>
<string>share_value</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
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