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

SF.net SVN: ledger-smb:[4877] trunk



Revision: 4877
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=4877&view=rev
Author:   einhverfr
Date:     2012-06-09 14:40:04 +0000 (Sat, 09 Jun 2012)
Log Message:
-----------
Adding Equity (Temp) account type for drawing and other equity accounts that get closed at year-end

Modified Paths:
--------------
    trunk/Changelog
    trunk/LedgerSMB/DBObject/Account.pm
    trunk/UI/accounts/edit.html
    trunk/sql/Pg-database.sql
    trunk/sql/modules/Account.sql
    trunk/sql/modules/EndOfYear.sql
    trunk/sql/modules/Fixes.sql

Modified: trunk/Changelog
===================================================================
--- trunk/Changelog	2012-06-09 10:23:02 UTC (rev 4876)
+++ trunk/Changelog	2012-06-09 14:40:04 UTC (rev 4877)
@@ -16,6 +16,7 @@
 * Centralized database commit for new code (Chris T)
 * invoice.unit is now unbounded numeric to reduce errors (Chris T, 3516235)
 * Invoices with inventory subject to draft/vouchers workflows (Chris T)
+* Added Equity (Temp) account type (Chris T)
 
 New RESTful Web Services Framework
 * Supports XML and JSON as input formats

Modified: trunk/LedgerSMB/DBObject/Account.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Account.pm	2012-06-09 10:23:02 UTC (rev 4876)
+++ trunk/LedgerSMB/DBObject/Account.pm	2012-06-09 14:40:04 UTC (rev 4877)
@@ -54,6 +54,10 @@
     if (!defined $self->{tax}) {
 	$self->{tax} = '0';
     }
+    if ($self->{category} eq 'Qt'){
+       $self->{is_temp} = '1';
+       $self->{category} = 'Q';
+    }
     $self->generate_links;
     my $func = 'account_save';
     if ($self->{charttype} and $self->{charttype} eq 'H') {

Modified: trunk/UI/accounts/edit.html
===================================================================
--- trunk/UI/accounts/edit.html	2012-06-09 10:23:02 UTC (rev 4876)
+++ trunk/UI/accounts/edit.html	2012-06-09 14:40:04 UTC (rev 4877)
@@ -102,6 +102,7 @@
               { value = 'A', text = text('Asset') }
               { value = 'L', text = text('Liability') }
               { value = 'Q', text = text('Equity') }
+              { value = 'Qt', text = text('Equity (Temporary)') } #'
               { value = 'I', text = text('Income') }
               { value = 'E', text = text('Expense') }
         ];  

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2012-06-09 10:23:02 UTC (rev 4876)
+++ trunk/sql/Pg-database.sql	2012-06-09 14:40:04 UTC (rev 4877)
@@ -72,6 +72,7 @@
   id serial not null unique,
   accno text primary key,
   description text,
+  is_temp not null default false bool,
   category CHAR(1) NOT NULL,
   gifi_accno text,
   heading int not null references account_heading(id),
@@ -80,6 +81,9 @@
   obsolete bool not null default false
 );
 
+COMMENT ON COLUMN account.is_temp IS
+$$ Only affects equity accounts.  If set, close at end of year. $$;
+
 COMMENT ON TABLE  account IS
 $$ This table stores the main account info.$$;
 

Modified: trunk/sql/modules/Account.sql
===================================================================
--- trunk/sql/modules/Account.sql	2012-06-09 10:23:02 UTC (rev 4876)
+++ trunk/sql/modules/Account.sql	2012-06-09 14:40:04 UTC (rev 4877)
@@ -70,10 +70,10 @@
 $$ Checks to see if any transactions use this account.  If so, returns true.
 If not, returns false.$$;
 
-CREATE OR REPLACE FUNCTION account_save 
+CREATE OR REPLACE FUNCTION account__save 
 (in_id int, in_accno text, in_description text, in_category char(1), 
 in_gifi_accno text, in_heading int, in_contra bool, in_tax bool,
-in_link text[], is_obsolete bool)
+in_link text[], in_obsolete bool, in_is_temp bool)
 RETURNS int AS $$
 DECLARE 
 	t_heading_id int;
@@ -115,8 +115,9 @@
 		gifi_accno = in_gifi_accno,
 		heading = t_heading_id,
 		contra = in_contra,
-                obsolete = is_obsolete,
-                tax = t_tax
+                obsolete = in_obsolete,
+                tax = t_tax,
+                is_temp = in_is_temp
 	WHERE id = in_id;
 
 	IF FOUND THEN
@@ -125,9 +126,9 @@
                 -- can't obsolete on insert, but this can be changed if users
                 -- request it --CT
 		INSERT INTO account (accno, description, category, gifi_accno,
-			heading, contra, tax)
+			heading, contra, tax, is_temp)
 		VALUES (in_accno, in_description, in_category, in_gifi_accno,
-			t_heading_id, in_contra, in_tax);
+			t_heading_id, in_contra, in_tax, in_is_temp);
 
 		t_id := currval('account_id_seq');
 	END IF;

Modified: trunk/sql/modules/EndOfYear.sql
===================================================================
--- trunk/sql/modules/EndOfYear.sql	2012-06-09 10:23:02 UTC (rev 4876)
+++ trunk/sql/modules/EndOfYear.sql	2012-06-09 14:40:04 UTC (rev 4877)
@@ -81,7 +81,8 @@
 	JOIN account acc ON (acc.id = a.chart_id)
 	WHERE a.transdate <= in_end_date 
 		AND a.transdate > coalesce(cp.end_date, a.transdate - 1)
-		AND acc.category IN ('I', 'E')
+		AND (acc.category IN ('I', 'E')
+                      OR acc.category = 'Q' AND acc.is_temp)
 	GROUP BY a.chart_id;
 
 	INSERT INTO acc_trans (transdate, trans_id, chart_id, amount)

Modified: trunk/sql/modules/Fixes.sql
===================================================================
--- trunk/sql/modules/Fixes.sql	2012-06-09 10:23:02 UTC (rev 4876)
+++ trunk/sql/modules/Fixes.sql	2012-06-09 14:40:04 UTC (rev 4877)
@@ -9,3 +9,7 @@
 ALTER TABLE makemodel ADD barcode TEXT;
 
 COMMIT;
+
+BEGIN;
+ALTER TABLE account ADD COLUMN is_temp BOOL NOT NULL DEFAULT FALSE;
+COMMIT;

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