[FIX] l10n_fr_fec: solve some issues with the french FEC

This commit:

1. Allows exporting the FEC without any VAT number. Indeed, a company can have to submit its FEC without being submitted to VAT regulation.

2. Allows non french companies to export FEC file.

3. The FEC now includes the journal items == 0 and/or journal entries which total is 0.
Initially, french tax administration rejected the journal items which balance is 0.
But after several requests from tax payers, they agreed because they prefer continuous sequences and some tax payers post entries which total amount is 0.

task-2717676

closes odoo/odoo#82456

X-original-commit: e6206b03ba245ece3d8f765644d71f2d2008398d
Signed-off-by: Laurent Smet <las@odoo.com>
This commit is contained in:
Julien Van Roy
2022-01-11 08:36:38 +00:00
parent c856cd08d9
commit 4e18c501b8
+8 -18
View File
@@ -65,7 +65,6 @@ class AccountFrFec(models.TransientModel):
am.date < %s
AND am.company_id = %s
AND aat.include_initial_balance IS NOT TRUE
AND (aml.debit != 0 OR aml.credit != 0)
'''
# For official report: only use posted entries
if self.export_type == "official":
@@ -93,14 +92,10 @@ class AccountFrFec(models.TransientModel):
"""
dom_tom_group = self.env.ref('l10n_fr.dom-tom')
is_dom_tom = company.account_fiscal_country_id.code in dom_tom_group.country_ids.mapped('code')
if not is_dom_tom and not company.vat:
raise UserError(_("Missing VAT number for company %s", company.name))
if not is_dom_tom and company.vat[0:2] != 'FR':
raise UserError(_("FEC is for French companies only !"))
return {
'siren': company.vat[4:13] if not is_dom_tom else '',
}
if not company.vat or is_dom_tom:
return {'siren': ''}
else:
return {'siren': company.vat[4:13]}
def generate_fec(self):
self.ensure_one()
@@ -183,7 +178,6 @@ class AccountFrFec(models.TransientModel):
am.date < %s
AND am.company_id = %s
AND aat.include_initial_balance = 't'
AND (aml.debit != 0 OR aml.credit != 0)
'''
# For official report: only use posted entries
@@ -194,8 +188,7 @@ class AccountFrFec(models.TransientModel):
sql_query += '''
GROUP BY aml.account_id, aat.type
HAVING round(sum(aml.balance), %s) != 0
AND aat.type not in ('receivable', 'payable')
HAVING aat.type not in ('receivable', 'payable')
'''
formatted_date_from = fields.Date.to_string(self.date_from).replace('-', '')
date_from = self.date_from
@@ -203,7 +196,7 @@ class AccountFrFec(models.TransientModel):
currency_digits = 2
self._cr.execute(
sql_query, (formatted_date_year, formatted_date_from, formatted_date_from, formatted_date_from, self.date_from, company.id, currency_digits))
sql_query, (formatted_date_year, formatted_date_from, formatted_date_from, formatted_date_from, self.date_from, company.id))
for row in self._cr.fetchall():
listrow = list(row)
@@ -281,7 +274,6 @@ class AccountFrFec(models.TransientModel):
am.date < %s
AND am.company_id = %s
AND aat.include_initial_balance = 't'
AND (aml.debit != 0 OR aml.credit != 0)
'''
# For official report: only use posted entries
@@ -292,11 +284,10 @@ class AccountFrFec(models.TransientModel):
sql_query += '''
GROUP BY aml.account_id, aat.type, rp.ref, rp.id
HAVING round(sum(aml.balance), %s) != 0
AND aat.type in ('receivable', 'payable')
HAVING aat.type in ('receivable', 'payable')
'''
self._cr.execute(
sql_query, (formatted_date_year, formatted_date_from, formatted_date_from, formatted_date_from, self.date_from, company.id, currency_digits))
sql_query, (formatted_date_year, formatted_date_from, formatted_date_from, formatted_date_from, self.date_from, company.id))
for row in self._cr.fetchall():
listrow = list(row)
@@ -362,7 +353,6 @@ class AccountFrFec(models.TransientModel):
am.date >= %s
AND am.date <= %s
AND am.company_id = %s
AND (aml.debit != 0 OR aml.credit != 0)
'''
# For official report: only use posted entries