Bank payment/deposit edit. Attachment will follow the new edit number.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 30 Sep 2011 22:38:34 +0000 (00:38 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Fri, 30 Sep 2011 22:38:34 +0000 (00:38 +0200)
gl/gl_bank.php
gl/includes/db/gl_db_banking.inc

index 67271a2d7138513c6462826b05122efeeb5bb285..97f67ddcb9815f7d123358d9ede77175a8467ded 100644 (file)
@@ -22,6 +22,7 @@ include_once($path_to_root . "/includes/data_checks.inc");
 include_once($path_to_root . "/gl/includes/ui/gl_bank_ui.inc");
 include_once($path_to_root . "/gl/includes/gl_db.inc");
 include_once($path_to_root . "/gl/includes/gl_ui.inc");
+include_once($path_to_root . "/admin/db/attachments_db.inc");
 
 $js = '';
 if ($use_popup_windows)
index 41879225587e638e572495105daed95d58509019..6f08087b45d467fc14ba0bd61a8527af577e7a47 100644 (file)
@@ -306,10 +306,11 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
                'person_type_id', 'person_id', 'person_detail_id', 'ref', 'memo_', 'use_transaction'),
                $args);
        hook_db_prewrite($args, $trans_type);
-
+       $aid = 0;
        if ($trans_no) {
                void_transaction($trans_type, $trans_no, Today(), _("Document reentered."));
                $Refs->restore_last($trans_type, $trans_no);
+               $aid = has_attachment($trans_type, $trans_no);
        }
 
        $currency = get_bank_account_currency($from_account);
@@ -351,7 +352,12 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
        if ($do_exchange_variance)
                $trans_no1 = get_next_trans_no(ST_JOURNAL);
     }
-
+       if ($aid != 0)
+       {
+               $row = get_attachment($aid);
+               update_attachment($aid, $row['type_no'], $trans_no, $row['description'],
+                       $row['filename'], $row['unique_name'], $row['filesize'], $row['filetype']);
+       }
        // do the source account postings
 
     add_bank_trans($trans_type, $trans_no, $from_account, $ref,