コード例 #1
0
        public IActionResult SearchRevenue(int days)
        {
            if (days < 7)
            {
                return(View("AdminMenu"));
            }
            var model  = new RevenueViewModel();
            var orders = _context.GetOrdersByDateRange(model.Today, days);

            foreach (var order in orders)
            {
                var customer = _context.Get <User>(order.UserEntityID);
                var store    = _context.GetStoreByID(order.StoreEntityID);
                var history  = new HistoryViewModel();

                history.Customer = customer.Name;
                history.Store    = store.Name;
                history.Order    = order;

                model.PizzaAmount += order.Pizzas.Count;
                model.SalesTotal  += order.GetTotalAmount();
                model.History.Add(history);
            }

            return(View("Revenue", model));
        }
コード例 #2
0
        public void GetRevenueByYear_ValidDateTime_ReturnDatePropertyInCorrectFormatForYear()
        {
            DateTime dateTest = new DateTime(2020, 4, 1);

            RevenueViewModel dateTimeVM = _sut.GetRevenueByYear(dateTest);

            dateTimeVM.Date.Should().Be("2020");
        }
コード例 #3
0
        public RevenueViewModel GetRevenueByYear(DateTime dateTime)
        {
            var revenueVM = new RevenueViewModel();

            revenueVM.Date    = dateTime.Date.ToString("yyyy");
            revenueVM.Revenue = CalculateRevenueByYear(dateTime);
            return(revenueVM);
        }
コード例 #4
0
 public CMSController(ApplicationDbContext db)
 {
     _db       = db;
     RevenueVM = new RevenueViewModel()
     {
         Register = new Dictionary <string, int>(),
         Revenue  = new Dictionary <string, double>(),
     };
 }
コード例 #5
0
 public ActionResult Add(RevenueViewModel model)
 {
     if (ModelState.IsValid)
     {
         var modelDAO = Mapper.Map <Finance>(model);
         _unitOfWork.FinanceRepository.Add(modelDAO);
         _unitOfWork.SaveChanges();
         return(RedirectToAction("ShowForCategory", new { categoryId = model.CategoryId }));
     }
     return(View(model));
 }
コード例 #6
0
        public ActionResult Add(int categoryId)
        {
            var category = _unitOfWork.CategoryRepository.GetDetail(x => x.Id == categoryId);
            var model    = new RevenueViewModel()
            {
                CategoryId   = category.Id,
                CategoryName = category.Name
            };

            return(View(model));
        }
コード例 #7
0
        private RevenueViewModel GetRevenueOverview(IEnumerable <CsmsOrder> orders)
        {
            RevenueViewModel result = new RevenueViewModel();

            result.Total           = orders.Where(n => n.CompletedTime.HasValue).Sum(n => n.Total);
            result.CompletedOrders = orders.Where(n => n.CompletedTime.HasValue).Count();
            result.CanceledOrders  = orders.Where(n => n.CanceledTime.HasValue).Count();
            result.TotalOrders     = result.CompletedOrders + result.CanceledOrders;

            return(result);
        }
コード例 #8
0
        public ActionResult Create(long?id)
        {
            RevenueViewModel viewModel = new RevenueViewModel
            {
                Accounts   = accountService.GetAll(),
                Categories = categoryService.GetAll(),
                Customers  = customerService.GetAll(),
                Id         = id ?? 0
            };

            return(View(viewModel));
        }
コード例 #9
0
 public ActionResult Edit(RevenueViewModel model)
 {
     if (ModelState.IsValid)
     {
         var finanse = _unitOfWork.FinanceRepository.GetDetail(x => x.Id == model.Id);
         finanse.Name           = model.Name;
         finanse.Value          = model.Price;
         finanse.CreateDateTime = DateTime.Now;
         finanse.TimeEvent      = model.TimeEvent;
         _unitOfWork.SaveChanges();
         return(RedirectToAction("ShowForCategory", new { categoryId = model.CategoryId }));
     }
     return(View(model));
 }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: kavrat/MyWallet
 public ActionResult AddRevenue(RevenueViewModel revenue)
 {
     try
     {
         if (ModelState.IsValid)
         {
             db.Activities.Add(new Activities
             {
                 Amount      = revenue.Amount,
                 Description = revenue.Description,
                 Date        = DateTime.Now,
                 OpId        = revenue.OpId
             });
             db.SaveChanges();
         }
         return(new HttpStatusCodeResult(HttpStatusCode.OK));
     }
     catch (Exception e)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
 }
