Esempio n. 1
0
        public void AddRegularTransactions()
        {
            FillTransDetails();
            DataTable dtReader = _uTransSvc.GetUserTransactions(_runDate);

            if (dtReader != null)
            {
                foreach (DataRow reader in dtReader.Rows)
                {
                    try
                    {
                        using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
                        {
                            DateTime?lastDayOfRun  = null;
                            DateTime?nextDayToRun  = null;
                            string   isDiffTo      = string.Empty;
                            int      transMasterId = (int)reader["TranMasterId"];
                            if (IsTransactionRequired(transMasterId, string.IsNullOrEmpty(reader["NextAutoTransactionOn"].ToString())?null: reader["NextAutoTransactionOn"], string.IsNullOrEmpty(reader["LastAutoTransactionOn"].ToString())?null: reader["LastAutoTransactionOn"], out lastDayOfRun, out nextDayToRun, out isDiffTo))
                            {
                                DataRow[] rules = GetRuleRow(transMasterId, isDiffTo, reader["StandardId"], reader["SectionId"], reader["UserMasterId"], reader["ClassTypeId"]);

                                if (rules != null)
                                {
                                    //Insert records as pending in trans log
                                    TransactionLogDTO trnsLogDto = new TransactionLogDTO();
                                    trnsLogDto.Active            = true;
                                    trnsLogDto.User              = new UserMasterDTO();
                                    trnsLogDto.User.UserMasterId = (int)reader["UserMasterId"];
                                    trnsLogDto.TransactionDate   = _runDate;

                                    if (rules[0]["FirstDueAfterDays"] != null || !string.IsNullOrEmpty(rules[0]["FirstDueAfterDays"].ToString()))
                                    {
                                        trnsLogDto.TransactionDueDate = _runDate.AddDays((int)rules[0]["FirstDueAfterDays"]);
                                    }
                                    else
                                    {
                                        trnsLogDto.TransactionDueDate = null;
                                    }

                                    trnsLogDto.TransactionPreviousDueDate = null;
                                    trnsLogDto.ParentTransactionLogId     = null;
                                    trnsLogDto.IsCompleted   = false;
                                    trnsLogDto.CompletedOn   = null;
                                    trnsLogDto.AmountImposed = CalculateAmount(string.IsNullOrEmpty(reader["GraceAmountOn"].ToString())?null: reader["GraceAmountOn"], string.IsNullOrEmpty(reader["GraceAmount"].ToString())?null: reader["GraceAmount"], double.Parse(rules[0]["ActualAmount"].ToString()));
                                    trnsLogDto.AmountGiven   = null;
                                    trnsLogDto.DueAmount     = trnsLogDto.AmountImposed;
                                    trnsLogDto.TransferMode  = null;
                                    trnsLogDto.Location      = null;
                                    if (string.Equals(reader["RoleId"].ToString(), _commonConfig["STUD_ROLE_ID"]))
                                    {
                                        trnsLogDto.StandardSectionMap = new StandardSectionMapDTO();
                                        trnsLogDto.StandardSectionMap.StandardSectionId = (int)reader["StandardSectionId"];
                                    }
                                    else
                                    {
                                        trnsLogDto.StandardSectionMap = null;
                                    }
                                    trnsLogDto.TransactionType            = reader["TransactionType"].ToString();
                                    trnsLogDto.HasPenalty                 = false;
                                    trnsLogDto.TransactionRule            = new TransactionRuleDTO();
                                    trnsLogDto.TransactionRule.TranRuleId = (int)rules[0]["TranRuleId"];

                                    if (trnsLogDto.TransactionDueDate != null)
                                    {
                                        trnsLogDto.PenaltyTransactionRule            = new TransactionRuleDTO();
                                        trnsLogDto.PenaltyTransactionRule.TranRuleId = trnsLogDto.TransactionRule.TranRuleId;
                                    }

                                    StatusDTO <TransactionLogDTO> status = _transLog.Insert(trnsLogDto);
                                    if (status.IsSuccess)
                                    {
                                        UserTransactionDTO uTrns = new UserTransactionDTO();
                                        uTrns.LastAutoTransactionOn = lastDayOfRun;
                                        uTrns.NextAutoTransactionOn = nextDayToRun;
                                        uTrns.UserTransactionId     = (int)reader["UserTransactionId"];
                                        StatusDTO uTrnsStatus = _uTransSvc.UpdateTransLastRunNextRun(uTrns);
                                        if (uTrnsStatus.IsSuccess)
                                        {
                                            ts.Complete();
                                        }
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception exp)
                    {
                        _logger.Log(exp);
                    }
                }
            }

            //Disposing source data
            _uTransSvc.Dispose();
            if (dtReader != null)
            {
                dtReader.Dispose();
                dtReader = null;
            }
        }
        public JsonResult GetStudentPaymentDetails(Models.TransactionViewModel trDetails)
        {
            string dueDate = string.Empty;
            StatusDTO <TransactionMasterDTO> status = _trMaster.Select(trDetails.TransactionMasterId);

            if (status.IsSuccess)
            {
                StatusDTO <StudentDTO>    studStatus = _studentSvc.GetStudentTransactionInfo(trDetails.StudentInfoId);
                TransactionRuleDTO        rule       = null;
                List <TransactionRuleDTO> rules      = null;
                string isDiffTo = status.ReturnObj.IsDiffTo.ToUpper();
                switch (isDiffTo)
                {
                case "NONE":
                    rules = _trRule.GetNoneLevelRules(trDetails.TransactionMasterId);
                    if (rules != null && rules.Count > 0)
                    {
                        rule = rules[0];
                    }
                    break;

                case "USER":
                    rules = _trRule.GetUserLevelRules(trDetails.TransactionMasterId, studStatus.ReturnObj.UserDetails.UserMasterId);
                    if (rules != null && rules.Count > 0)
                    {
                        rule = rules[0];
                    }
                    break;

                case "STANDARD":
                    rules = _trRule.GetStandardLevelRules(trDetails.TransactionMasterId, studStatus.ReturnObj.StandardSectionMap.Standard.StandardId);
                    if (rules != null && rules.Count > 0)
                    {
                        rule = rules[0];
                    }
                    break;

                case "SECTION":
                    rules = _trRule.GetStandardSectionLevelRules(trDetails.TransactionMasterId, studStatus.ReturnObj.StandardSectionMap.Standard.StandardId, studStatus.ReturnObj.StandardSectionMap.Section.SectionId);
                    if (rules != null && rules.Count > 0)
                    {
                        rule = rules[0];
                    }
                    break;

                case "CLASS-TYPE":
                    rules = _trRule.GetClassTypeLevelRules(trDetails.TransactionMasterId, studStatus.ReturnObj.StandardSectionMap.Standard.ClassType.ClassTypeId);
                    if (rules != null && rules.Count > 0)
                    {
                        rule = rules[0];
                    }
                    break;
                }
                List <UserTransactionDTO> uTrans = _uTranSvc.GetUserTransactions(trDetails.TransactionMasterId, studStatus.ReturnObj.UserDetails.UserMasterId);
                if (uTrans != null && uTrans.Count > 0 && rule != null)
                {
                    if (string.Equals(uTrans[0].GraceAmountIn, "ACTUAL", StringComparison.OrdinalIgnoreCase))
                    {
                        rule.ActualAmount = rule.ActualAmount - uTrans[0].GraceAmount;
                    }
                    if (string.Equals(uTrans[0].GraceAmountIn, "PERCENT", StringComparison.OrdinalIgnoreCase))
                    {
                        rule.ActualAmount = rule.ActualAmount - ((uTrans[0].GraceAmount * rule.ActualAmount) / 100);
                    }
                }
                if (rule != null)
                {
                    int?dueAfterDays = _trRule.GetFirstDueAfterDays(rule.TranRuleId);
                    if (dueAfterDays.HasValue)
                    {
                        DateTime dtValid = new DateTime();
                        if (DateTime.TryParse(trDetails.TransactionDateString, out dtValid))
                        {
                            dueDate = dtValid.AddDays(dueAfterDays.Value).ToString("dd-MMM-yyyy");
                        }
                        else
                        {
                            dueDate = DateTime.Today.AddDays(dueAfterDays.Value).ToString("dd-MMM-yyyy");
                        }
                    }
                }
                return(Json(new { status = true, message = "", ruleData = rule, tranMasterData = status.ReturnObj, dueDateString = dueDate }));
            }

            return(Json(new { status = false, message = "Failed to fetch data", ruleData = new TransactionRuleDTO(), tranMasterData = new TransactionMasterDTO(), dueDateString = dueDate }));
        }
        public ActionResult Register(string mode, string id)
        {
            Models.StudentVM studView = new Models.StudentVM();
            studView.UserDetails   = new UserMasterDTO();
            studView.MODE          = mode;
            studView.DisabledClass = "";
            if (string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase))
            {
                studView.UserDetails.UserMasterId = int.Parse(id);
            }
            if (string.Equals(mode, "VIEW", StringComparison.OrdinalIgnoreCase))
            {
                studView.DisabledClass = "disabledPlace";
            }
            studView.Transactions = new List <UserTransactionDTO>();
            if (mode != null && (string.Equals(mode, "EDIT", StringComparison.OrdinalIgnoreCase) || string.Equals(mode, "VIEW", StringComparison.OrdinalIgnoreCase)))
            {
                //Populate edit data using id passed in URL, if id==null then show error message
                StatusDTO <StudentDTO> dto = _studSvc.Select(Convert.ToInt32(id));
                studView.UserDetails = new UserMasterDTO();
                studView.UserDetails.UserMasterId = dto.ReturnObj.UserDetails.UserMasterId;
                //uvModel.UserMasterId = dto.ReturnObj.UserMasterId;
                studView.UserDetails.FName              = dto.ReturnObj.UserDetails.FName;
                studView.UserDetails.MName              = dto.ReturnObj.UserDetails.MName;
                studView.UserDetails.LName              = dto.ReturnObj.UserDetails.LName;
                studView.UserDetails.Gender             = dto.ReturnObj.UserDetails.Gender;
                studView.UserDetails.Image              = dto.ReturnObj.UserDetails.Image;
                studView.UserDetails.DOB                = dto.ReturnObj.UserDetails.DOB;
                studView.DOBString                      = studView.UserDetails.DOB.HasValue ? studView.UserDetails.DOB.Value.ToString("dd-MMM-yyyy") : string.Empty;
                studView.UserDetails.EmailId            = dto.ReturnObj.UserDetails.EmailId;
                studView.UserDetails.ResidentialAddress = dto.ReturnObj.UserDetails.ResidentialAddress;
                studView.UserDetails.PermanentAddress   = dto.ReturnObj.UserDetails.PermanentAddress;
                studView.UserDetails.ContactNo          = dto.ReturnObj.UserDetails.ContactNo;
                studView.UserDetails.AltContactNo       = dto.ReturnObj.UserDetails.AltContactNo;
                studView.UserDetails.BloodGroup         = dto.ReturnObj.UserDetails.BloodGroup;
                studView.UserDetails.Location           = dto.ReturnObj.UserDetails.Location;
                studView.UserDetails.Role               = dto.ReturnObj.UserDetails.Role;

                //studView.Student = new StudentDTO();
                studView.RollNumber             = dto.ReturnObj.RollNumber;
                studView.RegistrationNumber     = dto.ReturnObj.RegistrationNumber;
                studView.AdmissionDate          = dto.ReturnObj.AdmissionDate;
                studView.FatherContact          = dto.ReturnObj.FatherContact;
                studView.GuardianName           = dto.ReturnObj.GuardianName;
                studView.FatherEmailId          = dto.ReturnObj.FatherEmailId;
                studView.HouseType              = dto.ReturnObj.HouseType;
                studView.StandardSectionMap     = dto.ReturnObj.StandardSectionMap;
                studView.FatherName             = dto.ReturnObj.FatherName;
                studView.FatherQualification    = dto.ReturnObj.FatherQualification;
                studView.FatherOccupation       = dto.ReturnObj.FatherOccupation;
                studView.FatherDesignation      = dto.ReturnObj.FatherDesignation;
                studView.FatherOrganisationName = dto.ReturnObj.FatherOrganisationName;
                studView.MotherName             = dto.ReturnObj.MotherName;
                studView.MotherQualification    = dto.ReturnObj.MotherQualification;
                studView.MotherOccupation       = dto.ReturnObj.MotherOccupation;
                studView.MotherAnnualIncome     = dto.ReturnObj.MotherAnnualIncome;
                studView.MotherOrganisationName = dto.ReturnObj.MotherOrganisationName;
                studView.IsChristian            = dto.ReturnObj.IsChristian;
                studView.IsParentTeacher        = dto.ReturnObj.IsParentTeacher;
                studView.SubjectNameTheyTeach   = dto.ReturnObj.SubjectNameTheyTeach;
                studView.IsParentFromEngMedium  = dto.ReturnObj.IsParentFromEngMedium;
                studView.IsJointOrNuclearFamily = dto.ReturnObj.IsJointOrNuclearFamily;
                studView.SiblingsInStadOrNot    = dto.ReturnObj.SiblingsInStadOrNot;
                studView.AnyAlumuniMember       = dto.ReturnObj.AnyAlumuniMember;
                studView.StuInPrivateTution     = dto.ReturnObj.StuInPrivateTution;
                studView.NoOfTution             = dto.ReturnObj.NoOfTution;
                studView.FeesPaidForTution      = dto.ReturnObj.FeesPaidForTution;

                studView.Transactions       = _userTrans.GetUserTransactions(dto.ReturnObj.UserDetails.UserMasterId);
                studView.TransactionMasters = _uiddlRepo.getTransactionMasters();


                string studentImageFolder = _configSvc.GetStudentImagesFolder();
                string fatherImageFolder  = _configSvc.GetFatherImagesFolder();
                string motherImageFolder  = _configSvc.GetMotherImagesFolder();

                studView.StudentImagePath = _configSvc.GetStudentImagesRelPath() + "/" + GetImageFileName(studView.RegistrationNumber, studentImageFolder);
                studView.FatherImagePath  = _configSvc.GetFatherImagesRelPath() + "/" + GetImageFileName(studView.RegistrationNumber, fatherImageFolder);
                studView.MotherImagePath  = _configSvc.GetMotherImagesRelPath() + "/" + GetImageFileName(studView.RegistrationNumber, motherImageFolder);
            }

            //studView.Transactions = _userTrans.GetUserTransactions(dto.ReturnObj.UserDetails.UserMasterId);
            studView.TransactionMasters = _uiddlRepo.getTransactionMasters();

            studView.CalcInSelectList            = _uiddlRepo.getCalcTypeDic();
            studView.TransactionMasterSelectList = _dropDwnRepo.GetTransactionMasters();

            studView.GenderList               = _uiddlRepo.getGenderDropDown();
            studView.LocationList             = _uiddlRepo.getLocationDropDown();
            studView.RoleList                 = _uiddlRepo.getRoleDropDown();
            studView.ClassTypeList            = _uiddlRepo.getClassTypeDropDown();
            studView.SectionList              = _uiddlRepo.getSectionDropDown();
            studView.HouseList                = _uiddlRepo.getHouseDropDown();
            studView.IsChristianList          = _uiddlRepo.getSelectValueDropDown();
            studView.IsParentTeacherList      = _uiddlRepo.getSelectValueDropDown();
            studView.IsParentFromEngMedList   = _uiddlRepo.getSelectValueDropDown();
            studView.JointOrNuclearFamilyList = _uiddlRepo.getSelectJointNuclearDropDown();
            studView.SiblingsInStdOrNotList   = _uiddlRepo.getSelectValueDropDown();
            studView.AnyAlumunimemberList     = _uiddlRepo.getSelectValueDropDown();
            studView.StudentinPvtTutionList   = _uiddlRepo.getSelectValueDropDown();

            //uvModel.BookCategoryList = _uiddlRepo.getBookCategoryDropDown();
            //uvModel.DepartmentList = _uiddlRepo.getDepartmentDropDown();
            //uvModel.DesignationList = _uiddlRepo.getDesignationDropDown();
            studView.StandardSectionList = _uiddlRepo.getStandardSectionDropDown();
            studView.GraceAmountOnList   = _uiddlRepo.getCalcType();



            return(View(studView));
        }