Rates, net terms and SLAs come from the client's contract, else the instance defaults: database 3.5.0 adds a default after-hours rate (Settings > Defaults, now Rates and terms), gives each client whose own rate, net terms or SLAs differ from the defaults an active Standard terms contract setting just those (12-month term renewing itself, starting the day the client was added or the day before its earliest contract, archived with an archived client), deletes per-client SLA assignments and drops clients.client_rate and client_net_terms; time bills at the contract's rate, its after-hours rate or the default after-hours rate, else the default rate, new invoices are due on the contract's net terms else the default, and new tickets get the contract's SLA else the default; a client's own terms still apply until the update runs; the client add and edit windows lose the rate, terms and SLA fields for a note saying what the client is billed on and where it comes from, the Clients list loses Set Hourly Rate and Set Net Terms and shows the contract's rate, the overview's Terms shows the after-hours rate and whether terms are a contract's or the defaults, a contract's page and document show what it leaves empty from another contract in force or the default so signed documents stay unchanged, contract windows show the defaults as placeholders, contract names take a proper possessive; the client import and API create make a Standard terms contract for a rate or terms that aren't the defaults (returning contract_id), API update reports them in not_kept; the client export gives the rates, terms and SLAs as billed; demo data puts each demo client's terms on a contract; changelog updated

This commit is contained in:
johnnyq
2026-10-27 22:22:34 -04:00
parent 954f1e3688
commit 1e5bffff3c
49 changed files with 859 additions and 648 deletions

View File

@@ -1,8 +1,8 @@
<?php
/*
* Get started - Billing: the hourly rate and net terms a new client starts
* with, the tax new lines get (a rate is made when there is none), how
* Get started - Billing: the hourly rate and net terms a client is billed on
* without a contract, the tax new lines get (a rate is made when there is none), how
* invoices and quotes are numbered, and - if you like - Stripe, for clients
* to pay invoices by card (getting_started_billing). The same settings as
* Admin > Defaults, Taxes, Invoices, Quotes and Payment Providers.
@@ -31,11 +31,11 @@ $gs_stripe_on = settingsChecked('stripe_on', false);
<div class="col-sm-6">
<?= settingsInput('config_default_hourly_rate', $gs_rate > 0 ? number_format($gs_rate, 2, '.', '') : '', ['icon' => 'fa-coins', 'type' => 'number', 'label' => 'Hourly rate', 'required' => true,
'min' => '0.01', 'step' => '0.01', 'inputmode' => 'decimal', 'placeholder' => '125.00', 'suffix' => escapeHtml($session_company_currency) . ' an hour',
'help' => 'For time on a ticket - a client can have their own.']) ?>
'help' => 'For time on a ticket - a client\'s contract can set its own.']) ?>
</div>
<div class="col-sm-6">
<?= settingsSelect('config_default_net_terms', (string) intval($gs_billing['config_default_net_terms'] ?? 30), settingsNetTerms(), ['icon' => 'fa-calendar-check', 'label' => 'Invoices are due',
'help' => 'A new client starts with these.']) ?>
'help' => 'Unless a client\'s contract sets its own.']) ?>
</div>
</div>

View File

@@ -16,7 +16,6 @@ require_once dirname(__DIR__) . '/post/demo_data_model.php';
$gs_demo = demoDataStatus($mysqli);
$gs_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL ORDER BY client_created_at DESC, client_id DESC LIMIT 3");
$gs_client_count = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM clients WHERE client_archived_at IS NULL"))[0] ?? 0);
$gs_defaults = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT config_default_hourly_rate, config_default_net_terms FROM settings WHERE company_id = 1")) ?: [];
?>
<?php if ($gs_client_count) { ?>
@@ -40,8 +39,6 @@ $gs_defaults = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT config_default_h
'title', 'contact_phone_country_code', 'contact_phone', 'contact_extension', 'contact_mobile_country_code', 'contact_mobile'] as $gs_field) { ?>
<input type="hidden" name="<?= $gs_field ?>" value="">
<?php } ?>
<input type="hidden" name="rate" value="<?= escapeHtml(number_format(floatval($gs_defaults['config_default_hourly_rate'] ?? 0), 2, '.', '')) ?>">
<input type="hidden" name="net_terms" value="<?= intval($gs_defaults['config_default_net_terms'] ?? 30) ?>">
<div class="row g-3 mb-3">
<div class="col-sm-7">
<?= settingsInput('name', '', ['id' => 'gsClientName', 'icon' => 'fa-user-friends', 'label' => 'Client', 'required' => true, 'maxlength' => 200, 'placeholder' => 'Name or company']) ?>