Section courante

A propos

Section administrative du site

Le Canada est sans doute l'un des pays ou les taxes de vente sur les produits et services sont les plus compliqués à appliquer. Et pour cause: Elle varie d'une province ou territoire à l'autre, elle est parfois composé ou séparé. Voici leur représentation en date du mois septembre de l'année 2006:

Province/Territoire Taxe 1 Taxe 2 Taux
Alberta TVH: 6% Aucune 6%
Colombie-Britannique TVH: 6% TVP: 7% 13%
Ile-du-Prince-Édouard TPS: 6% TVP: 10% 16.6%
Manitoba TPS: 6% TVP: 7% 13%
Nouveau-Brunswick TVH: 14% Aucune 14%
Nouvelle-Écosse TVH: 14% Aucune 14%
Nunavut TVH: 6% Aucune 6%
Ontario TPS: 6% TVP: 8% 14%
Québec TPS: 6% TVQ: 7.5% 13.95%
Saskatchewan TPS: 6% TVP: 7% 13%
Terre-Neuve/Labrador TVH: 14% Aucune 14%
Territoire du Nord Ouest TVH: 6% Aucune 6%
Territoire du Yukon TVH: 6% Aucune 6%

Tout d'abord, voici un premier exemple permet d'afficher des données complètes sur les taxes en Ruby:

Essayer maintenant !
  1. compute=['C','C','C','C','S','C','S','S','S','S','C','S','S']
  2. taxName1=["TPS","TVH","TVH","TVH","TPS","TVH","TPS","TVH","TVH","TPS","TPS","TPS","TVH"]
  3. taxRate1=[6.0000,14.0000,14.0000,14.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000]
  4. taxName2=["TVQ","","","","TVP","","TVP","","","TVP","TVP","TVP",""]
  5. taxRate2=[7.5000,0.0000,0.0000,0.0000,7.0000,0.0000,7.0000,0.0000,0.0000,8.0000,10.0000,7.0000,0.0000]
  6. regionMID=["QC","NS","NB","NF","BC","AB","MB","NT","NU","ON","PE","SK","YT"]
  7. regionName_EN=["Quebec","Nova Scotia","New Brunswick","Newfoundland","British Columbia","Alberta","Manitoba","Northwest Territories","Nunavut","Ontario","Prince Edward Island","Saskatchewan","Yukon Territory"]
  8. regionName_FR=["Québec","Nouvelle-Écosse","Nouveau-Brunswick","Terre-Neuve/Labrador","Colombie-Britanique","Alberta","Manitoba","Territoire du Nord Ouest","Nunavut","Ontario","Ile-du-Prince-Édouard","Saskatchewan","Territoire du Yukon"]
  9.          
  10. def Empattement(chaine,espace)
  11.     i=0
  12.     l=espace-chaine.length
  13.     while i<l
  14.         chaine=chaine+" "
  15.         i=i+1
  16.     end
  17.     return chaine
  18. end
  19.  
  20. print "Nom de la province/territoire MID Taxe 1 Taxe 2 Taux\n"
  21. i=0
  22. while i<compute.length
  23.      print Empattement(regionName_FR[i],31)
  24.      print Empattement(regionMID[i],5)
  25.      print taxName1[i] + ":" + String(taxRate1[i]) + "%" + "\t"
  26.      if taxName2[i]==""
  27.           print Empattement("",10)
  28.      else
  29.         print Empattement(taxName2[i] + ":" + String(taxRate2[i]),10)
  30.      end
  31.      case compute[i]
  32.           when 'S' then #Séparé
  33.              print String(taxRate1[i]+taxRate2[i]) + "%" + "\t"
  34.         when 'C' then #Composé
  35.                 print String(taxRate1[i]+((taxRate2[i]*(100+taxRate1[i]))/100)) + "%" + "\t"
  36.      end
  37.      print "\n"
  38.      i=i+1
  39.  end

on obtiendra le résultat suivant:

Nom de la province/territoireMIDTaxe 1Taxe 2Taux
QuébecQCTPS:6%TVQ:7.5%13.95%
Nouvelle-ÉcosseNSTVH:14% 14%
Nouveau-BrunswickNBTVH:14% 14%
Terre-Neuve/LabradorNFTVH:14% 14%
Colombie-BritaniqueBCTPS:6%TVP:7%13%
AlbertaABTVH:6% 6%
ManitobaMBTPS:6%TVP:7%13%
Territoire du Nord OuestNTTVH:6% 6%
NunavutNUTVH:6% 6%
OntarioONTPS:6%TVP:8%14%
Ile-du-Prince-ÉdouardPETPS:6%TVP:10%16.6%
SaskatchewanSKTPS:6%TVP:7%13%
Territoire du YukonYTTVH:6% 6%

