예제 #1
0
        public CancelBookingViewModel GetCancelledBooking(int transId)
        {
            CancelBookingViewModel cancelledBooking = null;

            var booking = (from b in _dbcontext.Bookings where b.trn_Id.Equals(transId) select b).FirstOrDefault();

            if (booking != null)
            {
                cancelledBooking = new CancelBookingViewModel()
                {
                    TransId          = booking.trn_Id,
                    CustomerFullname = Utilities.getfullname(booking.Customer.lastname, booking.Customer.firstname, booking.Customer.middle),
                    EventDate        = (DateTime)booking.startdate,
                    PackageDesc      = booking.Package.p_descripton,
                    NoofPax          = (int)booking.noofperson,
                    Venue            = booking.venue,
                    CancelDate       = DateTime.Now,
                    AmountDue        = bookingPayments.Get_TotalAmountBook(transId),
                    AmountPaid       = transdetails.GetTotalPaymentByTrans(transId),
                };
            }

            _dbcontext.Dispose();

            return(cancelledBooking);
        }
예제 #2
0
        public IEnumerable <RefundsViewModel> GetAllRefundsList()
        {
            List <RefundsViewModel> listRefunds = new List <RefundsViewModel>();

            try
            {
                IEnumerable <Booking> bookings = (from booking in dbentities.Bookings select booking).ToList();


                listRefunds = (from b in bookings
                               select new
                {
                    _tId = b.trn_Id,
                    _trEvtDate = b.startdate,
                    _cusId = b.c_Id,
                    _cusfullname = Utilities.getfullname(b.Customer.lastname, b.Customer.firstname, b.Customer.middle),
                    _occasion = b.occasion,
                    _evtVenue = b.venue,
                    _iscancelledbooking = b.is_cancelled,
                    _serveStat = b.serve_stat,
                    _tpackageAmt = bookingPayments.Get_TotalAmountBook(b.trn_Id),
                    _totapayment = (from p in dbentities.Payments select p).Where(s => s.trn_Id == b.trn_Id).Sum(x => x.amtPay),
                    _hasrefundEntry = (from rp in dbentities.Refunds select rp).Any(x => x.trn_Id == b.trn_Id),
                    _stat = " "

                            //}).ToList().Where(t=> t._serveStat==false || t._iscancelledbooking==true) .Select(book => new RefundsViewModel()
                }).ToList().Where(t => t._serveStat == false).Select(book => new RefundsViewModel()
                {
                    TransId        = book._tId,
                    cId            = (int)book._cusId,
                    CustomerName   = book._cusfullname,
                    EventLocation  = book._evtVenue,
                    Eventdate      = (DateTime)book._trEvtDate,
                    isCancelled    = (bool)book._iscancelledbooking,
                    PaymemntAmount = Convert.ToDecimal(book._totapayment),
                    RefundAmount   = book._totapayment > book._tpackageAmt?Convert.ToDecimal(book._totapayment - book._tpackageAmt):0,
                    //RefundAmount =book._iscancelledbooking==false? Convert.ToDecimal(book._totapayment - book._tpackageAmt): Convert.ToDecimal(book._totapayment),
                    hasrefundEntry = book._hasrefundEntry,
                    Status         = book._stat
                }).ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }



            return(listRefunds);
        }
