10-Oct-2010 Joe Hunt
# Master bug in class supp_trans get_items_total. Minor bug in gl_db_trans.inc
Wrong tax report and wrong supp trans/gl records with gl item lines.
+ Fixing tax_included in gl_items.
$ /purchasing/includes/supp_trans_class.inc
+ /purchasing/includes/db/invoice_db.inc
+ /purchasing/includes/ui/invoice_ui.inc
/gl/includes/db/gl_db_trans.inc
06-Oct-2010 Jusz Dobrowolski
//--------------------------------------------------------------------------------
// Stores journal/bank transaction tax details if applicable
//
-function add_gl_tax_details($gl_code, $trans_type, $trans_no, $amount, $ex_rate, $date, $memo)
+function add_gl_tax_details($gl_code, $trans_type, $trans_no, $amount, $ex_rate, $date, $memo, $included=0)
{
$tax_type = is_tax_account($gl_code);
if(!$tax_type) return; // $gl_code is not tax account
$net_amount = $amount/$tax['rate']*100;
}
- add_trans_tax_details($trans_type, $trans_no, $tax['id'], $tax['rate'], 0,
+ add_trans_tax_details($trans_type, $trans_no, $tax['id'], $tax['rate'], $included,
$amount, $net_amount, $ex_rate, $date, $memo);
}
/*First insert the invoice into the supp_trans table*/
$invoice_id = add_supp_trans($trans_type, $supp_trans->supplier_id, $date_, $supp_trans->due_date,
$supp_trans->reference, $supp_trans->supp_reference,
- $invoice_items_total, $item_added_tax, $supp_trans->ov_discount);
+ $invoice_items_total, $item_added_tax, $supp_trans->ov_discount, "", 0, $supp_trans->tax_included);
$total = 0;
/* Now the control account */
$entered_gl_code->amount = -$entered_gl_code->amount;
add_gl_tax_details($entered_gl_code->gl_code,
$trans_type, $invoice_id, $entered_gl_code->amount,
- $ex_rate, $date_, $supp_trans->supp_reference);
+ $ex_rate, $date_, $supp_trans->supp_reference, $supp_trans->tax_included);
}
foreach ($supp_trans->grn_items as $line_no => $entered_grn)
{
//-------------------------------------------------------------------------------------------------------------
function add_supp_trans($type, $supplier_id, $date_, $due_date, $reference, $supp_reference,
- $amount, $amount_tax, $discount, $err_msg="", $rate=0)
+ $amount, $amount_tax, $discount, $err_msg="", $rate=0, $included=0)
{
$date = date2sql($date_);
if ($due_date == "")
$sql = "INSERT INTO ".TB_PREF."supp_trans (trans_no, type, supplier_id, tran_date, due_date,
- reference, supp_reference, ov_amount, ov_gst, rate, ov_discount) ";
+ reference, supp_reference, ov_amount, ov_gst, rate, ov_discount, tax_included) ";
$sql .= "VALUES (".db_escape($trans_no).", ".db_escape($type)
.", ".db_escape($supplier_id).", '$date', '$due_date',
".db_escape($reference).", ".db_escape($supp_reference).", ".db_escape($amount)
- .", ".db_escape($amount_tax).", ".db_escape($rate).", ".db_escape($discount).")";
+ .", ".db_escape($amount_tax).", ".db_escape($rate).", ".db_escape($discount).", ".db_escape($included).")";
if ($err_msg == "")
$err_msg = "Cannot insert a supplier transaction record";
foreach ($this->gl_codes as $gl_line)
{ //////// 2010-10-10 Joe Hunt
- if (!is_tax_account($gl_line->gl_code))
+ if (!is_tax_account($gl_line->gl_code) || $this->tax_included)
$total += $gl_line->amount;
}
return $total;
foreach ( $supp_trans->gl_codes as $gl_line)
{
////////// 2009-08-18 Joe Hunt
- if (!is_tax_account($gl_line->gl_code))
+ if (!is_tax_account($gl_line->gl_code) || $supp_trans->tax_included)
$supp_trans->ov_amount += $gl_line->amount;
}
}
$th[] = "";
}
table_header($th);
- $total_gl_value=0;
+ $total_gl_value=$total = 0;
$i = $k = 0;
if (count($supp_trans->gl_codes) > 0)
}
end_row();
/////////// 2009-08-18 Joe Hunt
- if ($mode > 1 && !is_tax_account($entered_gl_code->gl_code))
- $total_gl_value += $entered_gl_code->amount;
+ if ($mode > 1) {
+ if ($supp_trans->tax_included || !is_tax_account($entered_gl_code->gl_code))
+ $total_gl_value += $entered_gl_code->amount;
+ }
else
$total_gl_value += $entered_gl_code->amount;
+ $total += $entered_gl_code->amount;
$i++;
if ($i > 15)
{
if ($mode == 1)
display_gl_controls($supp_trans, $k);
$colspan = ($dim == 2 ? 4 : ($dim == 1 ? 3 : 2));
- label_row(_("Total"), price_format($total_gl_value),
+ label_row(_("Total"), price_format($total),
"colspan=".$colspan." align=right", "nowrap align=right", ($mode==1?3:1));
end_table(1);