private void tbR_TextChanged(object sender, EventArgs e) { if ((sender as TextBox).Name == "tbR") { if (modelList != null && checkValue()) { FeeModel tempModel = modelList.Find(m => m.R == Convert.ToDouble((sender as TextBox).Text.Trim())); if (tempModel != null) { tbL.Text = tempModel.L.ToString(); tbWorkCost.Text = tempModel.Cost.ToString(); } } } foreach (var item in boxList) { if (item.Text == "") { item.Text = "0"; item.SelectAll(); } } try { doCalculation(); } catch (Exception) { } }
public async Task TransferTest() { FeeModel fee = new FeeModel() { TargetClientId = "e3fa1d1e-8e7a-44e0-a666-a442bc35515c", Size = 0 }; await Task.Delay(500); var sw = new Stopwatch(); const int cycles = 100; sw.Start(); for (int i = 0; i < cycles; i++) { var result = await _client.TransferAsync(Guid.NewGuid().ToString(), "a26d8644-6be9-4b26-bdc8-4046aa65ba86", "4d58c448-2c34-4804-a260-533d8efc9eef", "USD", 2, 100, fee, 0); Assert.NotNull(result); result = await _client.TransferAsync(Guid.NewGuid().ToString(), "4d58c448-2c34-4804-a260-533d8efc9eef", "a26d8644-6be9-4b26-bdc8-4046aa65ba86", "USD", 2, 100, fee, 0); Assert.NotNull(result); } _log.WriteLine((sw.ElapsedMilliseconds / (double)cycles / 2).ToString()); }
/// <summary> /// Calculates fee, additional fee and discount for merchant per month /// </summary> /// <param name="merchantTransactions">list of merchant's transactions per month</param> /// <param name="feesCalculationInstances">instances of fees calculation classes</param> /// <param name="discountCalculationInstances">instances of discount calculation classes</param> /// <param name="discountsList">list of discounts for merchants</param> /// <returns>fee model that contains fee amount, additional fee amount and discount</returns> public static FeeModel CalculateFee( IEnumerable <TransactionModel> merchantTransactions, IEnumerable <IFeesCalculationRule> feesCalculationInstances, IEnumerable <IDiscountCalculationRule> discountCalculationInstances, Dictionary <string, decimal> discountsList) { var feeModel = new FeeModel(); var transactionAmount = merchantTransactions.Sum(x => x.transactionAmount); var merchantName = merchantTransactions.First().merchantName; //get fee amount foreach (IFeesCalculationRule instance in feesCalculationInstances) { var fee = instance.CalculateFee(transactionAmount); if (fee.feesAmount > 0) { feeModel.feesAmount += fee.feesAmount; } if (fee.additionalFeesAmount > 0) { feeModel.additionalFeesAmount += fee.additionalFeesAmount; } } var feeBeforeDiscount = feeModel.feesAmount; //get discount amount foreach (IDiscountCalculationRule instance in discountCalculationInstances) { feeModel.discountAmount += instance.CalculateDiscountForMerchant(feeBeforeDiscount, merchantName, discountsList); } return(feeModel); }
public void UpdateFeeHeads() { try { FeeModel FM = new FeeModel(); FM.FHName = txtFHN.Text; FM.UpdatedBy = Session["UserName"].ToString(); FM.UpdatedOn = Convert.ToDateTime(DateTime.Now.ToLongDateString()); FM.FHID = Convert.ToInt64(ViewState["FHID"]); string returnMessage = dal.UpdateFeeHeads(FM); if (returnMessage == "Transaction Updated Successful") { lblError.Visible = false; lblSuccess.Visible = true; getFeeHeads(); lblSuccess.Text = returnMessage; btnUpdate.Visible = false; btnAddFH.Visible = true; } else { lblSuccess.Visible = false; lblError.Visible = true; lblError.Text = returnMessage; } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.ToString(); } }
/// <summary> /// 一次性读取配置文件 /// </summary> public List <FeeModel> LoadConfig() { List <FeeModel> modelList = new List <FeeModel>(); try { XmlDocument xml = new XmlDocument(); string xmlfile = System.IO.Directory.GetCurrentDirectory() + "\\config.xml"; if (!File.Exists(xmlfile)) { throw new Exception("配置文件不存在,路径:" + xmlfile); } xml.Load(xmlfile); //数据库连接字符串 if (xml.GetElementsByTagName("CostModels").Count > 0) { foreach (XmlNode item in xml.DocumentElement["CostModels"].ChildNodes) { FeeModel tempModel = new FeeModel(); tempModel.ModelName = item["ModelName"].InnerText.Trim(); tempModel.R = Convert.ToDouble(item["R"].InnerText.Trim()); tempModel.L = Convert.ToDouble(item["L"].InnerText.Trim()); tempModel.Cost = Convert.ToDouble(item["COST"].InnerText.Trim()); modelList.Add(tempModel); } } return(modelList); } catch (Exception ex) { return(null); } }
public ActionResult Month_Earning(Int64 ID) { try { var Plane = db.Students.Join(db.Fees, j => j.ID, u => u.Student_ID, (j, u) => new { Fees = u, Student = j }).Where(i => i.Student.Branch_ID == ID && i.Fees.Payment_Date.Value.Month == DateTime.Now.Month).ToList(); List <StudentFeePlaneModel> StudentFeePlaneModelList = new List <StudentFeePlaneModel>(); foreach (var d in Plane) { StudentFeePlaneModel StudentFeePlaneModel = new StudentFeePlaneModel(); StudentModel StudentModel = new StudentModel(); FeeModel feeModel = new FeeModel(); PlaneModel planeModel = new PlaneModel(); StudentModel.First_Name = d.Student.First_Name; StudentModel.Last_Name = d.Student.Last_Name; StudentModel.Email_ID = d.Student.Email_ID; StudentModel.Mobile = d.Student.Mobile; feeModel.Payment_Amount = d.Fees.Payment_Amount; var Plane_Name = db.Planes.Where(i => i.ID == d.Student.Current_Package_ID).FirstOrDefault(); planeModel.Name = Plane_Name.Name; StudentFeePlaneModel.StudentModel = StudentModel; StudentFeePlaneModel.FeeModel = feeModel; StudentFeePlaneModel.PlaneModel = planeModel; StudentFeePlaneModelList.Add(StudentFeePlaneModel); } return(View(StudentFeePlaneModelList)); } catch (Exception ex) { return(RedirectToAction("Contact", "Home")); } }
public static decimal GetFeeCost(FeeModel fee, decimal loanAmount) { if (fee == null) { return(0); } return(fee.ValueType == FeeValueType.Currency ? fee.Value : GetFeeCost(fee.Value, loanAmount)); }
internal static FeeContract ToMeModel(this FeeModel src) { return(new FeeContract { Size = src.Size, SizeType = (int)src.SizeType, SourceClientId = src.SourceClientId, TargetClientId = src.TargetClientId, Type = (int)src.Type }); }
public ActionResult GetPlaneName(Int64 ID) { try { FeeModel FeeDetail = new FeeModel(); var plane = db.Planes.Where(i => i.ID == ID).FirstOrDefault(); return(Json(plane, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(RedirectToAction("Contact", "Home")); } }
public ActionResult CreateFee(IFormCollection collection) { FeeModel fee = new FeeModel(); fee.IdentityNumber = Convert.ToInt32(collection["IdentityNumber"]); fee.Name = collection["Name"]; fee.Status = collection["Status"]; fee.CreatedBy = collection["CreatedBy"]; fee.CreatedOn = DateTime.Now; fee.ModifiedOn = DateTime.Now; fee.ModifiedBy = collection["ModifiedBy"]; FeeModel.FeeList.Add(fee); return(RedirectToAction("Fee")); }
public ActionResult Index() { try { int Branch_ID = Convert.ToInt32(Session["Branvch_ID"]); var Fees = db.Fees.Where(i => i.Branch_ID == Branch_ID && i.Status == true).OrderByDescending(i => i.ID).ToList(); List <FeeStudentPlaneOfferModel> FeeStudentPlaneOfferModelList = new List <FeeStudentPlaneOfferModel>(); foreach (var Fee in Fees) { FeeStudentPlaneOfferModel FeeStudentPlaneOfferModel = new FeeStudentPlaneOfferModel(); FeeModel FeeModel = new FeeModel(); StudentModel StudentModel = new StudentModel(); PlaneModel PlaneModel = new PlaneModel(); OfferModel OfferModel = new OfferModel(); var Plane = db.Planes.Where(i => i.ID == Fee.Plane_ID).FirstOrDefault(); var Offer = db.Offers.Where(i => i.ID == Fee.Offer_ID).FirstOrDefault(); var Student = db.Students.Where(i => i.ID == Fee.Student_ID).FirstOrDefault(); FeeModel.ID = Fee.ID; FeeModel.Payment_Date = Fee.Payment_Date; FeeModel.Duration = Fee.Start_Date + " TO " + Fee.End_Date; PlaneModel.GST = Fee.GST; FeeModel.Payment_Amount = Fee.Payment_Amount; FeeModel.Discount_On_Bill = Fee.Discount_On_Bill; if (Offer != null) { OfferModel.Name = Offer.Name; } PlaneModel.Name = Plane.Name; PlaneModel.Worth = Plane.Worth; StudentModel.Full_Name = Student.First_Name + " " + Student.Last_Name; FeeStudentPlaneOfferModel.FeeModel = FeeModel; FeeStudentPlaneOfferModel.OfferModel = OfferModel; FeeStudentPlaneOfferModel.PlaneModel = PlaneModel; FeeStudentPlaneOfferModel.StudentModel = StudentModel; FeeStudentPlaneOfferModelList.Add(FeeStudentPlaneOfferModel); } return(View(FeeStudentPlaneOfferModelList)); } catch (Exception ex) { return(RedirectToAction("Contact", "Home")); } }
// revert fee to client // transfer (return) amount from amountClientId to amountClientId // transfer (return) fee from feeClientId to amountClientId public async Task TransferRevertFee() { var clientId = ""; var feeClientId = ""; var amountClientId = ""; FeeModel fee = new FeeModel() { SourceClientId = feeClientId, TargetClientId = clientId, Size = 15, SizeType = FeeSizeType.ABSOLUTE, Type = FeeType.EXTERNAL_FEE }; var result = await _client.TransferAsync(Guid.NewGuid().ToString(), amountClientId, clientId, "USD", 2, 7, fee, 0); }
public async Task TransferAbsoluteFee() { var clientId = ""; var feeClientId = ""; var amountClientId = ""; FeeModel fee = new FeeModel() { SourceClientId = null, TargetClientId = feeClientId, Size = 15, SizeType = FeeSizeType.ABSOLUTE, Type = FeeType.CLIENT_FEE, ChargingType = FeeChargingType.SUBTRACT_FROM_AMOUNT }; var result = await _client.TransferAsync(Guid.NewGuid().ToString(), clientId, amountClientId, "USD", 2, 22, fee, 0); }
public async Task TransferPercentageFee() { var clientId = ""; var feeClientId = ""; var amountClientId = ""; FeeModel fee = new FeeModel { SourceClientId = null, TargetClientId = feeClientId, Size = 0.025, SizeType = FeeSizeType.PERCENTAGE, Type = FeeType.CLIENT_FEE, ChargingType = FeeChargingType.SUBTRACT_FROM_AMOUNT }; var result = await _client.TransferAsync(Guid.NewGuid().ToString(), clientId, amountClientId, "USD", 2, 11, fee, 0); }
public static async Task <List <FeeModel> > GetFees() { List <FeeModel> Fee = new List <FeeModel>(); using (SqlConnection dbConn = new SqlConnection(connectionString)) { var query = "SELECT * from Fee"; SqlDataReader reader; try { dbConn.Open(); SqlCommand cmd = new SqlCommand(query, dbConn); reader = await cmd.ExecuteReaderAsync(); if (reader.HasRows) { while (reader.Read()) { FeeModel FeeItem = new FeeModel(); FeeItem.ID = reader.GetInt32(0); FeeItem.Description = reader.GetString(1); FeeItem.Fee = reader.GetDecimal(2); Fee.Add(FeeItem); } } } catch (Exception ex) { reader = null; Console.WriteLine(ex); } finally { dbConn.Close(); } return(Fee); } }
/// <summary> /// Create brokerage model for internal usage /// </summary> /// <param name="accounttype"></param> /// <param name="feemodel"></param> /// <param name="fillmodel"></param> /// <param name="latencymodel"></param> /// <param name="margincallmodel"></param> /// <param name="marginmodel"></param> /// <param name="settlementmodel"></param> /// <param name="slippagemodel"></param> /// <param name="spreadmodel"></param> protected GenericBrokerModel( AccountType accounttype, FeeModel feemodel, FillModel fillmodel, LatencyModel latencymodel, MarginCallModel margincallmodel, MarginModel marginmodel, SettlementModel settlementmodel, SlippageModel slippagemodel, SpreadModel spreadmodel) { //Set given values AccountType = accounttype; FeeModel = feemodel; FillModel = fillmodel; LatencyModel = latencymodel; MarginCallModel = margincallmodel; SettlementModel = settlementmodel; SlippageModel = slippagemodel; MarginModel = marginmodel; SpreadModel = spreadmodel; }
internal static FeeModel GenerateTransferFee( this FeeModel feeModel, double amount, int accuracy) { var feeAbsolute = Math.Round(amount * feeModel.Size, 15).TruncateDecimalPlaces(accuracy, true); if (Math.Abs(feeAbsolute) > double.Epsilon) { return new FeeModel { Type = feeModel.Type, Size = feeAbsolute, SourceClientId = feeModel.SourceClientId, TargetClientId = feeModel.TargetClientId, SizeType = FeeSizeType.ABSOLUTE, ChargingType = feeModel.ChargingType } } ; return(null); }
protected void btnAddFH_Click(object sender, EventArgs e) { try { FeeModel FeeHead = new FeeModel(); FeeHead.FHName = txtFHN.Text; FeeHead.FHType = ddlFHT.SelectedIndex; FeeHead.UserName = Session["UserName"].ToString(); FeeHead.FRate = 0; FeeHead.IsPrimary = 0; string ReturnMessage = dal.InsertIntoFeeHead(FeeHead); if (ReturnMessage == "Transaction Successful") { lblError.Visible = false; lblSuccess.Visible = true; lblSuccess.Text = ReturnMessage; getFeeHeads(); txtFHN.Text = ""; ddlFHT.SelectedValue = "-1"; } else { lblError.Visible = true; lblSuccess.Visible = false; lblError.Text = ReturnMessage; } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.ToString(); } }
internal static double CalculateAmountWithFee( this FeeModel feeModel, double sourceAmount, int accuracy) { if (feeModel.Type == FeeType.EXTERNAL_FEE) { return(sourceAmount); } var amount = 0d; switch (feeModel.SizeType) { case FeeSizeType.ABSOLUTE: amount = sourceAmount > 0 ? sourceAmount + feeModel.Size : sourceAmount - feeModel.Size; break; case FeeSizeType.PERCENTAGE: amount = Math.Round(Math.Abs(sourceAmount) * (1 + feeModel.Size), 15); break; } return(amount.TruncateDecimalPlaces(accuracy, true)); }
public ActionResult Create(FeeModel model) { try { if (ModelState.IsValid) { var Fee = Mapper.Map <Fee>(model); Fee.Branch_ID = Convert.ToInt32(Session["Branvch_ID"]); Fee.GYM_ID = Convert.ToInt32(Session["GYM_ID"]); Fee.Payment_Date = DateTime.Now; var plane = db.Planes.Where(i => i.ID == model.Plane_ID).FirstOrDefault(); Fee.GST = model.GST; Fee.Status = true; Fee.Discount_On_Bill = model.Discount_On_Bill; db.Fees.Add(Fee); db.SaveChanges(); new Thread(new ThreadStart(() => { var dataExists = db.Students.Where(b => b.ID == model.Student_ID).FirstOrDefault(); if (dataExists != null) { dataExists.Status = true; dataExists.Current_Package_ID = Fee.Plane_ID; db.SaveChanges(); } })).Start(); TempData["Success"] = "Fees submitted sucessfully!!"; return(RedirectToAction("Bill", "Fee", new { ID = Fee.ID })); } else { int GYM_ID = Convert.ToInt32(Session["GYM_ID"]); int Branch_ID = Convert.ToInt32(Session["Branvch_ID"]); var Student = db.Students.Where(i => i.Branch_ID == Branch_ID).ToList(); List <StudentModel> StudentModelList = new List <StudentModel>(); foreach (var Full_Name in Student) { StudentModel StudentModel = new StudentModel(); StudentModel.Full_Name = Full_Name.First_Name + " " + Full_Name.Last_Name; StudentModel.ID = Full_Name.ID; StudentModelList.Add(StudentModel); } ViewBag.Student_NAME = StudentModelList; var Plane = db.Planes.Join(db.Branch_Wise_Plane, j => j.ID, u => u.Plane_ID, (j, u) => new { Branch_Plane = u, Plane = j }).Where(i => i.Branch_Plane.Branch_ID == Branch_ID && i.Branch_Plane.Status == true).ToList(); List <PlaneModel> PlaneModelList = new List <PlaneModel>(); foreach (var d in Plane) { PlaneModel planeModel = new PlaneModel(); planeModel.Name = d.Plane.Name; planeModel.ID = d.Plane.ID; PlaneModelList.Add(planeModel); } ViewBag.Planes_NAME = PlaneModelList; var Offer = db.Offers.Join(db.Branch_Wise_Offer, j => j.ID, u => u.Offer_ID, (j, u) => new { Branch_Wise_Offer = u, Offer = j }).Where(i => i.Branch_Wise_Offer.Branch_ID == Branch_ID && i.Branch_Wise_Offer.Status == true).ToList(); List <OfferModel> OfferModelList = new List <OfferModel>(); foreach (var d in Offer) { OfferModel OfferModel = new OfferModel(); OfferModel.Name = d.Offer.Name; OfferModel.ID = d.Offer.ID; OfferModelList.Add(OfferModel); } ViewBag.Offer_NAME = OfferModelList; var Planes = db.Planes.Where(i => i.GYM_ID == GYM_ID).ToList(); ViewBag.Planes_NAME = Planes; TempData["Error"] = "Please Fill All Required Details.!"; return(View()); } } catch (Exception ex) { return(RedirectToAction("Contact", "Home")); } }
protected void btnSaveNewFee_Click(object sender, DirectEventArgs e) { int featureId = Convert.ToInt32(cmbChargeableItems.SelectedItem.Value); FeeModel model = new FeeModel(featureId); model.ChargeAmount = (decimal)nfChargeAmount.Number; model.BaseAmount = (decimal)nfBaseAmount.Number; model.Rate = (decimal)nfRate.Number; FinancialProductForm form = this.CreateOrRetrieve<FinancialProductForm>(); form.AddFee(model); storeFee.DataSource = form.AvailableFees; storeFee.DataBind(); //AssignFees(); }
///<inheritdoc cref="IMatchingEngineClient"/> public Task <MeResponseModel> TransferAsync( string id, string fromClientId, string toClientId, string assetId, int accuracy, double amount, FeeModel feeModel, double overdraft, CancellationToken cancellationToken = default) { var amountToTransfer = amount.TruncateDecimalPlaces(accuracy, true); FeeModel fee = null; if (feeModel != null) { fee = feeModel.SizeType == FeeSizeType.PERCENTAGE // create absolute fee from percentage ? feeModel.GenerateTransferFee(amount, accuracy) : feeModel; switch (feeModel.ChargingType) { case FeeChargingType.RAISE_AMOUNT: amountToTransfer = fee?.CalculateAmountWithFee(amount, accuracy) ?? amountToTransfer; break; case FeeChargingType.SUBTRACT_FROM_AMOUNT: // default ME behavior - no any amoung change required break; default: if (feeModel.Type != FeeType.EXTERNAL_FEE) { throw new ArgumentOutOfRangeException(nameof(feeModel.ChargingType)); } break; } } var model = MeNewTransferModel.Create( id, fromClientId, toClientId, assetId, amountToTransfer, fee?.ToMeModel(), overdraft); string telemetryFeeSiteType = fee == null ? "" : fee.SizeType == FeeSizeType.PERCENTAGE ? " %" : " abs"; return(SendData( model, _newTasksManager, x => x.ToDomainModel(), _meResponsePolicy, cancellationToken, id, $"{assetId} with acc {accuracy} and fee size{telemetryFeeSiteType} {fee?.Size ?? 0}" )); }
public async Task <ActionResult> GetFees([FromBody] FeeFilterView model) { try { var schoolId = GetMySchoolId(); FeeStudentModelView FeeStudentView = new FeeStudentModelView(); //Get School // var school = await _schoolService.GetSchoolById(schoolId.ToString()); if (school == null) { return(BadRequest("School not valid")); } /// Get Active session from school var sessionToUse = school.GetActiveSession(); /// Update Current Session if user choose other session from filter if (model.SessionId.HasSomething()) { sessionToUse = school.Sessions.FirstOrDefault(x => x.Id == model.SessionId.AsObjectId()); } if (sessionToUse != null) { model.ActiveSessionName = sessionToUse.Name; var allClassesForSchool = await _schoolClassService.Get(x => x.SchoolId == school.Id && x.SessionId == sessionToUse.Id && x.DeactivateDate == null); var activeClassIds = allClassesForSchool.Select(x => x.Id); var student = await _studentService.Get( x => activeClassIds.Contains(x.ClassId) && x.DeactivateDate == null && x.SchoolId == school.Id && x.DeletedAt == null); if (!school.FeeCycles.Any()) { return(BadRequest("School has no feecylces")); } IEnumerable <Student> allstudent; if (model.ClassId != null) { allstudent = student.Where(x => x.ClassId == model.ClassId.AsObjectId()).ToList(); } else { allstudent = student; } if (model.StudentId != null) { allstudent = allstudent.Where(x => x.Id == model.StudentId.AsObjectId()); } if (model.StudentFeeFrequency != null && !model.StudentFeeFrequency.Contains("All")) { allstudent = allstudent.Where(x => x.FeeFrequency.ToString() == model.StudentFeeFrequency); } var allstudentIds = allstudent.Select(x => x.Id); var allCalculatedFee = new List <Fee>(); if (model.FeeCycleId != null) { allCalculatedFee = await _feeService.Get( x => allstudentIds.Contains(x.StudentId) && x.FeeCycleId == model.FeeCycleId.AsObjectId()); } else { var feeCycleIdsforSchool = school.FeeCycles.Where(x => x.SessionId == sessionToUse.Id).Select(x => x.Id); allCalculatedFee = await _feeService.Get( x => allstudentIds.Contains(x.StudentId) && feeCycleIdsforSchool.Contains(x.FeeCycleId)); } var students = student.Where(x => allstudentIds.Contains(x.Id)); var schoolComponents = school.SchoolFeeComponents; var allfeeCycle = school.FeeCycles; if (model.FeeStatus != null && !model.FeeStatus.Contains("All")) { allCalculatedFee = allCalculatedFee.Where(x => model.FeeStatus.Contains(x.FeeStatus.ToString())).ToList(); } if (allCalculatedFee.Count > 0) { var sortedFees = allCalculatedFee.OrderByDescending(x => x.CreatedAt) .ThenBy(x => x.FeeStatus == FeeStatus.PendingApproval); var classDict = allClassesForSchool.OrderBy(x => x.Name) .ToDictionary(x => x.Id.ToString(), x => x.Name); foreach (var fee in sortedFees) { var singleFeeModel = new FeeStudentModel { StudentId = fee.StudentId.ToString(), FeeId = fee.Id.ToString(), FeeStatus = EnumHelper.DisplayName(typeof(FeeStatus), fee.FeeStatus.ToString()), FeeStatusEnum = fee.FeeStatus, Remark = fee.Remark, CreateAt = fee.CreatedAt, Checked = true }; var singleStudent = students.FirstOrDefault(x => x.Id == fee.StudentId); singleFeeModel.ClassName = allClassesForSchool.First(x => x.Id == singleStudent.ClassId).Name; var feeCycleForFee = allfeeCycle.FirstOrDefault(x => x.Id == fee.FeeCycleId); var totalPayable = Math.Round(fee.GetPendingFee(DateTime.Now, feeCycleForFee, school, singleStudent.JoiningDate), 2); singleFeeModel.TotalPayable = totalPayable > 0 ? Math.Round(fee.GetPendingFee(DateTime.Now, feeCycleForFee, school, singleStudent.JoiningDate), 2) : 0; singleFeeModel.TotalPaid = fee.Transactions.Sum(x => x.Amount); singleFeeModel.FeeCycle = _mapperService.MapFeeCycleToFeeCycleSingleModel(feeCycleForFee); //var singleStudent = students.FirstOrDefault(x => x.Id == fee.StudentId); if (singleStudent != null) { singleFeeModel.StudentName = singleStudent.Name; singleFeeModel.AdmNumber = singleStudent.Identifier; singleFeeModel.StudentMotherName = singleStudent.MotherName; singleFeeModel.StudentClass = classDict.ContainsKey(singleStudent.ClassId.ToString()) ? classDict[singleStudent.ClassId.ToString()] : string.Empty; singleFeeModel.StudentFeeFrequency = EnumHelper.DisplayName( typeof(StudentFeeFrequency), singleStudent.FeeFrequency.ToString()); } if (Convert.ToDateTime(singleStudent.JoiningDate).ToLocalTime().Date > feeCycleForFee.LastDueDate.ToLocalTime().Date) { singleFeeModel.LateFee = Math.Round(fee.GetTotalLateFeesOfLateJoinedStudent(school, DateTime.Today, feeCycleForFee, Convert.ToDateTime(singleStudent.JoiningDate).ToLocalTime().Date), 2); } else { singleFeeModel.LateFee = Math.Round(fee.GetTotalLateFees(school, DateTime.Today, feeCycleForFee), 2); } //singleFeeModel.LateFee = fee.GetTotalLateFees(school, DateTime.Today, feeCycleForFee); if (fee.ApprovedBy != null || fee.CancelledBy != null) { singleFeeModel.ApprovedById = fee.ApprovedBy; singleFeeModel.CancelledById = fee.CancelledBy; } else { model.ToCheckUnapprovedStudents = model.ToCheckUnapprovedStudents + 1; } foreach (var component in fee.Components) { var singleComponentModel = new FeeModel { ComponentValue = component.Value, SchoolFeeComponentId = component.ComponetId.ToString() }; singleFeeModel.TotalFeeForStudent = Math.Round(singleFeeModel.TotalFeeForStudent + singleComponentModel.ComponentValue, 2); var singlecomponent = schoolComponents.FirstOrDefault(x => x.Id == component.ComponetId); if (singlecomponent != null) { singleComponentModel.ComponentName = singlecomponent.Name; } singleFeeModel.StudentAllFee = singleFeeModel.StudentAllFee != null ? singleFeeModel.StudentAllFee.Concat(new[] { singleComponentModel }).ToArray() : new[] { singleComponentModel }; singleFeeModel.ComponetDict = singleFeeModel.StudentAllFee.GroupBy( x => x.SchoolFeeComponentId.ToString()).ToDictionary( x => x.Key, x => x.First().ComponentValue); } FeeStudentView.FeeStudents = FeeStudentView.FeeStudents != null ? FeeStudentView.FeeStudents.Concat(new[] { singleFeeModel }).ToArray() : new[] { singleFeeModel }; } FeeStudentView.Maxdata = FeeStudentView.FeeStudents.OrderByDescending(x => x.StudentAllFee.Length).FirstOrDefault(); if (FeeStudentView.Maxdata != null) { FeeStudentView.FeeComponentWithDictinctValueDict = FeeStudentView.Maxdata.StudentAllFee.GroupBy(x => x.SchoolFeeComponentId) .ToDictionary(x => x.Key, x => x.First().ComponentValue ); } } } if (FeeStudentView.FeeStudents != null && FeeStudentView.FeeStudents.Length > 0) { FeeStudentView.FeeStudents = FeeStudentView.FeeStudents.OrderBy(x => x.FeeCycle.LastDueDate).ThenBy(x => x.StudentName).ToArray(); } if (FeeStudentView.FeeStudents != null) { foreach (var fee in FeeStudentView.FeeStudents) { if (fee.FeeCycle.LastDueDate.ToLocalTime().Date < DateTime.Today.Date) { fee.LateFee = fee.LateFee; } else { fee.LateFee = null; } } } return(Ok(FeeStudentView)); } catch (ArgumentNullException argNullEx) { return(BadRequest(argNullEx.Message)); } catch (ArgumentException argEx) { return(BadRequest(argEx.Message)); } catch (Exception ex) { return(StatusCode(500, ex)); } }