]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/sql/Pg/upgrade/0583.schema.aging_circ_view.sql
LP#1206936 - Fix wrong billing info in money.transaction_billing_summary
[Evergreen.git] / Open-ILS / src / sql / Pg / upgrade / 0583.schema.aging_circ_view.sql
1 -- Evergreen DB patch 0583.schema.aging_circ_view.sql
2 --
3 -- This implements the same update as 0582.schema.aging_circ_view.sql,
4 -- and exists purely the the sake of avoid a potential upgrade
5 -- glitch for somebody who's upgrading from 2.0.8+.
6 --
7 --
8 BEGIN;
9
10 -- check whether patch can be applied
11 SELECT evergreen.upgrade_deps_block_check('0583', :eg_version);
12
13 CREATE OR REPLACE VIEW action.all_circulation AS
14     SELECT  id,usr_post_code, usr_home_ou, usr_profile, usr_birth_year, copy_call_number, copy_location,
15         copy_owning_lib, copy_circ_lib, copy_bib_record, xact_start, xact_finish, target_copy,
16         circ_lib, circ_staff, checkin_staff, checkin_lib, renewal_remaining, grace_period, due_date,
17         stop_fines_time, checkin_time, create_time, duration, fine_interval, recurring_fine,
18         max_fine, phone_renewal, desk_renewal, opac_renewal, duration_rule, recurring_fine_rule,
19         max_fine_rule, stop_fines, workstation, checkin_workstation, checkin_scan_time, parent_circ
20       FROM  action.aged_circulation
21             UNION ALL
22     SELECT  DISTINCT circ.id,COALESCE(a.post_code,b.post_code) AS usr_post_code, p.home_ou AS usr_home_ou, p.profile AS usr_profile, EXTRACT(YEAR FROM p.dob)::INT AS usr_birth_year,
23         cp.call_number AS copy_call_number, cp.location AS copy_location, cn.owning_lib AS copy_owning_lib, cp.circ_lib AS copy_circ_lib,
24         cn.record AS copy_bib_record, circ.xact_start, circ.xact_finish, circ.target_copy, circ.circ_lib, circ.circ_staff, circ.checkin_staff,
25         circ.checkin_lib, circ.renewal_remaining, circ.grace_period, circ.due_date, circ.stop_fines_time, circ.checkin_time, circ.create_time, circ.duration,
26         circ.fine_interval, circ.recurring_fine, circ.max_fine, circ.phone_renewal, circ.desk_renewal, circ.opac_renewal, circ.duration_rule,
27         circ.recurring_fine_rule, circ.max_fine_rule, circ.stop_fines, circ.workstation, circ.checkin_workstation, circ.checkin_scan_time,
28         circ.parent_circ
29       FROM  action.circulation circ
30         JOIN asset.copy cp ON (circ.target_copy = cp.id)
31         JOIN asset.call_number cn ON (cp.call_number = cn.id)
32         JOIN actor.usr p ON (circ.usr = p.id)
33         LEFT JOIN actor.usr_address a ON (p.mailing_address = a.id)
34         LEFT JOIN actor.usr_address b ON (p.billing_address = b.id);
35
36
37
38 COMMIT;