# Taxes

Bill contracts can be used to do people's taxes. Suppose we want to process taxes for user A who is a merchant on CanCan.&#x20;

Let's setup our Bill contract to process taxes for User A at the end of each month.

* The first step is to deploy a Bill contract (with the **Is Payable** parameter set to No since we are not going to be paying the user) like we did on this page

{% content-ref url="" %}
[]()
{% endcontent-ref %}

* Bill contracts enable you to account for all credits/debits to an account.&#x20;
* You can also add a credit factor that multiplies all the credits and a debit factor that multiplies all the debits in an equation that gives an end value which in our case will be the monthly tax.
* All taxes can be written in this format: debit\_factor \* debit - credit\_factor \* credit = tax

## Setting Up You Bill's Factors

* To setup the credit and debit factors of your bill, go your Bill contract and click on the **Details** button to reveal its panel.

<figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FgzhhPuhcdnujd9bnrXhF%2Fbill4.png?alt=media&#x26;token=96594853-9338-47c5-ad73-c410ef642679" alt=""><figcaption></figcaption></figure>

* Click on the **Control Panel** button to reveal its menu and select the **Update Migration Point** option

<div><figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2F6HeZM7aEufNDY2BZTaiu%2Fbill10.png?alt=media&#x26;token=2b5f5ac3-b344-46da-a8ab-6c75ba1b31f9" alt=""><figcaption></figcaption></figure> <figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FLrmwTjijyCv6qBE21f6o%2Fbill11.png?alt=media&#x26;token=3a98da3e-c03e-484b-aee0-25f83cf08643" alt=""><figcaption></figcaption></figure></div>

* We are setting our factors to be 100% so our monthly taxes due on an account could just be computed as all credits - all debits.&#x20;
* We will just need to update each account on all credits/debits to an account each month. That way the account owner will know at the end of each month, how much taxes he/she needs to pay.
* The next step will be for account owners to pay their taxes through the Bill contract and for the Bill admin to withdraw the paid taxes and send the funds to the IRS or whichever branch of the government is in charge of taxes in your country.

## Creating User A's Account

* The next step is to create your user's accounts. Let's create **User A**'s account then Click on the **Details** button of your Bill contract to reveal the panel

<figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FgzhhPuhcdnujd9bnrXhF%2Fbill4.png?alt=media&#x26;token=96594853-9338-47c5-ad73-c410ef642679" alt=""><figcaption></figcaption></figure>

* Since **User A** is paid in USD, let's select the USD tFIAT token. Click on the **Select a currency** button to reveal the token wizard like in the image below. Click on the **Manage Tokens** button to reveal the form on the right, activate the **PaySwap Onramp** tokens then go back to the previous form

<div><figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2Fj2WAtWdo39w4HZLzhKiI%2Framp_select_token.png?alt=media&#x26;token=c76e6e66-6409-4714-ab1c-7864e88c0c5c" alt=""><figcaption></figcaption></figure> <figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FhbjNPjYjZpydbvDdlcNQ%2Framp_select_token2.png?alt=media&#x26;token=1400cc94-4fa0-4aaa-acdd-6cbade4552bb" alt=""><figcaption></figcaption></figure></div>

* Search for and select the USD tFIAT token
* &#x20;You should now have the USD selected in the drop down field on top of your **Control Panel** button. Click on the Control Panel button to show the control panel's menu&#x20;
* Click the Create/Update Account button; fill in the form on the right image below. Make sure you read the description for each parameter in order to provide the correct value

<div><figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FfmbiPHbDO8TXMI3Q7YVK%2Fbill7.png?alt=media&#x26;token=c4ff48a7-33bb-43f4-99c7-04a9ea345a12" alt=""><figcaption></figcaption></figure> <figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FrLh4SPqwJ2pHjEuKvZqz%2Fbill5.png?alt=media&#x26;token=43541e08-815d-434f-a82e-67ddd0668012" alt=""><figcaption></figcaption></figure></div>

