NKoonen / vatchecker

[Prestashop]Checks if customer has a valid VAT number, and then puts the customer a specific group.
https://customs-documents.com
BSD 3-Clause "New" or "Revised" License
34 stars 14 forks source link

module functioning #23

Closed AndrzejSzczepanik closed 2 years ago

AndrzejSzczepanik commented 2 years ago

I have been using the module for 2 years, there was a description somewhere before, I remember that the description explained that the VIES group should be created for which prices are displayed net - this setting is in the group configuration. The module probably assigned to this group based on the VAT ID and delivery address. Now I can see that it does not automatically assign to any group and will charge the customer in gross price and so he will sell / issue a prestashop invoice if I have not added the customer to the VIES group manually. Can someone explain exactly how this is supposed to work. Thank you in advance

JoryHogeveen commented 2 years ago

Hi @AndrzejSzczepanik

You are describing an older version of this module. At that point it indeed assigned a user to a non-VAT group based on the VAT ID. However, this does not work for multiple addresses.

The new version of the module does vat validation based on the address, not the user. So an address is either VAT validated or not. If it is then VAT is disabled, otherwise it is enabled. Group assignment (and groups in general) is something different entirely and it's (and should be) unrelated to VAT calculation.

AndrzejSzczepanik commented 2 years ago

OK, that's how I understood the intentions in the current version, but the tests show that if the user has VIES and the address is exported, he does not count and invoice net anyway, until I manually changes the group to VIES, then the net is invoiced, it would follow that I don't know about something else. Could you explain at what point in time this verification takes place, does it have any reflection in the customer's databases, etc., thank you beautifully

JoryHogeveen commented 2 years ago

The validation occurs when an Address is validated and then the result is stored in a database table. Each time the Tax calculator class gets requested this module hooks into that calculator and checks if the address is VAT validated or not. If it is then it returns 0 for tax.

TaxCalculator: https://github.com/NKoonen/vatchecker/blob/master/override/classes/tax/TaxRulesTaxManager.php Validation hook: https://github.com/NKoonen/vatchecker/blob/master/vatchecker.php#L126 Validation method: https://github.com/NKoonen/vatchecker/blob/master/vatchecker.php#L424

The validation isn't visible in the default customer tables. It's stored in this plugin's table: https://github.com/NKoonen/vatchecker/blob/037aa84064131cd33ffb3a4c62669cf33bd65896/vatchecker.php#L540-L543

AndrzejSzczepanik commented 2 years ago

Thank you for your clarification, so I see that VAT checking is performed on demand, and it does not depends on customer group at all. Sounds nice, but please pay atention to this atached screens - it should't calucate a tax but it does calculate TAX. The same situation with the same user, when the user is assigned to VIES group (what only lists product prices in net value) TAX is not included. What the explanation coud be? Prestshop 1.7.8.5 Vat checker today yesterdea reinstaled current version from this Giithub VatChecker bring us to pay without tax when user belogs to VIES group Vies gropu configuration Vat Checker config VatChecker bring us to pay tax

AndrzejSzczepanik commented 2 years ago

the last screen is situation when user does not belong to VIES group

AndrzejSzczepanik commented 2 years ago

Supporting information - the store is multi languges and multi currencies

AndrzejSzczepanik commented 2 years ago

And I can see that ps_vatchecker table is not present in my database schemat Screenshot_2022-09-15-21-47-43-961_com android chrome

JoryHogeveen commented 2 years ago

Hi @AndrzejSzczepanik Are you sure you are running the latest version? This plugin doesn't even check or validate a customer group so that is fully unrelated to any issue. The mentioned group setting to show prices excluding taxes is also unrelated as this is only changing display, not the actual pricing.

Please make sure you re-install correctly.

AndrzejSzczepanik commented 2 years ago

You make me start thinking. I did uninstall, and install again, then I have checked in vatchecker table was created, because I see that it shoud be created when vatchecker is installed, so I get succes - table was created, and all start working exactly as it is discrbed ! Perfect module - sutis exactly the need. Thanky very mutch for puting some light how it works.

AndrzejSzczepanik commented 2 years ago

And this approach to the VAT issue ensures showing correct prices and bill calculation as well based on address and VAT id of delivery address - really perfect !!! you are clever guy!!

JoryHogeveen commented 2 years ago

Good to hear you've solved the issue, enjoy the module!