Bugzilla – Attachment 181581 Details for
Bug 39711
Migrate C4::Contract to object classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39711: Fix 500 when viewing a basket without contract
Bug-39711-Fix-500-when-viewing-a-basket-without-co.patch (text/plain), 5.68 KB, created by
Jonathan Druart
on 2025-04-28 09:48:49 UTC
(
hide
)
Description:
Bug 39711: Fix 500 when viewing a basket without contract
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2025-04-28 09:48:49 UTC
Size:
5.68 KB
patch
obsolete
>From afabb05370217257d7e33d95d82a93a7ebdb0da5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 28 Apr 2025 11:47:36 +0200 >Subject: [PATCH] Bug 39711: Fix 500 when viewing a basket without contract > >Can't call method "contractname" on an undefined value at /kohadevbox/koha/acqui/basket.pl line 462. > >Use Koha::Acq::Basket->contract >--- > Koha/Acquisition/Basket.pm | 13 ++++++++ > acqui/basket.pl | 10 ++---- > .../prog/en/modules/acqui/basket.tt | 5 +-- > t/db_dependent/Koha/Acquisition/Basket.t | 32 ++++++++++++++++++- > 4 files changed, 50 insertions(+), 10 deletions(-) > >diff --git a/Koha/Acquisition/Basket.pm b/Koha/Acquisition/Basket.pm >index b22aa924409..2a77034804f 100644 >--- a/Koha/Acquisition/Basket.pm >+++ b/Koha/Acquisition/Basket.pm >@@ -80,6 +80,19 @@ sub basket_group { > return Koha::Acquisition::BasketGroup->_new_from_dbic($basket_group_rs); > } > >+=head3 contract >+ >+Returns the contract associated to this basket >+ >+=cut >+ >+sub contract { >+ my ($self) = @_; >+ my $rs = $self->_result->contractnumber; >+ return unless $rs; >+ return Koha::Acquisition::Contract->_new_from_dbic($rs); >+} >+ > =head3 orders > > my $orders = $basket->orders; >diff --git a/acqui/basket.pl b/acqui/basket.pl >index 60757a4c410..d102541af38 100755 >--- a/acqui/basket.pl >+++ b/acqui/basket.pl >@@ -31,7 +31,6 @@ use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSugge > use Koha::Biblios; > use Koha::Acquisition::Baskets; > use Koha::Acquisition::Booksellers; >-use Koha::Acquisition::Contracts; > use Koha::Acquisition::Orders; > use Koha::Libraries; > use C4::Letters qw( SendAlerts ); >@@ -400,8 +399,6 @@ if ( $op eq 'list' ) { > push @cancelledorders_loop, $line; > } > >- my $contract = Koha::Acquisition::Contracts->find( $basket->{contractnumber} ); >- > if ( $basket->{basketgroupid} ) { > $basketgroup = GetBasketgroup( $basket->{basketgroupid} ); > } >@@ -418,14 +415,13 @@ if ( $op eq 'list' ) { > my $edi_order = $basket_obj->edi_order; > > $template->param( >- basketno => $basketno, >- basket => $basket, >+ basketno => $basketno, >+ basket => $basket, # FIXME Remove basket_obj and use the Koha::Acq::Basket object in the template >+ basket_obj => $basket_obj, > basketname => $basket->{'basketname'}, > basketbranchcode => $basket->{branch}, > basketnote => $basket->{note}, > basketbooksellernote => $basket->{booksellernote}, >- basketcontractno => $basket->{contractnumber}, >- basketcontractname => $contract->contractname, > branches_loop => \@branches_loop, > creationdate => $basket->{creationdate}, > edi_order => $edi_order, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >index 25592a3b50f..341100ff165 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basket.tt >@@ -318,10 +318,11 @@ > [% IF ( basketbooksellernote ) %] > <li><span class="label">Vendor note:</span> [% basketbooksellernote | html %]</li> > [% END %] >- [% IF ( basketcontractno ) %] >+ [% SET contract = basket_obj.contract %] >+ [% IF contract %] > <li > ><span class="label">Contract name:</span> >- <a href="../admin/aqcontract.pl?op=add_form&contractnumber=[% basketcontractno | uri %]&booksellerid=[% booksellerid | uri %]">[% basketcontractname | html %]</a></li >+ <a href="../admin/aqcontract.pl?op=add_form&contractnumber=[% contract.contractnumber| uri %]&booksellerid=[% contract.booksellerid | uri %]">[% contract.contractname| html %]</a></li > > > [% END %] > [% IF deliveryplace %] >diff --git a/t/db_dependent/Koha/Acquisition/Basket.t b/t/db_dependent/Koha/Acquisition/Basket.t >index 9d629c543a9..7356e454e6e 100755 >--- a/t/db_dependent/Koha/Acquisition/Basket.t >+++ b/t/db_dependent/Koha/Acquisition/Basket.t >@@ -20,7 +20,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 14; >+use Test::More tests => 15; > use Test::Exception; > > use t::lib::TestBuilder; >@@ -125,6 +125,36 @@ subtest 'basket_group' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'contract' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $basket = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Baskets', >+ value => { contractnumber => undef } >+ } >+ ); >+ is( $basket->contract, undef, '->contract returns undef is no contract for this basket' ); >+ >+ my $contract = $builder->build_object( >+ { >+ class => 'Koha::Acquisition::Contracts', >+ } >+ ); >+ >+ $basket->contractnumber( $contract->contractnumber )->store; >+ >+ is( >+ ref( $basket->contract ), 'Koha::Acquisition::Contract', >+ '->contract should return a Koha::Acquisition::Contract object if linked to a contract' >+ ); >+ >+ $schema->storage->txn_rollback; >+}; >+ > subtest 'creator() tests' => sub { > > plan tests => 4; >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39711
:
181453
|
181454
|
181455
|
181456
|
181457
|
181458
|
181459
|
181460
|
181461
|
181580
| 181581 |
181582
|
181583
|
181584
|
181586
|
181587
|
181588