Taxes stage 1: Admin > Taxes rebuilt (renamed from Tax Rates) listing each rate with its whole percent, parts, description, registration number and usage (invoices, quotes, recurring invoices, products, clients), Current and Archived tabs showing what replaced a rate, Restore, Make default, and Delete only for a rate never used; rates made of parts (state and county, GST and QST) with parts charged on top of the ones above, the whole rate shown as typed, four decimal places and a registration number per rate or part printed with the company details on invoices, quotes and PDFs; changing the percent or parts of a rate on a sent invoice or quote makes a new rate of the same name and archives the old one, so billed lines keep the old rate while products, client rates, the default, recurring invoices and optionally drafts move to the new one, and archiving offers to move whatever still uses it; How lines are taxed settings for the default rate, taxing billed time, trips and expenses, and discounts taken off before tax (on by default, shared across lines by amount, paid, cancelled and answered documents never recalculated); clients get their own tax rate and tax exempt with certificate number and expiry on the Billing tab, new lines defaulting to the client's rate then the product's then the default and to no tax for exempt clients, exempt badge on the client header and overview, a warning with Take the tax off on open documents that still carry taxed lines for an exempt client, and Tax exempt with the certificate under the client on untaxed documents; totals, PDFs, guest and portal views show tax by part; Unbilled Time can bill at each client's usual rate and the ticket, Add Tickets, Add Expenses and Add Trips windows start on it; API client fields for rate and exemption and tax_id default on invoice item create; Tax Collected shows exact percents; demo taxes get parts and registration numbers, demo clients their rates and two nonprofits exemptions; database 3.1.1 makes tax_percent decimal(9,4) and adds tax description, registration and replaced-by, tax_components, client rate and exemption columns and the tax settings; new functions/tax.php and js/tax_form.js; changelog updated

This commit is contained in:
johnnyq
2026-10-17 13:00:54 -04:00
parent e29369926f
commit afaaa5fc32
50 changed files with 1919 additions and 318 deletions

View File

@@ -0,0 +1,52 @@
<?php
/*
* ITFlow - Database update to version 3.1.1 (from 3.1.0)
* Included by admin/database_updates.php - do not access directly
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
// A rate to the ten-thousandth of a percent (Quebec's 9.975%) rather than
// a float, a description and the registration number the rate is charged
// under, and - when a rate in use was changed - the rate that took its place
// (functions/tax.php: taxChangeRate())
mysqli_query($mysqli, "ALTER TABLE `taxes`
MODIFY `tax_percent` decimal(9,4) NOT NULL DEFAULT 0.0000,
ADD COLUMN `tax_description` varchar(255) DEFAULT NULL AFTER `tax_percent`,
ADD COLUMN `tax_registration_number` varchar(100) DEFAULT NULL AFTER `tax_description`,
ADD COLUMN `tax_replaced_by` int(11) NOT NULL DEFAULT 0 AFTER `tax_registration_number`");
// A rate made of parts - state and county, GST and PST - each charged on
// the line, or on the line and the parts before it (compound), each with
// its own registration number if it has one (GST and QST do). A rate
// without parts is its own single part; with them, tax_percent is the
// whole rate they come to.
mysqli_query($mysqli, "CREATE TABLE IF NOT EXISTS `tax_components` (
`component_id` int(11) NOT NULL AUTO_INCREMENT,
`component_tax_id` int(11) NOT NULL,
`component_name` varchar(200) NOT NULL,
`component_percent` decimal(9,4) NOT NULL DEFAULT 0.0000,
`component_compound` tinyint(1) NOT NULL DEFAULT 0,
`component_registration_number` varchar(100) DEFAULT NULL,
`component_order` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`component_id`),
KEY `component_tax_id` (`component_tax_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci");
// A client's own rate (0: the company's default) and tax exemption, with
// the certificate it rests on and when that runs out
mysqli_query($mysqli, "ALTER TABLE `clients`
ADD COLUMN `client_default_tax_id` int(11) NOT NULL DEFAULT 0 AFTER `client_tax_id_number`,
ADD COLUMN `client_tax_exempt` tinyint(1) NOT NULL DEFAULT 0 AFTER `client_default_tax_id`,
ADD COLUMN `client_tax_exempt_number` varchar(200) DEFAULT NULL AFTER `client_tax_exempt`,
ADD COLUMN `client_tax_exempt_expires` date DEFAULT NULL AFTER `client_tax_exempt_number`");
// The default rate for new lines, whether billed time, trips and expenses
// are taxed, and discounts taken off before tax is worked out
mysqli_query($mysqli, "ALTER TABLE `settings`
ADD COLUMN `config_tax_default_id` int(11) NOT NULL DEFAULT 0 AFTER `config_invoice_show_tax_id`,
ADD COLUMN `config_tax_time` tinyint(1) NOT NULL DEFAULT 0 AFTER `config_tax_default_id`,
ADD COLUMN `config_tax_trips` tinyint(1) NOT NULL DEFAULT 0 AFTER `config_tax_time`,
ADD COLUMN `config_tax_expenses` tinyint(1) NOT NULL DEFAULT 0 AFTER `config_tax_trips`,
ADD COLUMN `config_tax_discount_before` tinyint(1) NOT NULL DEFAULT 1 AFTER `config_tax_expenses`");

View File

@@ -57,7 +57,7 @@
<li class="nav-item">
<a href="/admin/tax_rates.php" class="nav-link <?= (basename($_SERVER['PHP_SELF']) == 'tax_rates.php' ? 'active' : '') ?>">
<i class="nav-icon fas fa-balance-scale"></i>
<p>Tax Rates</p>
<p>Taxes</p>
</a>
</li>
<li class="nav-item">

View File

@@ -2,6 +2,8 @@
require_once '../../includes/modal_header.php';
$tax = null;
ob_start();
?>
@@ -14,14 +16,13 @@ ob_start();
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<div class="modal-body">
<div class="mb-3">
<label>Name <strong class="text-danger">*</strong></label>
<input type="text" class="form-control" name="name" placeholder="Tax name" maxlength="200" required autofocus>
</div>
<div class="mb-3">
<label>Percent <strong class="text-danger">*</strong></label>
<input type="number" min="0" step="any" class="form-control w-25" name="percent">
</div>
<?php require __DIR__ . '/tax_form.php'; ?>
<?php if (!taxSettings()['default_id']) { ?>
<div class="form-check form-switch mt-3">
<input type="checkbox" class="form-check-input" name="make_default" value="1" id="taxMakeDefault">
<label class="form-check-label" for="taxMakeDefault">Make it the default for new lines</label>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="submit" name="add_tax" class="btn btn-primary text-bold"><i class="fa fa-check me-2"></i>Create</button>

View File

@@ -0,0 +1,68 @@
<?php
/*
* Archive a tax - no longer offered for new lines - and, when products,
* clients, recurring invoices, drafts or the default use it, move them to
* another rate (functions/tax.php: taxArchive()).
*/
require_once '../../includes/modal_header.php';
$tax_id = intval($_GET['id'] ?? 0);
$tax = taxRow($tax_id);
ob_start();
if (!$tax || $tax['tax_archived_at']) { ?>
<div class="modal-body text-center text-secondary py-5">That tax is already archived.</div>
<?php } else {
$usage = taxUsage($tax_id);
$drafts = count(taxDocIds('invoice', $tax_id)) + count(taxDocIds('quote', $tax_id));
$uses = [];
foreach (['products' => ['product', 'products'], 'clients' => ['client', 'clients'], 'recurring' => ['recurring invoice', 'recurring invoices']] as $key => [$one, $many]) {
if ($usage[$key]) {
$uses[] = number_format($usage[$key]) . ' ' . ($usage[$key] === 1 ? $one : $many);
}
}
if ($drafts) {
$uses[] = $drafts . ' draft ' . ($drafts === 1 ? 'invoice or quote' : 'invoices and quotes');
}
$others = billingTaxes();
unset($others[$tax_id]); ?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-archive me-2"></i>Archive tax: <strong><?= escapeHtml(taxLabel($tax)) ?></strong></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="tax_id" value="<?= $tax_id ?>">
<div class="modal-body">
<p>It won't be offered for new lines. Invoices and quotes already billed with it keep it.</p>
<?php if ($uses || $usage['default']) { ?>
<div class="alert alert-warning small">
<i class="fas fa-fw fa-exclamation-triangle me-1"></i>Still used by <?= escapeHtml($uses ? implode(', ', $uses) : 'nothing but the default') ?><?= $uses && $usage['default'] ? ', and it is the default' : '' ?>.
</div>
<div class="mb-2">
<label class="form-label">Move them to</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-exchange-alt"></i></span>
<select class="form-select" name="move_to">
<option value="0">Leave them where they are</option>
<?php foreach ($others as $id => $other) { ?>
<option value="<?= intval($id) ?>"><?= escapeHtml(taxLabel($other)) ?></option>
<?php } ?>
</select>
</div>
<small class="text-secondary">Left where they are, recurring invoices and drafts keep charging it, products and clients fall back to the next rate along for new lines<?= $usage['default'] ? ', and there is no default until you pick one' : '' ?>.</small>
</div>
<?php } ?>
</div>
<div class="modal-footer">
<button type="submit" name="archive_tax" class="btn btn-danger text-bold"><i class="fas fa-archive me-2"></i>Archive</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<?php }
require_once '../../../includes/modal_footer.php';

