Commit ff8f63be authored by Kevin Deldycke's avatar Kevin Deldycke

Support dynamic update of gross salary calculation on pay sheet preview

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10913 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b4ad51f5
......@@ -73,6 +73,9 @@
"""\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
This script accept gross_salary parameter to override the default one.\n
This is helpfull in case of update made on PaySheetTransaction_viewPreview fast input.\n
"""\n
\n
kw = {}\n
......@@ -89,8 +92,10 @@ paysheet_type = paysheet.getPortalType()\n
employee = paysheet.getDestinationSectionValue()\n
company = paysheet.getSourceSectionValue()\n
\n
# Get Paysheet datas\n
gross_salary = abs(paysheet.getGrossSalary())\n
# Use the gross salary given as parameter or not\n
if gross_salary == None:\n
gross_salary = abs(paysheet.getGrossSalary())\n
\n
start_date = paysheet.getStartDate()\n
stop_date = paysheet.getStopDate()\n
\n
......@@ -410,7 +415,6 @@ if executive:\n
comp_date = DateTime(start_date.year(), 3, 31)\n
while comp_date < comp_date:\n
comp_date = DateTime(comp_date.year() + 1, 3, 31)\n
context.log("kev date", repr(comp_date))\n
if executive and start_date <= comp_date <= stop_date:\n
kw[\'apec/forfait\'] = \\\n
{ \'employer_share\': 3.72\n
......@@ -513,6 +517,25 @@ kw[\'precarite/gross\'] = \\\n
, \'base\' : 1.0\n
}\n
\n
\n
# Normalize\n
for line_key in kw.keys():\n
# Only \'variable\' contribution are expressed in percents of a base\n
line = kw[line_key]\n
# \'Fixed\' contributions\n
if line_key.endswith(\'/gross\') or \\\n
line_key.endswith(\'/forfait\'):\n
# Defensive programming: be sure conventions are respected\n
kw[line_key][\'base\'] = 1.0\n
# \'Variable\' contributions\n
else:\n
# All rates in this script are written in percents, we must convert them in pure floats.\n
for share_type in [\'employer_share\', \'employee_share\']:\n
share_value = line[share_type]\n
if share_value not in [\'\', None]:\n
# Fix percents\n
kw[line_key][share_type] = share_value / 100.0\n
\n
return kw\n
......@@ -544,7 +567,7 @@ return kw\n
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
<value> <string>gross_salary=None</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
......@@ -564,12 +587,13 @@ return kw\n
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>0</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>gross_salary</string>
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
......@@ -577,8 +601,8 @@ return kw\n
<string>paysheet_type</string>
<string>employee</string>
<string>company</string>
<string>None</string>
<string>abs</string>
<string>gross_salary</string>
<string>start_date</string>
<string>stop_date</string>
<string>ceiling_salary_list</string>
......@@ -605,16 +629,19 @@ return kw\n
<string>DateTime</string>
<string>old_limit</string>
<string>comp_type</string>
<string>None</string>
<string>employer_rate</string>
<string>employee_rate</string>
<string>fngs_employer_rate</string>
<string>employee_share_rate</string>
<string>employer_share_rate</string>
<string>comp_date</string>
<string>repr</string>
<string>col_agr</string>
<string>syntec_rate</string>
<string>_getiter_</string>
<string>line_key</string>
<string>line</string>
<string>share_type</string>
<string>share_value</string>
</tuple>
</value>
</item>
......@@ -626,7 +653,9 @@ return kw\n
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<none/>
</tuple>
</value>
</item>
<item>
......
......@@ -68,22 +68,29 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>return context.REQUEST.RESPONSE.redirect(\'%s/PaySheetTransaction_viewPreview?portal_status_message=Base+Salary+updated.\' % context.absolute_url())\n
<value> <string encoding="cdata"><![CDATA[
"""\n
This script get the new listbox content and save it in a selection to let the\n
listbox script (PaySheetTransaction_initializePreview) recalculate necessary contributions.\n
"""\n
\n
# Get all cells which are needed to calculate the base_salary\n
portal = context.getPortalObject()\n
N_ = portal.Base_translateString\n
\n
# Scan the listbox and look for complementary lines to add to the gross salary\n
#for user_line in listbox:\n
# if user_line[\'base\'] not in (None, \'\'):\n
# Get the base salary if given by the user\n
# base = r_(user_line[\'base\'])\n
# Save listbox dict in a selection for recalculation\n
if len(listbox) > 0:\n
# XXX Don\'t know how the selection is supposed to behave in case of simultaneous\n
# pay sheet edition by the same user.\n
context.portal_selections.setSelectionParamsFor(script.id, {\'updated_listbox\': listbox})\n
\n
# IDEA: compare normal _initializePreview returned rates and base with the current one and keep user-defined values. Then merge them with current one.\n
# This is the only solution to mimic real user interaction without AJAX/DHTML-like UI.\n
\n
# Recalculate the preview with new base_salary\n
#std_lines = context.PaySheetTransaction_initializePreview()\n
</string> </value>
from ZTUtils import make_query\n
params = { \'portal_status_message\': N_(\'Gross Salary and Depending Contributions Updated.\')}\n
redirect_url = \'%s/%s?%s\' % (context.absolute_url(), \'PaySheetTransaction_viewPreview\', make_query(params))\n
return context.REQUEST.RESPONSE.redirect(redirect_url)\n
]]></string> </value>
</item>
<item>
<key> <string>_code</string> </key>
......@@ -135,6 +142,14 @@
<string>kw</string>
<string>_getattr_</string>
<string>context</string>
<string>portal</string>
<string>N_</string>
<string>len</string>
<string>script</string>
<string>ZTUtils</string>
<string>make_query</string>
<string>params</string>
<string>redirect_url</string>
</tuple>
</value>
</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