From df05ac5f5b6e7feb539795eef36ba4edd52399c6 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 25 Oct 2019 14:37:34 +0100 Subject: [PATCH] Bug 23354: (follow-up) Ensure 'CASH' payment type is present Signed-off-by: Kyle M Hall --- installer/data/mysql/account_credit_types.sql | 2 ++ installer/data/mysql/atomicupdate/bug_23354.perl | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/installer/data/mysql/account_credit_types.sql b/installer/data/mysql/account_credit_types.sql index 06fca15898..20e15ebbc7 100644 --- a/installer/data/mysql/account_credit_types.sql +++ b/installer/data/mysql/account_credit_types.sql @@ -5,3 +5,5 @@ INSERT INTO account_credit_types ( code, description, can_be_added_manually, is_ ('CREDIT', 'Credit', 1, 1), ('REFUND', 'A refund applied to a patrons fine', 0, 1), ('LOST_RETURN', 'Lost item fee refund', 0, 1); + +INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('PAYMENT_TYPE','CASH','Cash'); diff --git a/installer/data/mysql/atomicupdate/bug_23354.perl b/installer/data/mysql/atomicupdate/bug_23354.perl index 9e7d269303..2e920c459d 100644 --- a/installer/data/mysql/atomicupdate/bug_23354.perl +++ b/installer/data/mysql/atomicupdate/bug_23354.perl @@ -5,6 +5,17 @@ if( CheckVersion( $DBversion ) ) { INSERT IGNORE INTO account_offset_types ( type ) VALUES ( 'Purchase' ); }); + 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( -- 2.20.1