コード例 #11
0
        public void GetAllRevenues_Test()
        {
            //Arrange
            var mock = new Mock <IDbContext>();

            mock.Setup(x => x.Set <Revenue>())
            .Returns(new FakeDbSet <Revenue>
            {
                new Revenue()
                {
                    Name = "I Urząd Skarbowy testowy", City = "Testowe", Street = "Testowa"
                }
            });

            RevenueViewModel dvm = new RevenueViewModel(null, mock.Object);

            // Act
            var allRevenues = dvm.GetAllRevenues();

            // Assert
            Assert.AreEqual(1, allRevenues.Count());
        }
コード例 #12
0
        protected override async Task OnInitializedAsync()
        {
            IsDataLoaded = false;


            if (string.IsNullOrEmpty(revenueId))
            {
                revenue = new RevenueViewModel();
                revenue.transactionDate = DateTime.Today;
                revenue.cashOrCheck     = "0";
            }
            else
            {
                var id = Guid.Parse(revenueId);

                var data = await appDBContext.Revenues
                           .Include(a => a.account)
                           .Include(a => a.cashAccount)
                           .Include(a => a.propertyDirectory)
                           .Include(a => a.checkDetails)
                           .Where(r => r.id.Equals(id)).FirstOrDefaultAsync();

                revenue = new RevenueViewModel()
                {
                    id            = data.id.ToString(),
                    glAccountCode = data.account.accountCode,
                    glAccountName = data.account.accountDesc,
                    amount        = data.cashOrCheck.Equals("0") ? data.amount : data.checkDetails.amount,
                    cashOrCheck   = data.cashOrCheck
                };
            }

            revenue.revenueAccounts = await appDBContext.GLAccounts.Where(a => a.revenue || a.cashAccount).ToListAsync();

            revenue.propertyDirectories = await appDBContext.PropertyDirectory.Include(a => a.property).Include(a => a.tenant).ToListAsync();

            IsDataLoaded = true;
        }
