cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="welcome-tax-calculator">
  <label class="value">
    Valeur du bien* / Property Value*
    <input type="number" id="value" />
  </label>

  <p class="result-line">
    Total fees:
    <span id="fees" class="fees">0</span>
    $CAD
  </p>
</div>
<div class="sources">
<blockquote class="tax-source">
<p>*La base d'imposition correspond au montant le plus élevé parmi les trois montants suivants :</p>
<ul>
<li>Le montant réellement payé pour le transfert de l'immeuble (n'incluant pas la TPS et la TVQ)</li>
<li>Le montant de la contrepartie stipulé pour le transfert de l'immeuble (généralement, il s'agit du montant inscrit dans l'acte de vente)</li>
<li>Le montant de la valeur marchande au moment du transfert de l'immeuble (valeur inscrite au rôle d'évaluation multipliée par le facteur comparatif de l'exercice correspondant à la date de transfert).</li>
</ul>
</blockquote>

<blockquote class="tax-source">
<p>*The basis of imposition corresponds to the greater of the following three amounts:</p>

<ul>
<li>The amount that was actually paid for the transfer of the immovable (not including the GST and the QST)</li>
<li>The amount of the consideration stipulated for the transfer of the immovable (generally the amount shown on the deed of sale)</li>
<li>The amount of the market value at the time of the transfer of the immovable (value entered on the property assessment roll multiplied by the comparative factor of the transfer's fiscal year).</li>
</ul>
</div>
            
          
!
            
              body {
  font-family: sans-serif;
}
.welcome-tax-calculator {
  border: 1px solid #eee;
  padding: 20px;
  margin: 15px 0;
  width: 50%;
  float: left;
  text-align: center;
  box-sizing: border-box;
}
.value {
  font-weight: bold;
}
.value input {
  display: block;
  width: 200px;
  padding: 10px;
  font-size: 18px;
  margin: 10px auto;
}
.result-line {
  font-weight: bold;
}
.fees {
  font-weight: bolder;
  color: #cb2027;
  font-size: 20px;
}
.sources {
  float: right;
  width: 50%;
}
.tax-source {
  background-color: #fafafa;
  border-left: 5px solid #f48fb1;
  padding: 10px 20px;
  font-style: italic;
}
            
          
!
            
              /*
Droits sur les mutations immobilières (Montréal)
French: http://ville.montreal.qc.ca/portal/page?_pageid=43,60524&_dad=portal&_schema=PORTAL

Duties on transfers of immovables (Montreal)
English: http://ville.montreal.qc.ca/portal/page?_pageid=44,80257&_dad=portal&_schema=PORTAL

Updated: Nov 2017
*/

var input = document.getElementById( 'value' );
var fees = document.getElementById( 'fees' );

function welcometax( value ) {
	var inrange;
	var result = 0;
  var remaining = value;
	var parts = new Array();
	parts.push([50000, 0.005]);
	parts.push([250000, 0.01]);
	parts.push([500000, 0.015]);
	parts.push([1000000, 0.02]);

	for ( var i = 0; i < 4; i++ ) {
		if ( value >= parts[i][0] ) {
      var prev = ( i >= 1 ) ? i - 1 : false;
      var prevRange = ( i >= 1 ) ? parts[prev][0] : 0;
			inrange = parts[i][0] - prevRange;
			result += inrange * parts[i][1];
      remaining = remaining - inrange;
		} else if ( value < parts[i][0] ) {
			result += remaining * parts[i][1];
      remaining = 0;
			break;
		}
	}
  
	if ( remaining > 0 ) {
		result += remaining * 0.025;
	}

	return Math.round( result, 2 );
}

input.addEventListener('input', function() {
  var result = welcometax( input.value );
  fees.innerHTML = result;
});
            
          
!
999px
Loading ..................

Console