[0000095] Inbalance double entry on Documents (1 file missing)
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 4 Dec 2008 15:35:07 +0000 (15:35 +0000)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Thu, 4 Dec 2008 15:35:07 +0000 (15:35 +0000)
CHANGELOG.txt
gl/includes/db/gl_db_banking.inc

index c9a1606ab0c8ecd7243c34d19122f1f6dfe87ea3..bb8c90c96e22eea09527d3a7b2e87e0f753299e0 100644 (file)
@@ -30,6 +30,7 @@ $ /admin/create_coy.php
 04-Dec-2008 Joe Hunt
 # [0000095] Inbalance double entry on Documents
 $ /gl/includes/db/gl_db_trans.inc
+  /gl/includes/db/gl_db_banking.inc
   /purchasing/includes/db/invoice_db.inc
   /purchasing/includes/db/supp_payment_db.inc
   /sales/includes/db/payment_db.inc
index a5fe71ad2250ee84ee1d05764b9d153aa925025d..799d37fb22acfea583790455381f8537dafbbcdc 100644 (file)
@@ -13,8 +13,9 @@ function add_bank_transfer($from_account, $to_account, $date_,
 
        $trans_no = get_next_trans_no($trans_type);
 
+       $total = 0;
        // do the source account postings
-    add_gl_trans($trans_type, $trans_no, $date_, $from_account, 0, 0, "",
+    $total += add_gl_trans($trans_type, $trans_no, $date_, $from_account, 0, 0, "",
                -$amount, $currency);
 
     add_bank_trans($trans_type, $trans_no, $from_account, $ref,
@@ -24,7 +25,7 @@ function add_bank_transfer($from_account, $to_account, $date_,
 
        // do the destination account postings
        add_gl_trans($trans_type, $trans_no, $date_, $to_account, 0, 0, "",
-               $amount, $currency);
+               -$total, null);
 
        add_bank_trans($trans_type, $trans_no, $to_account, $ref,
                $date_, $payment_type, $amount,
@@ -92,16 +93,12 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_,
        $trans_no = get_next_trans_no($trans_type);
     }
 
-       // do the source account postings
-    add_gl_trans($trans_type, $trans_no, $date_, $from_account, 0, 0, "",
-       -$total_amount, $currency, $person_type_id, $person_id);
-
     add_bank_trans($trans_type, $trans_no, $from_account, $ref,
        $date_, $type, -$total_amount,
        $person_type_id, $person_id,
        $currency,
        "Cannot insert a source bank transaction");
-
+       $total = 0;
        foreach ($items->gl_items as $gl_item)
        {
                $is_bank_to = is_bank_account($gl_item->code_id);
@@ -113,7 +110,7 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_,
                }
 
        // do the destination account postings
-       add_gl_trans($trans_type, $trans_no, $date_, $gl_item->code_id,
+       $total += add_gl_trans($trans_type, $trans_no, $date_, $gl_item->code_id,
                $gl_item->dimension_id, $gl_item->dimension2_id, $gl_item->reference,
                $gl_item->amount, $currency, $person_type_id, $person_id);
 
@@ -126,6 +123,10 @@ function add_bank_transaction($trans_type, $from_account, $items, $date_,
        }
        }
 
+       // do the source account postings
+    add_gl_trans($trans_type, $trans_no, $date_, $from_account, 0, 0, "",
+       -$total, null, $person_type_id, $person_id);
+
        add_comments($trans_type, $trans_no, $date_, $memo_);
 
        references::save_last($ref, $trans_type);