From: miker Date: Fri, 15 Jul 2005 16:12:47 +0000 (+0000) Subject: making billing line items voidable X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=3673638074638ad1135d9e966c1f1215e08fdc1f;p=Evergreen.git making billing line items voidable git-svn-id: svn://svn.open-ils.org/ILS/trunk@1210 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- 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 d0d961aea5..2ceea75faf 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm @@ -34,8 +34,7 @@ package money::billing; use base qw/money/; __PACKAGE__->table('money_billing'); __PACKAGE__->columns(Primary => 'id'); -__PACKAGE__->columns(Essential => qw/xact amount billing_ts/); -__PACKAGE__->columns(Others => qw/note/); +__PACKAGE__->columns(Essential => qw/xact amount billing_ts note void/); #------------------------------------------------------------------------------- package money::payment; diff --git a/Open-ILS/src/sql/Postgres/080.schema.money.sql b/Open-ILS/src/sql/Postgres/080.schema.money.sql index 964ecdab46..995d00d313 100644 --- a/Open-ILS/src/sql/Postgres/080.schema.money.sql +++ b/Open-ILS/src/sql/Postgres/080.schema.money.sql @@ -17,7 +17,8 @@ CREATE TABLE money.billing ( xact BIGINT NOT NULL, -- money.billable_xact.id amount NUMERIC(6,2) NOT NULL, billing_ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), - note TEXT + note TEXT, + void BOOL NOT NULL DEFALUT FALSE ); CREATE INDEX m_b_xact_idx ON money.billing (xact); @@ -26,7 +27,8 @@ CREATE TABLE money.payment ( xact BIGINT NOT NULL, -- money.billable_xact.id amount NUMERIC(6,2) NOT NULL, payment_ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(), - note TEXT + note TEXT, + void BOOL NOT NULL DEFALUT FALSE ); CREATE INDEX m_p_xact_idx ON money.payment (xact); @@ -41,8 +43,8 @@ CREATE OR REPLACE VIEW money.billable_xact_summary AS MAX(debit.billing_ts) AS last_billing_ts, SUM(COALESCE(debit.amount,0) - COALESCE(credit.amount,0)) AS balance_owed FROM money.billable_xact xact - LEFT JOIN money.billing debit ON (xact.id = debit.xact) - LEFT JOIN money.payment credit ON (xact.id = credit.xact) + LEFT JOIN money.billing debit ON (xact.id = debit.xact AND debit.void IS FALSE) + LEFT JOIN money.payment credit ON (xact.id = credit.xact AND credit.void IS FALSE) WHERE xact.xact_finish IS NULL GROUP BY 1,2,3,4; diff --git a/Open-ILS/src/support-scripts/generate-fines.pl b/Open-ILS/src/support-scripts/generate-fines.pl index ab183a9489..0c3941ed3f 100755 --- a/Open-ILS/src/support-scripts/generate-fines.pl +++ b/Open-ILS/src/support-scripts/generate-fines.pl @@ -48,8 +48,9 @@ try { "\tItem was due on or before: ".localtime($due)."\n"; my $fine = $session->request( - 'open-ils.storage.direct.money.billing.search.xact', - $c->id, { order_by => 'billing_ts DESC', limit => '1' } + 'open-ils.storage.direct.money.billing.search', + { xact => $c->id, void => 'f' }, + { order_by => 'billing_ts DESC', limit => '1' } )->gather(1); my $last_fine;