Fixed error creating customer credit note: Undefined index: sales_gl_code. @notrinos.
[fa-stable.git] / gl / gl_journal.php
index e057d0989563d63c01369e20b4a17b4bbf7bca64..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
@@ -140,8 +139,8 @@ function create_cart($type=0, $trans_no=0)
                {
                        $tax_id = $detail['tax_type_id'];
                        $tax_info['net_amount'][$tax_id] = $detail['net_amount']; // we can two records for the same tax_id, but in this case net_amount is the same
-                       $tax_info['tax_date'] = sql2date($detail['effective_date']);
-                       $tax_info['tax_group'] = $detail['tax_group_id'];
+                       $tax_info['tax_date'] = sql2date($detail['tran_date']);
+                       //$tax_info['tax_group'] = $detail['tax_group_id'];
 
                }
                if (isset($tax_info['net_amount']))     // guess exempt sales/purchase if any tax has been found
@@ -316,7 +315,7 @@ if (isset($_POST['Process']))
        {
                // complete tax register data
                $cart->tax_info['tax_date'] = $_POST['tax_date'];
-               $cart->tax_info['tax_group'] = $_POST['tax_group'];
+               //$cart->tax_info['tax_group'] = $_POST['tax_group'];
                $taxes = get_all_tax_types();
                while ($tax = db_fetch($taxes))
                {
@@ -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']);
@@ -467,7 +475,7 @@ if (tab_closed('tabs', 'gl'))
 {
        $cart = &$_SESSION['journal_items'];
        $cart->tax_info['tax_date'] = $_POST['tax_date'];
-       $cart->tax_info['tax_group'] = $_POST['tax_group'];
+       //$cart->tax_info['tax_group'] = $_POST['tax_group'];
        $taxes = get_all_tax_types();
        while ($tax = db_fetch($taxes))
        {
@@ -536,10 +544,12 @@ tabbed_content_start('tabs', array(
 
                case 'tax':
                        update_tax_info();
+                       br();
                        display_heading(_("Tax register record"));
+                       br();
                        start_table(TABLESTYLE2, "width=40%");
                        date_row(_("VAT date:"), 'tax_date', '', "colspan='3'");
-                       tax_groups_list_row(_("Tax group:"), 'tax_group');
+                       //tax_groups_list_row(_("Tax group:"), 'tax_group');
                        end_table(1);
 
                        start_table(TABLESTYLE2, "width=60%");