public static Double GetCountLeaveRecord(Ins_InsuranceRecord record) { Double leaveInMonth = record.DayCount; if (record.Status == InsuranceRecordType.E_PREGNANCY_SUCKLE.ToString()) { DateTime dateEnd = record.DateEnd != null ? record.DateEnd.Value : record.RecordDate; DateTime dateStart = record.DateStart != null ? record.DateStart.Value : record.RecordDate; DateTime dateValue = new DateTime(2013, 05, 01); if (dateStart >= dateValue) { //Truong hop thai san neu nho hon 150 ngay lam tron thanh 4 thang 120 ngay if (leaveInMonth <= 190) leaveInMonth = 180; else leaveInMonth = 210; } else { //Truong hop thai san neu nho hon 150 ngay lam tron thanh 4 thang 120 ngay if (leaveInMonth < 150) leaveInMonth = 120; else leaveInMonth = 150; } } return leaveInMonth; }
private System.Data.DataTable FillRow(Hre_Profile Profile, Ins_InsuranceRecord record , System.Data.DataTable tblData, DateTime _from, DateTime _to, DateTime monthYear , List<Sal_BasicSalary> listBasicSalary, List<Ins_InsuranceRecord> list_Year, List<Cat_ExchangeRate> lstRateInsurance , string status, List<Cat_DayOff> lstDayOff, List<Guid> PositionIsWorkingHard, String GroupName, List<Cat_OrgStructure> lstOrgAll, List<Sys_AllSetting> lstAppConfig) { //List<Sys_AllSetting> lstAppConfig = EntityService.GetAllEntities<Sys_AllSetting>(EntityService.GuidMainContext, LoginUserID.Value); if (record.DayCount <= 0) return tblData; Guid proID = Profile.ID; //HRService hrser = new HRService(); DataRow row = tblData.NewRow(); row = fillRowBasic(row, monthYear, Profile, record, list_Year.Where(m => m.ProfileID == Profile.ID).ToList(), lstDayOff); DateTime _monthJoin = InsuranceServices.GetMonthJoinInsurance(Profile, monthYear); #region loai SICK if (status == InsuranceRecordType.E_SICK_SHORT.ToString() || status == InsuranceRecordType.E_SICK_LONG.ToString() || status == InsuranceRecordType.E_SICK_CHILD.ToString()) { //Tính cột thời gian đóng bảo hiểm xã hội if (record.DateStart != null) { DateTime dateStartInsurance = new DateTime(record.DateStart.Value.AddMonths(-1).Year, record.DateStart.Value.AddMonths(-1).Month, InsuranceServices.PeriodInsuranceDayCurrentMonthDefault); int month = 0; if (Profile.UnEmpInsCountMonthOld != null) { month = Profile.UnEmpInsCountMonthOld ?? 0; } for (DateTime dateCheck = _monthJoin; dateCheck <= dateStartInsurance; dateCheck = dateCheck.AddMonths(1)) { month++; } int year = month / 12; month = month % 12; string yearTemp = year.ToString(); yearTemp = yearTemp.Length == 1 ? "0" + yearTemp : yearTemp; string monthTemp = month.ToString(); monthTemp = monthTemp.Length == 1 ? "0" + monthTemp : monthTemp; row[Ins_C70aReportEntity.FieldNames.BeginSocialInsIssueDate] = yearTemp + "-" + monthTemp; } //Tình trạng của nhân viên //Logic Tất cả các chức danh trừ nhân viên thì là tình trang "Điều kiện NN-ĐH"còn nhân viên thì là "Điều Kiện BT" if (status == InsuranceRecordType.E_SICK_CHILD.ToString()) // Nếu loại con óm thì không cần ghi { row[Ins_C70aReportEntity.FieldNames.Notes] = string.Empty; row[Ins_C70aReportEntity.FieldNames.Notes1] = record.DateSuckle != null ? string.Format("{0:dd/MM/yyyy}", record.DateSuckle.Value) : string.Empty; } else { if (PositionIsWorkingHard.Contains(Profile.PositionID ?? Guid.Empty)) { row[Ins_C70aReportEntity.FieldNames.Notes] = "Điều kiện NN-ĐH"; } else { row[Ins_C70aReportEntity.FieldNames.Notes] = "Điều Kiện BT"; } } } #endregion #region loai Kham thai if (status == InsuranceRecordType.E_PREGNANCY_EXAMINE.ToString() || status == InsuranceRecordType.E_PREGNANCY_LOST.ToString() || status == InsuranceRecordType.E_PREGNANCY_SUCKLE.ToString() || status == InsuranceRecordType.E_PREGNANCY_PREVENTION.ToString()) { //Tính cột thời gian đóng bảo hiểm xã hội if (record.DateStart != null) { DateTime dateStartInsurance = new DateTime(record.DateStart.Value.AddMonths(-1).Year, record.DateStart.Value.AddMonths(-1).Month, InsuranceServices.PeriodInsuranceDayCurrentMonthDefault); int month = 0; for (DateTime dateCheck = _monthJoin; dateCheck <= dateStartInsurance; dateCheck = dateCheck.AddMonths(1)) { month++; } month = month > 12 ? 12 : month; string monthTemp = month.ToString(); monthTemp = monthTemp.Length == 1 ? "0" + monthTemp : monthTemp; row[Ins_C70aReportEntity.FieldNames.BeginSocialInsIssueDate] = "0" + "-" + monthTemp; if (status == InsuranceRecordType.E_PREGNANCY_LOST.ToString()) { row[Ins_C70aReportEntity.FieldNames.Notes] = record.Comment; } if (status == InsuranceRecordType.E_PREGNANCY_SUCKLE.ToString()) { //row["Notes"] = LanguageManager.GetString(record.TypeSuckle); row[Ins_C70aReportEntity.FieldNames.Notes] = record.TypeSuckle; row[Ins_C70aReportEntity.FieldNames.Notes1] = record.DateSuckle != null ? string.Format("{0:dd/MM/yyyy}", record.DateSuckle.Value) : string.Empty; } } } #endregion #region loai Duong Suc if (status == InsuranceRecordType.E_RESTORATION_SICK.ToString() || status == InsuranceRecordType.E_RESTORATION_TNLD.ToString() || status == InsuranceRecordType.E_RESTORATION_PREGNANCY.ToString()) { //Tính cột thời gian đóng bảo hiểm xã hội //row["Notes"] = LanguageManager.GetString(record.TypeSuckle); row[Ins_C70aReportEntity.FieldNames.Notes] = record.TypeSuckle; row[Ins_C70aReportEntity.FieldNames.Notes1] = record.DateStartWorking != null ? string.Format("{0:dd/MM/yyyy}", record.DateStartWorking.Value) : string.Empty; } #endregion Double salaryIns = 0; Double moneyIns = 0; InsuranceServices.GetMoneyInsSalaryIns(record, ListMaxSalary, ListMinSalary, _monthJoin, listBasicSalary, lstRateInsurance, lstAppConfig, out moneyIns, out salaryIns, false); //Tien BHXH tra // Double roundMoney = Common.GetRoundMoney(moneyIns, 2); //totalMoney += roundMoney; row[Ins_C70aReportEntity.FieldNames.Money] = moneyIns; totalMoney += moneyIns; totalMoneyNotRound += moneyIns; // row["MoneyNotRound"] = moneyIns; //Luong tham gia BHXH totalSalaryInsurance += salaryIns; row[Ins_C70aReportEntity.FieldNames.SalaryInsurance] = salaryIns; if (status == InsuranceRecordType.E_LEAVE_AT_SAME_PLACE.ToString() || status == InsuranceRecordType.E_LEAVE_AT_HOME.ToString() || status == InsuranceRecordType.E_RESTORATION_TNLD.ToString() || status == InsuranceRecordType.E_RESTORATION_PREGNANCY.ToString())//Nếu là phần dưỡng sưc thì thể hiện 25% { totalSalaryInsurance = 0.25; row[Ins_C70aReportEntity.FieldNames.SalaryInsurance] = 0.25; if (status == InsuranceRecordType.E_LEAVE_AT_SAME_PLACE.ToString()) { totalSalaryInsurance = 0.4; row[Ins_C70aReportEntity.FieldNames.SalaryInsurance] = 0.4; } } //Lay nam nghi viec cua record de tinh luy ke. Neu nghi tu nam ngoai thi luy ke cac ngay nghi tu nam ngoai List<Ins_InsuranceRecord> lstInSursInYear = list_Year.Where(ir => ir.ProfileID == proID && ir.DateStart.Value.Year == record.DateStart.Value.Year && ir.DateEnd <= record.DateEnd && ir.InsuranceType == status).ToList(); //Trường hợp con Ốm thì con nào phải đúng tuyến cho con đó. if (record.InsuranceType == InsuranceRecordType.E_SICK_CHILD.ToString()) { lstInSursInYear = lstInSursInYear.Where(m => m.ChildSickID == record.ChildSickID).ToList(); } Double leaveInYear = 0; foreach (Ins_InsuranceRecord it in lstInSursInYear) { leaveInYear += InsuranceServices.GetCountLeaveRecord(it); } totalLeaveInYear += leaveInYear; row[Ins_C70aReportEntity.FieldNames.LeaveInYear] = leaveInYear; Double leaveInMonth = InsuranceServices.GetCountLeaveRecord(record); totalLeaveInMonth += leaveInMonth; row[Ins_C70aReportEntity.FieldNames.LeaveInMonth] = leaveInMonth; if (record.DateStart != null) { row[Ins_C70aReportEntity.FieldNames.DateStart] = record.DateStart.Value; } if (record.DateEnd != null) { row[Ins_C70aReportEntity.FieldNames.DateEnd] = record.DateEnd.Value; } //row["Status"] = LanguageManager.GetString(status); //row["GroupName"] = LanguageManager.GetString(GroupName); row[Ins_C70aReportEntity.FieldNames.Status] = status; row[Ins_C70aReportEntity.FieldNames.GroupName] = GroupName; row[Ins_C70aReportEntity.FieldNames.CodeParentOrgLevel] = Hre_ProfileServices.GetCodeInListOrgParent(Profile.OrgStructureID ?? Guid.Empty, lstOrgAll, 1); tblData.Rows.Add(row); return tblData; }
/// <summary> /// Tinh so tien luong tham gia BHXH, va so tien duoc huong doi voi tung record /// </summary> /// <param name="record">Chung tu</param> /// <param name="AmountMaxIns">Muc tran dong BHXH</param> /// <param name="AmountMinumumIns">Muc luong toi thieu</param> /// <param name="monthJoin">Thang tham gia BHXH</param> /// <param name="listBasicSalary">Danh sach luong co ban</param> /// <param name="listRateInsurance">Danh sach ty gia BHXH</param> /// <param name="moneyIns">Tien BHXH phai tra</param> /// <param name="SalaryIns">Muc luong tinh BHXH</param> public static void GetMoneyInsSalaryIns(Ins_InsuranceRecord record, List<Cat_ValueEntity> lstAmountMaxIns , List<Cat_ValueEntity> lstAmountMinIns, DateTime monthJoin , List<Sal_BasicSalary> listBasicSalary, List<Cat_ExchangeRate> listRateInsurance, List<Sys_AllSetting> appConfig , out Double moneyIns, out Double SalaryIns, bool isCheckGetBirthChildForRestorationPregnancy) { Hre_Profile pro = record.Hre_Profile; String status = record.InsuranceType.ToString(); Double leaveDayInMonth = record.DayCount; moneyIns = 0; SalaryIns = 0; //BHXH quy dinh ngay cong chuan la 26 Double _workdaySta = 26; //Pregnancy if (status == InsuranceRecordType.E_PREGNANCY_EXAMINE.ToString() || status == InsuranceRecordType.E_PREGNANCY_LOST.ToString() || status == InsuranceRecordType.E_PREGNANCY_PREVENTION.ToString() || status == InsuranceRecordType.E_PREGNANCY_SUCKLE.ToString()) { DateTime dateStart = record.DateStart != null ? record.DateStart.Value : record.RecordDate; DateTime dateEnd = record.DateEnd != null ? record.DateEnd.Value : record.RecordDate; Double AmountMaxIns = GetMaxMinAmountOfMonth(dateStart, lstAmountMaxIns); //Lay muc luong cua 6 thang lien ke List<Sal_BasicSalary> listBasicSalaryPro = listBasicSalary.Where(sl => sl.ProfileID == pro.ID).ToList(); SalaryIns = GetAmountInsuranceSixMonth(pro, dateStart, monthJoin, AmountMaxIns, listBasicSalaryPro, listRateInsurance, status); if (SalaryIns > AmountMaxIns) { SalaryIns = AmountMaxIns; } //Lay so tien BHXH tra moneyIns = (SalaryIns / _workdaySta) * leaveDayInMonth; if (status == InsuranceRecordType.E_PREGNANCY_SUCKLE.ToString()) { //TODO: cấu hình động chỗ này //TH1-FOV: ngày tính bắt đầu từ ngày nghỉ //TH2-FGL: ngày tính bắt đầu từ ngày sinh con //AppConfig:PREGNANCY_AVERAGE_SALARY_FROM_CHILD_BORN //DateSuckle: ngay sinh con, bo frame se co cau hinh phu hop voi FGL List<Sys_AllSetting> appcf = appConfig.Where(prop => prop.Name == AppConfig.E_COLLECT_SOCIAL_INSURANCE_CONFIGFGL.ToString()).ToList(); if (appcf.Count > 0) { if (appcf[0].Value3 != null && (Boolean.Parse(appcf[0].Value1.ToString()) == true)) { if (record.DateSuckle.HasValue) dateStart = record.DateSuckle.Value; } } //Lay muc tran tai thoi diem nghi thai san or sinh con Double AmountMaxInsSuckle = GetMaxMinAmountOfMonth(dateStart, lstAmountMaxIns); Double AmountMinumumInsSuckle = GetMaxMinAmountOfMonth(dateStart, lstAmountMinIns); SalaryIns = GetAmountInsuranceSixMonth(pro, dateStart, monthJoin, AmountMaxInsSuckle, listBasicSalaryPro, listRateInsurance, status); if (SalaryIns > AmountMaxInsSuckle) { SalaryIns = AmountMaxInsSuckle; } //Neu loai sinh doi thi duoc cong them 4 thang luong toi thieu Double countTypeSuckle = 2; if (!String.IsNullOrEmpty(record.TypeSuckle)) { if (record.TypeSuckle == TypeSuckle.E_SUCKLE_TWINS.ToString()) countTypeSuckle = 4; } //Quy dinh BHXH FG: cong nhan nghi 5 thang, nhan vien nghi 4 thang. Fuji : tat ca deu nghi 4 thang, sinh doi nghi 5 thang //Neu so ngay nho hon 180 ngay thi tinh 6 thang. else tinh 7 thang. //20130405 - Ap dung luat moi Neu DateEnd > '01/05/2013' thi ap dung thai san 6 thang else 4 thang. DateTime dateValue = new DateTime(2013, 05, 01); if (dateEnd >= dateValue) { if (record.DayCount <= 190) moneyIns = SalaryIns * 6 + AmountMinumumInsSuckle * countTypeSuckle; else moneyIns = SalaryIns * 7 + AmountMinumumInsSuckle * countTypeSuckle; } else { if (record.DayCount < 150) moneyIns = SalaryIns * 4 + AmountMinumumInsSuckle * countTypeSuckle; else moneyIns = SalaryIns * 5 + AmountMinumumInsSuckle * countTypeSuckle; } } } else if (status == InsuranceRecordType.E_SICK_SHORT.ToString() || status == InsuranceRecordType.E_SICK_LONG.ToString() || status == InsuranceRecordType.E_SICK_CHILD.ToString()) { //Lay muc luong cua thang lien ke //--Lay thang lien ke DateTime dateSalary = new DateTime(); dateSalary = new DateTime(record.DateStart.Value.AddMonths(-1).Year , record.DateStart.Value.AddMonths(-1).Month ,PeriodInsuranceDayCurrentMonthDefault); List<Sal_BasicSalary> lstbs = listBasicSalary.Where(sa => sa.DateOfEffect <= dateSalary && sa.ProfileID == pro.ID) .OrderByDescending(sa => sa.DateOfEffect).ToList(); Double AmountMaxIns = GetMaxMinAmountOfMonth(dateSalary, lstAmountMaxIns); if (lstbs.Count > 0) { Sal_BasicSalary basicSalary = lstbs[0]; if (basicSalary != null) { Double amountIns = basicSalary.InsuranceAmount; Cat_Currency curIns = basicSalary.Cat_Currency1; if (curIns != null && curIns.Code != CurrencyCode.VND.ToString()) amountIns = Sal_PayrollLib.ConvertExtractRateToVND(amountIns, curIns, listRateInsurance); SalaryIns = amountIns; } } if (SalaryIns > AmountMaxIns) { SalaryIns = AmountMaxIns; } //Lay so tien BHXH tra //--Bao cao om dau huong 75% moneyIns = (SalaryIns / _workdaySta) * leaveDayInMonth * 0.75; } else if (status == InsuranceRecordType.E_RESTORATION_PREGNANCY.ToString() || status == InsuranceRecordType.E_RESTORATION_TNLD.ToString() || status == InsuranceRecordType.E_RESTORATION_SICK.ToString()) { //Khong tinh luong tham gia BHXH SalaryIns = 0; DateTime dateStart = record.DateStart.Value; if (isCheckGetBirthChildForRestorationPregnancy && status == InsuranceRecordType.E_RESTORATION_PREGNANCY.ToString() && record.DateSuckle != null) { dateStart = record.DateSuckle.Value; } Double AmountMinumumIns = GetMaxMinAmountOfMonth(dateStart, lstAmountMinIns); //Lay so tien BHXH toi thieu tra //--Bao cao duong suc huong 25% muc luong toi thieu voi thoi diem hien tai if (status == InsuranceRecordType.E_RESTORATION_SICK.ToString() && record.TypeData == InsuranceRecordType.E_LEAVE_AT_SAME_PLACE.ToString()) { moneyIns = AmountMinumumIns * 0.4 * leaveDayInMonth; } else { moneyIns = AmountMinumumIns * 0.25 * leaveDayInMonth; } } }
private DataRow fillRowBasic(DataRow dr, DateTime monthYear, Hre_Profile profile, Ins_InsuranceRecord record, List<Ins_InsuranceRecord> lstRecordByProfile, List<Cat_DayOff> lstDayOff) { if (profile == null) { return dr; } Stt++; dr[Ins_C70aReportEntity.FieldNames.Stt] = Stt; dr[Ins_C70aReportEntity.FieldNames.CodeEmp] = profile.CodeEmp; dr[Ins_C70aReportEntity.FieldNames.ProfileName] = ConvertStringToNamePerson(profile.ProfileName); if (profile.DateOfBirth != null) { if (profile.Gender == EnumDropDown.Sexual.E_FEMALE.ToString()) { dr["FemaleBirthYear"] = profile.DateOfBirth.Value.Year; } else { dr["MaleBirthYear"] = profile.DateOfBirth.Value.Year; } } dr["SocialInsNo"] = profile.SocialInsNo; if (record.DateStart != null) { dr["DateStart"] = record.DateStart.Value; } if (record.DateEnd != null) { dr["DateEnd"] = record.DateEnd.Value; } //if (record.DateStart != null && record.DateEnd != null) //{ // dr["SumStartEnd"] = (record.DateEnd.Value - record.DateStart.Value).TotalDays; // totalLeaveInMonth += (record.DateEnd.Value - record.DateStart.Value).TotalDays; //} //DateTime beginYear = new DateTime(monthYear.Year-1,12,15); //bat dau tu ngay 15 theo bao hiem. Can phai hoi lai chi Oanh van de tren //lstDayOff = lstDayOff.Where(m=>m.DateOff > beginYear).ToList(); //if (record.DateStart != null && record.DateEnd != null) //{ // List<Ins_InsuranceRecord> lstRecordLeaveInYear = lstRecordByProfile.Where(m => m.ProfileID == profile.ID && m.InsuranceType == record.InsuranceType // && m.DateEnd != null && m.DateEnd.Value > beginYear // && m.DateStart != null && m.DateStart.Value <= record.DateStart).ToList(); // dr["SumStartEndInYear"] = (record.DateEnd.Value - record.DateStart.Value).TotalDays + getNumDayLeaveInYear(lstRecordLeaveInYear, lstDayOff); // totalLeaveInYear = (record.DateEnd.Value - record.DateStart.Value).TotalDays + getNumDayLeaveInYear(lstRecordLeaveInYear, lstDayOff); //} return dr; }