Commit 94c62357 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_payroll_l10n_fr: add the DSN End of Contract Report

parent dcec9f2d
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>generate_report</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>Modify portal content</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>5.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Generate DSN Report</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DSNEndOfContractReport_makeReport</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_print</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_print</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>print</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Print DSN report</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DSNReport_printAsFile</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DSNEndOfContractReport_view</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>view_editor</string> </value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>2.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Edit</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/DSNReport_viewEditor</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,6 +10,7 @@
</portal_type>
<portal_type id="Social Declaration Report Module">
<item>DSN Early Recovery Report</item>
<item>DSN End Of Contract Report</item>
<item>DSN Monthly Report</item>
</portal_type>
</allowed_content_type_list>
\ No newline at end of file
......@@ -5,6 +5,9 @@
<portal_type id="DSN Early Recovery Report">
<item>source_administration</item>
</portal_type>
<portal_type id="DSN End Of Contract Report">
<item>source_administration</item>
</portal_type>
<portal_type id="DSN Monthly Report">
<item>source_administration</item>
<item>source_section</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Base Type" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>content_icon</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>factory</string> </key>
<value> <string>addXMLObject</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DSN End Of Contract Report</string> </value>
</item>
<item>
<key> <string>init_script</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Base Type</string> </value>
</item>
<item>
<key> <string>type_class</string> </key>
<value> <string>TextDocument</string> </value>
</item>
<item>
<key> <string>type_interface</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>type_mixin</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
portal = context.getPortalObject()
portal_categories = context.portal_categories
rubric_value_dict = {}
france_territory_code = ('FR' ,'GP', 'BL', 'MF', 'MQ', 'GF', 'RE', 'PM', 'YT', 'WF', 'PF', 'NC', 'MC')
def getCountryCode(target):
region = portal_categories.getCategoryValue(target.getDefaultAddressRegion(), base_category="region")
if region is None:
raise ValueError("Country should be defined in address field of %s" % target.getRelativeUrl())
codification = region.getCodification()
if codification is None:
raise ValueError("Region %s doesn't have codification" % region.getRelativeUrl())
return codification
def formatDate(datetime):
return "%02d%02d%04d" % (datetime.day(), datetime.month(), datetime.year())
def formatFloat(number):
return "{:.2f}".format(float(number))
# Declaration
if block_id == 'S20.G00.05':
now = DateTime()
rubric_value_dict['S20.G00.05.001'] = '02' # End of Contract DSN
rubric_value_dict['S20.G00.05.002'] = '01' # Normal Declaration
rubric_value_dict['S20.G00.05.003'] = '11'
rubric_value_dict['S20.G00.05.004'] = kw['order'] # Declaration.Ordre, incremented for each DSN
rubric_value_dict['S20.G00.05.006'] = ''
rubric_value_dict['S20.G00.05.007'] = formatDate(DateTime(now.year(), now.month(), now.day()))
rubric_value_dict['S20.G00.05.009'] = ''
rubric_value_dict['S20.G00.05.010'] = '01'
elif block_id == 'S21.G00.40':
item = target.getAggregateValue()
rubric_value_dict["S21.G00.40.001"] = formatDate(item.getCareerStartDate())
rubric_value_dict["S21.G00.40.009"] = '00000'
rubric_value_dict["S21.G00.40.019"] = target.getSubordinationValue().getCorporateRegistrationCode().replace(' ','')
rubric_value_dict["S21.G00.40.026"] = enrollment_record.getCivilServantStatus()
return rubric_value_dict
<?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>block_id=None, target=None, enrollment_record=None, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DSNEndOfContractReport_getDataDict</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.DateUtils import getNumberOfDayInMonth
def getLastDateOfMonth(date):
return DateTime(date.year(), date.month(), getNumberOfDayInMonth(date))
if context.getSourceAdministration() is None:
return context.REQUEST.response.redirect("%s?portal_status_message=%s" % (context.absolute_url(), "DSN can't be built if some fields are empty"))
portal = context.getPortalObject()
getDSNBlockDict = context.DSNMonthlyReport_getDataDict
getEventDSNBlockDict = context.DSNEarlyRecoveryReport_getDataDict
# Get all paysheets for requested month
related_accounting_transaction_list = context.getAggregateRelatedValueList()
paysheet_list = sorted([transaction for transaction in related_accounting_transaction_list
if transaction.getPortalType() == "Pay Sheet Transaction"], key=lambda x: x.getTitle()) # Sorting for idempotent result in tests
if len(paysheet_list) != 1:
return context.Base_redirect(message='Exactly one paysheet should be declared')
# Retrieve related documents
paysheet = paysheet_list[0]
employee = paysheet.getSourceSectionValue()
career = employee.getDefaultCareerValue()
establishment = career.getSubordinationValue()
organisation = career.getDestinationValue()
disenrollment_record = employee.Person_getCareerRecord('DSN Disenrollment Record')
enrollment_record = employee.Person_getCareerRecord('DSN Enrollment Record')
# Set up variables needed for the DSN Report
dsn_file = []
nb_dsn = 1
organisation_contact = context.getSourceAdministrationValue()
dsn_order = portal.portal_ids.generateNewId(
id_generator='continuous_integer_increasing',
id_group='dsn_event_counter'
)
# Compute values related to the declaration
paysheet_data_dict = paysheet.PaySheetTransaction_getSocialContributionDict()
collective_contract_list = getDSNBlockDict(block_id='S21.G00.15')
# DSN HEADERS
dsn_file.append(getDSNBlockDict(block_id='S10.G00.00'))
dsn_file.append(getDSNBlockDict(block_id='S10.G00.01', target=organisation))
dsn_file.append(getDSNBlockDict(block_id='S10.G00.02', target=organisation_contact))
# DSN End Of Contract Report's Body
dsn_file.append(context.DSNEndOfContractReport_getDataDict(
block_id='S20.G00.05', order=dsn_order
))
dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.06', target=organisation))
dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.11', target=establishment))
for collective_contract in collective_contract_list:
if collective_contract['S21.G00.15.005'] in set([x[1] for x in paysheet_data_dict['taxable_base']]):
dsn_file.append({key: value for key, value in collective_contract.items() if key != 'S21.G00.15.004'})
dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.30', target=employee))
dsn_file.append(
context.DSNEndOfContractReport_getDataDict(
block_id='S21.G00.40', target=employee.getDefaultCareerValue(), enrollment_record=enrollment_record
)
)
dsn_file.append(getDSNBlockDict("S21.G00.62", enrollment_record=enrollment_record, disenrollment_record=disenrollment_record))
dsn_file.append(getDSNBlockDict("S21.G00.63", enrollment_record=enrollment_record, disenrollment_record=disenrollment_record))
dsn_file.append(getDSNBlockDict(block_id='S21.G00.71', enrollment_record=enrollment_record))
dsn_file.append(getDSNBlockDict(block_id='S21.G00.50',
date=getLastDateOfMonth(paysheet.getStopDate()),
net_salary=paysheet_data_dict['net_salary'],
net_taxable_salary=paysheet_data_dict['net_taxable_salary']))
for remuneration_block in paysheet_data_dict['remuneration']:
if 'S21.G00.51.011' in remuneration_block and remuneration_block['S21.G00.51.011'] not in ('001', '002'):
continue
dsn_file.append(remuneration_block)
for bonus_category in paysheet_data_dict['other_bonus'].itervalues():
dsn_file.append(getDSNBlockDict(block_id='S21.G00.52', target=bonus_category))
for bonus_category in paysheet_data_dict['other_income'].itervalues():
dsn_file.append(getDSNBlockDict(block_id='S21.G00.54', target=bonus_category))
# Print DSN Record
rubric_counter = 0
dsn_report_string = ""
# NORMAL MODE
for block in dsn_file:
for rubric in sorted(block):
if block[rubric]:
rubric_counter += 1
dsn_report_string += "%s,'%s'\n" % (rubric, block[rubric])
# Footer block
footer = getDSNBlockDict(block_id='S90.G00.90', length=rubric_counter, dsn_record_counter=nb_dsn)
for rubric in sorted(footer.keys()):
dsn_report_string += "%s,'%s'\n" % (rubric, footer[rubric])
context.setTextContent(dsn_report_string.strip())
if batch_mode:
# Set charset for response
context.REQUEST.response.setHeader("Content-Type", "text/plain; charset=iso-8859-1")
return
context.REQUEST.response.redirect("%s?portal_status_message=%s" % (context.absolute_url(), "Monthly DSN Record Created."))
<?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>batch_mode=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DSNEndOfContractReport_makeReport</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>my_aggregate_related_title_list</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list>
<string>my_description</string>
</list>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_title</string>
<string>my_source_administration_title</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list>
<string>my_translated_simulation_state_title</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>DSNEndOfContractReport_view</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>DSNMonthlyReport_view</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>DSN Early Recovery Report</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<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>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>columns</string>
<string>list_method</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_aggregate_related_title_list</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>columns</string> </key>
<value>
<list>
<tuple>
<string>portal_type</string>
<string>Type</string>
</tuple>
<tuple>
<string>title</string>
<string>Title</string>
</tuple>
<tuple>
<string>source_section_title</string>
<string>Employee</string>
</tuple>
<tuple>
<string>start_date</string>
<string>Work Period Start</string>
</tuple>
<tuple>
<string>stop_date</string>
<string>Work Period Stop</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_listbox</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPayrollFieldLibrary</string> </value>
</item>
<item>
<key> <string>list_method</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Accounting Transactions</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Method" module="Products.Formulator.MethodField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>method_name</string> </key>
<value> <string>getAggregateRelatedValueList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_description</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_description</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPayrollFieldLibrary</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>base_category</string>
<string>catalog_index</string>
<string>portal_type</string>
<string>title</string>
</list>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_source_administration_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>base_category</string> </key>
<value> <string>source_administration</string> </value>
</item>
<item>
<key> <string>catalog_index</string> </key>
<value> <string>title</string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_relation_field</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPayrollFieldLibrary</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value>
<list>
<tuple>
<string>Person</string>
<string>Person</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Contact</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_title</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPayrollFieldLibrary</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ProxyField" module="Products.ERP5Form.ProxyField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>delegated_list</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>my_translated_simulation_state_title</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>field_id</string> </key>
<value> <string>my_view_mode_translated_workflow_state_title</string> </value>
</item>
<item>
<key> <string>form_id</string> </key>
<value> <string>Base_viewPayrollFieldLibrary</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -110,7 +110,7 @@ if block_id == 'S21.G00.06':
return ''
def calculateManPower():
manpower_dict = {}
social_declaration_module = portal.getDefaultModule("DSN Monthly Report")
social_declaration_module = portal.social_declaration_report_module
report_list = social_declaration_module.searchFolder(
portal_type="DSN Monthly Report",
effective_date=str(context.getEffectiveDate().year()),
......@@ -274,7 +274,7 @@ if block_id == 'S21.G00.40':
rubric_value_dict["S21.G00.40.008"] = enrollment_record.getSpecialContractType()
rubric_value_dict["S21.G00.40.009"] = '00000'
rubric_value_dict["S21.G00.40.010"] = ('' if enrollment_record.getContractType() not in ('02', '29') else formatDate(enrollment_record.getCareerStopDate()))
if enrollment_record.getCareerStopDate() and enrollment_record.getCareerStopDate() <= context.getEffectiveDate():
if enrollment_record.getCareerStopDate() and enrollment_record.getCareerStopDate() <= getLastDateOfMonth(context.getEffectiveDate()):
rubric_value_dict["S21.G00.40.010"] = formatDate(enrollment_record.getCareerStopDate())
rubric_value_dict["S21.G00.40.011"] = enrollment_record.getWorkingUnitType()
rubric_value_dict["S21.G00.40.012"] = formatFloat(enrollment_record.getStandardWorkingUnit())
......@@ -319,7 +319,7 @@ if block_id == 'S21.G00.44':
# Versement Individu
if block_id == 'S21.G00.50':
# target is a paysheet
rubric_value_dict['S21.G00.50.001'] = formatDate(context.getEffectiveDate())
rubric_value_dict['S21.G00.50.001'] = formatDate(context.getEffectiveDate() or kw.get('date', None))
rubric_value_dict['S21.G00.50.002'] = formatFloat(kw['net_taxable_salary'])
rubric_value_dict['S21.G00.50.003'] = ''
rubric_value_dict['S21.G00.50.004'] = formatFloat(kw['net_salary'])
......@@ -360,7 +360,6 @@ if block_id == 'S21.G00.62':
rubric_value_dict['S21.G00.62.001'] = formatDate(enrollment_record.getCareerStopDate())
if enrollment_record.getContractType() == '29':
rubric_value_dict['S21.G00.62.002'] = '999'
# TODO : currently only works for end of training periods
else:
disenrollment_record = kw['disenrollment_record']
rubric_value_dict['S21.G00.62.002'] = '059'
......@@ -371,6 +370,10 @@ if block_id == 'S21.G00.62':
if block_id == 'S21.G00.63':
disenrollment_record = kw['disenrollment_record']
rubric_value_dict['S21.G00.63.001'] = disenrollment_record.getNoticeType()
# notified leave
if disenrollment_record.getNoticeType() == '60':
rubric_value_dict['S21.G00.63.001'] = formatDate(disenrollment_record.getNotificationDate())
rubric_value_dict['S21.G00.63.001'] = formatDate(enrollment_record.getContractStopDate())
# Autre suspension du contrat
if block_id == 'S21.G00.65':
......
......@@ -62,6 +62,7 @@ else:
if bank_account.getValidationState() == 'validated']
leave_period_dict = context.DSNMonthlyReport_getLeavePeriodDict(bank_account)
employee_list = []
leaving_employee_list = []
# DSN HEADERS
dsn_type = ('01' if len(paysheet_list) else '02')
......@@ -70,7 +71,7 @@ dsn_file.append(getDSNBlockDict(block_id='S10.G00.01', target=organisation))
dsn_file.append(getDSNBlockDict(block_id='S10.G00.02', target=organisation_contact))
# Monthly DSN
dsn_file.append(getDSNBlockDict(block_id='S20.G00.05', year=declared_year, month=declared_month, order=nb_dsn, type=dsn_type))
dsn_file.append(getDSNBlockDict(block_id='S20.G00.05', year=declared_year, month=declared_month, order=nb_dsn, type='01'))
dsn_file.append(getDSNBlockDict(block_id='S21.G00.06', target=organisation))
......@@ -244,9 +245,10 @@ for employee_data_dict, paysheet_data_dict in employee_result_list:
if enrollment_record.getCareerStopDate() != None and \
first_date_of_month <= enrollment_record.getCareerStopDate() <= last_date_of_month:
if enrollment_record.getContractType() != '29':
disenrollment_record = employee.Person_getCareerRecord('DSN Disenrollment Record')
leaving_employee_list.append(employee)
disenrollment_record = portal.restrictedTraverse(employee).Person_getCareerRecord('DSN Disenrollment Record')
dsn_file.append({rubric: value
for rubric, value in getDSNBlockDict("S21.G00.62", enrollment_record=enrollment_record, disenrollment_record=disenrollment_record)
for rubric, value in getDSNBlockDict("S21.G00.62", enrollment_record=enrollment_record, disenrollment_record=disenrollment_record).items()
if rubric in ('S21.G00.62.001',
'S21.G00.62.002',
'S21.G00.62.006',
......@@ -341,7 +343,7 @@ if len(leave_period_dict):
id_generator='continuous_integer_increasing',
id_group='dsn_event_counter')
employee = portal.restrictedTraverse(employee)
dsn_file.append(getEventDSNBlockDict(block_id='S20.G00.05', dsn_type='04', order=dsn_order)) #'04' is DSN Leave Event
dsn_file.append(getEventDSNBlockDict(block_id='S20.G00.05', dsn_type='04', order=dsn_order))
dsn_file.append(getEventDSNBlockDict(block_id='S20.G00.07', target=organisation_contact))
dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.06', target=organisation))
dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.11', target=establishment))
......@@ -349,6 +351,53 @@ if len(leave_period_dict):
dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.40', target=employee.getDefaultCareerValue()))
dsn_file.append(period)
# Add end of contract event DSN if needed
# Usually we don't merge the monthly DSN with the End of Contract DSN,
# but if we need the code is below :
#for employee in leaving_employee_list:
# nb_dsn += 1
# employee = portal.restrictedTraverse(employee)
# dsn_order = portal.portal_ids.generateNewId(
# id_generator='continuous_integer_increasing',
# id_group='dsn_event_counter')
# disenrollment_record = employee.Person_getCareerRecord('DSN Disenrollment Record')
# enrollment_record = employee.Person_getCareerRecord('DSN Enrollment Record')
# for employee_data_dict, paysheet_data_dict in employee_result_list:
# if employee_data_dict['person_relative_url'] == employee.getRelativeUrl():
# break
# dsn_file.append(context.DSNEndOfContractReport_getDataDict(
# block_id='S20.G00.05', order=dsn_order
# ))
# dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.06', target=organisation))
# dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.11', target=establishment))
# for collective_contract in collective_contract_list:
# if collective_contract['S21.G00.15.005'] in set([x[1] for x in paysheet_data_dict['taxable_base']]):
# dsn_file.append({key: value for key, value in collective_contract.items() if key != 'S21.G00.15.004'})
# dsn_file.append(getEventDSNBlockDict(block_id='S21.G00.30', target=employee))
# dsn_file.append(
# context.DSNEndOfContractReport_getDataDict(
# block_id='S21.G00.40', target=employee.getDefaultCareerValue(), enrollment_record=enrollment_record
# )
# )
# dsn_file.append(getDSNBlockDict("S21.G00.62", enrollment_record=enrollment_record, disenrollment_record=disenrollment_record))
# dsn_file.append(getDSNBlockDict("S21.G00.63", enrollment_record=enrollment_record, disenrollment_record=disenrollment_record))
# dsn_file.append(getDSNBlockDict(block_id='S21.G00.71', enrollment_record=enrollment_record))
# dsn_file.append(getDSNBlockDict(block_id='S21.G00.50',
# net_salary=paysheet_data_dict['net_salary'],
# net_taxable_salary=paysheet_data_dict['net_taxable_salary']))
# for remuneration_block in paysheet_data_dict['remuneration']:
# if 'S21.G00.51.011' in remuneration_block and remuneration_block['S21.G00.51.011'] not in ('001', '002'):
# continue
# dsn_file.append(remuneration_block)
# for bonus_category in paysheet_data_dict['other_bonus'].itervalues():
# dsn_file.append(getDSNBlockDict(block_id='S21.G00.52', target=bonus_category))
#
# for bonus_category in paysheet_data_dict['other_income'].itervalues():
# dsn_file.append(getDSNBlockDict(block_id='S21.G00.54', target=bonus_category))
# Print DSN Record
last_block = ''
rubric_counter = 0
......
erp5_calendar
erp5_payroll
erp5_payroll
\ No newline at end of file
......@@ -4,6 +4,10 @@ DSN Early Recovery Report | generate_report
DSN Early Recovery Report | print
DSN Early Recovery Report | view
DSN Early Recovery Report | view_editor
DSN End Of Contract Report | generate_report
DSN End Of Contract Report | print
DSN End Of Contract Report | view
DSN End Of Contract Report | view_editor
DSN Enrollment Record | view
DSN Monthly Report | create_replacement
DSN Monthly Report | generate_report
......
......@@ -2,4 +2,5 @@ DSN Monthly Report | DSN Change Block
Payroll Disenrollment Record Module | DSN Disenrollment Record
Payroll Enrollment Record Module | DSN Enrollment Record
Social Declaration Report Module | DSN Early Recovery Report
Social Declaration Report Module | DSN End Of Contract Report
Social Declaration Report Module | DSN Monthly Report
\ No newline at end of file
DSN Change Block | use
DSN Early Recovery Report | source_administration
DSN End Of Contract Report | source_administration
DSN Monthly Report | source_administration
DSN Monthly Report | source_section
DSN Monthly Report | source_trade
\ No newline at end of file
DSN Change Block
DSN Disenrollment Record
DSN Early Recovery Report
DSN End Of Contract Report
DSN Enrollment Record
DSN Monthly Report
\ 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