making billing line items voidable
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 15 Jul 2005 16:12:47 +0000 (16:12 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 15 Jul 2005 16:12:47 +0000 (16:12 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@1210 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/money.pm
Open-ILS/src/sql/Postgres/080.schema.money.sql
Open-ILS/src/support-scripts/generate-fines.pl

index d0d961a..2ceea75 100644 (file)
@@ -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;
index 964ecda..995d00d 100644 (file)
@@ -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;
 
index ab183a9..0c3941e 100755 (executable)
@@ -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;