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

question about rolling back invoice repost transactions



Hello,

I have a question regarding commits and rollbacks, in lsmb and in general.  We are running a modified version of 1.2.18, and are having some serious trouble with SQL errors that come up when reposting invoices.  The errors are no doubt local to our implementation, but the critical problem is that when the repost process fails it does not do any kind of rollback, and ends up deleting the entire invoice!  This has caused much frustration in the accounting department.

I have spent considerable time trying to locate the error, which is related to an integer being left blank and coming in as "" instead of "0" - any advice on general solutions to that problem would also be welcome!  But in the short term and as a good practice in general, it seems reasonable to try to wrap the entire (re)post invoice process in a single database transaction.  I notice that there is one call to $dbh->rollback in IS.pm::post_invoice() where ($invamount->is_nan). I'm unfortunately not an SQL or DBI expert by any means, so I thought I'd ask here before bumbling my way into it.  Should I put an eval{} wrapper around the entire function and then do an if ($@) { dbh->rollback; }?  Or check every step of the way and rollback if it didn't work?  Any enlightenment here would be most appreciated.

Sincerely,

Chris Calef
(Think-Electric)