From a547aa13c742a71b817dae4eedd3e61673a9d482 Mon Sep 17 00:00:00 2001 From: Nicolas Wavrant <nicolas.wavrant@nexedi.com> Date: Thu, 4 Jan 2018 15:17:22 +0000 Subject: [PATCH] erp5_payroll_l10n_fr: compute blocks for annual taxes --- .../DSNMonthlyReport_getDataDict.py | 4 ++ .../DSNMonthlyReport_makeReport.py | 10 ++- .../Organisation_getAnnualTaxDictList.py | 56 +++++++++++++++++ .../Organisation_getAnnualTaxDictList.xml | 62 +++++++++++++++++++ 4 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.py create mode 100644 bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.xml diff --git a/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_getDataDict.py b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_getDataDict.py index 7caeecea21..37229a2ad5 100644 --- a/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_getDataDict.py +++ b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_getDataDict.py @@ -294,6 +294,10 @@ if block_id == 'S21.G00.40': rubric_value_dict["S21.G00.40.042"] = '' rubric_value_dict["S21.G00.40.043"] = formatFloat(enrollment_record.getOccupationalAccidentRiskRate()) +# Assujettissement fiscal +if block_id == 'S21.G00.44': + rubric_value_dict['S21.G00.44.001'] = kw['tax_code'] + rubric_value_dict['S21.G00.44.002'] = formatFloat(kw['amount']) # Versement Individu if block_id == 'S21.G00.50': diff --git a/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_makeReport.py b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_makeReport.py index 12e701ed99..b16a179003 100644 --- a/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_makeReport.py +++ b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/DSNMonthlyReport_makeReport.py @@ -192,8 +192,14 @@ 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)) +# Annual Taxes +if organisation == establishment: + tax_list = organisation.Organisation_getAnnualTaxDictList(context) + for tax in tax_list: + if tax['tax_code'] == '011': + dsn_file.append(getDSNBlockDict(block_id='S21.G00.42', target=establishment)) + dsn_file.append(getDSNBlockDict(block_id='S21.G00.44', target=establishment, **tax)) + for employee_data_dict, paysheet_data_dict in employee_result_list: enrollment_record = employee_data_dict['enrollment_record'] diff --git a/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.py b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.py new file mode 100644 index 0000000000..2bc420aa43 --- /dev/null +++ b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.py @@ -0,0 +1,56 @@ +portal = context.getPortalObject() + +# Annual taxes are only to declare in May or December +current_month = dsn_report.getEffectiveDate().month() +if current_month not in (5, 12): + return [] + +annual_tax_list = [] +tax_property_name_list = { + 'apprenticeship_fee_liability': ('001', '002'), + 'apprenticeship_supplementary_fee_liability': ('003', '004'), + 'construction_effort_fee_liability': ('005', '006'), + 'continuous_professional_training_fee_liability': ('007', '008'), + 'salary_fee_liability': ('009', '010'), + 'cvae_fee_liability': ('011', '012'), + 'continuous_short_term_professional_training_fee_liability': ('013', '014'), +} + +if dsn_report.getEffectiveDate().month() == 5: + tax = 'cvae_fee_liability' + result = { + 'tax_code': '', + 'amount': 0., # TODO: get amount right + } + if context.getProperty(tax, False): + result['tax_code'] = tax_property_name_list['cvae_fee_liability'][0] + else: + result['tax_code'] = tax_property_name_list['cvae_fee_liability'][1] + return result + + +year_start_date = DateTime(dsn_report.getEffectiveDate().year(), 1, 1) +year_stop_date = DateTime(dsn_report.getEffectiveDate().year(), 12, 31) + +for tax, value_list in tax_property_name_list.items(): + is_subjected = context.getProperty(tax, False) + amount = 0. + if is_subjected: + amount = portal.portal_simulation.getInventory( + node_uid=portal.account_module.remuneration_personnel.getUid(), # XXX: hardcoded + from_date=year_start_date, + at_date=year_stop_date, + section_uid=context.getUid(), + portal_type="Accounting Transaction Line", + simulation_state=['stopped', 'delivered', 'started', 'confirmed'], + ) + annual_tax_list.append({ + 'tax_code': (value_list[0] if is_subjected else value_list[1]), + 'amount': amount, + }) + +return annual_tax_list + + +# TODO : calculate base values for salary fee in case the company is subjected +# (for codes 015, 016 and 017 of S21.G00.44.001) diff --git a/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.xml b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.xml new file mode 100644 index 0000000000..1e35a8e7a7 --- /dev/null +++ b/bt5/erp5_payroll_l10n_fr/SkinTemplateItem/portal_skins/erp5_payroll_l10n_fr/Organisation_getAnnualTaxDictList.xml @@ -0,0 +1,62 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>dsn_report=None</string> </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>Organisation_getAnnualTaxDictList</string> </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> -- 2.30.9