Tax Calculations
From PhpCOIN Documentation
Contents |
phpCOIN and Taxes
phpCOIN can handle one or two taxes, and can calculate the tax(es) in a variety of ways, controlled by various settings in Admin -> Parameters -> Common -> Invoices
Tax 1
Invoice Tax 01 Enable: Whether or not to calculate tax 1 on items tagged as taxable by tax 1
Invoice Tax 01 Text Label: What to call this tax on invoices, for example "State Sales Tax"
Invoice Tax 01 Rate Default Value: The percentage rate for this tax, for example, "8.625"
Tax 2
Invoice Tax 02 Enable: Whether or not to calculate tax 2 on items tagged as taxable by tax 2
Invoice Tax 02 Text Label: What to call this tax on invoices, for example "County Sales Tax"
Invoice Tax 02 Rate Default Value: The percentage rate for this tax, for example, "5.00"
Both Taxes
Display Digits For Tax Percent: How many digits after the decimal point to display the tax rate? For example, Canadian HST rate could be zero or two (5.00% HST) whereas New York sales tax needs three digits (8.625% Tax)
Display Digits For Tax Amount: Most jurisdictions require that the tax amount be displayed to two digits the same as currency, but New York requires that the tax amount be displayed to three digits, such as $8.625
Invoice Tax By Item Enable: Whether to calculate the taxes on each item individually and keep a running total, or simply calculate the taxes on the invoice totals.
Invoice Taxes Are Included In Price: Some jurisdictions such as Australia require that website prices be tax-included. If "No", phpCOIN will add applicable taxes to items on invoices. If "Yes", phpCOIN assumes that the prices include tax. In that event, taxes will be removed from the items and then recalculated, so the invoice can show the amount of taxes included in the prices. For example, on an item that is priced at $100 with Tax 1 as 10%:
ON:
Items Sub-total: $100.00 Tax Included: $9.09 (item cost - (item_cost / (1+(tax 1 percent / 100)))) Total: $100.00
OFF:
Items Sub-total: $100.00 Tax Included: $10.00 (item cost * tax 1 percent) Total: $110.00
Products Taxes
Each individual product or service has three flags, as follows:
Apply Tax 01: Whether or not tax 1 must be charged on this product or service
Apply Tax 02: Whether or not tax 2 must be charged on this product or service
Calc Tax 02 On Tax 01: Some tax jurisdictions require that tax 1 be added to the product and that tax 2 be calculated on the sum of the cost plus tax 1, while other jurisdictions calculate tax 2 only on the cost and ignore tax 1. For example, on an item that is priced at $100 with Tax 1 at 10% and Tax 2 also at 10%:
ON:
Items Sub-total: $100.00 Tax 1: $10.00 Tax 2: $11.00 (10% of $110) Total: $121.00
OFF:
Items Sub-total: $100.00 Tax 1: $10.00 Tax 2: $10.00 (10% of $100) Total: $120.00
Invoices
Auto-generated invoices will use the values specified above. Manually generated invoices will select these values as the defaults, but you can over-ride whether or not to calculate tax, the rates, and whether phpCOIN should auto-calculate taxes or use the amounts you manually enter, while creating the invoice.
If you have taxes disabled, then no tax options will appear when editing products or invoices, nor will tax information be displayed when viewing products or invoices.
Multiple Tax2 Rates
The combination of tax1 setup as GST and tax2 setup as PST will usually meet the needs of Canadian users. Sometimes, however, a Canadian seller may need to handle multiple tax2 rates depending on where the product is being shipped to or the service is deemed to be performed in. phpCOIN v1.4.2 and higher has a method of handling multiple tax2 rates ~ a tax2 override file.
Create a file called invoice_tax2_override.php and make the contents similar to the following:
<?php
/**
* Module: Invoices (Overide tax2 calculation for specific clients)
* - phpCOIN is based on concept and code of Mike Lansberry <mg@mgwebhosting.com>
* - Do NOT alter or remove this text block
* @package phpCOIN
* @subpackage Invoices
* @version 1.4
* @author Stephen M. Kitching <support@phpcoin.com>
* @copyright Copyright © 2003-2008 COINSoftTechnologies Inc. All rights reserved.
* @license coin_docs/license.txt phpCOIN License Terms
* @translation
* @arguments
*/
# This is for Canadian users who need to over-ride the PST rate (tax2) depending on destination
# First we retrieve invoice/client info
$query = 'SELECT * FROM '.$_DBCFG['clients'].', '.$_DBCFG['invoices'];
$query .= ' WHERE '.$_DBCFG['clients'].'.cl_id='.$_DBCFG['invoices'].'.invc_cl_id';
$query .= ' AND '.$_DBCFG['invoices'].'.invc_id='.$adata['invc_id'];
$result = $db_coin->db_query_execute($query);
while ($row = $db_coin->db_fetch_array($result)) {$_prov = $row['cl_state_prov'];}
# Then we over-ride tax2 rate based on client's province
# We can add more provinces and rates here, and even override the tax2 description
IF ($_prov == 'QC') { // Charge 7.5% for Quebec
$data['invc_tax_02_amount'] = 7.5;
} ELSEIF ($_prov == 'BC') { // Charge 7.0% for British Columbia
$data['invc_tax_02_amount'] = 7;
} ELSE { // Charge 0% for everywhere else
$data['invc_tax_02_amount'] = 0;
}
?>
For phpCOIN v1.4.2, place the file in the root folder of the phpCOIN website.
For phpCOIN v1.4.3 and higher, place the file in the /coin_overrides folder.
At run-time, if the invoice_tax2_override.php file exists, phpCOIN will load it and do whatever the file says when calculating invoice totals. In this case, it will over-ride the tax2 percentages before adding taxes to the invoice or recalculating taxes, as the case may be

