Jump to content

Action Hooks (Valid Tax/VAT ID Number)


Grzesiu

Recommended Posts

Now I'm checking Action Hooks (Valid Tax/VAT ID Number). But it doesn't work correct. Does hook ClientAdd, ClientEdit work after client was adding to the base (or when new data was saved) or action is concurrent?

Function setTaxExemptForVAT from script vatnumbervalidation not always change taxexempt on.

It looks like

update_query("tblclients",array("taxexempt"=>"on"),array("id"=>$vars["userid"]));

can't find client in base. Maybe like he wasn't added yet.

Link to comment
Share on other sites

when new data is saved by an updatequery (somewhere in your code), the hook ClientEdit probably will not called.

The Hook Client Edit is called on the Editform in clientarea ( clientarea.php?action=details ) when saving.

 

Tip:

add in the hook ClientEdit:

die("this is the die in ClientEdit Hook ");

 

Then you will see, if its called.

Link to comment
Share on other sites

Then you will see, if its called.

OK,

Hook vatnumbervalidation does not work

Please change the function of setTaxExemptForVAT

function setTaxExemptForVAT($vars) {

   global $VAT_CUSTOM_FIELD_NAME,$VAT_HOME_COUNTRY;

   $result = select_query("tblcustomfields","id",array("type"=>"client","fieldname"=>$VAT_CUSTOM_FIELD_NAME));
   $data = mysql_fetch_array($result);
   $VAT_CUSTOM_FIELD_ID = $data["id"];

   $result = select_query("tblcustomfieldsvalues","value",array("fieldid"=>$VAT_CUSTOM_FIELD_ID,"relid"=>$vars["userid"]));
   $data = mysql_fetch_array($result);
   $VAT_CUSTOM_FIELD_VALUE = $data["value"];

if (!$VAT_CUSTOM_FIELD_VALUE) {
die ("VAT Number not found, id: $VAT_CUSTOM_FIELD_ID fieldid: $VAT_CUSTOM_FIELD_VALUE");
}

   $european_union_countries = array('AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK');

   if ((in_array($vars["country"],$european_union_countries))AND($vars["country"]!=$VAT_HOME_COUNTRY)AND($VAT_CUSTOM_FIELD_VALUE)) {
       update_query("tblclients",array("taxexempt"=>"on"),array("id"=>$vars["userid"]));
   }

}

 

And set up a new user with a valid VAT number

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated