Bug 19166: Database changes
authorNick Clemens <nick@bywatersolutions.com>
Wed, 23 Aug 2017 16:12:25 +0000 (16:12 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 19 Jul 2018 17:28:35 +0000 (17:28 +0000)
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
installer/data/mysql/atomicupdate/bug_19166.perl [new file with mode: 0644]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_19166.perl b/installer/data/mysql/atomicupdate/bug_19166.perl
new file mode 100644 (file)
index 0000000..5539daa
--- /dev/null
@@ -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";
+}
index bd258e7..1f087d6 100644 (file)
@@ -823,6 +823,25 @@ CREATE TABLE `import_items` (
   KEY `branchcode` (`branchcode`)
 ) 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`
 --