From ed38b9e910c0b9626d72c9cd47ebb3591100b2cb Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 24 Apr 2025 14:46:41 +0100 Subject: [PATCH] Bug 39711: Update all calls to GetContract --- C4/Acquisition.pm | 14 +++++++------- acqui/basket.pl | 6 +++--- acqui/basketheader.pl | 1 - acqui/neworderempty.pl | 6 +++--- admin/aqcontract.pl | 26 +++++++++++++------------- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index a81a6b9acd1..c56b7314c55 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -23,7 +23,6 @@ use Text::CSV_XS; use C4::Context; use C4::Suggestions qw( GetSuggestion GetSuggestionFromBiblionumber ModSuggestion ); use C4::Biblio qw( GetMarcFromKohaField GetMarcStructure IsMarcStructureInternal ); -use C4::Contract qw( GetContract ); use C4::Log qw( logaction ); use C4::Templates qw(gettemplate); use Koha::DateUtils qw( dt_from_string ); @@ -31,6 +30,7 @@ use Koha::Acquisition::Baskets; use Koha::Acquisition::Booksellers; use Koha::Acquisition::Invoices; use Koha::Acquisition::Orders; +use Koha::Acquisition::Contracts; use Koha::AdditionalFieldValue; use Koha::Biblios; use Koha::Exceptions; @@ -264,7 +264,7 @@ sub GetBasketAsCSV { my ( $basketno, $cgi, $csv_profile_id ) = @_; my $basket = GetBasket($basketno); my @orders = GetOrders($basketno); - my $contract = GetContract( { contractnumber => $basket->{'contractnumber'} } ); + my $contract = Koha::Acquisition::Contracts->find( $basket->{'contractnumber'} ); my $template = C4::Templates::gettemplate( "acqui/csv/basket.tt", "intranet", $cgi ); my @rows; @@ -309,7 +309,7 @@ sub GetBasketAsCSV { my $biblioitem = $biblio->biblioitem; $order = { %$order, %{ $biblioitem->unblessed } }; if ($contract) { - $order = { %$order, %$contract }; + $order = { %$order, %{ $contract->unblessed } }; } $order = { %$order, %$basket, %{ $biblio->unblessed } }; for my $field (@fields) { @@ -332,7 +332,7 @@ sub GetBasketAsCSV { $biblioitem = $biblio->biblioitem; } my $row = { - contractname => $contract->{'contractname'}, + contractname => $contract->contractname, ordernumber => $order->{'ordernumber'}, entrydate => $order->{'entrydate'}, isbn => $order->{'isbn'}, @@ -394,7 +394,7 @@ sub GetBasketGroupAsCSV { my @rows; for my $basket (@$baskets) { my @orders = GetOrders( $basket->{basketno} ); - my $contract = GetContract( { contractnumber => $basket->{contractnumber} } ); + my $contract = Koha::Acquisition::Contracts->find( $basket->{'contractnumber'} ); my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} ); my $basketgroup = GetBasketgroup( $$basket{basketgroupid} ); @@ -425,8 +425,8 @@ sub GetBasketGroupAsCSV { booksellername => $bookseller->name, bookselleraddress => $bookseller->address1, booksellerpostal => $bookseller->postal, - contractnumber => $contract->{contractnumber}, - contractname => $contract->{contractname}, + contractnumber => $contract->contractnumber, + contractname => $contract->contractname, }; my $temp = { basketgroupdeliveryplace => $basketgroup->{deliveryplace}, diff --git a/acqui/basket.pl b/acqui/basket.pl index ab194704835..60757a4c410 100755 --- a/acqui/basket.pl +++ b/acqui/basket.pl @@ -27,11 +27,11 @@ use CGI qw ( -utf8 ); use C4::Acquisition qw( GetBasket CanUserManageBasket GetBasketAsCSV NewBasket NewBasketgroup ModBasket ReopenBasket ModBasketUsers GetBasketgroup GetBasketgroups GetBasketUsers GetOrders GetOrder get_rounded_price ); use C4::Budgets qw( GetBudgetHierarchy GetBudget CanUserUseBudget ); -use C4::Contract qw( GetContract ); use C4::Suggestions qw( GetSuggestion GetSuggestionInfoFromBiblionumber GetSuggestionInfo ); 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,7 +400,7 @@ if ( $op eq 'list' ) { push @cancelledorders_loop, $line; } - my $contract = GetContract( { contractnumber => $basket->{contractnumber} } ); + my $contract = Koha::Acquisition::Contracts->find( $basket->{contractnumber} ); if ( $basket->{basketgroupid} ) { $basketgroup = GetBasketgroup( $basket->{basketgroupid} ); @@ -425,7 +425,7 @@ if ( $op eq 'list' ) { basketnote => $basket->{note}, basketbooksellernote => $basket->{booksellernote}, basketcontractno => $basket->{contractnumber}, - basketcontractname => $contract->{contractname}, + basketcontractname => $contract->contractname, branches_loop => \@branches_loop, creationdate => $basket->{creationdate}, edi_order => $edi_order, diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl index 5a36b88b82f..2ad821060eb 100755 --- a/acqui/basketheader.pl +++ b/acqui/basketheader.pl @@ -51,7 +51,6 @@ use C4::Context; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); use C4::Acquisition qw( GetBasket ModBasket ModBasketHeader NewBasket ); -use C4::Contract qw( GetContract ); use Koha::Acquisition::Booksellers; use Koha::Acquisition::Baskets; diff --git a/acqui/neworderempty.pl b/acqui/neworderempty.pl index 4228db940f0..c31257c627c 100755 --- a/acqui/neworderempty.pl +++ b/acqui/neworderempty.pl @@ -71,7 +71,6 @@ use C4::Auth qw( get_template_and_user ); use C4::Budgets qw( GetBudget GetBudgetHierarchy CanUserUseBudget ); use C4::Acquisition qw( GetOrder GetBasket FillWithDefaultValues GetOrderUsers ); -use C4::Contract qw( GetContract ); use C4::Suggestions qw( GetSuggestion GetSuggestionInfo ); use C4::Biblio qw( AddBiblio @@ -89,6 +88,7 @@ use C4::Search qw( FindDuplicate ); use C4::ImportBatch qw( SetImportRecordStatus SetMatchedBiblionumber GetImportRecordMarc ); use Koha::Acquisition::Booksellers; +use Koha::Acquisition::Contracts; use Koha::Acquisition::Currencies qw( get_active ); use Koha::Biblios; use Koha::BiblioFrameworks; @@ -158,7 +158,7 @@ $template->param( output_and_exit( $input, $cookie, $template, 'order_cannot_be_edited' ) if $ordernumber and ( $basketobj->closedate || $data->{orderstatus} eq "complete" ); -my $contract = GetContract( { contractnumber => $basket->{contractnumber} } ); +my $contract = Koha::Acquisition::Contracts->find( $basket->{contractnumber} ); my $listprice = 0; # the price, that can be in MARC record if we have one if ( $ordernumber eq '' and defined $breedingid ) { @@ -454,7 +454,7 @@ $template->param( booksellerid => $basket->{'booksellerid'}, basketbooksellernote => $basket->{booksellernote}, basketcontractno => $basket->{contractnumber}, - basketcontractname => $contract->{contractname}, + basketcontractname => $contract->contractname, creationdate => $basket->{creationdate}, authorisedby => $basket->{'authorisedby'}, authorisedbyname => $basket->{'authorisedbyname'}, diff --git a/admin/aqcontract.pl b/admin/aqcontract.pl index 53f7bd45316..228c532a21e 100755 --- a/admin/aqcontract.pl +++ b/admin/aqcontract.pl @@ -28,12 +28,12 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Contract qw( AddContract DelContract - GetContract ModContract ); use Koha::DateUtils qw( dt_from_string ); use Koha::Acquisition::Booksellers; +use Koha::Acquisition::Contracts; my $input = CGI->new; my $contractnumber = $input->param('contractnumber'); @@ -66,14 +66,14 @@ if ( $op eq 'add_form' ) { # if contractnumber exists, it's a modify action, so read values to modify... if ($contractnumber) { - my $contract = GetContract( { contractnumber => $contractnumber } ); + my $contract = Koha::Acquisition::Contracts->find($contractnumber); $template->param( - contractnumber => $contract->{contractnumber}, - contractname => $contract->{contractname}, - contractdescription => $contract->{contractdescription}, - contractstartdate => $contract->{contractstartdate}, - contractenddate => $contract->{contractenddate}, + contractnumber => $contract->contractnumber, + contractname => $contract->contractname, + contractdescription => $contract->contractdescription, + contractstartdate => $contract->contractstartdate, + contractenddate => $contract->contractenddate, ); } else { $template->param( @@ -135,14 +135,14 @@ elsif ( $op eq 'cud-add_validate' ) { elsif ( $op eq 'delete_confirm' ) { $template->param( delete_confirm => 1 ); - my $contract = GetContract( { contractnumber => $contractnumber } ); + my $contract = Koha::Acquisition::Contracts->find($contractnumber); $template->param( - contractnumber => $$contract{contractnumber}, - contractname => $$contract{contractname}, - contractdescription => $$contract{contractdescription}, - contractstartdate => $$contract{contractstartdate}, - contractenddate => $$contract{contractenddate}, + contractnumber => $contract->contractnumber, + contractname => $contract->contractname, + contractdescription => $contract->contractdescription, + contractstartdate => $contract->contractstartdate, + contractenddate => $contract->contractenddate, ); # END $OP eq DELETE_CONFIRM -- 2.48.1