Commit 546663b1 authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_payroll_l10n_fr: support "void" monthly DSN

parent 26e755a7
...@@ -55,7 +55,7 @@ if block_id == 'S10.G00.00': ...@@ -55,7 +55,7 @@ if block_id == 'S10.G00.00':
rubric_value_dict['S10.G00.00.005'] = '01' rubric_value_dict['S10.G00.00.005'] = '01'
rubric_value_dict['S10.G00.00.006'] = 'P03V01' rubric_value_dict['S10.G00.00.006'] = 'P03V01'
rubric_value_dict['S10.G00.00.007'] = '01' rubric_value_dict['S10.G00.00.007'] = '01'
rubric_value_dict['S10.G00.00.008'] = '01' rubric_value_dict['S10.G00.00.008'] = kw.get('type', '01')
# Emetteur # Emetteur
if block_id == 'S10.G00.01': if block_id == 'S10.G00.01':
...@@ -88,7 +88,7 @@ if block_id == 'S10.G00.02': ...@@ -88,7 +88,7 @@ if block_id == 'S10.G00.02':
if block_id == 'S20.G00.05': if block_id == 'S20.G00.05':
now = DateTime() now = DateTime()
rubric_value_dict['S20.G00.05.001'] = '01' # Monthly DSN rubric_value_dict['S20.G00.05.001'] = '01' # Monthly DSN
rubric_value_dict['S20.G00.05.002'] = '01' # Normal Declaration rubric_value_dict['S20.G00.05.002'] = kw.get('type', '01') # Normal Declaration
rubric_value_dict['S20.G00.05.003'] = '11' 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.004'] = kw['order'] # Declaration.Ordre, incremented for each DSN
rubric_value_dict['S20.G00.05.005'] = formatDate(DateTime(kw['year'], kw['month'], 1)) rubric_value_dict['S20.G00.05.005'] = formatDate(DateTime(kw['year'], kw['month'], 1))
...@@ -149,7 +149,7 @@ elif block_id == 'S21.G00.11': ...@@ -149,7 +149,7 @@ elif block_id == 'S21.G00.11':
rubric_value_dict['S21.G00.11.005'] = target.getDefaultAddressCity() rubric_value_dict['S21.G00.11.005'] = target.getDefaultAddressCity()
rubric_value_dict['S21.G00.11.006'] = '' rubric_value_dict['S21.G00.11.006'] = ''
rubric_value_dict['S21.G00.11.007'] = '' rubric_value_dict['S21.G00.11.007'] = ''
rubric_value_dict['S21.G00.11.008'] = int(context.getQuantity()) rubric_value_dict['S21.G00.11.008'] = str(int(context.getQuantity(0)))
rubric_value_dict['S21.G00.11.009'] = '' rubric_value_dict['S21.G00.11.009'] = ''
rubric_value_dict['S21.G00.11.015'] = (establishment_country_code if establishment_country_code not in france_territory_code else '') rubric_value_dict['S21.G00.11.015'] = (establishment_country_code if establishment_country_code not in france_territory_code else '')
rubric_value_dict['S21.G00.11.016'] = '' rubric_value_dict['S21.G00.11.016'] = ''
......
...@@ -2,8 +2,7 @@ from Products.ERP5Type.DateUtils import addToDate, getNumberOfDayInMonth ...@@ -2,8 +2,7 @@ from Products.ERP5Type.DateUtils import addToDate, getNumberOfDayInMonth
if context.getSourceAdministration() is None \ if context.getSourceAdministration() is None \
or context.getEffectiveDate() is None \ or context.getEffectiveDate() is None \
or context.getQuantity() is None \ or context.getQuantity() is None:
or len(context.getAggregateRelatedIdList()) <= 0:
return context.REQUEST.response.redirect("%s?portal_status_message=%s" % (context.absolute_url(), "DSN can't be built if some fields are empty")) 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() portal = context.getPortalObject()
...@@ -34,14 +33,19 @@ paysheet_id_list = [transaction.getId() for transaction in paysheet_list] ...@@ -34,14 +33,19 @@ paysheet_id_list = [transaction.getId() for transaction in paysheet_list]
change_block_dict = context.DSNMonthlyReport_getChangeBlockDict() change_block_dict = context.DSNMonthlyReport_getChangeBlockDict()
organisation_contact = context.getSourceAdministrationValue() organisation_contact = context.getSourceAdministrationValue()
establishment = accounting_module.restrictedTraverse(paysheet_id_list[0]).getDestinationTradeValue() if len(paysheet_list):
establishment = accounting_module.restrictedTraverse(paysheet_id_list[0]).getDestinationTradeValue()
else:
establishment = context.getSourceTradeValue()
establishment_registration_code = ''.join(establishment.getCorporateRegistrationCode().split(' ')) establishment_registration_code = ''.join(establishment.getCorporateRegistrationCode().split(' '))
# Finds the head office of the comany # Finds the head office of the comany
if len(payment_transaction_list): if len(payment_transaction_list):
organisation = payment_transaction_list[0].getSourceSectionValue() organisation = payment_transaction_list[0].getSourceSectionValue()
else: elif len(paysheet_list):
organisation = paysheet_list[0].getDestinationSectionValue() organisation = paysheet_list[0].getDestinationSectionValue()
else:
organisation = context.getSourceSectionValue()
# Variable containing all the record of the DSN # Variable containing all the record of the DSN
...@@ -60,12 +64,13 @@ leave_period_dict = context.DSNMonthlyReport_getLeavePeriodDict(bank_account) ...@@ -60,12 +64,13 @@ leave_period_dict = context.DSNMonthlyReport_getLeavePeriodDict(bank_account)
employee_list = [] employee_list = []
# DSN HEADERS # DSN HEADERS
dsn_file.append(getDSNBlockDict(block_id='S10.G00.00')) dsn_type = ('01' if len(paysheet_list) else '02')
dsn_file.append(getDSNBlockDict(block_id='S10.G00.00', type=dsn_type))
dsn_file.append(getDSNBlockDict(block_id='S10.G00.01', target=organisation)) dsn_file.append(getDSNBlockDict(block_id='S10.G00.01', target=organisation))
dsn_file.append(getDSNBlockDict(block_id='S10.G00.02', target=organisation_contact)) dsn_file.append(getDSNBlockDict(block_id='S10.G00.02', target=organisation_contact))
# Monthly DSN # Monthly DSN
dsn_file.append(getDSNBlockDict(block_id='S20.G00.05', year=declared_year, month=declared_month, order=nb_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='S21.G00.06', target=organisation)) dsn_file.append(getDSNBlockDict(block_id='S21.G00.06', target=organisation))
...@@ -79,7 +84,10 @@ employee_result_list = [ ...@@ -79,7 +84,10 @@ employee_result_list = [
for paysheet in paysheet_list for paysheet in paysheet_list
] ]
employee_data_list, paysheet_data_list = zip(*employee_result_list) if len(employee_result_list):
employee_data_list, paysheet_data_list = zip(*employee_result_list)
else:
employee_data_list, paysheet_data_list = [], []
insurance_contract_id_list = set() insurance_contract_id_list = set()
for employee_data_dict, paysheet_data_dict in employee_result_list: for employee_data_dict, paysheet_data_dict in employee_result_list:
...@@ -171,7 +179,7 @@ if len(payment_transaction_list): ...@@ -171,7 +179,7 @@ if len(payment_transaction_list):
establishment=establishment, establishment=establishment,
payer=organisation)) payer=organisation))
dsn_file.append(getDSNBlockDict(block_id='S21.G00.55', target=payment, establishment=establishment)) dsn_file.append(getDSNBlockDict(block_id='S21.G00.55', target=payment, establishment=establishment))
else: elif len(paysheet_list):
# If there is no Payment Transaction, then the organisation pays quaterly # If there is no Payment Transaction, then the organisation pays quaterly
amount = -1. * portal.portal_simulation.getInventory( amount = -1. * portal.portal_simulation.getInventory(
from_date=first_date_of_month, from_date=first_date_of_month,
......
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