Page 1 of 1

tax issue in php

Posted: Wed Sep 10, 2008 10:07 am
by kabucek
hello @LL,

is this piece of code correct ?

Code: Select all

$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

Re: tax issue in php

Posted: Wed Sep 10, 2008 10:18 am
by onion2k
Run it and find out? Test it? We can't tell you if it's correct because we don't know what 'correct' would be.

Have to say though..

Code: Select all

$taxRate=.085;
$taxRate=.09;
Having those two lines next to each other probably isn't right. The second just overwrites the value set in the first, making the first line redundant.

Re: tax issue in php

Posted: Wed Sep 10, 2008 10:30 am
by kabucek
it suppose to charge tax in our form but it doesn't display tax fee after someone is trying to submit
payment


thanks

Re: tax issue in php

Posted: Wed Sep 10, 2008 10:52 am
by onion2k
Why do you think it should display something? There's no display code anywhere in it.

Re: tax issue in php

Posted: Wed Sep 10, 2008 11:12 am
by kabucek
this is just a "piece"