Jump to content

tax issue in php


kabucek

Recommended Posts

hello @LL,

 

is this piece of code correct ?

 

$showTotalShippingPrice=number_format($totalShippingPrice,2);
	//calc tax
		if(strtolower($memberDataArray['state'])=='il')
			{
				// Patch by someone
				// Fixes "divide by zero" error.
				if(!isset($discountedProdPrice) || $discountedProdPrice <= 0) {
					$discountedProdPrice = 1;
				}
				if(!isset($totalProdPrice) || $totalProdPrice <= 0) {
					$totalProdPrice = 1;
				}
				$discountFraction=$discountedProdPrice/$totalProdPrice;

				$taxExclusionDiscountTotal=$taxExclusionRetailTotal;

				$taxableAmount=$discountedProdPrice-$taxExclusionDiscountTotal;

				$taxableAmount=number_format($taxableAmount,2);

				$taxRate=.085;
				$taxRate=.09;
				$tmp=$taxRate*100;
				$showTaxRate=number_Format($tmp, 2)."%";
				$totalTax=number_format(($taxableAmount)*$taxRate, 2);

				$totalTax=max(0,$totalTax); //with discounts, total tax can go negative

				$showTotalTax=$totalTax;

				if ($taxExclusionDiscountTotal>0)
					{
						$taxExclusionNotificationString="
							 - <SPAN style=color:green><SPAN style=font-size:120%>+</SPAN> $dollarSign$taxExclusionDiscountTotal non-taxable</SPAN>, $dollarSign$taxableAmount taxable at $showTaxRate
							";
						}
					else
						{
							$taxExclusionNotificationString="
								 - $showTaxRate
								";
							}
				if ($nonTaxableItemFound=='true')
					{
						$promotionMsg.="
							<DIV class=processMsgSuccess>'+' (plus sign) signifies non-taxable item</DIV>
							";
						}
				}
			else
				{
					$totalTax=0;
					$showTotalTax=number_format($totalTax, 2);
					}

 

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/123628-tax-issue-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.