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/GL.pm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'LedgerSMB/GL.pm') 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