Support for Value Added Tax (VAT)

Contrib type: 
Module
Status: 
Abandoned

Downloads

Latest version: 
1.0
Compatibility: 
Ubercart 1.x

Abandonned : see the Add tax to product price module for support.

(*This was posted by olav@drupal.org and will be restored to him when he comes back around.)

This module supports VAT as needed for shops in (at least) Europe. It assumes that products are maintained with their gross prices and allows to assign one of a defined set of VAT rates to each product. During checkout, for each rate, the resulting tax amount is shown.

Related threads: 

PreviewAttachmentSize
uc_vat_1.0.tar14.5 KB
ali
ali's picture
Offline
Joined: 08/12/2007
Juice: 9
user warning, please help

Hi, ubercart sucesfully instaled, everything ok, but after enabled VAT module, i have an error:

user warning: Unknown column 'rate' in 'field list' query: select rate from uc_vat where nid=1 and vid=1 in /data/web/du-sk.com/web/includes/database.mysql.inc on line 172.

I am not very good in php, but i think the path "/data/web/du-sk.com/web/includes/database.mysql.inc" can be wrong... it should be "/data/web/du-sk.com/includes/database.mysql.inc"
how can i fix it?

michels's picture
Offline
Uber DonorBug FinderInternationalizationizer
Joined: 08/12/2007
Juice: 205
Alter Table

Hey Ali.

Problem is, that there's missing the row 'rate' in the mysql-table uc_vat.
You can fix that with the SQL-statement "ALTER TABLE `uc_vat` ADD `rate` INT( 11 ) NOT NULL ;"

Then the error isn't displayed anymore. But, after a first look, it seems, that the module still don't work correctly.

Any help welcome.

Edit: Sorry, it works fine after altering the table with the row "rate" (see sql-statement above).
Thanks a lot for that module!

ali
ali's picture
Offline
Joined: 08/12/2007
Juice: 9
Re: Alter Table

thanks, i did it before 5 minutes Smiling
VAT is displayed, after you add an item, and click on "checkout".

there is a pane displayed:
VAT contained in order
19,0% VAT $478.99

but i think it would be nice to have VAT also in Order total preview

Something like this:
Subtotal: $2,521.01
19,0% VAT: $478.99
Order total: $3,000.00

And, for better funcionality of this module, shop admin have to be able to see amout without tax and with tax also when he add a product.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15453
Re: Alter Table

I looked in olav's install file, and he had provided that query in an update function but forgot to tweak the install function. I've changed this and re-uploaded the file.

michels's picture
Offline
Uber DonorBug FinderInternationalizationizer
Joined: 08/12/2007
Juice: 205
Wrong calculation

The formula for calculating the VAT [price * qty * rate / (100 + rate)] is wrong, isn't it?

You must replace the line
+= $item->price * $item->qty * $rate / (100 + $rate);
with
+= $item->price * $item->qty * $rate / (100);

I will also try to add some more features to the Module in the next few days. But I'm just a silly noob in programming drupal modules, so please be patient (and hope the weather will be bad, so that I have the time to read those drupalbooks)

And before I start coding: Is this the only module for displaying VAT? I don't want to do needless work.

greetings from germany!

EDIT: Sorry, that was wrong... Calculation is right, cause you calculate the vat IN the price.

Mog
Mog's picture
Offline
Internationalizationizer
Joined: 08/16/2007
Juice: 160
amelioration with hook_line_item

Thanks for this useful module, here is my suggestion :
i saw you try to add "hook_line_item" but doesn't seems to work, but it would be a better integration than make a pane, here is my code (update, better way and show on bill):

<?php

