Bank account transfers don't have GL dimensions. Fixed.
authorJoe <joe.hunt.consulting@gmail.com>
Wed, 23 Mar 2022 08:38:04 +0000 (09:38 +0100)
committerJoe <joe.hunt.consulting@gmail.com>
Wed, 23 Mar 2022 08:38:04 +0000 (09:38 +0100)
gl/bank_transfer.php
gl/includes/db/gl_db_banking.inc

index 8d828a51fb47b333e8330d790bdcda1545195fe0..35e7743e3a6b3e0ea7df04e5f33ad95325cadc34 100644 (file)
@@ -86,12 +86,16 @@ function gl_payment_controls($trans_no)
                        $_POST['ToBankAccount'] = $to_trans['bank_act'];
                        $_POST['target_amount'] = price_format($to_trans['amount']);
                        $_POST['amount'] = price_format(-$from_trans['amount']);
+                       $_POST['dimension_id'] = $to_trans['dimension_id'];
+                       $_POST['dimension2_id'] = $to_trans['dimension2_id'];
                } else {
                        $_POST['ref'] = $Refs->get_next(ST_BANKTRANSFER, null, get_post('DatePaid'));
                        $_POST['memo_'] = '';
                        $_POST['FromBankAccount'] = 0;
                        $_POST['ToBankAccount'] = 0;
                        $_POST['amount'] = 0;
+                       $_POST['dimension_id'] = 0;
+                       $_POST['dimension2_id'] = 0;
                }
        }
 
@@ -116,6 +120,12 @@ function gl_payment_controls($trans_no)
 
     ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_BANKTRANSFER, null, get_post('DatePaid')), false, ST_BANKTRANSFER,
        array('date' => get_post('DatePaid')));
+       $dim = get_company_pref('use_dimension');
+       if ($dim > 0)
+               dimensions_list_row(_("Dimension").":", 'dimension_id', 
+                       null, true, ' ', false, 1, false);
+       else
+               hidden('dimension_id', 0);
 
        table_section(2);
 
@@ -133,6 +143,11 @@ function gl_payment_controls($trans_no)
                amount_row(_("Amount:"), 'amount');
                amount_row(_("Bank Charge:"), 'charge');
        }
+       if ($dim > 1)
+               dimensions_list_row(_("Dimension")." 2:", 'dimension2_id', 
+                       null, true, ' ', false, 2, false);
+       else
+               hidden('dimension2_id', 0);
 
     textarea_row(_("Memo:"), 'memo_', null, 40,4);
 
@@ -273,10 +288,12 @@ function bank_transfer_handle_submit()
 {
        $trans_no = array_key_exists('_trans_no', $_POST) ?  $_POST['_trans_no'] : null;
        if ($trans_no) {
-               $trans_no = update_bank_transfer($trans_no, $_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'], input_num('amount'), $_POST['ref'], $_POST['memo_'], input_num('charge'), input_num('target_amount'));
+               $trans_no = update_bank_transfer($trans_no, $_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'],     input_num('amount'), 
+                       $_POST['ref'], $_POST['memo_'], $_POST['dimension_id'], $_POST['dimension2_id'], input_num('charge'), input_num('target_amount'));
        } else {
                new_doc_date($_POST['DatePaid']);
-               $trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'], input_num('amount'), $_POST['ref'], $_POST['memo_'], input_num('charge'), input_num('target_amount'));
+               $trans_no = add_bank_transfer($_POST['FromBankAccount'], $_POST['ToBankAccount'], $_POST['DatePaid'], input_num('amount'), $_POST['ref'], 
+                       $_POST['memo_'], $_POST['dimension_id'], $_POST['dimension2_id'], input_num('charge'), input_num('target_amount'));
        }
 
        meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no");
index 14c7f14feca65cee7b6dd62295bb357df2045c27..157d59d5fb228091c6caad11fb08df9a0ac142d3 100644 (file)
@@ -208,14 +208,14 @@ function add_exchange_variation_all($date, $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,7 +347,7 @@ 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);
@@ -355,7 +355,7 @@ function update_bank_transfer(
        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;