Commit a5246bcf authored by Sven Franck's avatar Sven Franck Committed by Xiaowu Zhang

erp5_payroll: use corporate identity for Payslip report

parent 94053d30
"""
================================================================================
Create the actual report and return parameters for the report header
================================================================================
"""
# parameters
# ------------------------------------------------------------------------------
#
def translateText(snip):
return rep_localiser.erp5_ui.gettext(snip, lang=rep_language).encode('utf-8').strip()
rep = context
rep_language = rep.getLanguage() if getattr(rep, 'getLanguage', None) else None
rep_localiser = rep.getPortalObject().Localizer
rep_data_source_caller = None
rep_start_date = kwargs.get('start_date', None)
rep_stop_date = kwargs.get('stop_date', None)
rep_title = kwargs.get('report_title')
# bridge for filling in testdata and setting exported title to bogus dates
if kwargs.get('override_batch_mode'):
rep_data_source_caller = getattr(context, "PaySheetTransaction_getPayslipTestData", None)
rep_start_date = DateTime("1976-11-04")
rep_stop_date = DateTime("1976-11-30")
if rep_data_source_caller is None:
rep_data_source_caller = getattr(context, "PaySheetTransaction_getPayslipTestData")
rep_start_date = rep_start_date or context.Base_getFirstAndLastDayOfMonth(day="first")
rep_stop_date = rep_stop_date or context.Base_getFirstAndLastDayOfMonth(day="last")
kwargs["report_data"] = rep_data_source_caller(start_date=rep_start_date,stop_date=rep_stop_date)
rep_content = context.Person_generatePayslipReportContent(*args, **kwargs)
if isinstance(rep_content, unicode):
rep_content = rep_content.encode("utf8")
return rep_content, rep_title, ' '.join([
translateText("from").title(),
rep_start_date.strftime('%Y/%m/%d'),
translateText("to"),
rep_stop_date.strftime('%Y/%m/%d')
])
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>*args, **kwargs</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_generatePayslipReport</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<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_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_generatePayslipReportContent</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<tal:comment replace="nothing">
<!-- """
================================================================================
Generates payslip report for a person
================================================================================
"""
# paramters
# ------------------------------------------------------------------------------
# language document language to translate headers
# display_report whether this is a standalone or embedded report
# display_sandbox wrap in iframe if multiple gantts on page
# display_embedded called internally to create embedded chart
# report_title title to display ("Budget" used instead)
#
-->
</tal:comment>
<tal:block tal:define="global documen_language python: options.get('document_language');
global sandbox python: options.get('display_sandbox') or 0;
global embedded python: options.get('display_embedded') or 0;
global display_report python: options.get('display_report') or 0;
global display_detail python: options.get('display_detail');
global display_header python: options.get('display_header');
global display_depth python: options.get('display_depth');">
<tal:comment replace="nothing"><!-- sandboxed call - when integrated into another document (drop irrelevant params) --></tal:comment>
<tal:block tal:condition="python: sandbox">
<iframe width="100%" style="border:0 none; background-color:#FFFFFF;box-sizing:border-box;-wekbit-box-sizing:border-box;"
tal:attributes="src python: '%s/WebPage_viewAsWeb?portal_skin=Report&amp;document_language=%s&amp;report_name=PaySheetTransaction_generatePayslipReport&amp;display_embedded=1&amp;display_detail=%s&amp;display_header=%s&amp;display_depth=%s' % (context.absolute_url(), language, display_detail, display_header, display_depth);">
</iframe>
</tal:block>
<tal:comment replace="nothing"><!-- regular call --></tal:comment>
<tal:block tal:condition="python: (embedded and sandbox == 0) or (embedded == 0 and sandbox == 0)">
<tal:block metal:use-macro="context/PaySheetTransaction_generatePayslipReportContent/macros/report"/>
</tal:block>
</tal:block>
<tal:block tal:condition="python: False">
<tal:block metal:define-macro="report">
<tal:block tal:define="global start_date python: options.get('start_date');
global stop_date python: options.get('stop_date');
global payslip_data python: options.get('report_data');
override_display_header python: True;">
<tal:block tal:condition="python: payslip_data is not None">
<tal:block tal:condition="python: display_report">
<tal:block tal:condition="python: override_display_header is None">
<tal:block tal:replace="structure python: '<h%(headcount)d>%(title)s</h%(headcount)d>' % {'headcount': display_header, 'title': options.get('report_title')}"></tal:block>
</tal:block>
<!--div class="ci-book-report-date-wrapper">
<span i18n:translate="" i18n:domain="erp5_ui">From</span>
<span tal:content="python: start_date.strftime('%Y-%m-%d')"></span>
<span i18n:translate="" i18n:domain="erp5_ui">to</span>
<span tal:content="python: stop_date.strftime('%Y-%m-%d')"></span>
</div-->
<div class="ci-book-report-content-header-wrapper">
<table class="ci-book-table">
<tbody>
<tr>
<td style="background:#fff">
<div class="ci-book-report-content-card">
<tal:block tal:define="sender python: payslip_data['source_address_line_list'];">
<tal:block tal:repeat="address_line sender">
<tal:block tal:condition="python: address_line.get('is_header', None) is not None">
<span class="ci-book-report-emphasis" tal:content="python: address_line['value']">Nexedi Sa</span>
</tal:block>
<tal:block tal:condition="python: address_line.get('is_header', None) is None">
<span tal:content="python: address_line['value']">2 Rue unerue</span>
</tal:block>
</tal:block>
</tal:block>
</div>
<div class="ci-book-report-content-card">
<tal:block tal:define="sender_info python: payslip_data['source_corporate_info_line_list'];">
<tal:block tal:repeat="info_line sender_info">
<tal:block tal:condition="python: info_line.get('is_header', None) is not None">
<span class="ci-book-report-emphasis" tal:content="python: info_line['value']">UserTest Slicea</span>
</tal:block>
<tal:block tal:condition="python: info_line.get('is_header', None) is None">
<span tal:content="python: info_line['value']">2 Rue unerue</span>
</tal:block>
</tal:block>
</tal:block>
</div>
</td>
<td style="background:#fff">
<div class="ci-book-report-content-card">
<tal:block tal:define="recipient python: payslip_data['destination_address_line_list'];">
<tal:block tal:repeat="address_line recipient">
<tal:block tal:condition="python: address_line.get('is_header', None) is not None">
<span class="ci-book-report-emphasis ci-book-report-headline" tal:content="python: address_line['value']"></span>
</tal:block>
<tal:block tal:condition="python: address_line.get('is_header', None) is None">
<span tal:content="python: address_line['value']"></span>
</tal:block>
</tal:block>
</tal:block>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</tal:block>
<div class="ci-book-report-content-table-wrapper">
<table class="ci-book-table">
<thead>
<tr>
<th i18n:translate="" i18n:domain="erp5_ui">Designation</th>
<th i18n:translate="" i18n:domain="erp5_ui">Base</th>
<th i18n:translate="" i18n:domain="erp5_ui">Employee Share (%)</th>
<th i18n:translate="" i18n:domain="erp5_ui">Employee Share</th>
<th i18n:translate="" i18n:domain="erp5_ui">Employer Share (%)</th>
<th i18n:translate="" i18n:domain="erp5_ui">Employer Share</th>
</tr>
</thead>
<tbody>
<tal:block tal:define="section_list python: payslip_data['payslip_section_list'];">
<tal:block tal:repeat="section_info section_list">
<tal:block tal:repeat="line section_info">
<tal:block tal:define="last_class python: 'ci-book-report-table-section-end' if repeat.get('line').end is True else '';">
<tr tal:attributes="class python: last_class">
<tal:block tal:condition="python: line.get('is_header', None) is not None">
<td><b tal:content="python: line['value']"></b></td>
</tal:block>
<tal:block tal:condition="python: line.get('is_header', None) is None">
<td class="ci-book-report-cell-indent" tal:content="python: line['value']"></td>
</tal:block>
<td tal:content="python: line['value_base']"></td>
<td tal:content="python: line['value_employee_share_rate']"></td>
<td tal:content="python: line['value_employee_share']"></td>
<td tal:content="python: line['value_employer_share_rate']"></td>
<td tal:content="python: line['value_employer_share']"></td>
</tr>
</tal:block>
</tal:block>
</tal:block>
</tal:block>
</tbody>
</table>
</div>
<div class="ci-book-report-content-summary-wrapper">
<div class="ci-book-report-content-section">
<table class="ci-book-table">
<tbody>
<tr>
<td style="background:#fff">
<div class="ci-book-report-content-card">
<span><b i18n:translate="" i18n:domain="erp5_ui">Net payable</b></span><span><b tal:content="python: payslip_data['general_data_dict']['net_salary']"></b></span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="ci-book-report-content-footer-wrapper">
<div class="ci-book-report-content-section">
<table class="ci-book-table">
<tbody>
<tr>
<td style="background:#fff">
<div class="ci-book-report-content-card">
<span><b i18n:translate="" i18n:domain="erp5_ui">Contract Info</b></span>
<tal:block tal:define="hiring_info python: payslip_data['destination_hiring_info_list'];">
<tal:block tal:repeat="info_line hiring_info">
<tal:block tal:condition="python: info_line.get('is_header', None) is not None">
<span class="ci-book-report-emphasis" tal:content="python: info_line['value']"></span>
</tal:block>
<tal:block tal:condition="python: info_line.get('is_header', None) is None">
<span tal:content="python: info_line['value']"></span>
</tal:block>
</tal:block>
</tal:block>
</div>
</td>
<td style="background:#fff">
<div class="ci-book-report-content-card">
<span><b i18n:translate="" i18n:domain="erp5_ui">Attendance</b></span>
<tal:block tal:define="attendance_info python: payslip_data['destination_attendance_info_list'];">
<tal:block tal:repeat="info_line attendance_info">
<tal:block tal:condition="python: info_line.get('is_header', None) is not None">
<span class="ci-book-report-emphasis" tal:content="python: info_line['value']"></span>
</tal:block>
<tal:block tal:condition="python: info_line.get('is_header', None) is None">
<span tal:content="python: info_line['value']"></span>
</tal:block>
</tal:block>
</tal:block>
</div>
</td>
<td style="background:#fff">
<div class="ci-book-report-content-card">
<span><b i18n:translate="" i18n:domain="erp5_ui">Paid Vacation (in days)</b></span>
<tal:block tal:define="vacation_info python: payslip_data['destination_vacation_info_list'];">
<tal:block tal:repeat="info_line vacation_info">
<tal:block tal:condition="python: info_line.get('is_header', None) is not None">
<span class="ci-book-report-emphasis" tal:content="python: info_line['value']"></span>
</tal:block>
<tal:block tal:condition="python: info_line.get('is_header', None) is None">
<span tal:content="python: info_line['value']"></span>
</tal:block>
</tal:block>
</tal:block>
</div>
</td>
<td style="background:#fff">
<div class="ci-book-report-content-card">
<span><b i18n:translate="" i18n:domain="erp5_ui">Tax Info</b></span>
<tal:block tal:define="tax_info python: payslip_data['destination_taxation_info_list'];">
<tal:block tal:repeat="info_line tax_info">
<tal:block tal:condition="python: info_line.get('is_header', None) is not None">
<span class="ci-book-report-emphasis" tal:content="python: info_line['value']"></span>
</tal:block>
<tal:block tal:condition="python: info_line.get('is_header', None) is None">
<span tal:content="python: info_line['value']"></span>
</tal:block>
</tal:block>
</tal:block>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="ci-book-report-content-section">
<table class="ci-book-table">
<thead>
<tr>
<th colspan="6"><span i18n:translate="" i18n:domain="erp5_ui">Cumuls Annuels</span>&nbsp;<span>(</span><span tal:content="python: payslip_data['general_data_dict']['year']"></span><span>)</span></th>
</tr>
</thead>
<tbody>
<tal:block tal:define="cumulative_title python: payslip_data['cumulative_title_list'];
cumulative_info python: payslip_data['cumulative_info_list']">
<tr>
<tal:block tal:repeat="info_line cumulative_title">
<td><b style="font-weight:bold;" i18n:translate="" i18n:domain="erp5_ui" tal:content="python: info_line['value']"></b></td>
</tal:block>
</tr>
<tr>
<tal:block tal:repeat="info_line cumulative_info">
<td style="text-align: right;" i18n:translate="" i18n:domain="erp5_ui" tal:content="python: info_line['value']"></td>
</tal:block>
</tr>
</tal:block>
</tbody>
</table>
</div>
</div>
</tal:block>
</tal:block>
<tal:block tal:condition="python: payslip_data is None">
<h1 i18n:translate="" i18n:domain="erp5_ui" class="custom-header">XXX ERROR Payslip Report: No Paysheet data available</h1>
</tal:block>
</tal:block>
</tal:block>
\ No newline at end of file
"""
================================================================================
Get data to build a payslip report based on a person's paysheet transaction
================================================================================
"""
#
# parameters
# ------------------------------------------------------------------------------
# start_date start date of the report
# stop_date stop date of the report
#
# returns:
# {
# "general_data_dict": {
# "year": 2017,
# "net_salary": "2 300.93",
# "gross_salary": "3 085.28"
# },
# "cumulative_title_list": [
# {"value": "Gross Salary", "is_header": True},
# ...
# ],
# "cumulative_info_list":[
# {"value": "3 085.28", "is_header": True},
# ...
# ],
# 'destination_address_line_list': [
# {"value": "USERTEST Slicea", "is_header": True},
# {"value": "2 rue unerue"},
# ...
# ],
# 'destination_hiring_info_list': [
# {"value": "Hiring Date: 1990/10/10"},
# ...
# ],
# 'destination_attendance_info_list': [
# {"value": "Normal Working Hours": 151.67"},
# ...
# ]
# 'destination_vacation_info_list': [
# {"value": "Earned this period: "},
# ...
# ],
# 'destination_taxation_info_list': [
# {"value": "Price Currency: EUR"},
# ],
# 'source_address_line_list: [
# {"value": "Nexedi SA", "is_header": True},
# {"value": "147 Rue du Ballon"}
# ...
# ],
# source_corporate_info_line_list: [
# {"value": "Corporate Registration Code: 440047504 00020"},
# {"value": "Activity Code: 5829C"},
# ...
# ],
# "payslip_section_list": [
# [
# {"value": "Usertest Slicea", "is_header": True, "value_base": "", "value_employee_share_rate": "", "value_employee_share": "", "value_employer_share_rate": "", "value_employer_share": ""},
# {"value": "Salarie de Base", "value_base": "2 805.28", "value_employee_share_rate": "", "value_employee_share": "", "value_employer_share_rate": "", "value_employer_share": ""}
# ], [
# ...
# ]
# ]
#}
response = {
"general_data_dict": {
"year": "",
"net_salary": "",
"gross_salary": ""
},
"cumulative_title_list": [],
"cumulative_info_list": [],
"destination_address_line_list": [],
"destination_hiring_info_list": [],
"destination_attendance_info_list": [],
"destination_vacation_info_list": [],
"destination_taxation_info_list": [],
"source_address_line_list": [],
"source_corporate_info_line_list": [],
"payslip_section_list": []
}
return response
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>start_date=None, stop_date=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_getPayslipData</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
"""
================================================================================
Wire PaySheetTransaction through to erp5_corporate_identity Report
================================================================================
"""
# ERP5 web uses format= argument, which is also a python builtin
# pylint: disable=redefined-builtin
# parameters (* default)
# ------------------------------------------------------------------------------
# format: output in html*, pdf
# international_form translate terms
# language target_language
return context.Base_printAsReport(
format=format,
report_title="Payslip",
report_name="Person_generatePayslipReport",
language=target_language,
start_date=context.getStartDate() or None,
stop_date=context.getStopDate() or None,
**kw
)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>format=None, international_form=None, target_language=None, *args,**kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>PaySheetTransaction_printPayslipReport</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</item> </item>
<item> <item>
<key> <string>action</string> </key> <key> <string>action</string> </key>
<value> <string>PaySheet_printAsODT</string> </value> <value> <string>PaySheetTransaction_printPayslipReport</string> </value>
</item> </item>
<item> <item>
<key> <string>description</string> </key> <key> <string>description</string> </key>
...@@ -124,6 +124,10 @@ ...@@ -124,6 +124,10 @@
<key> <string>update_action</string> </key> <key> <string>update_action</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
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