summaryrefslogtreecommitdiff
path: root/LedgerSMB/IR.pm
diff options
context:
space:
mode:
Diffstat (limited to 'LedgerSMB/IR.pm')
-rwxr-xr-xLedgerSMB/IR.pm16
1 files changed, 11 insertions, 5 deletions
diff --git a/LedgerSMB/IR.pm b/LedgerSMB/IR.pm
index 9c6839d3..69b20aea 100755
--- a/LedgerSMB/IR.pm
+++ b/LedgerSMB/IR.pm
@@ -40,6 +40,9 @@ use Math::BigFloat;
sub post_invoice {
my ( $self, $myconfig, $form ) = @_;
+ if ($form->{id}){
+ delete_invoice($self, $myconfig, $form);
+ }
my $dbh = $form->{dbh};
$form->{invnumber} = $form->update_defaults( $myconfig, "vinumber", $dbh )
unless $form->{invnumber};
@@ -923,6 +926,7 @@ sub reverse_invoice {
sub delete_invoice {
my ( $self, $myconfig, $form ) = @_;
+
# connect to database
my $dbh = $form->{dbh};
@@ -949,10 +953,6 @@ sub delete_invoice {
&reverse_invoice( $dbh, $form );
- # delete AP record
- $query = qq|DELETE FROM ap WHERE id = ?|;
- my $sth = $dbh->prepare($query);
- $sth->execute( $form->{id} ) || $form->dberror($query);
# delete spool files
$query = qq|
@@ -991,7 +991,13 @@ sub delete_invoice {
if $spoolfile;
}
}
-
+ $query = "DELETE FROM invoice WHERE trans_id = ?";
+ $sth = $dbh->prepare($query);
+ $sth->execute($form->{id});
+ # delete AP record
+ $query = qq|DELETE FROM ap WHERE id = ?|;
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $form->{id} ) || $form->dberror($query);
my $rc = $dbh->commit;
$rc;