Hi,

Cannot seem to attach files to the sf issue tracker (dang is that a pain
in the butt!)

Cheers,
John Locke
http://freelock.com
diff --git sql/modules/Voucher.sql sql/modules/Voucher.sql
index 9eb9154..c9842e8 100644
--- sql/modules/Voucher.sql
+++ sql/modules/Voucher.sql
@@ -84,14 +84,14 @@ BEGIN
 		SELECT v.id, a.source,
                         cr.meta_number || '--'  || co.legal_name ,
 			v.batch_id, v.trans_id, 
-			CASE WHEN bc.class LIKE 'receipt%' THEN a.amount * -1
-			     ELSE a.amount  END, a.transdate, 
+			CASE WHEN bc.class LIKE 'receipt%' THEN sum(a.amount) * -1
+			     ELSE sum(a.amount)  END, a.transdate, 
 			CASE WHEN bc.class = 'receipt' THEN 'Receipt'
 			     WHEN bc.class = 'receipt_reversal' 
 			     THEN 'Receipt Reversal'
 			END
 		FROM voucher v
-		JOIN acc_trans a ON (v.trans_id = a.trans_id)
+		JOIN acc_trans a ON (v.id = a.voucher_id)
                 JOIN batch_class bc ON (bc.id = v.batch_class)
 		JOIN chart c ON (a.chart_id = c.id)
 		JOIN ar ON (ar.id = a.trans_id)
@@ -101,6 +101,8 @@ BEGIN
 		WHERE v.batch_id = in_batch_id 
 			AND a.voucher_id = v.id
 			AND (bc.class like 'receipt%' AND c.link = 'AR')
+		GROUP BY v.id, a.source, cr.meta_number, co.legal_name ,
+                        v.batch_id, v.trans_id, a.transdate, bc.class
 		UNION ALL
 		SELECT v.id, g.reference, g.description, 
 			v.batch_id, v.trans_id,
diff --git sql/modules/Payment.sql sql/modules/Payment.sql
index 4a06143..ed4b5ea 100644
--- sql/modules/Payment.sql
+++ sql/modules/Payment.sql
@@ -530,14 +530,16 @@ BEGIN
         IF in_account_class = 1 THEN
         	EXECUTE $E$
 	        	UPDATE ap 
-		        set paid = paid + (select amount from bulk_payments_in b 
-		         	where b.id = ap.id)
+		        set paid = paid + (select amount from bulk_payments_in b
+		         	where b.id = ap.id),
+                            datepaid = $E$ || quote_literal(in_payment_date) || $E$
 		         where id in (select id from bulk_payments_in) $E$;
         ELSE
         	EXECUTE $E$
 	        	UPDATE ar 
 		        set paid = paid + (select amount from bulk_payments_in b 
-		         	where b.id = ar.id)
+		         	where b.id = ar.id),
+                            datepaid = $E$ || quote_literal(in_payment_date) || $E$
 		         where id in (select id from bulk_payments_in) $E$;
         END IF;
 	EXECUTE $E$ DROP TABLE bulk_payments_in $E$;
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Ledger-smb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel

Reply via email to