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

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



Revision: 2913
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=2913&view=rev
Author:   einhverfr
Date:     2010-02-26 18:59:59 +0000 (Fri, 26 Feb 2010)

Log Message:
-----------
Committing Lacey Powers' patches for GL line item ordering and setting up bank recon from the user interface
minor whitespace edits to Account.sql for easier reading
Also my patch to add a link to the login screen to the logout page

Modified Paths:
--------------
    trunk/LedgerSMB/DBObject/Account.pm
    trunk/LedgerSMB/GL.pm
    trunk/UI/logout.html
    trunk/install-mycompany.sh
    trunk/scripts/account.pl
    trunk/sql/modules/Account.sql

Modified: trunk/LedgerSMB/DBObject/Account.pm
===================================================================
--- trunk/LedgerSMB/DBObject/Account.pm	2010-02-24 22:16:18 UTC (rev 2912)
+++ trunk/LedgerSMB/DBObject/Account.pm	2010-02-26 18:59:59 UTC (rev 2913)
@@ -30,6 +30,9 @@
     }
     $self->generate_links;
     $self->exec_method(funcname => 'account_save');
+    if (defined $self->{recon}){
+        $self->call_procedure(procname => 'cr_coa_to_account_save', args =>[ $self->{accno}, $self->{description}]);
+    }
     $self->{dbh}->commit;
 }
 

Modified: trunk/LedgerSMB/GL.pm
===================================================================
--- trunk/LedgerSMB/GL.pm	2010-02-24 22:16:18 UTC (rev 2912)
+++ trunk/LedgerSMB/GL.pm	2010-02-26 18:59:59 UTC (rev 2913)
@@ -427,10 +427,11 @@
         department  => 15,
         memo        => 16,
         trans_id    => 18,
-        chart_id    => 19
+        chart_id    => 19,
+        entry_id    => 20
     );
 
-    my @a = ( id, transdate, reference, source, description, accno );
+    my @a = ( entry_id, trans_id, chart_id, id, transdate, reference, source, description, accno);
     my $sortorder = $form->sort_order( ..hidden.., \%ordinal );
 
     my $chart_id;
@@ -448,11 +449,11 @@
         $approved = $dbh->quote($form->{approved});
     }
 
-    my $query = qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference,
+    my $query = qq|SELECT g.id, 'gl' AS type, $false AS invoice, g.reference::int,
 						  g.description, ac.transdate, ac.source,
 						  ac.amount, c.accno, c.gifi_accno, g.notes, c.link,
 						  '' AS till, ac.cleared, d.description AS department,
-						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id
+						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id, ac.entry_id
 					 FROM gl AS g
 					 JOIN acc_trans ac ON (g.id = ac.trans_id)
 					 JOIN chart c ON (ac.chart_id = c.id)
@@ -466,11 +467,11 @@
 
 					UNION ALL
 
-				   SELECT a.id, 'ar' AS type, a.invoice, a.invnumber,
+				   SELECT a.id, 'ar' AS type, a.invoice, a.invnumber::int,
 						  e.name, ac.transdate, ac.source,
 						  ac.amount, c.accno, c.gifi_accno, a.notes, c.link,
 						  a.till, ac.cleared, d.description AS department,
-						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id
+						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id, ac.entry_id 
 					 FROM ar a
 					 JOIN acc_trans ac ON (a.id = ac.trans_id)
 					 JOIN chart c ON (ac.chart_id = c.id)
@@ -486,11 +487,11 @@
 
 				UNION ALL
 
-				   SELECT a.id, 'ap' AS type, a.invoice, a.invnumber,
+				   SELECT a.id, 'ap' AS type, a.invoice, a.invnumber::int,
 						  e.name, ac.transdate, ac.source,
 						  ac.amount, c.accno, c.gifi_accno, a.notes, c.link,
 						  a.till, ac.cleared, d.description AS department,
-						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id
+						  ac.memo, c.description AS accname, ac.trans_id, ac.chart_id, ac.entry_id 
 					 FROM ap a
 					 JOIN acc_trans ac ON (a.id = ac.trans_id)
 					 JOIN chart c ON (ac.chart_id = c.id)
@@ -596,7 +597,7 @@
 					  JOIN chart c ON (ac.chart_id = c.id)
 				 LEFT JOIN project p ON (p.id = ac.project_id)
 					 WHERE ac.trans_id = ?
-				  ORDER BY accno|;
+				  ORDER BY ac.entry_id|;
 
         $sth = $dbh->prepare($query);
         $sth->execute( $form->{id} ) || $form->dberror($query);

Modified: trunk/UI/logout.html
===================================================================
--- trunk/UI/logout.html	2010-02-24 22:16:18 UTC (rev 2912)
+++ trunk/UI/logout.html	2010-02-26 18:59:59 UTC (rev 2913)
@@ -2,5 +2,6 @@
 <?lsmb PROCESS elements.html ?> 
 <body>
 <h1 class="info">Logout Successful</h1>
+<p><a href="login.pl"><?lsmb text('Return to the login screen.') ?></a>
 </body>
 </html>

Modified: trunk/install-mycompany.sh
===================================================================
--- trunk/install-mycompany.sh	2010-02-24 22:16:18 UTC (rev 2912)
+++ trunk/install-mycompany.sh	2010-02-26 18:59:59 UTC (rev 2913)
@@ -8,11 +8,11 @@
 
 # The following path can vary per distribution
 # Debian/Ubuntu
