Commit 6581bdd4 authored by Nicolas Wavrant's avatar Nicolas Wavrant

WIP: erp5_payroll_l10n_fr: allow declaration of regularisations in CTPs

parent b9beaecd
......@@ -92,22 +92,38 @@ for collective_contract in collective_contract_list:
# Generate aggregated contributions
aggregated_social_contribution_dict = {}
aggregated_social_regularisation_dict = {}
social_contribution_organisation = None
social_contribution_start_date = None
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:
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']
for key in employee_ctp:
try:
ctp_code, start_date, stop_date = key
except ValueError:
raise ValueError(key)
# If date is different, then it is a regularisation
if (declared_year, declared_month) != start_date[:2]:
aggregated_social_regularisation_dict.setdefault((start_date, stop_date), {})
if ctp_code not in aggregated_social_regularisation_dict[(start_date, stop_date)]:
aggregated_social_regularisation_dict[(start_date, stop_date)] = {ctp_code: employee_ctp[key].copy()}
else:
for summing_parameter in ('base', 'quantity'):
aggregated_social_regularisation_dict[(start_date, stop_date)][ctp_code][summing_parameter] = \
aggregated_social_regularisation_dict[(start_date, stop_date)][ctp_code][summing_parameter] + employee_ctp[key][summing_parameter]
# Otherwise normal case of declaration
else:
if social_contribution_organisation is None and 'corporate_registration_code' in employee_ctp[key]:
social_contribution_organisation = employee_ctp[key]['corporate_registration_code']
social_contribution_start_date = employee_ctp[key]['start_date']
social_contribution_stop_date = employee_ctp[key]['stop_date']
if ctp_code not in aggregated_social_contribution_dict:
aggregated_social_contribution_dict[ctp_code] = employee_ctp[ctp_code].copy()
aggregated_social_contribution_dict[ctp_code] = employee_ctp[key].copy()
else:
for summing_parameter in ('base', 'quantity'):
aggregated_social_contribution_dict[ctp_code][summing_parameter] = \
aggregated_social_contribution_dict[ctp_code][summing_parameter] + employee_ctp[ctp_code][summing_parameter]
aggregated_social_contribution_dict[ctp_code][summing_parameter] + employee_ctp[key][summing_parameter]
# Find the payment transaction for the social contributions
if len(payment_transaction_list):
......
......@@ -150,16 +150,18 @@ for movement in context.PaySheetTransaction_getMovementList():
continue
contribution_set = set(movement.getBaseContributionValueList())
start_date = movement.getStartDate().parts()
stop_date = movement.getStopDate().parts()
ctp_set = all_ctp_set.intersection(contribution_set)
for category in ctp_set:
category = category.getCodification()
contribution_dict = makeCTPBlock(movement, category)
if category in result["ctp"]:
result['ctp'][category]['base'] = result['ctp'][category]['base'] + contribution_dict['base']
result['ctp'][category]['quantity'] = result['ctp'][category]['quantity'] + contribution_dict['quantity']
if (category, start_date, stop_date) in result["ctp"]:
result['ctp'][(category, start_date, stop_date)]['base'] = result['ctp'][(category, start_date, stop_date)]['base'] + contribution_dict['base']
result['ctp'][(category, start_date, stop_date)]['quantity'] = result['ctp'][(category, start_date, stop_date)]['quantity'] + contribution_dict['quantity']
else:
result['ctp'][category] = contribution_dict
result['ctp'][(category, start_date, stop_date)] = contribution_dict
taxable_base_set = all_taxable_base_set.intersection(contribution_set)
for category in taxable_base_set:
......@@ -246,7 +248,7 @@ if len(result['ctp']):
raise AttributeError(context.getUrl())
if year_to_date_gross_salary < 2.5 * minimum_salary * int(context.getStopDate().month()):
category = '400D'
result['ctp'][category] = {
result['ctp'][(category, start_date, stop_date)] = {
'code': category,
'cap': ('921' if category[-1] == 'P' else '920'),
'rate': '',
......
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