Vat problem in intra-community sale

  • Posts: 79
  • Thank you received: 3
9 years 1 month ago #217956

-- HikaShop version -- : Business 2.6.0
-- Joomla version -- : 3.2.3
-- PHP version -- : 5.3.3

Hello, some time ago, I developed a plugin in order to check VAT number depending on custom field "user_type". You can find in topic " Invalid VAT number for individuals, what can I do? ".

It checks VAT number properly, but now our financial staff warn us about a problem with users with valid VAT number not in our country (Spain), because when a company with valid VAT number do an order, VAT must not apply because it is considering a "Intra-community sale".

Looking for where VAT is calculated, I found a function named "getTax" in class currency.php

	function getTax($zone_id,$tax_category_id,$type=''){
This function seems to filter depending on "$type" parameter.
My question is, where can I set this "type" in checkout process? (note I have configured address before cart in checkout as you can see and I've set the "Type of of address used for tax" to billing.)

What can I do to set this parameter?

Regards

Attachments:
Last edit: 9 years 1 month ago by pljuarez.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 1 month ago #217970

Hi,

The type is decided automatically by the function getTaxType which is called by the getTax function itself to know what is the type of the current user based on his billing or shipping address. If he fills the address_company field, he will be considered as a company, otherwise, an individual.

Please Log in or Create an account to join the conversation.

  • Posts: 79
  • Thank you received: 3
9 years 1 month ago #218075

Thanks for your answer Nicholas.

Then, if I need to modify this behavior, should I modyfy this function?. Can I override this function in a plugin?

Regards

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 1 month ago #218079

Modifying the function will be simpler.
You can just override the function with a plugin. You would have to either override the whole class file, or use the onHikashopGetTax trigger in a plugin to reload the taxes yourself, or recalculate all the taxes yourself using the same principle than the TaxCloud plugin.
Modifying the function in the core file will be way easier.

Please Log in or Create an account to join the conversation.

  • Posts: 79
  • Thank you received: 3
9 years 1 month ago #218164

Thanks Nicholas, I'll try to override the funtion in a plugin like you said in order to prevent modifications in futures updates.

Can you say me where can I find documentation about onHikashopGetTax trigger? (parameters, use, ...). I looked for information and I haven't found anything in documentation neither in the forum.

Regards

Last edit: 9 years 1 month ago by pljuarez.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
9 years 4 weeks ago #218209

Hi,

There is no documentation about it. It's a new trigger that has been added recently.

The parameters are:
onHikashopGetTax( &$class, $zone_id, $tax_category_id, $type, &$matches, &$taxPlans)

$class : the currency class
$zone_id : the id of the current zone of the customer
$tax_category_id : the id of the tax category of the current product for which we're getting the tax rate
$type: the type of user that was calculated in the getTaxType function
$matches: an array of objects containing the tax rules and tax rates data that were loaded based on the previous parameters
$taxPlans: an array of objects containing the tax rules and tax rates data that were loaded before the filtering on the zone_id

What you'll have to do is to load yourself the tax rules and tax rates data objects you want in $matches based on your own rules so that the system can then use them for the calculations.

Please Log in or Create an account to join the conversation.

  • Posts: 79
  • Thank you received: 3
9 years 4 weeks ago #218425

Thanks Nicholas, I'll try to make a plugin that override the function based on this trigger, I'll keep you up to date on my progress.

Regards

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum