Ejemplo n.º 1
0
        public void AddDataForBasicSalary(string ProfileIDs, string BasicSalary, DateTime DateHire, Guid SalaryRankID,string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                string status = string.Empty;
                var repoBasicSalary = new CustomBaseRepository<Sal_BasicSalary>(unitOfWork);
                List<Guid> lstProfileIDs = ProfileIDs.Split(',').Select(x => Guid.Parse(x)).ToList();
                List<Sal_BasicSalary> lstBasicSalary = new List<Sal_BasicSalary>();
                //chua co cach giai quyet nen hard code lay mac dinh la VND
                var repoCurrency = new CustomBaseRepository<Cat_Currency>(unitOfWork);
                var currency = repoCurrency.FindBy(s => s.IsDelete == null && s.CurrencyName == "VND").FirstOrDefault();
                //var repoSalaryRank = new CustomBaseRepository<Cat_SalaryRank>(unitOfWork);
                //var repoSalaryClass = new CustomBaseRepository<Cat_SalaryClass>(unitOfWork);
                //var salaryRank = repoSalaryRank.FindBy(s => s.IsDelete == null && s.ID == SalaryRankID).FirstOrDefault();
                //var salaryClass = repoSalaryClass.FindBy(s => s.IsDelete == null && s.ID == salaryRank.SalaryClassID).FirstOrDefault();
                var salaryRankServices = new Cat_SalaryRankServices();
                var lstObjRank = new List<object>();
                lstObjRank.Add(null);
                lstObjRank.Add(null);
                lstObjRank.Add(1);
                lstObjRank.Add(int.MaxValue -1);
                var lstRank = salaryRankServices.GetData<Cat_SalaryRankEntity>(lstObjRank, ConstantSql.hrm_cat_sp_get_SalaryRank, UserLogin, ref status).ToList().Translate<Cat_SalaryRank>();
                var rankEntity = lstRank.Where(s => s.ID == SalaryRankID).FirstOrDefault();

                var salaryClassServices = new Cat_SalaryClassServices();
                var lstObjClass = new List<object>();
                lstObjClass.Add(null);
                lstObjClass.Add(1);
                lstObjClass.Add(int.MaxValue -1);
                var salaryClass = salaryClassServices.GetData<Cat_SalaryClassEntity>(lstObjClass, ConstantSql.hrm_cat_sp_get_SalaryClass, UserLogin, ref status).ToList().Translate<Cat_SalaryClass>();
                
                var salaryClassEntity = salaryClass.Where(s => rankEntity.SalaryClassID == s.ID).FirstOrDefault();
               
                foreach (var item in lstProfileIDs)
                {
                    Sal_BasicSalary objBasicSalary = new Sal_BasicSalary();
                    objBasicSalary.ProfileID = item;
                    objBasicSalary.GrossAmount = BasicSalary;
                    objBasicSalary.Amount = BasicSalary.Encrypt(); 
                    objBasicSalary.DateOfEffect = DateHire;
                    objBasicSalary.RankRateID = SalaryRankID;
                    objBasicSalary.CurrencyID = currency.ID;
                    objBasicSalary.ClassRateID = salaryClassEntity == null ? Guid.Empty : salaryClassEntity.ID;
                    lstBasicSalary.Add(objBasicSalary);
                }

                repoBasicSalary.Add(lstBasicSalary);
                repoBasicSalary.SaveChanges();


            }
        }
Ejemplo n.º 2
0
        public List<Sal_SalaryDepartmentItem> CalSalaryLineItemProfile(Sal_SalaryDepartment salDepartment, List<Att_AttendanceTableItem> lstAttItemPro, Hre_Profile pro,
                                                                             List<Sal_BasicSalary> lstBasicSalPro, List<Att_Roster> lstRosterPro, DateTime dfrom, DateTime dto, DateTime monthYear,
                                                                             Sal_SalaryDepartmentItem itemProAdd)
        {
            List<Sal_SalaryDepartmentItem> lstItem = new List<Sal_SalaryDepartmentItem>();
            Double ratePer = 0;

            //Lấy hệ số trong lương cơ bản
            Sal_BasicSalary basSal = new Sal_BasicSalary();
            if (lstBasicSalPro.Count == 2)
                basSal = lstBasicSalPro[1];
            else if (lstBasicSalPro.Count == 1)
                basSal = lstBasicSalPro[0];

            if (ratePer != basSal.PersonalRate)
            {
                ratePer = basSal.PersonalRate != null ? basSal.PersonalRate.Value : 0;
                Sal_SalaryDepartmentItem depItem = null;

                string stFIX = EnumDropDown.StatusLoadEnumSalDepartItem.E_FIX.ToString();
                string stEDIT_FIX = EnumDropDown.StatusLoadEnumSalDepartItem.E_EDIT_FIX.ToString();
                if (itemProAdd != null && itemProAdd.ID.ToString() != Guid.Empty.ToString() && itemProAdd.Status != stFIX && itemProAdd.Status != stEDIT_FIX)
                {
                    depItem = itemProAdd;
                }
                else
                {
                    depItem = new Sal_SalaryDepartmentItem();
                }
                depItem.Sal_SalaryDepartment = salDepartment;
                depItem.DateFrom = dfrom;
                depItem.DateTo = dto;
                depItem.ProfileID = pro.ID;
                depItem.Rate = ratePer;
                if (itemProAdd != null)
                    depItem.Status = itemProAdd.Status;

                for (DateTime idx = dfrom; idx <= dto; idx = idx.AddDays(1))
                {
                    //(3.Use general: Insert chi tiết --> Gần Finished)
                    depItem = SetItemSalDep(depItem, lstAttItemPro, idx);
                }

                //AppConfig
                var service = new Sys_AttOvertimePermitConfigServices();
                var value56 =  service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE56);
                var value57 =  service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE57);
                var value58 =  service.GetConfigValue<string>(AppConfig.HRM_SAL_CONFIG_VALUE58);

                //Nếu có check áp dụng trừ số giờ cho nữ
                string gender = EnumDropDown.Gender.E_FEMALE.ToString();
                if (value56.ToLower() == true.ToString().ToLower() && pro.Gender == gender)
                {
                    if (!value57.IsNullOrEmpty() && !value58.IsNullOrEmpty())
                    {
                        double hoursub = Convert.ToDouble(value57);
                        double daywork = Convert.ToDouble(value58);
                        if (hoursub > 0 && daywork > 0)
                        {
                            var lstAttItem = lstAttItemPro.Where(p => p.IsHavingPregTreatment == true).ToList();
                            //Nếu nhân viên không có thai sản
                            if (lstAttItem.Count <= 0)
                            {
                                if (depItem.PaidWorkHours / 8 > daywork)
                                    depItem.PaidWorkHours = depItem.PaidWorkHours - hoursub;
                            }
                        }
                    }
                }
                lstItem.Add(depItem);
            }
            return lstItem;
        }
