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
------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Ledger-smb-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel

Reply via email to