From a5516c489de9179966d0874047bc44ba32c0a765 Mon Sep 17 00:00:00 2001 From: Joe Date: Fri, 15 Mar 2024 12:18:14 +0100 Subject: [PATCH] Bug. Edit Journal -> orphaned attachments. --- gl/includes/db/gl_journal.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/gl/includes/db/gl_journal.inc b/gl/includes/db/gl_journal.inc index 7de137a1..88a8553d 100644 --- a/gl/includes/db/gl_journal.inc +++ b/gl/includes/db/gl_journal.inc @@ -103,6 +103,7 @@ function write_journal_entries(&$cart) $memo_ = $cart->memo_; $trans_type = $cart->trans_type; $new = $cart->order_id == 0; + $old_no = $cart->order_id; begin_transaction(); hook_db_prewrite($cart, ST_JOURNAL); @@ -117,6 +118,18 @@ function write_journal_entries(&$cart) } $trans_id = $cart->order_id = get_next_trans_no($trans_type); + if ($old_no) + { + $aid = 0; + $aid = has_attachment($trans_type, $old_no); + if ($aid != 0) + { + $row = get_attachment($aid); + update_attachment($aid, $row['type_no'], $trans_id, $row['description'], + $row['filename'], $row['unique_name'], $row['filesize'], $row['filetype']); + } + + } $total = $cart->gl_items_total_debit(); $cart->write_gl(); -- 2.30.2