Taxes - the rates charged on invoice and quote lines, and how new * lines get one. * * A rate is a single percent, or parts (state and county, GST and PST) each * charged on the line or on top of the parts before it. Changing the rate of * one already billed makes a new rate in its place (functions/tax.php: * taxChangeRate()), so each shows what uses it and, once archived, what * replaced it. A rate nothing has used can be deleted. */ require_once "includes/inc_all_admin.php"; $show_archived = isset($_GET['archived']); $search_sql = $q !== '' ? "AND (tax_name LIKE '%$q%' OR tax_description LIKE '%$q%' OR tax_registration_number LIKE '%$q%')" : ''; $sql = mysqli_query( $mysqli, "SELECT tax_id FROM taxes WHERE tax_archived_at IS " . ($show_archived ? 'NOT NULL' : 'NULL') . " $search_sql ORDER BY " . ($show_archived ? 'tax_archived_at DESC, ' : '') . "tax_name ASC, tax_percent ASC" ); $rates = []; while ($row = mysqli_fetch_row($sql)) { $rates[] = taxRow($row[0]); } $archived_count = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM taxes WHERE tax_archived_at IS NOT NULL"))[0]); $usage = taxUsageAll(); $tax_settings = taxSettings(); $active_taxes = billingTaxes(); // "4 invoices, 1 quote" - what has a line at a rate, and what picks it for new ones $used_text = function (array $u) { $words = ['invoices' => ['invoice', 'invoices'], 'quotes' => ['quote', 'quotes'], 'recurring' => ['recurring invoice', 'recurring invoices'], 'products' => ['product', 'products'], 'clients' => ['client', 'clients']]; $parts = []; foreach ($words as $key => [$one, $many]) { if ($u[$key]) { $parts[] = number_format($u[$key]) . ' ' . ($u[$key] === 1 ? $one : $many); } } return $parts; }; ?>
| Tax | Rate | Used on | Action |
|---|---|---|---|
|
= escapeHtml($rate['tax_name']) ?>
Default
= escapeHtml($rate['tax_description']) ?>
= escapeHtml($rate['tax_registration_number']) ?>
= $replaced_by ? 'Replaced by ' . escapeHtml(taxLabel($replaced_by)) . ' on ' : 'Archived ' ?>= date('M j, Y', strtotime($rate['tax_archived_at'])) ?>
|
= taxPercentText($rate['tax_percent']) ?>%
$part) { ?>
= $i ? '+' : '' ?>>= escapeHtml($part['name']) ?> = taxPercentText($part['percent']) ?>%= $part['compound'] ? ' on top' : '' ?>= $part['registration'] !== '' ? '' : '' ?>
|
= $used ? escapeHtml(implode(', ', $used)) : 'Not used yet' ?> |
|
Changing a rate. Once a rate is on an invoice or quote, saving a new percent or parts makes a new rate with the same name. What was already billed keeps the old rate; products, clients, the default and recurring invoices move to the new one.
Exempt clients. Mark a client tax exempt, with its certificate, on the client's Billing tab. Its new lines get no tax, and its invoices say why.
Filing. The Tax Collected report adds up each part by month or quarter, invoiced or paid, with exempt sales and the tax paid on expenses.