Ejemplo n.º 1
0
        // GET: BillGenerator
        public IActionResult Index()
        {
            ViewData["items"] = new SelectList(_uow.ItemRepository.GetAll(), "Id", "Name");
            TotalBillViewModel totalBillViewModel = new TotalBillViewModel();

            totalBillViewModel.BillGeneratorViewModels = _uow.BillGeneratorRepository.GetBillList();
            calculateTotal(totalBillViewModel.BillGeneratorViewModels, ref totalBillViewModel);
            return(View(totalBillViewModel));
        }
Ejemplo n.º 2
0
        private void calculateTotal(List <BillGeneratorViewModel> billGeneratorViewModels, ref TotalBillViewModel totalBillViewModel)
        {
            double totalItems    = 0;
            double totalDiscount = 0;
            double totalGST      = 0;
            double grandTotal    = 0;

            foreach (var item in billGeneratorViewModels)
            {
                totalItems    += item.ItemCount;
                totalDiscount += item.TotalDiscountPerItems;
                totalGST      += item.TotalGSTPerItems;
                grandTotal    += item.ItemTotal;
            }

            totalBillViewModel.ItemsCount    = totalItems;
            totalBillViewModel.TotalDiscount = totalDiscount;
            totalBillViewModel.TotalGST      = totalGST;
            totalBillViewModel.GrandTotal    = grandTotal;
        }