Commit ec835d86 authored by Jérome Perrin's avatar Jérome Perrin

payroll_l10n_fr: add missing sorts in DSN report

When producing DSN report, there was a few places where we depended on
dict iteration order, so the test did not pass when running with
PYTHONHASHSEED (erp5_payroll_l10n_fr:testDSNSocialDeclarationReport
fails with PYTHONHASHSEED 323). In these changes we add sorts to some
places where we were iterating on dicts so that the order of the Lines
is deterministic even with hash randomization enabled.
Co-authored-by: Nicolas Wavrant's avatarNicolas Wavrant <nicolas.wavrant@nexedi.com>
parent 228174da
......@@ -50,7 +50,7 @@ leave_period_type_set = set(portal_categories.use.social_declaration.l10n.fr.lea
# Create dict containing a DSN leave blocs, grouped by employee
leave_dict = {}
for period in leave_period_list:
for period in sorted(leave_period_list, key=lambda lp: lp.getCreationDate()):
# some leave periods don't have to be reported in DSN
period_resource = period.getResourceValue()
assert period_resource is not None, 'No type set on Leave Request %s' % period.absolute_url()
......
......@@ -173,7 +173,7 @@ if len(payment_transaction_list):
start_date=social_contribution_start_date,
stop_date=social_contribution_stop_date,
amount=amount))
for ctp_code in aggregated_social_contribution_dict:
for ctp_code in sorted(aggregated_social_contribution_dict):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.23',
target=aggregated_social_contribution_dict[ctp_code]))
else:
......@@ -206,7 +206,7 @@ elif len(paysheet_list):
start_date=first_date_of_month,
stop_date=last_date_of_month,
amount=amount))
for ctp_code in aggregated_social_contribution_dict:
for ctp_code in sorted(aggregated_social_contribution_dict):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.23',
target=aggregated_social_contribution_dict[ctp_code]))
......@@ -228,12 +228,12 @@ for employee_data_dict, paysheet_data_dict in employee_result_list:
contract_change_block_list = []
if employee in change_block_dict:
for rubric_root, change_date_block in six.iteritems(change_block_dict[employee]):
for rubric_root, change_date_block in sorted(six.iteritems(change_block_dict[employee])):
if rubric_root == 'S21.G00.31':
for date, change_block in six.iteritems(change_date_block):
for date, change_block in sorted(six.iteritems(change_date_block)):
dsn_file.append(getDSNBlockDict(block_id=rubric_root, change_block=change_block, change_date=date))
elif rubric_root == 'S21.G00.41':
for date, change_block in six.iteritems(change_date_block):
for date, change_block in sorted(six.iteritems(change_date_block)):
contract_change_block_list.append(getDSNBlockDict(block_id=rubric_root, change_block=change_block, change_date=date))
employee_data_dict['contract']['S21.G00.40.019'] = establishment_registration_code
......@@ -241,7 +241,7 @@ for employee_data_dict, paysheet_data_dict in employee_result_list:
dsn_file.extend(contract_change_block_list)
if employee in leave_period_dict:
for leave_period in leave_period_dict[employee]:
for leave_period in sorted(leave_period_dict[employee]):
leave_block = {rubric: leave_period.get(rubric, None)
for rubric in ('S21.G00.60.001',
'S21.G00.60.002',
......@@ -257,7 +257,7 @@ for employee_data_dict, paysheet_data_dict in employee_result_list:
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).items()
for rubric, value in sorted(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',
......@@ -270,7 +270,7 @@ for employee_data_dict, paysheet_data_dict in employee_result_list:
# which are of the form : (contribution_category, contract_id)
insurance_contract_id_list = set([x[1] for x in paysheet_data_dict['taxable_base']])
for insurance_contract_id in insurance_contract_id_list:
for insurance_contract_id in sorted(insurance_contract_id_list):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.70',
enrollment_record=enrollment_record,
contract_id=insurance_contract_id))
......@@ -284,13 +284,13 @@ for employee_data_dict, paysheet_data_dict in employee_result_list:
for remuneration_block in paysheet_data_dict['remuneration']:
dsn_file.append(remuneration_block)
for bonus_category in six.itervalues(paysheet_data_dict['other_bonus']):
for bonus_category in sorted(six.itervalues(paysheet_data_dict['other_bonus'])):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.52', target=bonus_category))
for bonus_category in six.itervalues(paysheet_data_dict['other_income']):
for bonus_category in sorted(six.itervalues(paysheet_data_dict['other_income'])):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.54', target=bonus_category))
for taxable_base_category in six.itervalues(paysheet_data_dict['taxable_base']):
for taxable_base_category in sorted(six.itervalues(paysheet_data_dict['taxable_base'])):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.78', target=taxable_base_category))
if taxable_base_category['code'] == '02': # Assiette Brute plafonnee
if ('063', '') in paysheet_data_dict['individual_contribution']:
......@@ -324,21 +324,21 @@ for employee_data_dict, paysheet_data_dict in employee_result_list:
dsn_file.append(getDSNBlockDict(block_id='S21.G00.81', target=paysheet_data_dict['individual_contribution'][('059', taxable_base_category['contract_id'])]))
del paysheet_data_dict['individual_contribution'][('059', taxable_base_category['contract_id'])]
for taxable_base_component_category in six.itervalues(paysheet_data_dict['taxable_base_component']):
for taxable_base_component_category in sorted(six.itervalues(paysheet_data_dict['taxable_base_component'])):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.79', target=taxable_base_component_category))
if ('03', '') in taxable_base_component_category:
dsn_file.append(getDSNBlockDict(block_id='S21.G00.81', target=paysheet_data_dict['individual_contribution'][('064', '')]))
del paysheet_data_dict['individual_contribution'][('064', '')]
for individual_contribution_category in six.itervalues(paysheet_data_dict['individual_contribution']):
for individual_contribution_category in sorted(six.itervalues(paysheet_data_dict['individual_contribution'])):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.81', target=individual_contribution_category))
dsn_file.append(employee_data_dict['seniority'])
# Add leave event DSN if needed
if len(leave_period_dict):
for employee in leave_period_dict:
for period in leave_period_dict[employee]:
for employee in sorted(leave_period_dict):
for period in sorted(leave_period_dict[employee]):
#leave_date_as_string = period['S21.G00.60.002']
#year = int(leave_date_as_string[4:])
#month = int(leave_date_as_string[2:4])
......
......@@ -85,39 +85,39 @@ S21.G00.22.002,'44004750400020'
S21.G00.22.003,'01012015'
S21.G00.22.004,'31012015'
S21.G00.22.005,'5158.42'
S21.G00.23.001,'260'
S21.G00.23.002,'920'
S21.G00.23.004,'10278.00'
S21.G00.23.001,'479'
S21.G00.23.002,'920'
S21.G00.23.004,'275.00'
S21.G00.23.001,'772'
S21.G00.23.002,'920'
S21.G00.23.004,'9163.00'
S21.G00.23.001,'100'
S21.G00.23.002,'920'
S21.G00.23.003,'1.10'
S21.G00.23.004,'9163.00'
S21.G00.23.001,'100'
S21.G00.23.002,'921'
S21.G00.23.004,'8505.00'
S21.G00.23.001,'260'
S21.G00.23.002,'920'
S21.G00.23.004,'10278.00'
S21.G00.23.001,'332'
S21.G00.23.002,'921'
S21.G00.23.004,'8505.00'
S21.G00.23.001,'900'
S21.G00.23.001,'400'
S21.G00.23.002,'920'
S21.G00.23.003,'2.00'
S21.G00.23.004,'9163.00'
S21.G00.23.006,'59378'
S21.G00.23.004,'5335.00'
S21.G00.23.001,'430'
S21.G00.23.002,'920'
S21.G00.23.004,'6913.00'
S21.G00.23.001,'400'
S21.G00.23.001,'479'
S21.G00.23.002,'920'
S21.G00.23.004,'5335.00'
S21.G00.23.004,'275.00'
S21.G00.23.001,'671'
S21.G00.23.002,'921'
S21.G00.23.005,'32.00'
S21.G00.23.001,'100'
S21.G00.23.002,'921'
S21.G00.23.004,'8505.00'
S21.G00.23.001,'772'
S21.G00.23.002,'920'
S21.G00.23.004,'9163.00'
S21.G00.23.001,'900'
S21.G00.23.002,'920'
S21.G00.23.003,'2.00'
S21.G00.23.004,'9163.00'
S21.G00.23.006,'59378'
S21.G00.30.001,'1930259017323'
S21.G00.30.002,'Beginner'
S21.G00.30.004,'Usertest'
......@@ -197,20 +197,14 @@ S21.G00.51.002,'31012015'
S21.G00.51.010,'00000'
S21.G00.51.011,'010'
S21.G00.51.013,'2250.00'
S21.G00.54.001,'18'
S21.G00.54.002,'23.00'
S21.G00.54.003,'01012015'
S21.G00.54.004,'31012015'
S21.G00.54.001,'17'
S21.G00.54.002,'100.80'
S21.G00.54.003,'01012015'
S21.G00.54.004,'31012015'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'2250.00'
S21.G00.81.001,'063'
S21.G00.81.004,'219.38'
S21.G00.54.001,'18'
S21.G00.54.002,'23.00'
S21.G00.54.003,'01012015'
S21.G00.54.004,'31012015'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -220,27 +214,16 @@ S21.G00.79.001,'20'
S21.G00.79.004,'97.16'
S21.G00.81.001,'059'
S21.G00.81.004,'97.16'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'0.00'
S21.G00.78.005,'2'
S21.G00.79.001,'11'
S21.G00.79.004,'2250.00'
S21.G00.81.001,'059'
S21.G00.81.004,'15.75'
S21.G00.78.001,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'2305.53'
S21.G00.78.001,'13'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'94.91'
S21.G00.78.001,'07'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'2250.00'
S21.G00.81.001,'063'
S21.G00.81.004,'219.38'
S21.G00.78.001,'03'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -253,6 +236,23 @@ S21.G00.81.001,'226'
S21.G00.81.002,'75367340900011'
S21.G00.81.003,'2250.00'
S21.G00.81.005,'59378'
S21.G00.78.001,'07'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'2250.00'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'0.00'
S21.G00.78.005,'2'
S21.G00.79.001,'11'
S21.G00.79.004,'2250.00'
S21.G00.81.001,'059'
S21.G00.81.004,'15.75'
S21.G00.78.001,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'2305.53'
S21.G00.81.001,'018'
S21.G00.81.002,'75367340900011'
S21.G00.81.003,'2250.00'
......@@ -335,12 +335,6 @@ S21.G00.54.001,'17'
S21.G00.54.002,'62.40'
S21.G00.54.003,'01012015'
S21.G00.54.004,'31012015'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3085.28'
S21.G00.81.001,'063'
S21.G00.81.004,'300.81'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -350,27 +344,16 @@ S21.G00.79.001,'20'
S21.G00.79.004,'97.16'
S21.G00.81.001,'059'
S21.G00.81.004,'97.16'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'0.00'
S21.G00.78.005,'2'
S21.G00.79.001,'11'
S21.G00.79.004,'3085.28'
S21.G00.81.001,'059'
S21.G00.81.004,'21.60'
S21.G00.78.001,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'4125.36'
S21.G00.78.001,'13'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'94.07'
S21.G00.78.001,'07'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3085.28'
S21.G00.81.001,'063'
S21.G00.81.004,'300.81'
S21.G00.78.001,'03'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -381,6 +364,23 @@ S21.G00.81.001,'226'
S21.G00.81.002,'75367340900011'
S21.G00.81.003,'3085.28'
S21.G00.81.005,'59378'
S21.G00.78.001,'07'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3085.28'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'0.00'
S21.G00.78.005,'2'
S21.G00.79.001,'11'
S21.G00.79.004,'3085.28'
S21.G00.81.001,'059'
S21.G00.81.004,'21.60'
S21.G00.78.001,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'4125.36'
S21.G00.86.001,'01'
S21.G00.86.002,'02'
S21.G00.86.003,'11'
......@@ -459,12 +459,6 @@ S21.G00.54.001,'17'
S21.G00.54.002,'67.20'
S21.G00.54.003,'01012015'
S21.G00.54.004,'31012015'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3170.00'
S21.G00.81.001,'063'
S21.G00.81.004,'323.55'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -474,6 +468,16 @@ S21.G00.79.001,'20'
S21.G00.79.004,'97.16'
S21.G00.81.001,'059'
S21.G00.81.004,'97.16'
S21.G00.78.001,'13'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'86.36'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3170.00'
S21.G00.81.001,'063'
S21.G00.81.004,'323.55'
S21.G00.78.001,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -485,18 +489,6 @@ S21.G00.79.001,'13'
S21.G00.79.004,'657.86'
S21.G00.81.001,'059'
S21.G00.81.004,'29.29'
S21.G00.78.001,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3847.23'
S21.G00.78.001,'13'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'86.36'
S21.G00.78.001,'07'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3827.86'
S21.G00.78.001,'03'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -507,6 +499,14 @@ S21.G00.81.001,'226'
S21.G00.81.002,'75367340900011'
S21.G00.81.003,'3827.86'
S21.G00.81.005,'59378'
S21.G00.78.001,'07'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3827.86'
S21.G00.78.001,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3847.23'
S21.G00.86.001,'01'
S21.G00.86.002,'02'
S21.G00.86.003,'11'
......
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