Beispiel #1
0
        public ActionResult AddTaxReturns(HttpPostedFileBase employeeExcelSheet, TaxReturnView taxReturnView)
        {
            if (taxReturnView.IncomeTypeId < 1)
            {
                this.ModelState.AddModelError("", "Please specify Income Type");
            }

            if (taxReturnView.BranchId < 1)
            {
                this.ModelState.AddModelError("", "Please specify Branch");
                var view = this.agentOfDeductionService.GetTaxreturnsView("");
                return(this.View("AddTaxReturns", view));
            }


            var returnInfo = this.agentOfDeductionService.ProcessUploadExcel(employeeExcelSheet, taxReturnView.IncomeTypeId, taxReturnView.BranchId);

            if (!string.IsNullOrEmpty(returnInfo))
            {
                var returnModel = this.agentOfDeductionService.GetTaxreturnsView(returnInfo);
                return(this.View("AddTaxReturns", returnModel));
            }
            var returnView = this.agentOfDeductionService.GetTaxreturnsView("File Uploaded Successfully");

            return(this.View("AddTaxReturns", returnView));
        }
        /// <summary>
        /// Processes the upload excel department.
        /// </summary>
        /// <param name="departmentExcelFile">The department excel file.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="incomeTypeId">The income type identifier.</param>
        /// <param name="branchId">The branch identifier.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">departmentExcelFile</exception>
        public string ProcessUploadExcel(HttpPostedFileBase departmentExcelFile, int incomeTypeId, int branchId)
        {
            if (departmentExcelFile == null)
            {
                throw new ArgumentNullException(nameof(departmentExcelFile));
            }

            var result              = string.Empty;
            var userId              = (int)session.GetSessionValue(SessionKey.UserId);
            var jurisidiction       = this.generalRepository.GetJurisdictionByBranchId(branchId);
            var agentOfdeduction    = this.agentOfDeductionRepository.GetAgentOfdeductionBranchByranchId(branchId);
            var taxreturnCollection = this.agentOfDeductionRepository.ExcelUpload(departmentExcelFile);

            try
            {
                foreach (DataRow r in taxreturnCollection.Rows)
                {
                    var taxReturnView = new TaxReturnView()

                    {
                        BeneficiaryTin = r.ItemArray[8].ToString(),

                        BeneficiaryName     = r.ItemArray[9].ToString(),
                        BVN                 = r.ItemArray[0].ToString(),
                        BeneficiaryAddress  = r.ItemArray[1].ToString(),
                        InvoiceNo           = r.ItemArray[2].ToString(),
                        ContractDate        = r.ItemArray[3].ToString(), //3
                        ContractDescription = r.ItemArray[4].ToString(),
                        ContractAmount      = r.ItemArray[5].ToString(),
                        WHT_Rate            = r.ItemArray[6].ToString(),
                        WHT_Amount          = r.ItemArray[7].ToString(),
                        IncomeTypeId        = incomeTypeId,
                        UserRegistrationId  = userId,
                        BranchId            = branchId,
                        IsActive            = true,
                        DateCreated         = DateTime.Now,
                        JurisdictionId      = jurisidiction.JurisdictionId,
                        AgentOfDeductionId  = agentOfdeduction.AgentOfDeductionId
                    };
                    result = this.agentOfDeductionRepository.SaveTaxReturnInfo(taxReturnView);
                }
            }
            catch
            {
                var ErrorFormat = "Invalid File Type";
                return(ErrorFormat);
            }


            return(result);
        }