public void LogCustomer(CustomerAccount customer, decimal amount, TransactionType type)
        {
            if (customer.AccountType == AccountType.Loan)
            {
                var transaction = new TransactionsLog
                {
                    Name                = customer.AccountName,
                    Amount              = amount,
                    AccountCode         = customer.AccountNumber,
                    Type                = type,
                    date                = DateTime.Now,
                    MainAccountCategory = "Asset"
                };

                _context.Add(transaction);
                _context.Save(transaction);
            }
            else
            {
                var transaction = new TransactionsLog
                {
                    Name   = customer.AccountName,
                    Amount = amount,
                    Type   = type,
                    date   = DateTime.Now,
                    MainAccountCategory = "Liability"
                };

                _context.Add(transaction);
                _context.Save(transaction);
            }
        }
        public void Log(GlAccountManagement gl, decimal amount, TransactionType type)
        {
            var transaction = new TransactionsLog
            {
                Name                = gl.Name,
                Amount              = amount,
                Type                = type,
                AccountCode         = gl.AccCode,
                date                = DateTime.Now,
                MainAccountCategory = GetCategory(gl)
            };

            _context.Add(transaction);
            _context.Save(transaction);
        }
示例#3
0
        private void ParseFromXML(string path)
        {
            XElement settings;

            try
            {
                settings = XElement.Load(path);

                var fund          = settings.Element("AccountBudget").Attribute("Funds").Value;
                var monthlyProfit = settings.Element("AccountBudget").Attribute("MonthlyProfit").Value;

                MyAccount.Funds = Decimal.Parse(fund);

                var expViewDataXml = settings.Element("MonthlyExpenses");

                foreach (var ev in ExpensesView.ExpensesViewDataList)
                {
                    var currEl = expViewDataXml.Element(ev.Category.Replace(" ", string.Empty));

                    ev.PlannedFunds = Decimal.Parse(currEl.Attribute("PlannedFunds").Value);
                    ev.SpentFunds   = Decimal.Parse(currEl.Attribute("SpentFunds").Value);
                }

                foreach (var item in settings.Element("TransactionsLog").Elements())
                {
                    var category = item.Attribute("Category").Value;

                    if (category == "Profit")
                    {
                        TransactionsLog.Instance().SaveToLog(new TransactionView(new Profit(item.Attribute("Type").Value,
                                                                                            item.Attribute("Description").Value, decimal.Parse(item.Attribute("Value").Value),
                                                                                            item.Attribute("TransactionDate").Value)));
                    }
                    else
                    {
                        TransactionsLog.Instance().SaveToLog(new TransactionView(new Expense(item.Attribute("Type").Value,
                                                                                             item.Attribute("Description").Value, decimal.Parse(item.Attribute("Value").Value),
                                                                                             item.Attribute("TransactionDate").Value)));
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#4
0
        private void DataToXML()
        {
            XElement settings = new XElement("AccountantSettings", new XElement("AccountBudget", new XAttribute("Funds", MyAccount.Funds),
                                                                                new XAttribute("MonthlyProfit", MyAccount.MonthlyProfit), new XAttribute("CurrentExpenses", CurrentExpenses),
                                                                                new XAttribute("SavingPlan", SavingPlan), new XAttribute("PlannedExpenses", PlannedExpenses)));

            XElement monthlyExpenses = new XElement("MonthlyExpenses");

            foreach (var expense in ExpensesView.ExpensesViewDataList)
            {
                monthlyExpenses.Add(new XElement(expense.Category.Replace(" ", string.Empty),
                                                 new XAttribute("PlannedFunds", expense.PlannedFunds),
                                                 new XAttribute("SpentFunds", expense.SpentFunds)));
            }

            settings.Add(monthlyExpenses);

            XElement transactionsLog = new XElement("TransactionsLog");

            foreach (var item in TransactionsLog.Instance().LogList())
            {
                var description = string.Empty;
                if (item.Description != null)
                {
                    description = item.Description;
                }

                transactionsLog.Add(new XElement("Transaction",
                                                 new XAttribute("Category", item.Category),
                                                 new XAttribute("Type", item.Type),
                                                 new XAttribute("Description", description),
                                                 new XAttribute("Value", item.Value),
                                                 new XAttribute("TransactionDate", item.TransactionDate)));
            }
            settings.Add(transactionsLog);

            settings.Add(new XElement("DateTime", DateTime.Now.ToShortDateString()));

            settings.Save("Settings.xml");
        }
示例#5
0
        public void AddTransaction(string category, string description, decimal value)
        {
            try
            {
                if (value != 0)
                {
                    if (category == "Single income")
                    {
                        ITransaction profit = new Profit(category, description, value);
                        MyAccount.Funds += value;
                        TransactionsLog.Instance().SaveToLog(new TransactionView(profit));
                    }
                    else if (category == "Monthly income")
                    {
                        ITransaction profit = new Profit(category, description, value);
                        TransactionsLog.Instance().SaveToLog(new TransactionView(profit));
                        MyAccount.MonthlyProfits.Add(profit);
                    }
                    else
                    {
                        ITransaction expense = new Expense(category, description, value);

                        MyAccount.Funds -= value;

                        ExpensesView.ExpensesViewDataList.Where(evd => evd.Category == category)
                        .FirstOrDefault()
                        .SpentFunds += value;

                        MyAccount.MonthlyExpenses.Add(expense);
                        TransactionsLog.Instance().SaveToLog(new TransactionView(expense));
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
示例#6
0
 public void New()
 {
     MyAccount    = new Account();
     ExpensesView = new MonthlyExpensesControl();
     TransactionsLog.Instance().NewLog();
 }