- if ($qe_line['tax_acc'])
- {
- $account = get_gl_account($qe_line['account']);
- $tax_group = $account['tax_code'];
- $items = get_tax_group_items($tax_group);
- while ($item = db_fetch($items))
- $rate += $item['rate'];
- if ($rate != 0)
- $totamount = round2($totamount * 100 / ($rate + 100), user_price_dec());
- //$cart->clear_items();
- if (!$supp_trans)
- $cart->add_gl_item($qe_line['account'], $qe_line['dimension_id'], $qe_line['dimension2_id'],
- $totamount, $qe['description']);
- else
- {
- $acc_name = get_gl_account_name($qe_line['account']);
- $cart->add_gl_codes_to_trans($qe_line['account'], $acc_name, $qe_line['dimension_id'],
- $qe_line['dimension2_id'], $totamount, $qe['description']);
- }
- $items = get_tax_group_items($tax_group);
- while ($item = db_fetch($items))
- {
- if ($item['rate'] != 0)
- {
- $amount = round2($totamount * $item['rate'] / 100, user_price_dec());
- $code = (($amount < 0 || $payment || $supp_trans) ? $item['purchasing_gl_code'] :
- $item['sales_gl_code']);
- if (!$supp_trans)
- $cart->add_gl_item($code, 0, 0, $amount, $qe['description']);
+ 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']);
+ $tax_total = 0;
+ foreach ($taxes as $index => $item_tax) {
+ if(substr($qe_line['action'],0,1) != 'T')
+ $tax = round2($base * $item_tax['rate']
+ / ($item_tax['rate'] + 100), user_price_dec());