RE: need a quick help with an order total module

dreamscape <[email protected]>
Newsgroups gmane.comp.web.oscommerce.devel
Message-ID <9ce822fd13906169a558c3ea9d7e6c44@osCommerce-Forums>
This message was sent from: Development
http://forums.oscommerce.com/viewtopic.php?p=163158#163158
----------------------------------------------------------------

I have got it Ian.

on flat discounts the difference in tax will ALWAYS be the same. just think about it... it doesn't matter the size of the order.  here are 2 examples:

Sub-Total:  $579.00 
Qty Discount:  -$10.00 
UPS Ground:  $7.00 
VA TAX 4.5%:  $25.61 
Total:  $601.61 

Sub-Total:  $217,993.50 
Qty Discount:  -$10.00 
UPS Ground:  $7.00 
VA TAX 4.5%:  $9,809.26 
Total:  $227,799.76 

from one extreme to the other, but the difference in tax each time is exactly the same:
(579 x.045) = 26.055
(569 x .045) = 25.605
difference in tax = .45

(217,993.5 x .045) = 9,809.7075
(217,983.5 x .045) = 9,809.2575
difference in tac = .45

thinking maybe this was just the magic of the number 10, I tried this with other values ($5, $20, and $18.56 just to throw a loop)... it works the same each time.

The difference in tax will always equal the tax rate [b]x[/b] the discount [b]/[/b] 100

so then the calculation for the re-calculation of taxes on flat rate discounts becomes:
[code]	$tod_amount = 0; 
	reset($order->info['tax_groups']); 
	  while (list($key, $value) = each($order->info['tax_groups'])) { 
		$god_amout=0; 
		$tax_rate = tep_get_tax_rate_from_desc($key); 
		$net = $tax_rate * $order->info['tax_groups'][$key]; 
		  if ($net>0) { 
			$ratio1 = ($tax_rate*$od_amount)/100;
			$god_amount = $ratio1; 
			$tod_amount += $god_amount; 
			$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; 
		  } 
	  }            
	}[/code]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.