Journal Edition: allow edit reconciliation status for bank related journals.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 3 Feb 2018 09:14:39 +0000 (10:14 +0100)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sat, 3 Feb 2018 17:02:46 +0000 (18:02 +0100)
gl/gl_journal.php
gl/includes/db/gl_db_bank_trans.inc
gl/includes/ui/gl_journal_ui.inc

index 34abbedfabb4175acdf4ee1f7307d4ea2f513f15..e8af7d23dbea6d68e4ce5def5e0484a13c35284c 100644 (file)
@@ -129,7 +129,6 @@ function create_cart($type=0, $trans_no=0)
                }
                $cart->memo_ = get_comments_string($type, $trans_no);
                $cart->reference = $header['reference'];
-
                // update net_amounts from tax register
 
                // retrieve tax details
@@ -328,6 +327,15 @@ if (isset($_POST['Process']))
                $cart->tax_info = false;
        $trans_no = write_journal_entries($cart);
 
+        // retain the reconciled status if desired by user
+        if (isset($_POST['reconciled'])
+            && $_POST['reconciled'] == 1) {
+            $sql = "UPDATE ".TB_PREF."bank_trans SET reconciled=".db_escape($_POST['reconciled_date'])
+                ." WHERE type=" . ST_JOURNAL . " AND trans_no=".db_escape($trans_no);
+
+            db_query($sql, "Can't change reconciliation status");
+        }
+
        $cart->clear_items();
        new_doc_date($_POST['date_']);
        unset($_SESSION['journal_items']);
index a4228f5c434177e4c97e45efe9b54d1b566d1516..5ffa2d0cf0acd52f8f5eabead63a537971f4abe9 100644 (file)
@@ -76,13 +76,13 @@ function get_bank_trans($type, $trans_no=null, $person_type_id=null, $person_id=
                                 LEFT JOIN ".TB_PREF."suppliers supplier ON supplier.supplier_id = st.supplier_id,
                         ".TB_PREF."bank_accounts act
                WHERE act.id=bt.bank_act ";
-       if ($type != null)
+       if (isset($type))
                $sql .= " AND bt.type=".db_escape($type);
-       if ($trans_no != null)
+       if (isset($trans_no))
                $sql .= " AND bt.trans_no = ".db_escape($trans_no);
-       if ($person_type_id != null)
+       if (isset($person_type_id))
                $sql .= " AND bt.person_type_id = ".db_escape($person_type_id);
-       if ($person_id != null)
+       if (isset($person_id))
                $sql .= " AND bt.person_id = ".db_escape($person_id);
        $sql .= " ORDER BY trans_date, bt.id";
 
index 675d8734282788be0a46d54cf339f7e0b522db63..44762f7e753e4c1c902206f2c800a7a0cc36de3c 100644 (file)
@@ -79,6 +79,16 @@ function display_order_header(&$Order)
        }
 
        check_row(_('Include in tax register:'), 'taxable_trans', null, true);
+        // Query the user to retain the reconciled status
+        if (!$new) {
+            $result = get_bank_trans(ST_JOURNAL, $Order->order_id);
+            $row = db_fetch($result);
+            if ($row
+                && $row['reconciled']) {
+                check_row(_('Reconciled:'), 'reconciled', 1, true);
+                hidden('reconciled_date', $row['reconciled']);
+            }
+        }
        end_outer_table(1);
 }