Bugzilla – Attachment 67464 Details for
Bug 14826
Store account offsets
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14826: Add account offset type table
Bug-14826-Add-account-offset-type-table.patch (text/plain), 8.54 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-09-29 14:02:09 UTC
(
hide
)
Description:
Bug 14826: Add account offset type table
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-09-29 14:02:09 UTC
Size:
8.54 KB
patch
obsolete
>From c1009d97702a84297503502552d267c80147789e Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 1 Sep 2017 07:51:49 -0400 >Subject: [PATCH] Bug 14826: Add account offset type table > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > C4/Installer.pm | 1 + > Koha/Schema/Result/AccountOffset.pm | 22 +++++++- > Koha/Schema/Result/AccountOffsetType.pm | 74 +++++++++++++++++++++++++ > installer/data/mysql/account_offset_types.sql | 11 ++++ > installer/data/mysql/atomicupdate/bug_14826.sql | 21 ++++++- > installer/data/mysql/kohastructure.sql | 13 ++++- > misc/devel/populate_db.pl | 1 + > 7 files changed, 137 insertions(+), 6 deletions(-) > create mode 100644 Koha/Schema/Result/AccountOffsetType.pm > create mode 100644 installer/data/mysql/account_offset_types.sql > >diff --git a/C4/Installer.pm b/C4/Installer.pm >index 866d1f2..74ae288 100644 >--- a/C4/Installer.pm >+++ b/C4/Installer.pm >@@ -327,6 +327,7 @@ sub load_sql_in_order { > push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userpermissions.sql"; > push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/audio_alerts.sql"; > push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/mandatory/refund_lost_item_fee_rules.sql"; >+ push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/mandatory/account_offset_types.sql"; > foreach my $file (@fnames) { > # warn $file; > undef $/; >diff --git a/Koha/Schema/Result/AccountOffset.pm b/Koha/Schema/Result/AccountOffset.pm >index dc9099f..013cb69 100644 >--- a/Koha/Schema/Result/AccountOffset.pm >+++ b/Koha/Schema/Result/AccountOffset.pm >@@ -44,6 +44,7 @@ __PACKAGE__->table("account_offsets"); > =head2 type > > data_type: 'varchar' >+ is_foreign_key: 1 > is_nullable: 0 > size: 16 > >@@ -70,7 +71,7 @@ __PACKAGE__->add_columns( > "debit_id", > { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, > "type", >- { data_type => "varchar", is_nullable => 0, size => 16 }, >+ { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 16 }, > "amount", > { data_type => "decimal", is_nullable => 0, size => [26, 6] }, > "created_on", >@@ -136,9 +137,24 @@ __PACKAGE__->belongs_to( > }, > ); > >+=head2 type >+ >+Type: belongs_to >+ >+Related object: L<Koha::Schema::Result::AccountOffsetType> >+ >+=cut >+ >+__PACKAGE__->belongs_to( >+ "type", >+ "Koha::Schema::Result::AccountOffsetType", >+ { type => "type" }, >+ { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, >+); >+ > >-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-02-15 16:13:26 >-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CQ2SRBUEiVgEVhe88acqqA >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-09-01 11:00:44 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EFxhLJ1SMRwknCaS5srYZA > > > # You can replace this text with custom code or comments, and it will be preserved on regeneration >diff --git a/Koha/Schema/Result/AccountOffsetType.pm b/Koha/Schema/Result/AccountOffsetType.pm >new file mode 100644 >index 0000000..636d8a0 >--- /dev/null >+++ b/Koha/Schema/Result/AccountOffsetType.pm >@@ -0,0 +1,74 @@ >+use utf8; >+package Koha::Schema::Result::AccountOffsetType; >+ >+# Created by DBIx::Class::Schema::Loader >+# DO NOT MODIFY THE FIRST PART OF THIS FILE >+ >+=head1 NAME >+ >+Koha::Schema::Result::AccountOffsetType >+ >+=cut >+ >+use strict; >+use warnings; >+ >+use base 'DBIx::Class::Core'; >+ >+=head1 TABLE: C<account_offset_types> >+ >+=cut >+ >+__PACKAGE__->table("account_offset_types"); >+ >+=head1 ACCESSORS >+ >+=head2 type >+ >+ data_type: 'varchar' >+ is_nullable: 0 >+ size: 16 >+ >+=cut >+ >+__PACKAGE__->add_columns( >+ "type", >+ { data_type => "varchar", is_nullable => 0, size => 16 }, >+); >+ >+=head1 PRIMARY KEY >+ >+=over 4 >+ >+=item * L</type> >+ >+=back >+ >+=cut >+ >+__PACKAGE__->set_primary_key("type"); >+ >+=head1 RELATIONS >+ >+=head2 account_offsets >+ >+Type: has_many >+ >+Related object: L<Koha::Schema::Result::AccountOffset> >+ >+=cut >+ >+__PACKAGE__->has_many( >+ "account_offsets", >+ "Koha::Schema::Result::AccountOffset", >+ { "foreign.type" => "self.type" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ >+ >+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-09-01 11:00:44 >+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PSvAX6W0Sv/MOy6pA/GB5Q >+ >+ >+# You can replace this text with custom code or comments, and it will be preserved on regeneration >+1; >diff --git a/installer/data/mysql/account_offset_types.sql b/installer/data/mysql/account_offset_types.sql >new file mode 100644 >index 0000000..2f9004c >--- /dev/null >+++ b/installer/data/mysql/account_offset_types.sql >@@ -0,0 +1,11 @@ >+INSERT INTO account_offset_types ( type ) VALUES >+('Writeoff'), >+('Payment'), >+('Lost Item'), >+('Manual Debit'), >+('Reverse Payment'), >+('Forgiven'), >+('Dropbox'), >+('Rental Fee'), >+('Fine Update'), >+('Fine'); >diff --git a/installer/data/mysql/atomicupdate/bug_14826.sql b/installer/data/mysql/atomicupdate/bug_14826.sql >index 91d183b..bfbcf1b 100644 >--- a/installer/data/mysql/atomicupdate/bug_14826.sql >+++ b/installer/data/mysql/atomicupdate/bug_14826.sql >@@ -1,4 +1,8 @@ >-DROP TABLE IF EXISTS `accountoffsets`; >+CREATE TABLE `account_offset_types` ( >+ `type` varchar(16) NOT NULL, -- The type of offset this is >+ PRIMARY KEY (`type`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; >+ > CREATE TABLE IF NOT EXISTS `account_offsets` ( > `id` int(11) NOT NULL auto_increment, -- unique identifier for each offset > `credit_id` int(11) NULL DEFAULT NULL, -- The id of the accountline the increased the patron's balance >@@ -8,5 +12,18 @@ CREATE TABLE IF NOT EXISTS `account_offsets` ( > `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP, > PRIMARY KEY (`id`), > CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE, >- CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE >+ CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE, >+ CONSTRAINT `account_offsets_ibfk_t` FOREIGN KEY (`type`) REFERENCES `account_offset_types` (`type`) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; >+ >+INSERT INTO account_offset_types ( type ) VALUES >+('Writeoff'), >+('Payment'), >+('Lost Item'), >+('Manual Debit'), >+('Reverse Payment'), >+('Forgiven'), >+('Dropbox'), >+('Rental Fee'), >+('Fine Update'), >+('Fine'); >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 445cd2e..9485a73 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2735,6 +2735,16 @@ CREATE TABLE `accountlines` ( > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >+-- Table structure for table `account_offset_types` >+-- >+ >+DROP TABLE IF EXISTS `account_offset_types`; >+CREATE TABLE `account_offset_types` ( >+ `type` varchar(16) NOT NULL, -- The type of offset this is >+ PRIMARY KEY (`type`) >+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; >+ >+-- > -- Table structure for table `account_offsets` > -- > >@@ -2748,7 +2758,8 @@ CREATE TABLE `account_offsets` ( > `created_on` timestamp NOT NULL default CURRENT_TIMESTAMP, > PRIMARY KEY (`id`), > CONSTRAINT `account_offsets_ibfk_p` FOREIGN KEY (`credit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE, >- CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE >+ CONSTRAINT `account_offsets_ibfk_f` FOREIGN KEY (`debit_id`) REFERENCES `accountlines` (`accountlines_id`) ON DELETE CASCADE ON UPDATE CASCADE, >+ CONSTRAINT `account_offsets_ibfk_t` FOREIGN KEY (`type`) REFERENCES `account_offset_types` (`type`) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; > > -- >diff --git a/misc/devel/populate_db.pl b/misc/devel/populate_db.pl >index 9bad049..e419e37 100755 >--- a/misc/devel/populate_db.pl >+++ b/misc/devel/populate_db.pl >@@ -106,6 +106,7 @@ my @sample_files_mandatory = ( > "$data_dir/sysprefs.sql", > "$data_dir/userflags.sql", > "$data_dir/userpermissions.sql", >+ "$data_dir/account_offset_types.sql", > ); > my @sample_lang_files_mandatory = ( glob $root . "/installer/data/mysql/$lang/mandatory/*.sql" ); > my @sample_lang_files_optional = ( glob $root . "/installer/data/mysql/$lang/optional/*.sql" ); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14826
:
53318
|
53319
|
53320
|
53321
|
53324
|
53326
|
53602
|
53603
|
53604
|
53605
|
53606
|
53607
|
59254
|
59255
|
59256
|
59257
|
59258
|
60270
|
60271
|
60272
|
60273
|
60274
|
60275
|
60276
|
60277
|
60278
|
60439
|
60440
|
60441
|
60442
|
60443
|
60444
|
60445
|
60446
|
64051
|
64052
|
64053
|
64054
|
64055
|
64056
|
64057
|
64058
|
64059
|
64217
|
64220
|
64222
|
64223
|
64224
|
64225
|
64226
|
64227
|
64228
|
65459
|
65460
|
65461
|
65462
|
65463
|
65464
|
65465
|
65466
|
65467
|
65642
|
65643
|
65644
|
65645
|
65646
|
65647
|
65648
|
65649
|
65650
|
65651
|
65652
|
66387
|
66388
|
66389
|
66390
|
66391
|
66392
|
66393
|
66394
|
66395
|
66396
|
66397
|
66716
|
67453
|
67454
|
67455
|
67456
|
67457
|
67458
|
67459
|
67460
|
67461
|
67462
|
67463
|
67464
|
67465
|
67936
|
67937
|
67938
|
67939
|
67940
|
67941
|
67942
|
67943
|
67944
|
67945
|
67946
|
67947
|
67948
|
67949
|
68018
|
68019
|
68020
|
68021
|
68022
|
68023
|
68024
|
68025
|
68026
|
68027
|
68028
|
68029
|
68030
|
68031
|
68032
|
68334
|
68383