]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/XXXX.lp1788260.schema.non-cat-in-house-use-aacct.sql
LP#1788260 - Break out in-house-use non-cat circulations.
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / XXXX.lp1788260.schema.non-cat-in-house-use-aacct.sql
1 BEGIN;
2
3 CREATE OR REPLACE VIEW action.all_circulation_combined_types AS
4  SELECT acirc.id AS id,
5     acirc.xact_start,
6     acirc.circ_lib,
7     acirc.circ_staff,
8     acirc.create_time,
9     ac_acirc.circ_modifier AS item_type,
10     'regular_circ'::text AS circ_type
11    FROM action.circulation acirc,
12     asset.copy ac_acirc
13   WHERE acirc.target_copy = ac_acirc.id
14 UNION ALL
15  SELECT ancc.id::BIGINT AS id,
16     ancc.circ_time AS xact_start,
17     ancc.circ_lib,
18     ancc.staff AS circ_staff,
19     ancc.circ_time AS create_time,
20     cnct_ancc.name AS item_type,
21     'non-cat_circ'::text AS circ_type
22    FROM action.non_cataloged_circulation ancc,
23     config.non_cataloged_type cnct_ancc
24   WHERE ancc.item_type = cnct_ancc.id
25 UNION ALL
26  SELECT aihu.id::BIGINT AS id,
27     aihu.use_time AS xact_start,
28     aihu.org_unit AS circ_lib,
29     aihu.staff AS circ_staff,
30     aihu.use_time AS create_time,
31     ac_aihu.circ_modifier AS item_type,
32     'in-house_use'::text AS circ_type
33    FROM action.in_house_use aihu,
34     asset.copy ac_aihu
35   WHERE aihu.item = ac_aihu.id
36 UNION ALL
37  SELECT ancihu.id::BIGINT AS id,
38     ancihu.use_time AS xact_start,
39     ancihu.org_unit AS circ_lib,
40     ancihu.staff AS circ_staff,
41     ancihu.use_time AS create_time,
42     cnct_ancihu.name AS item_type,
43     'non-cat-in-house_use'::text AS circ_type
44    FROM action.non_cat_in_house_use ancihu,
45     config.non_cataloged_type cnct_ancihu
46   WHERE ancihu.item_type = cnct_ancihu.id
47 UNION ALL
48  SELECT aacirc.id AS id,
49     aacirc.xact_start,
50     aacirc.circ_lib,
51     aacirc.circ_staff,
52     aacirc.create_time,
53     ac_aacirc.circ_modifier AS item_type,
54     'aged_circ'::text AS circ_type
55    FROM action.aged_circulation aacirc,
56     asset.copy ac_aacirc
57   WHERE aacirc.target_copy = ac_aacirc.id;
58
59 COMMIT;
60