Interchange Developer Resource
[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date ][Interchange by thread ]

[ic] Sales tax in Canada : Solution .



Here is simple solution to habdle sales tax in Canada, with explaining
of tax calculation.

Usually in Canada it's required to explain tax calculation on order.

It can be useful in some areas where salex tax is complex function .


Note :
TPS: Tax on Products and Services (federal tax)
TVQ: Tax on Value added Quebec (provincial tax)
TVH: Another tax ( don't know what exactly )


Content of catalog.cfg :  based on example for Quebec .


a)  defining of SalesTaxFunction

SalesTaxFunction  <<EOR

 if ( ! defined $Values->{country} or $Values->{country} ne "CA" ) {
   return { DEFAULT => 0.0 } ;
 }

    return {
        DEFAULT => 0.0,
        AB => 0.07 ,
        BC => 0.07 ,
        MB => 0.07 ,
        NB => 0.15 ,
        NW => 0.07 ,
        NS => 0.15 ,
        NT => 0.07 ,
        ON => 0.07 ,
        PE => 0.07 ,
        QC => 0.15025 ,
        SK => 0.07 ,
        YT => 0.07
    };
EOR



b)    defining of salestax-comment    user  tag
      Now in order and report you can insert new tag  :
[salestax-comment], that will explain tax calculation .

      For example for Quebec :
      Subtotal    -   13.68 CAN
      Sales Tax   -   2.06  CAN
      Explaining  -   TPS (7%) = 0.96, TPQ (7.5%) = 1.1
      Total       -   15.74 CAN  



UserTag salestax-comment Order area
 UserTag salestax-comment Routine <<EOF
 sub {

 if ( ! defined $Values->{country} or $Values->{country} ne "CA" ) {
   return "-" ;
 }

 my $area = $Values->{state} ;

 my %hash = (

  AB  =>  sub { return "TPS (7%) "  . $Tag->salestax },
  BC  =>  sub { return "TPS (7%) "  . $Tag->salestax },
  MB  =>  sub { return "TPS (7%) "  . $Tag->salestax },
  NB  =>  sub { return "TVH (15%) " . $Tag->salestax },
  NF  =>  sub { return "TVH (15%) " . $Tag->salestax },
  NW  =>  sub { return "TPS (7%) "  . $Tag->salestax },
  NS  =>  sub { return "TVH (15%) " . $Tag->salestax },
  NT  =>  sub { return "TPS (7%) "  . $Tag->salestax },
  ON  =>  sub { return "TPS (7%) "  . $Tag->salestax },
  PE  =>  sub { return "TPS (7%) "  . $Tag->salestax },

  QC  =>  sub {
            my $tps = Vend::Util::round_to_frac_digits($Tag->subtotal *
0.07) ;
            my $ret = "TPS (7%) = $tps" ;
            $ret .= ", " ;
            my $tpq = $Tag->salestax - $tps ;
            $ret .= "TPQ (7.5%) = $tpq" ;
            return $ret ; 
          } ,
  SK  =>  sub { return "TPS (7%) " . $Tag->salestax },
  YT  =>  sub { return "TPS (7%) " . $Tag->salestax }


 ) ;

 
 if  ( defined $hash{$area} ) {
   my $subr = $hash{$area} ;
   return &$subr ;
 } else {
   return "-"  ;
 }

}
EOF



Search for: Sort by: