From d31e5c2a87279d57df1256ebf62134b6268cee17 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 15 Oct 2019 09:43:46 +0100 Subject: [PATCH] Bug 23805: DBIC Classes Signed-off-by: Kyle Hall Signed-off-by: Tomas Cohen Arazi Signed-off-by: Martin Renvoize --- Koha/Schema/Result/AccountCreditType.pm | 113 ++++++++++++++++++ .../Schema/Result/AccountCreditTypesBranch.pm | 97 +++++++++++++++ Koha/Schema/Result/Accountline.pm | 27 ++++- Koha/Schema/Result/Branch.pm | 19 ++- 4 files changed, 251 insertions(+), 5 deletions(-) create mode 100644 Koha/Schema/Result/AccountCreditType.pm create mode 100644 Koha/Schema/Result/AccountCreditTypesBranch.pm diff --git a/Koha/Schema/Result/AccountCreditType.pm b/Koha/Schema/Result/AccountCreditType.pm new file mode 100644 index 0000000000..015fd3c0ec --- /dev/null +++ b/Koha/Schema/Result/AccountCreditType.pm @@ -0,0 +1,113 @@ +use utf8; +package Koha::Schema::Result::AccountCreditType; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::AccountCreditType + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("account_credit_types"); + +=head1 ACCESSORS + +=head2 code + + data_type: 'varchar' + is_nullable: 0 + size: 80 + +=head2 description + + data_type: 'varchar' + is_nullable: 1 + size: 200 + +=head2 can_be_added_manually + + data_type: 'tinyint' + default_value: 1 + is_nullable: 0 + +=head2 is_system + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "code", + { data_type => "varchar", is_nullable => 0, size => 80 }, + "description", + { data_type => "varchar", is_nullable => 1, size => 200 }, + "can_be_added_manually", + { data_type => "tinyint", default_value => 1, is_nullable => 0 }, + "is_system", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("code"); + +=head1 RELATIONS + +=head2 account_credit_types_branches + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "account_credit_types_branches", + "Koha::Schema::Result::AccountCreditTypesBranch", + { "foreign.credit_type_code" => "self.code" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 accountlines + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "accountlines", + "Koha::Schema::Result::Accountline", + { "foreign.credit_type_code" => "self.code" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-14 09:59:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Uycu/23b681kWHNX+/gNiw + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/AccountCreditTypesBranch.pm b/Koha/Schema/Result/AccountCreditTypesBranch.pm new file mode 100644 index 0000000000..40ea9ab560 --- /dev/null +++ b/Koha/Schema/Result/AccountCreditTypesBranch.pm @@ -0,0 +1,97 @@ +use utf8; +package Koha::Schema::Result::AccountCreditTypesBranch; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::AccountCreditTypesBranch + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("account_credit_types_branches"); + +=head1 ACCESSORS + +=head2 credit_type_code + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 1 + size: 80 + +=head2 branchcode + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 1 + size: 10 + +=cut + +__PACKAGE__->add_columns( + "credit_type_code", + { 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 }, +); + +=head1 RELATIONS + +=head2 branchcode + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "branchcode", + "Koha::Schema::Result::Branch", + { branchcode => "branchcode" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "RESTRICT", + }, +); + +=head2 credit_type_code + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "credit_type_code", + "Koha::Schema::Result::AccountCreditType", + { code => "credit_type_code" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "RESTRICT", + }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-14 09:59:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1oX/zPeT8gmc3ZwdTiyovA + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm index 1561f99d68..e77ff5be55 100644 --- a/Koha/Schema/Result/Accountline.pm +++ b/Koha/Schema/Result/Accountline.pm @@ -63,9 +63,10 @@ __PACKAGE__->table("accountlines"); data_type: 'longtext' is_nullable: 1 -=head2 accounttype +=head2 credit_type_code data_type: 'varchar' + is_foreign_key: 1 is_nullable: 1 size: 80 @@ -148,8 +149,8 @@ __PACKAGE__->add_columns( { data_type => "decimal", is_nullable => 1, size => [28, 6] }, "description", { data_type => "longtext", is_nullable => 1 }, - "accounttype", - { data_type => "varchar", is_nullable => 1, size => 80 }, + "credit_type_code", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 80 }, "debit_type_code", { data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 80 }, "status", @@ -261,6 +262,26 @@ __PACKAGE__->belongs_to( }, ); +=head2 credit_type_code + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "credit_type_code", + "Koha::Schema::Result::AccountCreditType", + { code => "credit_type_code" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); + =head2 debit_type_code Type: belongs_to diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm index 579edb8e39..73b50e581b 100644 --- a/Koha/Schema/Result/Branch.pm +++ b/Koha/Schema/Result/Branch.pm @@ -211,6 +211,21 @@ __PACKAGE__->set_primary_key("branchcode"); =head1 RELATIONS +=head2 account_credit_types_branches + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "account_credit_types_branches", + "Koha::Schema::Result::AccountCreditTypesBranch", + { "foreign.branchcode" => "self.branchcode" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 account_debit_types_branches Type: has_many @@ -692,8 +707,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-11 11:36:33 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:HCQKMSgKhVKtDSrvs1IeRg +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-14 09:59:52 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vWDJAm3K2jiyRS3htyip6A __PACKAGE__->add_columns( '+pickup_location' => { is_boolean => 1 } -- 2.39.5