FA 2.4.1 - If you create a journal entry, attach a document, and then later edit the journal entry (e.g. journal enquiry - edit), the old journal number is voided, and a new journal number created. However, the attachment data is NOT updated, so the document is orphaned, and the journal no longer is associated to the document, so doesn't list it for viewing.
The FIX: (in gl/gl_journal.php)
Line 298:
if (isset($_POST['Process']))
{
$cart = &$_SESSION['journal_items'];
$new = $cart->order_id == 0;
/***************
* Start of fix for orphaned attachments
***************/
$old_trans_type = $cart->trans_type;
$old_trans_no = $cart->order_id;
/***************/
new line 342:
unset($_SESSION['journal_items']);
/*********************************************
* original code does not update attachments.
* The old trans no is zero'd/marked voided and a new trans created
* This leads to an orphaned transaction.
*
* Update attachment info
***********************************************/
if( isset( $old_trans_no ) )
{
$sql = "UPDATE " . TB_PREF . "attachments SET `trans_no` = '" . $trans_no . "' WHERE trans_no = '" . $old_trans_no . "' and type_no = '" . $old_trans_type . "'";
db_query( $sql, "Couldn't update attachments" );
}
/***************/
I have not checked the other functions (i.e. bank payments/deposits, etc) but expect they are similar. I did see void_transaction function then calls different void_XXX_trans functions so didn't chase down the rabbit hole. If they all call the db HOOKs calls this could be made into a module but I didn't chase that neither.