* We set the **Period Receivable** to the duration of a month in a minutes since we will be doing User A's taxes every month
* We also set the Start of the account to October 20th, 2023 which is when the contract start counting the **Period Receivable** from
* Lastly, we set the **Description** of our account and validate the transaction
* Reload the page and tick the Mine Only button to only show your Bill contracts (this should enable you to find your Bill contract faster)

<figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2F4DPNk6Sv9Pv9N4NfpxMI%2Fbill8.png?alt=media&#x26;token=455ec153-ae26-48f3-bbb0-31cbb202d699" alt=""><figcaption></figcaption></figure>

* Click on the Details button to reveal the panel of your Bill contract. You should be able to see at the bottom left of the panel, your account's ID. Click on the ID to display the parameters of the account like we did by clicking on our account's ID in the image below (our account ID is 1)

<figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FUtgnDtAuVYqQaUBq3ROC%2Fbill12.png?alt=media&#x26;token=84560695-e1b7-4eb9-8d91-dc8e12c4446f" alt=""><figcaption></figcaption></figure>

* Other details like the amount of tax the account owner needs to pay (which is computed with the formula: debit\_factor \* debits - credit\_factor \* credits) are available in the parameter section of the Bill contract once you select the right account. In our case, the tax amount is the Due Payable

<figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FCS9lPq2lTSC0WrTeXubR%2Fbill16.png?alt=media&#x26;token=89732552-7d20-431e-9b78-1c587442dbc5" alt=""><figcaption></figcaption></figure>

## Notifying Account Credits

* Got to your Bill contract's panel and select the account to notify by its ID available at the bottom left of your panel

<figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FUtgnDtAuVYqQaUBq3ROC%2Fbill12.png?alt=media&#x26;token=84560695-e1b7-4eb9-8d91-dc8e12c4446f" alt=""><figcaption></figcaption></figure>

* Go to your control panel's menu and select the **Notify Credit** button and fill in the **Credit Address** parameter with your own wallet address since you are the one notifying the contract. In case you are not the admin of the Bill, you should input in here the address of a contract approved to notify your Bill contract of Credit & Bill operations. Also enter the amount of the credit; this is in the currency of the account being notified.

<div><figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2F4JSir0WqcFVOMhKoou8t%2Fbill13.png?alt=media&#x26;token=778d97f7-1f4f-4cfe-bd9b-d1c4dccb4ae8" alt=""><figcaption></figcaption></figure> <figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FZg0by3bM2ywTBn4YdzNz%2Fbill14.png?alt=media&#x26;token=746bedeb-df92-41e6-a275-3362227e3a56" alt=""><figcaption></figcaption></figure></div>

* Validate and confirm the operation. You should see the update reflected in the parameter section of your Bill contract once you select your account's ID



## Notifying Account Debits

* Got to your Bill contract's panel and select the account to notify by its ID available at the bottom left of your panel

<figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FUtgnDtAuVYqQaUBq3ROC%2Fbill12.png?alt=media&#x26;token=84560695-e1b7-4eb9-8d91-dc8e12c4446f" alt=""><figcaption></figcaption></figure>

* Go to your control panel's menu and select the **Notify Debit** button and fill in the **Debit Address** parameter with your own wallet address since you are the one notifying the contract. In case you are not the admin of the Bill, you should input in here the address of a contract approved to notify your Bill contract of Credit & Bill operations. Also enter the amount of the debit; this is in the currency of the account being notified.

<div><figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2F4JSir0WqcFVOMhKoou8t%2Fbill13.png?alt=media&#x26;token=778d97f7-1f4f-4cfe-bd9b-d1c4dccb4ae8" alt=""><figcaption></figcaption></figure> <figure><img src="https://1098290585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgbtC1OtK6WPXJAWRcR%2Fuploads%2FTHLlhZKgIGN6JwefyZDZ%2Fbill15.png?alt=media&#x26;token=29e155c2-98ed-48f4-abcc-4d58537426cf" alt=""><figcaption></figcaption></figure></div>

* Validate and confirm the operation. You should see the update reflected in the parameter section of your Bill contract once you select your account's ID
