window.addEvent('domready', function() { calcTax(''); }); var first_split_glob = 85000; var first_pecent = 3; var second_split_glob = 170000; var second_pecent = 5; var third_pecent = 8; var first_stamp_split = 5000; var first_stamp_percent = 0; var second_stamp_split = 170000; var second_stamp_percent = 0.15; var third_stamp_percent = 0.2; function calcTax(A) { if($('price').get('value').replace(",", "")) { var type = $$('input[name=as]:checked').map(function(e) { return e.value; }); var result_single; if(type=="Joint") { var result_joint = calcTransfer($('price').get('value').replace(",", ""),2); var total_joint = result_joint[1]+result_joint[2]+result_joint[3]; } result_single =calcTransfer($('price').get('value').replace(",", ""),1); var total_single = eval(result_single[1]+result_single[2]+result_single[3]); //half it for discount total_single_half = total_single/2; var res res = ""; res = res+""; if(type=="Joint") { if(result_joint[1]) { if(result_joint[2]) val = first_split_glob * 2; else val = $('price').get('value').replace(",", ""); } else val = 0; res = res+""; if(result_joint[2]) { if(result_joint[3]) val = (second_split_glob * 2) - (first_split_glob * 2); else val = $('price').get('value').replace(",", "") - (first_split_glob * 2); } else val = 0; res = res+""; if(result_joint[3]) val = $('price').get('value').replace(",", "") - (second_split_glob* 2); else val = 0; res = res+""; val = parseFloat(total_joint); val = Math.round(val*100)/100; val = val.toFixed(2); res = res+""; val = (val/2).toFixed(2); res = res+""; single = parseFloat(total_single_half); single = Math.round(single*100)/100; single = single.toFixed(2); saving = single - val; saving = Math.round(saving *100)/100; saving = saving .toFixed(2); res = stamp_duty(res,val); res = res+""; } else { if(result_single[1]) { if(result_single[2]) val = first_split_glob; else val = $('price').get('value').replace(",", ""); } else val = 0; res = res+""; if(result_single[2]) { if(result_single[3]) val = second_split_glob - first_split_glob; else val = $('price').get('value').replace(",", "") - first_split_glob; } else val = 0; res = res+""; if(result_single[3]) { val = $('price').get('value').replace(",", "") - second_split_glob; } else val = 0; res = res+""; val = parseFloat(total_single); val = Math.round(val*100)/100; val = val.toFixed(2); res = res+""; val = (val/2).toFixed(2); res = res+""; res = stamp_duty(res,val); } res = res+"
Налоговая ШкалаНалогоблагаемая База%Всего
до €170,000€"+addCommas(val)+"в "+first_pecent+"%€"+addCommas(result_joint[1])+"
от €170,001 - €340,000€"+addCommas(val)+"в "+second_pecent+"%€"+addCommas(result_joint[2])+"
свыше €340,000€"+addCommas(val)+"в "+third_pecent+"%€"+addCommas(result_joint[3])+"
Итого Налог на Перевод Прав Собственности€"+addCommas(val)+"
50% скидка применяется до 31/12/2016€"+addCommas((val))+"
Экономия при покупке на двух владельцев €"+addCommas(saving)+"
до €85,000€"+addCommas(val)+"в "+first_pecent+"%€"+addCommas(result_single[1])+"
от €85,001 - €170,000€"+addCommas(val)+"в "+second_pecent+"%€"+addCommas(result_single[2])+"
свыше €170,000€"+addCommas(val)+"в "+third_pecent+"%€"+addCommas(result_single[3])+"
Итого Налог на Перевод Прав Собственности€"+addCommas(val)+"
50% скидка применяется до 31/12/2016€"+addCommas((val))+"
"; $('tax_display').set('html', res); } else { //$('estimated_payment_display').set('value',''); } } function stamp_duty(res_here,tran_total) { console.log(tran_total); var price = $('price').get('value').replace(",", ""); console.log(price); var result_single = calcStamp(price); var total_stamp = eval(result_single[1]+result_single[2]+result_single[3]); if(result_single[1]) { if(result_single[2]) val = first_stamp_split; else val = $('price').get('value').replace(",", ""); } else val = 0; res_here = res_here+"
"; res_here = res_here+"Государственная Пошлина до €5,000€"+addCommas(val)+"в "+first_stamp_percent+"%€"+addCommas(result_single[1])+""; if(result_single[2]) { if(result_single[3]) val = second_stamp_split - first_stamp_split; else val = $('price').get('value').replace(",", "") - first_stamp_split; } else val = 0; result_single[2] = Math.round(result_single[2]*100)/100; result_single[2] = result_single[2].toFixed(2); res_here = res_here+"Государственная Пошлина от €5,001 - €170,000€"+addCommas(val)+"в "+second_stamp_percent+"%€"+addCommas(result_single[2])+""; if(result_single[3]) { val = $('price').get('value').replace(",", "") - second_stamp_split; } else val = 0; res_here = res_here+"Государственная Пошлина свыше €170,000€"+addCommas(val)+"в "+third_stamp_percent+"%€"+addCommas(result_single[3])+""; total_stamp = Math.round(total_stamp*100)/100; total_stamp = total_stamp.toFixed(2); res_here = res_here+"Итого Государственная Пошлина€"+addCommas(total_stamp)+""; res_here = res_here+"
"; grand_total = parseFloat(total_stamp) + parseFloat(tran_total); grand_total = Math.round(grand_total*100)/100; grand_total = grand_total.toFixed(2); res_here = res_here+"Итого Налогов€"+addCommas(grand_total)+""; return res_here; /* console.log(stamp); var stamp_one = 0; var stamp_two = 0; var price = $('price').get('value').replace(",", ""); //stamp duty if(price<=first_stamp_split) { stamp_one = Math.round((eval(price/100)*first_stamp_percent)*100)/100; //first stamp_one = parseFloat(stamp_one.toFixed(2)); } if(price>first_stamp_split) { price = price - first_stamp_split; stamp_one = Math.round((eval(first_stamp_split/100)*first_stamp_percent)*100)/100; //first stamp_one = parseFloat(stamp_one.toFixed(2)); stamp_two = Math.round((eval(price/100)*second_stamp_percent)*100)/100; //second stamp_two = parseFloat(stamp_two.toFixed(2)); } res_here = res_here+"
"; if(stamp_one) { if(stamp_two) val = first_stamp_split; else if($('price').get('value').replace(",", "")>first_stamp_split) val = first_stamp_split; else val = $('price').get('value').replace(",", ""); } else val = 0; res_here = res_here+"Государственная Пошлина до €170,860€"+addCommas(val)+"в "+first_stamp_percent+"%€"+addCommas(stamp_one)+""; if(stamp_two) { val = $('price').get('value').replace(",", "") - first_stamp_split; } else val = 0; res_here = res_here+"Государственная Пошлина свыше €170,860€"+addCommas(val)+"в "+second_stamp_percent+"%€"+addCommas(stamp_two)+""; if(stamp_two) stamp_total = parseFloat(stamp_one)+parseFloat(stamp_two); else stamp_total = parseFloat(stamp_one); stamp_total = Math.round(stamp_total*100)/100; stamp_total = stamp_total.toFixed(2); res_here = res_here+"Итого Государственная Пошлина€"+addCommas(stamp_total)+""; res_here = res_here+"
"; grand_total = parseFloat(stamp_total) + parseFloat(tran_total); grand_total = Math.round(grand_total*100)/100; grand_total = grand_total.toFixed(2); res_here = res_here+"Итого Налогов€"+addCommas(grand_total)+""; return res_here; */ } function calcStamp(price) { var results=new Array(); var first_split = first_stamp_split; var second_split = second_stamp_split; pricev=parseFloat(price); results[0] = 0; results[1] = 0; results[2] = 0; results[3] = 0; //work out 1st if(pricev<=first_split) { results[1] = Math.round((eval(pricev/100)*first_stamp_percent)*100)/100; //first results[1] = parseFloat(results[1].toFixed(2)); } else if(pricev<=second_split) { pricev = pricev - first_split; results[1] = Math.round((eval(first_split/100)*first_stamp_percent)*100)/100; //first results[1] = parseFloat(results[1].toFixed(2)); results[2] = Math.round((eval(pricev/100)*second_stamp_percent)*100)/100; //second results[2] = parseFloat(results[2].toFixed(2)); } else if(price>second_split) { var second = second_split-first_split; results[1] = Math.round((eval(first_split/100)*first_stamp_percent)*100)/100; //first results[1] = parseFloat(results[1].toFixed(2)); results[2] = Math.round((eval(second/100)*second_stamp_percent)*100)/100; //second results[2] = parseFloat(results[2].toFixed(2)); pricev = pricev - second_split; results[3] = Math.round((eval(pricev/100)*third_stamp_percent)*100)/100; //third results[3] = parseFloat(results[3].toFixed(2)); } return results; } function calcTransfer(price,multiply) { var results=new Array(); var first_split = first_split_glob * multiply; var second_split = second_split_glob * multiply; pricev=parseFloat(price); results[0] = 0; results[1] = 0; results[2] = 0; results[3] = 0; //work out 1st if(pricev<=first_split) { results[1] = Math.round((eval(pricev/100)*first_pecent)*100)/100; //first results[1] = parseFloat(results[1].toFixed(2)); } else if(pricev<=second_split) { pricev = pricev - first_split; results[1] = Math.round((eval(first_split/100)*first_pecent)*100)/100; //first results[1] = parseFloat(results[1].toFixed(2)); results[2] = Math.round((eval(pricev/100)*second_pecent)*100)/100; //second results[2] = parseFloat(results[2].toFixed(2)); } else if(price>second_split) { var second = second_split-first_split; results[1] = Math.round((eval(first_split/100)*first_pecent)*100)/100; //first results[1] = parseFloat(results[1].toFixed(2)); results[2] = Math.round((eval(second/100)*second_pecent)*100)/100; //second results[2] = parseFloat(results[2].toFixed(2)); pricev = pricev - second_split; results[3] = Math.round((eval(pricev/100)*third_pecent)*100)/100; //third results[3] = parseFloat(results[3].toFixed(2)); } return results; } function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; }