The Javascript Function to Compute the Stamp Duty Tax


There is always tax and death. If you are buying a house, you will need to pay the stamp duty tax if your property is valued more than 125K pounds (effective after December 2014). It was changed to this progressive rate scheme instead of a fixed rate scheme before Dec 2014.

For everything under 125K, there is no tax. Between 125 to 250 K, there is 2% tax and for 250 to 925K it is 5%. From 925K to 1500K, it is 10% and for anything above 1500K, it is 12%.

The following is a Javascript function that computes the stamp duty tax when the property field is updated (onkeyup etc).

Property Value (in GBP):

 

The full Javascript source code is:

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
// format currency
Number.prototype.money = function(c, d, t){
var n = this, 
    c = isNaN(c = Math.abs(c)) ? 2 : c, 
    d = d == undefined ? "." : d, 
    t = t == undefined ? "," : t, 
    s = n < 0 ? "-" : "", 
    i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", 
    j = (j = i.length) > 3 ? j % 3 : 0;
   return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
 
// https://HelloACM.com
function getprice(x) {
   var r = 0;
   var p, q;
   x = x.replace("," ,"");
   x = x.replace(" " ,"");
   x = parseInt(x);
   var ss = '';
   if (x < 0) {
      return "<B>Please Input Property Value</B>";
   }
   if (x <= 125000) {
      return "<B>Less than 125K, no stamp duty tax.</B>";
   }
   q = x >= 250000 ? 125000 : x - 125000;
   p = q * 0.02;
   r += p;
   ss += "£125,000.01 - £250,000 2% " + q.money(2, '.', ',') + "GBP X 2% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   if (x >= 250000) {
      q = x >= 925000 ? (925000 - 250000) : x - 250000;
      p = q * 0.05;
      r += p;
      ss += "£250,000.01 - £925,000 5% " + q.money(2, '.', ',') + "GBP X 5% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   }
   if (x >= 925000) {
      q = x >= 1500000 ? (1500000 - 925000) : x - 925000;
      p = q * 0.1;
      r += p;
      ss += "£925,000.01 - £1,500,000 10% " + q.money(2, '.', ',') + "GBP X 10% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   }
   if (x > 1500000) {
      q = x - 1500000;
      p = q * 0.12;
      r += p;
      ss += "£1,500,000.01 Above, 12% " + q.money(2, '.', ',') + "GBP X 12% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   }
   ss += "Total: <B>" + r.money(2, '.', ',') + "</B> GBP (Stamp Duty),  (Effective Rate) <B>" + (r/x*100).toFixed(2) + "%</B>";
   return ss;
}
document.getElementById('tax').innerHTML = getprice(document.getElementById("price").value);
// format currency
Number.prototype.money = function(c, d, t){
var n = this, 
    c = isNaN(c = Math.abs(c)) ? 2 : c, 
    d = d == undefined ? "." : d, 
    t = t == undefined ? "," : t, 
    s = n < 0 ? "-" : "", 
    i = parseInt(n = Math.abs(+n || 0).toFixed(c)) + "", 
    j = (j = i.length) > 3 ? j % 3 : 0;
   return s + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};

// https://HelloACM.com
function getprice(x) {
   var r = 0;
   var p, q;
   x = x.replace("," ,"");
   x = x.replace(" " ,"");
   x = parseInt(x);
   var ss = '';
   if (x < 0) {
      return "<B>Please Input Property Value</B>";
   }
   if (x <= 125000) {
      return "<B>Less than 125K, no stamp duty tax.</B>";
   }
   q = x >= 250000 ? 125000 : x - 125000;
   p = q * 0.02;
   r += p;
   ss += "£125,000.01 - £250,000 2% " + q.money(2, '.', ',') + "GBP X 2% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   if (x >= 250000) {
      q = x >= 925000 ? (925000 - 250000) : x - 250000;
      p = q * 0.05;
      r += p;
      ss += "£250,000.01 - £925,000 5% " + q.money(2, '.', ',') + "GBP X 5% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   }
   if (x >= 925000) {
      q = x >= 1500000 ? (1500000 - 925000) : x - 925000;
      p = q * 0.1;
      r += p;
      ss += "£925,000.01 - £1,500,000 10% " + q.money(2, '.', ',') + "GBP X 10% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   }
   if (x > 1500000) {
      q = x - 1500000;
      p = q * 0.12;
      r += p;
      ss += "£1,500,000.01 Above, 12% " + q.money(2, '.', ',') + "GBP X 12% = Tax <B>" + p.money(2, '.', ',') + " GBP</B><BR/>";
   }
   ss += "Total: <B>" + r.money(2, '.', ',') + "</B> GBP (Stamp Duty),  (Effective Rate) <B>" + (r/x*100).toFixed(2) + "%</B>";
   return ss;
}
document.getElementById('tax').innerHTML = getprice(document.getElementById("price").value);

You may also like: 英国房子的印花税

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
561 words
Last Post: C# Example of Using LINQ - 1
Next Post: How to Make a Virtual Drive on Windows Based on a Directory Using SubSt Command ?

The Permanent URL is: The Javascript Function to Compute the Stamp Duty Tax

3 Comments

  1. Jeff
      • Jeff

Leave a Reply