public ActionResult Bill(int id, CreateBillInput billInput, int ActivityId)
        {
            var dealer = _dealerAppService.GetDealer(id);


            if (dealer != null)
            {
                var revenue = _revenueSourceAppService.GetRevenueResource(ActivityId);
                var items   = _allocatedPlotAppService.GetAllocatedPlotsByDealer(dealer);
                var user    = _userAppService.GetLoggedInUser();
                var Fyear   = _financialYearAppService.GetActiveFinancialYear();

                //Dealer Registration Bill

                int bill = _billAppService.CreateBill(billInput);
                if (bill > 0)
                {
                    foreach (var item in items)
                    {
                        var billItem = new CreateBillItemInput
                        {
                            BillId      = bill,
                            ActivityId  = ActivityId,
                            Description = revenue.Description,
                            Loyality    = item.Loyality,
                            TFF         = item.TFF,
                            LMDA        = item.LMDA,
                            CESS        = item.CESS,
                            VAT         = item.VAT,
                            TP          = item.TP,
                            Total       = item.TOTAL
                        };

                        _billItemAppService.CreateBillItem(billItem);
                    }
                    var License = new CreateLicenseInput
                    {
                        BillId          = bill,
                        FinancialYearId = Fyear.Id,
                        StationId       = user.StationId,
                        IssuedDate      = DateTime.Now
                    };

                    _licenseAppService.CreateLicense(License);// Create Licence under pending status

                    return(RedirectToAction("ApplicationBill", "PlotAllocation", new { id = bill }));
                }
            }

            return(RedirectToAction("Index", new { id = id }));
        }
Exemple #2
0
        public void CreateLicense(CreateLicenseInput input)
        {
            //get current active financial year;
            var current = _financialYearRepository.FirstOrDefault(c => c.IsActive == true);

            Random random = new Random();

            if (current != null)
            {
                var license = new License
                {
                    serialNumber    = random.Next(input.BillId, 1000000).ToString(),
                    FinancialYearId = current.Id,
                    StationId       = input.StationId,
                    BillId          = input.BillId,
                    IssuedDate      = input.IssuedDate
                };
                _licenseRepository.Insert(license);
            }
            else
            {
                throw new UserFriendlyException("No Active Financial Year");
            }
        }