コード例 #13
0
        public ActionResult Revenue()
        {
            var data = new RevenueViewModel[]
            {
                new RevenueViewModel("Oct1", 686.55, 1199.96, 1540.66),
                new RevenueViewModel("Oct 2", 1637.77, 1790.78, 1181.57),
                new RevenueViewModel("Oct 3", 1337.28, 2040.39, 491.7),
                new RevenueViewModel("Oct 4", 2388, 2063.29, 2012.99),
                new RevenueViewModel("Oct 5", 6877.44, 4861.67, 1472.12),
                new RevenueViewModel("Oct 6", 5772.99, 636.62, 4042.37),
                new RevenueViewModel("Oct 7", 1592, 2042.68, 986.38),
                new RevenueViewModel("Oct 8", 9078.38, 1996.88, 2687.96),
                new RevenueViewModel("Oct 9", 13374.79, 4586.87, 4246.5),
                new RevenueViewModel("Oct 10", 4881.47, 4602.9, 2874.21),
                new RevenueViewModel("Oct 11", 8996.79, 6482.99, 2354.2),
                new RevenueViewModel("Oct 12", 13356.88, 1852.61, 2680.51),
                new RevenueViewModel("Oct 13", 5753.09, 2502.97, 5825.9),
                new RevenueViewModel("Oct 14", 5834.68, 4586.87, 6736.29),
                new RevenueViewModel("Oct 15", 13374.79, 6886.03, 4495.33),
                new RevenueViewModel("Oct 16", 15545.88, 11470.61, 5787.16),
                new RevenueViewModel("Oct 17", 7446.58, 9173.74, 17960.46),
                new RevenueViewModel("Oct 18", 15545.88, 6881.45, 6345.91),
                new RevenueViewModel("Oct 19", 15705.08, 11454.58, 7447.02),
                new RevenueViewModel("Oct 20", 17734.88, 4653.28, 3038.11),
                new RevenueViewModel("Oct 21", 9004.75, 7085.26, 2108.35),
                new RevenueViewModel("Oct 22", 11307.18, 6624.97, 487.23),
                new RevenueViewModel("Oct 23", 4881.47, 7914.24, 2956.16),
                new RevenueViewModel("Oct 24", 15048.38, 9647.77, 4152.63),
                new RevenueViewModel("Oct 25", 4845.65, 10458.43, 4817.17),
                new RevenueViewModel("Oct 26", 13494.19, 14972.02, 15767.18),
                new RevenueViewModel("Oct 27", 15703.09, 10653.08, 7970.01),
                new RevenueViewModel("Oct 28", 17892.09, 2825.86, 2617.93),
                new RevenueViewModel("Oct 29", 398, 535.86, 981.91),
                new RevenueViewModel("Oct 30", 3980, 1731.24, 2744.58),
                new RevenueViewModel("Oct 31", 3765.08, 535.86, 1983.19),
                new RevenueViewModel("Nov 1", 9733.09, 989.28, 1145.81),
                new RevenueViewModel("Nov 2", 8660.48, 1552.62, 4264.38),
                new RevenueViewModel("Nov 3", 2455.66, 10458.43, 13053.89),
                new RevenueViewModel("Nov 4", 15703.09, 5374.63, 4413.38),
                new RevenueViewModel("Nov 5", 7802.79, 10586.67, 11857.42),
                new RevenueViewModel("Nov 6", 17734.88, 15063.62, 5083.88),
                new RevenueViewModel("Nov 7", 13494.19, 10675.98, 7835.91),
                new RevenueViewModel("Nov 8", 17486.13, 2381.6, 1667.31),
                new RevenueViewModel("Nov 9", 17892.09, 4371.61, 1777.57),
                new RevenueViewModel("Nov 10", 11506.18, 8003.55, 15536.23),
                new RevenueViewModel("Nov 11", 21854.18, 5491.42, 6739.27),
                new RevenueViewModel("Nov 12", 25141.66, 6077.66, 3879.96),
                new RevenueViewModel("Nov 13", 13713.09, 13378.18, 6034.5),
                new RevenueViewModel("Nov 14", 3765.08, 8143.24, 6551.53),
                new RevenueViewModel("Nov 15", 28878.88, 14273.57, 3216.91),
                new RevenueViewModel("Nov 16", 9076.39, 5983.77, 2622.4),
                new RevenueViewModel("Nov 17", 5120.27, 7905.08, 10367.42),
                new RevenueViewModel("Nov 18", 18600.53, 15507.88, 10067.93),
                new RevenueViewModel("Nov 19", 15506.08, 5846.37, 15847.64),
                new RevenueViewModel("Nov 20", 17563.74, 10927.88, 12329.75),
                new RevenueViewModel("Nov 21", 15790.65, 18065.81, 13643.93),
                new RevenueViewModel("Nov 22", 38275.66, 5436.46, 3374.85),
                new RevenueViewModel("Nov 23", 15370.76, 17990.24, 4166.04),
                new RevenueViewModel("Nov 24", 17911.99, 5370.05, 15551.13),
                new RevenueViewModel("Nov 25", 17440.36, 10449.27, 3494.05),
                new RevenueViewModel("Nov 26", 26988.38, 7914.24, 3632.62),
                new RevenueViewModel("Nov 27", 31185.29, 3288.44, 1327.59),
                new RevenueViewModel("Nov 28", 37658.76, 2571.67, 2422.74),
                new RevenueViewModel("Nov 29", 21874.08, 7889.05, 5657.53),
                new RevenueViewModel("Nov 30", 7255.54, 7914.24, 29546.7)
            };

            return(Json(data));
        }
