예제 #1
0
        public ExpenseDetailsPage(Expense expense)
        {
            InitializeComponent();

            ViewModel         = Resources["viewModel"] as ExpenseDetailsViewModel;
            ViewModel.Expense = expense;
        }
예제 #2
0
        public ActionResult GetExpenseDetailsViewModel()
        {
            //var info = GetTransactionAndLineItemDetails("Visa0000000000006109");
            var info = GetTransactionAndLineItemDetails("MasterCard0000027318");

            var vm = new ExpenseDetailsViewModel();

            vm.ExpenseTypeDetails = GetExpenseTypeDetals(info.First().CardType);
            vm.TaxCodeDetails     = GetTaxCodeDetals();
            vm.GlCodeDetails      = GetGlCodeDetals();

            vm.Transaction = info.Select(x => new TransactionDetails
            {
                CardType        = x.CardType,
                ReferenceNumber = x.ReferenceNumber,
                TransactionDate = x.TransactionDate,
                MerchantName    = x.MerchantName,
                Amount          = x.Amount,
                Purpose         = x.Purpose,
                ExpenseGroup    = x.ExpenseGroup,
                TaxReceipt      = x.TaxReceipt.Equals("Y")
            }).First();

            vm.LineItems = info.Select(x => new LineItemDetails
            {
                LineId       = x.LineId,
                Description  = x.Description,
                ExpenseType  = x.ExpenseType,
                TaxCode      = x.TaxCode,
                NetAmount    = x.NetAmount,
                TaxAmount    = x.TaxAmount,
                GrossAmount  = x.GrossAmount,
                Price        = x.Price,
                Quantity     = x.Quantity,
                CurrencyType = x.CurrencyType,
                ExchangeRate = x.ExchangeRate,
                GlCodes      = ConvertGlCodesToList(x.GlCodes, vm.GlCodeDetails)
            }).ToList();


            vm.LineItems.Add(new LineItemDetails
            {
                Description  = "Line 2",
                ExpenseType  = "",
                TaxCode      = "GST",
                NetAmount    = 10.00m,
                TaxAmount    = 0,
                GrossAmount  = 10.00m,
                Price        = 10.00m,
                Quantity     = 1,
                CurrencyType = "AUD",
                ExchangeRate = 1.0000m,
                GlCodes      = vm.LineItems.First().GlCodes.ToList()
            });

            return(Json(vm, JsonRequestBehavior.AllowGet));
        }
        public ExpenseDetailsViewModel MapExpenseDetailsDTOToViewModel(Application.Services.Abstract.DTO.IExpenseDetails expenseDetailsDTO)
        {
            if (expenseDetailsDTO == null)
            {
                throw new ArgumentNullException("ExpenseDetailsDTO cannot be null");
            }
            if (expenseDetailsDTO.ExpenseList == null)
            {
                throw new ArgumentNullException("ExpenseDetailsDTO-->ExpenseList cannot be null");
            }
            //ExpenseDetailsViewModel
            List <ExpenseViewModel> expenseViewModelList = new List <ExpenseViewModel>();

            if (expenseDetailsDTO.ExpenseList.Count == 0)
            {
                return new ExpenseDetailsViewModel
                       {
                           Title       = "Expense Summary",
                           TotalAmount = 0,
                           expenses    = null
                       }
            }
            ;

            foreach (var expenseDTO in expenseDetailsDTO.ExpenseList)
            {
                if (expenseDTO.Type == null)
                {
                    throw new ArgumentNullException("ExpenseDTO ==> Type cannot be null");
                }
                expenseViewModelList.Add(new ExpenseViewModel
                {
                    ExpenseType = new ExpenseTypeViewModel
                    {
                        TypeId = expenseDTO.Type.TypeId,
                        Type   = expenseDTO.Type.Type
                    },
                    Amount      = expenseDTO.Amount,
                    ExpenseDate = expenseDTO.ExpenseDate.ToString(),
                    Description = expenseDTO.Description.Length > 35 ? expenseDTO.Description.Substring(0, 34) + "..." : expenseDTO.Description,
                    Comments    = expenseDTO.Comments,
                });
            }
            ExpenseDetailsViewModel expenseDetails = new ExpenseDetailsViewModel()
            {
                expenses    = expenseViewModelList,
                Title       = "Expense Summary",
                TotalAmount = expenseDetailsDTO.TotalAmount
            };

            return(expenseDetails);
        }
예제 #4
0
        // GET: Expenses/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExpenseDetailsViewModel expView = new ExpenseDetailsViewModel();

            expView.Expense            = db.Expenses.SingleOrDefault(e => e.ExpenseID == id);
            expView.ExpenseDetailsList = db.ExpenseDetails.Where(e => e.ExpenseId == id).ToList();

            if (expView.Expense == null)
            {
                return(HttpNotFound());
            }
            return(View(expView));
        }