From ceba85dfd56b474594d0f6911d02f80621e8b74d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 13 Jan 2020 14:12:47 +0000 Subject: [PATCH] Bug 23354: DBRev 19.12.00.009 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- .../data/mysql/atomicupdate/bug_23354.perl | 117 ---------------- .../atomicupdate/bug_23354_permissions.perl | 13 -- installer/data/mysql/updatedatabase.pl | 125 ++++++++++++++++++ 4 files changed, 126 insertions(+), 131 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_23354.perl delete mode 100644 installer/data/mysql/atomicupdate/bug_23354_permissions.perl diff --git a/Koha.pm b/Koha.pm index 7d7f234402..989ad48446 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "19.12.00.008"; +$VERSION = "19.12.00.009"; sub version { return $VERSION; diff --git a/installer/data/mysql/atomicupdate/bug_23354.perl b/installer/data/mysql/atomicupdate/bug_23354.perl deleted file mode 100644 index cec1fdc5eb..0000000000 --- a/installer/data/mysql/atomicupdate/bug_23354.perl +++ /dev/null @@ -1,117 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - - $dbh->do(q{ - INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Purchase' ); - }); - - $dbh->do(q{ - INSERT IGNORE INTO account_credit_types ( code, description, can_be_added_manually, is_system ) - VALUES ('PURCHASE', 'Purchase', 0, 1); - }); - - my $sth = $dbh->prepare(q{ - SELECT COUNT(*) FROM authorised_values WHERE category = 'PAYMENT_TYPE' AND authorised_value = 'CASH' - }); - $sth->execute; - my $already_exists = $sth->fetchrow; - if ( not $already_exists ) { - $dbh->do(q{ - INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('PAYMENT_TYPE','CASH','Cash') - }); - } - - # Updating field in account_debit_types - unless ( column_exists('account_debit_types', 'can_be_invoiced') ) { - $dbh->do( - qq{ - ALTER TABLE account_debit_types - CHANGE COLUMN - can_be_added_manually can_be_invoiced tinyint(1) NOT NULL DEFAULT 1 - } - ); - } - unless ( column_exists('account_debit_types', 'can_be_sold') ) { - $dbh->do( - qq{ - ALTER IGNORE TABLE account_debit_types - ADD - can_be_sold tinyint(1) DEFAULT 0 - AFTER - can_be_invoiced - } - ); - } - - $dbh->do(q{ -INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES -('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', '[% PROCESS "accounts.inc" %] - -[% IF ( LibraryName ) %] - - - -[% END %] - - - - - - - - - - - - - - - - - - - - - - - - - - - - [% FOREACH offset IN offsets %] - - - - - [% END %] - - - - - - - - - - - - - - - -
-

[% LibraryName | html %]

-
-

[% Branches.GetName( payment.branchcode ) | html %]

-
-

[% payment.date | $KohaDates %]

-
Transaction ID: [% payment.accountlines_id %]
Operator ID: [% payment.manager_id %]
Payment type: [% payment.payment_type %]
-

Fee receipt

-
Description of chargesAmount
[% PROCESS account_type_description account=offset.debit %][% offset.amount * -1 | $Price %]
Total: [% payment.amount * -1| $Price %]
Tendered: [% collected | $Price %]
Change: [% change | $Price %]
', 'print', 'default'); - }); - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 23354 - Add 'Purchase' account offset type)\n"; - print "Upgrade to $DBversion done (Bug 23354 - Add 'RECEIPT' notice for Point of Sale)\n"; -} diff --git a/installer/data/mysql/atomicupdate/bug_23354_permissions.perl b/installer/data/mysql/atomicupdate/bug_23354_permissions.perl deleted file mode 100644 index 05b1d7d453..0000000000 --- a/installer/data/mysql/atomicupdate/bug_23354_permissions.perl +++ /dev/null @@ -1,13 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if ( CheckVersion($DBversion) ) { - - $dbh->do(qq{ - INSERT IGNORE permissions (module_bit, code, description) - VALUES - (25, 'takepayment', 'Access the point of sale page and take payments') - }); - - - SetVersion($DBversion); - print "Upgrade to $DBversion done (Bug 23354 - Add point of sale permissions)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 61b1fc31ca..e45c39836c 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20360,6 +20360,131 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 24206 - Update OpacSearchForTitleIn system preference)\n"; } +$DBversion = '19.12.00.009'; +if( CheckVersion( $DBversion ) ) { + + $dbh->do(q{ + INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Purchase' ); + }); + + $dbh->do(q{ + INSERT IGNORE INTO account_credit_types ( code, description, can_be_added_manually, is_system ) + VALUES ('PURCHASE', 'Purchase', 0, 1); + }); + + my $sth = $dbh->prepare(q{ + SELECT COUNT(*) FROM authorised_values WHERE category = 'PAYMENT_TYPE' AND authorised_value = 'CASH' + }); + $sth->execute; + my $already_exists = $sth->fetchrow; + if ( not $already_exists ) { + $dbh->do(q{ + INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('PAYMENT_TYPE','CASH','Cash') + }); + } + + # Updating field in account_debit_types + unless ( column_exists('account_debit_types', 'can_be_invoiced') ) { + $dbh->do( + qq{ + ALTER TABLE account_debit_types + CHANGE COLUMN + can_be_added_manually can_be_invoiced tinyint(1) NOT NULL DEFAULT 1 + } + ); + } + unless ( column_exists('account_debit_types', 'can_be_sold') ) { + $dbh->do( + qq{ + ALTER IGNORE TABLE account_debit_types + ADD + can_be_sold tinyint(1) DEFAULT 0 + AFTER + can_be_invoiced + } + ); + } + + $dbh->do(q{ +INSERT IGNORE INTO `letter` (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`, `lang`) VALUES +('pos', 'RECEIPT', '', 'Point of sale receipt', 0, 'Receipt', '[% PROCESS "accounts.inc" %] + +[% IF ( LibraryName ) %] + + + +[% END %] + + + + + + + + + + + + + + + + + + + + + + + + + + + + [% FOREACH offset IN offsets %] + + + + + [% END %] + + + + + + + + + + + + + + + +
+

[% LibraryName | html %]

+
+

[% Branches.GetName( payment.branchcode ) | html %]

+
+

[% payment.date | $KohaDates %]

+
Transaction ID: [% payment.accountlines_id %]
Operator ID: [% payment.manager_id %]
Payment type: [% payment.payment_type %]
+

Fee receipt

+
Description of chargesAmount
[% PROCESS account_type_description account=offset.debit %][% offset.amount * -1 | $Price %]
Total: [% payment.amount * -1| $Price %]
Tendered: [% collected | $Price %]
Change: [% change | $Price %]
', 'print', 'default'); + }); + + $dbh->do(qq{ + INSERT IGNORE permissions (module_bit, code, description) + VALUES + (25, 'takepayment', 'Access the point of sale page and take payments') + }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 23354 - Add 'Purchase' account offset type)\n"; + print "Upgrade to $DBversion done (Bug 23354 - Add 'RECEIPT' notice for Point of Sale)\n"; + print "Upgrade to $DBversion done (Bug 23354 - Add point of sale permissions)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.39.5