use CGI qw ( -utf8 );
use C4::Context;
-use C4::Koha; # GetItemTypes
use C4::Acquisition;
use C4::Auth;
use C4::Output;
use C4::Items;
use C4::Biblio;
use C4::Suggestions;
+use C4::Koha;
-use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Booksellers;
+use Koha::Acquisition::Orders;
use Koha::DateUtils qw( dt_from_string );
+use Koha::ItemTypes;
+use Koha::Patrons;
my $input = new CGI;
my $freight = $invoice->{shipmentcost};
my $ordernumber = $input->param('ordernumber');
-my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
+my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
my $results;
$results = SearchOrders({
ordernumber => $ordernumber
# prepare the form for receiving
my $order = $results->[0];
+my $basket = Koha::Acquisition::Orders->find( $ordernumber )->basket;
# Check if ACQ framework exists
my $acq_fw = GetMarcStructure( 1, 'ACQ', { unsafe => 1 } );
$template->param('NoACQframework' => 1);
}
-my $AcqCreateItem = C4::Context->preference('AcqCreateItem');
+my $AcqCreateItem = $basket->effective_create_items;
if ($AcqCreateItem eq 'receiving') {
$template->param(
AcqCreateItemReceiving => 1,
my @items;
foreach (@itemnumbers) {
my $item = GetItem($_);
- my $av;
- $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
- $item->{notforloan} = $av ? $av->lib : '';
+ my $descriptions;
+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.notforloan', authorised_value => $item->{notforloan} });
+ $item->{notforloan} = $descriptions->{lib} // '';
- $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
- $item->{restricted} = $av ? $av->lib : '';
+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.restricted', authorised_value => $item->{restricted} });
+ $item->{restricted} = $descriptions->{lib} // '';
- $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
- $item->{location} = $av ? $av->lib : '';
+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.location', authorised_value => $item->{location} });
+ $item->{location} = $descriptions->{lib} // '';
- $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
- $item->{collection} = $av ? $av->lib : '';
+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.collection', authorised_value => $item->{collection} });
+ $item->{collection} = $descriptions->{lib} // '';
- $av = Koha::AuthorisedValues->find_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
- $item->{materials} = $av ? $av->lib : '';
+ $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => $fw, kohafield => 'items.materials', authorised_value => $item->{materials} });
+ $item->{materials} = $descriptions->{lib} // '';
- my $itemtype = getitemtypeinfo($item->{itype});
- $item->{itemtype} = $itemtype->{description};
+ my $itemtype = Koha::ItemTypes->find( $item->{itype} );
+ if (defined $itemtype) {
+ $item->{itemtype} = $itemtype->description; # FIXME Should not it be translated_description?
+ }
push @items, $item;
}
$template->param(items => \@items);
my $unitprice = $order->{unitprice};
my ( $rrp, $ecost );
-if ( $bookseller->{invoiceincgst} ) {
+if ( $bookseller->invoiceincgst ) {
$rrp = $order->{rrp_tax_included};
$ecost = $order->{ecost_tax_included};
unless ( $unitprice != 0 and defined $unitprice) {
my $suggestion = GetSuggestionInfoFromBiblionumber($order->{biblionumber});
my $authorisedby = $order->{authorisedby};
-my $member = GetMember( borrowernumber => $authorisedby );
+my $authorised_patron = Koha::Patrons->find( $authorisedby );
my $budget = GetBudget( $order->{budget_id} );
subscriptionid => $order->{subscriptionid},
booksellerid => $order->{'booksellerid'},
freight => $freight,
- name => $bookseller->{'name'},
+ name => $bookseller->name,
title => $order->{'title'},
author => $order->{'author'},
copyrightdate => $order->{'copyrightdate'},
ecost => $ecost,
unitprice => $unitprice,
tax_rate => $tax_rate,
- memberfirstname => $member->{firstname} || "",
- membersurname => $member->{surname} || "",
+ memberfirstname => $authorised_patron->firstname || "",
+ membersurname => $authorised_patron->surname || "",
invoiceid => $invoice->{invoiceid},
invoice => $invoice->{invoicenumber},
datereceived => $datereceived,
gst_values => \@gst_values,
);
-my $borrower = GetMember( 'borrowernumber' => $loggedinuser );
+my $patron = Koha::Patrons->find( $loggedinuser )->unblessed;
my @budget_loop;
my $periods = GetBudgetPeriods( );
foreach my $period (@$periods) {
my $budget_hierarchy = GetBudgetHierarchy( $period->{'budget_period_id'} );
my @funds;
foreach my $r ( @{$budget_hierarchy} ) {
- next unless ( CanUserUseBudget( $borrower, $r, $userflags ) );
+ next unless ( CanUserUseBudget( $patron, $r, $userflags ) );
if ( !defined $r->{budget_amount} || $r->{budget_amount} == 0 ) {
next;
}