最新個人所得稅計算器C#版 源碼2012-2013


由於項目需要計算個稅,自己就根據最新稅法以及稅率表,寫了計算個人所得稅的C#版代碼,貼出來,指高手指正不足之處。

演示地址:http://www.9aicai.com/

代碼如下:

1、TaxInfo.cs

 

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

///   <summary>
/// TaxInfo 個人所得稅詳細信息
/// 版本:1.0
/// 官網: http://www.9aicai.com
/// 名稱:愛財個人所得稅計算器(C#版) 2012-2013
///   </summary>
public  class TaxInfo
{
     public TaxInfo()
    {
         //
        
// TODO: 在此處添加構造函數邏輯
        
//
    }
     ///   <summary>
    
///  工資收入
    
///   </summary>
     public  decimal Income
    {
         set;
         get;
    }
     ///   <summary>
    
///  納稅人員類型,是否外籍人士
    
///   </summary>
     public  bool IsForeign
    {
         set;
         get;
    }
     ///   <summary>
    
///  五險一金
    
///   </summary>
     public  decimal Golds
    {
         set;
         get;
    }
     ///   <summary>
    
///  個人所得稅起征點
    
///   </summary>
     public  decimal StartPoint
    {
         set;
         get;
    }
     ///   <summary>
    
///  應納稅所得額
    
///   </summary>
     public  decimal TaxableIncome
    {
         set;
         get;
    }
     ///   <summary>
    
///  適用稅率
    
///   </summary>
     public  decimal Rate
    {
         set;
         get;
    }
     ///   <summary>
    
///  速算扣除數
    
///   </summary>
     public  decimal Deduct
    {
         set;
         get;
    }
     ///   <summary>
    
///  應納稅額
    
///   </summary>
     public  decimal Tax
    {
         set;
         get;
    }
     ///   <summary>
    
///  稅后收入
    
///   </summary>
     public  decimal IncomeAfterTax
    {
         set;
         get;
    }
}
 

 

2、TaxManager.cs

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

///   <summary>
/// TaxManager 個人所得稅的計算處理
/// 版本:1.0
/// 官網: http://www.9aicai.com
/// 名稱:愛財個人所得稅計算器(C#版) 2012-2013
///   </summary>
public  class TaxManager
{
     public TaxManager()
    {
         //
        
// TODO: 在此處添加構造函數邏輯
        
//
    }
     ///   <summary>
    
///  計算個人所得稅
    
///   </summary>
    
///   <param name="income"> 工資收入 </param>
    
///   <param name="golds"> 五險一金 </param>
    
///   <param name="isForeign"> 是否是外籍人員 </param>
    
///   <returns> 個人所得稅計算結果 </returns>
     public  static TaxInfo Calc( decimal income,  decimal golds,  bool isForeign)
    {
        TaxInfo taxInfo =  new TaxInfo();
        taxInfo.Income = income;
        taxInfo.Golds = golds;
        taxInfo.IsForeign = isForeign;
         // 國內人員與外籍人員的起征點是不一樣的,
        taxInfo.StartPoint = taxInfo.IsForeign ?  4800 :  3500;
        taxInfo.TaxableIncome = taxInfo.Income - taxInfo.Golds - taxInfo.StartPoint;
         decimal rate, deduct;
         // 不需要納稅,應納稅額小於等於0
         if (taxInfo.TaxableIncome <=  0)
        {
            taxInfo.Rate =  0;
            taxInfo.Deduct =  0;
            taxInfo.Tax =  0;
            taxInfo.IncomeAfterTax = taxInfo.Income;
        } // 下面是需要納稅部分
         else
        {
             // 獲取對應的稅率與速算扣除數
            getRateAndDeduct(taxInfo.TaxableIncome,  out rate,  out deduct);
            taxInfo.Rate = rate;
            taxInfo.Deduct = deduct;
            taxInfo.Tax = taxInfo.TaxableIncome * taxInfo.Rate - taxInfo.Deduct;
            taxInfo.IncomeAfterTax = taxInfo.Income - taxInfo.Golds - taxInfo.Tax;
        }
         return taxInfo;
    }


     ///   <summary>
    
///  獲取對應的稅率與速算扣除數,采用最新七級超額累進個人所得稅稅率表
    
///   </summary>
    
///   <param name="taxableIncome"> 應納稅所得額 </param>
    
///   <param name="rate"> 適用稅率 </param>
    
///   <param name="deduct"> 速算扣除數 </param>
     private  static  void getRateAndDeduct( decimal taxableIncome,  out  decimal rate,  out  decimal deduct)
    {
         if (taxableIncome <=  1500)
        {
            rate =  3; deduct =  0;
        }
         else  if (taxableIncome >  1500 && taxableIncome <=  4500)
        {
            rate =  10; deduct =  105;
        }
         else  if (taxableIncome >  4500 && taxableIncome <=  9000)
        {
            rate =  20; deduct =  555;
        }
         else  if (taxableIncome >  9000 && taxableIncome <=  35000)
        {
            rate =  25; deduct =  1005;
        }
         else  if (taxableIncome >  35000 && taxableIncome <=  55000)
        {
            rate =  30; deduct =  2755;
        }
         else  if (taxableIncome >  55000 && taxableIncome <=  80000)
        {
            rate =  35; deduct =  5505;
        }
         else
        {
            rate =  45; deduct =  13505;
        }
    }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM