Beispiel #1
0
        public HttpResponseMessage PostDelete([FromBody] ExpenseItem eItem)
        {
            String resp = "{\"Response\":\"Undefine\"}";

            try
            {
                var ctx = new GASEntities();

                if (eItem != null)
                {
                    var item = (from ex in ctx.ExpenseItems
                                where ex.ItemID == eItem.ItemID
                                select ex).First();
                    item.Action = "Deleted";
                    ctx.SaveChanges();
                    resp = "{\"Response\":\"OK\"}";
                }
            }
            catch (Exception ex)
            {
                int a = 1;
                resp = "{\"Response\":\"Fail\"}";
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
            return(response);
        }
Beispiel #2
0
        public HttpResponseMessage PostAddItem([FromBody] ExpenseItem eItem)
        {
            String resp = "{\"Response\":\"Undefine\"}";

            try
            {
                var ctx = new GASEntities();

                if (eItem != null)
                {
                    var id = ctx.ExpenseItems.Add(eItem);

                    ctx.SaveChanges();
                    resp = "{\"Response\":\"OK\"}";
                }
            }
            catch (Exception ex)
            {
                Utility.log(ex.Message);
                int a = 1;
                resp = "{\"Response\":\"Fail\"}";
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);

            response.Content = new StringContent(resp, System.Text.Encoding.UTF8, "application/json");
            return(response);
        }
Beispiel #3
0
 private void FillExpenseForm(ExpenseItem Item)
 {
     dateTimePicker1.Value = DateTime.Parse(Item.Date);
     comboBoxType.Text     = Item.Type;
     txtDescription.Text   = Item.Description;
     txtCost.Text          = Item.Cost.ToString();
 }
Beispiel #4
0
        public async Task <ActionResult <ExpenseItem> > PostExpenseItem(ExpenseItem item)
        {
            _context.ExpenseItems.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetExpenseItem), new { id = item.Id }, item));
        }
Beispiel #5
0
        public async Task <BudgetItemViewModel> AddBudgetItemAsync()
        {
            BudgetItemViewModel vm = new BudgetItemViewModel(this.dbFilePath);

            vm.ItemUpdated += OnItemUpdate;
            BudgetItem item = null;

            if (this.CategoryType == BudgetCategoryType.Income)
            {
                item          = new IncomeItem();
                item.ItemType = BudgetItemType.Income;
            }
            else
            {
                item          = new ExpenseItem();
                item.ItemType = BudgetItemType.Expense;
            }
            item.budgetCategory   = model;
            item.budgetCategoryId = model.id;
            item.StartDate        = DateTime.Now;
            item.recurring        = true;
            item.frequency        = Frequency.Monthly;
            await vm.PopulateVMAsync(item);

            vm.IsNew = true;
            this.BudgetItems.Add(vm);
            this.SelectedBudgetItem = vm;
            return(vm);
        }
        public ActionResult Delete(int expenseId, int itemId)
        {
            ExpenseItem expenseItem = ExpenseItem.Find(itemId);

            expenseItem.Delete();
            return(RedirectToAction("Show", "ExpenseCategory", new { id = expenseId }));
        }
Beispiel #7
0
 private static void UpdateExpenseItem(ExpenseItem expenseItemInDb, ExpenseItemDto expenseItemDto, ExpenseAppEntities entity)
 {
     expenseItemInDb.ExpenseItemDate = expenseItemDto.ExpenseItemDate;
     expenseItemInDb.Description     = expenseItemDto.Description;
     expenseItemInDb.Amount          = expenseItemDto.Amount;
     entity.SaveChanges();
 }
Beispiel #8
0
        public void AddOneItem_Test_ReturnsTrue()
        {
            // arrange
            var expenseData     = new ExpenseData();
            var expenseItem     = new ExpenseItem();
            var expenseItem1    = new ExpenseItem(0, "dateString", 0.0, "tag");
            var expenseItemList = new List <ExpenseItem> {
                expenseItem1
            };

            expenseItemList = new List <ExpenseItem> {
                expenseItem1, expenseItem
            };
            var handleExpenseItem = Isolate.Fake.AllInstances <ExpenseItem>(Members.CallOriginal);

            Isolate.WhenCalled(() => handleExpenseItem.ID).WillReturn((-1));
            Isolate.WhenCalled(() => handleExpenseItem.Validate()).WillReturn(true);
            var boolean = expenseData.LoadFromList(expenseItemList);

            // act
            var result = expenseData.AddOneItem(0, "dateString", 0.1, "tag");

            // assert
            Assert.AreEqual(true, result);
            // side affects on expenseData
            Assert.AreEqual(2, expenseData.Items.Count);
            Assert.AreEqual("dateString", expenseData.Items[1].DateString);
            Assert.AreEqual(0.1, expenseData.Items[1].Amount, 0.01);
            Assert.AreEqual("tag", expenseData.Items[1].Tag);
            Assert.AreEqual("<Item><ID>0</ID><Date>dateString</Date><Amount>0.1</Amount><Tag>tag</Tag></Item>", expenseData.Items[1].ToXMLString());
            Assert.AreEqual("0,dateString,0.1,tag", expenseData.Items[1].ToTextString());
        }
