Fix bug when take party VAT

This commit is contained in:
Bernat Brunet Torruella 2017-08-28 14:17:12 +02:00
parent 5c05cd6eca
commit 21ec0409eb

View file

@ -19,10 +19,14 @@ class Party:
'get_sii_vat_data')
def get_sii_vat_data(self, name=None):
if self.vat_code:
vat_code = self.vat_code
if vat_code:
type = None
for identifier in self.identifiers:
if identifier.code == vat_code:
type = identifier.type
break
if name == 'sii_vat_code':
return (self.vat_code[-9:]
if self.type == 'eu_vat' else self.vat_code)
return vat_code[2:] if type == 'eu_vat' else vat_code
elif name == 'sii_vat_country':
return (self.vat_code[:2]
if self.type == 'eu_vat' else None)
return vat_code[:2] if type == 'eu_vat' else None