Commit 82198163 authored by Sven Franck's avatar Sven Franck

erp5_payroll: use corporate identity for Payslip report

parent 7ac1453e
"""
================================================================================
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>
"""
================================================================================
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 @@
</item>
<item>
<key> <string>action</string> </key>
<value> <string>PaySheet_printAsODT</string> </value>
<value> <string>PaySheetTransaction_printPayslipReport</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -124,6 +124,10 @@
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</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