Exemplo n.º 1
0
        public async Task <Unit> Handle(AddFeePaymentCommand request, CancellationToken cancellationToken)
        {
            var fee = new FeePayment(request.ManagementContractId, request.ScheduledPaymentAmt, request.ActualPaymentAmt,
                                     request.PayMethod, request.MangementFeeType, request.PaymentDueDate, request.PaymentReceivedDate, request.IsOnTime,
                                     request.InChargeOwnerId, request.Note, request.FeeForMonth, request.FeeForYear, DateTime.Now, DateTime.Now);

            _context.FeePayment.Add(fee);

            try
            {
                await _context.SaveChangesAsync();

                // logging
                Log.Information("Fee payment on contract {ContractId} has been added successfully", fee.ManagementContractId);

                // Send messages if necessary
            }
            catch (Exception ex)
            {
                //throw ex;
                Log.Error(ex, "Error occured while adding fee payment on contract {ContractId}.", fee.ManagementContractId);
            }

            return(await Unit.Task);

            //throw new NotImplementedException();
        }
        public async Task <ActionResult> Confirm(int id = 0)
        {
            var selectedGateway = await _paymentGateWayService.GetById(id);

            string UserId          = UserHelperInfo.GetUserId();
            var    selectedStudent = _studentService.GetStudentByUserId(UserId);

            if (selectedStudent == null)
            {
                return(HttpNotFound("Student Not Found In DB"));
            }
            var LastAdmission = await _admissionService.GetLastAdmission(selectedStudent.ID);

            FeePayment feePayment = new FeePayment
            {
                PaymentGateway   = selectedGateway,
                PaymentGatewayId = selectedGateway.ID,
                Id          = 0,
                AdmissionId = LastAdmission.AdmissionID,
                IP          = UserInfo.IP(),
                Agent       = UserInfo.Agent()
            };

            return(View(feePayment));
        }
Exemplo n.º 3
0
        public async Task ClosePosition(int accountId)
        {
            var account = await this.accountRepository
                          .All()
                          .FirstOrDefaultAsync(a => a.Id == accountId);

            var position          = account.Positions.FirstOrDefault(p => p.OpenClose == OpenClose.Open);
            var currentStockPrice = datasetsRepository
                                    .All()
                                    .OrderByDescending(d => d.DateAndTime)
                                    .Select(d => d.ClosePrice)
                                    .FirstOrDefault();

            if (position != null)
            {
                position.OpenClose  = OpenClose.Close;
                position.ClosePrice = currentStockPrice;
                account.Balance    -= account.TradeFee;
                account.Balance    += position.CountStocks * currentStockPrice;
                var tradeFee = new FeePayment
                {
                    Amount  = account.TradeFee,
                    TypeFee = TypeFee.TradeFee,
                };

                account.Fees.Add(tradeFee);
                await this.accountRepository.SaveChangesAsync();
            }
        }
Exemplo n.º 4
0
        // GET: Suggestion/Delete/5
        public ActionResult Delete(FeePayment IdDel)
        {
            var d = db.FeePayments.Where(x => x.id == IdDel.id).FirstOrDefault();

            db.FeePayments.Remove(d);
            db.SaveChanges();
            return(RedirectToAction("AllDetail"));
        }
Exemplo n.º 5
0
        // POST api/fee
        public void Post(FeePayment fp)
        {
            ArrayOfStudent students = XmlFileUtil.Deserialize();
            Student        student  = students.studentsList.FirstOrDefault((s) => s.StudentID == fp.StudentID);

            // sort fee by payment type
            if (fp.paymentType == "Rank")
            {
                student.fees.Sort(delegate(Fee x, Fee y)
                {
                    return(x.Rank.CompareTo(y.Rank));
                });
            }
            else if (fp.paymentType == "Date")
            {
                student.fees.Sort(delegate(Fee x, Fee y)
                {
                    return(x.DueDate.CompareTo(y.DueDate));
                });
            }

            List <Fee> newFees = new List <Fee>();
            double     payment = 0;

            double.TryParse(fp.amount, out payment);

            //calculate fee payments
            foreach (Fee f in student.fees)
            {
                double amountAssessed = 0;
                double amountPaid     = 0;

                double.TryParse(f.AmountAssessed, out amountAssessed);
                double.TryParse(f.AmountPaid, out amountPaid);

                if (amountPaid < amountAssessed)
                {
                    if (payment + amountPaid < amountAssessed)
                    {
                        f.AmountPaid = Math.Round(payment + amountPaid, 2).ToString();
                        payment      = 0;
                    }
                    else
                    {
                        f.AmountPaid = amountAssessed.ToString();
                        payment      = Math.Round(payment + amountPaid - amountAssessed, 2);
                    }
                }

                newFees.Add(f);
            }

            student.fees = newFees;

            // save to xml
            XmlFileUtil.SaveStudent(student);
        }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            FeePayment feePayment = await Db.FeePayments.FindAsync(id);

            Db.FeePayments.Remove(feePayment);
            await Db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 7