-CONTRIB=/usr/share/postgresql/8.3/contrib/
+CONTRIB=/usr/share/postgresql/$PGVERSION/contrib/
 # Compiled from source.
 #CONTRIB=/usr/local/pgsql/share/contrib
 
-echo 'This script will create a $MYCOMPANY dataset per INSTALL. Ctrl-C to cancel.'
+echo "This script will create a $MYCOMPANY dataset per INSTALL. Ctrl-C to cancel."
 
 dropdb -i -U postgres $MYCOMPANY 
 for role in `psql -U postgres -t -c "SELECT rolname FROM pg_roles WHERE rolname LIKE 'lsmb_${MYCOMPANY}%';"`; do dropuser -U postgres $role; done

Modified: trunk/scripts/account.pl
===================================================================
--- trunk/scripts/account.pl	2010-02-24 22:16:18 UTC (rev 2912)
+++ trunk/scripts/account.pl	2010-02-26 18:59:59 UTC (rev 2913)
@@ -17,6 +17,7 @@
     my @accounts = $account->get();
     my $a = shift @accounts;
     $a->{title} = $request->{_locale}->text('Edit Account');
+    $a->{_locale} = $request->{_locale};
     _display_account_screen($a);
 }
 
@@ -40,6 +41,8 @@
     my $buttons = [];
     my $checked;
     my $hiddens;
+    my $logger = Log::Log4perl->get_logger('');
+    $logger->debug("scripts/account.pl Locale: $locale");
 
     foreach my $item ( split( /:/, $form->{link} ) ) {
         $form->{$item} = "checked";

Modified: trunk/sql/modules/Account.sql
===================================================================
--- trunk/sql/modules/Account.sql	2010-02-24 22:16:18 UTC (rev 2912)
+++ trunk/sql/modules/Account.sql	2010-02-26 18:59:59 UTC (rev 2913)
@@ -5,6 +5,8 @@
 $$
      select * from account where accno = $1;
 $$ language sql;
+
+
 CREATE OR REPLACE FUNCTION account__get_taxes()
 RETURNS setof account AS
 $$
@@ -14,6 +16,7 @@
 ORDER BY accno;
 $$ language sql;
 
+
 CREATE OR REPLACE FUNCTION account_get (in_id int) RETURNS chart AS
 $$
 DECLARE
@@ -24,6 +27,7 @@
 END;
 $$ LANGUAGE plpgsql;
 
+
 CREATE OR REPLACE FUNCTION account_has_transactions (in_id int) RETURNS bool AS
 $$
 BEGIN
@@ -36,6 +40,7 @@
 END;
 $$ LANGUAGE plpgsql;
 
+
 CREATE OR REPLACE FUNCTION account_save 
 (in_id int, in_accno text, in_description text, in_category char(1), 
 in_gifi text, in_heading int, in_contra bool, in_link text[])
@@ -47,6 +52,7 @@
 	t_id int;
 BEGIN
 	-- check to ensure summary accounts are exclusive
+        -- necessary for proper handling by legacy code
 	FOR t_text IN 
 		select t_summary_links[generate_series] AS val 
 		FROM generate_series(array_lower(t_summary_links, 1), 
@@ -94,17 +100,20 @@
 		INSERT INTO account_link (account_id, description)
 		VALUES (t_id, t_text.val);
 	END LOOP;
+
 	
 	RETURN t_id;
 END;
 $$ language plpgsql;
 
+
 CREATE OR REPLACE FUNCTION account_heading_list()
 RETURNS SETOF account_heading AS
 $$
 SELECT * FROM account_heading order by accno;
 $$ language sql;
 
+
 CREATE OR REPLACE FUNCTION account_heading_save 
 (in_id int, in_accno text, in_description text, in_parent int)
 RETURNS int AS
@@ -126,9 +135,31 @@
 END;
 $$ LANGUAGE PLPGSQL;
 
+
 CREATE RULE chart_i AS ON INSERT TO chart
 DO INSTEAD
-SELECT CASE WHEN new.charttype='H' THEN account_heading_save(new.id, new.accno, new.description, NULL)
-ELSE account_save(new.id, new.accno, new.description, new.category, new.gifi_accno, NULL, CASE WHEN new.contra IS NULL THEN FALSE ELSE new.contra END, string_to_array(new.link, ':'))
+SELECT CASE WHEN new.charttype='H' THEN account_heading_save(new.id, new.accno, 
+new.description, NULL)
+ELSE account_save(new.id, new.accno, new.description, new.category, 
+new.gifi_accno, NULL, 
+CASE WHEN new.contra IS NULL THEN FALSE ELSE new.contra END, 
+string_to_array(new.link, ':'))
 END;
 --
+
+CREATE OR REPLACE FUNCTION cr_coa_to_account_save(in_accno text, in_description text)
+RETURNS void AS $BODY$
+    DECLARE
+       v_chart_id int;
+    BEGIN
+        -- Check for existence of the account already
+        PERFORM * FROM cr_coa_to_account WHERE in_accno = in_accno;
+
+        IF NOT FOUND THEN
+           -- This is a new account. Insert the relevant data.
+           SELECT chart_id INTO v_chart_id FROM charts WHERE accno = in_accno;
+           INSERT INTO cr_coa_to_account (chart_id, account) VALUES (v_chart_id, in_accno||'--'||in_description);
+        END IF;
+        -- Already found, no need to do anything. =) 
+    END;
+$BODY$ LANGUAGE PLPGSQL;


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