diff options
-rw-r--r-- | LedgerSMB/AA.pm | 5 | ||||
-rw-r--r-- | LedgerSMB/DBObject/Draft.pm | 27 | ||||
-rw-r--r-- | LedgerSMB/GL.pm | 4 | ||||
-rw-r--r-- | LedgerSMB/IR.pm | 6 |
4 files changed, 33 insertions, 9 deletions
diff --git a/LedgerSMB/AA.pm b/LedgerSMB/AA.pm index 4663971b..d5d8a1fe 100644 --- a/LedgerSMB/AA.pm +++ b/LedgerSMB/AA.pm @@ -371,10 +371,7 @@ sub post_transaction { $query = qq| UPDATE $table 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')); - } + if (!$form->{approved} && $form->{batch_id}){ if ($form->{arap} eq 'ar'){ $batch_class = 'receivable'; } else { diff --git a/LedgerSMB/DBObject/Draft.pm b/LedgerSMB/DBObject/Draft.pm new file mode 100644 index 00000000..2aec59a9 --- /dev/null +++ b/LedgerSMB/DBObject/Draft.pm @@ -0,0 +1,27 @@ +package LedgerSMB::DBObject::Draft; + +use base qw/LedgerSMB::DBObject/; + +sub search { + my ($self) = @_; + @{$self->{draft_results} = $self->exec_method(funcname => 'draft__search'); + return @{$self->{draft_results}; +} + +sub approve { + my ($self) = @_; + if (!$self->{id}){ + $self->error($self->{_locale}->text('No ID Set'); + } + ($self->{approved}) = $self->exec_method(funcname => 'draft_approve'); + return $self->{approved}; +} + +sub delete { + my ($self) = @_; + if (!$self->{id}){ + $self->error($self->{_locale}->text('No ID Set'); + } + ($self->{deleted}) = $self->exec_method(funcname => 'draft_delete'); + return $self->{deleted}; +} diff --git a/LedgerSMB/GL.pm b/LedgerSMB/GL.pm index 2009c037..25b0206d 100644 --- a/LedgerSMB/GL.pm +++ b/LedgerSMB/GL.pm @@ -80,7 +80,7 @@ sub post_transaction { my $id = $dbh->quote( $form->{id} ); if ($form->{separate_duties}){ - $form->approved = '0'; + $form->{approved} = '0'; } if ( $form->{id} ) { @@ -135,7 +135,7 @@ sub post_transaction { my $query = qq| UPDATE gl SET approved = ? WHERE id = ?|; $dbh->prepare($query)->execute($form->{approved}, $form->{id}) || $form->dberror($query); - if (!$form->{approved}){ + if (!$form->{approved} and $form->{batch_id}){ if (not defined $form->{batch_id}){ $form->error($locale->text('Batch ID Missing')); } diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm index e3e6aa2a..d2ade36d 100644 --- a/LedgerSMB/IR.pm +++ b/LedgerSMB/IR.pm @@ -921,16 +921,16 @@ sub reverse_invoice { # delete acc_trans $query = qq|DELETE FROM acc_trans WHERE trans_id = ?|; - $dbh->prepare($query); + $sth = $dbh->prepare($query); $sth->execute( $form->{id} ) || $form->dberror($query); # delete invoice entries $query = qq|DELETE FROM invoice WHERE trans_id = ?|; - $dbh->prepare($query); + $sth = $dbh->prepare($query); $sth->execute( $form->{id} ) || $form->dberror($query); $query = qq|DELETE FROM shipto WHERE trans_id = ?|; - $dbh->prepare($query); + $sth = $dbh->prepare($query); $sth->execute( $form->{id} ) || $form->dberror($query); $dbh->commit; |