Commit 9627132a authored by Nicolas Wavrant's avatar Nicolas Wavrant

erp5_payroll_l10n_fr: support "void" monthly DSN

parent 634edc71
......@@ -55,7 +55,7 @@ if block_id == 'S10.G00.00':
rubric_value_dict['S10.G00.00.005'] = '01'
rubric_value_dict['S10.G00.00.006'] = 'P03V01'
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
if block_id == 'S10.G00.01':
......@@ -88,7 +88,7 @@ if block_id == 'S10.G00.02':
if block_id == 'S20.G00.05':
now = DateTime()
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.004'] = kw['order'] # Declaration.Ordre, incremented for each DSN
rubric_value_dict['S20.G00.05.005'] = formatDate(DateTime(kw['year'], kw['month'], 1))
......@@ -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.006'] = ''
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.015'] = (establishment_country_code if establishment_country_code not in france_territory_code else '')
rubric_value_dict['S21.G00.11.016'] = ''
......
......@@ -2,8 +2,7 @@ from Products.ERP5Type.DateUtils import addToDate, getNumberOfDayInMonth
if context.getSourceAdministration() is None \
or context.getEffectiveDate() is None \
or context.getQuantity() is None \
or len(context.getAggregateRelatedIdList()) <= 0:
or context.getQuantity() is None:
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()
......@@ -34,14 +33,19 @@ paysheet_id_list = [transaction.getId() for transaction in paysheet_list]
change_block_dict = context.DSNMonthlyReport_getChangeBlockDict()
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(' '))
# Finds the head office of the comany
if len(payment_transaction_list):
organisation = payment_transaction_list[0].getSourceSectionValue()
else:
elif len(paysheet_list):
organisation = paysheet_list[0].getDestinationSectionValue()
else:
organisation = context.getSourceSectionValue()
# Variable containing all the record of the DSN
......@@ -60,12 +64,13 @@ leave_period_dict = context.DSNMonthlyReport_getLeavePeriodDict(bank_account)
employee_list = []
# 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.02', target=organisation_contact))
# 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))
......@@ -79,7 +84,10 @@ employee_result_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()
for employee_data_dict, paysheet_data_dict in employee_result_list:
......@@ -171,7 +179,7 @@ if len(payment_transaction_list):
establishment=establishment,
payer=organisation))
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
amount = -1. * portal.portal_simulation.getInventory(
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