コード例 #14
0
        protected override async Task OnInitializedAsync()
        {
            IsDataLoaded = false;
            DataSaved    = false;
            ErrorMessage = string.Empty;
            try {
                UserName = await _sessionStorageService.GetItemAsync <string>("UserName");

                CompanyId = await _sessionStorageService.GetItemAsync <string>("CompanyId");

                if (string.IsNullOrEmpty(revenueId))
                {
                    revenue = new RevenueViewModel();
                    revenue.transactionDate = DateTime.Today;
                    revenue.cashOrCheck     = "0";
                    IsViewonly = false;
                }
                else
                {
                    var id = Guid.Parse(revenueId);
                    IsViewonly = true;

                    var data = await appDBContext.Revenues
                               .Include(a => a.propertyDirectory).ThenInclude(b => b.property)
                               .Include(a => a.propertyDirectory).ThenInclude(b => b.tenant)
                               .Include(a => a.checkDetails)
                               .Where(r => r.id.Equals(id)).FirstOrDefaultAsync();

                    revenue = new RevenueViewModel()
                    {
                        id = data.id.ToString(),
                        transactionDate = data.transactionDate,
                        dueDate         = data.dueDate,

                        amount = data.cashOrCheck.Equals("0") ? data.amount : data.checkDetails.amount,

                        cashOrCheck         = data.cashOrCheck,
                        checkAmount         = data.cashOrCheck.Equals("1") ? data.checkDetails.amount : 0,
                        bankName            = data.cashOrCheck.Equals("1") ? data.checkDetails.bankName : "",
                        branch              = data.cashOrCheck.Equals("1") ? data.checkDetails.branch : "",
                        checkDate           = data.cashOrCheck.Equals("1") ? (DateTime?)data.checkDetails.checkDate : null,
                        propertyDirectoryId = data.propertyDirectory.id.ToString(),
                        propertyDescription = data.propertyDirectory.property.description,
                        tenantName          = $"{data.propertyDirectory.tenant.firstName} {data.propertyDirectory.tenant.lastName}",
                        reference           = data.reference,
                        receiptNo           = data.receiptNo
                    };
                }

                revenue.revenueAccounts = await appDBContext.GLAccounts.Where(a => a.revenue || a.cashAccount).ToListAsync();

                var vatAccount = await appDBContext.GLAccounts.Where(a => a.outputVatAccount).FirstOrDefaultAsync();

                if (vatAccount != null)
                {
                    revenue.outputVatAccount = $"{vatAccount.accountCode} - {vatAccount.accountDesc}";
                }

                IsDataLoaded = true;
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.ToString();
            }
            finally
            {
                IsDataLoaded = true;
            }
        }
