You are here:  » adding VAT on prices

Active Forum Topics


adding VAT on prices

Submitted by PHILDARV on Mon, 2007-06-04 09:12 in

I've got a feed where the prices don't include VAT, but in order for it to match the other merchants where VAT is included I want to add 17.5% to the prices on that one merchant.

Just wondering if there is a simple bit of code I could add to the import process to add the 17.5% where merchant="x" ?

Thanks

Phillip

Submitted by support on Mon, 2007-06-04 09:18

Hi Phillip,

Yes - that should be reasonably straight forward.

In includes/admin.php you will find the following code (line 166 in the distribution):

$record[$admin_importFeed["field_price"]] =
  tapestry_decimalise($record[$admin_importFeed["field_price"]]);

To do what you want, try the following immediately afterwards:

  if ($admin_importFeed["merchant"] == "Example Merchant")
  {
    // add VAT at 17.5% (multiply by 1.175)
    $record[$admin_importFeed["field_price"]] =
      $record[$admin_importFeed["field_price"]] * 1.175;
    // decimalise again to round to 2 decimal places
    $record[$admin_importFeed["field_price"]] =
      tapestry_decimalise($record[$admin_importFeed["field_price"]]);
  }

That should do the trick!

Cheers,
David.

Submitted by PHILDARV on Mon, 2007-06-04 13:22

That works a treat David ;-)

Many thanks
Phillip
Sat nav Price Comparison

Submitted by apa on Thu, 2008-10-30 09:15

This simply doesn't do anything for me. Has anything changed in the newer distributions. Should it still work?

Is "Example Merchant" supposed to be the feed name (merchant.txt) or the name i give the merchant on import? Is lower/uppercase an issue? (i did try it all i think)

Kind Regards,
Anders

Submitted by support on Thu, 2008-10-30 10:04

Hello Anders,

"Example Merchant" is the merchant name exactly as entered on Feed Registration (Step 2). The code is certainly still valid, so if you're not seeing any effect feel free to email me any files you have modified and i'll check them over for you...

Cheers,
David.

Submitted by apa on Thu, 2008-10-30 14:43

It works now. I wasn't thinking straight before. Sorry.

Regards

Submitted by philstone on Wed, 2010-08-04 15:30

Di David,

i cant find this line in the current version, has this changed?

regards

Phil Stone
www.buy24-7.net

Submitted by support on Wed, 2010-08-04 15:45

Hi Phil,

In the latest distribution, look for the following code starting at line 274

    /* decimalise price */
    $importRecord["price"] = tapestry_decimalise($importRecord["price"]);

...and REPLACE with:

    /* decimalise price */
    $importRecord["price"] = tapestry_decimalise($importRecord["price"]);
    if ($admin_importFeed["merchant"] == "Example Merchant")
    {
      // add VAT at 17.5% (multiply by 1.175)
      $importRecord["price"] =
      $importRecord["price"] * 1.175;
      // decimalise again to round to 2 decimal places
      $importRecord["price"] =
      tapestry_decimalise($importRecord["price"]);
    }

Cheers,
David.

Submitted by QuickDesign on Thu, 2010-09-30 11:31

Hello David,

How do I add VAT to more than one merchant. I have a feed with mixed VAT included and excluded.

thanks,
Bryan

Submitted by support on Thu, 2010-09-30 11:37

Hi Bryan,

In the latest distribution, instead of placing the modification where described above, look for the following code at line 292 of includes/admin.php:

    if (!$merchant) return;

...and at that point add the following:

    if (
       ($merchant == "Example Merchant")
       ||
       ($merchant == "Another Example Merchant")
       )
    {
      // add VAT at 17.5% (multiply by 1.175)
      $importRecord["price"] =
      $importRecord["price"] * 1.175;
      // decimalise again to round to 2 decimal places
      $importRecord["price"] =
      tapestry_decimalise($importRecord["price"]);
    }

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by QuickDesign on Thu, 2010-09-30 12:19

Hello David,

It works! Thank you.

If there is more than 2 merchant I guess I just have to change it to:

