Commit 69098d3c authored by Kevin Deldycke's avatar Kevin Deldycke

Calculate yearly sums.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10986 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ad651d97
...@@ -219,9 +219,6 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n ...@@ -219,9 +219,6 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n
, \'employee_share\' : None # Employee Share (Part salariale)\n , \'employee_share\' : None # Employee Share (Part salariale)\n
, \'taxable\' : taxable\n , \'taxable\' : taxable\n
, \'description\' : None\n , \'description\' : None\n
# , \'service_id\' : None # Service ID\n
# , \'salary_range\' : None # Salary Range\n
# , \'tax_category\' : None # Tax Category\n
}\n }\n
# Update group\'s sublines\n # Update group\'s sublines\n
groups = details[\'groups\']\n groups = details[\'groups\']\n
...@@ -281,10 +278,10 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n ...@@ -281,10 +278,10 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n
line_description = line_description.replace(\'\\n\', \' \').strip().capitalize()\n line_description = line_description.replace(\'\\n\', \' \').strip().capitalize()\n
if len(line_description) > 0:\n if len(line_description) > 0:\n
updateSubLine( group_id = cell_group_id\n updateSubLine( group_id = cell_group_id\n
, subline_id = cell_subline_id\n , subline_id = cell_subline_id\n
, property = \'description\'\n , property = \'description\'\n
, value = \'(%s)\' % line_description\n , value = \'(%s)\' % line_description\n
)\n )\n
\n \n
### Gross salary group handling\n ### Gross salary group handling\n
if range_type.startswith("fixed/gross"):\n if range_type.startswith("fixed/gross"):\n
...@@ -370,11 +367,9 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n ...@@ -370,11 +367,9 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n
\n \n
\n \n
##########################################\n ##########################################\n
# TODO: insert code here to get yearly totals\n # Calculate current paysheet grand totals\n
##########################################\n ##########################################\n
\n \n
\n
\n
details[\'totals\'][\'gross_salary\'] = gross_salary\n details[\'totals\'][\'gross_salary\'] = gross_salary\n
details[\'totals\'][\'net_salary\'] = net_salary\n details[\'totals\'][\'net_salary\'] = net_salary\n
details[\'totals\'][\'taxable_net_salary\'] = r_(net_salary + taxable_net_salary)\n details[\'totals\'][\'taxable_net_salary\'] = r_(net_salary + taxable_net_salary)\n
...@@ -385,6 +380,56 @@ details[\'totals\'][\'total_employee_payment\'] = r_(net_salary + total_addendum ...@@ -385,6 +380,56 @@ details[\'totals\'][\'total_employee_payment\'] = r_(net_salary + total_addendum
\n \n
\n \n
\n \n
##########################################\n
# Calculate yearly sums if needed\n
##########################################\n
\n
if not ignore_yearly_sums:\n
\n
# Calculate the year period\n
from DateTime import DateTime\n
start_year = context.getStartDate().year()\n
year_start_date = DateTime(start_year, 1, 1)\n
year_stop_date = context.getStopDate()\n
\n
\n
# Initialize the yearly sums data structure with current paysheet totals\n
yearly_sums = { \'start_date\': year_start_date\n
, \'stop_date\' : context.getStopDate()\n
}\n
yearly_sums_base_id = details[\'totals\'].keys()\n
for base_id in yearly_sums_base_id:\n
yearly_sums[base_id] = details[\'totals\'][base_id]\n
\n
\n
# Get all paysheet transaction to calculate the sum of different value in a year\n
search_params = \\\n
{ \'portal_type\' : \'Pay Sheet Transaction\'\n
, \'simulation_state\' : [\'planned\', \'confirmed\', \'stopped\', \'delivered\']\n
, \'delivery.start_date\' : {\'range\': "minngt", \'query\': (year_start_date, year_stop_date)}\n
, \'destination_section_uid\': context.getDestinationSectionUid() # Employee\'s UID\n
}\n
accounting_folder = context.aq_parent\n
paysheet_transactions = accounting_folder.searchFolder(**search_params)\n
\n
\n
# Browse through paysheet transaction\n
current_paysheet_uid = context.getUid()\n
for paysheet in paysheet_transactions:\n
# Ignore the current paysheet to avoid infinite loop\n
if paysheet.getUid() != current_paysheet_uid:\n
# Get all detailed values of the paysheet\n
paysheet_details = paysheet.PaySheetTransaction_getDetails(ignore_yearly_sums = True)\n
for base_id in yearly_sums_base_id:\n
if paysheet_details[\'totals\'].has_key(base_id):\n
yearly_sums[base_id] = r_(yearly_sums[base_id] + r_(float(paysheet_details[\'totals\'][base_id])))\n
\n
\n
# Save the yearly sums in the current details dict\n
details[\'totals\'][\'yearly\'] = yearly_sums\n
\n
\n
\n
##############################################################################\n ##############################################################################\n
# Transform every float value to a string representation according the currency.\n # Transform every float value to a string representation according the currency.\n
##############################################################################\n ##############################################################################\n
...@@ -420,10 +465,14 @@ for group_id in getPSLGroupIdList():\n ...@@ -420,10 +465,14 @@ for group_id in getPSLGroupIdList():\n
, value = new_value\n , value = new_value\n
)\n )\n
\n \n
# Format totals\n # Format totals and yearly sums\n
for (key, value) in details[\'totals\'].items():\n for (key, value) in details[\'totals\'].items():\n
if same_type(value, 1.0) or same_type(value, 1):\n if same_type(value, 1.0) or same_type(value, 1):\n
details[\'totals\'][key] = (\'%.\' + str(currency_precision) + \'f\') % value\n details[\'totals\'][key] = (\'%.\' + str(currency_precision) + \'f\') % value\n
elif key == \'yearly\':\n
for (key, value) in details[\'totals\'][\'yearly\'].items():\n
if same_type(value, 1.0) or same_type(value, 1):\n
details[\'totals\'][\'yearly\'][key] = (\'%.\' + str(currency_precision) + \'f\') % value\n
\n \n
\n \n
return details\n return details\n
...@@ -451,7 +500,7 @@ return details\n ...@@ -451,7 +500,7 @@ return details\n
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string></string> </value> <value> <string>ignore_yearly_sums=False</string> </value>
</item> </item>
<item> <item>
<key> <string>errors</string> </key> <key> <string>errors</string> </key>
...@@ -471,12 +520,13 @@ return details\n ...@@ -471,12 +520,13 @@ return details\n
<dictionary> <dictionary>
<item> <item>
<key> <string>co_argcount</string> </key> <key> <string>co_argcount</string> </key>
<value> <int>0</int> </value> <value> <int>1</int> </value>
</item> </item>
<item> <item>
<key> <string>co_varnames</string> </key> <key> <string>co_varnames</string> </key>
<value> <value>
<tuple> <tuple>
<string>ignore_yearly_sums</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>context</string> <string>context</string>
<string>portal</string> <string>portal</string>
...@@ -533,6 +583,21 @@ return details\n ...@@ -533,6 +583,21 @@ return details\n
<string>cell_base</string> <string>cell_base</string>
<string>cell_share</string> <string>cell_share</string>
<string>subline</string> <string>subline</string>
<string>DateTime</string>
<string>start_year</string>
<string>year_start_date</string>
<string>year_stop_date</string>
<string>yearly_sums</string>
<string>yearly_sums_base_id</string>
<string>base_id</string>
<string>search_params</string>
<string>accounting_folder</string>
<string>_apply_</string>
<string>paysheet_transactions</string>
<string>current_paysheet_uid</string>
<string>paysheet</string>
<string>paysheet_details</string>
<string>float</string>
<string>RATE_PRECISION</string> <string>RATE_PRECISION</string>
<string>money_format</string> <string>money_format</string>
<string>rate_format</string> <string>rate_format</string>
...@@ -556,7 +621,9 @@ return details\n ...@@ -556,7 +621,9 @@ return details\n
<item> <item>
<key> <string>func_defaults</string> </key> <key> <string>func_defaults</string> </key>
<value> <value>
<none/> <tuple>
<int>0</int>
</tuple>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -50,10 +50,10 @@ ...@@ -50,10 +50,10 @@
<?xml version="1.0" encoding="iso-8859-1" ?>\n <?xml version="1.0" encoding="iso-8859-1" ?>\n
\n \n
<tal:block tal:define="employee python: here.getDestinationSectionValue();\n <tal:block tal:define="employee python: here.getDestinationSectionValue();\n
employer python: here.getSourceSectionValue();\n employer python: here.getSourceSectionValue();\n
urssaf python: employer.getDestinationSectionValue();\n urssaf python: employer.getDestinationSectionValue();\n
start_date python: here.getStartDate()">\n start_date python: here.getStartDate()">\n
\n \n
<template bottommargin=\'0.665cm\'\n <template bottommargin=\'0.665cm\'\n
showboundary=\'0\'\n showboundary=\'0\'\n
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
allowsplitting=\'1\'\n allowsplitting=\'1\'\n
landscape=\'0\'\n landscape=\'0\'\n
leftmargin=\'0.635cm\'\n leftmargin=\'0.635cm\'\n
tal:define=\'portal python: here.portal_url.getPortalObject()\'>\n tal:define=\'portal python: here.getPortalObject()\'>\n
\n \n
<stylesheet>\n <stylesheet>\n
<tablestyle name="decompte">\n <tablestyle name="decompte">\n
...@@ -121,9 +121,9 @@ ...@@ -121,9 +121,9 @@
<stylecmd expr="(\'LEFTPADDING\', (0,0), (-1,-1), 4)"/>\n <stylecmd expr="(\'LEFTPADDING\', (0,0), (-1,-1), 4)"/>\n
\n \n
<!--Tableau de gauche -->\n <!--Tableau de gauche -->\n
<stylecmd expr="(\'GRID\', (0,0), (4,1), 0.1, (0.4,0.4,0.4))"/>\n <stylecmd expr="(\'GRID\', (0,0), (5,1), 0.1, (0.4,0.4,0.4))"/>\n
<stylecmd expr="(\'ALIGNMENT\', (0,0), (4,0), \'CENTER\')"/>\n <stylecmd expr="(\'ALIGNMENT\', (0,0), (5,0), \'CENTER\')"/>\n
<stylecmd expr="(\'ALIGNMENT\', (0,1), (4,1), \'RIGHT\')"/>\n <stylecmd expr="(\'ALIGNMENT\', (0,1), (5,1), \'RIGHT\')"/>\n
\n \n
<!-- Deuxieme ligne de droite -->\n <!-- Deuxieme ligne de droite -->\n
<!-- <stylecmd expr="(\'LINEBELOW\', (-1,0), (-1,0), 0.1, (0.4,0.4,0.4))"/>\n <!-- <stylecmd expr="(\'LINEBELOW\', (-1,0), (-1,0), 0.1, (0.4,0.4,0.4))"/>\n
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
<document filename="report01.pdf"\n <document filename="report01.pdf"\n
xmlns:tal="http://xml.zope.org/namespaces/tal"\n xmlns:tal="http://xml.zope.org/namespaces/tal"\n
tal:define="details python: here.PaySheetTransaction_getDetails();\n tal:define="details python: here.PaySheetTransaction_getDetails();\n
yearly_sums python: details[\'totals\'][\'yearly\'];\n
start_date python: here.getStartDate();\n start_date python: here.getStartDate();\n
boldstyle python: \'(\\\'FONT\\\', \\\'Helvetica-Bold\\\', 7)\';\n boldstyle python: \'(\\\'FONT\\\', \\\'Helvetica-Bold\\\', 7)\';\n
GROSS_SALARY_GROUP_ID python: \'gross\';\n GROSS_SALARY_GROUP_ID python: \'gross\';\n
...@@ -263,33 +264,35 @@ ...@@ -263,33 +264,35 @@
\n \n
<table style="cumul_conges">\n <table style="cumul_conges">\n
<tr>\n <tr>\n
<td colwidth="11cm"> <tal:block tal:replace="python: \'Cumuls annuels (%s)\' % start_date.year()" tal:condition="python: start_date not in (\'\', None)"/></td>\n <td colwidth="12cm"><tal:block replace="python: \'Cumuls Annuels (%s au %s)\' % (yearly_sums[\'start_date\'], yearly_sums[\'stop_date\'])"/> </td>\n
<td colwidth="3cm"> </td>\n <td colwidth="2cm"> </td>\n
<td colwidth="5cm"> <!-- <tal:block tal:replace="python: \'Dur\xc3\xa9e des cong\xc3\xa9s pay\xc3\xa9s : ???\'"/> --> </td>\n <td colwidth="5cm"> </td>\n
</tr>\n </tr>\n
</table>\n </table>\n
<!--\n \n
<table style="cumul_conges_corps">\n <table style="cumul_conges_corps">\n
<tr>\n <tr>\n
<td colwidth="2cm">Salaire brut</td>\n <td colwidth="2cm">Salaire Brut</td>\n
<td colwidth="3cm">Cotisations salariales</td>\n <td colwidth="2cm">Part Patronale</td>\n
<td colwidth="2cm">Salaire net</td>\n <td colwidth="2cm">Part Salariale</td>\n
<td colwidth="2cm">Net imposable</td>\n <td colwidth="2cm">Salaire Net</td>\n
<td colwidth="2cm">Part patronale</td>\n <td colwidth="2cm">Net Imposable</td>\n
<td colwidth="3cm"> </td>\n <td colwidth="2cm">Addendum</td>\n
<td colwidth="2cm"> </td>\n
<td colwidth="5cm"> <tal:block tal:replace="python: \'Dur\xc3\xa9e des d\xc3\xa9lais de pr\xc3\xa9avis : \' + context.PaySheetTransaction_getResignmentLegalDelay()"/></td>\n <td colwidth="5cm"> <tal:block tal:replace="python: \'Dur\xc3\xa9e des d\xc3\xa9lais de pr\xc3\xa9avis : \' + context.PaySheetTransaction_getResignmentLegalDelay()"/></td>\n
</tr>\n </tr>\n
<tr>\n <tr>\n
<td> <tal:block replace="python: \'%.2f\' % paysheet_details[\'yearly_gross_salary\']" tal:condition="python: paysheet_details[\'yearly_gross_salary\'] not in (\'\', None)"></tal:block></td>\n <td><tal:block replace="python: yearly_sums[\'gross_salary\']" condition="python: yearly_sums.has_key(\'gross_salary\')"/> </td>\n
<td> <tal:block replace="python: \'%.2f\' % paysheet_details[\'yearly_employee_share\']" tal:condition="python: paysheet_details[\'yearly_employee_share\'] not in (\'\', None)"></tal:block></td>\n <td><tal:block replace="python: yearly_sums[\'total_employer_share\']" condition="python: yearly_sums.has_key(\'total_employer_share\')"/> </td>\n
<td> <tal:block replace="python: \'%.2f\' % paysheet_details[\'yearly_net_salary\']" tal:condition="python: paysheet_details[\'yearly_net_salary\'] not in (\'\', None)"></tal:block></td>\n <td><tal:block replace="python: yearly_sums[\'total_employee_share\']" condition="python: yearly_sums.has_key(\'total_employee_share\')"/> </td>\n
<td> <tal:block replace="python: \'%.2f\' % paysheet_details[\'yearly_taxable_net_salary\']" tal:condition="python: paysheet_details[\'yearly_taxable_net_salary\'] not in (\'\', None)"></tal:block></td>\n <td><tal:block replace="python: yearly_sums[\'net_salary\']" condition="python: yearly_sums.has_key(\'net_salary\')"/> </td>\n
<td> <tal:block replace="python: \'%.2f\' % paysheet_details[\'yearly_employer_share\']" tal:condition="python: paysheet_details[\'yearly_employer_share\'] not in (\'\', None)"></tal:block></td>\n <td><tal:block replace="python: yearly_sums[\'taxable_net_salary\']" condition="python: yearly_sums.has_key(\'taxable_net_salary\')"/> </td>\n
<td> </td>\n <td><tal:block replace="python: yearly_sums[\'total_addendum\']" condition="python: yearly_sums.has_key(\'total_addendum\')"/> </td>\n
<td> </td>\n <td> </td>\n
<td><!--tal:block replace="python: \'Dur\xc3\xa9e des cong\xc3\xa9s pay\xc3\xa9s : ???\'"/--> </td>\n
</tr>\n </tr>\n
</table>\n </table>\n
-->\n \n
</content>\n </content>\n
</document> </document>
......
2006-10-27 Kevin
* Calculate yearly sums.
2006-10-26 Kevin 2006-10-26 Kevin
* Accounting of paysheets addendum. * Accounting of paysheets addendum.
* Show pay sheet line comments on PDF. * Show pay sheet line comments on PDF.
......
125 128
\ No newline at end of file \ No newline at end of file
0.2.10 0.2.11
\ No newline at end of file \ No newline at end of file
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