Ejemplo n.º 1
0
        public ViewResult Index(int?StaffId)
        {
            ViewBag.StaffId = StaffId;
            IQueryable <StaffFamilyViewModel> q = StaffFamilyRepository.GetAllStaffFamily().Where(x => x.StaffId == StaffId)
                                                  .Select(item => new StaffFamilyViewModel
            {
                Id            = item.Id,
                CreatedUserId = item.CreatedUserId,
                //CreatedUserName = item.CreatedUserName,
                CreatedDate    = item.CreatedDate,
                ModifiedUserId = item.ModifiedUserId,
                //ModifiedUserName = item.ModifiedUserName,
                ModifiedDate   = item.ModifiedDate,
                Name           = item.Name,
                StaffId        = item.StaffId,
                Address        = item.Address,
                Birthday       = item.Birthday,
                Correlative    = item.Correlative,
                Gender         = item.Gender,
                Phone          = item.Phone,
                IsDependencies = item.IsDependencies
            }).OrderByDescending(m => m.ModifiedDate);

            ViewBag.SuccessMessage    = TempData["SuccessMessage"];
            ViewBag.FailedMessage     = TempData["FailedMessage"];
            ViewBag.AlertMessage      = TempData["AlertMessage"];
            ViewBag.AccessRightCreate = SecurityFilter.AccessRight("Create", "StaffFamily", "Staff");
            //ViewBag.AccessRightEdit = SecurityFilter.AccessRight("Edit", "Technique", "Staff");
            //ViewBag.AccessRightDelete = SecurityFilter.AccessRight("Delete", "Technique", "Staff");
            return(View(q));
        }
Ejemplo n.º 2
0
        public ActionResult Create(TaxViewModel model)
        {
            if (ModelState.IsValid)
            {
                var Tax = new Tax();
                AutoMapper.Mapper.Map(model, Tax);
                Tax.IsDeleted      = false;
                Tax.CreatedUserId  = WebSecurity.CurrentUserId;
                Tax.ModifiedUserId = WebSecurity.CurrentUserId;
                Tax.AssignedUserId = WebSecurity.CurrentUserId;
                Tax.CreatedDate    = DateTime.Now;
                Tax.ModifiedDate   = DateTime.Now;
                Tax.Status         = App_GlobalResources.Wording.Processing;

                TaxRepository.InsertTax(Tax);

                //Hiện tại lấy hết nhân viên theo mã thuế
                var staff_in_tax = taxIncomePersonDetailRepository.GetAllTaxIncomePersonDetail().Where(n => n.TaxIncomePersonId == model.TaxIncomePersonId).ToList();

                //Lấy dữ liệu từ bảng lương
                var salaryReport = salaryTableDetailReportRepository.GetSalaryTableDetailReportBySalaryTableId(model.SalaryTableId.Value).ToList();
                //Cate Thu nhập chịu thếu và Giảm trừ
                var cate = categoryRepository.GetCategoryByCode("TaxCode").ToList();
                //Lấy dữ liệu giảm trừ từ người thân
                var staff_family = staffFamilyRepository.GetAllStaffFamily().Where(n => n.IsDependencies == true).ToList();

                for (int a = 0; a < staff_in_tax.Count(); a++)
                {
                    var tnct = cate.Where(n => n.Description == "TNCT").ToList();
                    for (int i = 0; i < tnct.Count; i++)
                    {
                        var             value           = salaryReport.SingleOrDefault(n => n.StaffId == staff_in_tax[a].StaffId && n.ColumName.Equals(tnct[i].Value));
                        ThuNhapChiuThue thunhapchiuthue = new ThuNhapChiuThue();
                        thunhapchiuthue.IsDeleted      = false;
                        thunhapchiuthue.CreatedUserId  = WebSecurity.CurrentUserId;
                        thunhapchiuthue.ModifiedUserId = WebSecurity.CurrentUserId;
                        thunhapchiuthue.AssignedUserId = WebSecurity.CurrentUserId;
                        thunhapchiuthue.CreatedDate    = DateTime.Now;
                        thunhapchiuthue.ModifiedDate   = DateTime.Now;

                        //Name
                        thunhapchiuthue.TaxId   = Tax.Id;
                        thunhapchiuthue.StaffId = staff_in_tax[a].StaffId;
                        thunhapchiuthue.TaxIncomePersonDetailId = staff_in_tax[a].Id;
                        thunhapchiuthue.Name  = tnct[i].Name;
                        thunhapchiuthue.Value = value == null ? 0 : decimal.Parse(value.Value);
                        thuNhapChiuThueRepository.InsertThuNhapChiuThue(thunhapchiuthue);
                    }

                    //Thêm thu nhập giảm thuế
                    var gt = cate.Where(n => n.Description == "GT").ToList();
                    for (int i = 0; i < gt.Count; i++)
                    {
                        var             value   = salaryReport.SingleOrDefault(n => n.StaffId == staff_in_tax[a].StaffId && n.ColumName.Equals(gt[i].Value));
                        GiamTruThueTNCN giamtru = new GiamTruThueTNCN();
                        giamtru.IsDeleted      = false;
                        giamtru.CreatedUserId  = WebSecurity.CurrentUserId;
                        giamtru.ModifiedUserId = WebSecurity.CurrentUserId;
                        giamtru.AssignedUserId = WebSecurity.CurrentUserId;
                        giamtru.CreatedDate    = DateTime.Now;
                        giamtru.ModifiedDate   = DateTime.Now;

                        //Name
                        giamtru.TaxId   = Tax.Id;
                        giamtru.StaffId = staff_in_tax[a].StaffId;
                        giamtru.TaxIncomePersonDetailId = staff_in_tax[a].Id;
                        giamtru.Name  = gt[i].Name;
                        giamtru.Value = value == null ? 0 : decimal.Parse(value.Value);
                        giamTruThueTNCNRepository.InsertGiamTruThueTNCN(giamtru);
                    }

                    //Thêm giảm trừ từ gia đình có thành viên phụ thuộc
                    var gd = staff_family.Where(n => n.StaffId == staff_in_tax[a].StaffId).ToList();
                    for (int i = 0; i < gd.Count; i++)
                    {
                        GiamTruThueTNCN giamtru = new GiamTruThueTNCN();
                        giamtru.IsDeleted      = false;
                        giamtru.CreatedUserId  = WebSecurity.CurrentUserId;
                        giamtru.ModifiedUserId = WebSecurity.CurrentUserId;
                        giamtru.AssignedUserId = WebSecurity.CurrentUserId;
                        giamtru.CreatedDate    = DateTime.Now;
                        giamtru.ModifiedDate   = DateTime.Now;

                        //Name
                        giamtru.TaxId   = Tax.Id;
                        giamtru.StaffId = staff_in_tax[a].StaffId;
                        giamtru.TaxIncomePersonDetailId = staff_in_tax[a].Id;
                        giamtru.Name  = string.Format("Người phụ thuộc [{0}]", gd[i].Name);
                        giamtru.Value = 3600000;
                        giamTruThueTNCNRepository.InsertGiamTruThueTNCN(giamtru);
                    }
                }
                //Thêm thu nhập chịu thuế

                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" }));
            }
            return(View(model));
        }