Fixed cust_trans update on bank trans change.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 21 Oct 2010 14:38:04 +0000 (14:38 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Thu, 21 Oct 2010 14:38:04 +0000 (14:38 +0000)
gl/gl_bank.php
gl/includes/db/gl_db_banking.inc

index 0b973784df34839aa13df3f6e6d5f689a3fe0570..5ed202e7c2c43814556ce38e039e3ec051300633 100644 (file)
@@ -249,6 +249,16 @@ if (isset($_POST['Process']))
                $input_error = 1;
        }
 
+       if (get_post('PayType')==PT_CUSTOMER && (!get_post('person_id') || !get_post('PersonDetailID'))) {
+               display_error(_("You have to select customer and customer branch."));
+               set_focus('person_id');
+               $input_error = 1;
+       } elseif (get_post('PayType')==PT_SUPPLIER && (!get_post('person_id'))) {
+               display_error(_("You have to select supplier."));
+               set_focus('person_id');
+               $input_error = 1;
+       }
+
        if ($input_error == 1)
                unset($_POST['Process']);
 }
index c6534fd6ae44413bc991dc948cf54aea424f2d7e..721bff1eb34abed556cccd099448713be56fbb8e 100644 (file)
@@ -185,7 +185,7 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
                begin_transaction();
 
        if ($trans_no)
-               clear_bank_transaction($_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id, true);
+               clear_bank_transaction($_SESSION['pay_items']->trans_type, $_SESSION['pay_items']->order_id);
 
        $currency = get_bank_account_currency($from_account);
        $bank_gl_account = get_bank_gl_account($from_account);
@@ -216,7 +216,7 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
                $supp_amount = -$supp_amount;
 
                $trans_no = write_supp_trans($trans_type, $trans_no, $person_id, $date_, '',
-               $ref, "", $supp_amount, 0, 0);
+                       $ref, "", $supp_amount, 0, 0);
 
     }
     else
@@ -299,12 +299,8 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
 }
 //----------------------------------------------------------------------------------------
 
-function clear_bank_transaction($type, $type_no, $nested=false)
+function clear_bank_transaction($type, $type_no)
 {
-       global $Refs;
-       
-       if (!$nested)
-               begin_transaction();
 
        $sql = "DELETE FROM ".TB_PREF."bank_trans 
                WHERE type=".db_escape($type)." AND trans_no=".db_escape($type_no);
@@ -315,7 +311,6 @@ function clear_bank_transaction($type, $type_no, $nested=false)
 
        // in case it's a customer trans - probably better to check first
        void_cust_allocations($type, $type_no);
-       clear_customer_trans($type, $type_no);
 
        // in case it's a supplier trans - probably better to check first
        void_supp_allocations($type, $type_no);
@@ -324,8 +319,6 @@ function clear_bank_transaction($type, $type_no, $nested=false)
        clear_trans_tax_details($type, $type_no);
 
        delete_comments($type, $type_no);
-       if (!$nested)
-               commit_transaction();
 }
 
 ?>
\ No newline at end of file