Files
itflow/agent/post/client_model.php
johnnyq afaaa5fc32 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
2026-10-17 13:00:54 -04:00

27 lines
1.2 KiB
PHP

<?php
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
$name = escapeSql($_POST['name']);
$type = escapeSql($_POST['type']);
$website = preg_replace("(^https?://)", "", escapeSql($_POST['website']));
$referral = escapeSql($_POST['referral']);
$rate = floatval($_POST['rate'] ?? 0);
$net_terms = intval($_POST['net_terms'] ?? $config_default_net_terms);
$tax_id_number = escapeSql($_POST['tax_id_number'] ?? '');
$abbreviation = escapeSql($_POST['abbreviation'] ?? '');
if (empty($abbreviation)) {
$abbreviation = shortenClientName($name);
}
$notes = escapeSql($_POST['notes'] ?? '');
$lead = intval($_POST['lead'] ?? 0);
// Reminders and statements - only when the Billing tab was on the form
$reminders = isset($_POST['reminders_field']) ? intval(!empty($_POST['reminders'])) : null;
// Its tax rate and exemption - only when the Billing tab was on the form;
// client.php adds the client's row when editing (taxClientSetSql())
$tax_input = isset($_POST['tax_fields']) ? [
'default_tax_id' => $_POST['default_tax_id'] ?? 0,
'tax_exempt' => !empty($_POST['tax_exempt']),
'tax_exempt_number' => $_POST['tax_exempt_number'] ?? '',
'tax_exempt_expires' => $_POST['tax_exempt_expires'] ?? '',
] : null;