Bug 5522, 5523, 5524: Journal Entry Affecting in both sales and purchase and more...
[fa-stable.git] / includes / ui / items_cart.inc
index 9387558966a576980620164e85250fc6d8b4cb2d..f5b1940d317dc9842ad8e36337c4bf3b63a27b5e 100644 (file)
@@ -280,7 +280,7 @@ class items_cart
                        } elseif ($tax_id = is_tax_account($gl->code_id))
                        {
                                $tax_type = get_tax_type($tax_id);
-                               if ($gl->code_id == $tax_type['purchasing_gl_code']) {
+                               if ($gl->code_id == $tax_type['purchasing_gl_code'] && $gl->amount > 0) {
                                        if (!isset($tax_info['tax_in'][$tax_id]))
                                                $tax_info['tax_in'][$tax_id] = 0;
                                        $tax_info['tax_in'][$tax_id] += $gl->amount;
@@ -299,7 +299,7 @@ class items_cart
                                        // we can have both input and output tax postings in some cases like intra-EU trade.
                                        // so just calculate net_amount from the higher in/out tax
                                        $tax_info['net_amount'][$tax_id]
-                                               = $sign*round2(max(abs(@$tax_info['tax_in'][$tax_id]), abs(@$tax_info['tax_out'][$tax_id]))/$tax_type['rate']*100, 2)/$factor;
+                                               = $sign*round2(max(abs(@$tax_info['tax_in'][$tax_id]), abs(@$tax_info['tax_out'][$tax_id]))/$tax_type['rate']*100, user_price_dec())/$factor;
 
                                }
                        } else
@@ -531,7 +531,7 @@ class gl_item
                }
                $this->dimension_id = $dimension_id;
                $this->dimension2_id = $dimension2_id;
-               $this->amount = round($amount, 2);
+               $this->amount = round2($amount, user_price_dec());
                $this->reference = $memo;
                $this->date = $date;
        }