I'm surprised to see a big SQL query in acqui/spent.pl. Is not that kind of stuff supposed to be rather in C4/Aquisitions.pm ? my $query = <<EOQ; SELECT aqorders.basketno, aqorders.ordernumber, quantity-quantityreceived AS tleft, ecost, budgetdate, entrydate, aqbasket.booksellerid, itype, title, aqorders.invoiceid, aqinvoices.invoicenumber, quantityreceived, unitprice, datereceived, aqorders.biblionumber FROM (aqorders, aqbasket) LEFT JOIN biblio ON biblio.biblionumber=aqorders.biblionumber LEFT JOIN items ON biblio.biblionumber = items.biblionumber LEFT JOIN aqorders_items ON items.itemnumber = aqorders_items.itemnumber LEFT JOIN aqinvoices ON aqorders.invoiceid = aqinvoices.invoiceid WHERE aqorders.ordernumber=aqorders_items.ordernumber AND aqorders.basketno=aqbasket.basketno AND budget_id=? AND (datecancellationprinted IS NULL OR datecancellationprinted='0000-00-00') GROUP BY aqorders.ordernumber EOQ M. Saby
spent and ordered can be seen as reports for which an exception has been made: https://wiki.koha-community.org/wiki/Coding_Guidelines#SQL8:_SQL_code_in_.pl_scripts Maybe we will move it to Koha:* later, but marking this WONTFIX for now.