<<

NAME

C4::Acquisition - Koha functions for dealing with orders and acquisitions

SYNOPSIS

use C4::Acquisition;

DESCRIPTION

The functions in this module deal with acquisitions, managing book orders, basket and parcels.

FUNCTIONS

FUNCTIONS ABOUT BASKETS

GetBasket

  $aqbasket = &GetBasket($basketnumber);

get all basket informations in aqbasket for a given basket

returns: informations for a given basket returned as a hashref.

NewBasket

  $basket = &NewBasket( $booksellerid, $authorizedby, $basketname, 
      $basketnote, $basketbooksellernote, $basketcontractnumber );

Create a new basket in aqbasket table

$booksellerid is a foreign key in the aqbasket table
$authorizedby is the username of who created the basket

The other parameters are optional, see ModBasketHeader for more info on them.

CloseBasket

  &CloseBasket($basketno);

close a basket (becomes unmodifiable,except for recieves)

GetBasketAsCSV

  &GetBasketAsCSV($basketno);

Export a basket as CSV

CloseBasketgroup

  &CloseBasketgroup($basketgroupno);

close a basketgroup

ReOpenBaskergroup($basketgroupno)

  &ReOpenBaskergroup($basketgroupno);

reopen a basketgroup

DelBasket

  &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

  &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

  &ModBasketHeader($basketno, $basketname, $note, $booksellernote, $contractnumber);

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.

GetBasketsByBookseller

  @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)

GetBasketsByBasketgroup

  $baskets = &GetBasketsByBasketgroup($basketgroupid);

Returns a reference to all baskets that belong to basketgroup $basketgroupid.

NewBasketgroup

  $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->{'deliveryplace'} is the 'deliveryplace' 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

  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->{'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

  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

FUNCTIONS ABOUT ORDERS

GetBasketgroup

  $basketgroup = &GetBasketgroup($basketgroupid);

Returns a reference to the hash containing all infermation about the basketgroup.

GetBasketgroups

  $basketgroups = &GetBasketgroups($booksellerid);

Returns a reference to the array of all the basketgroups of bookseller $booksellerid.

FUNCTIONS ABOUT ORDERS

GetPendingOrders

  $orders = &GetPendingOrders($booksellerid, $grouped, $owner);

Finds pending orders from the bookseller with the given ID. Ignores completed and cancelled orders.

$booksellerid contains the bookseller identifier $grouped contains 0 or 1. 0 means returns the list, 1 means return the total $owner contains 0 or 1. 0 means any owner. 1 means only the list of orders entered by the user itself.

$orders is a reference-to-array; each element is a reference-to-hash with the following fields: $grouped is a boolean that, if set to 1 will group all order lines of the same basket in a single result line

authorizedby
entrydate
basketno

These give the value of the corresponding field in the aqorders table of the Koha database.

Results are ordered from most to least recent.

GetOrders

  @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.

GetOrderNumber

  $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.

GetOrder

  $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.

NewOrder

  &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.

$hashref->{'basketno'} is the basketno foreign key in aqorders, it is mandatory
$hashref->{'ordernumber'} is a "minimum order number."
$hashref->{'budgetdate'} is effectively ignored. If it's undef (anything false) or the string 'now', the current day is used. Else, the upcoming July 1st is used.
$hashref->{'subscription'} may be either "yes", or anything else for "no".
$hashref->{'uncertainprice'} may be 0 for "the price is known" or 1 for "the price is uncertain"
defaults entrydate to Now

The following keys are used: "biblionumber", "title", "basketno", "quantity", "notes", "biblioitemnumber", "rrp", "ecost", "gst", "unitprice", "subscription", "sort1", "sort2", "booksellerinvoicenumber", "listprice", "budgetdate", "purchaseordernumber", "branchcode", "booksellerinvoicenumber", "bookfundid".

NewOrderItem

  &NewOrderItem();

ModOrder

  &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

  &ModOrderItem(\%hashref);

Modifies the itemnumber in the aqorders_items table. The input hash needs three entities:

- itemnumber: the old itemnumber =item - ordernumber: the order this item is attached to =item - newitemnumber: the new itemnumber we want to attach the line to

ModOrderBibliotemNumber

  &ModOrderBiblioitemNumber($biblioitemnumber,$ordernumber, $biblionumber);

Modifies the biblioitemnumber for an existing order. Updates the order with order number $ordernum and biblionumber $biblionumber.

ModReceiveOrder

  &ModReceiveOrder($biblionumber, $ordernumber, $quantityreceived, $user,
    $unitprice, $booksellerinvoicenumber, $biblioitemnumber,
    $freight, $bookfund, $rrp);

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. The received portion must have a booksellerinvoicenumber.

Updates the order with bibilionumber $biblionumber and ordernumber $ordernumber.

SearchOrder

@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
bookfundid

DelOrder

  &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.

FUNCTIONS ABOUT PARCELS

GetParcel

  @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.

GetParcels

  $results = &GetParcels($bookseller, $order, $code, $datefrom, $dateto);

get a lists of parcels.

* Input arg :

$bookseller is the bookseller this function has to get parcels.
$order To know on what criteria the results list has to be ordered.
$code is the booksellerinvoicenumber.
$datefrom & $dateto to know on what date this function has to filter its search.

* return: a pointer on a hash list containing parcel informations as such :

Creation date
Last operation
Number of biblio
Number of items

GetLateOrders

  @results = &GetLateOrders;

Searches for bookseller with late orders.

return: the table of supplier with late issues. This table is full of hashref.

GetHistory

  (\@order_loop, $total_qty, $total_price, $total_qtyreceived) = GetHistory( $title, $author, $name, $from_placed_on, $to_placed_on );

Retreives some acquisition history information

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

GetRecentAcqui

  $results = GetRecentAcqui($days);

$results is a ref to a table which containts hashref

GetContracts

  $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.

GetContract

  $contract = &GetContract($contractID);

Looks up the contract that has PRIMKEY (contractnumber) value $contractID

Returns a contract

AUTHOR

Koha Development Team <http://koha-community.org/>

<<