From fc456496ef6d7e082df436e183f841ba93f3fe1d Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Thu, 20 Aug 2009 17:16:31 +0000 Subject: [PATCH] Changed so you can choose all the tax types in Quick Entries you want in a single row --- CHANGELOG.txt | 3 + gl/manage/gl_quick_entries.php | 57 ++++++++++++++- includes/ui/ui_view.inc | 125 ++++++--------------------------- 3 files changed, 77 insertions(+), 108 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 182dff7..ed110b3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -24,6 +24,9 @@ $ -> Affected files $ /gl/includes/gl_db_accounts.inc # If setting the delivered items in PO Receive Items to 0 the value is not updated $ /purchasing/po_receive_items.php +! Changed so you can choose all the tax types in Quick Entries you want in a single row. +$ /gl/manage/gl_quick_entries.php + /includes/ui/ui_view.inc 19-Aug-2009 Joe Hunt ! Change of Quick Entries to use the Tax Types instead, due to complexity using the Tax Groups in EU. diff --git a/gl/manage/gl_quick_entries.php b/gl/manage/gl_quick_entries.php index ed19b7f..048bb76 100644 --- a/gl/manage/gl_quick_entries.php +++ b/gl/manage/gl_quick_entries.php @@ -110,6 +110,23 @@ if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') 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), @@ -247,7 +264,23 @@ if ($selected_id != -1) 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 { @@ -296,14 +329,31 @@ if ($selected_id != -1) 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(" ", "" . _("Tax Types").""); + 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 { @@ -326,6 +376,7 @@ if ($selected_id != -1) hidden('dimension2_id', 0); if ($dim < 1) hidden('dimension_id', 0); + hidden('tax', $actn); div_end(); hidden('selected_id', $selected_id); diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 4e50bbf..2765c6c 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -567,22 +567,8 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='') $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 @@ -611,100 +597,30 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='') 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 @@ -753,7 +669,6 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='') $qe_line['dimension2_id'], $part, $qe['description']); } } -*/ } return $bank_amount; } -- 2.30.2