Beispiel #9
0
        public bool IsExpenseItemUpdated(ExpenseItem expenseItem)
        {
            dbContext.Entry(expenseItem).State = EntityState.Modified;
            var isUpdated = dbContext.SaveChanges() > 0;

            return(isUpdated);
        }
Beispiel #10
0
        public async Task <ActionResult <ExpenseItem> > PostExpenseItem(ExpenseItem expenseItem)
        {
            _context.ExpenseItem.Add(expenseItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetExpenseItem", new { id = expenseItem.Id }, expenseItem));
        }
Beispiel #11
0
        public ActionResult Details(long id)
        {
            ExpenseItem   expenseItem   = _expenseItemBll.FindExpenseItem(id);
            ExpenseItemVM expenseItemVM = Mapper.Map <ExpenseItemVM>(expenseItem);

            return(PartialView("_Details", expenseItemVM));
        }
Beispiel #12
0
        public async Task <IActionResult> PutExpenseItem(int id, ExpenseItem expenseItem)
        {
            if (id != expenseItem.Id)
            {
                _logger.LogWarning($"The id of the item to update ({expenseItem.Id}) does not match the id in the request ({id}).");
                return(BadRequest());
            }

            _context.Entry(expenseItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExpenseItemExists(id))
                {
                    _logger.LogWarning($"Item with the id={id} does not exist.");
                    return(NotFound());
                }
                else
                {
                    _logger.LogError($"An error has occured.");
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #13
0
        public ActionResult Create(ExpenseItem expenseItem, HttpPostedFileBase ImageFile)
        {
            if (ImageFile == null)
            {
                ModelState.AddModelError("Image", "Please upload an Image");
            }
            bool isValidFormate = common.ImageValidation(ImageFile);

            if (isValidFormate == false)
            {
                ModelState.AddModelError("Image", "only png,jpg,jpeg format is allowed");
            }

            byte[] convertedImage = common.ConvertImage(ImageFile);
            expenseItem.Image = convertedImage;
            if (ModelState.IsValid)
            {
                status = expenseItemBll.Create(expenseItem);
                if (status == true)
                {
                    return(RedirectToAction("List", "ExpenseItems"));
                }
                else
                {
                    ViewBag.Message = "Expense Catagory added failed";
                }
            }
            ViewBag.ExpenseCategoryId = expenseItemBll.GetExpenseItemCategory();
            return(View(expenseItem));
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!IsValid())
                {
                    return;
                }
                bool isNew = false;
                using (DLMSEntities db = new DLMSEntities())
                {
                    if (_ExpenseItem.ExpenseItemID <= 0)
                    {
                        RefreshObject();
                        _ExpenseItem.ExpenseItemID = db.ExpenseItems.Count() > 0 ? db.ExpenseItems.Max(obj => obj.ExpenseItemID) + 1 : 1;
                        db.ExpenseItems.Add(_ExpenseItem);
                        isNew = true;
                    }
                    else
                    {
                        _ExpenseItem = db.ExpenseItems.FirstOrDefault(obj => obj.ExpenseItemID == _ExpenseItem.ExpenseItemID);
                        RefreshObject();
                    }

                    db.SaveChanges();

                    MessageBox.Show("Data saved successfully.", "Save Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (!isNew)
                    {
                        if (ItemChanged1 != null)
                        {
                            ItemChanged1();
                        }
                        this.Close();
                    }
                    else
                    {
                        if (ItemChanged1 != null)
                        {
                            ItemChanged1();
                        }
                        _ExpenseItem = new ExpenseItem();
                        RefreshValue();
                        txtCode.Text = GenerateCategoryCode();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException == null)
                {
                    MessageBox.Show(ex.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show(ex.InnerException.Message, "Failed to save", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public bool IsExpenseItemSaved(ExpenseItemVM itemVm)
        {
            ExpenseItem item = new ExpenseItem()
            {
                Name        = itemVm.Name,
                Code        = itemVm.Code,
                Description = itemVm.Description,
                Date        = itemVm.Date,
                CategoryId  = itemVm.CategoryId
            };

            dbContext.ExpenseItems.Add(item);
            var isAdded = dbContext.SaveChanges();

            if (isAdded > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }

            return(false);
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                DEWSRMEntities db         = new DEWSRMEntities();
                int[]          selRows    = ((GridView)grdExpens.MainView).GetSelectedRows();
                DataRowView    oExpenseID = (DataRowView)(((GridView)grdExpens.MainView).GetRow(selRows[0]));
                int            nExpenseID = Convert.ToInt32(oExpenseID["ExpenseItemID"]);
                ExpenseItem    oExpense   = db.ExpenseItems.FirstOrDefault(p => p.ExpenseItemID == nExpenseID);

                if (oExpense == null)
                {
                    MessageBox.Show("select an item to delete", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                if (MessageBox.Show("Do you want to delete the selected item?", "Delete Setup", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    db.ExpenseItems.Attach(oExpense);
                    db.ExpenseItems.Remove(oExpense);
                    db.SaveChanges();

                    MessageBox.Show("Data Deleted Successfully.", "Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    RefreshList();
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show("Cannot delete item due to " + Ex.Message);
            }
        }
        public async Task <IActionResult> Edit(Guid id, [Bind("Amount,ExpenseDate,Id,ListId,Name,Description")] ExpenseItem expenseItem)
        {
            if (id != expenseItem.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(expenseItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ExpenseItemExists(expenseItem.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ListId"] = new SelectList(_context.List, nameof(List.Id), nameof(List.Name), expenseItem.ListId);
            return(View(expenseItem));
        }
        public ActionResult Update(int expenseId, int itemId, string newName, double newPrice)
        {
            ExpenseItem expenseItem = ExpenseItem.Find(itemId);

            expenseItem.Edit(newName, newPrice);
            return(RedirectToAction("Show", expenseItem));
        }
        public void set_SelectedExpenseItem_Test_ReturnsSelectedExpenseItemIsValue()
        {
            // arrange
            var expenseViewer            = new ExpenseViewer();
            var propertyChangedWasRaised = false;

            expenseViewer.PropertyChanged += (a, b) => propertyChangedWasRaised = true;
            var value = new ExpenseItem();
            var propertyChangedWasRaised1 = false;

            value.PropertyChanged += (a, b) => propertyChangedWasRaised1 = true;
            var propertyChangedWasRaised2 = false;

            value.PropertyChanged += (a, b) => propertyChangedWasRaised2 = true;

            // act
            expenseViewer.SelectedExpenseItem = value;

            // assert
            // side affects on expenseViewer
            Assert.AreSame(value, expenseViewer.SelectedExpenseItem);
            Assert.AreEqual(true, expenseViewer.IsSelected);
            // side affects on propertyChangedWasRaised
            Assert.AreEqual(true, propertyChangedWasRaised);
        }
        public async Task <ExpenseItem> AddExpenseItemAsync(ExpenseItem expense)
        {
            var inserted = await connection.InsertAsync(expense);

            //expense.IsNew = false;
            return(expense);
        }
        internal bool Delete(int id)
        {
            ExpenseItem expenseItem = db.ExpenseItems.Find(id);

            expenseItem.IsDeleted = true;
            return(db.SaveChanges() > 0);
        }
Beispiel #22
0
        public async Task <IActionResult> PutExpenseItem(long id, ExpenseItem expenseItem)
        {
            if (id != expenseItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(expenseItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                if (!ExpenseItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw e;
                }
            }

            return(NoContent());
        }
Beispiel #23
0
        public ActionResult Edit(ExpenseItem expenseItem, HttpPostedFileBase ImageFile)
        {
            if (ImageFile != null)
            {
                bool isValidFormate = common.ImageValidation(ImageFile);
                if (isValidFormate == false)
                {
                    ModelState.AddModelError("Image", "only png,jpeg,jpg formates are allowed");
                }
                byte[] convertedImage = common.ConvertImage(ImageFile);
                expenseItem.Image = convertedImage;
            }

            if (ModelState.IsValid)
            {
                status = expenseItemBll.Edit(expenseItem);
                if (status == true)
                {
                    return(RedirectToAction("List", "ExpenseItems"));
                }
                else
                {
                    ViewBag.Message = "Item is not updated succesfully";
                }
            }

            ViewBag.ExpenseCategoryId = expenseItemBll.GetExpenseItemCategory();
            return(View(expenseItem));
        }
        public ActionResult Create(int accountId, int expenseId, string name, double price)
        {
            ExpenseItem newExpenseItem = new ExpenseItem(name, price, expenseId);

            newExpenseItem.Save();
            return(RedirectToAction("Show", "ExpenseCategory", new { id = expenseId }));
        }
Beispiel #25
0
        private void GetExpenseDetailTransactionalData(ExpenseReportMasterModel MasterModel)
        {
            GlBL BL = new GlBL();
            List <ExpenseItem> list = new List <ExpenseItem>();

            MasterModel.ExpenseItems = list;
            DataSet ds = BL.PerformSearch();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                if (Convert.ToString(ds.Tables[0].Rows[i]["Customer_Number"]).GetType() != Type.GetType("System.DBNull"))
                {
                    ExpenseItem item = new ExpenseItem();
                    item.Amount          = Convert.ToString(ds.Tables[0].Rows[i]["Amount"]);
                    item.Balance         = Convert.ToString(ds.Tables[0].Rows[i]["Balance"]);
                    item.customer_name   = Convert.ToString(ds.Tables[0].Rows[i]["customer_name"]);
                    item.customer_number = Convert.ToString(ds.Tables[0].Rows[i]["customer_number"]);

                    for (int k = 0; k < ds.Tables[1].Rows.Count; k++)
                    {
                        if (ds.Tables[0].Rows[i]["Customer_Name"].GetType() != Type.GetType("System.DBNull") && Convert.ToString(ds.Tables[0].Rows[i]["Customer_Name"]) != "Total" && Convert.ToString(ds.Tables[0].Rows[i]["Customer_Name"]) != "Cumulative Total")
                        {
                            if (Convert.ToString(ds.Tables[1].Rows[k]["Customer_Name"]) == Convert.ToString(ds.Tables[0].Rows[i]["Customer_Name"]))
                            {
                                ExpenseTransactionalItem trans = new ExpenseTransactionalItem();
                                trans.elt_account_number = Convert.ToString(ds.Tables[1].Rows[k]["elt_account_number"]);
                                trans.Amount             = Convert.ToString(ds.Tables[1].Rows[k]["Amount"]);
                                trans.Balance            = Convert.ToString(ds.Tables[1].Rows[k]["Balance"]);
                                trans.Customer_Name      = Convert.ToString(ds.Tables[1].Rows[k]["Customer_Name"]);
                                trans.Customer_Number    = Convert.ToString(ds.Tables[1].Rows[k]["Customer_Number"]);

                                trans.Date  = Convert.ToString(ds.Tables[1].Rows[k]["Date"]);
                                trans.Link  = Convert.ToString(ds.Tables[1].Rows[k]["Link"]);
                                trans.Num   = Convert.ToString(ds.Tables[1].Rows[k]["Num"]);
                                trans.Memo  = Convert.ToString(ds.Tables[1].Rows[k]["Memo"]);
                                trans.Split = Convert.ToString(ds.Tables[1].Rows[k]["Split"]);
                                trans.Num   = Convert.ToString(ds.Tables[1].Rows[k]["Num"]);
                                trans.Type  = Convert.ToString(ds.Tables[1].Rows[k]["Type"]);
                                item.TransactionItems.Add(trans);
                            }
                        }
                        if (Convert.ToString(ds.Tables[0].Rows[i]["Customer_Name"]) == "Total")
                        {
                            MasterModel.Total = Convert.ToString(ds.Tables[1].Rows[k]["Amount"]);
                        }
                        if (Convert.ToString(ds.Tables[0].Rows[i]["Customer_Name"]) == "Cumulative Total")
                        {
                            MasterModel.Cumulative_Total = Convert.ToString(ds.Tables[1].Rows[k]["Amount"]);
                        }
                    }
                    if (item.Amount != "")
                    {
                        if (double.Parse(item.Amount) != 0)
                        {
                            list.Add(item);
                        }
                    }
                }
            }
        }
Beispiel #26
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         ExpenseItem oExpenseItem = new ExpenseItem();
         if (lsvExpenseIteams.SelectedItems != null && lsvExpenseIteams.SelectedItems.Count > 0)
         {
             oExpenseItem = (ExpenseItem)lsvExpenseIteams.SelectedItems[0].Tag;
             if (MessageBox.Show("Do you want to delete the selected item?", "Delete Setup", MessageBoxButtons.YesNo,
                                 MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 using (DLMSEntities db = new DLMSEntities())
                 {
                     db.ExpenseItems.Attach(oExpenseItem);
                     db.ExpenseItems.Remove(oExpenseItem);
                     //Save to database
                     db.SaveChanges();
                 }
                 RefreshList();
             }
         }
     }
     catch (Exception Ex)
     {
         MessageBox.Show("Cannot delete item due to " + Ex.Message);
     }
 }
 public void ShowDlg(ExpenseItem oExpenseItem, bool IsNew)
 {
     _IsNew       = IsNew;
     _ExpenseItem = oExpenseItem;
     RefreshValue();
     this.ShowDialog();
 }
Beispiel #28
0
        public void UpdateOperations_DontMoveDateIfWriteofAtIssueDate()
        {
            var uow      = Substitute.For <IUnitOfWork>();
            var employee = Substitute.For <EmployeeCard>();
            var norm     = Substitute.For <NormItem>();

            norm.Amount.Returns(1);
            var nomeclature = Substitute.For <Nomenclature>();

            var operationIssue = Substitute.For <EmployeeIssueOperation>();

            operationIssue.Id.Returns(1);
            operationIssue.OperationTime.Returns(new DateTime(2019, 1, 15));
            operationIssue.Issued.Returns(2);
            var operationWriteoff = Substitute.For <EmployeeIssueOperation>();

            operationWriteoff.Id.Returns(2);
            operationWriteoff.IssuedOperation.Returns(operationIssue);
            operationWriteoff.OperationTime.Returns(new DateTime(2019, 1, 15));
            operationWriteoff.Returned.Returns(2);

            var operation = new EmployeeIssueOperation();

            operation.OperationTime = new DateTime(2019, 1, 15);
            operation.NormItem      = norm;

            IssueGraph.MakeIssueGraphTestGap = (e, t) => new IssueGraph(new List <EmployeeIssueOperation>()
            {
                operation, operationIssue, operationWriteoff
            });

            var expenseItem = new ExpenseItem();

            expenseItem.Nomenclature           = nomeclature;
            expenseItem.EmployeeIssueOperation = operation;
            expenseItem.Amount = 1;
            var expense = new Expense();

            expense.Employee  = employee;
            expense.Date      = new DateTime(2019, 1, 15);
            expense.Operation = ExpenseOperations.Employee;
            expense.Items.Add(expenseItem);
            expenseItem.ExpenseDoc = expense;

            var ask            = Substitute.For <IInteractiveQuestion>();
            var baseParameters = Substitute.For <BaseParameters>();

            baseParameters.ColDayAheadOfShedule.Returns(0);

            //Выполняем
            expense.UpdateOperations(uow, baseParameters, ask);

            //В данном сценарии мы не должны ничего спрашивать у пользователя. Предпологается что мы могли попросить передвинуть дату начала, на тот же день, так как списание было в этот день. реальный случай.
            ask.DidNotReceiveWithAnyArgs().Question(string.Empty);

            Assert.That(expense.Items[0].EmployeeIssueOperation.OperationTime,
                        Is.EqualTo(new DateTime(2019, 1, 15))
                        );
        }
Beispiel #29
0
 public Task InsertExpenseItemAsync(Context context, ExpenseItem expenseItem, CancellationToken cancellationToken)
 {
     return(ExecuteWithAuthorizationAsync(context, () =>
     {
         var expenseItemTable = _client.GetTable <ExpenseItem>();
         return expenseItemTable.InsertAsync(expenseItem);
     }, cancellationToken));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            ExpenseItem expenseItem = db.expenseItems.Find(id);

            db.expenseItems.Remove(expenseItem);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #31
0
 public Facede(Bll.Facede Application)
 {
     corporationExpenses = new CorporationExpenses(Application);
     corporationRevenues = new CorporationRevenues(Application);
     expenseItem = new ExpenseItem(Application);
     expenses = new Expenses(Application);
     memberExpenses = new MemberExpenses(Application);
     memberRevenues = new MemberRevenues(Application);
     revenueItem = new RevenueItem(Application);
     revenues = new Revenues(Application);
 }