View File

@@ -2,43 +2,56 @@
require_once '../../includes/modal_header.php';
$tax_id = intval($_GET['id']);
$tax_id = intval($_GET['id'] ?? 0);
$tax = taxRow($tax_id);
$sql = mysqli_query($mysqli, "SELECT tax_name, tax_percent FROM taxes WHERE tax_id = $tax_id LIMIT 1");
$row = mysqli_fetch_assoc($sql);
$tax_name = escapeHtml($row['tax_name']);
$tax_percent = floatval($row['tax_percent']);
// Generate the HTML form content using output buffering.
ob_start();
?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-balance-scale me-2"></i>Editing tax: <strong><?= $tax_name ?></strong></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="tax_id" value="<?= $tax_id ?>">
<div class="modal-body">
<div class="mb-3">
<label>Name <strong class="text-danger">*</strong></label>
<input type="text" class="form-control" name="name" maxlength="200" value="<?= $tax_name ?>" required>
</div>
<div class="mb-3">
<label>Percent <strong class="text-danger">*</strong></label>
<input type="number" min="0" step="any" class="form-control w-25" name="percent" value="<?= $tax_percent ?>">
</div>
if (!$tax) { ?>
<div class="modal-body text-center text-secondary py-5">That tax is gone.</div>
<?php } else {
$usage = taxUsage($tax_id);
$billed = taxBilled($tax_id);
$drafts = count(taxDocIds('invoice', $tax_id)) + count(taxDocIds('quote', $tax_id));
$replaced_by = intval($tax['tax_replaced_by']) ? taxRow($tax['tax_replaced_by']) : null;
$on = [];
foreach (['invoices' => ['invoice', 'invoices'], 'quotes' => ['quote', 'quotes']] as $key => [$one, $many]) {
if ($usage[$key]) {
$on[] = number_format($usage[$key]) . ' ' . ($usage[$key] === 1 ? $one : $many);
}
} ?>
<div class="modal-header bg-dark">
<h5 class="modal-title"><i class="fas fa-fw fa-balance-scale me-2"></i>Editing tax: <strong><?= escapeHtml($tax['tax_name']) ?></strong></h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal"></button>
</div>
<div class="modal-footer">
<button type="submit" name="edit_tax" class="btn btn-primary text-bold"><i class="fas fa-check me-2"></i>Save</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<input type="hidden" name="tax_id" value="<?= $tax_id ?>">
<div class="modal-body">
<?php if ($tax['tax_archived_at']) { ?>
<div class="alert alert-secondary small">
<i class="fas fa-fw fa-archive me-1"></i><?= $replaced_by ? 'Replaced by <strong>' . escapeHtml(taxLabel($replaced_by)) . '</strong> on ' : 'Archived on ' ?><?= date('M j, Y', strtotime($tax['tax_archived_at'])) ?> - it stays on what was billed with it, but isn't offered for new lines.
</div>
<?php } elseif ($billed) { ?>
<div class="alert alert-info small">
<i class="fas fa-fw fa-history me-1"></i>On <?= escapeHtml(implode(' and ', $on)) ?>. A new rate or parts makes a new <strong><?= escapeHtml($tax['tax_name']) ?></strong> from now on: what was billed keeps this rate, and its products, clients, recurring invoices and the default move to the new one. The name, description and registration number change in place.
<?php if ($drafts) { ?>
<input type="hidden" name="drafts_asked" value="1">
<div class="form-check mt-2 mb-0">
<input type="checkbox" class="form-check-input" name="move_drafts" value="1" id="taxMoveDrafts" checked>
<label class="form-check-label" for="taxMoveDrafts">Move <?= $drafts === 1 ? 'the draft invoice or quote' : "the $drafts draft invoices and quotes" ?> with it to the new rate too</label>
</div>
<?php } ?>
</div>
<?php } ?>
<?php require __DIR__ . '/tax_form.php'; ?>
</div>
<div class="modal-footer">
<button type="submit" name="edit_tax" class="btn btn-primary text-bold"><i class="fas fa-check me-2"></i>Save</button>
<button type="button" class="btn btn-light" data-bs-dismiss="modal"><i class="fas fa-times me-2"></i>Cancel</button>
</div>
</form>
<?php }
<?php
require_once '../../../includes/modal_footer.php';

