Commit 5c64a0a4 authored by Nicolas Wavrant's avatar Nicolas Wavrant Committed by Eteri

erp5_payroll_l10n_fr: minor improvements in DSN social report generation

These improvements include :
   * better address reporting
   * better handling of Social Security Number and Temporary Technical Number
     for foreign employees
   * add more checks and UI error messages to report wrong values to the user
     before he submits the DSN
   * fix bugs for some edge cases
parent 0055578b
......@@ -26,7 +26,7 @@ if block_id == 'S20.G00.05':
rubric_value_dict['S20.G00.05.001'] = kw['dsn_type']
rubric_value_dict['S20.G00.05.002'] = '01'
rubric_value_dict['S20.G00.05.003'] = '11'
rubric_value_dict['S20.G00.05.004'] = '1' # TODO : to increment for each new event DSN
rubric_value_dict['S20.G00.05.004'] = kw['order']
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'] = ''
......@@ -54,11 +54,14 @@ elif block_id == 'S21.G00.11':
# Individu
if block_id == 'S21.G00.30':
rubric_value_dict["S21.G00.30.001"] = ''.join(target.getSocialCode().split(' '))[:13] # sometimes there are spaces in textfield
social_code = target.getSocialCode('')
rubric_value_dict["S21.G00.30.001"] = ("" if not social_code else "".join(social_code.split(' '))[:13])
rubric_value_dict["S21.G00.30.001"] = ''.join(target.getSocialCode('').split(' '))[:13] # sometimes there are spaces in textfield
rubric_value_dict["S21.G00.30.002"] = target.getLastName()
rubric_value_dict["S21.G00.30.003"] = '' # Nom d'usage
rubric_value_dict["S21.G00.30.004"] = ' '.join([target.getFirstName(), target.getMiddleName() or '']).strip()
rubric_value_dict["S21.G00.30.006"] = formatDate(target.getStartDate())
rubric_value_dict["S21.G00.30.020"] = target.getCareerReference('')
# Contrat
if block_id == 'S21.G00.40':
......
......@@ -212,6 +212,11 @@ if block_id == 'S21.G00.23':
if block_id == 'S21.G00.30':
birth_country_code = getCountryCode(target)
address = target.getDefaultAddressStreetAddress().strip().split('\n')
if ',' in address[0]:
address_complement = address[0].split(',', 1)[1].strip()
address[0] = address[0].split(',', 1)[0]
else:
address_complement = ''
social_code = target.getSocialCode('')
rubric_value_dict["S21.G00.30.001"] = ("" if not social_code else "".join(social_code.split(' '))[:13])
rubric_value_dict["S21.G00.30.002"] = target.getLastName()
......@@ -229,7 +234,7 @@ if block_id == 'S21.G00.30':
rubric_value_dict["S21.G00.30.013"] = enrollment_record.getUeCode()
rubric_value_dict["S21.G00.30.014"] = enrollment_record.getBirthDepartment()
rubric_value_dict["S21.G00.30.015"] = enrollment_record.getBirthCountryCode()
rubric_value_dict["S21.G00.30.016"] = ''
rubric_value_dict["S21.G00.30.016"] = address_complement
rubric_value_dict["S21.G00.30.017"] = (' '.join(address[1:]).strip() if len(address) > 1 else '')
rubric_value_dict["S21.G00.30.018"] = target.getDefaultEmailCoordinateText() or ''
rubric_value_dict["S21.G00.30.019"] = ''
......@@ -248,6 +253,8 @@ 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():
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())
rubric_value_dict["S21.G00.40.013"] = formatFloat(enrollment_record.getWorkingUnitQuantity())
......@@ -379,6 +386,10 @@ if block_id == 'S21.G00.71':
code = 'RETA'
elif enrollment_record.getComplementaryRetirementStatus() == '01':
code = 'RETC'
elif enrollment_record.getComplementaryRetirementStatus() == '99':
code = '90000'
else:
raise ValueError('Unsupported Code for Complementary Retirement Status in Enrollement Record %s' % enrollment_record.absolute_url())
rubric_value_dict['S21.G00.71.002'] = code
if block_id == 'S21.G00.78':
......
......@@ -191,6 +191,9 @@ else:
dsn_file.append(getDSNBlockDict(block_id='S21.G00.23',
target=aggregated_social_contribution_dict[ctp_code]))
dsn_file.append(getDSNBlockDict(block_id='S21.G00.42', target=establishment))
dsn_file.append(getDSNBlockDict(block_id='S21.G00.44', target=establishment))
for employee_data_dict, paysheet_data_dict in employee_result_list:
enrollment_record = employee_data_dict['enrollment_record']
employee = employee_data_dict['person_relative_url']
......
......@@ -109,7 +109,7 @@ def makeIndividualContributionBlock(movement, category):
if category in ('018', '063', '064', '059'):
quantity = (getattr(movement, 'employer_total_price', 0) + getattr(movement, 'employee_total_price', 0)) * -1
if category == '018':
assert quantity < 0.
assert quantity <= 0., "Quantity in %s should be negative" % movement.absolute_url()
base = movement.base
else:
base = movement.base
......@@ -139,6 +139,9 @@ def makeOtherBonusBlock(movement, category):
}
for movement in context.PaySheetTransaction_getMovementList():
if not movement.base:
continue
contribution_set = set(movement.getBaseContributionValueList())
ctp_set = all_ctp_set.intersection(contribution_set)
......
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