[0000714] Bug creating GL trans on inventory items in supplier invoice when tax included.
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 13 Apr 2011 23:19:18 +0000 (01:19 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Wed, 13 Apr 2011 23:19:18 +0000 (01:19 +0200)
purchasing/includes/db/grn_db.inc
purchasing/includes/db/invoice_db.inc

index 1e9f71be23769b860cba371dd26e5ecf891d80bb..09d68ff33a98d77ce26ef0da59203bfc1e9b3895 100644 (file)
@@ -125,7 +125,7 @@ function add_grn(&$po)
                                        $total += add_gl_trans_supplier(ST_SUPPRECEIVE, $grn, $date_, $stock_gl_code["inventory_account"],
                                                $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
                                                $order_line->receive_qty * $order_line->taxfree_charge_price($po), $po->supplier_id);
-                               update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->price,
+                               update_average_material_cost($po->supplier_id, $order_line->stock_id, $order_line->taxfree_charge_price($po),
                                        $order_line->receive_qty, $date_);
                        }               
                        //----------------------------------------------------------------------------------------------------------------
index 411a7a0b194dffa24025be9798791f2de04204de..4f8024a62420a57ee8009b5e8cbeb0d56d047ab1 100644 (file)
@@ -225,13 +225,16 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b
                        //$old_price = $old[0];
                         
                        $old_price = $old[2];
+                       // adjust for tax included.
+                       $old_price = get_tax_free_price_for_item($entered_grn->item_code, $old_price,
+                               $supp_trans->tax_group_id, $entered_grn->tax_included);                 
 
                        /*
                        If statement is removed. Should always check for deliveries nomatter if there has been a price change. 
                        */
-                       //if ($old_price != $entered_grn->chg_price) // price-change, so update
+                       //if ($old_price != $line_taxfree) // price-change, so update
                        //{
-                       //$diff = $entered_grn->chg_price - $old_price;
+                       //$diff = $line_taxfree - $old_price;
                        $old_date = sql2date($old[1]);
                        if (!is_inventory_item($entered_grn->item_code))
                                $total += add_gl_trans_supplier($trans_type, $invoice_id, $date_, $iv_act,
@@ -245,7 +248,7 @@ function add_supp_invoice($supp_trans, $invoice_no=0) // do not receive as ref b
                                        $stock_gl_code['dimension_id'], $stock_gl_code['dimension2_id'],
                                        $entered_grn->this_quantity_inv * $old_price, $supp_trans->supplier_id, "", $ex_rate);
                                $diff = get_diff_in_home_currency($supp_trans->supplier_id, $old_date, $date_, $old_price, 
-                                       $entered_grn->chg_price);       
+                                       $line_taxfree); 
                        
                                // always return due to change in currency.
                                /*$mat_cost = update_average_material_cost(null, $entered_grn->item_code,