diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index de85953e89..6a8df0280a 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -1893,7 +1893,6 @@ cancelled. sub DelOrder { my ( $bibnum, $ordernumber, $delete_biblio, $reason ) = @_; - my $error; my $dbh = C4::Context->dbh; my $query = " diff --git a/Koha/Acquisition/Invoice/Adjustment.pm b/Koha/Acquisition/Invoice/Adjustment.pm index e3d0bc206c..4d87a94ad9 100644 --- a/Koha/Acquisition/Invoice/Adjustment.pm +++ b/Koha/Acquisition/Invoice/Adjustment.pm @@ -20,6 +20,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::Acquisition::Invoice; use base qw(Koha::Object); @@ -33,6 +34,20 @@ Koha::Acquisition::Invoice::Adjustment - Koha Invoice Adjustment class =cut +=head3 invoice + +my $invoice = $adjustment->invoice; + +Return the invoice for this adjustment + +=cut + +sub invoice { + my ( $self ) = @_; + my $invoice_rs = $self->_result->invoiceid; + return Koha::Acquisition::Invoice->_new_from_dbic( $invoice_rs ); +} + =head3 type =cut diff --git a/acqui/ordered.pl b/acqui/ordered.pl index 09fd607eba..ebf89e86d0 100755 --- a/acqui/ordered.pl +++ b/acqui/ordered.pl @@ -107,7 +107,7 @@ while ( my $data = $sth->fetchrow_hashref ) { } } -my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $fund_id, closedate => undef, encumber_open => 1 }, { join => 'invoiceid' } ); +my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $fund_id, closedate => undef, encumber_open => 1 }, { prefetch => 'invoiceid' } ); while ( my $adj = $adjustments->next ){ $total += $adj->adjustment; } diff --git a/acqui/spent.pl b/acqui/spent.pl index 75b495b78d..20d2b13c0c 100755 --- a/acqui/spent.pl +++ b/acqui/spent.pl @@ -135,7 +135,7 @@ while (my $data = $sth->fetchrow_hashref) { } $sth->finish; -my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $bookfund, closedate => { '!=' => undef } }, { join => 'invoiceid' } ); +my $adjustments = Koha::Acquisition::Invoice::Adjustments->search({budget_id => $bookfund, closedate => { '!=' => undef } }, { prefetch => 'invoiceid' }, ); while ( my $adj = $adjustments->next ){ $total += $adj->adjustment; } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt index 6e20dfb250..5685d7e07f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/ordered.tt @@ -77,7 +77,11 @@ [% FOREACH adjustment IN adjustments %]