-->
</links>
</class>
+ <class id="mabs" controller="open-ils.cstore"
+ oils_obj:fieldmapper="money::aged_billing_summary"
+ oils_persist:tablename="money.aged_billing_summary"
+ oils_persist="readonly" reporter:label="Aged Billing Summary">
+ <fields oils_persist:primary="id" oils_persist:sequence="">
+ <field reporter:label="Balance Owed" name="balance_owed" reporter:datatype="money"/>
+ <field reporter:label="Transaction ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Last Billing Note" name="last_billing_note" reporter:datatype="text"/>
+ <field reporter:label="Last Billing Timestamp" name="last_billing_ts" reporter:datatype="timestamp"/>
+ <field reporter:label="Last Billing Type" name="last_billing_type" reporter:datatype="text"/>
+ <field reporter:label="Last Payment Note" name="last_payment_note" reporter:datatype="text"/>
+ <field reporter:label="Last Payment Timestamp" name="last_payment_ts" reporter:datatype="timestamp"/>
+ <field reporter:label="Last Payment Type" name="last_payment_type" reporter:datatype="text"/>
+ <field reporter:label="Total Owed" name="total_owed" reporter:datatype="money"/>
+ <field reporter:label="Total Paid" name="total_paid" reporter:datatype="money"/>
+ <field reporter:label="Transaction Finish Time" name="xact_finish" reporter:datatype="timestamp" />
+ <field reporter:label="Transaction Start Time" name="xact_start" reporter:datatype="timestamp" />
+ <field reporter:label="Transaction Type" name="xact_type" reporter:datatype="text"/>
+ </fields>
+ <links>
+ </links>
+ </class>
+ <class id="mallbs" controller="open-ils.cstore"
+ oils_obj:fieldmapper="money::all_billing_summary"
+ oils_persist:tablename="money.all_billing_summary"
+ oils_persist="readonly" reporter:label="Combined Aged and Active Billing Summary">
+ <fields oils_persist:primary="id" oils_persist:sequence="">
+ <field reporter:label="Balance Owed" name="balance_owed" reporter:datatype="money"/>
+ <field reporter:label="Transaction ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Last Billing Note" name="last_billing_note" reporter:datatype="text"/>
+ <field reporter:label="Last Billing Timestamp" name="last_billing_ts" reporter:datatype="timestamp"/>
+ <field reporter:label="Last Billing Type" name="last_billing_type" reporter:datatype="text"/>
+ <field reporter:label="Last Payment Note" name="last_payment_note" reporter:datatype="text"/>
+ <field reporter:label="Last Payment Timestamp" name="last_payment_ts" reporter:datatype="timestamp"/>
+ <field reporter:label="Last Payment Type" name="last_payment_type" reporter:datatype="text"/>
+ <field reporter:label="Total Owed" name="total_owed" reporter:datatype="money"/>
+ <field reporter:label="Total Paid" name="total_paid" reporter:datatype="money"/>
+ <field reporter:label="Transaction Finish Time" name="xact_finish" reporter:datatype="timestamp" />
+ <field reporter:label="Transaction Start Time" name="xact_start" reporter:datatype="timestamp" />
+ <field reporter:label="Transaction Type" name="xact_type" reporter:datatype="text"/>
+ </fields>
+ <links>
+ </links>
+ </class>
<class id="pugm" controller="open-ils.cstore" oils_obj:fieldmapper="permission::usr_grp_map" oils_persist:tablename="permission.usr_grp_map" reporter:label="User Group Map">
<fields oils_persist:primary="id" oils_persist:sequence="permission.usr_grp_map_id_seq">
<field name="grp" />
UNION ALL
SELECT * FROM money.aged_billing;
+-- Create table to hold aged materialized billable xact summary data
+CREATE TABLE money.aged_billing_summary (
+ id BIGINT,
+ xact_start TIMESTAMP WITH TIME ZONE,
+ xact_finish TIMESTAMP WITH TIME ZONE,
+ total_paid NUMERIC,
+ last_payment_ts TIMESTAMP WITH TIME ZONE,
+ last_payment_note TEXT,
+ last_payment_type TEXT,
+ total_owed NUMERIC,
+ last_billing_ts TIMESTAMP WITH TIME ZONE,
+ last_billing_note TEXT,
+ last_billing_type TEXT,
+ balance_owed NUMERIC,
+ xact_type TEXT
+);
+
+ALTER TABLE money.aged_billing_summary ADD PRIMARY KEY (id);
+
+CREATE INDEX money_aged_billing_summary_usr_idx ON money.aged_billing_summary (usr);
+CREATE INDEX money_aged_billing_summary_xact_start_idx ON money.aged_billing_summary (xact_start);
+
+CREATE OR REPLACE VIEW money.all_billing_summary AS
+ SELECT id, xact_start, xact_finish, total_paid, last_payment_ts
+ last_payment_note, last_payment_type, total_owed, last_billing_ts,
+ last_billing_note, last_billing_type, balance_owed, xact_type
+ FROM money.billable_xact_summary
+ UNION ALL
+ SELECT id, xact_start, xact_finish, total_paid, last_payment_ts
+ last_payment_note, last_payment_type, total_owed, last_billing_ts,
+ last_billing_note, last_billing_type, balance_owed, xact_type
+ FROM money.aged_billing_summary;
+
COMMIT;
auto_renewal, auto_renewal_remaining
FROM action.all_circulation WHERE id = OLD.id;
+ -- Archive a copy of materialized_xact_billing_summary (minus usr)
+ INSERT INTO money.aged_billing_summary
+ (id, xact_start, xact_finish, total_paid, last_payment_ts, last_payment_note, last_payment_type,
+ total_owed, last_billing_ts, last_billing_note, last_billing_type, balance_owed, xact_type)
+ SELECT
+ id, xact_start, xact_finish, total_paid, last_payment_ts, last_payment_note, last_payment_type,
+ total_owed, last_billing_ts, last_billing_note, last_billing_type, balance_owed, xact_type
+ FROM money.materialized_billable_xact_summary WHERE id = OLD.id;
+
-- Migrate billings and payments to aged tables
INSERT INTO money.aged_billing
--- /dev/null
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+-- Create table to hold aged materialized billable xact summary data
+CREATE TABLE money.aged_billing_summary (
+ id BIGINT,
+ xact_start TIMESTAMP WITH TIME ZONE,
+ xact_finish TIMESTAMP WITH TIME ZONE,
+ total_paid NUMERIC,
+ last_payment_ts TIMESTAMP WITH TIME ZONE,
+ last_payment_note TEXT,
+ last_payment_type TEXT,
+ total_owed NUMERIC,
+ last_billing_ts TIMESTAMP WITH TIME ZONE,
+ last_billing_note TEXT,
+ last_billing_type TEXT,
+ balance_owed NUMERIC,
+ xact_type TEXT
+);
+
+ALTER TABLE money.aged_billing_summary ADD PRIMARY KEY (id);
+
+CREATE INDEX money_aged_billing_summary_usr_idx ON money.aged_billing_summary (usr);
+CREATE INDEX money_aged_billing_summary_xact_start_idx ON money.aged_billing_summary (xact_start);
+
+CREATE OR REPLACE VIEW money.all_billing_summary AS
+ SELECT id, xact_start, xact_finish, total_paid, last_payment_ts
+ last_payment_note, last_payment_type, total_owed, last_billing_ts,
+ last_billing_note, last_billing_type, balance_owed, xact_type
+ FROM money.billable_xact_summary
+ UNION ALL
+ SELECT id, xact_start, xact_finish, total_paid, last_payment_ts
+ last_payment_note, last_payment_type, total_owed, last_billing_ts,
+ last_billing_note, last_billing_type, balance_owed, xact_type
+ FROM money.aged_billing_summary;
+
+-- populate the new table with aged billing/payment summary data
+
+COMMIT;