changeset 33304864cd9e in modules/account_es:default
details:
https://hg.tryton.org/modules/account_es?cmd=changeset;node=33304864cd9e
description:
Do not remove first digits on Spanish identifiers in AEAT347 report
issue9834
review335111002
diffstat:
__init__.py | 1 +
aeat347.txt | 2 +-
party.py | 15 +++++++++++++++
reporting_tax.py | 4 ++--
tests/scenario_reporting.rst | 4 ++--
5 files changed, 21 insertions(+), 5 deletions(-)
diffs (76 lines):
diff -r 1b22c6719162 -r 33304864cd9e __init__.py
--- a/__init__.py Mon Nov 02 15:43:58 2020 +0100
+++ b/__init__.py Sun Dec 06 18:19:06 2020 +0100
@@ -15,6 +15,7 @@
account.TaxTemplate,
account.Tax,
party.Party,
+ party.Identifier,
reporting_tax.ESVATList,
reporting_tax.ESVATListContext,
reporting_tax.ECOperationList,
diff -r 1b22c6719162 -r 33304864cd9e aeat347.txt
--- a/aeat347.txt Mon Nov 02 15:43:58 2020 +0100
+++ b/aeat347.txt Sun Dec 06 18:19:06 2020 +0100
@@ -1,4 +1,4 @@
-1347${year}${company.party.tax_identifier.code[2:]}${justify(company.rec_name.upper(),
40)}T000000000${justify('', 40)}347${year}000001
0000000000000${format_integer(len(records),
9)}${format_decimal(records_amount)}${format_integer(0,
9)}${format_decimal(0)}${justify('', 315)}
+1347${year}${company.party.tax_identifier.es_code()}${justify(company.rec_name.upper(),
40)}T000000000${justify('', 40)}347${year}000001
0000000000000${format_integer(len(records),
9)}${format_decimal(records_amount)}${format_integer(0,
9)}${format_decimal(0)}${justify('', 315)}
{% for record in records %}\
2347${year}${justify(identifier_code(record.company_tax_identifier),
9)}${justify(identifier_code(record.party_tax_identifier), 9)}${justify('',
9)}${justify(strip_accents(record.party.name.upper()),
40)}D${justify(record.province_code, 2)}${justify(country_code(record), 2)}
${record.code}${format_decimal(record.amount)}
000000000000000${format_decimal(0)}0000${format_decimal(record.first_period_amount
or 0)}${format_decimal(0)}${format_decimal(record.second_period_amount or
0)}${format_decimal(0)}${format_decimal(record.third_period_amount or
0)}${format_decimal(0)}${format_decimal(record.fourth_period_amount or
0)}${format_decimal(0)}${justify('', 20)}${format_decimal(0)}${justify('', 201)}
{% end %}\
diff -r 1b22c6719162 -r 33304864cd9e party.py
--- a/party.py Mon Nov 02 15:43:58 2020 +0100
+++ b/party.py Sun Dec 06 18:19:06 2020 +0100
@@ -19,3 +19,18 @@
if country and zip_ and country.code == 'ES':
self.es_province_code = zip_[:2]
break
+
+
+class Identifier(metaclass=PoolMeta):
+ __name__ = 'party.identifier'
+
+ def es_country(self):
+ if self.type == 'eu_vat':
+ return self.code[:2]
+ if self.type in {'es_cif', 'es_dni', 'es_nie', 'es_nif'}:
+ return 'ES'
+
+ def es_code(self):
+ if self.type == 'eu_vat':
+ return self.code[2:]
+ return self.code
diff -r 1b22c6719162 -r 33304864cd9e reporting_tax.py
--- a/reporting_tax.py Mon Nov 02 15:43:58 2020 +0100
+++ b/reporting_tax.py Sun Dec 06 18:19:06 2020 +0100
@@ -68,14 +68,14 @@
def identifier_code(identifier):
if identifier:
- return identifier.code[2:]
+ return identifier.es_code()
return ''
def country_code(record):
code = None
if record.party_tax_identifier:
- code = record.party_tax_identifier.code[:2]
+ code = record.party_tax_identifier.es_country()
if code is None or code == 'ES':
return ''
return code
diff -r 1b22c6719162 -r 33304864cd9e tests/scenario_reporting.rst
--- a/tests/scenario_reporting.rst Mon Nov 02 15:43:58 2020 +0100
+++ b/tests/scenario_reporting.rst Sun Dec 06 18:19:06 2020 +0100
@@ -53,8 +53,8 @@
>>> TaxRule = Model.get('account.tax.rule')
>>> party = Party(name='Party')
>>> tax_identifier = party.identifiers.new()
- >>> tax_identifier.type = 'eu_vat'
- >>> tax_identifier.code = 'ES00000000T'
+ >>> tax_identifier.type = 'es_nif'
+ >>> tax_identifier.code = '00000000T'
>>> address, = party.addresses
>>> address.country = spain
>>> address.zip = '25001'