using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.Common; using Wellan.Data; using Wellan.Common; /// /// 計算健保費 /// public class Bhif : LaborAndHealthFee { private double _healthInsuranceFeeRate; private double _healthInsuranceAverageFamily; private double _oldHealthInsuranceFeeRate; public Bhif(DateTime aDate) : base(aDate) { _bftyp = 2; _tableName = "BHIF"; _healthInsuranceFeeRate = 0.0455d; _oldHealthInsuranceFeeRate = 0.0455d; } /// /// 健保費率 /// public double HealthInsuranceFeeRate { get { return _healthInsuranceFeeRate; } set { _healthInsuranceFeeRate = value; } } /// /// 健保平均眷口數 /// public double HealthInsuranceAverageFamily { get { return _healthInsuranceAverageFamily; } set { _healthInsuranceAverageFamily = value; } } public HealthInsuranceFee GetFee(int salary, int family, int family25, int family50, string disabled, bool hasHIF, string employeeType) { // 找出投保薪資 HealthInsuranceFee fee = new HealthInsuranceFee(); fee.Init(); // 不投健保,直接回傳 if (!hasHIF) return fee; // 新費率投保薪資 double bsamt = GetAmont(salary); // 舊費率投保薪資 double oldbsamt = GetAmont(new DateTime(2010, 3, 1) ,salary); fee.InsuranceSalary = (Int32)bsamt; if (bsamt > 0) { // 計算公司保費 // 員工身份是雇主 if (employeeType == "1") fee.CompanyFee = 0; // 員工身份是受雇員工 else fee.CompanyFee = Convert.ToInt32(Math.Round(bsamt * _healthInsuranceFeeRate * 0.6d * (1d + _healthInsuranceAverageFamily), MidpointRounding.AwayFromZero)); // 計算個人保費 double personalFee = 0; double oldPersonalFee = 0; // 員工身份是雇主 if (employeeType == "1") { personalFee = bsamt * _healthInsuranceFeeRate; oldPersonalFee = oldbsamt * _oldHealthInsuranceFeeRate; } // 員工身份是受雇員工 else { personalFee = bsamt * _healthInsuranceFeeRate * 0.3d; oldPersonalFee = oldbsamt * _oldHealthInsuranceFeeRate * 0.3d; } /* 99/4/1 到 101/12/31 實施差額補助 投保金額等級 所得水準 補助比率 40,100元(含)以下 約5萬1千元(含)以下 100% 42,000元至50,600元 約5萬3千元至6萬5千元 20% 53,000元(含)以上 約6萬8千元(含)以上 0% */ if (_baseDate.ToString("yyyyMM", WGuard1.InvariantCulture).CompareTo("201004") >= 0 && _baseDate.ToString("yyyyMM", WGuard1.InvariantCulture).CompareTo("201301") < 0) { // 以月投保薪資計算補助比率 if (bsamt <= 40100) { personalFee = oldPersonalFee; } else if (bsamt > 40100 && bsamt < 53000) { personalFee = personalFee - Convert.ToInt32(Math.Round((personalFee - oldPersonalFee) * 0.2d, MidpointRounding.AwayFromZero)); } } int noDiscountFee = Convert.ToInt32(Math.Round(personalFee, MidpointRounding.AwayFromZero)); int discount25Fee = Convert.ToInt32(Math.Truncate(Math.Round(personalFee, MidpointRounding.AwayFromZero) * 0.75d)); int discount50Fee = Convert.ToInt32(Math.Truncate(Math.Round(personalFee, MidpointRounding.AwayFromZero) * 0.5d)); int remainFamily = 3; switch (disabled) { case "0": // 無 fee.PersonalFee = noDiscountFee; break; case "1": // 輕度 fee.PersonalFee = discount25Fee; break; case "2": // 中度 fee.PersonalFee = discount50Fee; break; case "3": // 重度 fee.PersonalFee = 0; break; } // 加上一般眷口 fee.PersonalFee += noDiscountFee * (family > remainFamily ? (remainFamily > 0 ? remainFamily : 0) : family); remainFamily -= family; // 加上減免25%眷口 fee.PersonalFee += (discount25Fee) * (family25 > remainFamily ? (remainFamily > 0 ? remainFamily : 0) : family25); remainFamily -= family25; // 加上減免50%眷口 fee.PersonalFee += (discount50Fee) * (family50 > remainFamily ? (remainFamily > 0 ? remainFamily : 0) : family50); } return fee; } } public struct HealthInsuranceFee { public int InsuranceSalary; public int PersonalFee; public int CompanyFee; public void Init() { InsuranceSalary = 0; PersonalFee = 0; CompanyFee = 0; } public void Assign(HealthInsuranceFee fee) { InsuranceSalary = fee.InsuranceSalary; PersonalFee = fee.PersonalFee; CompanyFee = fee.CompanyFee; } }