Caliber Technology LLC logo Caliber Technology LLC

Login




Not logged in Log in

Here we take you through the first steps in using TaxControls in your application. (Be sure to select the proper platform for your environment.)

Set up the environment

  1. Download the .NET component from here.
  2. Two methods can be used to compile and execute code on the .NET platform: Microsoft's Visual Studio .NET, and the Mono project. For this tutorial, we will use the command-line tools available with Visual Studio 2022.

  3. Open a command-line window.
  4. Click the Windows Start button, then select Visual Studio 2022, then Developer Command Prompt for VS 2022.

  5. In the resulting command prompt, type the following:
  6. csc /version

    You should see output similar to this if your environment is set up correctly:

    4.0.1-1.21568.1 (6ab66011)
  7. Create a project directory.
  8. We're using the name "TaxDemo" under the user's home directory:

    cd %HOMEPATH%
    mkdir TaxDemo
    cd TaxDemo

Instantiate the TaxControls object

  1. Create and test the object.
  2. In your project directory, create a new file called 'Instantiate.cs'. Enter the following code and save the file:

    using System;
    using TaxControls;
    class Instantiate {
      public static voic Main() {
          CTaxControl tc = new CTaxControl();
          Console.WriteLine(tc.SoftwareVersion);
      }
    }
  3. Compile the code.
  4. At the command prompt enter:

    csc /reference TaxControls.dll Instantiate.cs
  5. Run the code.
  6. At the command prompt enter:

    Instantiate.exe

    The program should print a version number for TaxControls on the console.

Compute a withholding amount

  1. Enter the following code into a file named 'Compute.cs':
  2. using System;
    using TaxControls;
    class Compute {
      public static void Main() {
          CTaxControl tc = new CTaxControl();
          tc.DataFilename = "demo.tax";
          try {
            tc.SelectedTax = "federal income tax";
            tc.Earnings = 2000.00;
            Console.WriteLine(tc.TaxAmount());
          } catch(TaxControlException e) {
            Console.WriteLine(e);
          }
      }
    }
  3. Compile the code.
  4. At the command prompt enter:

    csc /reference TaxControls.dll Compute.cs
  5. Run the code.
  6. At the command prompt enter:

    Compute.exe

    The program should print a computed withholding amount on the console, which you can check against an online payroll calculator such as NanoCalc using the same earnings, selecting Monthly payroll, and checking the "2020 W-4" field. Results should match those labelled "Federal tax".

List all tax names

  1. Enter the following code into a file named 'List.cs':
  2. using System;
    using System.Collections;
    using TaxControls;
    class List {
      public static void Main() {
          CTaxControl tc = new CTaxControl();
          tc.DataFilename = "demo.tax";
          try {
            Taxes txs = tc.Taxes;
            IEnumerator inr = txs.GetEnumerator();
            while(inr.MoveNext())  {
              Tax t = (Tax) inr.Current;
              Console.WriteLine(t.Name);
            }
          } catch(TaxControlException e) {
            Console.WriteLine(e);
          }
      }
    }
  3. Compile the code.
  4. At the command prompt enter:

    csc /reference TaxControls.dll List.cs
  5. Run the code.
  6. At the command prompt enter:

    List.exe

    The program should print many tax names to the console.

List state tax names

  1. Enter the following code into a file named 'States.cs':
  2. using System;
    using System.Collections;
    using TaxControls;
    class States {
      public static void Main() {
          CTaxControl tc = new CTaxControl();
          tc.DataFilename = "demo.tax";
          try {
            Taxes txs = tc.Taxes;
            IEnumerator inr = txs.GetEnumerator();
            while(inr.MoveNext())  {
              Tax t = (Tax) inr.Current;
              if (t.TaxType == "S") {
                Console.WriteLine(t.Name);
              }
            }
          } catch(TaxControlException e) {
            Console.WriteLine(e);
          }
      }
    }
  3. Compile the code.
  4. At the command prompt enter:

    csc /reference TaxControls.dll States.cs
  5. Run the code.
  6. At the command prompt enter:

    States.exe

    The program should print state tax names to the console.

Look up taxes for a ZIP code

  1. Enter the following code into a file named 'Zip.cs':
  2. using System;
    using TaxControls;
    class Zip {
      public static void Main() {
          CTaxControl tc = new CTaxControl();
          tc.DataFilename = "demo.tax";
          try {
            // Employee lives and works in Ohio:
            String s = tc.TaxNamesForZip(44139, 44145);
            Console.WriteLine(s);
          } catch(TaxControlException e) {
            Console.WriteLine(e);
          }
      }
    }
  3. Compile the code.
  4. At the command prompt enter:

    csc /reference TaxControls.dll Zip.cs
  5. Run the code.
  6. At the command prompt enter:

    Zip.exe

    The program should print a comma-delimited string of tax names on the console. Note that Federal and Social Security taxes apply regardless of ZIP code, and are not returned by TaxNamesForZip().

Because ZIP code boundaries do not generally align well with tax jurisdiction boundaries, we recommend the use of the TaxQuery container, which uses employee workplace and residence addresses to identify relevant tax names.