Loans - roberts-sandbox/create-repo GitHub Wiki

Loans are the post type used to represent the borrowing of an Item from a library Member.

Loans hold information on which Item was loaned to whom, when and by which librarian. Additional information is added to the Loan when the Item is returned and if a Fine is incurred.

Items on loan can be renewed, allowing them to be on loan for longer without return. Items can be renewed either a limited number of times, or indefinitely, depending on the Library's settings. If an Item reaches its renewal limit it can be returned then re-loaned or the renewal limit can be increased by a Library Admin. Renewals are treated as modifications of an existing loan, creating post meta to store each renewal. Items, Members and Fines are ignorant of any renewals of a Loan.

Loans can also be scheduled, creating a loan that will be fulfilled at a later date. Scheduling allows a Librarian to reserve access of an Item for a Member. An Item can not be renewed if the resulting renewal would clash with a scheduled loan. Scheduling can be used as a means of reservation, for books in high demand, or a way of prompting another librarian to fulfil a loan which could not be fulfilled at the time. For example: John wants to borrow the book Raising Steam and asks the book club's librarian if he can. She agrees and schedules the loan to be fulfilled at the next club meeting. Scheduled Loans are fulfilled when the Item is given to the Member.

###Post Meta

Loans store information about themselves and foreign keys to connected library objects in their post meta. Below lists all post meta added by WP-Librarian, mandatory unless otherwise noted.

Meta Key Data Type Description
Start Date wp_lib_start_date Unix time stamp The date/time the item was scheduled to be given to the member
End Date wp_lib_end_date Unix time stamp The date/time the item was scheduled to be returned. If the item is renewed this date is updated and the previous date saved in the renewal data
Given Date wp_lib_give_date Unix time stamp The date/time the item was actually given to the member. This will match the start date if the item is directly loaned rather than scheduled
Given Librarian wp_lib_give_user Integer The user ID of the librarian who marked the item as having left the library. This will match the post author if the item is directly loaned rather than scheduled
Return Date wp_lib_return_date Unix time stamp The date/time the item was actually returned
Return Librarian wp_lib_return_user Integer The user ID of the librarian who marked the item as having been returned. This will match the post author of the fine, were one charged
Item ID wp_lib_item Integer The post ID of the item that was loaned
Member ID wp_lib_member Integer The post ID of the member that borrowed the item
Loan Status wp_lib_status Integer The current status of the loan, see below
RenewedΔ wp_lib_renew Array (Serialised) Each post meta instance represents a time the loan was renewed. Each instance contains: current time stamp, loan's previous End Date, librarian's user ID

* Optional post meta
† Post meta that has a reasonable expectation of eventually existing (such as the date an item is returned)
Δ Post meta with multiple values

Note: Given Librarian and Return Librarian were only added in Wolf Tail. For pre-Wolf Tail installations these meta values should be considered optional.

###Loan Status

Loans can have different states depending on whether they are scheduled/active/returned. These loan states also indicate which optional post meta should exist.

State Name Description
0 N/A Invalid status
1 On Loan The item is outside the library with a member
2 Returned The item was returned on time
3 Returned Late The item was returned late but the fine was wavered
4 Returned Late (with fine) The item was returned late and a fine was charged
5 Scheduled The loan is scheduled to happen but the item has not yet left the library
⚠️ **GitHub.com Fallback** ⚠️