예제 #3
0
        public IEnumerable <AccnRecieveSummaryViewModel> GetAllAccnRecievables()
        {
            List <AccnRecieveSummaryViewModel> listAccn = new List <AccnRecieveSummaryViewModel>();
            var _dbentities     = new PegasusEntities();
            var bookingPayments = new BookingPaymentsViewModel();
            var transdetails    = new TransactionDetailsViewModel();
            var bookingRefund   = new BookingRefundViewModel();


            try
            {
                var bookings = (from booking in _dbentities.Bookings where booking.is_cancelled == false select booking).OrderBy(x => x.Customer.lastname).ToList();

                listAccn = (from b in bookings
                            //let daydue = Convert.ToDateTime(b.transdate).AddDays(30)
                            let eventdatedue = Convert.ToDateTime(b.startdate).AddDays(30)
                                               where b.startdate != null && DateTime.Now.Subtract((DateTime)b.startdate).Days >= 0
                                               select new AccnRecieveSummaryViewModel
                {
                    cusId = Convert.ToInt32(b.c_Id),
                    cusname = Utilities.getfullname(b.Customer.lastname, b.Customer.firstname, b.Customer.middle),
                    transId = b.trn_Id,
                    transDate = Convert.ToDateTime(b.startdate),
                    duedate = eventdatedue,
                    daysOdd = Convert.ToInt32(DateTime.Now.Subtract(eventdatedue).Days) <= 0
                            ? 0
                            : Convert.ToInt32(DateTime.Now.Subtract(eventdatedue).Days),

                    balance = bookingPayments.Get_TotalAmountBook(b.trn_Id) -
                              transdetails.GetTotalPaymentByTrans(b.trn_Id)
                }).ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(listAccn.Where(x => x.balance > 0).ToList());
        }
예제 #4
0
        public IEnumerable <CustomerBookingsViewModel> GetCusBookings()
        {
            var _dbEntities = new PegasusEntities();


            List <CustomerBookingsViewModel> lst = new List <CustomerBookingsViewModel>();

            try
            {
                List <Booking> listbookings = new List <Booking>();
                listbookings = (from b in _dbEntities.Bookings select b).ToList();

                lst = (from l in listbookings
                       select new CustomerBookingsViewModel()
                {
                    transId = l.trn_Id,
                    cusId = l.c_Id,
                    cusfullname = Utilities.getfullname_nonreverse(l.Customer.lastname, l.Customer.firstname, l.Customer.middle),
                    occasion = l.occasion,
                    venue = l.venue,
                    bookdatetime = l.startdate,
                    package = l.Package.p_descripton,
                    packageType = l.Package.p_type.Trim(),
                    packageDue = bookingPayments.Get_TotalAmountBook(l.trn_Id),
                    isServe = Convert.ToBoolean(l.serve_stat),
                    isCancelled = Convert.ToBoolean(l.is_cancelled),
                    bookingtype = l.booktype?.Trim() ?? "",
                    transType = "bk"
                }).ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }


            return(lst);
        }
예제 #5
0
        public IEnumerable <TransRecievablesViewModel> GetAllRecievables(IQueryable <Booking> tBookings)
        {
            List <TransRecievablesViewModel> recievable_list = new List <TransRecievablesViewModel>();

            try
            {
                IEnumerable <Booking> bookings = tBookings.ToList();



                recievable_list = (from b in bookings
                                   select new
                {
                    _tId = b.trn_Id,
                    _trDate = b.transdate,
                    _evtDate = b.startdate,
                    _cusId = b.c_Id,
                    _cusfullname =
                        Utilities.getfullname(b.Customer.lastname, b.Customer.firstname, b.Customer.middle),
                    _address = b.Customer.address,
                    _contact = b.Customer.contact1,
                    _occasion = b.occasion,
                    _venue = b.venue,
                    _iscancelledbooking = b.is_cancelled,
                    _packagedetails = b.Package.p_descripton,
                    _pAmountperPax = b.Package.p_amountPax,
                    _tpackageAmt = bookingPayments.Get_TotalAmountBook(b.trn_Id),
                    _totapayment = (from p in db_entities.Payments select p).Where(s => s.trn_Id == b.trn_Id)
                                   .Sum(x => x.amtPay),
                    _refunds = (from re in db_entities.Refunds select re).FirstOrDefault(t => t.trn_Id == b.trn_Id)
                }).Select(p => new TransRecievablesViewModel()
                {
                    transId            = p._tId,
                    transDate          = Convert.ToDateTime(p._trDate),
                    bookdatetime       = Convert.ToDateTime(p._evtDate),
                    cusId              = Convert.ToInt32(p._cusId),
                    cusfullname        = p._cusfullname,
                    address            = p._address,
                    contact            = p._contact,
                    occasion           = p._occasion,
                    venue              = p._venue,
                    iscancelled        = Convert.ToBoolean(p._iscancelledbooking),
                    packagedetails     = p._packagedetails,
                    p_amountperPax     = Convert.ToDecimal(p._pAmountperPax),
                    totalPackageAmount = p._tpackageAmt,
                    totalPayment       = Convert.ToDecimal(p._totapayment),
                    //balance = Convert.ToDecimal(p._totapayment)> p._tpackageAmt?Convert.ToDecimal(p._refunds) > 0 ? Convert.ToDecimal(((p._tpackageAmt - p._totapayment) + Convert.ToDecimal(p._refunds.rf_Amount))) : Convert.ToDecimal(p._tpackageAmt - p._totapayment): p._tpackageAmt,
                    balance = Convert.ToDecimal(p._totapayment) > p._tpackageAmt ? p._refunds != null ? Convert.ToDecimal(((p._tpackageAmt - p._totapayment) + Convert.ToDecimal(p._refunds.rf_Amount))) : Convert.ToDecimal(p._tpackageAmt - p._totapayment) : p._refunds != null?0: p._tpackageAmt == p._totapayment?0: p._tpackageAmt > p._totapayment?Convert.ToDecimal(p._tpackageAmt - p._totapayment):p._tpackageAmt,
                    refunds = p._refunds != null ? Convert.ToDecimal(p._refunds.rf_Amount) : 0
                }).ToList();
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }



            return(recievable_list);
        }