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

SF.net SVN: ledger-smb:[2722] trunk/sql/modules/EndOfYear.sql



Revision: 2722
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2722&view=rev
Author:   einhverfr
Date:     2009-07-14 22:01:43 +0000 (Tue, 14 Jul 2009)

Log Message:
-----------
More changes to end of year routines

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

Modified: trunk/sql/modules/EndOfYear.sql
===================================================================
--- trunk/sql/modules/EndOfYear.sql	2009-07-14 01:07:48 UTC (rev 2721)
+++ trunk/sql/modules/EndOfYear.sql	2009-07-14 22:01:43 UTC (rev 2722)
@@ -40,7 +40,8 @@
 $$ language plpgsql;
 
 CREATE OR REPLACE FUNCTION eoy_zero_accounts
-(in_end_date date, in_reference text, in_description text)
+(in_end_date date, in_reference text, in_description text, 
+in_retention_acc_id int)
 RETURNS int AS
 $$
 DECLARE ret_val int;
@@ -49,8 +50,8 @@
 	VALUES (in_end_date, in_reference, in_description, true);
 
 	INSERT INTO yearend (id, transdate) values (currval('id'), in_end_date);
-	INSERT INTO acc_trans (trans_date, chart_id, amount)
-	SELECT in_end_date, a.chart_id, 
+	INSERT INTO acc_trans (transdate, chart_id, trans_id, amount)
+	SELECT in_end_date, a.chart_id, currval('id'),
 		(sum(a.amount) + coalesce(cp.amount, 0)) * -1
 	FROM acc_trans a
 	LEFT JOIN (
@@ -63,7 +64,12 @@
 		AND a.transdate > coalesce(cp.end_date, a.transdate)
 		AND acc.category IN ('I', 'E');
 
+	INSERT INTO acc_trans (transdate, trans_id, chart_id, amount)
+	SELECT in_end_date, currval('id'), in_retention_acc_id, 
+		sum(amount) * -1
+	FROM acc_trans WHERE trans_id = currval('id');
 
+
 	SELECT count(*) INTO ret_val from acc_trans 
 	where trans_id = currval('id');
 


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