From 7293c39048eee450b310d1de0b27dce3b0e36bea Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 16 Nov 2005 22:48:26 +0000 Subject: [PATCH 1/1] fixing money stuff -- note vs type git-svn-id: svn://svn.open-ils.org/ILS/trunk@2048 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Storage/CDBI/money.pm | 8 ++++---- Open-ILS/src/sql/Pg/080.schema.money.sql | 15 ++++++++++----- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm index c4fe509403..c49a67ba35 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm @@ -23,7 +23,7 @@ __PACKAGE__->columns(Essential => qw/total_paid total_owed balance_owed/); package money::user_circulation_summary; use base qw/money/; -__PACKAGE__->table('money_user_summary'); +__PACKAGE__->table('money_user_circulation_summary'); __PACKAGE__->columns(Primary => 'usr'); __PACKAGE__->columns(Essential => qw/total_paid total_owed balance_owed/); #------------------------------------------------------------------------------- @@ -34,8 +34,8 @@ __PACKAGE__->table('money_billable_transaction_summary'); __PACKAGE__->columns(Primary => 'id'); __PACKAGE__->columns(Essential => qw/xact_start usr xact_finish total_paid last_payment_ts total_owed last_billing_ts - balance_owed xact_type last_billing_note - last_payment_note/); + balance_owed xact_type last_billing_note last_billing_type + last_payment_note last_payment_type/); #------------------------------------------------------------------------------- package money::billing; @@ -82,7 +82,7 @@ __PACKAGE__->columns(Others => 'note'); package money::forgive_payment; use base qw/money/; -__PACKAGE__->table('money_payment'); +__PACKAGE__->table('money_forgive_payment'); __PACKAGE__->columns(Primary => 'id'); __PACKAGE__->columns(Essential => qw/xact amount payment_ts accepting_usr amount_collected/); __PACKAGE__->columns(Others => qw/note/); diff --git a/Open-ILS/src/sql/Pg/080.schema.money.sql b/Open-ILS/src/sql/Pg/080.schema.money.sql index 5812490273..23371684a0 100644 --- a/Open-ILS/src/sql/Pg/080.schema.money.sql +++ b/Open-ILS/src/sql/Pg/080.schema.money.sql @@ -18,6 +18,7 @@ CREATE TABLE money.billing ( billing_ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), voided BOOL NOT NULL DEFAULT FALSE, amount NUMERIC(6,2) NOT NULL, + billing_type TEXT NOT NULL, note TEXT ); CREATE INDEX m_b_xact_idx ON money.billing (xact); @@ -39,22 +40,24 @@ CREATE OR REPLACE VIEW money.payment_view AS CREATE OR REPLACE VIEW money.transaction_billing_summary AS SELECT xact, - note AS last_billing_note, + billing_type AS last_billing_type, + LAST(note) AS last_billing_note, MAX(billing_ts) AS last_billing_ts, SUM(COALESCE(amount,0)) AS total_owed FROM money.billing WHERE voided IS FALSE - GROUP BY xact,note + GROUP BY xact,billing_type ORDER BY MAX(billing_ts); CREATE OR REPLACE VIEW money.transaction_payment_summary AS SELECT xact, - note AS last_payment_note, + payment_type AS last_payment_type, + LAST(note) AS last_payment_note, MAX(payment_ts) as last_payment_ts, SUM(COALESCE(amount,0)) AS total_paid - FROM money.payment + FROM money.payment_view WHERE voided IS FALSE - GROUP BY xact,note + GROUP BY xact,payment_type ORDER BY MAX(payment_ts); CREATE OR REPLACE VIEW money.billable_xact_summary AS @@ -65,9 +68,11 @@ CREATE OR REPLACE VIEW money.billable_xact_summary AS credit.total_paid, credit.last_payment_ts, credit.last_payment_note, + credit.last_payment_type, debit.total_owed, debit.last_billing_ts, debit.last_billing_note, + debit.last_billing_type, COALESCE(debit.total_owed,0) - COALESCE(credit.total_paid,0) AS balance_owed, p.relname AS xact_type FROM money.billable_xact xact -- 2.43.2