<?php
class ModelExtensionTotalTax extends Model {
	public function getTotal($total) {
		$promotion = $this->config->get('promotion');

		$extra_value = 0;

		// Yapılan indirim için kdv düzenlemesidir. getTaxes() sadece ürünlerin vergisini getirir. İndirim vergiden de düşülür.
		if(!empty($promotion['discount_percent'])) {
			$taxes = $this->cart->getTaxes();
			$total_tax = 0;
			foreach($taxes as $tax) {
				$total_tax += $tax;
			}
			// $discount_percent = $promotion['discount_percent']/100;
			$discount_percent = 0.1;
			$extra_value = $total_tax*$discount_percent;
		}
		
		foreach ($total['taxes'] as $key => $value) {
			if ($value > 0) {
				$total['totals'][] = array(
					'code'       => 'tax',
					'title'      => $this->tax->getRateName($key),
					'value'      => $value - $extra_value,
					'sort_order' => $this->config->get('tax_sort_order')
				);
				$total['total'] += $value - $extra_value;
				$extra_value = 0;
			}
		}
	}
}