From f4d702c668661f4ef01f5fe0d4ae99d81f89712d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 20 Oct 2017 16:28:52 -0300 Subject: [PATCH] Bug 14826: DBIC Schema changes Signed-off-by: Jonathan Druart --- Koha/Schema/Result/AccountOffset.pm | 161 ++++++++++++++++++++++++ Koha/Schema/Result/AccountOffsetType.pm | 74 +++++++++++ Koha/Schema/Result/Accountline.pm | 34 ++++- Koha/Schema/Result/Borrower.pm | 19 +-- 4 files changed, 269 insertions(+), 19 deletions(-) create mode 100644 Koha/Schema/Result/AccountOffset.pm create mode 100644 Koha/Schema/Result/AccountOffsetType.pm diff --git a/Koha/Schema/Result/AccountOffset.pm b/Koha/Schema/Result/AccountOffset.pm new file mode 100644 index 0000000000..892c095dd3 --- /dev/null +++ b/Koha/Schema/Result/AccountOffset.pm @@ -0,0 +1,161 @@ +use utf8; +package Koha::Schema::Result::AccountOffset; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::AccountOffset + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("account_offsets"); + +=head1 ACCESSORS + +=head2 id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +=head2 credit_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +=head2 debit_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +=head2 type + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 0 + size: 16 + +=head2 amount + + data_type: 'decimal' + is_nullable: 0 + size: [26,6] + +=head2 created_on + + data_type: 'timestamp' + datetime_undef_if_invalid: 1 + default_value: current_timestamp + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "credit_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "debit_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "type", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 16 }, + "amount", + { data_type => "decimal", is_nullable => 0, size => [26, 6] }, + "created_on", + { + data_type => "timestamp", + datetime_undef_if_invalid => 1, + default_value => \"current_timestamp", + is_nullable => 0, + }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + +=head1 RELATIONS + +=head2 credit + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "credit", + "Koha::Schema::Result::Accountline", + { accountlines_id => "credit_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 debit + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "debit", + "Koha::Schema::Result::Accountline", + { accountlines_id => "debit_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); + +=head2 type + +Type: belongs_to + +Related object: L + +=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-10-20 16:27:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tPPrIug2c7PbDO7LCxCJAA + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/AccountOffsetType.pm b/Koha/Schema/Result/AccountOffsetType.pm new file mode 100644 index 0000000000..fd62a02969 --- /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 + +=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 + +=back + +=cut + +__PACKAGE__->set_primary_key("type"); + +=head1 RELATIONS + +=head2 account_offsets + +Type: has_many + +Related object: L + +=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-10-20 16:27:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rPRWMfAfRke3jGG3iISi2A + + +# 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 d3fa5b3b0e..d09a40218f 100644 --- a/Koha/Schema/Result/Accountline.pm +++ b/Koha/Schema/Result/Accountline.pm @@ -185,6 +185,36 @@ __PACKAGE__->set_primary_key("accountlines_id"); =head1 RELATIONS +=head2 account_offsets_credits + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "account_offsets_credits", + "Koha::Schema::Result::AccountOffset", + { "foreign.credit_id" => "self.accountlines_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 account_offsets_debits + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "account_offsets_debits", + "Koha::Schema::Result::AccountOffset", + { "foreign.debit_id" => "self.accountlines_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 borrowernumber Type: belongs_to @@ -221,8 +251,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-01-26 17:18:34 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:RCQohhphtg+0+RszpB4wLg +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-10-20 16:27:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gCCyA5hOqI3EG3bIxsgpKA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index 91dde0da66..bac998959c 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -710,21 +710,6 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 accountoffsets - -Type: has_many - -Related object: L - -=cut - -__PACKAGE__->has_many( - "accountoffsets", - "Koha::Schema::Result::Accountoffset", - { "foreign.borrowernumber" => "self.borrowernumber" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - =head2 aqbasketusers Type: has_many @@ -1386,8 +1371,8 @@ Composing rels: L -> ordernumber __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-09-19 03:00:28 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZZDjvikajGC+2s4vkp9stw +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-10-20 16:27:04 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5pHsZTeeMmLw1Y4f4l3qng __PACKAGE__->belongs_to( "guarantor", -- 2.39.5