use C4::Templates qw(gettemplate);
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Acquisition::Order;
-use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Booksellers;
+use Koha::Biblios;
use Koha::Number::Price;
use Koha::Libraries;
my $contract = GetContract({
contractnumber => $basket->{contractnumber}
});
- my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $basket->{booksellerid} });
+ my $bookseller = Koha::Acquisition::Booksellers->find( $basket->{booksellerid} );
my $basketgroup = GetBasketgroup( $$basket{basketgroupid} );
foreach my $order (@orders) {
my $bd = GetBiblioData( $order->{'biblionumber'} );
my $row = {
- clientnumber => $bookseller->{accountnumber},
+ clientnumber => $bookseller->accountnumber,
basketname => $basket->{basketname},
ordernumber => $order->{ordernumber},
author => $bd->{author},
quantity => $order->{quantity},
rrp_tax_included => $order->{rrp_tax_included},
rrp_tax_excluded => $order->{rrp_tax_excluded},
- discount => $bookseller->{discount},
+ discount => $bookseller->discount,
ecost_tax_included => $order->{ecost_tax_included},
ecost_tax_excluded => $order->{ecost_tax_excluded},
notes => $order->{order_vendornote},
entrydate => $order->{entrydate},
- booksellername => $bookseller->{name},
- bookselleraddress => $bookseller->{address1},
- booksellerpostal => $bookseller->{postal},
+ booksellername => $bookseller->name,
+ bookselleraddress => $bookseller->address1,
+ booksellerpostal => $bookseller->postal,
contractnumber => $contract->{contractnumber},
contractname => $contract->{contractname},
};
$order->{budget_id} = ( $budget_id || $order->{budget_id} );
$order->{quantity} = $quantrec;
$order->{quantityreceived} = $quantrec;
+ $order->{ecost_tax_excluded} //= 0;
+ $order->{tax_rate_on_ordering} //= 0;
+ $order->{unitprice_tax_excluded} //= 0;
+ $order->{tax_rate_on_receiving} //= 0;
$order->{tax_value_on_ordering} = $order->{quantity} * $order->{ecost_tax_excluded} * $order->{tax_rate_on_ordering};
$order->{tax_value_on_receiving} = $order->{quantity} * $order->{unitprice_tax_excluded} * $order->{tax_rate_on_receiving};
$order->{datereceived} = $datereceived;
if($delete_biblio) {
# We get the number of remaining items
- my $itemcount = C4::Items::GetItemsCount($bibnum);
+ my $biblio = Koha::Biblios->find( $bibnum );
+ my $itemcount = $biblio->items->count;
# If there are no items left,
if ( $itemcount == 0 ) {
my $booksellerid = $params->{booksellerid};
return unless $booksellerid;
- my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $booksellerid });
+ my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid );
my $receiving = $params->{receiving};
my $ordering = $params->{ordering};
if ($ordering) {
$order->{tax_rate_on_ordering} //= $order->{tax_rate};
- if ( $bookseller->{listincgst} ) {
+ if ( $bookseller->listincgst ) {
# The user entered the rrp tax included
$order->{rrp_tax_included} = $order->{rrp};
if ($receiving) {
$order->{tax_rate_on_receiving} //= $order->{tax_rate};
- if ( $bookseller->{invoiceincgst} ) {
+ if ( $bookseller->invoiceincgst ) {
# Trick for unitprice. If the unit price rounded value is the same as the ecost rounded value
# we need to keep the exact ecost value
if ( Koha::Number::Price->new( $order->{unitprice} )->round == Koha::Number::Price->new( $order->{ecost_tax_included} )->round ) {