Exemplo n.º 1
0
        public IEnumerable <SalesSummaryViewModel> GetSalesSummary()
        {
            List <SalesSummaryViewModel> listofSales  = new List <SalesSummaryViewModel>();
            TransRecievablesViewModel    t            = new TransRecievablesViewModel();
            TransactionDetailsViewModel  transdetails = new TransactionDetailsViewModel();
            PegasusEntities db_entities = new PegasusEntities();

            try
            {
                IEnumerable <Booking> bookings = (from booking in db_entities.Bookings select booking).ToList();
                listofSales = (from b in bookings join p in db_entities.Payments on b.trn_Id equals p.trn_Id
                               select new SalesSummaryViewModel()
                {
                    transId = b.trn_Id,
                    accountname = Utilities.getfullname(b.Customer.lastname, b.Customer.firstname, b.Customer.middle),
                    dateTrans = Convert.ToDateTime(p.dateofPayment),
                    reference = p.particular,
                    particular = b.Package.p_descripton,
                    CashSales = Convert.ToDecimal(p.amtPay),
                    OnAccount = transdetails.GetTotalBookingAmount(b.trn_Id) - transdetails.GetTotalPaymentByTrans(b.trn_Id)
                }).ToList();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }


            return(listofSales.ToList());
        }
Exemplo n.º 2
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());
        }