Files
itflow/admin/database_updates/2.9.3.php
johnnyq 2fcdd6006b Invoices, quotes and recurring invoices makeover stage 4: quote lines billed one time or each month, quarter or year with a Billed choice on the add-a-line row and in Edit Line, quotes grouped into One-time, Each month, Each quarter and Each year with a total for each on the page, PDF and client view, lines dragged within their own group, Start Billing on accepted quotes putting one-time lines on a draft invoice due on the client's terms and each recurring part on a new recurring invoice from a chosen date, emailed or left as drafts, or added to one of the client's recurring invoices of the same frequency, with an option to bill the first period on the invoice, an Invoiced as card on the quote linking every invoice and recurring invoice it became including ones it added lines to, From links back on invoices and recurring invoices, monthly amounts in the quotes list and its totals, search, client portal, quote email, Send and Copy windows, quotes export and client export, and Quotes Pipeline valuing quotes at up front plus a year of recurring lines. Fixes Make Invoice invoicing a quote twice or one never accepted, and its audit entry using the current quote prefix instead of the quote's own. Adds DB 2.9.3 with item_frequency, quote_monthly_amount, invoice_quote_id and recurring_invoice_quote_id, linking invoices to their quotes from history, quoteConvert() as the one invoicing path claiming the quote in a transaction, quoteLineGroups(), quoteAmountText() and quoteMadeFrom(), reportCsv() totals written as given, and updates the 26.11 changelog
2026-10-16 14:14:53 -04:00

28 lines
1.7 KiB
PHP

<?php
/*
* ITFlow - Database update to version 2.9.3 (from 2.9.2)
* Included by admin/database_updates.php - do not access directly
*/
defined('FROM_DB_UPDATER') || die("Direct file access is not allowed");
// Quotes with monthly lines (functions/billing.php, Quotes). A quote line is
// billed once (NULL) or each month, quarter or year - those go on a
// recurring invoice when the quote is invoiced. quote_amount stays what is
// billed once; quote_monthly_amount is what the recurring lines come to a
// month (a quarterly line a third, a yearly one a twelfth).
mysqli_query($mysqli, "ALTER TABLE `quote_items` ADD COLUMN `item_frequency` varchar(10) DEFAULT NULL AFTER `item_order`");
mysqli_query($mysqli, "ALTER TABLE `quotes` ADD COLUMN `quote_monthly_amount` decimal(15,2) NOT NULL DEFAULT 0.00 AFTER `quote_amount`");
// What a quote became - the invoice and recurring invoices made from it
mysqli_query($mysqli, "ALTER TABLE `invoices` ADD COLUMN `invoice_quote_id` int(11) NOT NULL DEFAULT 0 AFTER `invoice_recurring_invoice_id`");
mysqli_query($mysqli, "ALTER TABLE `recurring_invoices` ADD COLUMN `recurring_invoice_quote_id` int(11) NOT NULL DEFAULT 0 AFTER `recurring_invoice_category_id`");
// Invoices made from a quote before now say so only in their history - link them
mysqli_query($mysqli, "UPDATE `invoices`
JOIN `history` ON `history_invoice_id` = `invoice_id`
JOIN `quotes` ON `history_description` = CONCAT('Invoice created from quote ', `quote_prefix`, `quote_number`) AND `quote_client_id` = `invoice_client_id`
SET `invoice_quote_id` = `quote_id`
WHERE `invoice_quote_id` = 0");