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 <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Tomas Cohen Arazi 2020-01-20 11:56:36 -03:00 committed by Martin Renvoize
parent 3702194574
commit 7f815b258f
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
2 changed files with 14 additions and 1 deletions

View File

@ -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 );
}

View File

@ -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';
}