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 permettant d'afficher des données complètes sur les taxes en Visual Basic .NET (VB .NET) :
- Module Module1
-
- Sub Main()
- Dim Compute() As Char = {"C", "C", "C", "C", "S", "C", "S", "S", "S", "S", "C", "S", "S"}
- Dim TaxName1() As String = {"TPS", "TVH", "TVH", "TVH", "TPS", "TVH", "TPS", "TVH", "TVH", "TPS", "TPS", "TPS", "TVH"}
- Dim TaxRate1() As Double = {6.0, 14.0, 14.0, 14.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0}
- Dim TaxName2() As String = {"TVQ", "", "", "", "TVP", "", "TVP", "", "", "TVP", "TVP", "TVP", ""}
- Dim TaxRate2() As Double = {7.5, 0.0, 0.0, 0.0, 7.0, 0.0, 7.0, 0.0, 0.0, 8.0, 10.0, 7.0, 0.0}
- Dim RegionMID() As String = {"QC", "NS", "NB", "NF", "BC", "AB", "MB", "NT", "NU", "ON", "PE", "SK", "YT"}
- Dim RegionName_EN() As String = {"Quebec", "Nova Scotia", "New Brunswick", "Newfoundland", "British Columbia", "Alberta", "Manitoba", "Northwest Territories", "Nunavut", "Ontario", "Prince Edward Island", "Saskatchewan", "Yukon Territory"}
- Dim RegionName_FR() As String = {"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"}
- Dim I As Integer
-
- Console.WriteLine("Nom de la province/territoire MID Taxe 1 Taxe 2 Taux")
- For I = 0 To Compute.Length - 1
- Console.Write(Empattement(RegionName_FR(I), 31))
- Console.Write(Empattement(RegionMID(I), 5))
- Console.Write(TaxName1(I) & ":" & TaxRate1(I) & "%" & " ")
- If TaxName2(I) = "" Then
- Console.Write(Empattement("", 10))
- Else
- Console.Write(Empattement(TaxName2(I) & ":" & TaxRate2(I) & "%", 10))
- End If
- Select Case Compute(I)
- Case "S" 'Séparé
- Console.Write(TaxRate1(I) + TaxRate2(I) & "%" & " ")
- Case "C" 'Composé
- Console.Write(TaxRate1(I) + ((TaxRate2(I) * (100 + TaxRate1(I))) / 100) & "%" & " ")
- End Select
- Console.WriteLine()
- Next
- End Sub
-
- Function Empattement(ByVal Chaine As String, ByVal Espace As Integer) As String
- Dim I As Integer
- Dim L As Integer = Espace - Chaine.Length
- For I = 0 To L - 1
- Chaine &= " "
- Next
- Return Chaine
- End Function
-
- End Module
on obtiendra le résultat suivant :
Nom de la province/territoire | MID | Taxe 1 | Taxe 2 | Taux |
Québec | QC | TPS:6% | TVQ:7.5% | 13.95% |
Nouvelle-Écosse | NS | TVH:14% | 14% | |
Nouveau-Brunswick | NB | TVH:14% | 14% | |
Terre-Neuve/Labrador | NF | TVH:14% | 14% | |
Colombie-Britanique | BC | TPS:6% | TVP:7% | 13% |
Alberta | AB | TVH:6% | 6% | |
Manitoba | MB | TPS:6% | TVP:7% | 13% |
Territoire du Nord Ouest | NT | TVH:6% | 6% | |
Nunavut | NU | TVH:6% | 6% | |
Ontario | ON | TPS:6% | TVP:8% | 14% |
Ile-du-Prince-Édouard | PE | TPS:6% | TVP:10% | 16.6% |
Saskatchewan | SK | TPS:6% | TVP:7% | 13% |
Territoire du Yukon | YT | TVH:6% | 6% |
Ensuite, voici un deuxième exemple permettant de calculer la taxe de vente d'un produit ou service en fonction des provinces ou territoires en Visual Basic .NET (VB .NET) :
- Module Module1
-
- Sub Main()
- Dim Compute() As Char = {"C", "C", "C", "C", "S", "C", "S", "S", "S", "S", "C", "S", "S"}
- Dim TaxName1() As String = {"TPS", "TVH", "TVH", "TVH", "TPS", "TVH", "TPS", "TVH", "TVH", "TPS", "TPS", "TPS", "TVH"}
- Dim TaxRate1() As Double = {6.0, 14.0, 14.0, 14.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0, 6.0}
- Dim TaxName2() As String = {"TVQ", "", "", "", "TVP", "", "TVP", "", "", "TVP", "TVP", "TVP", ""}
- Dim TaxRate2() As Double = {7.5, 0.0, 0.0, 0.0, 7.0, 0.0, 7.0, 0.0, 0.0, 8.0, 10.0, 7.0, 0.0}
- Dim RegionMID() As String = {"QC", "NS", "NB", "NF", "BC", "AB", "MB", "NT", "NU", "ON", "PE", "SK", "YT"}
- Dim RegionName_EN() As String = {"Quebec", "Nova Scotia", "New Brunswick", "Newfoundland", "British Columbia", "Alberta", "Manitoba", "Northwest Territories", "Nunavut", "Ontario", "Prince Edward Island", "Saskatchewan", "Yukon Territory"}
- Dim RegionName_FR() As String = {"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"}
- Dim I As Integer
-
- Console.WriteLine("Nom de la province/territoire Taxe 1 Taxe 2 Taux 1$ 15$ 44,95$ 100$")
- For I = 0 To Compute.Length - 1
- Dim Tax As Double = 0
- Console.Write(Empattement(RegionName_FR(I), 31))
- Console.Write(TaxName1(I) & ":" & TaxRate1(I) & "%" & " ")
- If TaxName2(I) = "" Then
- Console.Write(Empattement("", 10))
- Else
- Console.Write(Empattement(TaxName2(I) & ":" & TaxRate2(I), 10))
- End If
- Select Case Compute(I)
- Case "S" 'Séparé
- Tax = TaxRate1(I) + TaxRate2(I)
- Case "C" 'Composé
- Tax = TaxRate1(I) + ((TaxRate2(I) * (100 + TaxRate1(I))) / 100)
- End Select
- Console.Write((Tax) & "%" & " ")
- Console.Write((1 * (1 + (Tax / 100))) & "$ ")
- Console.Write((15 * (1 + (Tax / 100))) & "$ ")
- Console.Write((44.95 * (1 + (Tax / 100))) & "$ ")
- Console.Write((100 * (1 + (Tax / 100))) & "$ ")
- Console.WriteLine()
- Next
- End Sub
-
- Function Empattement(ByVal Chaine As String, ByVal Espace As Integer) As String
- Dim I As Integer
- Dim L As Integer = Espace - Chaine.Length
- For I = 0 To L - 1
- Chaine &= " "
- Next
- Return Chaine
- End Function
-
- End Module
on obtiendra le résultat suivant :
Nom de la province/territoire | Taxe 1 | Taxe 2 | Taux | 1$ | 15$ | 44,95$ | 100$ |
Québec | TPS:6% | TVQ:7.5% | 13.95% | 1.1395$ | 17.0925$ | 51.220525$ | 113.95$ |
Nouvelle-Écosse | TVH:14% | 14% | 1.14$ | 17.1$ | 51.243$ | 114$ | |
Nouveau-Brunswick | TVH:14% | 14% | 1.14$ | 17.1$ | 51.243$ | 114$ | |
Terre-Neuve/Labrador | TVH:14% | 14% | 1.14$ | 17.1$ | 51.243$ | 114$ | |
Colombie-Britanique | TPS:6% | TVP:7% | 13% | 1.13$ | 16.95$ | 50.7935$ | 113$ |
Alberta | TVH:6% | 6% | 1.06$ | 15.9$ | 47.647$ | 106$ | |
Manitoba | TPS:6% | TVP:7% | 13% | 1.13$ | 16.95$ | 50.7935$ | 113$ |
Territoire du Nord Ouest | TVH:6% | 6% | 1.06$ | 15.9$ | 47.647$ | 106$ | |
Nunavut | TVH:6% | 6% | 1.06$ | 15.9$ | 47.647$ | 106$ | |
Ontario | TPS:6% | TVP:8% | 14% | 1.14$ | 17.1$ | 51.243$ | 114$ |
Ile-du-Prince-Édouard | TPS:6% | TVP:10% | 16.6% | 1.166$ | 17.49$ | 52.4117$ | 116.6$ |
Saskatchewan | TPS:6% | TVP:7% | 13% | 1.13$ | 16.95$ | 50.7935$ | 113$ |
Territoire du Yukon | TVH:6% | 6% | 1.06$ | 15.9$ | 47.647$ | 106$ |
Dernière mise à jour : Samedi, le 22 octobre 2016