tax issue in php

Discussion in 'Programming' started by kabucek, Sep 10, 2008.

  1. #1
    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);
    						}
    Code (markup):

    thanks
     
    kabucek, Sep 10, 2008 IP