Ejemplo n.º 3
0
        /// <summary>      
        /// Lay luong trung binh dong BH 6 thang gan nhat
        /// </summary>
        /// <param name="monthYear">ngay 15</param>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static Double GetAmountInsuranceSixMonth(Hre_Profile pro, DateTime monthYear, DateTime monthJoin, Double AmountMaxIns, List<Sal_BasicSalary> lstSal, List<Cat_ExchangeRate> listRateInsurance, String typeRecord)
        {
            Double _amount = 0;
            DateTime monthYearIns = new DateTime();
            int month = 0;
            //Lay thang lien ke
            //Nghi trong thang nao tinh thang do ko tinh ngay 15
            monthYearIns = new DateTime(monthYear.AddMonths(-1).Year
                                            , monthYear.AddMonths(-1).Month
                                            , PeriodInsuranceDayCurrentMonthDefault);

            if (typeRecord == InsuranceRecordType.E_PREGNANCY_EXAMINE.ToString()
            || typeRecord == InsuranceRecordType.E_PREGNANCY_LOST.ToString()
            || typeRecord == InsuranceRecordType.E_PREGNANCY_PREVENTION.ToString())
            {
                //LamLe- Update luat moi neu sinh con 1-15 thi tinh 6 thang lien ke - Neu sinh con 16-cuối tháng tinh 6 thang bat dau tu thang sinh con.
                // cac loaij lien tuan den thai san thi ap dung ngay 15
                if (monthYear.Day >= PeriodInsuranceDayCurrentMonthDefault)
                    monthYearIns = new DateTime(monthYear.Year
                                                , monthYear.Month
                                                , PeriodInsuranceDayCurrentMonthDefault);
            }
            if (typeRecord == InsuranceRecordType.E_PREGNANCY_SUCKLE.ToString())
            {
                //LamLe- Update luat moi neu sinh con 1-15 thi tinh 6 thang lien ke - Neu sinh con 16-cuối tháng tinh 6 thang bat dau tu thang sinh con.
                //Loai nghi sanh thi ap  dung ngay 16
                if (monthYear.Day > PeriodInsuranceDayCurrentMonthDefault)
                    monthYearIns = new DateTime(monthYear.Year
                                                , monthYear.Month
                                                , PeriodInsuranceDayCurrentMonthDefault);
            }

            //Kiem tra thoi gian dong bao hiem co lon hon 6 thang.
            DateTime monthSix = new DateTime(monthYearIns.AddMonths(-6).Year
                                            , monthYearIns.AddMonths(-6).Month
                                            , PeriodInsuranceDayCurrentMonthDefault);
            monthJoin = new DateTime(monthJoin.Year
                                     , monthJoin.Month
                                            , PeriodInsuranceDayCurrentMonthDefault);
            if (monthSix.Date.CompareTo(monthJoin.Date) < 0)
            {
                for (DateTime dx = monthJoin; dx <= monthYearIns; dx = new DateTime(dx.AddMonths(1).Year
                                                                           , dx.AddMonths(1).Month
                                                                           , PeriodInsuranceDayCurrentMonthDefault))
                {
                    month += 1;
                }
            }
            else
                month = 6;
            //lstSal = lstSal.Where(sal => sal.DateOfEffect > minMonthYear && ).ToList();
            lstSal = lstSal.Where(sal => sal.DateOfEffect <= monthYearIns).OrderByDescending(pit => pit.DateOfEffect).ToList();
            for (int i = 0; i < month; i++)
            {
                DateTime dateMonth = new DateTime(monthYearIns.AddMonths(-i).Year
                                            , monthYearIns.AddMonths(-i).Month
                                            , PeriodInsuranceDayCurrentMonthDefault);
                DateTime dateMaxSal = DateTime.MinValue;
                Sal_BasicSalary salMonth = new Sal_BasicSalary();
                foreach (Sal_BasicSalary sal in lstSal)
                {
                    if (sal.DateOfEffect > dateMaxSal && sal.DateOfEffect <= dateMonth)
                    {
                        dateMaxSal = sal.DateOfEffect;
                        salMonth = sal;
                    }
                }
                Double amountIns = salMonth.InsuranceAmount;
                Cat_Currency curIns = salMonth.Cat_Currency1;
                if (curIns != null && curIns.Code != CurrencyCode.VND.ToString())
                    amountIns = Sal_PayrollLib.ConvertExtractRateToVND(amountIns, curIns, listRateInsurance);

                if (amountIns > AmountMaxIns)
                {
                    _amount += AmountMaxIns;
                }
                else
                {
                    _amount += amountIns;
                }

            }
            return _amount / month;

        }