/**
* Implementation of hook_line_item
*/
function uc_vat_line_item() {
 
$items[] = array(
   
'id' => 'vat',
   
'title' => t('VAT'),
   
'weight' => 2,
   
'default' => FALSE,
   
'stored' => FALSE,
   
'calculated' => FALSE,
   
'display_only' => TRUE,
   
'callback' => 'uc_vat_item_vat',
  );
  return
$items;
}
function
uc_vat_item_vat($op, $order) {
  switch (
$op) {
    case
'display':
   
$vat_items = uc_vat_calculate($order->products);
   
$vat_amount = 0;
    foreach (
$vat_items as $rate => $vat) {
       
$vat_name = $vat['name'];
       
$vat_amount += $vat['amount'];
    }
   
$lines[] = array(
       
'id' => 'vat',
       
'title' => t('contains ').$vat_name,
       
'amount' => $vat_amount,
        );
   
$lines[] = array(
       
'id' => 'total_no_vat',
       
'title' => t('Total without VAT'),
       
'amount' => $order->order_total-$vat_amount,
        );
    return
$lines;
    break;
   
    case
'cart-preview':
   
$vat_items = uc_vat_calculate($order);
   
$vat_amount = 0;
    foreach (
$vat_items as $rate => $vat) {
       
$vat_name = $vat['name'];
       
$vat_amount += $vat['amount'];
    }
    foreach (
$order as $item) {
       
$total += ($item->qty) ? $item->qty * $item->price : $item->price;
    }
   
$total = $total-$vat_amount;
    if (
$vat_amount > 0) {
   
drupal_add_js("\$(document).ready( function() { set_line_item('subtotal', '". t('Total without VAT') ."', ". $total .", -1); } );", 'inline');
   
drupal_add_js("\$(document).ready( function() { set_line_item('taxe', '". $vat_name ."', ". $vat_amount .", 0); } );", 'inline');
    }
    break;
  }
}
?>

it works, but sometimes, on checkout page, need some refresh to get good line, saw post about this, i'll look tomorow.

ali
ali's picture
Offline
Joined: 08/12/2007
Juice: 9
Re: amelioration with hook_line_item

i am not sure how to add or replace this code in module...

Mog
Mog's picture
Offline
Internationalizationizer
Joined: 08/16/2007
Juice: 160
hook_line_item / details

You can place it line 130 (there is coment line of hook_line_item), and so you can remove (or just coment) hook pane function, line 174 to 221.

michels's picture
Offline
Uber DonorBug FinderInternationalizationizer
Joined: 08/12/2007
Juice: 205
Hey Mog. Seems to be good.

Hey Mog.

Seems to be good. Thanks for the work.
But the code has one problem: It doesn't consider the shipping cost and other generic line-items.
Maybe you can try to change this.

Just a hint:
Instead of:

<?php
    $vat_items
= uc_vat_calculate($order->products);
   
$vat_amount = 0;
    foreach (
$vat_items as $rate => $vat) {
       
$vat_name = $vat['name'];
       
$vat_amount += $vat['amount'];
    }
?>

use something like this:

<?php
$vat_value
= 19; //VAT of your country  @todo:Considering different VAT values
$total = uc_order_get_total($order);
$vat = $total * $vat_value / (100 + $vat_value);
?>

It's dirty. But it works (just tested on the checkout-review page).

greetings mic

flebas's picture
Offline
Bug Finder
Joined: 09/02/2007
Juice: 18
TTC display

I have installed module ans french translation.
No probleme with tables, I have created VAT rates without problem.
After editing some products, I have the word "TTC" (french abriviation for "with taxes") added before the SKU, without space.
How can I change this display, I think it should be better near price.

Frederic

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1195
Re: TTC display

I tested the module, it is very usefull for european shop. Thanks

If I can suggest a new feature, it coule be really great to add a role and a country selection to apply a VAT. Why ?

Because, in the case of a shop that sell to personal and professionnal people all over the world, the following rules apply :

In my example, the shop is based in an European Union country...

  • If you sell products to personal people all over the world, you have to include the VAT, so, actually, the module works well for this case.
  • However, if you sell to professionnal people, the rules are more complex :
    • If the professionnal is in the country of the shop, you apply the VAT
    • If the professionnal is not in the country of the shop, you don't apply the VAT

That's why it could be great to provide a role and a country selection to be able to configure the VAT without hacking the module.

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1195
VAT number

As I say in this post, in Europe, company have an unique VAT number that have to figure on all invoices.

