From 6e13bacefd8e71242dec64a3185215980e749bcf Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 19 Jun 2007 06:37:26 +0000 Subject: Voucher creation support added to API git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1284 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/AA.pm | 5 +++++ LedgerSMB/GL.pm | 6 ++++++ LedgerSMB/IR.pm | 6 ++++++ LedgerSMB/IS.pm | 6 ++++++ LedgerSMB/OP.pm | 8 ++++++-- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm index 2edcc44a..4f14fda8 100644 --- a/LedgerSMB/AA.pm +++ b/LedgerSMB/AA.pm @@ -321,7 +321,12 @@ sub post_transaction { ); $dbh->prepare($query)->execute(@queryargs) || $form->dberror($query); + if (defined $form->{approved}) { + $query = qq| UPDATE $table SET approved = ? WHERE id = ?|; + $dbh->prepare($query)->execute($form->{approved}, $form->{id}) || + $form->dberror($query); + } @queries = $form->run_custom_queries( $table, 'INSERT' ); # update exchangerate diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm index 322e08b1..98be9cbe 100644 --- a/LedgerSMB/GL.pm +++ b/LedgerSMB/GL.pm @@ -130,6 +130,12 @@ sub post_transaction { department_id = ? WHERE id = ?|; + if (defined $form->{approved}) { + + $query = qq| UPDATE gl SET approved = ? WHERE id = ?|; + $dbh->prepare($query)->execute($form->{approved}, $form->{id}) + || $form->dberror($query); + } $sth = $dbh->prepare($query); $sth->execute( $form->{transdate}, $department_id, $form->{id} ) || $form->dberror($query); diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm index 714acf61..4812b9f8 100644 --- a/LedgerSMB/IR.pm +++ b/LedgerSMB/IR.pm @@ -295,6 +295,12 @@ sub post_invoice { $project_id, $form->{"serialnumber_$i"}, $form->{"notes_$i"}, $invoice_id ) || $form->dberror($query); + if (defined $form->{approved}) { + + $query = qq| UPDATE ap SET approved = ? WHERE id = ?|; + $dbh->prepare($query)->execute($form->{approved}, $form->{id}) + || $form->dberror($query); + } if ( $form->{"inventory_accno_id_$i"} ) { diff --git a/LedgerSMB/IS.pm b/LedgerSMB/IS.pm index f737e5d3..dfbb465d 100644 --- a/LedgerSMB/IS.pm +++ b/LedgerSMB/IS.pm @@ -1096,6 +1096,12 @@ sub post_invoice { $project_id, $form->{"serialnumber_$i"}, $form->{"notes_$i"}, $invoice_id ) || $form->dberror($query); + if (defined $form->{approved}) { + + $query = qq| UPDATE ar SET approved = ? WHERE id = ?|; + $dbh->prepare($query)->execute($form->{approved}, $form->{id}) + || $form->dberror($query); + } # add invoice_id $form->{acc_trans}{lineitems}[$ndx]->{invoice_id} = $invoice_id; diff --git a/LedgerSMB/OP.pm b/LedgerSMB/OP.pm index 3a07f036..836ef92c 100644 --- a/LedgerSMB/OP.pm +++ b/LedgerSMB/OP.pm @@ -92,9 +92,13 @@ sub overpayment { $query = qq| INSERT INTO acc_trans (trans_id, chart_id, transdate, amount) VALUES (?, (SELECT id FROM chart - WHERE accno = ?), ?, ?)|; + WHERE accno = ?), ?, ?, ?)|; + if (not defined $form->{approved}){ + $form->{approved} = 1; + } $sth = $dbh->prepare($query); - $sth->execute( $uid, $accno, $form->{datepaid}, $fxamount * $ml ) + $sth->execute( $uid, $accno, $form->{datepaid}, $fxamount * $ml, + $form->{approved} ) || $form->dberror($query); # add payment -- cgit v1.2.3