0
 public ActionResult Create([Bind(Exclude = "id")] FeePayment tech)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     db.FeePayments.Add(tech);
     db.SaveChanges();
     //Response.Redirect("StudentAdmission",true);
     return(RedirectToAction("AllDetail"));
 }
Exemplo n.º 8
0
        public ActionResult Edit(FeePayment IdEdit)
        {
            var orignalRecord = (from m in db.FeePayments where m.id == IdEdit.id select m).First();

            if (!ModelState.IsValid)
            {
                return(View(orignalRecord));
            }
            db.Entry(orignalRecord).CurrentValues.SetValues(IdEdit);

            db.SaveChanges();
            return(RedirectToAction("AllDetail"));
        }
        // GET: FeePayments/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            FeePayment feePayment = await Db.FeePayments.FindAsync(id);

            if (feePayment == null)
            {
                return(HttpNotFound());
            }
            return(View(feePayment));
        }
        public async Task <ActionResult> Confirm(FeePayment feePayment)
        {
            feePayment.ModifiedOn    = DateTimeHelper.Now();
            var(IsTrue, ResponseMsg) = await _feePaymentService.Save(feePayment);

            if (IsTrue)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                ModelState.AddModelError("Error", ResponseMsg);
                return(View(feePayment));
            }
        }
        public async Task TakeAllAccountsMonthlyFeesAsync()
        {
            var openAccounts = await this.accountRepository
                               .All()
                               .Where(a => !a.IsDeleted)
                               .ToListAsync();

            foreach (var account in openAccounts)
            {
                var tradeFee = new FeePayment
                {
                    Amount  = account.MonthlyFee,
                    TypeFee = TypeFee.MonthlyCommission,
                };
                account.Balance -= tradeFee.Amount;
                account.Fees.Add(tradeFee);
                await this.accountRepository.SaveChangesAsync();
            }
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,StudentId,FeeName,Term,Session,PaidFee,TotalAmount,PaymentMode,Date")] FeePayment feePayment)
        {
            if (ModelState.IsValid)
            {
                feePayment.SchoolId = userSchool;
                Db.FeePayments.Add(feePayment);
                await Db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            DateTime datetime = new DateTime();

            datetime          = DateTime.Now.Date;
            ViewBag.Date      = datetime.ToShortDateString();
            ViewBag.StudentId = new SelectList(Db.Students.AsNoTracking(), "StudentID", "FullName");
            ViewBag.FeeName   = new SelectList(Db.FeeTypes.AsNoTracking(), "FeeName", "FeeName");
            ViewBag.Session   = new SelectList(Db.Sessions.AsNoTracking(), "SessionName", "SessionName");
            ViewBag.Term      = new SelectList(Db.Terms.AsNoTracking(), "TermName", "TermName");
            return(View(feePayment));
        }
Exemplo n.º 13
0
        public async Task <(bool IsTrue, string ResponseMsg)> Save(FeePayment feePayment)
        {
            if (feePayment.Id > 0)
            {
                _context.Entry(feePayment).State = EntityState.Modified;
            }
            else
            {
                _context.FeePayments.Add(feePayment);
            }

            try
            {
                return(await _context.SaveChangesAsync() > 0, Result.Success);
            }
            catch (Exception exc)
            {
                return(false, exc.ToString());
            }
        }
        public void PayFees(FeePayment feePayment, int branchId)
        {
            var receipt = new Receipt()
            {
                AmountPaid      = feePayment.Amount,
                BranchId        = branchId,
                CreatedBy       = feePayment.UserId,
                UpdatedBy       = feePayment.UserId,
                CreatedDate     = DateTime.Now,
                UpdatedDate     = DateTime.Now,
                PaymentMethodId = feePayment.PaymentModeId,
                ReceiptDate     = feePayment.ReceiptDate,
                Reference       = feePayment.Reference
            };

            receipt = _recieptRepository.Save(receipt);
            var studentAssign = _studentAssignmentRepository.Get(feePayment.StudentAssignmentId);

            studentAssign.ReceiptId = receipt.Id;
            _studentAssignmentRepository.Save(studentAssign);
        }
Exemplo n.º 15
0
        public FeePayment MakePayment(int student, int course, PaymentMethod method, decimal amount)
        {
            if (student < 1)
            {
                throw new LepadException("Payment failed! Invalid student id.");
            }

            var _student = _repos.Students.GetWith(student, "Payments");

            if (_student == null)
            {
                throw new LepadException("Payment failed! Student record not found.");
            }

            var payment = new FeePayment()
            {
                Amount    = amount,
                IsGeneral = true,
                Method    = method,
                StudentId = student,
                CourseId  = course
            };

            payment = _repos.FeePayments.Create(payment);
            _repos.Commit();

            if (_student.Payments == null)
            {
                _student.Payments = new List <FeePayment>();
            }
            ;
            _student.Payments.Add(payment);
            _student = _repos.Students.Update(_student);
            _repos.Commit();

            return(payment);
        }