Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-04-2011, 11:00 AM   PM User | #1
mynton
New to the CF scene

 
Join Date: Jan 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
mynton is an unknown quantity at this point
IPT calculation (calculate a percentage of a figure)

Hi,

I am fairly new to this so please bare with me.

I have a php page that uses Javascript (I think) to calculate the percentage Insurance Premium Tax (IPT field) of a total.

I have located where the calculation occurs and can see that it take the total of a predefined amount and divides it by 21 to give me the 5% IPT tax. IPT has risen in the UK today to 6% so I need to know what I need to change the 21 to to give me an accurate IPT calculation.

Here's a snippet of the code. Can anyone help please? Is it 17.65?

PHP Code:
////////////////////////////////////////////
// Motor Bike Calculations
////////////////////////////////////////////
$p 3;
$q 0;
  while (
$p 6){
  
$base_array mysql_fetch_row($result4);
  
// Motor Bikes
  
$risk_code 2;
  
$ap = (+ ($p));

          
$ipt_rate $ipt_main;

  
$monthly_total $pricing_row[$ap];
  
// Calculate IPT
  
$ipt_percentage $monthly_total 21;
  
$monthly_ipt $ipt_percentage;

    
$base_cost $base_array[0] + $dealer_loading;
  
$base_final $base_cost;
  
  
$profit $monthly_total $base_cost $monthly_ipt;
  
        
$monthly_total number_format($monthly_total2'.''');
            
$monthly_ipt number_format($monthly_ipt2'.''');
                
$base_final number_format($base_final2'.''');
                    
$profit number_format($profit2'.''');
                    
  echo 
'
  <tr align="center" bgcolor="#FFDDFF"> 
    <td>'
;
if (
$p == 3)
{
echo (
'');
}
elseif (
$p == 4)
{
echo (
'UK');
}
elseif (
$p == 5)
{
echo (
'UK & European');
}
echo 
'</td>
    <td>
        <input name="'
;
if (
$p == 3)
{
echo (
'comprehensive_plus_'.$risk_code);
}
elseif (
$p == 4)
{
echo (
'comprehensive_'.$risk_code);
}
elseif (
$p == 5)
{
echo (
'driveline_plus_'.$risk_code);
}


echo 
'" type="text" value="'.$pricing_row[$ap].'" size="6" maxlength="6" class="smallinfo">
     </td>
    <td>'
.$monthly_ipt.'</td>
    <td>'
.$base_final.'</td>
    <td>'
.$profit.'</td>
  </tr>'
;
  
$q++;
$p++;


Last edited by mynton; 01-04-2011 at 11:05 AM..
mynton is offline   Reply With Quote
Old 01-04-2011, 10:15 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,567
Thanks: 62
Thanked 4,057 Times in 4,026 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Nope. Not a lick of JavaScript in there. That's 100% PHP code.

But you know, the language in use has nothing to do with this. It's just simple arithmetic.

105 / 21 is indeed 5. Simply because, of course, 105 / 5 is 21.


What you need is to solve for x where 106 / x = 6. And simple algebra says x = 106 / 6 or 17.666666667 (that is 17 and 2/3).

So, you almost had the right answer. Just a shade off. You might want to multiply by 6 and then divide by 106 to get as accurate an answer as possible.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

Last edited by Old Pedant; 01-04-2011 at 10:20 PM..
Old Pedant is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 PM.


Advertisement
Log in to turn off these ads.