X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fincludes%2Fdb%2Fgl_db_banking.inc;h=4a88583a24a73138d080699f128edbbfa5f934ae;hb=50339ff6ffe3cbb2a6237cc6a922a98481c7a41f;hp=6f08087b45d467fc14ba0bd61a8527af577e7a47;hpb=93375884a1256d1db34dc8612e96e3aef43bda10;p=fa-stable.git diff --git a/gl/includes/db/gl_db_banking.inc b/gl/includes/db/gl_db_banking.inc index 6f08087b..4a88583a 100644 --- a/gl/includes/db/gl_db_banking.inc +++ b/gl/includes/db/gl_db_banking.inc @@ -308,7 +308,7 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $ hook_db_prewrite($args, $trans_type); $aid = 0; if ($trans_no) { - void_transaction($trans_type, $trans_no, Today(), _("Document reentered.")); + $old_trans = $trans_no; $Refs->restore_last($trans_type, $trans_no); $aid = has_attachment($trans_type, $trans_no); } @@ -422,6 +422,11 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $ $Refs->save($trans_type, $trans_no, $ref); add_audit_trail($trans_type, $trans_no, $date_); + // old transaction can be voided only after new transaction is entered, + // otherwise the operation could fail for cash accounts due to temporary negative balance + if (@$old_trans) + void_transaction($trans_type, $old_trans, Today(), _("Document reentered.")); + $args->trans_no = $trans_no; hook_db_postwrite($args, $trans_type); if ($use_transaction)