Show also Upcoming Purchase Invoices - in Dashboard. Fixed.
[fa-stable.git] / gl / includes / db / gl_db_banking.inc
index c1a5e16d23a193e3d3ce3c67a4177fa7d94a08a1..157d59d5fb228091c6caad11fb08df9a0ac142d3 100644 (file)
@@ -143,7 +143,7 @@ function get_account_home_balance($person_id, $person_type, $rec_account, $to_da
 // Note: in 2.4.9 sparse 'ref' argument was removed (generated transactions use
 // next references from default refline).
 //
-function add_exchange_variation_all($date=null, $memo)
+function add_exchange_variation_all($date, $memo)
 {
        begin_transaction();
        $exchanged = false;
@@ -208,14 +208,14 @@ function add_exchange_variation_all($date=null, $memo)
 //     
 
 function add_bank_transfer($from_account, $to_account, $date_,
-       $amount, $ref, $memo_, $charge=0, $target_amount=0)
+       $amount, $ref, $memo_, $dim1, $dim2, $charge=0, $target_amount=0)
 {
        global $Refs, $SysPrefs;
 
        begin_transaction();
        $args = func_get_args(); if (count($args) < 8) $args[] = 0;
-       $args = (object)array_combine(array('from_account', 'to_account', 'date_', 'amount',
-               'ref', 'memo_', 'charge', 'target_amount'), $args);
+       $args = (object)array_combine(array('from_account', 'to_account', 'date_', 'amount',  
+               'ref', 'memo_', 'dimension_id', 'dimension2_id', 'charge', 'target_amount'), $args);
        $args->trans_no = 0;
        hook_db_prewrite($args, ST_BANKTRANSFER);
 
@@ -234,7 +234,7 @@ function add_bank_transfer($from_account, $to_account, $date_,
        
        $total = 0;
        // do the source account postings
-    $total += add_gl_trans($trans_type, $trans_no, $date_, $from_gl_account, 0, 0, $person_id,
+    $total += add_gl_trans($trans_type, $trans_no, $date_, $from_gl_account, $dim1, $dim2, $person_id,
                -($amount + $charge), $currency);
 
     add_bank_trans($trans_type, $trans_no, $from_account, $ref,
@@ -252,7 +252,7 @@ function add_bank_transfer($from_account, $to_account, $date_,
                /* Now Debit bank charge account with charges */
                $charge_act = get_bank_charge_account($from_account);
                $total += add_gl_trans($trans_type, $trans_no, $date_,
-                       $charge_act, 0, 0, $person_id, $charge, $currency);
+                       $charge_act, $dim1, $dim2, $person_id, $charge, $currency);
        }
 
        // provide backward compatibility for extension modules (target amount can be not passed)
@@ -260,7 +260,7 @@ function add_bank_transfer($from_account, $to_account, $date_,
        $to_amount = $target_amount ? $target_amount : $amount;
 
        // do the destination account postings
-       $total += add_gl_trans($trans_type, $trans_no, $date_, $to_gl_account, 0, 0, $person_id,
+       $total += add_gl_trans($trans_type, $trans_no, $date_, $to_gl_account, $dim1, $dim2, $person_id,
                $to_amount, $to_currency);
                
        /*Post a balance post if $total != 0 */
@@ -268,7 +268,7 @@ function add_bank_transfer($from_account, $to_account, $date_,
                add_gl_balance($trans_type, $trans_no, $date_, -$total);
        else    // in this case those are exchange variances between bank and home rates
                add_gl_trans($trans_type, $trans_no, $date_, get_company_pref('exchange_diff_act'),
-                       0, 0, _("Exchange Variance"), -$total);
+                       $dim1, $dim2, _("Exchange Variance"), -$total);
        
        add_bank_trans($trans_type, $trans_no, $to_account, $ref,
                $date_, $to_amount, PT_MISC, $person_id,
@@ -347,15 +347,15 @@ function check_bank_transfer($trans_no, $from_account, $to_account, $date_,
 
 function update_bank_transfer(
        $trans_no, $from_account, $to_account, $date_,
-       $amount, $ref, $memo_, $charge=0, $target_amount=0)
+       $amount, $ref, $memo_, $dim1, $dim2, $charge=0, $target_amount=0)
 {
        begin_transaction();
        delete_comments(ST_BANKTRANSFER, $trans_no);
-       void_transaction(ST_BANKTRANSFER, $trans_no, Today(), _("Document reentered."));
+       void_transaction(ST_BANKTRANSFER, $trans_no, $date_, _("Document reentered."));
        void_gl_trans(ST_BANKTRANSFER, $trans_no, true);
        $new_trans_no = add_bank_transfer(
                $from_account, $to_account, $date_, $amount,
-               $ref, $memo_, $charge, $target_amount
+               $ref, $memo_, $dim1, $dim2, $charge, $target_amount
        );
        commit_transaction();
        return $new_trans_no;
@@ -518,7 +518,7 @@ function write_bank_transaction($trans_type, $trans_no, $from_account, $items, $
        //  otherwise the operation could fail for cash accounts due to temporary negative balance
        if ($old_trans) 
        {
-               $msg = void_transaction($trans_type, $old_trans, Today(), _("Document reentered."));
+               $msg = void_transaction($trans_type, $old_trans, $date_, _("Document reentered."));
                if ($msg)
                {
                        display_error($msg);