Remove country code when is eu VAT

This commit is contained in:
Raimon Esteve 2017-07-25 09:14:57 +02:00
parent 669a773978
commit 4082cb2ee5
2 changed files with 10 additions and 6 deletions

View File

@ -35,10 +35,12 @@ class BaseTrytonInvoiceMapper(Model):
exempt_kind = attrgetter('sii_excemption_key')
def counterpart_nif(self, invoice):
nif = invoice.party.identifiers[0].code
if nif.startswith('ES'):
nif = nif[2:]
return nif
if invoice.party.identifiers:
nif = invoice.party.identifiers[0].code
if nif.type == 'eu_vat':
return nif[2:]
return nif
return ''
counterpart_id_type = attrgetter('party.sii_identifier_type')
counterpart_id = counterpart_nif

View File

@ -21,6 +21,8 @@ class Party:
def get_sii_vat_data(self, name=None):
if self.vat_code:
if name == 'sii_vat_code':
return self.vat_code[-9:]
return (self.vat_code[-9:]
if self.type == 'eu_vat' else self.vat_code)
elif name == 'sii_vat_country':
return self.vat_code[:2]
return (self.vat_code[:2]
if self.type == 'eu_vat' else None)