View File

@@ -0,0 +1,109 @@
<?php
/*
* A tax's fields - for tax_add.php and tax_edit.php, which set $tax (a
* taxRow(), or null when new). One rate, or parts each charged on the line
* or on top of the parts above it (js/tax_form.js). Posts to admin/post.php
* (admin/post/tax.php).
*/
isset($mysqli) || die("Direct file access is not allowed");
$t = $tax ?? null;
$t_parts = $t && $t['grouped'] ? $t['components'] : [];
// One part's row - $key keeps a part's name, percent and "on top" together when rows are added and removed
$tax_part_row = function ($key, array $part = []) {
ob_start(); ?>
<div class="row g-2 align-items-center mb-2" data-tax-part>
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-tag"></i></span>
<input type="text" class="form-control" name="part_name[<?= $key ?>]" maxlength="200" placeholder="State, county, GST..." value="<?= escapeHtml($part['name'] ?? '') ?>" data-tax-part-name>
</div>
</div>
<div class="col-sm-3">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-id-card"></i></span>
<input type="text" class="form-control" name="part_registration[<?= $key ?>]" maxlength="100" placeholder="Its own reg. no." title="This part's registration number, when it isn't the tax's" value="<?= escapeHtml($part['registration'] ?? '') ?>">
</div>
</div>
<div class="col-7 col-sm-2">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-percent"></i></span>
<input type="text" class="form-control" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,4}" name="part_percent[<?= $key ?>]" placeholder="0" value="<?= isset($part['percent']) ? taxPercentText($part['percent']) : '' ?>" data-tax-part-percent>
</div>
</div>
<div class="col-3 col-sm-2">
<div class="form-check mb-0" title="Charged on the line plus the parts above it, not just the line">
<input type="checkbox" class="form-check-input" name="part_compound[<?= $key ?>]" value="1" id="taxPartCompound<?= $key ?>"<?= !empty($part['compound']) ? ' checked' : '' ?> data-tax-part-compound>
<label class="form-check-label small" for="taxPartCompound<?= $key ?>">On top</label>
</div>
</div>
<div class="col-2 col-sm-1 text-end">
<button type="button" class="btn btn-sm btn-outline-secondary" title="Remove this part" data-tax-remove-part><i class="fas fa-times"></i></button>
</div>
</div>
<?php return ob_get_clean();
};
?>
<div data-tax-form>
<div class="mb-3">
<label class="form-label">Name <strong class="text-danger">*</strong></label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-balance-scale"></i></span>
<input type="text" class="form-control" name="name" maxlength="200" placeholder="PA Sales Tax, GST, VAT" value="<?= escapeHtml($t['tax_name'] ?? '') ?>" required autofocus>
</div>
</div>
<div class="row">
<div class="col-md-7 mb-3">
<label class="form-label">Description</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-align-left"></i></span>
<input type="text" class="form-control" name="description" maxlength="255" placeholder="Where and what it is charged on" value="<?= escapeHtml($t['tax_description'] ?? '') ?>">
</div>
</div>
<div class="col-md-5 mb-3">
<label class="form-label">Registration number</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-id-card"></i></span>
<input type="text" class="form-control" name="registration" maxlength="100" placeholder="Permit, GST/HST or VAT number" value="<?= escapeHtml($t['tax_registration_number'] ?? '') ?>">
</div>
<small class="text-secondary">Printed with this tax on invoices</small>
</div>
</div>
<div class="mb-1<?= $t_parts ? ' d-none' : '' ?>" data-tax-single>
<label class="form-label">Rate <strong class="text-danger">*</strong></label>
<div class="row g-2 align-items-center">
<div class="col-sm-4">
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-percent"></i></span>
<input type="text" class="form-control" inputmode="decimal" pattern="[0-9]*\.?[0-9]{0,4}" name="percent" placeholder="0" value="<?= $t && !$t_parts ? taxPercentText($t['tax_percent']) : '' ?>"<?= $t_parts ? ' disabled' : ' required' ?> data-tax-percent>
</div>
</div>
<div class="col-sm-8">
<button type="button" class="btn btn-link btn-sm px-0 text-decoration-none" data-tax-split><i class="fas fa-layer-group me-1"></i>Split into parts - a state's and a county's, GST and PST</button>
</div>
</div>
</div>
<div class="mb-1<?= $t_parts ? '' : ' d-none' ?>" data-tax-parts>
<label class="form-label">Parts <strong class="text-danger">*</strong></label>
<div data-tax-part-rows>
<?php foreach ($t_parts as $i => $part) {
echo $tax_part_row($i, $part);
} ?>
</div>
<template data-tax-part-template><?= $tax_part_row('__KEY__') ?></template>
<div class="d-flex flex-wrap align-items-center gap-2">
<button type="button" class="btn btn-outline-secondary btn-sm" data-tax-add-part><i class="fas fa-plus me-1"></i>Add a part</button>
<span class="ms-auto">Comes to <strong data-tax-total><?= $t ? taxPercentText($t['tax_percent']) : '0' ?>%</strong></span>
</div>
<small class="text-secondary d-block mt-1">Each part is shown on its own on invoices, with its registration number - or the tax's. <em>On top</em> charges a part on the line plus the parts above it.</small>
</div>
</div>
<script src="/js/tax_form.js"></script>

