iconfinder / pyvat

VAT validation for Python
Other
66 stars 29 forks source link

get_sale_vat_charge raise NotImplementedError for Danish electronic services #9

Open dtrinchet opened 9 years ago

dtrinchet commented 9 years ago

As the doc says "Currently only supports determination of the VAT charge for telecommunications, broadcasting and electronic services in the EU." I expected to get the right vat rate doing:

import pyvat import datetime pyvat.get_sale_vat_charge(datetime.datetime.now(), pyvat.ItemType.generic_electronic_service, pyvat.Party("DK", True), pyvat.Party("DK", False))

but I'm getting:

NotImplementedError: cannot determine VAT charge for a sale of item ItemType.generic_electronic_service: 2 between pyvat.Party: country code = DK, is business = False and pyvat.Party: country code = DK, is business = True

shouldn't I get a valid VAT charge for this case?

kdeldycke commented 9 years ago

Third argument of get_sale_vat_charge(date, item_type, buyer, seller) is the customer while the last is the seller. So your code is about a C2B transaction in Denmark. If you're looking for the VAT of a B2C transaction, reverse the two last parameters.

Source: https://github.com/iconfinder/pyvat/blob/v1.3.1/pyvat/__init__.py#L208-L211

But I agree, I found this convention quite unnatural. I propose to change get_sale_vat_chargesignature from (date, item_type, buyer, seller) to (date, item_type, seller, buyer).

martinleblanc commented 9 years ago

I don't think this change will make it more natural. Wouldn't better error handling be the best way forward?

dtrinchet commented 9 years ago

What i want is exactly what i wrote, figure out the vat rate charge for a transaction where the buyer is a business and the seller is an individual, in Denmark. Isn't that supported?

martinleblanc commented 9 years ago

I'm pretty sure that is supported. We have that scenario quite often at Iconfinder.

dtrinchet commented 9 years ago

Why i got the exception so? Could you please give it a try? Thanks. You can see the traceback in my first post.

phidah commented 9 years ago

@martinleblanc yeah seemed like a bug when I tried

import pyvat
import datetime
pyvat.get_sale_vat_charge(datetime.datetime.now(), pyvat.ItemType.generic_electronic_service, pyvat.Party("DK", True), pyvat.Party("DK", False))

and it seemed to be unsupported.

We'd love to be able to use this in Saxo. @dtrinchet perhaps you can check if you can find the bug and do a PR for the Iconfinder guys?

dtrinchet commented 9 years ago

Yeah, I will check @phidah if i can find the bug and do a PR :)

dtrinchet commented 9 years ago

@phidah @martinleblanc @kdeldycke I have checked and this is not a bug, just it is not supported, although the docs says another thing :( It seems we should add some financial-economic data to support this, constants, etc I would like to be cautious around, I would rather someone in the team checks that.