コード例 #15
0
        protected override async Task OnInitializedAsync()
        {
            IsDataLoaded = false;
            DataSaved    = false;
            ErrorMessage = string.Empty;
            _BillingType = "MB";
            IsSaving     = false;
            try
            {
                UserName = await _sessionStorageService.GetItemAsync <string>("UserName");

                CompanyId = await _sessionStorageService.GetItemAsync <string>("CompanyId");

                if (string.IsNullOrEmpty(revenueId))
                {
                    DynamicParameters dynamicParameters = new DynamicParameters();
                    var IdKey = $"COLLECTION{DateTime.Today.ToString("yyyyMM")}";
                    dynamicParameters.Add("IdKey", IdKey);
                    dynamicParameters.Add("Format", "000000");
                    dynamicParameters.Add("CompanyId", CompanyId);

                    var documentIdTable = await dapperManager.GetAllAsync <DocumentIdTable>("spGetNextId", dynamicParameters);

                    var documentId = string.Empty;

                    if (documentIdTable.Any())
                    {
                        documentId = $"COL{DateTime.Today.ToString("yyyyMM")}{documentIdTable.First().NextId.ToString(documentIdTable.First().Format)}";
                    }

                    revenue = new RevenueViewModel();
                    revenue.transactionDate = DateTime.Today;

                    if (!string.IsNullOrEmpty(billId))
                    {
                        var bill = await appDBContext.Billings.AsNoTracking()
                                   .Include(b => b.propertyDirectory)
                                   .ThenInclude(a => a.property)
                                   .Include(b => b.propertyDirectory)
                                   .ThenInclude(a => a.tenant)
                                   .Include(b => b.billingLineItems)
                                   .Where(b => b.billId.Equals(Guid.Parse(billId))).FirstOrDefaultAsync();

                        revenue.billingDocumentId = bill.documentId;
                        revenue.billingId         = bill.billId.ToString();
                        revenue.collect           = true;
                        revenue.dueDate           = bill.dateDue;
                        revenue.tenantId          = bill.propertyDirectory.tenandId;
                        revenue.tenantName        = $"{bill.propertyDirectory.tenant.lastName} {bill.propertyDirectory.tenant.firstName}";
                        revenue.ownerName         = bill.propertyDirectory.property.ownerFullName;

                        revenue.propertyId          = bill.propertyDirectory.propertyId;
                        revenue.propertyDescription = bill.propertyDirectory.property.description;
                        revenue.propertyDirectoryId = bill.propertyDirectory.id.ToString();
                        revenue.billingType         = bill.billType;

                        var param = new DynamicParameters();
                        param.Add("billId", billId);

                        var list = await dapperManager.GetAllAsync <RevenueLineItemViewModel>("spInitCollection", param);

                        var companyDefault = appDBContext.CompanyDefaults
                                             .Include(a => a.RevenueAssocDuesAccount)
                                             .Include(a => a.RevenueAssocDuesDebitAccount)
                                             .Include(a => a.RevenueAssocDuesVatAccount)
                                             .Include(a => a.RevenueMonthlyDueAccount)
                                             .Include(a => a.RevenueMonthlyDueDebitAccount)
                                             .Include(a => a.RevenueMonthlyDueVatAccount)
                                             .Include(a => a.RevenueMonthlyDueWTAccount)

                                             .Where(a => a.companyId.Equals(CompanyId)).FirstOrDefault();

                        list.ForEach(a => {
                            if (Guid.Empty.Equals(a.Id))
                            {
                                a.Id = Guid.NewGuid();
                            }

                            if (a.billBalance > 0)
                            {
                                a.amountApplied = a.billBalance;
                            }

                            if (companyDefault != null)
                            {
                                switch (a.billLineType)
                                {
                                case Constants.BillLineTypes.MONTHLYBILLITEM_PREVBAL:
                                case Constants.BillLineTypes.MONTHLYBILLITEM:
                                case Constants.BillLineTypes.MONTHLYBILLITEMPENALTY:
                                    if (companyDefault.RevenueMonthlyDueAccountId.HasValue)
                                    {
                                        a.creditAccountId   = companyDefault.RevenueMonthlyDueAccountId.Value.ToString();
                                        a.creditAccountCode = companyDefault.RevenueMonthlyDueAccount.accountCode;
                                        a.creditAccountName = companyDefault.RevenueMonthlyDueAccount.accountDesc;
                                    }
                                    if (companyDefault.RevenueMonthlyDueDebitAccountId.HasValue)
                                    {
                                        a.debitAccountId   = companyDefault.RevenueMonthlyDueDebitAccountId.Value.ToString();
                                        a.debitAccountCode = companyDefault.RevenueMonthlyDueDebitAccount.accountCode;
                                        a.debitAccountName = companyDefault.RevenueMonthlyDueDebitAccount.accountDesc;
                                    }
                                    break;

                                case Constants.BillLineTypes.MONTHLYBILLITEM_VAT:
                                    if (companyDefault.RevenueMonthlyDueVatAccountId.HasValue)
                                    {
                                        a.creditAccountId   = companyDefault.RevenueMonthlyDueVatAccountId.Value.ToString();
                                        a.creditAccountCode = companyDefault.RevenueMonthlyDueVatAccount.accountCode;
                                        a.creditAccountName = companyDefault.RevenueMonthlyDueVatAccount.accountDesc;
                                    }
                                    if (companyDefault.RevenueMonthlyDueDebitAccountId.HasValue)
                                    {
                                        a.debitAccountId   = companyDefault.RevenueMonthlyDueDebitAccountId.Value.ToString();
                                        a.debitAccountCode = companyDefault.RevenueMonthlyDueDebitAccount.accountCode;
                                        a.debitAccountName = companyDefault.RevenueMonthlyDueDebitAccount.accountDesc;
                                    }
                                    break;

                                case Constants.BillLineTypes.MONTHLYBILLITEM_WT:
                                    if (companyDefault.RevenueMonthlyDueWTAccountId.HasValue)
                                    {
                                        a.creditAccountId   = companyDefault.RevenueMonthlyDueWTAccountId.Value.ToString();
                                        a.creditAccountCode = companyDefault.RevenueMonthlyDueWTAccount.accountCode;
                                        a.creditAccountName = companyDefault.RevenueMonthlyDueWTAccount.accountDesc;
                                    }
                                    if (companyDefault.RevenueMonthlyDueDebitAccountId.HasValue)
                                    {
                                        a.debitAccountId   = companyDefault.RevenueMonthlyDueDebitAccountId.Value.ToString();
                                        a.debitAccountCode = companyDefault.RevenueMonthlyDueDebitAccount.accountCode;
                                        a.debitAccountName = companyDefault.RevenueMonthlyDueDebitAccount.accountDesc;
                                    }
                                    break;

                                case Constants.BillLineTypes.MONTHLYASSOCDUE_PREVBAL:
                                case Constants.BillLineTypes.MONTHLYASSOCDUE:
                                case Constants.BillLineTypes.MONTHLYASSOCDUEPENALTY:
                                    if (companyDefault.RevenueAssocDuesAccountId.HasValue)
                                    {
                                        a.creditAccountId   = companyDefault.RevenueAssocDuesAccountId.Value.ToString();
                                        a.creditAccountCode = companyDefault.RevenueAssocDuesAccount.accountCode;
                                        a.creditAccountName = companyDefault.RevenueAssocDuesAccount.accountDesc;
                                    }
                                    if (companyDefault.RevenueAssocDuesDebitAccountId.HasValue)
                                    {
                                        a.debitAccountId   = companyDefault.RevenueAssocDuesDebitAccountId.Value.ToString();
                                        a.debitAccountCode = companyDefault.RevenueAssocDuesDebitAccount.accountCode;
                                        a.debitAccountName = companyDefault.RevenueAssocDuesDebitAccount.accountDesc;
                                    }
                                    break;

                                case Constants.BillLineTypes.MONTHLYASSOCDUE_VAT:
                                    if (companyDefault.RevenueAssocDuesVatAccountId.HasValue)
                                    {
                                        a.creditAccountId   = companyDefault.RevenueAssocDuesVatAccountId.Value.ToString();
                                        a.creditAccountCode = companyDefault.RevenueAssocDuesVatAccount.accountCode;
                                        a.creditAccountName = companyDefault.RevenueAssocDuesVatAccount.accountDesc;
                                    }
                                    if (companyDefault.RevenueAssocDuesDebitAccountId.HasValue)
                                    {
                                        a.debitAccountId   = companyDefault.RevenueAssocDuesDebitAccountId.Value.ToString();
                                        a.debitAccountCode = companyDefault.RevenueAssocDuesDebitAccount.accountCode;
                                        a.debitAccountName = companyDefault.RevenueAssocDuesDebitAccount.accountDesc;
                                    }
                                    break;

                                default:
                                    if (companyDefault.RevenueMonthlyDueAccountId.HasValue)
                                    {
                                        a.creditAccountId   = companyDefault.RevenueMonthlyDueAccountId.Value.ToString();
                                        a.creditAccountCode = companyDefault.RevenueMonthlyDueAccount.accountCode;
                                        a.creditAccountName = companyDefault.RevenueMonthlyDueAccount.accountDesc;
                                    }
                                    if (companyDefault.RevenueMonthlyDueDebitAccountId.HasValue)
                                    {
                                        a.debitAccountId   = companyDefault.RevenueMonthlyDueAccountId.Value.ToString();
                                        a.debitAccountCode = companyDefault.RevenueMonthlyDueDebitAccount.accountCode;
                                        a.debitAccountName = companyDefault.RevenueMonthlyDueDebitAccount.accountDesc;
                                    }
                                    break;
                                }
                            }
                        });

                        if (revenue.revenueLineItems == null)
                        {
                            revenue.revenueLineItems = new List <RevenueLineItemViewModel>();
                        }
                        else
                        {
                            revenue.revenueLineItems.Clear();
                        }

                        revenue.revenueLineItems.AddRange(list);
                    }


                    revenue.dueDate     = DateTime.Today;
                    revenue.cashOrCheck = "1";
                    IsViewonly          = false;
                    revenue.documentId  = documentId;
                }
                else
                {
                    var id = Guid.Parse(revenueId);
                    IsViewonly = true;

                    var data = await appDBContext.Revenues
                               .Include(a => a.revenueLineItems).ThenInclude(a => a.debitAccount)
                               .Include(a => a.revenueLineItems).ThenInclude(a => a.creditAccount)
                               .Include(a => a.revenueLineItems).ThenInclude(a => a.billingLineItem)
                               .Include(a => a.propertyDirectory).ThenInclude(b => b.property)
                               .Include(a => a.propertyDirectory).ThenInclude(b => b.tenant)
                               .Include(a => a.checkDetails)
                               .Include(a => a.billing)
                               .Where(r => r.id.Equals(id)).FirstOrDefaultAsync();

                    revenue = new RevenueViewModel()
                    {
                        id                  = data.id.ToString(),
                        documentId          = data.documentId,
                        transactionDate     = data.transactionDate,
                        dueDate             = data.dueDate,
                        propertyDirectoryId = data.propertyDirectory.id.ToString(),
                        propertyDescription = data.propertyDirectory.property.description,
                        propertyId          = data.propertyDirectory.propertyId,
                        tenantName          = $"{data.propertyDirectory.tenant.firstName} {data.propertyDirectory.tenant.lastName}",
                        reference           = data.reference,
                        receiptNo           = data.receiptNo,
                        billingId           = data.billing == null ? string.Empty : data.billing.billId.ToString(),
                        billingDocumentId   = data.billing == null?string.Empty:data.billing.documentId,
                        billingType         = data.billingType,
                        cashOrCheck         = data.cashOrCheck,
                        bankName            = data.cashOrCheck.Equals("1")?data.checkDetails.bankName:string.Empty,
                        branch              = data.cashOrCheck.Equals("1") ? data.checkDetails.branch : string.Empty,
                        checkNo             = data.cashOrCheck.Equals("1") ? data.checkDetails.checkNo : string.Empty,
                        checkAmount         = data.cashOrCheck.Equals("1") ? data.checkDetails.amount : 0m,
                        checkDate           = data.cashOrCheck.Equals("1") ? data.checkDetails.checkDate : null,
                        checkDepositDate    = data.cashOrCheck.Equals("1") ? data.checkDetails.depositDate : null,
                        ownerName           = data.propertyDirectory.property.ownerFullName
                    };
                    BillingType = revenue.billingType;

                    revenue.revenueLineItems = data.revenueLineItems.Select(a =>
                                                                            new RevenueLineItemViewModel()
                    {
                        Id               = a.id,
                        description      = a.description,
                        billBalance      = a.billingLineItem.amount - a.billingLineItem.amountPaid,
                        billLineType     = a.billingLineItem.billLineType,
                        amount           = a.billingLineItem.amount,
                        amountPaid       = a.amount,
                        amountApplied    = a.amount,
                        debitAccountId   = a.debitAccountId.ToString(),
                        debitAccountCode = a.debitAccount.accountCode,
                        debitAccountName = a.debitAccount.accountDesc,

                        creditAccountId   = a.creditAccountId.ToString(),
                        creditAccountCode = a.creditAccount.accountCode,
                        creditAccountName = a.creditAccount.accountDesc,
                        bankName          = a.bankName,
                        branch            = a.branch,
                        checkDate         = a.checkDate
                    }

                                                                            ).ToList();
                }

                revenue.revenueAccounts = await appDBContext
                                          .GLAccounts.Where(a => a.companyId.Equals(CompanyId))
                                          .ToListAsync();

                var pdlist = await appDBContext.PropertyDirectory
                             .Where(a => a.companyId.Equals(CompanyId))
                             .Include(a => a.property).ToListAsync();

                revenue.properties = pdlist.GroupBy(a => a.propertyId)
                                     .Select(grp => grp.First().property).ToList();

                revenue.tenants = new List <Tenant>();

                var vatAccount = await appDBContext.GLAccounts.Where(a => a.outputVatAccount &&
                                                                     a.companyId.Equals(CompanyId)).FirstOrDefaultAsync();

                if (vatAccount != null)
                {
                    revenue.outputVatAccount = $"{vatAccount.accountCode} - {vatAccount.accountDesc}";
                }

                IsDataLoaded = true;
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.ToString();
            }
            finally
            {
                IsDataLoaded = true;
            }
        }
コード例 #16
0
 public ActionResult Revenue(RevenueViewModel model)
 {
     Session["Result"] = DatabaseQueries.SellingPointRevenue(model.SellingPointTitle, model.StartPeriod,
                                                             model.EndPeriod);
     return(RedirectToAction("Revenue"));
 }