Ejemplo n.º 1
0
        /// <summary>
        /// Called every time the customer wants to pay for something
        /// </summary>
        public void CreateMoneyOrders(decimal amount)
        {
            Amount      = amount;
            MoneyOrders = new List <MoneyOrder>();

            // for testing only
            var rnd = new Random();

            // for testing only

            for (var i = 0; i < NumOrders; i++)
            {
                var testBytes = new byte[10];
                rnd.NextBytes(testBytes);
                var uniquenessString = new Guid();
                //var idPairs = CreateIdStringPairs(PersonalDataBytes);
                // TODO: once done testing, change back to use our personal data
                var idPairs           = CreateIdStringPairs(testBytes);
                var currentMoneyOrder = new MoneyOrder(Amount, uniquenessString.ToByteArray(), idPairs);
                MoneyOrders.Add(currentMoneyOrder);
            }

            // store the transaction for later reference with a unique id
            Ledger.Add(new Guid(), MoneyOrders);
        }
Ejemplo n.º 2
0
        private void OnAccountUpdate(BinanceStreamAccountInfo data)
        {
            Assets = new ObservableCollection <AssetViewModel>(data.Balances.Where(b => b.Free != 0 || b.Locked != 0).Select(b => new AssetViewModel()
            {
                Asset = b.Asset, Free = b.Free, Locked = b.Locked
            }).ToList());

            // Update Ledger
            foreach (var balance in data.Balances)
            {
                var ledge = Ledger.Where(l => balance.Asset == l.Asset).FirstOrDefault();

                // Only worth tracking if we have a balance to monitor
                if (balance.Free != 0 || balance.Locked != 0)
                {
                    if (ledge == null)
                    {
                        Ledger.Add(new LedgerAssetViewModel()
                        {
                            Asset = balance.Asset, Amount = balance.Total
                        });
                    }
                    else
                    {
                        ledge.Amount = balance.Total;
                    }
                }
                else if (ledge != null)
                {
                    Ledger.Remove(ledge); // needs to be dispatched
                }
            }
            //GetLedgerTrades();
        }
        public void Credit(int accountId, decimal amount)
        {
            if (Closed)
            {
                throw new ValidationException("The account is closed");
            }

            Ledger.Add(Transaction.CreditTransaction(amount));
        }
        public ActionResult NewPayment()
        {
            bool Valid = Post.VerifyParams(Request.QueryString);

            if (Valid)
            {
                Ledger.Add(Request.QueryString);
            }
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 5
0
        public void TestRemove()
        {
            var dt            = DateTime.Today;
            var testSubject   = new Ledger();
            var testName00    = "Assets";
            var testName01    = "Liabilities";
            var testResults00 = testSubject.Add(testName00, KindsOfAccounts.Asset, false, 101, dt.AddDays(-12));

            Assert.IsNotNull(testResults00);
            var testResults01 = testSubject.Add(testName01, KindsOfAccounts.Asset, false, 112, dt.AddDays(-12));

            Assert.IsNotNull(testResults01);
            var testResults02 = testSubject.Remove(testName01);

            Assert.IsNotNull(testResults02);
            Assert.IsTrue(testResults01.Equals(testResults02));

            Assert.IsNull(testSubject.Get(testName01));
        }
Ejemplo n.º 6
0
        public void TestAdd()
        {
            var dt            = DateTime.Today;
            var testSubject   = new Ledger();
            var testName00    = "Assets";
            var testResults00 = testSubject.Add(testName00, KindsOfAccounts.Asset, false, 101, dt.AddDays(-12));

            Assert.IsNotNull(testResults00);
            Assert.AreEqual(testName00, testResults00.Id.Value);
            Assert.AreEqual("101", testResults00.Id.Abbrev);

            var testResults01 = testSubject.Add(testName00, KindsOfAccounts.Asset, false);

            Assert.IsNotNull(testResults01);
            Assert.IsTrue(testResults00.Equals(testResults01));

            var testInput    = new Account(new AccountId("Cash"), dt, KindsOfAccounts.Asset, false);
            var testResult02 = testSubject.Add(testInput);

            Assert.IsNotNull(testResult02);
            Assert.IsTrue(testInput.Equals(testResult02));
        }
        public ActionResult EncodeDirectPayment()
        {
            XDocument           document = (XDocument)TempData["document"];
            NameValueCollection param    = new NameValueCollection();

            param.Add("PAYID", document.Element("ncresponse").Attribute("PAYID").Value);
            param.Add("CN", document.Element("ncresponse").Attribute("CN").Value);
            param.Add("orderID", document.Element("ncresponse").Attribute("orderID").Value);
            param.Add("currency", document.Element("ncresponse").Attribute("currency").Value);
            param.Add("amount", document.Element("ncresponse").Attribute("amount").Value);
            param.Add("STATUS", document.Element("ncresponse").Attribute("STATUS").Value);

            Ledger.Add(param);
            return(RedirectToAction("Index", "Home"));
        }
        public void Debit(decimal amount)
        {
            if (Closed)
            {
                throw new ValidationException("The account is closed");
            }

            var debitAmount = Math.Abs(amount); //make sure the number is positive

            if (GetAccountBalance() < debitAmount)
            {
                throw new ValidationException("Insufficient balance.");
            }

            Ledger.Add(Transaction.DebitTransaction(amount));
        }
Ejemplo n.º 9
0
 private void Btn_Calculate(object sender, RoutedEventArgs e)
 {
     ///<summary>
     /// bill instance will contain the converted string to int that will
     /// pass price to Bill and passes the calculated price to the view (total_with_tax)
     /// </summary>
     if (Price.Text != "" && Tip.Text != "" && Tax.Text != "")
     {
         Bill bill = new Bill(
             Math.Round(
                 Decimal.Parse(Price.Text), 2),
             Decimal.Parse(Tip.Text),
             Decimal.Parse(Tax.Text),
             Restaurant.Text,
             DateTime.Now.ToString());
         Total_With_Tax.Text = bill.Total.ToString();
         ledger.Add(bill);
     }
     else
     {
         MessageBox.Show("Please Enter All The Values.", "Error");
     }
 }
Ejemplo n.º 10
0
        public void TestGet()
        {
            var dt            = DateTime.Today;
            var testSubject   = new Ledger();
            var testName00    = "Assets";
            var testResults00 = testSubject.Add(testName00, KindsOfAccounts.Asset, false, 101, dt.AddDays(-12));

            Assert.IsNotNull(testResults00);
            var testResults01 = testSubject.Get(testName00);

            Assert.IsNotNull(testResults01);
            Assert.IsTrue(testResults00.Equals(testResults01));

            var testResults02 = testSubject.Get(101);

            Assert.IsNotNull(testResults02);
            Assert.IsTrue(testResults01.Equals(testResults02));

            var voca          = new VocaBase(testName00);
            var testResults03 = testSubject.Get(voca);

            Assert.IsNotNull(testResults03);
            Assert.IsTrue(testResults02.Equals(testResults03));
        }