C4::Acquisition - Koha functions for dealing with orders and acquisitions
use C4::Acquisition;
The functions in this module deal with acquisitions, managing book orders, basket and parcels.
$aqbasket = &GetBasket($basketnumber);
get all basket informations in aqbasket for a given basket
returns: informations for a given basket returned as a hashref.
$basket = &NewBasket( $booksellerid, $authorizedby, $basketname, $basketnote, $basketbooksellernote, $basketcontractnumber, $deliveryplace, $billingplace );
Create a new basket in aqbasket table
$booksellerid
is a foreign key in the aqbasket table$authorizedby
is the username of who created the basketThe other parameters are optional, see ModBasketHeader for more info on them.
&CloseBasket($basketno);
close a basket (becomes unmodifiable,except for recieves)
&GetBasketAsCSV($basketno);
Export a basket as CSV
$cgi parameter is needed for column name translation
&GetBasketGroupAsCSV($basketgroupid);
Export a basket group as CSV
$cgi parameter is needed for column name translation
&CloseBasketgroup($basketgroupno);
close a basketgroup
&ReOpenBaskergroup($basketgroupno);
reopen a basketgroup
&DelBasket($basketno);
Deletes the basket that has basketno field $basketno in the aqbasket table.
$basketno
is the primary key of the basket in the aqbasket table.&ModBasket($basketinfo);
Modifies a basket, using a hashref $basketinfo for the relevant information, only $basketinfo->{'basketno'} is required.
$basketno
is the primary key of the basket in the aqbasket table.&ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber, $booksellerid);
Modifies a basket's header.
$basketno
is the "basketno" field in the "aqbasket" table;$basketname
is the "basketname" field in the "aqbasket" table;$note
is the "note" field in the "aqbasket" table;$booksellernote
is the "booksellernote" field in the "aqbasket" table;$contractnumber
is the "contractnumber" (foreign) key in the "aqbasket" table.$booksellerid
is the id (foreign) key in the "aqbooksellers" table for the vendor.$deliveryplace
is the "deliveryplace" field in the aqbasket table.$billingplace
is the "billingplace" field in the aqbasket table.@results = &GetBasketsByBookseller($booksellerid, $extra);
Returns a list of hashes of all the baskets that belong to bookseller 'booksellerid'.
$booksellerid
is the 'id' field of the bookseller in the aqbooksellers table$extra
is the extra sql parameters, can be$extra->{groupby}: group baskets by column ex. $extra->{groupby} = aqbasket.basketgroupid $extra->{orderby}: order baskets by column $extra->{limit}: limit number of results (can be helpful for pagination)
my $baskets = GetBasketsInfosByBookseller($supplierid);
Returns in a arrayref of hashref all about booksellers baskets, plus: total_biblios: Number of distinct biblios in basket total_items: Number of items in basket expected_items: Number of non-received items in basket
$baskets = &GetBasketsByBasketgroup($basketgroupid);
Returns a reference to all baskets that belong to basketgroup $basketgroupid.
$basketgroupid = NewBasketgroup(\%hashref);
Adds a basketgroup to the aqbasketgroups table, and add the initial baskets to it.
$hashref->{'booksellerid'} is the 'id' field of the bookseller in the aqbooksellers table,
$hashref->{'name'} is the 'name' field of the basketgroup in the aqbasketgroups table,
$hashref->{'basketlist'} is a list reference of the 'id's of the baskets that belong to this group,
$hashref->{'billingplace'} is the 'billingplace' field of the basketgroup in the aqbasketgroups table,
$hashref->{'deliveryplace'} is the 'deliveryplace' field of the basketgroup in the aqbasketgroups table,
$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgroup in the aqbasketgroups table,
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
ModBasketgroup(\%hashref);
Modifies a basketgroup in the aqbasketgroups table, and add the baskets to it.
$hashref->{'id'} is the 'id' field of the basketgroup in the aqbasketgroup table, this parameter is mandatory,
$hashref->{'name'} is the 'name' field of the basketgroup in the aqbasketgroups table,
$hashref->{'basketlist'} is a list reference of the 'id's of the baskets that belong to this group,
$hashref->{'billingplace'} is the 'billingplace' field of the basketgroup in the aqbasketgroups table,
$hashref->{'deliveryplace'} is the 'deliveryplace' field of the basketgroup in the aqbasketgroups table,
$hashref->{'freedeliveryplace'} is the 'freedeliveryplace' field of the basketgroup in the aqbasketgroups table,
$hashref->{'deliverycomment'} is the 'deliverycomment' field of the basketgroup in the aqbasketgroups table,
$hashref->{'closed'} is the 'closed' field of the aqbasketgroups table, it is false if 0, true otherwise.
DelBasketgroup($basketgroupid);
Deletes a basketgroup in the aqbasketgroups table, and removes the reference to it from the baskets,
$basketgroupid
is the 'id' field of the basket in the aqbasketgroup table$basketgroup = &GetBasketgroup($basketgroupid);
Returns a reference to the hash containing all infermation about the basketgroup.
$basketgroups = &GetBasketgroups($booksellerid);
Returns a reference to the array of all the basketgroups of bookseller $booksellerid.
$orders = &GetPendingOrders($supplierid,$grouped,$owner,$basketno,$ordernumber,$search,$ean);
Finds pending orders from the bookseller with the given ID. Ignores completed and cancelled orders.
$booksellerid
contains the bookseller identifier $owner
contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself. $grouped
is a boolean that, if set to 1 will group all order lines of the same basket in a single result line $orders
is a reference-to-array; each element is a reference-to-hash.
Used also by the filter in parcel.pl I have added:
$ordernumber
$search
$ean
These give the value of the corresponding field in the aqorders table of the Koha database.
Results are ordered from most to least recent.
@orders = &GetOrders($basketnumber, $orderby);
Looks up the pending (non-cancelled) orders with the given basket number. If $booksellerID
is non-empty, only orders from that seller are returned.
return : &basket
returns a two-element array. @orders
is an array of references-to-hash, whose keys are the fields from the aqorders, biblio, and biblioitems tables in the Koha database.
$ordernumber = &GetOrderNumber($biblioitemnumber, $biblionumber);
Looks up the ordernumber with the given biblionumber and biblioitemnumber.
Returns the number of this order.
$ordernumber
is the order number.$order = &GetOrder($ordernumber);
Looks up an order by order number.
Returns a reference-to-hash describing the order. The keys of $order
are fields from the biblio, biblioitems, aqorders tables of the Koha database.
$order = &GetLastOrderNotReceivedFromSubscriptionid($subscriptionid);
Returns a reference-to-hash describing the last order not received for a subscription.
$order = &GetLastOrderReceivedFromSubscriptionid($subscriptionid);
Returns a reference-to-hash describing the last order received for a subscription.
&NewOrder(\%hashref);
Adds a new order to the database. Any argument that isn't described below is the new value of the field with the same name in the aqorders table of the Koha database.
The following keys are used: "biblionumber", "title", "basketno", "quantity", "notes", "biblioitemnumber", "rrp", "ecost", "gstrate", "unitprice", "subscription", "sort1", "sort2", "booksellerinvoicenumber", "listprice", "budgetdate", "purchaseordernumber", "branchcode", "booksellerinvoicenumber", "budget_id".
&NewOrderItem();
&ModOrder(\%hashref);
Modifies an existing order. Updates the order with order number $hashref->{'ordernumber'} and biblionumber $hashref->{'biblionumber'}. All other keys of the hash update the fields with the same name in the aqorders table of the Koha database.
&ModOrderItem(\%hashref);
Modifies the itemnumber in the aqorders_items table. The input hash needs three entities:
ModItemOrder($itemnumber, $ordernumber);
Modifies the ordernumber of an item in aqorders_items.
&ModOrderBiblioitemNumber($biblioitemnumber,$ordernumber, $biblionumber);
Modifies the biblioitemnumber for an existing order. Updates the order with order number $ordernum
and biblionumber $biblionumber
.
my @orders = GetCancelledOrders($basketno, $orderby);
Returns cancelled orders for a basket
&ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user, $unitprice, $invoiceid, $biblioitemnumber, $bookfund, $rrp, \@received_itemnumbers);
Updates an order, to reflect the fact that it was received, at least in part. All arguments not mentioned below update the fields with the same name in the aqorders table of the Koha database.
If a partial order is received, splits the order into two.
Updates the order with bibilionumber $biblionumber
and ordernumber $ordernumber
.
my $parent_ordernumber = CancelReceipt($ordernumber); Cancel an order line receipt and update the parent order line, as if no receipt was made. If items are created at receipt (AcqCreateItem = receiving) then delete these items.
@results = &SearchOrder($search, $biblionumber, $complete);
Searches for orders.
$search
may take one of several forms: if it is an ISBN, &ordersearch
returns orders with that ISBN. If $search
is an order number, &ordersearch
returns orders with that order number and biblionumber $biblionumber
. Otherwise, $search
is considered to be a space-separated list of search terms; in this case, all of the terms must appear in the title (matching the beginning of title words).
If $complete
is yes
, the results will include only completed orders. In any case, &ordersearch
ignores cancelled orders.
&ordersearch
returns an array. @results
is an array of references-to-hash with the following keys:
author
seriestitle
branchcode
budget_id
&DelOrder($biblionumber, $ordernumber);
Cancel the order with the given order and biblio numbers. It does not delete any entries in the aqorders table, it merely marks them as cancelled.
@results = &GetParcel($booksellerid, $code, $date);
Looks up all of the received items from the supplier with the given bookseller ID at the given date, for the given code (bookseller Invoice number). Ignores cancelled and completed orders.
@results
is an array of references-to-hash. The keys of each element are fields from the aqorders, biblio, and biblioitems tables of the Koha database.
@results
is sorted alphabetically by book title.
$results = &GetParcels($bookseller, $order, $code, $datefrom, $dateto);
get a lists of parcels.
* Input arg :
* return: a pointer on a hash list containing parcel informations as such :
@results = &GetLateOrders;
Searches for bookseller with late orders.
return: the table of supplier with late issues. This table is full of hashref.
(\@order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( %params );
Retreives some acquisition history information
params: title author name from_placed_on to_placed_on basket - search both basket name and number booksellerinvoicenumber
returns: $order_loop is a list of hashrefs that each look like this: { 'author' => 'Twain, Mark', 'basketno' => '1', 'biblionumber' => '215', 'count' => 1, 'creationdate' => 'MM/DD/YYYY', 'datereceived' => undef, 'ecost' => '1.00', 'id' => '1', 'invoicenumber' => undef, 'name' => '', 'ordernumber' => '1', 'quantity' => 1, 'quantityreceived' => undef, 'title' => 'The Adventures of Huckleberry Finn' } $total_qty is the sum of all of the quantities in $order_loop $total_price is the cost of each in $order_loop times the quantity $total_qtyreceived is the sum of all of the quantityreceived entries in $order_loop
$results = GetRecentAcqui($days);
$results
is a ref to a table which containts hashref
$contractlist = &GetContracts($booksellerid, $activeonly);
Looks up the contracts that belong to a bookseller
Returns a list of contracts
$booksellerid
is the "id" field in the "aqbooksellers" table.$activeonly
if exists get only contracts that are still active.$contract = &GetContract($contractID);
Looks up the contract that has PRIMKEY (contractnumber) value $contractID
Returns a contract
&AddClaim($ordernumber);
Add a claim for an order
my @invoices = GetInvoices( invoicenumber => $invoicenumber, suppliername => $suppliername, shipmentdatefrom => $shipmentdatefrom, # ISO format shipmentdateto => $shipmentdateto, # ISO format billingdatefrom => $billingdatefrom, # ISO format billingdateto => $billingdateto, # ISO format isbneanissn => $isbn_or_ean_or_issn, title => $title, author => $author, publisher => $publisher, publicationyear => $publicationyear, branchcode => $branchcode, order_by => $order_by );
Return a list of invoices that match all given criteria.
$order_by is "column_name (asc|desc)", where column_name is any of 'invoicenumber', 'booksellerid', 'shipmentdate', 'billingdate', 'closedate', 'shipmentcost', 'shipmentcost_budgetid'.
asc is the default if omitted
my $invoice = GetInvoice($invoiceid);
Get informations about invoice with given $invoiceid
Return a hash filled with aqinvoices.* fields
my $invoice = GetInvoiceDetails($invoiceid)
Return informations about an invoice + the list of related order lines
Orders informations are in $invoice->{orders} (array ref)
my $invoiceid = AddInvoice( invoicenumber => $invoicenumber, booksellerid => $booksellerid, shipmentdate => $shipmentdate, billingdate => $billingdate, closedate => $closedate, shipmentcost => $shipmentcost, shipmentcost_budgetid => $shipmentcost_budgetid );
Create a new invoice and return its id or undef if it fails.
ModInvoice( invoiceid => $invoiceid, # Mandatory invoicenumber => $invoicenumber, booksellerid => $booksellerid, shipmentdate => $shipmentdate, billingdate => $billingdate, closedate => $closedate, shipmentcost => $shipmentcost, shipmentcost_budgetid => $shipmentcost_budgetid );
Modify an invoice, invoiceid is mandatory.
Return undef if it fails.
CloseInvoice($invoiceid);
Close an invoice.
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => undef);
ReopenInvoice($invoiceid);
Reopen an invoice
Equivalent to ModInvoice(invoiceid => $invoiceid, closedate => C4::Dates->new()->output('iso'))
Koha Development Team <http://koha-community.org/>