From 69098d3ccc4e8c8dcd7f967d7fc5f411858e5cfb Mon Sep 17 00:00:00 2001 From: Kevin Deldycke <kevin@nexedi.com> Date: Fri, 27 Oct 2006 13:10:38 +0000 Subject: [PATCH] Calculate yearly sums. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10986 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../PaySheetTransaction_getDetails.xml | 95 ++++++++++++++++--- .../PaySheetTransaction_pdf_template.xml | 16 ++-- ...ansaction_viewPaySheetTransactionAsPDF.xml | 37 ++++---- bt5/erp5_payroll/bt/change_log | 3 + bt5/erp5_payroll/bt/revision | 2 +- bt5/erp5_payroll/bt/version | 2 +- 6 files changed, 114 insertions(+), 41 deletions(-) diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getDetails.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getDetails.xml index 85881706f1..5c404c84d9 100644 --- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getDetails.xml +++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_getDetails.xml @@ -219,9 +219,6 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n , \'employee_share\' : None # Employee Share (Part salariale)\n , \'taxable\' : taxable\n , \'description\' : None\n -# , \'service_id\' : None # Service ID\n -# , \'salary_range\' : None # Salary Range\n -# , \'tax_category\' : None # Tax Category\n }\n # Update group\'s sublines\n groups = details[\'groups\']\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 if len(line_description) > 0:\n updateSubLine( group_id = cell_group_id\n - , subline_id = cell_subline_id\n - , property = \'description\'\n - , value = \'(%s)\' % line_description\n - )\n + , subline_id = cell_subline_id\n + , property = \'description\'\n + , value = \'(%s)\' % line_description\n + )\n \n ### Gross salary group handling\n if range_type.startswith("fixed/gross"):\n @@ -370,11 +367,9 @@ for psl in context.objectValues(portal_type=\'Pay Sheet Line\'):\n \n \n ##########################################\n -# TODO: insert code here to get yearly totals\n +# Calculate current paysheet grand totals\n ##########################################\n \n -\n -\n details[\'totals\'][\'gross_salary\'] = gross_salary\n details[\'totals\'][\'net_salary\'] = 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 \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 # Transform every float value to a string representation according the currency.\n ##############################################################################\n @@ -420,10 +465,14 @@ for group_id in getPSLGroupIdList():\n , value = new_value\n )\n \n -# Format totals\n +# Format totals and yearly sums\n for (key, value) in details[\'totals\'].items():\n if same_type(value, 1.0) or same_type(value, 1):\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 return details\n @@ -451,7 +500,7 @@ return details\n </item> <item> <key> <string>_params</string> </key> - <value> <string></string> </value> + <value> <string>ignore_yearly_sums=False</string> </value> </item> <item> <key> <string>errors</string> </key> @@ -471,12 +520,13 @@ return details\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>ignore_yearly_sums</string> <string>_getattr_</string> <string>context</string> <string>portal</string> @@ -533,6 +583,21 @@ return details\n <string>cell_base</string> <string>cell_share</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>money_format</string> <string>rate_format</string> @@ -556,7 +621,9 @@ return details\n <item> <key> <string>func_defaults</string> </key> <value> - <none/> + <tuple> + <int>0</int> + </tuple> </value> </item> <item> diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_pdf_template.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_pdf_template.xml index 5096265407..a200fe5680 100644 --- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_pdf_template.xml +++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_pdf_template.xml @@ -50,10 +50,10 @@ <?xml version="1.0" encoding="iso-8859-1" ?>\n \n -<tal:block tal:define="employee python: here.getDestinationSectionValue();\n - employer python: here.getSourceSectionValue();\n - urssaf python: employer.getDestinationSectionValue();\n - start_date python: here.getStartDate()">\n +<tal:block tal:define="employee python: here.getDestinationSectionValue();\n + employer python: here.getSourceSectionValue();\n + urssaf python: employer.getDestinationSectionValue();\n + start_date python: here.getStartDate()">\n \n <template bottommargin=\'0.665cm\'\n showboundary=\'0\'\n @@ -64,7 +64,7 @@ allowsplitting=\'1\'\n landscape=\'0\'\n leftmargin=\'0.635cm\'\n - tal:define=\'portal python: here.portal_url.getPortalObject()\'>\n + tal:define=\'portal python: here.getPortalObject()\'>\n \n <stylesheet>\n <tablestyle name="decompte">\n @@ -121,9 +121,9 @@ <stylecmd expr="(\'LEFTPADDING\', (0,0), (-1,-1), 4)"/>\n \n <!--Tableau de gauche -->\n - <stylecmd expr="(\'GRID\', (0,0), (4,1), 0.1, (0.4,0.4,0.4))"/>\n - <stylecmd expr="(\'ALIGNMENT\', (0,0), (4,0), \'CENTER\')"/>\n - <stylecmd expr="(\'ALIGNMENT\', (0,1), (4,1), \'RIGHT\')"/>\n + <stylecmd expr="(\'GRID\', (0,0), (5,1), 0.1, (0.4,0.4,0.4))"/>\n + <stylecmd expr="(\'ALIGNMENT\', (0,0), (5,0), \'CENTER\')"/>\n + <stylecmd expr="(\'ALIGNMENT\', (0,1), (5,1), \'RIGHT\')"/>\n \n <!-- Deuxieme ligne de droite -->\n <!-- <stylecmd expr="(\'LINEBELOW\', (-1,0), (-1,0), 0.1, (0.4,0.4,0.4))"/>\n diff --git a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_viewPaySheetTransactionAsPDF.xml b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_viewPaySheetTransactionAsPDF.xml index a7e42fe46f..10939b5180 100644 --- a/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_viewPaySheetTransactionAsPDF.xml +++ b/bt5/erp5_payroll/SkinTemplateItem/portal_skins/erp5_payroll/PaySheetTransaction_viewPaySheetTransactionAsPDF.xml @@ -53,6 +53,7 @@ <document filename="report01.pdf"\n xmlns:tal="http://xml.zope.org/namespaces/tal"\n tal:define="details python: here.PaySheetTransaction_getDetails();\n + yearly_sums python: details[\'totals\'][\'yearly\'];\n start_date python: here.getStartDate();\n boldstyle python: \'(\\\'FONT\\\', \\\'Helvetica-Bold\\\', 7)\';\n GROSS_SALARY_GROUP_ID python: \'gross\';\n @@ -263,33 +264,35 @@ \n <table style="cumul_conges">\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="3cm"> </td>\n - <td colwidth="5cm"> <!-- <tal:block tal:replace="python: \'Dur\xc3\xa9e des cong\xc3\xa9s pay\xc3\xa9s : ???\'"/> --> </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="2cm"> </td>\n + <td colwidth="5cm"> </td>\n </tr>\n </table>\n -<!--\n +\n <table style="cumul_conges_corps">\n <tr>\n - <td colwidth="2cm">Salaire brut</td>\n - <td colwidth="3cm">Cotisations salariales</td>\n - <td colwidth="2cm">Salaire net</td>\n - <td colwidth="2cm">Net imposable</td>\n - <td colwidth="2cm">Part patronale</td>\n - <td colwidth="3cm"> </td>\n + <td colwidth="2cm">Salaire Brut</td>\n + <td colwidth="2cm">Part Patronale</td>\n + <td colwidth="2cm">Part Salariale</td>\n + <td colwidth="2cm">Salaire Net</td>\n + <td colwidth="2cm">Net Imposable</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 </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: \'%.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: \'%.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: \'%.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: \'%.2f\' % paysheet_details[\'yearly_employer_share\']" tal:condition="python: paysheet_details[\'yearly_employer_share\'] not in (\'\', None)"></tal:block></td>\n - <td> </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: yearly_sums[\'total_employer_share\']" condition="python: yearly_sums.has_key(\'total_employer_share\')"/> </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: yearly_sums[\'net_salary\']" condition="python: yearly_sums.has_key(\'net_salary\')"/> </td>\n + <td><tal:block replace="python: yearly_sums[\'taxable_net_salary\']" condition="python: yearly_sums.has_key(\'taxable_net_salary\')"/> </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><!--tal:block replace="python: \'Dur\xc3\xa9e des cong\xc3\xa9s pay\xc3\xa9s : ???\'"/--> </td>\n </tr>\n </table>\n --->\n +\n </content>\n </document> diff --git a/bt5/erp5_payroll/bt/change_log b/bt5/erp5_payroll/bt/change_log index e43290f2dc..41fd7181b6 100644 --- a/bt5/erp5_payroll/bt/change_log +++ b/bt5/erp5_payroll/bt/change_log @@ -1,3 +1,6 @@ +2006-10-27 Kevin +* Calculate yearly sums. + 2006-10-26 Kevin * Accounting of paysheets addendum. * Show pay sheet line comments on PDF. diff --git a/bt5/erp5_payroll/bt/revision b/bt5/erp5_payroll/bt/revision index 00c98bb3ad..b854a29217 100644 --- a/bt5/erp5_payroll/bt/revision +++ b/bt5/erp5_payroll/bt/revision @@ -1 +1 @@ -125 \ No newline at end of file +128 \ No newline at end of file diff --git a/bt5/erp5_payroll/bt/version b/bt5/erp5_payroll/bt/version index d156ab4660..f8112ebd44 100644 --- a/bt5/erp5_payroll/bt/version +++ b/bt5/erp5_payroll/bt/version @@ -1 +1 @@ -0.2.10 \ No newline at end of file +0.2.11 \ No newline at end of file -- 2.30.9