[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about rolling back invoice repost transactions



Okay, so, it was kind of ugly but we needed to get past this problem, so I ended up inserting a label "ROLLBACK_ALL" at the end of the post_invoice function, and then checking every query in the whole function for success - if anything fails, I simply rollback and exit, instead of failing right there and letting the previous changes stay, as was currently happening.

In order to make this work I had to make new versions of delete_invoice, reverse_invoice, audit_trail, check_exchangerate, save_status, and save_recurring, each with the call to dbh->commit removed  (named them all delete_invoice_no_commit etc.).

I wasn't sure what to do with the following in delete_invoice, so temporarily I just commented it out:
    (after "my $rc = $dbh->commit;")

    if ($rc) {
        foreach $spoolfile (@spoolfiles) {
            unlink "${LedgerSMB::Sysconfig::spool}/$spoolfile"
              if $spoolfile;
        }
    }
Any enlightenment on spoolfiles would be welcome, not sure what's going on there but I don't have $rc if I'm not doing the commit yet, so... ?

Preliminary testing suggests that it works - when there is an SQL fail late in the process, invoice remains as it was last saved.

If anyone is interested, I would be glad to share my modified IS.pm and Form.pm files.

Cheers,
Chris Calef