From: Joe Hunt Date: Thu, 20 Aug 2009 21:15:29 +0000 (+0000) Subject: Rolling back to single tax type based QE X-Git-Tag: 2.3-final~1148 X-Git-Url: https://delta.frontaccounting.com/gitweb/?p=fa-stable.git;a=commitdiff_plain;h=f9a2f83c106a01e0143bec0a022018eb8e40d2a5 Rolling back to single tax type based QE --- diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ed110b35..182dff71 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -24,9 +24,6 @@ $ -> 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/doc/quick_entries.txt b/doc/quick_entries.txt index 64a56d52..90db1293 100644 --- a/doc/quick_entries.txt +++ b/doc/quick_entries.txt @@ -20,8 +20,8 @@ Currently following type of operations are defined: a) Post constant amount to selected GL account. b) Post percent part of base amount to selected GL account -c) Post taxes for selected tax types, using base amount as net value. -d) Post taxes for selected tax types, using base amount as value with tax included. +c) Post taxes for selected tax type, using base amount as net value. +d) Post taxes for selected tax type, using base amount as value with tax included. e) Post remainder from previous calculations to selected GL acount. After most operations the base amount can be increased, decreased or not changed @@ -33,7 +33,8 @@ bill, gazolin or other kind of simple bills. Later on you can create more sophisticated entry lines. If tax should be includes in the base amount you can first select a line -'Tax included, reduce base and select the correct tax types. +'Tax included, reduce base and select the correct tax type. +If more lines with other Tax Types are needed, group them together and use the same action. And a line with 'Remainder' put on the account you want to put the rest on. That's it! diff --git a/gl/manage/gl_quick_entries.php b/gl/manage/gl_quick_entries.php index 048bb767..ed19b7fe 100644 --- a/gl/manage/gl_quick_entries.php +++ b/gl/manage/gl_quick_entries.php @@ -110,23 +110,6 @@ 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), @@ -264,23 +247,7 @@ if ($selected_id != -1) if ($act_type == 't') { - //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, ''); + label_cells($myrow['tax_name'], ''); } else { @@ -329,31 +296,14 @@ 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') { - $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); - + //item_tax_types_list_row(_("Item Tax Type").":",'dest_id', null); + tax_types_list_row(_("Tax Type").":", 'dest_id', null); } else { @@ -376,7 +326,6 @@ 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 2765c6c4..4e50bbf6 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -567,8 +567,22 @@ 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; - while ($qe_line = db_fetch($result)) + 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) { switch (strtolower($qe_line['action'])) { case "=": // post current base amount to GL account @@ -597,30 +611,100 @@ 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 - //$taxes = get_taxes_for_item_tax($qe_line['dest_id']); - $taxes = array(); - if ($type == QE_SUPPINV) + 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') { + $taxgroup = $cart->tax_group_id; + $rates = 0; $res = get_tax_group_items($cart->tax_group_id); while ($row = db_fetch($res)) - $taxes[] = array('rate'=>$row['rate'], 'sales_gl_code'=>$row['sales_gl_code'], - 'purchasing_gl_code'=>$row['purchasing_gl_code']); + $rates += $row['rate']; + if ($rates == 0) + continue 2; } - else + $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; + } + if ($type != QE_SUPPINV) + $cart->add_gl_item($gl_code, + $qe_line['dimension_id'], $qe_line['dimension2_id'], + $tax, $qe['description']); + else { - $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; - } - } + $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; $tax_total = 0; $totrate = 0; // find total tax @@ -669,6 +753,7 @@ function display_quick_entries(&$cart, $id, $base, $type, $descr='') $qe_line['dimension2_id'], $part, $qe['description']); } } +*/ } return $bank_amount; } diff --git a/update.html b/update.html index 608dfe8f..2d822fae 100644 --- a/update.html +++ b/update.html @@ -57,7 +57,8 @@ upgrade ALL your companies.
  • If somet updating from release 2.1.2 to 2.1.3, please go into Bank and General Ledger tab. Enter Account Classes. Change the Class Types to a proper value for all classes.
  • When updating from release 2.1.4 to 2.1.5, please go into Bank and General Ledger tab. Enter Quick Entries.
    The Tax now uses Tax Types instead of Item Tax Types. The reason for changing this is for the complex rules inside the EU.
    Change -to correct Tax Types. .
  • +to correct Tax Type. If you need more Tax Type lines in the same Quick +Entry, please group them together and use the same action type.