Professional Web Applications Themes

Getting an accurate Tax percentage - ASP Database

Hi Guys Wonder if you can help with my problem that seemed simple enough at first, but now appears to be a real pain. Basically I have created a few ASP web pages which have the following form fields on them: Net Amount (standard textbox) Tax Amount (standard textbox) Tax Rate (drop-down field) Total Amount (standard textbox) Allowing the user to populate these fields doesn't prove a problem, my problem is that when I retrieve the data that they have previously posted, I need to work out what rate to show (SELECTED) in the Tax Rate drop-down menu field. This ...

  1. #1

    Default Getting an accurate Tax percentage

    Hi Guys

    Wonder if you can help with my problem that seemed simple enough at first,
    but now appears to be a real pain.

    Basically I have created a few ASP web pages which have the following form
    fields on them:

    Net Amount (standard textbox)
    Tax Amount (standard textbox)
    Tax Rate (drop-down field)
    Total Amount (standard textbox)

    Allowing the user to populate these fields doesn't prove a problem, my
    problem is that when I retrieve the data that they have previously posted, I
    need to work out what rate to show (SELECTED) in the Tax Rate drop-down menu
    field. This is where the math part comes in.

    My plan was to take the Tax Amount divide it by the Net Amount and then
    times the result by 100. As an example, please not the following:

    a) My Tax Rate drop-down menu will have a rate of 17.5.

    b) My Net Amount is 200.00

    c) My Tax Amount is 35.00

    d) 35.00 / 200.00 * 100 = 17.5 <<< bingo I say, however:


    Lets say my Net Amount is 5.00 and my Tax Amount is 0.88 I get 17.6 and if I
    go for a Tax Amount of 0.87 I get 17.4.

    How can I get round this?

    For your ref, I'm using a MySQL DB that has the Net Amount and Tax Amount
    set to a decimal data type with 3 decimal places.

    Can you give me an idea of what calc I can use (ASP friendly would be really
    nice) to get a more accurate output.

    Thanks

    Laphan




    Laphan Guest

  2. #2

    Default Re: Getting an accurate Tax percentage

    My suggestion would be not to do the calculation in the database, but in the
    ASP script. The FormatNumber function can format your output to decimal
    places as needed:

    FormatNumber(TaxAmount/NetAmount * 100, 3)

    --
    Manohar Kamath
    Editor, .netWire
    [url]www.dotnetwire.com[/url]


    "Laphan" <newsDoNotEmailMe.co.uk> wrote in message
    news:4106c7c2_3127.0.0.1...
    > Hi Guys
    >
    > Wonder if you can help with my problem that seemed simple enough at first,
    > but now appears to be a real pain.
    >
    > Basically I have created a few ASP web pages which have the following form
    > fields on them:
    >
    > Net Amount (standard textbox)
    > Tax Amount (standard textbox)
    > Tax Rate (drop-down field)
    > Total Amount (standard textbox)
    >
    > Allowing the user to populate these fields doesn't prove a problem, my
    > problem is that when I retrieve the data that they have previously posted,
    I
    > need to work out what rate to show (SELECTED) in the Tax Rate drop-down
    menu
    > field. This is where the math part comes in.
    >
    > My plan was to take the Tax Amount divide it by the Net Amount and then
    > times the result by 100. As an example, please not the following:
    >
    > a) My Tax Rate drop-down menu will have a rate of 17.5.
    >
    > b) My Net Amount is 200.00
    >
    > c) My Tax Amount is 35.00
    >
    > d) 35.00 / 200.00 * 100 = 17.5 <<< bingo I say, however:
    >
    >
    > Lets say my Net Amount is 5.00 and my Tax Amount is 0.88 I get 17.6 and if
    I
    > go for a Tax Amount of 0.87 I get 17.4.
    >
    > How can I get round this?
    >
    > For your ref, I'm using a MySQL DB that has the Net Amount and Tax Amount
    > set to a decimal data type with 3 decimal places.
    >
    > Can you give me an idea of what calc I can use (ASP friendly would be
    really
    > nice) to get a more accurate output.
    >
    > Thanks
    >
    > Laphan
    >
    >
    >
    >

    Manohar Kamath [MVP] Guest

Similar Threads

  1. Displaying as a percentage
    By AHT Barry in forum Macromedia ColdFusion
    Replies: 5
    Last Post: July 1st, 10:21 PM
  2. CFCharts and Percentage
    By Rafael Klawonn in forum Macromedia ColdFusion
    Replies: 0
    Last Post: February 18th, 10:37 AM
  3. format Boundcolumn as Percentage
    By RobbRoss in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: June 17th, 03:16 PM
  4. preloader percentage
    By moni_80 in forum Macromedia Flash Actionscript
    Replies: 2
    Last Post: February 11th, 12:13 PM
  5. [PHP] How Do I Change A Number to Percentage
    By Van Andel in forum PHP Development
    Replies: 0
    Last Post: July 25th, 05:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139