function calculate_tax_deduction($amount, $od_amount, $method, $finalise = false) { global $order; $tax_address = zen_get_tax_locations(); switch ($method) { case 'Standard': if ($amount == 0) { $ratio1 = 0; } else { $ratio1 = zen_round($od_amount / $amount, 2); } $tod_amount = 0; reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $tax_rate = zen_get_tax_rate_from_desc($key, $tax_address['country_id'], $tax_address['zone_id']); $total_net += $tax_rate * $value; } if ($od_amount > $total_net) { $od_amount = $total_net; } reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $tax_rate = zen_get_tax_rate_from_desc($key, $tax_address['country_id'], $tax_address['zone_id']); $net = $tax_rate * $value; if ($net > 0) { $god_amount = $value * $ratio1; $tod_amount += $god_amount; if ($finalise) { $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } } if ($finalise) { $order->info['tax'] -= $tod_amount; } if ($finalise) { $order->info['total'] -= $tod_amount; } break; case 'Credit Note': $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']); $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']); $tod_amount = $this->deduction / (100 + $tax_rate) * $tax_rate; if ($finalise) { $order->info['tax_groups'][$tax_desc] -= $tod_amount; } if ($finalise) { $order->info['tax'] -= $tod_amount; } if ($finalise) { $order->info['total'] -= $tod_amount; } break; default: } return zen_round($tod_amount, 2); }
function process() { global $order, $currencies, $db; $od_amount = $this->calculate_deductions($this->get_order_total()); $this->deduction = $od_amount['total']; if ($od_amount['total'] > 0) { while (list($key, $value) = each($order->info['tax_groups'])) { $tax_rate = zen_get_tax_rate_from_desc($key); if ($od_amount[$key]) { $order->info['tax_groups'][$key] -= $od_amount[$key]; $order->info['total'] -= $od_amount[$key]; } } if ($od_amount['type'] == 'S') { $order->info['shipping_cost'] = 0; } $sql = "select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $_SESSION['cc_id'] . "'"; $zq_coupon_code = $db->Execute($sql); $this->coupon_code = $zq_coupon_code->fields['coupon_code']; $order->info['total'] = $order->info['total'] - $od_amount['total']; $this->output[] = array('title' => $this->title . ': ' . '<a href="javascript:couponpopupWindow(\'' . zen_href_link(FILENAME_POPUP_COUPON_HELP, 'cID=' . $_SESSION['cc_id']) . '\')">' . $this->coupon_code . '</a> :', 'text' => '-' . $currencies->format($od_amount['total']), 'value' => $od_amount['total']); } }
function process() { global $order, $currencies, $gBitDb; if ($od_amount = $this->calculate_deductions($this->get_order_total())) { $this->deduction = $od_amount['total']; if ($od_amount['total'] > 0) { while (list($key, $value) = each($order->info['tax_groups'])) { $tax_rate = zen_get_tax_rate_from_desc($key); if (!empty($od_amount[$key])) { $order->info['tax_groups'][$key] -= $od_amount[$key]; $order->info['total'] -= $od_amount[$key]; } } if (!empty($od_amount['type']) && $od_amount['type'] == 'S') { $order->info['shipping_cost'] = 0; } $sql = "select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $_SESSION['cc_id'] . "'"; $zq_coupon_code = $gBitDb->Execute($sql); $this->coupon_code = $zq_coupon_code->fields['coupon_code']; $order->info['total'] = $order->info['total'] - $od_amount['total']; $this->output[] = array('title' => $this->title . ': ' . $this->coupon_code . ' :', 'text' => '-' . $currencies->format($od_amount['total']), 'value' => $od_amount['total']); } } }
function gross_up($net) { global $order; $gross_up_amt = 0; reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $tax_rate = zen_get_tax_rate_from_desc($key); if ($tax_rate > 0) { $gross_up_amt += round($net * $tax_rate / 100, 2); } } return $gross_up_amt + $net; }