var dt = new Date(); var year; var curr; var orig; var priceIdx; var areain; var denominator; function toThousands(num) { var num = (num || 0).toString(), result = ''; while (num.length > 3) { result = ',' + num.slice(-3) + result; num = num.slice(0, num.length - 3);}; if (num) { result = num + result; } return result;}; function checkdata(){ if ($('select[name="year"]').val()==""||$('select[name="month"]').val()==""){ $('#yearError').text("請選擇前次移轉年期");year=0; }else if(((12*(dt.getFullYear()-parseInt($('select[name="year"]').val())))+(dt.getMonth()+1-parseInt($('select[name="month"]').val())))<0){ $('#yearError').text("前次移轉年期有誤");year=0; }else{ $('#yearError').text("");year=1; }; if ($('input[name="currVal"]').val()==""){ $('#currValError').text("請輸入土地公告現值");curr=0; }else if($('input[name="currVal"]').val()<=0){ $('#currValError').text("土地公告現值有誤");curr=0; }else{ $('#currValError').text("");curr=1; }; if ($('input[name="origVal"]').val()==""){ $('#origValError').text("請輸入原規定地價或前次移轉現值");orig=0; }else if($('input[name="origVal"]').val()<=0){ $('#origValError').text("原規定地價或前次移轉現值有誤");orig=0; }else{ $('#origValError').text("");orig=1; }; if ($('input[name="priceIdx"]').val()==""){ $('#priceIdxError').text("請輸入消費者物價總指數");priceIdx=0; }else if($('input[name="priceIdx"]').val()<=0){ $('#priceIdxError').text("消費者物價總指數有誤");priceIdx=0; }else{ $('#priceIdxError').text("");priceIdx=1; }; if ($('input[name="area"]').val()==""){ $('#areaError').text("請輸入土地宗地面積");areain=0; }else if($('input[name="area"]').val()<=0){ $('#areaError').text("土地宗地面積有誤");areain=0; }else{ $('#areaError').text("");areain=1; }; if ($('input[name="numerator"]').val()==""||$('input[name="denominator"]').val()==""){ $('#denominatorError').text("請輸入移轉或設典範圍");denominator=0; }else if($('input[name="numerator"]').val()<=0||$('input[name="denominator"]').val()<=0||parseInt($('input[name="numerator"]').val())>parseInt($('input[name="denominator"]').val())){ $('#denominatorError').text("移轉或設典範圍有誤");denominator=0; }else{ $('#denominatorError').text("");denominator=1; }; }; function getTax(){ var holdingperiod = (12*(dt.getFullYear()-parseInt($('select[name="year"]').val())))+(dt.getMonth()+1-parseInt($('select[name="month"]').val())); var origval = parseFloat($('input[name="origVal"]').val())*parseFloat($('input[name="priceIdx"]').val())/100; var priceincrease = Math.max(0,parseFloat($('input[name="currVal"]').val())-origval); var selfusebenchmark = parseInt($('input:radio:checked[name="landType"]').val()); var nu = parseInt($('input[name="numerator"]').val());var den = parseInt($('input[name="denominator"]').val()); var area = parseFloat($('input[name="area"]').val())*nu/den; var normalbenchmark = Math.max(0,area-selfusebenchmark); var longtimerate = 1;var taxnormal;var taxselfuse1;var taxselfuse2; checkdata(); if(year==1&&curr==1&&orig==1&&priceIdx==1&&areain==1&&denominator==1){ if (holdingperiod >= 480){longtimerate = 0.6; }else if (holdingperiod >= 360){longtimerate = 0.7; }else if (holdingperiod >= 240){longtimerate = 0.8;}; if (priceincrease < origval){ taxnormal = Math.round(priceincrease*0.2*area); taxselfuse1 = Math.round(priceincrease*0.1*Math.min(area,selfusebenchmark)); taxselfuse2 = Math.round(priceincrease*0.2*normalbenchmark); }else if(priceincrease < origval*2){ taxnormal = Math.round(((priceincrease*(0.2+0.1*longtimerate))-(origval*0.1*longtimerate))*area); taxselfuse1 = Math.round(priceincrease*0.1*Math.min(area,selfusebenchmark)); taxselfuse2 = Math.round(((priceincrease*(0.2+0.1*longtimerate))-(origval*0.1*longtimerate))*normalbenchmark); }else { taxnormal = Math.round(((priceincrease*(0.2+0.2*longtimerate))-(origval*0.3*longtimerate))*area); taxselfuse1 = Math.round(priceincrease*0.1*Math.min(area,selfusebenchmark)); taxselfuse2 = Math.round(((priceincrease*(0.2+0.2*longtimerate))-(origval*0.3*longtimerate))*normalbenchmark); }; if(area<=selfusebenchmark){ $('#generalBaseDiv').css('display','inline'); $('#overBaseDiv').css('display','none'); }else{ $('#generalBaseDiv').css('display','none'); $('#overBaseDiv').css('display','inline'); } $('#beforeYM').text('民國 '+($('select[name="year"]').val()-1911)+' 年 '+$('select[name="month"]').val()+' 月'); $('#holdingperiod').text(Math.floor(holdingperiod/12)+' 年 '+holdingperiod%12+' 月'); $('#taxnormalshow').text("NT$"+toThousands(taxnormal)); $('#taxselfuseshow').text("NT$"+toThousands(taxselfuse1+taxselfuse2)); $('#taxselfuseshow2').text("NT$"+toThousands(taxselfuse1+taxselfuse2)); $('#selfusepart').text("NT$"+toThousands(taxselfuse1)); $('#normalpart').text("NT$"+toThousands(taxselfuse2)); $('.resultDiv-overlay').css('display','inline'); $('#resultDiv').css('display','inline'); }; }; function copyResult(id){ var TextRange = document.createRange(); TextRange.selectNode(document.getElementById(id)); sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(TextRange); document.execCommand("copy"); if(window.getSelection){ if(window.getSelection().empty){ // Chrome window.getSelection().empty(); }else if(window.getSelection().removeAllRanges){ // Firefox window.getSelection().removeAllRanges(); } }else if(document.selection){ // IE? document.selection.empty(); }; $('#allreadyCopy').css('width','110px').css('height','110px'); setTimeout(function(){$('#allreadyCopy').css('width','0px').css('height','0px');},1000); } function closeResult(){ $('.resultDiv-overlay').css('display','none'); $('#resultDiv').css('display','none'); }; function cleanText(){ $('#yearError').text("");$('#currValError').text("");$('#origValError').text("");$('#priceIdxError').text("");$('#areaError').text("");$('#denominatorError').text(""); };