Stock Rotation for Koha

Basic concepts:

Koha already includes the ability to group items into collections and then manually rotate them to any library branch as a group.

Stock rotation is much more about the automated rotation of individual items. We will add the ability to configure rotation plans.  Initially the plans will allow rotation based upon time periods at library branches on a per branch basis, however if there is due interest other triggers may be implemented as a followup.

Database Schema

sr_rota
To store rota details… giving a rota an id, name and description along with some special exceptions.

  rotaId int(11) NOT NULL auto_increment COMMENT ‘Unique rota ID’,
  title varchar(100) NOT NULL default ‘’,
  tesc text NOT NULL default ‘’,
  cyclical TINYINT(1) NOT NULL default ‘0’,
  indemand TINYINT(1) NOT NULL default ‘0’,
  active TINYINT(1) NOT NULL default ‘0’,
  PRIMARY KEY (rotaID)

sr_stage
To store rota stages… putting a series of triggers in order on a rota.

  stageId int(11) NOT NULL auto_increment COMMENT ‘Unique trigger ID’,
  rotaId int(11) NOT NULL COMMENT ‘Rota trigger belongs to, references collections_rota.rotaId’,
  sequence int(11) NOT NULL COMMENT ‘Sequence number for triggers in rota’,
  branchNext varchar(10) NOT NULL COMMENT ‘Next branch to rotate to, references branches.branchcode’,
  duration int(11) NOT NULL default '4',
  PRIMARY KEY stageId

sr_item
To store an individual items rota details…

  itemnumber int(11) NOT NULL COMMENT ‘References items.itemnumber’,
  rotaId int(11) NOT NULL COMMENT ‘References sr_rota.rotaId’,
  stageId int(11) NOT NULL COMMENT ‘References sr_stage.stageId’,
  PRIMARY KEY (‘itemnumber’)

sr_triggers [Followup if interest shown]
To store trigger rules… should contain one rule by default (Duration) to allow rotation by duration stay at library. (Would also need modification to sr_stage above, replacing ‘duration’ with ‘trigID’ and ‘actuator’)

  trigId int(11) NOT NULL auto_increment COMMENT ‘Unique trigger ID’,
  rule text NOT NULL default ‘’
  PRIMARY KEY trifId

branchtransfers (existing)
Used for tracking when items were transferred to current branch.

  Add the note ‘StockRotation’ for transfers triggered by the stock rotation module, and use this to track item time periods at library branches.

systempreferences (existing)

permissions (existing)

System Preferences

The feature should be optional, therefore a system preference should be added to switch ‘Stock Rotation’ on or off.  This will be checked when deciding whether to display the rota field at item level, the rota configuration tool and alerts at checkin etc.

System Permissions

The configuration of rota’s, and which items belong to them should be permissions based.  A new permission should be introduced to control whether a user may add/update/remove rotas [and triggers in the followup], and a further permission is required to control whether a user can add/update/remove an item on a rota and whether they can manually move an item on in it’s rotation.

Configuring Rotas (new)
Upon enabling ‘Stock Rotation’ a new option should appear in the tools menu ‘Manage Stock Rotation’.

Each rota definition should contain information about the type of rota, the list of libraries and the minimum duration in days that an item should stay at each library before being eligible for moving on. Each library on the list should be configurable for a different duration. If the same library is on more than one rota it need not use the same duration on each rota. When an item is allocated to a rota it can start anywhere on the list of libraries.

So, there will be a table with a list of all the rotas and an option to “add” a rota with a template containing :-

Rota Name	Cyclical	Deleted	In Demand	Status	
PAPERBACK1	YES	NO	2	(Completed, Started, Not Started)	
PAPERBACK2	NO	NO			

A rota can be cyclical or not (that is, the stock keeps moving round and round branches indefinitely or it comes to the end at the last branch). 

A rota can also be “In demand”. For “In Demand” rota type there is an additional parameter that can be configured. This multiplies the time an item spends at the item’s first library. For example, if the parameter is set to 2 the item will stay twice as long at its first library.

Adding Stages to a Rota

Once you’ve created this you can click on the rota and add the rota stages. This will be a table/form containing.

Sequence	Library	Duration	
1	MAIN	120	
2	EDUCATION	80	
3	HUNT	120	

Managing Items
Upon enabling Stock Rotation we would like a further ‘Rota’ option to become visible upon the item detail screen (depending upon your staff permissions).

This tab should contain details of the current schedule/rota the item is allocated to, and what stage in that rota the item is at.  Along with these details should be the option to modify any parameter allowing the item to be moved onto a different rota or be manually transferred ahead of it’s scheduled rotation.

Additionally, within the Manage Stock Rotation item under tools, a user should be able to bring up a list of items on a particular rota and perform basic management functions upon them.

Description of Workflow
1. Overnight the stock_rotation_cron script will trigger transfers for items that have exceeded their stay at the current stage.
2. An email report will be sent to the email address registered in Koha for the branch that currently holds the item, which contains author, title, and barcode.
3. Items must be checked in, and they will be put into transit (with Alert - In Transit for Rotation).
4. When items are checked in at the destination branch, the rotas will be updated and the new stage begins for the amount of days specified in the database.
5. At the end of the rota, items either:
	a. Stay at the final branch if the rota is not cyclical
	b. Go into transit to the first branch in the sequence and the rotation begins again.

Followups

1) Allow rotation to accept other triggers  - for example analytic usage triggers