From 9e07ff9c719548c6236820415feee94ad12fe9dd Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 5 May 2025 08:56:37 -0300 Subject: [PATCH] Bug 39832: Add $basket->vendor method This patch adds the method to be used on the API for embedding. Tests are added. To test: 1. Apply this patch 2. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Acquisition/Basket.t => SUCCESS: Tests pass! 3. Sign off :-D Signed-off-by: Roman Dolny Signed-off-by: Emmi Takkinen Signed-off-by: Martin Renvoize --- Koha/Acquisition/Basket.pm | 15 +++++++++++++++ Koha/Schema/Result/Aqbasket.pm | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/Koha/Acquisition/Basket.pm b/Koha/Acquisition/Basket.pm index b22aa924409..a5452414b6e 100644 --- a/Koha/Acquisition/Basket.pm +++ b/Koha/Acquisition/Basket.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Koha::Database; use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::BasketGroups; +use Koha::Acquisition::Booksellers; use Koha::Acquisition::Orders; use Koha::Exceptions::Acquisition::Basket; use Koha::Patrons; @@ -51,6 +52,20 @@ sub bookseller { return Koha::Acquisition::Bookseller->_new_from_dbic($bookseller_rs); } +=head3 vendor + + my $vendor = $basket->vendor; + +Returns the related I object. + +=cut + +sub vendor { + my ($self) = @_; + my $vendor_rs = $self->_result->vendor; + return Koha::Acquisition::Bookseller->_new_from_dbic($vendor_rs); +} + =head3 creator my $creator = $basket->creator; diff --git a/Koha/Schema/Result/Aqbasket.pm b/Koha/Schema/Result/Aqbasket.pm index 6a2bb68e044..f4d160f555e 100644 --- a/Koha/Schema/Result/Aqbasket.pm +++ b/Koha/Schema/Result/Aqbasket.pm @@ -379,6 +379,13 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->belongs_to( + "vendor", + "Koha::Schema::Result::Aqbookseller", + { id => "booksellerid" }, + { is_deferrable => 1, on_delete => "RESTRICT", on_update => "CASCADE" }, +); + =head2 koha_object_class Missing POD for koha_object_class. -- 2.49.0