I'm working on the modification of the VAT module to allow 2 things :

  • Store the store VAT number and create a [store-vat] token to allow the display of this number on the invoice template system
  • To ask the customer VAT number on the checkout billing information pane (because if you sell products to another professionnal, both VAT number (your store and his store) have to figure on the invoice)

Edit : The first step is pretty finished.

Edit 2 : For the second step, I think it could be great to provide in the administration page the possibility to check or uncheck if you want to see the VAT number field on the checkout billing pane. I don't know if my developpers skill will allow that. See this post to provide your suggestions, help etc...

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1195
Re: amelioration with hook_line_item

Mog, does your work on the hook_line_item progress ?

I'm improving VAT module and I would like to implement your possibility. I pass a couple of hours to try to find why, sometimes, you need to refresh page to get good lines.

I don't find PHP problem, it seems to come from set_line_item javascript function...

intersol's picture
Offline
Bug Finder
Joined: 10/04/2007
Juice: 35
not compatible with alpha7d

It seams that the module does not work with alpha7d

Fatal error: Call to undefined function uc_cart_checkout_new_pane() in /var/www/html/drupal/sites/all/modules/uc_vat/uc_vat.module on line 196

Any update?

PS. It seams that module is not in any repository?!

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1195
Re: not compatible with alpha7d

You can see on the related thread how to make it compatible with newest version of Ubercart.

I think I will not support this module anymore for several reasons discuted in several others thread about the VAT :

  • My deadlines is very close and I need to put 100% of my brain on others module I need
  • The Taxe do a similar job to the VAT module, you can set different tax for different product classes etc... The only things that the VAT module do is to show VAT on checkout pane
  • The VAT module need a big changement to allow to manage and put product prices without VAT on your shop to have "not wrong" google analytic reports etc...

Instead of working on VAT module, I will work on a module that allow to put price with VAT when you put your sell price without VAT. But I think it will be another module that the VAT module.

mike-green's picture
Offline
Joined: 10/01/2008
Juice: 8
Re: Support for Value Added Tax (VAT)

Updated for newer Ubercart.

AttachmentSize
uc_vat.zip 6.27 KB
thebigwave's picture
Offline
Joined: 10/06/2008
Juice: 19
Can it be used for handling USA taxes?

I have a unique problem handling taxes that I posted here: http://www.ubercart.org/forum/support/6603/sales_tax_ma_only_part_produc...

Since taxes for certain of my products have to happen on a product-basis rather an an order-basis, I was wondering if this module might be better suited to attack it. Thoughts? Any help greatly appreciated!

Live sites:
, more on the way...

mattyt's picture
Offline
Joined: 12/02/2008
Juice: 44
Module apparently not supported any more?

deleted comment!

mattyt's picture
Offline
Joined: 12/02/2008
Juice: 44
In response to Mikes VAT module

This module does work with drupal 5.12 and ubercart 1.6 - however does not utilise the existing tax module (based on workflow) for calculating costs.

You are required to supply a tax amount and then your pages say "includes x% tax". A seperate (and confusing) block is added to the checkout page containing the taxable amount.

Finally - existing produts must be edited to have the tax applied.

It is essential that we keep the price supplied to our stores tax free - and tax is applied to the user. This allows us to display prices including tax or excluding tax (or both). When our tax changes (how topical) our store will automatically update all our prices.

For most countries there are multiple taxable products. In the uk, for example, shoes are not a taxable item, but fuel is taxed at nearly 75%.
This means that tax can be applied at a seperate rate to each product. The ideal solution requires an update to the core tax module allowing each product to have its own tax "band", and then the option to display prices with or without tax (or both).

A simple report would then show the amount of tax paid/payable a month.

joachimdesa's picture
Offline
Joined: 09/01/2009
Juice: 98
Re: Support for Value Added Tax (VAT)

Helllo i use this module, im really happy with it,
it saves my life...
i'd like to know if there is a way to make it works with price_per_role
http://drupal.org/project/uc_price_per_role
the price i enter for special roles do not include VAT, i have to make the math to mak it ok on checkout

thanks to all