1

Hi I need some help implementing a simple sales tax calculation to a delivery price estimation form that uses the Jquery Calculation Plugin that I'm sure many have come acros: http://www.pengoworks.com/workshop/jquery/calculation/calculation.plugin.htm

Here's my current test page: http://jsfiddle.net/treigh/afk3C/4/

  $("#FirstHourRate, #HalfHourRate, [rel='eta']").keyup(recalc);

  function recalc() {

  $("#subtotal").calc(
  // the equation to use for the calculation
  "FirstHourRate + (eta-1)*2*HalfHourRate", {
      bind: "keyup",
    eta: $("[rel='eta']").sum(),
      FirstHourRate: $("#FirstHourRate"),
      HalfHourRate: $("#HalfHourRate")
  }, function(s) {
      // return the number as a dollar amount
      return "$" + s.toFixed(2);
  });
}

Currently I can generate a subtotal. but I'd like to also calculate a grandtotal that will essentially be a sum of the subtoal + a 13% tax on the subtotal.

Someone had a similar question here, but my issue is slightly different.

I'd appreciate any Help.

EDIT

With the great help of @Mohammad Adil, I managed to have almost everything to work. So far I can display the subtotal and the grand total, which includes a 13% sales tax. I also need to display the actual tax value after the subtotal as well as fuel charge to help the user distinguish the service charge from the any other surcharges and sales tax. In other words, the form should display a breakdown of the charges before displaying the Grand total. The output should look like this:

Subtotal = $amount(based on "FirstHourRate + (eta-1)*2*HalfHourRate" as seen in the equation)

Fuel = $amount

Sales tax = 0.13(subtotal + fuel) Total = subtotal + fuel + sales tax

I hope it makes some sense.

Community
  • 1
  • 1
TPM
  • 69
  • 8

1 Answers1

0

if you want to calculate the grandtotal (sum of the subtoal + a 13% tax on the subtotal) you can do that with simple math.

Demo Fiddle

Integrated with calculation plugin
grandtotal = subtotal * 1.13 ;
Adil Shaikh
  • 44,509
  • 17
  • 89
  • 111
  • 2 last questions: how can modify the code to also print out the actual tax value, that is 0.13 of the subtotal? And If I need to also display other charges such as Fuel, without including it in the subtotal - I mean, I would have the subtotal, followed by the Fuel, the tax which includes is based the subtotal and the fuel charge and then the grand total which will sum them all up? – TPM Apr 02 '13 at 13:18