Ensuite, voici un deuxième exemple permet de calculer la taxe de vente d'un produit ou service en fonction des provinces ou territoires en Ruby:

Essayer maintenant !
  1. compute=['C','C','C','C','S','C','S','S','S','S','C','S','S']
  2. taxName1=["TPS","TVH","TVH","TVH","TPS","TVH","TPS","TVH","TVH","TPS","TPS","TPS","TVH"]
  3. taxRate1=[6.0000,14.0000,14.0000,14.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000,6.0000]
  4. taxName2=["TVQ","","","","TVP","","TVP","","","TVP","TVP","TVP",""]
  5. taxRate2=[7.5000,0.0000,0.0000,0.0000,7.0000,0.0000,7.0000,0.0000,0.0000,8.0000,10.0000,7.0000,0.0000]
  6. regionMID=["QC","NS","NB","NF","BC","AB","MB","NT","NU","ON","PE","SK","YT"]
  7. regionName_EN=["Quebec","Nova Scotia","New Brunswick","Newfoundland","British Columbia","Alberta","Manitoba","Northwest Territories","Nunavut","Ontario","Prince Edward Island","Saskatchewan","Yukon Territory"]
  8. regionName_FR=["Québec","Nouvelle-Écosse","Nouveau-Brunswick","Terre-Neuve/Labrador","Colombie-Britanique","Alberta","Manitoba","Territoire du Nord Ouest","Nunavut","Ontario","Ile-du-Prince-Édouard","Saskatchewan","Territoire du Yukon"]
  9.          
  10. def Empattement(chaine,espace)
  11.     i=0
  12.     l=espace-chaine.length
  13.     while i<l
  14.         chaine=chaine+" "
  15.         i=i+1
  16.     end
  17.     return chaine
  18. end
  19.  
  20. print "Nom de la province/territoire Taxe 1 Taxe 2 Taux 1$\t15$\t44,95$\t100$\n"
  21. i=0
  22. while i<compute.length
  23.     tax = 0
  24.     print Empattement(regionName_FR[i],31)
  25.     print taxName1[i] + ":" + String(taxRate1[i]) + "%" + "\t"
  26.     if taxName2[i]==""
  27.          print Empattement("",10)
  28.     else
  29.          print Empattement(taxName2[i] + ":" + String(taxRate2[i]),10)
  30.     end
  31.     case compute[i]
  32.          when 'S' then #Séparé
  33.              tax = taxRate1[i]+taxRate2[i]
  34.          when 'C' then #Composé
  35.              tax = taxRate1[i]+((taxRate2[i]*(100+taxRate1[i]))/100)
  36.     end
  37.     print String(tax) + "%" + "\t"
  38.     print String(1*(1+(tax/100))) + "$\t"
  39.     print String(15*(1+(tax/100))) + "$\t"
  40.     print String(44.95*(1+(tax/100))) + "$\t"
  41.     print String(100*(1+(tax/100))) + "$\t"
  42.     print "\n"
  43.     i=i+1
  44. end

on obtiendra le résultat suivant:

Nom de la province/territoireTaxe 1Taxe 2Taux1$15$44,95$100$
QuébecTPS:6%TVQ:7.5%13.95%1.1395$17.0925$51.220525$113.95$
Nouvelle-ÉcosseTVH:14% 14%1.14$17.1$51.243$114$
Nouveau-BrunswickTVH:14% 14%1.14$17.1$51.243$114$
Terre-Neuve/LabradorTVH:14% 14%1.14$17.1$51.243$114$
Colombie-BritaniqueTPS:6%TVP:7%13%1.13$16.95$50.7935$113$
AlbertaTVH:6% 6%1.06$15.9$47.647$106$
ManitobaTPS:6%TVP:7%13%1.13$16.95$50.7935$113$
Territoire du Nord OuestTVH:6% 6%1.06$15.9$47.647$106$
NunavutTVH:6% 6%1.06$15.9$47.647$106$
OntarioTPS:6%TVP:8%14%1.14$17.1$51.243$114$
Ile-du-Prince-ÉdouardTPS:6%TVP:10%16.6%1.166$17.49$52.4117$116.6$
SaskatchewanTPS:6%TVP:7%13%1.13$16.95$50.7935$113$
Territoire du YukonTVH:6% 6%1.06$15.9$47.647$106$


Dernière mise à jour : Dimanche, le 23 novembre 2014