if ($Mode2=='ADD_ITEM2' || $Mode2=='UPDATE_ITEM2')
{
+ if ($_POST['tax'] == 't')
+ {
+ $res = get_all_tax_types_simple();
+ $j = 1;
+ $i = 0;
+ while ($tt = db_fetch($res))
+ {
+ if (check_value('dest_id'.$tt['id']))
+ {
+ $i |= $j;
+ unset($_POST['dest_id'.$tt['id']]);
+ }
+ $j <<= 1;
+ }
+ $_POST['dest_id'] = $i;
+ unset($_POST['tax']);
+ }
if ($selected_id2 != -1)
{
update_quick_entry_line($selected_id2, $selected_id, $_POST['actn'], $_POST['dest_id'], input_num('amount', 0),
if ($act_type == 't')
{
- label_cells($myrow['tax_name'], '');
+ //label_cells($myrow['tax_name'], '');
+ $res = get_all_tax_types_simple();
+ $i = 1;
+ $str = "";
+ $first = true;
+ while ($tt = db_fetch($res))
+ {
+ if ($myrow['dest_id'] & $i)
+ {
+ if (!$first)
+ $str .= ", ";
+ $str .= $tt['name'] . " " . $tt['rate'] . "%";
+ $first = false;
+ }
+ $i <<= 1;
+ }
+ label_cells($str, '');
}
else
{
quick_actions_list_row(_("Posted").":",'actn', null, true);
if (list_updated('actn'))
+ {
$Ajax->activate('edit_line');
+ if (strtolower(substr($_POST['actn'],0,1)) == 't')
+ $_POST['dest_id'] = "";
+ }
$actn = strtolower(substr($_POST['actn'],0,1));
if ($actn == 't')
{
- //item_tax_types_list_row(_("Item Tax Type").":",'dest_id', null);
- tax_types_list_row(_("Tax Type").":", 'dest_id', null);
+ $res = get_all_tax_types_simple();
+ $i = 1;
+ if ($_POST['dest_id'] == '')
+ $_POST['dest_id'] = 1;
+ label_row(" ", "<b>" . _("Tax Types")."</b>");
+ while ($tt = db_fetch($res))
+ {
+ $str = $tt['name'] . " " . $tt['rate'] . "% ";
+ if ($_POST['dest_id'] & $i)
+ $_POST['dest_id'.$tt['id']] = 1;
+ check_row($str, 'dest_id'.$tt['id'], null);
+ $i <<= 1;
+ }
+ //label_cell($str);
+
}
else
{
hidden('dimension2_id', 0);
if ($dim < 1)
hidden('dimension_id', 0);
+ hidden('tax', $actn);
div_end();
hidden('selected_id', $selected_id);
$qe = get_quick_entry($id);
if ($descr != '') $qe['description'] .= ': '.$descr;
$result = get_quick_entry_lines($id);
- $totrate = 0;
- while ($row = db_fetch($result))
- {
- $qe_lines[] = $row;
- switch (strtolower($row['action'])) {
- case "t": // post taxes calculated on base amount
- case "t+": // ditto & increase base amount
- case "t-": // ditto & reduce base amount
- if (substr($qe_line['action'],0,1) != 'T')
- $totrate += get_tax_type_default_rate($row['dest_id']);
- }
- }
- $first = true;
- $taxbase = 0;
- foreach($qe_lines as $qe_line)
+ while ($qe_line = db_fetch($result))
{
switch (strtolower($qe_line['action'])) {
case "=": // post current base amount to GL account
case "t": // post taxes calculated on base amount
case "t+": // ditto & increase base amount
case "t-": // ditto & reduce base amount
- if ($first)
- {
- $taxbase = $base/($totrate+100);
- $first = false;
- }
-
- if (substr($qe_line['action'],0,1) != 'T')
- $part = $taxbase;
- else
- $part = $base;
- $item_tax = get_tax_type($qe_line['dest_id']);
- if ($type == QE_SUPPINV && substr($qe_line['action'],0,1) != 'T')
+ //$taxes = get_taxes_for_item_tax($qe_line['dest_id']);
+ $taxes = array();
+ if ($type == QE_SUPPINV)
{
- $taxgroup = $cart->tax_group_id;
- $rates = 0;
$res = get_tax_group_items($cart->tax_group_id);
while ($row = db_fetch($res))
- $rates += $row['rate'];
- if ($rates == 0)
- continue 2;
- }
- $tax = round2($part * $item_tax['rate'], user_price_dec());
- if ($tax==0) continue 2;
- $gl_code = ($type == QE_DEPOSIT || ($type == QE_JOURNAL && $base < 0))
- ? $item_tax['sales_gl_code'] : $item_tax['purchasing_gl_code'];
- if (!is_tax_gl_unique($gl_code)) {
- display_error(_("Cannot post to GL account used by more than one tax type."));
- break 2;
+ $taxes[] = array('rate'=>$row['rate'], 'sales_gl_code'=>$row['sales_gl_code'],
+ 'purchasing_gl_code'=>$row['purchasing_gl_code']);
}
- if ($type != QE_SUPPINV)
- $cart->add_gl_item($gl_code,
- $qe_line['dimension_id'], $qe_line['dimension2_id'],
- $tax, $qe['description']);
- else
+ else
{
- $acc_name = get_gl_account_name($gl_code);
- $cart->add_gl_codes_to_trans($gl_code,
- $acc_name, $qe_line['dimension_id'],
- $qe_line['dimension2_id'], $tax, $qe['description']);
- }
- if (strpos($qe_line['action'], '+'))
- $base += $tax;
- elseif (strpos($qe_line['action'], '-'))
- $base -= $tax;
- continue 2;
- }
- if ($type != QE_SUPPINV)
- $cart->add_gl_item($qe_line['dest_id'], $qe_line['dimension_id'],
- $qe_line['dimension2_id'], $part, $qe['description']);
- else
- {
- $acc_name = get_gl_account_name($qe_line['dest_id']);
- $cart->add_gl_codes_to_trans($qe_line['dest_id'],
- $acc_name, $qe_line['dimension_id'],
- $qe_line['dimension2_id'], $part, $qe['description']);
- }
- }
-/*
- while ($qe_line = db_fetch($qe_lines))
- {
- switch (strtolower($qe_line['action'])) {
- case "=": // post current base amount to GL account
- $part = $base;
- break;
- case "a": // post amount to GL account and reduce base
- $part = $qe_line['amount'];
- break;
- case "a+": // post amount to GL account and increase base
- $part = $qe_line['amount']; $base += $part;
- break;
- case "a-": // post amount to GL account and reduce base
- $part = $qe_line['amount']; $base -= $part;
- break;
- case "%": // store acc*amount% to GL account
- $part = round2($base * $qe_line['amount'] / 100, user_price_dec());
- break;
- case "%+": // ditto & increase base amount
- $part = round2($base * $qe_line['amount'] / 100, user_price_dec());
- $base += $part;
- break;
- case "%-": // ditto & reduce base amount
- $part = round2($base * $qe_line['amount'] / 100, user_price_dec());
- $base -= $part;
- break;
- case "t": // post taxes calculated on base amount
- case "t+": // ditto & increase base amount
- case "t-": // ditto & reduce base amount
- //$taxes = get_taxes_for_item_tax($qe_line['dest_id']);
- if ($type == QE_SUPPINV)
- $qe_line['dest_id'] = $cart->tax_group_id;
- $taxes = array();
- $res = get_tax_group_items($qe_line['dest_id']);
- while ($row = db_fetch($res))
- $taxes[] = $row;
+ $res = get_all_tax_types_simple();
+ $i = 1;
+ while ($tt = db_fetch($res))
+ {
+ if ($qe_line['dest_id'] & $i)
+ {
+ $row2 = get_tax_type($tt['id']);
+ $taxes[] = array('rate'=>$row2['rate'], 'sales_gl_code'=>$row2['sales_gl_code'],
+ 'purchasing_gl_code'=>$row2['purchasing_gl_code']);
+ }
+ $i <<= 1;
+ }
+ }
$tax_total = 0;
$totrate = 0;
// find total tax
$qe_line['dimension2_id'], $part, $qe['description']);
}
}
-*/
}
return $bank_amount;
}