//--------------------------------------------------------------------------------
// Stores journal/bank transaction tax details if applicable
//
-function add_gl_tax_details($gl_code, $trans_type, $trans_no, $amount, $ex_rate, $date, $memo, $included=0)
+function add_gl_tax_details($gl_code, $trans_type, $trans_no, $amount, $ex_rate, $date, $memo, $included=0, $net_amount = null)
{
$tax_type = is_tax_account($gl_code);
if(!$tax_type) return; // $gl_code is not tax account
if ($trans_type == ST_SALESINVOICE || $trans_type == ST_CUSTDELIVERY || $trans_type == ST_CUSTCREDIT)
$amount = -$amount;
// we have to restore net amount as we cannot know the base amount
- if ($tax['rate'] == 0) {
-// display_warning(_("You should not post gl transactions
-// to tax account with zero tax rate."));
- $net_amount = 0;
- } else {
- // calculate net amount
- $net_amount = $amount/$tax['rate']*100;
+ if ($net_amount===null) {
+ if ($tax['rate'] == 0) {
+// display_warning(_("You should not post gl transactions
+// to tax account with zero tax rate."));
+ $net_amount = 0;
+ } else {
+ // calculate net amount
+ $net_amount = $amount/$tax['rate']*100;
+ }
}
-
add_trans_tax_details($trans_type, $trans_no, $tax['id'], $tax['rate'], $included,
$amount, $net_amount, $ex_rate, $date, $memo);
hidden('order_price'.$n, $myrow['unit_price'], false).
hidden('std_cost_unit'.$n, $myrow['std_cost_unit'], false).
hidden('po_detail_item'.$n, $myrow['po_detail_item'], false));
+ hidden('location'.$n, $myrow["loc_code"], false).
label_cell(get_trans_view_str(ST_PURCHORDER, $myrow["purch_order_no"]));
label_cell($myrow["item_code"]);
label_cell($myrow["description"]);
}
$total = 0;
foreach ($invoice->line_items as $line_no => $invoice_line) {
-
+ $qty = $invoice_line->qty_dispatched;
$line_taxfree_price = get_tax_free_price_for_item($invoice_line->stock_id,
- $invoice_line->price, 0, $invoice->tax_included,
+ $invoice_line->price * $qty, 0, $invoice->tax_included,
$invoice->tax_group_array);
$line_tax = get_full_price_for_item($invoice_line->stock_id,
- $invoice_line->price, 0, $invoice->tax_included,
+ $invoice_line->price * $qty, 0, $invoice->tax_included,
$invoice->tax_group_array) - $line_taxfree_price;
write_customer_trans_detail_item(ST_SALESINVOICE, $invoice_no, $invoice_line->stock_id,
$invoice_line->item_description, $invoice_line->qty_dispatched,
- $invoice_line->line_price(), $line_tax, $invoice_line->discount_percent,
+ $invoice_line->line_price(), $qty ? $line_tax/$qty : 0, $invoice_line->discount_percent,
$invoice_line->standard_cost, $invoice_line->src_id,
$trans_no ? $invoice_line->id : 0);
$dim2 = ($invoice->dimension2_id != $customer['dimension2_id'] ? $invoice->dimension2_id :
($customer['dimension2_id'] != 0 ? $customer["dimension2_id"] : $stock_gl_code["dimension2_id"]));
$total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_, $sales_account, $dim, $dim2,
- (-$line_taxfree_price * $invoice_line->qty_dispatched),
+ -$line_taxfree_price ,
$invoice->customer_id, "The sales price GL posting could not be inserted");
if ($invoice_line->discount_percent != 0) {
$total += add_gl_trans_customer(ST_SALESINVOICE, $invoice_no, $date_,
$branch_data["sales_discount_account"], $dim, $dim2,
- ($line_taxfree_price * $invoice_line->qty_dispatched * $invoice_line->discount_percent),
+ ($line_taxfree_price * $invoice_line->discount_percent),
$invoice->customer_id, "The sales discount GL posting could not be inserted");
} /*end of if discount !=0 */
}
{
$tax_multiplier += $taxitem["rate"];
}
-
- return round($price / (1 + ($tax_multiplier / 100)), 2*user_price_dec());
+ return round($price / (1 + ($tax_multiplier / 100)), user_price_dec());
}
//
// Full price (incl. VAT) for item $stock_id with line price $price,
$tax_multiplier += $taxitem["rate"];
}
- return round($price * (1 + ($tax_multiplier / 100)), 2*user_price_dec());
+ return round($price * (1 + ($tax_multiplier / 100)), user_price_dec());
}
//---------------------------------------------------------------------------------
$index = $item_tax['tax_type_id'];
if($tax_included==1) {// 2008-11-26 Joe Hunt Taxes are stored without roundings
$nprice = get_tax_free_price_for_item($items[$i], $prices[$i], $tax_group, $tax_included);
- $ret_tax_array[$index]['Value'] += ($nprice * $item_tax['rate'] / 100);
+ $ret_tax_array[$index]['Value'] += $prices[$i]-$nprice;
$ret_tax_array[$index]['Net'] += $nprice;
} else {
$ret_tax_array[$index]['Value'] += ($prices[$i] * $item_tax['rate'] / 100);