Taxes stage 2: Tax Collected report rebuilt for filing with an Invoiced basis (each sent invoice in the month of its date) or Paid basis (each payment carrying its share of its invoice), tax by part of each rate with registration numbers so a state's and a county's parts count apart and parts named alike add up in one row, sales before tax and net of discounts split into taxable, exempt and non-taxable, tax paid on purchases by part and net tax collected less paid, exempt sales by client with certificate and expiry, quarterly or monthly with a chart and CSV export of the tax table or the exempt sales, archived payments left out; expenses and recurring expenses record the tax included in them with a rate worked out from the amount as typed or typed over from the receipt, a tax amount with no rate allowed, refunds giving their tax back, recurring expenses copying it to each expense recorded, vendor defaults filling it in, and the list and quick looks showing it; exports gain invoice subtotal, discount, tax and tax by part, quote and recurring invoice tax, expense before tax, tax and tax rate, and client tax rate and exemption columns; API adds a taxes read endpoint with each rate's parts, subtotal, tax, tax by part and registration numbers on invoice and quote reads, and each line's rate on invoice item reads; Admin > Taxes explains naming parts alike and links the report; demo data names Allegheny County's state part PA Sales Tax and taxes the company's own-use purchases; removes the unused getMonthlyTax and getQuarterlyTax; database 3.1.2 adds expense and recurring expense tax rate and amount; changelog updated

This commit is contained in:
johnnyq
2026-10-17 13:27:53 -04:00
parent afaaa5fc32
commit cd565b73c7
29 changed files with 797 additions and 224 deletions

View File

@@ -93,7 +93,8 @@ function demoDataSlas() {
function demoDataTaxes() {
return [
['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]]],
// The state's part is named as the state's own rate, so Tax Collected adds the two up in one row
['Allegheny County Sales Tax', 7.0, 'Pennsylvania 6% plus the Allegheny County local 1%', '75520193', [['PA Sales Tax', 6.0], ['Allegheny County', 1.0]]],
];
}
@@ -3396,6 +3397,10 @@ function demoBuildCompanyFinancials($mysqli, $context, &$counts) {
$card_categories = ['Software', 'Cloud and Hosting', 'Office Supplies', 'Meals', 'Shipping and Postage', 'Dues and Subscriptions', 'Telecom and Internet'];
$card_spent = [];
// What we buy for our own use pays sales tax; stock to resell doesn't
$taxed_categories = ['Office Supplies', 'Tools and Test Equipment', 'Equipment', 'Vehicle and Fuel'];
$purchase_tax_id = intval($context['taxes']['PA Sales Tax']['id'] ?? 0);
// Which purchases put hardware on the shelf, and what they bring in
$stock_lines = [
'UniFi shelf stock for the workshop' => ['Ubiquiti U6-Pro Access Point', 4],
@@ -3416,9 +3421,12 @@ function demoBuildCompanyFinancials($mysqli, $context, &$counts) {
$card_spent[$month] = ($card_spent[$month] ?? 0) + round($cost[1] * $drift, 2);
}
$taxed = $purchase_tax_id && in_array($cost[2], $taxed_categories, true);
$expense_id = starterInsert($mysqli, 'expenses', [
'expense_description' => $cost[0],
'expense_amount' => number_format($cost[1] * $drift, 2, '.', ''),
'expense_tax_id' => $taxed ? $purchase_tax_id : 0,
'expense_tax_amount' => number_format($taxed ? taxIncluded(round($cost[1] * $drift, 2), $purchase_tax_id) : 0, 2, '.', ''),
'expense_currency_code' => $currency,
'expense_date' => demoMonthDate($month, $cost[4]),
'expense_reference' => 'BILL-' . demoSerial('company' . $cost[0] . $month, 8),