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

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



Revision: 6782
          http://sourceforge.net/p/ledger-smb/code/6782
Author:   einhverfr
Date:     2014-02-06 08:43:58 +0000 (Thu, 06 Feb 2014)
Log Message:
-----------
Fixing 1015.  It is possible this may need to be backported to 1.3, to review after 1.3.38 is released.

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

Modified: trunk/sql/modules/Payment.sql
===================================================================
--- trunk/sql/modules/Payment.sql	2014-02-06 07:59:46 UTC (rev 6781)
+++ trunk/sql/modules/Payment.sql	2014-02-06 08:43:58 UTC (rev 6782)
@@ -596,6 +596,11 @@
              FROM bulk_payments_in  where amount <> 0;
 
         -- early payment discounts
+        IF t_cash_sign IS NULL THEN
+             raise exception 't_cash_sign is null';
+        ELSIF t_exchangerate IS NULL THEN
+             raise exception 't_exchangerate is null';
+        END IF; 
         INSERT INTO acc_trans
                (trans_id, chart_id, amount, approved,
                voucher_id, transdate, source)
@@ -614,7 +619,9 @@
                  WHERE in_account_class = 1) gl ON gl.id = bpi.id
           JOIN entity_credit_account eca ON gl.entity_credit_account = eca.id
          WHERE bpi.amount <> 0 
-               AND extract('days' from age(gl.transdate)) < eca.discount_terms;
+               AND extract('days' from age(gl.transdate)) < eca.discount_terms
+               and eca.discount_terms is not null AND discount IS NOT NULL
+               AND eca.discount_account_id IS NOT NULL;
 
         INSERT INTO acc_trans
                (trans_id, chart_id, amount, approved,
@@ -634,7 +641,9 @@
                  WHERE in_account_class = 1) gl ON gl.id = bpi.id
           JOIN entity_credit_account eca ON gl.entity_credit_account = eca.id
          WHERE bpi.amount <> 0 
-               AND extract('days' from age(gl.transdate)) < eca.discount_terms;
+               AND extract('days' from age(gl.transdate)) < eca.discount_terms
+               AND eca.discount_terms IS NOT NULL AND discount IS NOT NULL
+               AND eca.discount_account_id IS NOT NULL;
 
         -- Insert ar/ap side
         INSERT INTO acc_trans

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