From 7f815b258fca9cf2a76c83ebee1ec569fa7dd2ab Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 20 Jan 2020 11:56:36 -0300 Subject: [PATCH] Bug 24463: Add a basket_group relationship for baskets This patch aims to bring consistency between the accessor name and the underlying relationship to ease things when using it from the API. To test: 1. Apply this patch 2. Run: $ kshell k$ prove t/db_dependent/Koha/Acquisition/Basket.t => SUCCESS: Tests pass! No behavior change! 3. Sign off :-D Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize --- Koha/Acquisition/Basket.pm | 3 ++- Koha/Schema/Result/Aqbasket.pm | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Koha/Acquisition/Basket.pm b/Koha/Acquisition/Basket.pm index 33aa1f4673..b80b35fdff 100644 --- a/Koha/Acquisition/Basket.pm +++ b/Koha/Acquisition/Basket.pm @@ -54,7 +54,8 @@ Returns the basket group associated to this basket sub basket_group { my ($self) = @_; - my $basket_group_rs = $self->_result->basketgroupid; + + my $basket_group_rs = $self->_result->basket_group; return unless $basket_group_rs; return Koha::Acquisition::BasketGroup->_new_from_dbic( $basket_group_rs ); } diff --git a/Koha/Schema/Result/Aqbasket.pm b/Koha/Schema/Result/Aqbasket.pm index efbd6a1d36..e90d3c61e7 100644 --- a/Koha/Schema/Result/Aqbasket.pm +++ b/Koha/Schema/Result/Aqbasket.pm @@ -328,6 +328,18 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->belongs_to( + "basket_group", + "Koha::Schema::Result::Aqbasketgroup", + { 'foreign.id' => "self.basketgroupid" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "RESTRICT", + on_update => "CASCADE", + }, +); + sub koha_object_class { 'Koha::Acquisition::Basket'; } -- 2.39.5