View File

@@ -87,12 +87,13 @@ function demoDataSlas() {
// ------------------------------
// demoDataTaxes
// Sales tax on goods lines. Labor is not taxed in this fictional jurisdiction,
// which is why only hardware lines carry a rate.
// which is why only hardware lines carry a rate. Name, whole percent,
// description, registration number, and the parts it is made of.
// ------------------------------
function demoDataTaxes() {
return [
['PA Sales Tax', 6.0],
['Allegheny County Sales Tax', 7.0],
['PA Sales Tax', 6.0, 'Pennsylvania state sales tax', '75520193', []],
['Allegheny County Sales Tax', 7.0, 'Pennsylvania 6% plus the Allegheny County local 1%', '75520193', [['Pennsylvania', 6.0], ['Allegheny County', 1.0]]],
];
}
@@ -636,8 +637,18 @@ function demoEnsureTaxes($mysqli) {
$tax_id = starterInsert($mysqli, 'taxes', [
'tax_name' => $tax[0],
'tax_percent' => $tax[1],
'tax_description' => $tax[2],
'tax_registration_number' => $tax[3],
'tax_created_at' => demoMonthDateTime(24, 3, 9, 0),
]);
foreach ($tax[4] as $order => $part) {
starterInsert($mysqli, 'tax_components', [
'component_tax_id' => $tax_id,
'component_name' => $part[0],
'component_percent' => $part[1],
'component_order' => $order + 1,
]);
}
$taxes[$tax[0]] = ['id' => $tax_id, 'percent' => $tax[1]];
}
@@ -1147,8 +1158,14 @@ function demoDataRemove($mysqli) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(*) AS total FROM $table WHERE $column = $tax_id"));
$in_use = $in_use + intval($row['total'] ?? 0);
}
foreach (['clients' => 'client_default_tax_id'] as $table => $column) {
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(*) AS total FROM $table WHERE $column = $tax_id"));
$in_use = $in_use + intval($row['total'] ?? 0);
}
if (!$in_use) {
mysqli_query($mysqli, "DELETE FROM tax_components WHERE component_tax_id = $tax_id");
mysqli_query($mysqli, "DELETE FROM taxes WHERE tax_id = $tax_id");
mysqli_query($mysqli, "UPDATE settings SET config_tax_default_id = 0 WHERE config_tax_default_id = $tax_id");
}
}
@@ -1167,7 +1184,7 @@ function demoBuildClient($mysqli, $profile, $index, $context, &$counts) {
$user_id = $context['user_id'];
$months = demoClientMonths($profile);
$client_id = starterInsert($mysqli, 'clients', [
$client_id = starterInsert($mysqli, 'clients', array_merge([
'client_name' => $profile['name'],
'client_type' => $profile['type'],
'client_website' => 'https://www.' . $profile['domain'],
@@ -1177,6 +1194,8 @@ function demoBuildClient($mysqli, $profile, $index, $context, &$counts) {
'client_net_terms' => $profile['net_terms'],
'client_abbreviation' => $profile['abbreviation'],
'client_tax_id_number' => '82-' . demoSerial($profile['abbreviation'] . 'ein', 7),
// The rate where it is
'client_default_tax_id' => intval($context['taxes'][$profile['tax']]['id'] ?? 0),
'client_lead' => $profile['lead'],
'client_favorite' => $profile['favorite'],
'client_notes' => $profile['notes'],
@@ -1184,7 +1203,12 @@ function demoBuildClient($mysqli, $profile, $index, $context, &$counts) {
// first - a client record cannot postdate its own opening invoice
'client_created_at' => demoMonthDateTime($months, 1, 9, 14),
'client_accessed_at' => demoDateTime($index % 5, 11, 20),
]);
], !empty($profile['tax_exempt']) ? [
// Or exempt on a certificate - a church, a school
'client_tax_exempt' => 1,
'client_tax_exempt_number' => $profile['tax_exempt'][0],
'client_tax_exempt_expires' => date('Y-m-d', strtotime($profile['tax_exempt'][1])),
] : []));
demoAttachTags($mysqli, 'client_tags', 'client_id', 'tag_id', $client_id, 1, $profile['tags']);
@@ -4696,7 +4720,7 @@ function demoDataSpecs() {
'second_site' => null,
'age_days' => 760, 'seats' => 8, 'servers' => 1, 'build' => 1, 'billing' => 'managed',
'balance' => 'clear', 'hosting' => [['Web Hosting - Standard', 1, 25.00, 'Church website and service times, hosted with nightly backup', 0], ['Email Hosting - Per Mailbox', 8, 4.50, 'Staff and volunteer mailboxes with filtering', 0]],
'lead' => 0, 'favorite' => 0, 'tax' => 'PA Sales Tax',
'lead' => 0, 'favorite' => 0, 'tax' => '', 'tax_exempt' => ['75-0012847', '+2 years'],
'mail_platform' => 'Google Workspace', 'cert_issuer' => "Let's Encrypt",
'tags' => ['Managed', 'Non Profit', 'Block Hours'],
'notes' => 'Non profit rate. Mostly volunteers on the machines, so the build is locked down and simple.',
@@ -4806,7 +4830,7 @@ function demoDataSpecs() {
'second_site' => null,
'age_days' => 1320, 'seats' => 38, 'servers' => 3, 'build' => 1, 'billing' => 'managed',
'balance' => 'clear', 'hosting' => [['Nextcloud Hosting - Instance', 1, 95.00, 'Staff and coursework file sharing', 0], ['Web Hosting - Standard', 1, 25.00, 'School website and newsletter archive', 0]],
'lead' => 0, 'favorite' => 0, 'tax' => 'Allegheny County Sales Tax',
'lead' => 0, 'favorite' => 0, 'tax' => '', 'tax_exempt' => ['75-0031906', '-20 days'],
'mail_platform' => 'Google Workspace', 'cert_issuer' => "Let's Encrypt",
'tags' => ['Co-Managed', 'Managed', 'Non Profit', 'Seasonal', 'Compliance'],
'notes' => 'Runs on open source deliberately - budget goes on staff, not licences. Quiet in July, chaotic in late August.',
@@ -5211,6 +5235,7 @@ function demoExpandProfile($spec) {
'lead' => $spec['lead'],
'favorite' => $spec['favorite'],
'tax' => $spec['tax'],
'tax_exempt' => $spec['tax_exempt'] ?? null,
'notes' => $spec['notes'],
'account_note' => $spec['account_note'],
'review_note' => $spec['review_note'],

View File

@@ -1,7 +1,8 @@
<?php
/*
* ITFlow - GET/POST request handler for tax
* Taxes (Admin > Taxes) - rates, the parts they are made of, and how new
* lines are taxed. The work is in functions/tax.php.
*/
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
@@ -10,16 +11,21 @@ if (isset($_POST['add_tax'])) {
validateCSRFToken();
$name = escapeSql($_POST['name']);
$percent = floatval($_POST['percent']);
[$fields, $error] = taxFromInput($_POST);
if ($error !== '') {
flashAlert($error, 'error');
redirect();
}
mysqli_query($mysqli,"INSERT INTO taxes SET tax_name = '$name', tax_percent = $percent");
$tax_id = taxCreate($fields);
$label = taxLabel(taxRow($tax_id));
if (!empty($_POST['make_default']) && !taxSettings()['default_id']) {
taxSetDefault($tax_id);
}
$tax_id = mysqli_insert_id($mysqli);
logAudit("Tax", "Create", "$session_name created tax " . escapeSql($label), 0, $tax_id);
logAudit("Tax", "Create", "$session_name created tax $name - $percent%", 0, $tax_id);
flashAlert("Tax <strong>$name</strong> ($percent%) created");
flashAlert("Tax <strong>" . escapeHtml($label) . "</strong> created");
redirect();
@@ -29,33 +35,102 @@ if (isset($_POST['edit_tax'])) {
validateCSRFToken();
$tax_id = intval($_POST['tax_id']);
$name = escapeSql($_POST['name']);
$percent = floatval($_POST['percent']);
$tax_id = intval($_POST['tax_id'] ?? 0);
$row = taxRow($tax_id);
if (!$row) {
flashAlert("That tax is gone", 'error');
redirect();
}
mysqli_query($mysqli,"UPDATE taxes SET tax_name = '$name', tax_percent = $percent WHERE tax_id = $tax_id");
[$fields, $error] = taxFromInput($_POST);
if ($error !== '') {
flashAlert($error, 'error');
redirect();
}
if ($row['tax_archived_at'] && !taxSameRate($row, $fields) && taxBilled($tax_id)) {
flashAlert("An archived tax keeps the rate it was billed at - restore it, or make a new tax", 'error');
redirect();
}
logAudit("Tax", "Edit", "$session_name edited tax $name - $percent%", 0, $tax_id);
$before = taxLabel($row);
$move_drafts = empty($_POST['drafts_asked']) || !empty($_POST['move_drafts']);
$saved = taxUpdate($tax_id, $fields, $move_drafts);
$after = taxLabel(taxRow($saved['id']));
$moved = taxMovedText($saved['moved']);
flashAlert("Tax <strong>$name</strong> ($percent%) edited");
if ($saved['replaced']) {
logAudit("Tax", "Edit", "$session_name changed tax " . escapeSql($before) . " to " . escapeSql($after) . " - a new rate, the old one archived", 0, $saved['id']);
flashAlert("<strong>" . escapeHtml($after) . "</strong> takes over from " . escapeHtml($before) . " from now on" . ($moved !== '' ? " - $moved moved to it" : '') . ". What was already billed keeps the old rate.");
} else {
logAudit("Tax", "Edit", "$session_name edited tax " . escapeSql($after), 0, $tax_id);
flashAlert("Tax <strong>" . escapeHtml($after) . "</strong> saved" . ($moved !== '' ? " - $moved worked out again" : ''));
}
redirect();
}
if (isset($_GET['archive_tax'])) {
if (isset($_POST['archive_tax'])) {
validateCSRFToken();
$tax_id = intval($_GET['archive_tax']);
$tax_id = intval($_POST['tax_id'] ?? 0);
$row = taxRow($tax_id);
if (!$row || $row['tax_archived_at']) {
redirect();
}
$tax_name = escapeSql(getFieldById('taxes', $tax_id, 'tax_name'));
$move_to = intval($_POST['move_to'] ?? 0);
$done = taxArchive($tax_id, $move_to);
$label = taxLabel($row);
$moved = taxMovedText($done['moved']);
$to = $done['moved'] ? taxLabel(taxRow($move_to)) : '';
mysqli_query($mysqli,"UPDATE taxes SET tax_archived_at = NOW() WHERE tax_id = $tax_id");
logAudit("Tax", "Archive", "$session_name archived tax " . escapeSql($label) . ($to !== '' ? ", moving what used it to " . escapeSql($to) : ''), 0, $tax_id);
logAudit("Tax", "Archive", "$session_name archived tax $tax_name", 0, $tax_id);
flashAlert("Tax <strong>" . escapeHtml($label) . "</strong> archived"
. ($moved !== '' ? " - $moved moved to " . escapeHtml($to) : '')
. ($done['was_default'] ? ". There is no default rate now" : ''), 'error');
flashAlert("Tax <strong>$tax_name</strong> Archived", 'error');
redirect();
}
if (isset($_GET['restore_tax'])) {
validateCSRFToken();
$tax_id = intval($_GET['restore_tax']);
$row = taxRow($tax_id);
if (!$row) {
redirect();
}
taxRestore($tax_id);
$label = taxLabel($row);
logAudit("Tax", "Restore", "$session_name restored tax " . escapeSql($label), 0, $tax_id);
flashAlert("Tax <strong>" . escapeHtml($label) . "</strong> restored");
redirect();
}
if (isset($_GET['default_tax'])) {
validateCSRFToken();
$tax_id = intval($_GET['default_tax']);
if (!taxSetDefault($tax_id)) {
flashAlert("Only a current tax can be the default", 'error');
redirect();
}
$label = taxLabel(taxRow($tax_id));
logAudit("Tax", "Edit", "$session_name made " . escapeSql($label) . " the default tax", 0, $tax_id);
flashAlert("<strong>" . escapeHtml($label) . "</strong> is the default for new lines");
redirect();
@@ -66,14 +141,44 @@ if (isset($_GET['delete_tax'])) {
validateCSRFToken();
$tax_id = intval($_GET['delete_tax']);
$row = taxRow($tax_id);
if (!$row) {
redirect();
}
$label = taxLabel($row);
$tax_name = escapeSql(getFieldById('taxes', $tax_id, 'tax_name'));
if (!taxDelete($tax_id)) {
flashAlert("<strong>" . escapeHtml($label) . "</strong> has been used, so it stays - archive it instead", 'error');
redirect();
}
mysqli_query($mysqli,"DELETE FROM taxes WHERE tax_id = $tax_id");
logAudit("Tax", "Delete", "$session_name deleted tax " . escapeSql($label));
logAudit("Tax", "Delete", "$session_name deleted tax $tax_name");
flashAlert("Tax <strong>$tax_name</strong> deleted", 'error');
flashAlert("Tax <strong>" . escapeHtml($label) . "</strong> deleted", 'error');
redirect();
}
if (isset($_POST['edit_tax_settings'])) {
validateCSRFToken();
$default_id = intval($_POST['default_tax_id'] ?? 0);
$time = intval(!empty($_POST['tax_time']));
$trips = intval(!empty($_POST['tax_trips']));
$expenses = intval(!empty($_POST['tax_expenses']));
$discount_before = intval(!empty($_POST['tax_discount_before']));
if (!taxSetDefault($default_id)) {
$default_id = taxSettings()['default_id'];
}
mysqli_query($mysqli, "UPDATE settings SET config_tax_time = $time, config_tax_trips = $trips, config_tax_expenses = $expenses,
config_tax_discount_before = $discount_before WHERE company_id = 1");
logAudit("Settings", "Edit", "$session_name edited the tax settings");
flashAlert("Tax settings saved");
redirect();

View File

@@ -1,112 +1,219 @@
<?php
// Default Column Sortby Filter
$sort = "tax_name";
$order = "ASC";
/*
* Admin > 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 SQL_CALC_FOUND_ROWS tax_id, tax_name, tax_percent FROM taxes
WHERE tax_archived_at IS NULL AND tax_name LIKE '%$q%'
ORDER BY $sort $order LIMIT $record_from, $record_to"
"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();
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
// "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;
};
?>
<div class="card">
<div class="card-header bg-dark py-2">
<h3 class="card-title mt-2"><i class="fas fa-fw fa-balance-scale me-2"></i>Tax Rates</h3>
<div class="card-tools">
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="modals/tax/tax_add.php"><i class="fas fa-plus me-2"></i>New Tax Rate</button>
</div>
</div>
<div class="card-header py-3">
<form autocomplete="off">
<div class="row g-2 align-items-center">
<div class="col-md-4">
<div class="input-group">
<input type="search" class="form-control" name="q" value="<?php if (isset($q)) { echo stripslashes(escapeHtml($q)); } ?>" placeholder="Search Tax Rates">
<button class="btn btn-primary" title="Search"><i class="fa fa-search"></i></button>
</div>
<div class="row">
<div class="col-xl-8">
<div class="card">
<div class="card-header bg-dark py-2">
<h3 class="card-title mt-2"><i class="fas fa-fw fa-balance-scale me-2"></i>Taxes</h3>
<div class="card-tools">
<button type="button" class="btn btn-primary ajax-modal" data-modal-url="modals/tax/tax_add.php" data-modal-size="lg"><i class="fas fa-plus me-2"></i>New Tax</button>
</div>
</div>
</form>
<div class="card-header py-2">
<form autocomplete="off" class="d-flex flex-wrap align-items-center gap-2">
<?php if ($show_archived) { ?><input type="hidden" name="archived" value="1"><?php } ?>
<div class="input-group input-group-sm w-auto me-auto">
<input type="search" class="form-control" name="q" value="<?= escapeHtml(stripslashes($q)) ?>" placeholder="Search taxes">
<button class="btn btn-primary" title="Search"><i class="fa fa-search"></i></button>
</div>
<div class="btn-group btn-group-sm">
<a class="btn btn-outline-secondary<?= $show_archived ? '' : ' active' ?>" href="tax_rates.php">Current</a>
<a class="btn btn-outline-secondary<?= $show_archived ? ' active' : '' ?>" href="tax_rates.php?archived=1">Archived <span class="badge text-bg-secondary ms-1"><?= $archived_count ?></span></a>
</div>
</form>
</div>
<div class="table-responsive-sm">
<table class="table table-borderless table-hover mb-0 align-middle">
<?php if ($rates) { ?>
<thead class="text-dark">
<tr>
<th class="ps-3">Tax</th>
<th>Rate</th>
<th>Used on</th>
<th class="text-center">Action</th>
</tr>
</thead>
<?php } ?>
<tbody>
<?php foreach ($rates as $rate) {
$tax_id = intval($rate['tax_id']);
$u = $usage[$tax_id];
$used = $used_text($u);
$replaced_by = $rate['tax_archived_at'] && intval($rate['tax_replaced_by']) ? taxRow($rate['tax_replaced_by']) : null;
$unused = !$used && !$u['default'] && taxUnused($tax_id); ?>
<tr>
<td class="ps-3">
<a class="ajax-modal fw-semibold" href="#" data-modal-url="modals/tax/tax_edit.php?id=<?= $tax_id ?>" data-modal-size="lg"><?= escapeHtml($rate['tax_name']) ?></a>
<?php if ($u['default']) { ?>
<span class="badge rounded-pill text-bg-primary ms-1" title="New lines get this rate unless the client or product has its own">Default</span>
<?php } ?>
<?php if ($rate['tax_description']) { ?>
<div class="small text-secondary"><?= escapeHtml($rate['tax_description']) ?></div>
<?php } ?>
<?php if ($rate['tax_registration_number']) { ?>
<div class="small text-secondary" title="Registration number - printed on invoices"><i class="fas fa-fw fa-id-card me-1"></i><?= escapeHtml($rate['tax_registration_number']) ?></div>
<?php } ?>
<?php if ($rate['tax_archived_at']) { ?>
<div class="small text-secondary">
<i class="fas fa-fw fa-archive me-1"></i><?= $replaced_by ? 'Replaced by ' . escapeHtml(taxLabel($replaced_by)) . ' on ' : 'Archived ' ?><?= date('M j, Y', strtotime($rate['tax_archived_at'])) ?>
</div>
<?php } ?>
</td>
<td>
<span class="fw-semibold"><?= taxPercentText($rate['tax_percent']) ?>%</span>
<?php if ($rate['grouped']) { ?>
<div class="small text-secondary">
<?php foreach ($rate['components'] as $i => $part) { ?>
<?= $i ? '<span class="mx-1">+</span>' : '' ?><span class="text-nowrap"<?= $part['registration'] !== '' ? ' title="Registration number ' . escapeHtml($part['registration']) . '"' : '' ?>><?= escapeHtml($part['name']) ?> <?= taxPercentText($part['percent']) ?>%<?= $part['compound'] ? ' <em>on top</em>' : '' ?><?= $part['registration'] !== '' ? '<i class="fas fa-id-card ms-1"></i>' : '' ?></span>
<?php } ?>
</div>
<?php } ?>
</td>
<td class="small">
<?= $used ? escapeHtml(implode(', ', $used)) : '<span class="text-secondary">Not used yet</span>' ?>
</td>
<td>
<div class="dropdown dropstart text-center">
<button class="btn btn-secondary btn-sm" title="More actions" type="button" data-bs-toggle="dropdown"><i class="fas fa-ellipsis-h"></i></button>
<div class="dropdown-menu">
<a class="dropdown-item ajax-modal" href="#" data-modal-url="modals/tax/tax_edit.php?id=<?= $tax_id ?>" data-modal-size="lg"><i class="fas fa-fw fa-edit me-2"></i>Edit</a>
<?php if ($rate['tax_archived_at']) { ?>
<a class="dropdown-item" href="post.php?restore_tax=<?= $tax_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"><i class="fas fa-fw fa-redo me-2"></i>Restore</a>
<?php } else { ?>
<?php if (!$u['default']) { ?>
<a class="dropdown-item" href="post.php?default_tax=<?= $tax_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"><i class="fas fa-fw fa-star me-2"></i>Make default</a>
<?php } ?>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger ajax-modal" href="#" data-modal-url="modals/tax/tax_archive.php?id=<?= $tax_id ?>"><i class="fas fa-fw fa-archive me-2"></i>Archive</a>
<?php } ?>
<?php if ($unused) { ?>
<?php if ($rate['tax_archived_at']) { ?><div class="dropdown-divider"></div><?php } ?>
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_tax=<?= $tax_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>"><i class="fas fa-fw fa-trash me-2"></i>Delete</a>
<?php } ?>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<?php if (!$rates) { ?>
<?= emptyStateHtml([
'thing' => 'taxes',
'title' => $show_archived ? 'No archived taxes' : 'No taxes yet',
'text' => $show_archived ? '' : 'Sales tax, VAT or GST - one rate, or parts like a state\'s and a county\'s charged together.',
'icon' => 'fa-balance-scale',
'filtered' => $q !== '',
'clear_url' => 'tax_rates.php' . ($show_archived ? '?archived=1' : ''),
'actions' => $show_archived ? [] : [['label' => 'New Tax', 'modal' => 'modals/tax/tax_add.php', 'size' => 'lg']],
]) ?>
<?php } ?>
</div>
</div>
<div class="table-responsive-sm">
<table class="table table-striped table-borderless table-hover mb-0">
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
<tr>
<th class="ps-3">
<a class="text-dark" href="?<?= $url_query_strings_sort ?>&sort=tax_name&order=<?= $disp ?>">
Name <?php if ($sort == 'tax_name') { echo $order_icon; } ?>
</a>
</th>
<th>
<a class="text-dark" href="?<?= $url_query_strings_sort ?>&sort=tax_percent&order=<?= $disp ?>">
Percent <?php if ($sort == 'tax_percent') { echo $order_icon; } ?>
</a>
</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_assoc($sql)) {
$tax_id = intval($row['tax_id']);
$tax_name = escapeHtml($row['tax_name']);
$tax_percent = floatval($row['tax_percent']);
?>
<tr>
<td class="ps-3">
<a class="text-dark text-bold ajax-modal" href="#"
data-modal-url="modals/tax/tax_edit.php?id=<?= $tax_id ?>">
<?= $tax_name ?>
</a>
</td>
<td><?= "$tax_percent%" ?></td>
<td>
<div class="dropdown dropstart text-center">
<button class="btn btn-secondary btn-sm" title="More actions" type="button" data-bs-toggle="dropdown">
<i class="fas fa-ellipsis-h"></i>
</button>
<div class="dropdown-menu">
<a class="dropdown-item ajax-modal" href="#"
data-modal-url="modals/tax/tax_edit.php?id=<?= $tax_id ?>">
<i class="fas fa-fw fa-edit me-2"></i>Edit
</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_tax=<?= $tax_id ?>&csrf_token=<?= $_SESSION['csrf_token'] ?>">
<i class="fas fa-fw fa-archive me-2"></i>Archive
</a>
</div>
<div class="col-xl-4">
<div class="card card-dark">
<div class="card-header py-3">
<h3 class="card-title"><i class="fas fa-fw fa-sliders-h me-2"></i>How lines are taxed</h3>
</div>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="csrf_token" value="<?= $_SESSION['csrf_token'] ?>">
<div class="card-body">
<div class="mb-3">
<label class="form-label">Default rate</label>
<div class="input-group">
<span class="input-group-text"><i class="fa fa-fw fa-star"></i></span>
<select class="form-select" name="default_tax_id">
<option value="0">No default</option>
<?php foreach ($active_taxes as $id => $tax) { ?>
<option value="<?= intval($id) ?>"<?= intval($id) === $tax_settings['default_id'] ? ' selected' : '' ?>><?= escapeHtml(taxLabel($tax)) ?></option>
<?php } ?>
</select>
</div>
</td>
</tr>
<small class="text-secondary">For new lines when the client has no rate of its own - after the product's rate, for a product's line. Products set to no tax stay untaxed, and tax exempt clients get none.</small>
</div>
<?php
<label class="form-label">Also tax</label>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="tax_time" value="1" id="taxTime"<?= $tax_settings['time'] ? ' checked' : '' ?>>
<label class="form-check-label" for="taxTime">Billed time</label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="tax_trips" value="1" id="taxTrips"<?= $tax_settings['trip'] ? ' checked' : '' ?>>
<label class="form-check-label" for="taxTrips">Trips</label>
</div>
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="tax_expenses" value="1" id="taxExpenses"<?= $tax_settings['expense'] ? ' checked' : '' ?>>
<label class="form-check-label" for="taxExpenses">Expenses billed to clients</label>
</div>
<small class="text-secondary d-block mb-3">Lines added from tickets, Unbilled Time, trips and expenses get the client's rate when these are on, and no tax when off. Any line can still be changed.</small>
}
<div class="form-check form-switch">
<input type="checkbox" class="form-check-input" name="tax_discount_before" value="1" id="taxDiscountBefore"<?= $tax_settings['discount_before'] ? ' checked' : '' ?>>
<label class="form-check-label" for="taxDiscountBefore">Take discounts off before tax</label>
</div>
<small class="text-secondary d-block">Tax is worked out on what the client pays after the discount, shared across the lines. Off, tax is on the full price. Paid, cancelled and answered invoices and quotes never change; the rest follow the next time they are edited.</small>
</div>
<div class="card-footer">
<button type="submit" name="edit_tax_settings" class="btn btn-primary text-bold"><i class="fas fa-check me-2"></i>Save</button>
</div>
</form>
</div>
?>
</tbody>
</table>
<div class="card">
<div class="card-body small text-secondary">
<p class="mb-2"><i class="fas fa-fw fa-history me-1"></i><strong>Changing a rate.</strong> 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.</p>
<p class="mb-0"><i class="fas fa-fw fa-user-shield me-1"></i><strong>Exempt clients.</strong> 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.</p>
</div>
</div>
</div>
<?php
$empty_state = [
'thing' => 'tax rates',
'icon' => 'fa-balance-scale',
'actions' => [['label' => 'New Tax Rate', 'modal' => 'modals/tax/tax_add.php']],
];
?>
<?php require_once "../includes/filter_footer.php"; ?>
</div>
<?php