From 775c2103b8df75fcfc6eaadc5b20567e19c9c733 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 23 Aug 2017 16:12:25 +0000 Subject: [PATCH] Bug 19166: Database changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer --- installer/data/mysql/atomicupdate/bug_19166.perl | 20 ++++++++++++++++++++ installer/data/mysql/kohastructure.sql | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_19166.perl diff --git a/installer/data/mysql/atomicupdate/bug_19166.perl b/installer/data/mysql/atomicupdate/bug_19166.perl new file mode 100644 index 0000000..5539daa --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_19166.perl @@ -0,0 +1,20 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + $dbh->do( " + CREATE TABLE IF NOT EXISTS invoice_adjustments ( + adjustment_id int(11) NOT NULL AUTO_INCREMENT, + invoiceid int(11) NOT NULL, + adjustment decimal(28,6), + reason varchar(80) default NULL, + note mediumtext default NULL, + budget_id int(11) default NULL, + encumber_open smallint(1) NOT NULL default 1, + timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (adjustment_id), + CONSTRAINT invoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT invoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE + ) + " ); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 19166 - Add the ability to add adjustments to an invoice)\n"; +} diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 34545d0..8ef1fc2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -824,6 +824,25 @@ CREATE TABLE `import_items` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- +-- Table structure for table 'invoice_adjustments' +-- + +DROP TABLE IF EXISTS invoice_adjustments; +CREATE TABLE IF NOT EXISTS invoice_adjustments ( + adjustment_id int(11) NOT NULL AUTO_INCREMENT, -- primary key for adjustments + invoiceid int(11) NOT NULL, -- foreign key to link an adjustment to an invoice + adjustment decimal(28,6), -- amount of adjustment + reason varchar(80) default NULL, -- reason for adjustment defined by authorised values in ADJ_REASON category + note mediumtext default NULL, -- text to explain adjustment + budget_id int(11) default NULL, -- optional link to budget to apply adjustment to + encumber_open smallint(1) NOT NULL default 1, -- whether or not to encumber the finds when invoice is still open, 1 = yes, 0 = no + timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- timestamp of last adjustment to adjustment + PRIMARY KEY (adjustment_id), + CONSTRAINT invoice_adjustments_fk_invoiceid FOREIGN KEY (invoiceid) REFERENCES aqinvoices (invoiceid) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT invoice_adjustments_fk_budget_id FOREIGN KEY (budget_id) REFERENCES aqbudgets (budget_id) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- -- Table structure for table `issuingrules` -- -- 2.1.4