Include company phone and contact details in 347 and 349 format
issue11405 review405221002
This commit is contained in:
+2
-1
@@ -2,7 +2,7 @@
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
from trytond.pool import Pool
|
||||
|
||||
from . import account, account_payment, party, reporting_tax
|
||||
from . import account, account_payment, company, party, reporting_tax
|
||||
|
||||
|
||||
def register():
|
||||
@@ -13,6 +13,7 @@ def register():
|
||||
account.TaxTemplate,
|
||||
account.Tax,
|
||||
account.Invoice,
|
||||
company.Company,
|
||||
party.Party,
|
||||
party.Identifier,
|
||||
reporting_tax.ESVATList,
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
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)}
|
||||
1347${year}${company.party.tax_identifier.es_code()}${justify(company.party.name.upper(), 40)}T${format_phone(company.es_aeat_contact_phone)}${justify(company.party.name.upper(), 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 %}\
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
1349${year}${company.party.tax_identifier.code[2:]}${justify(company.rec_name.upper(), 40)}T000000000${justify('', 40)}349${year}${period_number}0001 0000000000000${period}${format_integer(len(records), 9)}${format_decimal(records_amount, 15)}${format_integer(0, 9)}${format_decimal(0), 15}${justify('', 315)}
|
||||
1349${year}${company.party.tax_identifier.code[2:]}${justify(company.party.name.upper(), 40)}T${format_phone(company.es_aeat_contact_phone)}${justify(company.party.name.upper(), 40)}349${year}${period_number}0001 0000000000000${period}${format_integer(len(records), 9)}${format_decimal(records_amount, 15)}${format_integer(0, 9)}${format_decimal(0), 15}${justify('', 315)}
|
||||
{% for record in records %}\
|
||||
2349${year}${justify(identifier_code(record.company_tax_identifier), 9)}${justify('', 58)}${justify(record.party_tax_identifier.code if record.party_tax_identifier else '', 17)}${justify(record.party.name.upper(), 40)}${record.code}${format_decimal(record.amount)}${justify('', 354)}
|
||||
{% end %}\
|
||||
|
||||
+15
-1
@@ -1,5 +1,8 @@
|
||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
# this repository contains the full copyright notices and license terms.
|
||||
import phonenumbers
|
||||
from phonenumbers import NumberParseException
|
||||
|
||||
from trytond.pool import PoolMeta
|
||||
|
||||
|
||||
@@ -8,4 +11,15 @@ class Company(metaclass=PoolMeta):
|
||||
|
||||
@property
|
||||
def es_aeat_contact_phone(self):
|
||||
return self.party.phone
|
||||
phone = None
|
||||
for contact_mechanism in self.party.contact_mechanisms:
|
||||
if contact_mechanism.type in {'phone', 'mobile'}:
|
||||
try:
|
||||
phonenumber = phonenumbers.parse(
|
||||
contact_mechanism.value, None)
|
||||
except NumberParseException:
|
||||
continue
|
||||
if phonenumber and phonenumber.country_code == '34':
|
||||
phone = contact_mechanism.value
|
||||
break
|
||||
return phone
|
||||
|
||||
@@ -7,9 +7,11 @@ from decimal import Decimal
|
||||
from io import BytesIO, TextIOWrapper
|
||||
from operator import attrgetter
|
||||
|
||||
import phonenumbers
|
||||
from dateutil.relativedelta import relativedelta
|
||||
# XXX fix: https://genshi.edgewall.org/ticket/582
|
||||
from genshi.template.astutil import ASTCodeGenerator, ASTTransformer
|
||||
from phonenumbers import NumberParseException
|
||||
from sql import Cast, Literal, Null
|
||||
from sql.aggregate import Count, Min, Sum
|
||||
from sql.conditionals import Case, Coalesce
|
||||
@@ -68,6 +70,17 @@ def format_percentage(n, size=5):
|
||||
return ('{0:.2f}'.format(n)).replace('.', '').rjust(size, '0')
|
||||
|
||||
|
||||
def format_phone(phone):
|
||||
try:
|
||||
phone = phonenumbers.format_number(
|
||||
phonenumbers.parse(phone, 'ES'),
|
||||
phonenumbers.PhoneNumberFormat.NATIONAL)
|
||||
except NumberParseException:
|
||||
phone = ''
|
||||
phone = phone.replace(' ', '')
|
||||
return phone[:9].rjust(9, '0')
|
||||
|
||||
|
||||
def identifier_code(identifier):
|
||||
if identifier:
|
||||
return identifier.es_code()
|
||||
@@ -543,6 +556,7 @@ class AEAT347(Report):
|
||||
15, '0')
|
||||
context['format_decimal'] = format_decimal
|
||||
context['format_integer'] = format_integer
|
||||
context['format_phone'] = format_phone
|
||||
context['identifier_code'] = identifier_code
|
||||
context['country_code'] = country_code
|
||||
context['strip_accents'] = strip_accents
|
||||
@@ -699,6 +713,7 @@ class AEAT349(Report):
|
||||
return ('{0:.2f}'.format(abs(n))).replace('.', '').rjust(
|
||||
digits, '0')
|
||||
context['format_decimal'] = format_decimal
|
||||
context['format_phone'] = format_phone
|
||||
|
||||
return context
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ else:
|
||||
if local_version:
|
||||
version += '+' + '.'.join(local_version)
|
||||
|
||||
requires = ['python-sql >= 1.1.0']
|
||||
requires = ['python-sql >= 1.1.0', 'phonenumbers']
|
||||
for dep in info.get('depends', []):
|
||||
if not re.match(r'(ir|res)(\W|$)', dep):
|
||||
requires.append(get_require_version('trytond_%s' % dep))
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
13472018B01000009DUNDER MIFFLIN T000000000 3472018000001 0000000000000000000001 000000000024200000000000 000000000000000
|
||||
13472018B01000009DUNDER MIFFLIN T000000000DUNDER MIFFLIN 3472018000001 0000000000000000000001 000000000024200000000000 000000000000000
|
||||
23472018B0100000900000000T PARTY D25 B 000000000024200 000000000000000 0000000000000000000 000000000024200 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000 000000000000000
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
13492018B01000009DUNDER MIFFLIN T000000000 3492018010001 000000000000001000000001000000000010000000000000000000000000015
|
||||
13492018B01000009DUNDER MIFFLIN T000000000DUNDER MIFFLIN 3492018010001 000000000000001000000001000000000010000000000000000000000000015
|
||||
23492018B01000009 BE0897290877 INTRACOMUNITARY SUPPLIER A0000000010000
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[tryton]
|
||||
version=6.3.0
|
||||
depends:
|
||||
company
|
||||
currency
|
||||
ir
|
||||
account
|
||||
|
||||
Reference in New Issue
Block a user