Commit e6f58997 authored by Jérome Perrin's avatar Jérome Perrin Committed by Kazuhiko Shiozaki

payroll_l10n_fr: fix for DSN sorts

in ec835d86 (payroll_l10n_fr: add missing sorts in DSN report, 2024-02-28)
we added sorts so that the report is deterministic when hash randomization
is enabled, but this was not enough, when iterating through employee_ctp
to find the social_contribution_organisation, not all records have a
corporate_registration_code, so we check that it's present before
accessing it.

Also, one `sorted` that was added was incorrect, because the elements
are dict, so they can not be compared on python3.
parent 22f88a55
......@@ -116,7 +116,7 @@ social_contribution_stop_date = None
for employee_result in paysheet_data_list:
employee_ctp = employee_result['ctp']
for ctp_code in employee_ctp:
if social_contribution_organisation is None:
if social_contribution_organisation is None and 'corporate_registration_code' in employee_ctp[ctp_code]:
social_contribution_organisation = employee_ctp[ctp_code]['corporate_registration_code']
social_contribution_start_date = employee_ctp[ctp_code]['start_date']
social_contribution_stop_date = employee_ctp[ctp_code]['stop_date']
......@@ -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 sorted(six.itervalues(paysheet_data_dict['other_bonus'])):
for bonus_category in sorted(six.itervalues(paysheet_data_dict['other_bonus']), key=lambda v: (v['code'],)):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.52', target=bonus_category))
for bonus_category in sorted(six.itervalues(paysheet_data_dict['other_income'])):
for bonus_category in sorted(six.itervalues(paysheet_data_dict['other_income']), key=lambda v: (v['code'],)):
dsn_file.append(getDSNBlockDict(block_id='S21.G00.54', target=bonus_category))
for taxable_base_category in sorted(six.itervalues(paysheet_data_dict['taxable_base'])):
for taxable_base_category in sorted(six.itervalues(paysheet_data_dict['taxable_base']), key=lambda v: (v['code'], v['contract_id'],)):
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']:
......
......@@ -205,19 +205,6 @@ 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'
S21.G00.78.004,'0.00'
S21.G00.78.005,'1'
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,'94.91'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -236,10 +223,27 @@ 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,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'2305.53'
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,'13'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'94.91'
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,'1'
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'
......@@ -249,10 +253,6 @@ 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,19 +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,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'0.00'
S21.G00.78.005,'1'
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,'94.07'
S21.G00.78.001,'02'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -364,10 +351,27 @@ 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,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'4125.36'
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,'13'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'94.07'
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,'1'
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'
......@@ -377,10 +381,6 @@ 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,36 +459,12 @@ 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,'31'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'0.00'
S21.G00.78.005,'1'
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'
S21.G00.78.004,'0.00'
S21.G00.78.005,'2'
S21.G00.79.001,'11'
S21.G00.79.004,'3170.00'
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,'03'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
......@@ -499,14 +475,38 @@ 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,'04'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3847.23'
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.001,'13'
S21.G00.78.002,'01012015'
S21.G00.78.003,'31012015'
S21.G00.78.004,'3847.23'
S21.G00.78.004,'86.36'
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,'1'
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,'3170.00'
S21.G00.79.001,'13'
S21.G00.79.004,'657.86'
S21.G00.81.001,'059'
S21.G00.81.004,'29.29'
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