[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[6750] trunk/sql/modules/Payment.sql



Revision: 6750
          http://sourceforge.net/p/ledger-smb/code/6750
Author:   einhverfr
Date:     2014-02-05 09:26:47 +0000 (Wed, 05 Feb 2014)
Log Message:
-----------
Correcting syntax errors with payments.sql changes (bug 1025 fix)
Correcting overpayments view.

Modified Paths:
--------------
    trunk/sql/modules/Payment.sql

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2014-02-04 09:59:47 UTC (rev 6749)
+++ trunk/sql/modules/Payment.sql	2014-02-05 09:26:47 UTC (rev 6750)
@@ -506,7 +506,7 @@
                     RAISE EXCEPTION 'Approved Batch';
                 ELSIF t_batch.locked_by IS NOT NULL THEN
                     RAISE EXCEPTION 'Locked Batch';
-                END;
+                END IF;
                 INSERT INTO voucher (batch_id, batch_class, trans_id)
                 values (in_batch_id,
                 (SELECT batch_class_id FROM batch WHERE id = in_batch_id),
@@ -1388,7 +1388,8 @@
 CREATE VIEW overpayments AS
 SELECT p.id as payment_id, p.reference as payment_reference, p.payment_class, p.closed as payment_closed,
        p.payment_date, ac.chart_id, c.accno, c.description as chart_description,
-       abs(sum(ac.amount)) as available, cmp.legal_name, 
+       sum(ac.amount) * CASE WHEN eca.entity_class = 1 THEN -1 ELSE 1 END 
+          as available, cmp.legal_name, 
        eca.id as entity_credit_id, eca.entity_id, eca.discount, eca.meta_number
 FROM payment p
 JOIN payment_links pl ON (pl.payment_id=p.id)
@@ -1401,7 +1402,7 @@
       AND c.link LIKE '%overpayment%'
 GROUP BY p.id, c.accno, p.reference, p.payment_class, p.closed, p.payment_date,
       ac.chart_id, chart_description,legal_name, eca.id,
-      eca.entity_id, eca.discount, eca.meta_number;
+      eca.entity_id, eca.discount, eca.meta_number, eca.entity_class;
 
 CREATE OR REPLACE FUNCTION payment_get_open_overpayment_entities(in_account_class int)
  returns SETOF payment_vc_info AS

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ledger-smb-commits mailing list
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-commits