From 8182144bdc4ba7dd3e923f3ad4341c54d21304cf Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 19 Oct 2023 13:53:53 -0500 Subject: [PATCH 1/9] Update database to have discount field on invoice. --- database_updates.php | 14 ++++++++++++-- database_version.php | 2 +- db.sql | 3 +++ 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/database_updates.php b/database_updates.php index 0dd7f23f..289f44c7 100644 --- a/database_updates.php +++ b/database_updates.php @@ -1470,8 +1470,18 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) { // // Then, update the database to the next sequential version mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.0'"); - } - // + } + + if (CURRENT_DATABASE_VERSION == '0.9.0') { + // Insert queries here required to update to DB version 0.9.1 + mysqli_query($mysqli, "ALTER TABLE `invoices` ADD `invoice_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `invoice_due`"); + mysqli_query($mysqli, "ALTER TABLE `recurring` ADD `recurring_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `recurring_status`"); + mysqli_query($mysqli, "ALTER TABLE `quotes` ADD `quote_discount_amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00 AFTER `quote_status`"); + + // Then update the database to the next sequential version + mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.9.1'"); + + } } else { // Up-to-date diff --git a/database_version.php b/database_version.php index 5bea9d6e..6815157f 100644 --- a/database_version.php +++ b/database_version.php @@ -5,4 +5,4 @@ * It is used in conjunction with database_updates.php */ -DEFINE("LATEST_DATABASE_VERSION", "0.9.0"); +DEFINE("LATEST_DATABASE_VERSION", "0.9.1"); diff --git a/db.sql b/db.sql index b1e9bf6f..812955d2 100644 --- a/db.sql +++ b/db.sql @@ -714,6 +714,7 @@ CREATE TABLE `invoices` ( `invoice_status` varchar(200) NOT NULL, `invoice_date` date NOT NULL, `invoice_due` date NOT NULL, + `invoice_discount_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `invoice_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `invoice_currency_code` varchar(200) NOT NULL, `invoice_note` text DEFAULT NULL, @@ -938,6 +939,7 @@ CREATE TABLE `quotes` ( `quote_status` varchar(200) NOT NULL, `quote_date` date NOT NULL, `quote_expire` date DEFAULT NULL, + `quote_discount_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `quote_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `quote_currency_code` varchar(200) NOT NULL, `quote_note` text DEFAULT NULL, @@ -988,6 +990,7 @@ CREATE TABLE `recurring` ( `recurring_last_sent` date DEFAULT NULL, `recurring_next_date` date NOT NULL, `recurring_status` int(1) NOT NULL, + `recurring_discount_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `recurring_amount` decimal(15,2) NOT NULL DEFAULT 0.00, `recurring_currency_code` varchar(200) NOT NULL, `recurring_note` text DEFAULT NULL, From 25d2b48542f56319abb823afa36b1895785fa0f4 Mon Sep 17 00:00:00 2001 From: o-psi Date: Thu, 19 Oct 2023 13:54:39 -0500 Subject: [PATCH 2/9] Add discount to modal, reformat. --- invoice_edit_modal.php | 154 ++++++++++++++++++++++------------------- 1 file changed, 83 insertions(+), 71 deletions(-) diff --git a/invoice_edit_modal.php b/invoice_edit_modal.php index f98cf7cc..38878590 100644 --- a/invoice_edit_modal.php +++ b/invoice_edit_modal.php @@ -1,80 +1,92 @@