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

[PATCH] Add new sproc for account_heading_get -- seems sloppy. Changed AM to use it for header accounts.



---
 LedgerSMB/DBObject/Account.pm |    9 +++++----
 sql/modules/Account.sql       |   13 ++++++++++++-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/LedgerSMB/DBObject/Account.pm b/LedgerSMB/DBObject/Account.pm
index 509ca20..065c523 100644
--- a/LedgerSMB/DBObject/Account.pm
+++ b/LedgerSMB/DBObject/Account.pm
@@ -45,12 +45,13 @@ value must be properly set.
  sub get {
     my $self = shift @_;
-    my @accounts =  $self->exec_method(funcname => 'account_get');
+    my $func = 'account_get';
+    if ($self->{charttype} and $self->{charttype} eq 'H'){
+      $func = 'account_heading_get';
+    }
+    my @accounts =  $self->exec_method(funcname => $func);
     $self->{account_list} = [];
     for my $ref (@accounts){
-        if ($self->{charttype} and $self->{charttype} ne
$ref->{charttype}){
-             next;
-        }
         bless $ref, 'LedgerSMB::DBObject::Account';
         $ref->merge($self, keys => ['_user', '_locale', 'stylesheet',
'dbh', '_roles', '_request']);
         push (@{$self->{account_list}}, $ref);
diff --git a/sql/modules/Account.sql b/sql/modules/Account.sql
index 1237fa1..7fff111 100644
--- a/sql/modules/Account.sql
+++ b/sql/modules/Account.sql
@@ -22,7 +22,18 @@ $$
 DECLARE
 	account chart%ROWTYPE;
 BEGIN
-	SELECT * INTO account FROM chart WHERE id = in_id;
+	SELECT * INTO account FROM chart WHERE id = in_id AND charttype = 'A';
+	RETURN account;
+END;
+$$ LANGUAGE plpgsql;
+
+
+CREATE OR REPLACE FUNCTION account_heading_get (in_id int) RETURNS chart AS
+$$
+DECLARE
+	account chart%ROWTYPE;
+BEGIN
+	SELECT * INTO account FROM chart WHERE id = in_id AND charttype = 'H';
 	RETURN account;
 END;
 $$ LANGUAGE plpgsql;