Tutorials > Tutorial 12 - Tax Calculations with TDBFinancialX |
This tutorial shows how to use the TaxType property to determine whether the Value property represents the desired total after the tax is calculated thus yielding the pre-tax total, or whether it represents the pre-tax amount yielding an after-tax total when invoking the TaxCalc method. The results can be retrieved from the Price, Tax, and the Total properties.
Start a new project.
From the Visual Basic Project menu, select References, then check the box labeled ComponentOne True DBFinancialX 8.0. Click OK to add the TDBFinancialX object to the project.
Place a ListBox (List1) on the form (Form1) as shown in the following figure.
We will use code to calculate the financial information that is displayed to the ListBox.
Example Title |
Copy Code
|
---|---|
Private Sub Form_Load() Dim objTax As New TDBFinancialX6Lib.TDBFinancialX Dim bRet As Boolean With objTax .Value = 450.755 .TaxRate = 5.5 ' After Tax. .TaxType = dbiAfterTax .RateType = dbiRatePercentage .RoundType = dbiRound .RoundDigit = -2 bRet = .TaxCalc() If bRet Then List1.AddItem "Price: " & .Price List1.AddItem "Tax: " & .Tax List1.AddItem "Total: " & .Total List1.AddItem "------------------------------" End If End With ' If set to 1-After Tax, the Price property will return the Value property, the Tax property is calculated as (Value * (TaxRate / 100)), and the Total property is calculated as (Value + Tax). With objTax .Value = 450.755 .TaxRate = 5.5 ' Pretax. .TaxType = dbiPreTax .RateType = dbiRatePercentage .RoundType = dbiRound .RoundDigit = -2 bRet = .TaxCalc() If bRet Then List1.AddItem "Price: " & .Price List1.AddItem "Tax: " & .Tax List1.AddItem "Total: " & .Total List1.AddItem "------------------------------" End If End With End Sub |
Observe the values in the ListBox against those in the comments section.
Note that when the RateType property is set to 0-Normal, the percentage calculation will be omitted
This concludes Tutorial 12.