==== What are circulations? How do you encode them? ==== Circulations are how we keep track of a certain type of item (material) usage in Evergreen. When an item "circulates", it is checked out to (loaned to, or placed in custody of) a patron (in the common case, "user" is more general). The item generally leaves the building, but doesn't have to, and after a set amount of time may become "due" for return. Patrons may "renew" the loan period for their items, and usually get fined for any that are overdue. Evergreen doesn't allow "nested" circulations. An item may be actively circulating only once at any given time. In Evergreen, circulations are a type of billable transaction (in an object oriented sense, circulations inherit from billable transactions). A transaction is either opened or closed, and may or may not contain (or be linked to from) billings and payments. If the total monetary amount of the billings is greater than that of the payments, then the patron owes money for that billable transaction. For circulations, each overdue/late fine per fine interval is recorded as a line item billing that is attached to the circulation/billable transaction. === IDL for circulation === === database table definition for circulation === evergreen=# \d "action".circulation Table "action.circulation" Column | Type | Modifiers --------------------+--------------------------+------------------------------------------------------------------ id | bigint | not null default nextval('money.billable_xact_id_seq'::regclass) usr | integer | not null xact_start | timestamp with time zone | not null default now() xact_finish | timestamp with time zone | target_copy | bigint | not null circ_lib | integer | not null circ_staff | integer | not null checkin_staff | integer | checkin_lib | integer | renewal_remaining | integer | not null due_date | timestamp with time zone | stop_fines_time | timestamp with time zone | checkin_time | timestamp with time zone | create_time | timestamp with time zone | not null default now() duration | interval | fine_interval | interval | not null default '1 day'::interval recuring_fine | numeric(6,2) | max_fine | numeric(6,2) | phone_renewal | boolean | not null default false desk_renewal | boolean | not null default false opac_renewal | boolean | not null default false duration_rule | text | not null recuring_fine_rule | text | not null max_fine_rule | text | not null stop_fines | text | Indexes: "circulation_pkey" PRIMARY KEY, btree (id) "circ_checkin_time" btree (checkin_time) WHERE checkin_time IS NOT NULL "circ_circ_lib_idx" btree (circ_lib) "circ_open_date_idx" btree (xact_start) WHERE xact_finish IS NULL "circ_open_xacts_idx" btree (usr) WHERE xact_finish IS NULL "circ_outstanding_idx" btree (usr) WHERE checkin_time IS NULL Check constraints: "circulation_stop_fines_check" CHECK (stop_fines = ANY (ARRAY['CHECKIN'::text, 'CLAIMSRETURNED'::text, 'LOST'::text, 'MAXFINES'::text, 'RENEW'::text, 'LONGOVERDUE'::text])) Foreign-key constraints: "action_circulation_circ_lib_fkey" FOREIGN KEY (circ_lib) REFERENCES actor.org_unit(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED "action_circulation_target_copy_fkey" FOREIGN KEY (target_copy) REFERENCES asset."copy"(id) ON DELETE SET NULL DEFERRABLE INITIALLY DEFERRED "action_circulation_usr_fkey" FOREIGN KEY (usr) REFERENCES actor.usr(id) DEFERRABLE INITIALLY DEFERRED Triggers: action_circulation_stop_fines_tgr BEFORE UPDATE ON "action".circulation FOR EACH ROW EXECUTE PROCEDURE "action".circulation_claims_returned() Inherits: billable_xact === ILD for billable transaction === === database table definition for billable transaction === evergreen=# \d money.billable_xact Table "money.billable_xact" Column | Type | Modifiers -------------+--------------------------+------------------------------------------------------------------ id | bigint | not null default nextval('money.billable_xact_id_seq'::regclass) usr | integer | not null xact_start | timestamp with time zone | not null default now() xact_finish | timestamp with time zone | Indexes: "billable_xact_pkey" PRIMARY KEY, btree (id) "m_b_x_open_xacts_idx" btree (usr) Foreign-key constraints: "money_billable_xact_usr_fkey" FOREIGN KEY (usr) REFERENCES actor.usr(id) DEFERRABLE INITIALLY DEFERRED