From db3e35002f922a80bf93ab5b5da09d2b352681d1 Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 19 Oct 2007 18:47:03 +0000 Subject: GL Vouchers are posting and saving correctly. Need to get listing and approving but that is conceptually a lot easier and involves a lot less legacy code git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1796 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/Batch.pm | 3 ++- LedgerSMB/DBObject.pm | 14 +++++++------- LedgerSMB/Form.pm | 2 +- LedgerSMB/GL.pm | 18 +++++++++++------- 4 files changed, 21 insertions(+), 16 deletions(-) (limited to 'LedgerSMB') diff --git a/LedgerSMB/Batch.pm b/LedgerSMB/Batch.pm index 1e6b320e..19cb656e 100644 --- a/LedgerSMB/Batch.pm +++ b/LedgerSMB/Batch.pm @@ -6,7 +6,8 @@ use base qw(LedgerSMB::DBObject); sub create { $self = shift @_; my ($ref) = $self->exec_method(funcname => 'batch_create'); - $self->{id} = $ref->{id} + print STDERR "$ref, $ref->{batch_create}, " . join (':', keys %$ref); + $self->{id} = $ref->{batch_create}; return $ref->{id}; } diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm index 93fc4f6e..4c96c82e 100644 --- a/LedgerSMB/DBObject.pm +++ b/LedgerSMB/DBObject.pm @@ -128,13 +128,13 @@ sub exec_method { my $m_name = $ref->{proname}; -# if ($args) { -# for my $arg (@proc_args) { -# if ( $arg =~ s/^in_// ) { - # push @call_args, $arg; -# } -# } -# } + if ($args) { + for my $arg (@proc_args) { + if ( $arg =~ s/^in_// ) { + push @call_args, $self->{$arg}; + } + } + } for (@in_args) { push @call_args, $_ } ; $self->{call_args} = \@call_args; diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index e5a8c9e4..5cc3b258 100644 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -2299,7 +2299,7 @@ sub create_links { } $sth->finish; } - if (!$self->{id}){ + if (!$self->{id} && !$self->{transdate}){ $self->{transdate} = $self->{current_date}; } diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm index 834bf8f0..7e4f8cc8 100644 --- a/LedgerSMB/GL.pm +++ b/LedgerSMB/GL.pm @@ -130,22 +130,24 @@ sub post_transaction { WHERE id = ?|; if (defined $form->{approved}) { - - $query = qq| UPDATE gl SET approved = ? WHERE id = ?|; + my $query = qq| UPDATE gl SET approved = ? WHERE id = ?|; $dbh->prepare($query)->execute($form->{approved}, $form->{id}) || $form->dberror($query); if (!$form->{approved}){ if (not defined $form->{batch_id}){ $form->error($locale->text('Batch ID Missing')); } - $query = qq| - INSERT INTO voucher (batch_id, trans_id) VALUES (?, ?)|; - $sth = $dbh->prepare($query); - $sth->execute($form->{batch_id}, $form->{id}) || + my $query = qq| + INSERT INTO voucher (batch_id, trans_id, batch_class) + VALUES (?, ?, (select id FROM batch_class + WHERE class = ?))|; + my $sth2 = $dbh->prepare($query); + $sth2->execute($form->{batch_id}, $form->{id}, 'gl') || $form->dberror($query); } } $sth = $dbh->prepare($query); + print STDERR $query; $sth->execute( $form->{transdate}, $department_id, $form->{id} ) || $form->dberror($query); @@ -570,7 +572,9 @@ sub transaction { my $results = $sth->fetchall_hashref('setting_key'); $form->{closedto} = $results->{'closedto'}->{'value'}; $form->{revtrans} = $results->{'revtrans'}->{'value'}; - $form->{transdate} = $results->{'revtrans'}->{'transdate'}; + if (!$form->{transdate}){ + $form->{transdate} = $results->{'revtrans'}->{'transdate'}; + } } $sth->finish; -- cgit v1.2.3