if (
       ($merchant == "Example Merchant")
       ||
       ($merchant == "Another Example Merchant")
       ||
       ($merchant == "Another Example1 Merchant")
       )
    {
      // add VAT at 17.5% (multiply by 1.175)
      $importRecord["price"] =
      $importRecord["price"] * 1.175;
      // decimalise again to round to 2 decimal places
      $importRecord["price"] =
      tapestry_decimalise($importRecord["price"]);
    }

Submitted by support on Thu, 2010-09-30 12:25

Hi Richard - that's exactly right...

Cheers,
David.
--
PriceTapestry.com

Submitted by BohemianRunner on Sun, 2010-12-19 17:06

Hello David,

when is it possible, please write me new manual for include this noVAT prices in new Distribution 12/10A. Many Thanks! :)

Submitted by support on Sun, 2010-12-19 18:58

Hi,

In the 12/10A beta, look for the following code at line 297:

    if (!$importRecord["merchant"]) return;

...and for the multi-merchant verison, REPLACE that with:

    if (!$importRecord["merchant"]) return;
    if (
       ($importRecord["merchant"] == "Example Merchant")
       ||
       ($importRecord["merchant"] == "Another Example Merchant")
       ||
       ($importRecord["merchant"] == "Another Example1 Merchant")
       )
    {
      // add VAT at 17.5% (multiply by 1.175)
      $importRecord["price"] =
      $importRecord["price"] * 1.175;
      // decimalise again to round to 2 decimal places
      $importRecord["price"] =
      tapestry_decimalise($importRecord["price"]);
    }

Cheers,
David.
--
PriceTapestry.com

Submitted by BohemianRunner on Sun, 2010-12-19 22:33

Hi David,

Thanks for quick reply. With your code i have this error: Notice: Undefined index: merchant ... i change code to:

if (!$importRecord["merchant"]) return;
    if (
       ($importRecord["merchant"] == "Example Merchant")
       ||
       ($importRecord["merchant"] == "Another Example Merchant")
       ||
       ($importRecord["merchant"] == "Another Example1 Merchant")
       )
    {
      // add VAT at 17.5% (multiply by 1.175)
      $importRecord["price"] =
      $importRecord["price"] * 1.175;
      // decimalise again to round to 2 decimal places
      $importRecord["price"] =
      tapestry_decimalise($importRecord["price"]);
    }

and script working. It is this change OK?

Submitted by support on Sun, 2010-12-19 22:37

Hi,

That's spot on! I've corrected the code above also...

Cheers,
David.
--
PriceTapestry.com

Submitted by darren on Thu, 2012-03-08 09:36

Hi David

I have just implemented this and it looks like admin.php has changed slightly in the latest revision: 12/10B
I also only needed it for one merchant and also changed the vat rate to 20% - so now I have on line 342:

if (!$importRecord["merchant"]) return;
if ($importRecord["merchant"] == "Merchant Name")
{
// add VAT at 20% (multiply by 1.20)
$importRecord["price"] =
$importRecord["price"] * 1.20;
// decimalise again to round to 2 decimal places
$importRecord["price"] =
tapestry_decimalise($importRecord["price"]);
}

It seems to work fine but thought I'd double check?

Cheers

Darren

Submitted by support on Thu, 2012-03-08 10:21

Looks fine Darren!

Cheers,
David.
--
PriceTapestry.com

Submitted by darren on Thu, 2012-03-08 11:35

Many thanks!

Submitted by sirmanu on Wed, 2018-04-25 19:41

Hi. Is it possible to have a filter for VAT?

Submitted by support on Thu, 2018-04-26 08:14

Hi,

Sure - here's code for an Add Tax filter - add to includes/filter.php:

  /*************************************************/
  /* addTax */
  /*************************************************/
  $filter_names["addTax"] = "Add Tax";
  function filter_addTaxConfigure($filter_data)
  {
    widget_textBox("Rate (%)","rate",TRUE,$filter_data["rate"],"",3);
  }
  function filter_addTaxValidate($filter_data)
  {
    if (!$filter_data["rate"])
    {
      widget_errorSet("rate","required field");
    }
  }
  function filter_addTaxExec($filter_data,$text)
  {
    $text = ($text / 100) * (100 + $filter_data["rate"]);
    return tapestry_decimalise($text);
  }

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Sat, 2018-04-28 08:51

Great! It works.