From bc0b44699395dab25936237569c48977cb11575c Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Fri, 11 Oct 2019 12:33:55 +0100
Subject: [PATCH] Bug 23049: (follow-up) VARCHAR(80) + ac -> account

---
 Koha/Account/DebitType.pm                        |  2 +-
 Koha/Schema/Result/AccountDebitType.pm           | 16 ++++++++--------
 ...TypesBranch.pm => AccountDebitTypesBranch.pm} | 16 ++++++++--------
 Koha/Schema/Result/Accountline.pm                |  8 ++++----
 Koha/Schema/Result/Branch.pm                     | 12 ++++++------
 .../data/mysql/atomicupdate/bug_23049_debit.perl | 12 ++++++------
 installer/data/mysql/kohastructure.sql           | 12 ++++++------
 7 files changed, 39 insertions(+), 39 deletions(-)
 rename Koha/Schema/Result/{AcDebitTypesBranch.pm => AccountDebitTypesBranch.pm} (79%)

diff --git a/Koha/Account/DebitType.pm b/Koha/Account/DebitType.pm
index 6324ec57cb..123dce1926 100644
--- a/Koha/Account/DebitType.pm
+++ b/Koha/Account/DebitType.pm
@@ -68,7 +68,7 @@ sub _library_limits {
 =cut
 
 sub _type {
-    return 'AccountDebitType';
+    return 'AccountDebitTypesBranch';
 }
 
 1;
diff --git a/Koha/Schema/Result/AccountDebitType.pm b/Koha/Schema/Result/AccountDebitType.pm
index 69f49dabeb..3ffb68b635 100644
--- a/Koha/Schema/Result/AccountDebitType.pm
+++ b/Koha/Schema/Result/AccountDebitType.pm
@@ -27,7 +27,7 @@ __PACKAGE__->table("account_debit_types");
 
   data_type: 'varchar'
   is_nullable: 0
-  size: 64
+  size: 80
 
 =head2 description
 
@@ -57,7 +57,7 @@ __PACKAGE__->table("account_debit_types");
 
 __PACKAGE__->add_columns(
   "code",
-  { data_type => "varchar", is_nullable => 0, size => 64 },
+  { data_type => "varchar", is_nullable => 0, size => 80 },
   "description",
   { data_type => "varchar", is_nullable => 1, size => 200 },
   "can_be_added_manually",
@@ -82,17 +82,17 @@ __PACKAGE__->set_primary_key("code");
 
 =head1 RELATIONS
 
-=head2 ac_debit_types_branches
+=head2 account_debit_types_branches
 
 Type: has_many
 
-Related object: L<Koha::Schema::Result::AcDebitTypesBranch>
+Related object: L<Koha::Schema::Result::AccountDebitTypesBranch>
 
 =cut
 
 __PACKAGE__->has_many(
-  "ac_debit_types_branches",
-  "Koha::Schema::Result::AcDebitTypesBranch",
+  "account_debit_types_branches",
+  "Koha::Schema::Result::AccountDebitTypesBranch",
   { "foreign.debit_type_code" => "self.code" },
   { cascade_copy => 0, cascade_delete => 0 },
 );
@@ -113,8 +113,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-08 11:15:31
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a3+iyqpi4NVpNjDkr9HM/w
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 11:36:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cDUy38YCBUs7I7mIknaasQ
 
 __PACKAGE__->add_columns(
     '+is_system' => { is_boolean => 1 }
diff --git a/Koha/Schema/Result/AcDebitTypesBranch.pm b/Koha/Schema/Result/AccountDebitTypesBranch.pm
similarity index 79%
rename from Koha/Schema/Result/AcDebitTypesBranch.pm
rename to Koha/Schema/Result/AccountDebitTypesBranch.pm
index 26e5825171..46334c147d 100644
--- a/Koha/Schema/Result/AcDebitTypesBranch.pm
+++ b/Koha/Schema/Result/AccountDebitTypesBranch.pm
@@ -1,12 +1,12 @@
 use utf8;
-package Koha::Schema::Result::AcDebitTypesBranch;
+package Koha::Schema::Result::AccountDebitTypesBranch;
 
 # Created by DBIx::Class::Schema::Loader
 # DO NOT MODIFY THE FIRST PART OF THIS FILE
 
 =head1 NAME
 
-Koha::Schema::Result::AcDebitTypesBranch
+Koha::Schema::Result::AccountDebitTypesBranch
 
 =cut
 
@@ -15,11 +15,11 @@ use warnings;
 
 use base 'DBIx::Class::Core';
 
-=head1 TABLE: C<ac_debit_types_branches>
+=head1 TABLE: C<account_debit_types_branches>
 
 =cut
 
-__PACKAGE__->table("ac_debit_types_branches");
+__PACKAGE__->table("account_debit_types_branches");
 
 =head1 ACCESSORS
 
@@ -28,7 +28,7 @@ __PACKAGE__->table("ac_debit_types_branches");
   data_type: 'varchar'
   is_foreign_key: 1
   is_nullable: 1
-  size: 64
+  size: 80
 
 =head2 branchcode
 
@@ -41,7 +41,7 @@ __PACKAGE__->table("ac_debit_types_branches");
 
 __PACKAGE__->add_columns(
   "debit_type_code",
-  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 64 },
+  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 80 },
   "branchcode",
   { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
 );
@@ -89,8 +89,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-04 07:57:30
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uVA4axnWjQjFOPqvM0hqyw
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 11:36:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HFOAT6jt7WwLp0myHu/dDA
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm
index 48b3dca958..a30290dcab 100644
--- a/Koha/Schema/Result/Accountline.pm
+++ b/Koha/Schema/Result/Accountline.pm
@@ -74,7 +74,7 @@ __PACKAGE__->table("accountlines");
   data_type: 'varchar'
   is_foreign_key: 1
   is_nullable: 1
-  size: 64
+  size: 80
 
 =head2 status
 
@@ -151,7 +151,7 @@ __PACKAGE__->add_columns(
   "accounttype",
   { data_type => "varchar", is_nullable => 1, size => 80 },
   "debit_type_code",
-  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 64 },
+  { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 80 },
   "status",
   { data_type => "varchar", is_nullable => 1, size => 16 },
   "payment_type",
@@ -342,8 +342,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-08 11:15:31
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1Vgkg0JR7RqmkniOmUoUhQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 11:36:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WZ2Mcd5gwQc69yDSEsJHGA
 
 sub koha_objects_class {
     'Koha::Account::Lines';
diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm
index fa9679eb2e..579edb8e39 100644
--- a/Koha/Schema/Result/Branch.pm
+++ b/Koha/Schema/Result/Branch.pm
@@ -211,17 +211,17 @@ __PACKAGE__->set_primary_key("branchcode");
 
 =head1 RELATIONS
 
-=head2 ac_debit_types_branches
+=head2 account_debit_types_branches
 
 Type: has_many
 
-Related object: L<Koha::Schema::Result::AcDebitTypesBranch>
+Related object: L<Koha::Schema::Result::AccountDebitTypesBranch>
 
 =cut
 
 __PACKAGE__->has_many(
-  "ac_debit_types_branches",
-  "Koha::Schema::Result::AcDebitTypesBranch",
+  "account_debit_types_branches",
+  "Koha::Schema::Result::AccountDebitTypesBranch",
   { "foreign.branchcode" => "self.branchcode" },
   { cascade_copy => 0, cascade_delete => 0 },
 );
@@ -692,8 +692,8 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-09-26 15:59:23
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:IiEBfDpMBAi9cv7OqevVRQ
+# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 11:36:33
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HCQKMSgKhVKtDSrvs1IeRg
 
 __PACKAGE__->add_columns(
     '+pickup_location' => { is_boolean => 1 }
diff --git a/installer/data/mysql/atomicupdate/bug_23049_debit.perl b/installer/data/mysql/atomicupdate/bug_23049_debit.perl
index 0fab0a600d..fd3faa306f 100644
--- a/installer/data/mysql/atomicupdate/bug_23049_debit.perl
+++ b/installer/data/mysql/atomicupdate/bug_23049_debit.perl
@@ -5,7 +5,7 @@ if ( CheckVersion($DBversion) ) {
     $dbh->do(
         qq{
             CREATE TABLE IF NOT EXISTS account_debit_types (
-              code varchar(64) NOT NULL,
+              code varchar(80) NOT NULL,
               description varchar(200) NULL,
               can_be_added_manually tinyint(4) NOT NULL DEFAULT 1,
               default_amount decimal(28, 6) NULL,
@@ -15,11 +15,11 @@ if ( CheckVersion($DBversion) ) {
           }
     );
 
-    # Adding ac_debit_types_branches
+    # Adding account_debit_types_branches
     $dbh->do(
         qq{
-            CREATE TABLE IF NOT EXISTS ac_debit_types_branches (
-                debit_type_code VARCHAR(64),
+            CREATE TABLE IF NOT EXISTS account_debit_types_branches (
+                debit_type_code VARCHAR(80),
                 branchcode VARCHAR(10),
                 FOREIGN KEY (debit_type_code) REFERENCES account_debit_types(code) ON DELETE CASCADE,
                 FOREIGN KEY (branchcode) REFERENCES branches(branchcode) ON DELETE CASCADE
@@ -93,7 +93,7 @@ if ( CheckVersion($DBversion) ) {
               is_system
             )
             SELECT
-              SUBSTR(authorised_value, 1, 64),
+              SUBSTR(authorised_value, 1, 80),
               lib,
               authorised_value,
               1,
@@ -111,7 +111,7 @@ if ( CheckVersion($DBversion) ) {
             qq{
                 ALTER IGNORE TABLE accountlines
                 ADD
-                  debit_type_code varchar(64) DEFAULT NULL
+                  debit_type_code varchar(80) DEFAULT NULL
                 AFTER
                   accounttype
               }
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index 7ff520decc..e720809171 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -2627,7 +2627,7 @@ CREATE TABLE `cash_registers` (
 
 DROP TABLE IF EXISTS `account_debit_types`;
 CREATE TABLE `account_debit_types` (
-  `code` varchar(64) NOT NULL,
+  `code` varchar(80) NOT NULL,
   `description` varchar(200) DEFAULT NULL,
   `can_be_added_manually` tinyint(4) NOT NULL DEFAULT 1,
   `default_amount` decimal(28,6) DEFAULT NULL,
@@ -2636,12 +2636,12 @@ CREATE TABLE `account_debit_types` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
 --
--- Table structure for table `ac_debit_types_branches`
+-- Table structure for table `account_debit_types_branches`
 --
 
-DROP TABLE IF EXISTS `ac_debit_types_branches`;
-CREATE TABLE `ac_debit_types_branches` (
-    `debit_type_code` VARCHAR(64),
+DROP TABLE IF EXISTS `account_debit_types_branches`;
+CREATE TABLE `account_debit_types_branches` (
+    `debit_type_code` VARCHAR(80),
     `branchcode` VARCHAR(10),
     FOREIGN KEY (`debit_type_code`) REFERENCES `account_debit_types` (`code`) ON DELETE CASCADE,
     FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE
@@ -2661,7 +2661,7 @@ CREATE TABLE `accountlines` (
   `amount` decimal(28,6) default NULL,
   `description` LONGTEXT,
   `accounttype` varchar(80) default NULL,
-  `debit_type_code` varchar(64) default NULL,
+  `debit_type_code` varchar(80) default NULL,
   `status` varchar(16) default NULL,
   `payment_type` varchar(80) default NULL, -- optional authorised value PAYMENT_TYPE
   `amountoutstanding` decimal(28,6) default NULL,
-- 
2.20.1