Bug 25655: DB changes
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 16 Jan 2023 20:09:05 +0000 (21:09 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 6 Mar 2023 16:57:53 +0000 (13:57 -0300)
Sponsored-by: The Research University in the Helmholtz Association (KIT)
Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/bug_25655.pl [new file with mode: 0755]
installer/data/mysql/kohastructure.sql

diff --git a/installer/data/mysql/atomicupdate/bug_25655.pl b/installer/data/mysql/atomicupdate/bug_25655.pl
new file mode 100755 (executable)
index 0000000..01be1a1
--- /dev/null
@@ -0,0 +1,26 @@
+use Modern::Perl;
+
+return {
+    bug_number => "25655",
+    description => "Store actual cost in foreign currency and currency from the invoices",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+        unless ( column_exists('aqorders', 'invoice_unitprice') ) {
+            $dbh->do(q{
+                ALTER TABLE aqorders
+                ADD COLUMN invoice_unitprice decimal(28,6) DEFAULT NULL COMMENT 'the unit price in foreign currency' AFTER estimated_delivery_date
+            });
+        }
+        say $out "Added column 'aqorders.invoice_unitprice'";
+
+        unless ( column_exists('aqorders', 'invoice_currency') ) {
+            $dbh->do(q{
+                ALTER TABLE aqorders
+                ADD COLUMN invoice_currency varchar(10) DEFAULT NULL COMMENT 'the currency of the invoice_unitprice' AFTER invoice_unitprice,
+                ADD CONSTRAINT `aqorders_invoice_currency` FOREIGN KEY (`invoice_currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL
+            });
+        }
+        say $out "Added column 'aqorders.invoice_currency'";
+    },
+};
index d87b9e9..afbd7e1 100644 (file)
@@ -690,6 +690,8 @@ CREATE TABLE `aqorders` (
   `suppliers_reference_qualifier` varchar(3) DEFAULT NULL COMMENT 'Type of number above usually ''QLI''',
   `suppliers_report` mediumtext DEFAULT NULL COMMENT 'reports received from suppliers',
   `estimated_delivery_date` date DEFAULT NULL COMMENT 'Estimated delivery date',
+  `invoice_unitprice` decimal(28,6) DEFAULT NULL COMMENT 'the unit price in foreign currency',
+  `invoice_currency` varchar(10) DEFAULT NULL COMMENT 'the currency of the invoice_unitprice',
   PRIMARY KEY (`ordernumber`),
   KEY `basketno` (`basketno`),
   KEY `biblionumber` (`biblionumber`),
@@ -703,6 +705,7 @@ CREATE TABLE `aqorders` (
   CONSTRAINT `aqorders_budget_id_fk` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `aqorders_created_by` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT `aqorders_currency` FOREIGN KEY (`currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL,
+  CONSTRAINT `aqorders_invoice_currency` FOREIGN KEY (`invoice_currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL,
   CONSTRAINT `aqorders_ibfk_1` FOREIGN KEY (`basketno`) REFERENCES `aqbasket` (`basketno`) ON DELETE CASCADE ON UPDATE CASCADE,
   CONSTRAINT `aqorders_ibfk_2` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE,
   CONSTRAINT `aqorders_ibfk_3` FOREIGN KEY (`invoiceid`) REFERENCES `aqinvoices` (`invoiceid`) ON DELETE SET NULL ON UPDATE CASCADE,