From 9a7b5250641a23d85fbdf8072ae034d7bcf79555 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 19 Jan 2017 14:43:35 +0000 Subject: [PATCH] Bug 14826 - Update table schemas --- Koha/Schema/Result/Accountline.pm | 34 +++++++++- Koha/Schema/Result/Accountoffset.pm | 121 ++++++++++++++++++++++++------------ Koha/Schema/Result/Borrower.pm | 19 +----- 3 files changed, 114 insertions(+), 60 deletions(-) diff --git a/Koha/Schema/Result/Accountline.pm b/Koha/Schema/Result/Accountline.pm index d3fa5b3..dcc5a46 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 @ 2016-07-12 14:26:28 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:88YKCYpyxgZHWCWQ4X956g # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/Accountoffset.pm b/Koha/Schema/Result/Accountoffset.pm index e9d8c2f..e44b4fe 100644 --- a/Koha/Schema/Result/Accountoffset.pm +++ b/Koha/Schema/Result/Accountoffset.pm @@ -1,12 +1,12 @@ use utf8; -package Koha::Schema::Result::Accountoffset; +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 +Koha::Schema::Result::AccountOffset =cut @@ -15,40 +15,45 @@ use warnings; use base 'DBIx::Class::Core'; -=head1 TABLE: C +=head1 TABLE: C =cut -__PACKAGE__->table("accountoffsets"); +__PACKAGE__->table("account_offsets"); =head1 ACCESSORS -=head2 borrowernumber +=head2 id data_type: 'integer' - default_value: 0 - is_foreign_key: 1 + is_auto_increment: 1 is_nullable: 0 -=head2 accountno +=head2 credit_id - data_type: 'smallint' - default_value: 0 - is_nullable: 0 + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 -=head2 offsetaccount +=head2 debit_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 - data_type: 'smallint' - default_value: 0 +=head2 type + + data_type: 'varchar' is_nullable: 0 + size: 16 -=head2 offsetamount +=head2 amount data_type: 'decimal' - is_nullable: 1 - size: [28,6] + is_nullable: 0 + size: [26,6] -=head2 timestamp +=head2 created_on data_type: 'timestamp' datetime_undef_if_invalid: 1 @@ -58,20 +63,17 @@ __PACKAGE__->table("accountoffsets"); =cut __PACKAGE__->add_columns( - "borrowernumber", - { - data_type => "integer", - default_value => 0, - is_foreign_key => 1, - is_nullable => 0, - }, - "accountno", - { data_type => "smallint", default_value => 0, is_nullable => 0 }, - "offsetaccount", - { data_type => "smallint", default_value => 0, is_nullable => 0 }, - "offsetamount", - { data_type => "decimal", is_nullable => 1, size => [28, 6] }, - "timestamp", + "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_nullable => 0, size => 16 }, + "amount", + { data_type => "decimal", is_nullable => 0, size => [26, 6] }, + "created_on", { data_type => "timestamp", datetime_undef_if_invalid => 1, @@ -80,27 +82,64 @@ __PACKAGE__->add_columns( }, ); +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + =head1 RELATIONS -=head2 borrowernumber +=head2 credit Type: belongs_to -Related object: L +Related object: L =cut __PACKAGE__->belongs_to( - "borrowernumber", - "Koha::Schema::Result::Borrower", - { borrowernumber => "borrowernumber" }, - { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, + "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", + }, ); -# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OTfcUiJCPb5aU/gjqAb/bA +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-07-12 14:26:28 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eu/gSdbAUL5bwhcvC+MGsw -# You can replace this text with custom content, and it will be preserved on regeneration +# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm index 1fe3988..2a2b93a 100644 --- a/Koha/Schema/Result/Borrower.pm +++ b/Koha/Schema/Result/Borrower.pm @@ -673,21 +673,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 @@ -1334,8 +1319,8 @@ Composing rels: L -> ordernumber __PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-10-31 10:39:35 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Lc6GQ2E7d+tyzTk3v2sWjQ +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2017-01-19 14:42:05 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CBJKHM62c0zXbjX9gK8MSw __PACKAGE__->belongs_to( "guarantor", -- 2.1.4