private void GetParentCategories()
        {
            List <BalanceAccount> allCategories = BalanceAccounts.GetAll();
            BalanceAccount        parent        = new BalanceAccount();
            BalanceAccount        mainParent    = new BalanceAccount();

            foreach (BalanceAccountResultDetailItem item in ActiveAccountDetailedList)
            {
                if (item.ParentId != 0)
                {
                    parent = allCategories.Single(x => x.BalanceAccountId == item.ParentId);
                    item.Sub1CategoryName = parent.Name;
                    if (parent.ParentId != 0)
                    {
                        mainParent            = allCategories.Single(x => x.BalanceAccountId == parent.ParentId);
                        item.MainCategoryName = mainParent.Name;
                    }
                }
            }

            foreach (BalanceAccountResultDetailItem item in PassiveAccountDetailedList)
            {
                if (item.ParentId != 0)
                {
                    parent = allCategories.Single(x => x.BalanceAccountId == item.ParentId);
                    item.Sub1CategoryName = parent.Name;
                    if (parent.ParentId != 0)
                    {
                        mainParent            = allCategories.Single(x => x.BalanceAccountId == parent.ParentId);
                        item.MainCategoryName = mainParent.Name;
                    }
                }
            }
        }
Example #2
0
        public void Account_Test_45_ConsultaDeSaldoByToken()
        {
            var            build    = new BuildSettings();
            BalanceAccount account  = new BalanceAccount(build.Url, build.Token);
            var            response = account.ConsultarSaldo();

            Assert.IsTrue(response.status == "success", response.messageDetail);
        }
Example #3
0
        public void ConsultaDeSaldoByUser()
        {
            var            build    = new BuildSettings();
            BalanceAccount account  = new BalanceAccount(build.Url, build.User, build.Password);
            var            response = account.ConsultarSaldo();

            Assert.IsTrue(response.status == "success", response.messageDetail);
        }
Example #4
0
        public async Task <BalanceAccount> CreateBalanceAccount(string accountId, decimal startBalance = Constants.DefaultAccountBalance)
        {
            var balanceAccount = BalanceAccount.Create(accountId, balance: startBalance);

            unitOfWork.BalanceAccountRepository.Add(balanceAccount);

            return(await unitOfWork.Complete() ? balanceAccount : throw new ServerException("Creating balance account failed"));
        }
 public void Post([FromBody] BalanceAccount value)
 {
     if (value.ID == 0)
     {
         ctx.BalanceAccounts.Add(value);
     }
     else
     {
         var acct = ctx.BalanceAccounts.FirstOrDefault(f => f.ID == value.ID);
         if (acct != null)
         {
             Mapper.CopyData(value, acct);
         }
     }
     ctx.SaveChanges();
 }
Example #6
0
        public BuyOrder CreateBuyOrder(string name, ulong quantity, ulong pricePerItem)
        {
            var orderAccount = new Account(0);

            if (!BalanceAccount.DepositInto(orderAccount, quantity * pricePerItem))
            {
                return(null);
            }
            var order = new BuyOrder(name, pricePerItem, quantity, orderAccount);

            order.AddCancelAction(CancelBuyOrder);
            order.AddExecuteAction(ExecuteBuyOrder);
            lock (BuyOrders)
            {
                BuyOrders.Add(order);
            }
            Updated?.Invoke(this, this);
            return(order);
        }
Example #7
0
        public async Task Account_Test_45_ConsultaDeSaldoByUserAsync()
        {
            var             build    = new BuildSettings();
            BalanceAccount  account  = new BalanceAccount("http://services.test.sw.com.mx", "demo", "123456789");
            AccountResponse response = await account.ConsultarSaldoAsync();

            if (response.status != "error")
            {
                //saldo timbres
                Console.WriteLine(response.data.saldoTimbres);
                //timbres utilizados
                Console.WriteLine(response.data.timbresUtilizados);
                //En caso de tener timbres infinitos (para cuentas hijo)
                Console.WriteLine(response.data.unlimited);
            }
            else
            {
                //errores
                Console.WriteLine(response.message);
                Console.WriteLine(response.messageDetail);
            }
            Assert.True(response.status == "success", response.messageDetail);
        }
Example #8
0
        public async Task <Dictionary <string, BalanceAccount> > FetchBalance()
        {
            var response = await Request(new Base.Request()
            {
                ApiType = "private",
                BaseUri = ApiPrivateV2,
                Path    = "balance/",
                Method  = HttpMethod.Post
            }).ConfigureAwait(false);

            var balances = JsonSerializer.Deserialize <Dictionary <string, string> >(response.Text);

            var result = new Dictionary <string, BalanceAccount>();

            var markets = await FetchMarkets();

            var currencies = markets.Select(m => m.BaseId).Concat(markets.Select(m => m.QuoteId)).GroupBy(m => m).Select(m => m.Key.ToLower());

            foreach (var currencyId in currencies)
            {
                var account = new BalanceAccount();
                if (balances.ContainsKey(currencyId + "_available"))
                {
                    account.Free = JsonSerializer.Deserialize <decimal>(balances[currencyId + "_available"]);
                }
                if (balances.ContainsKey(currencyId + "_balance"))
                {
                    account.Total = JsonSerializer.Deserialize <decimal>(balances[currencyId + "_balance"]);
                }
                if (account.Free != 0 || account.Total != 0)
                {
                    result[GetCommonCurrencyCode(currencyId.ToUpper())] = account;
                }
            }

            return(result);
        }
 public static bool Update(BalanceAccount balanceAccount)
 {
     return(WebApi <bool> .PutAsync(controllerName, balanceAccount, "Put").Result);
 }
 public static int Insert(BalanceAccount balanceAccount)
 {
     return(WebApi <int> .PostAsync(controllerName, balanceAccount, "SinglePost").Result);
 }
Example #11
0
        private static void SeedDatabase(VouchersDBContext context)
        {
            //To Create the Code First DB go to Package Manager Console ->
            //PackageManagerConsole:
            //Install-Package Microsoft.EntityFrameworkCore.Tools -Pre
            //Add-Migration MigrationName
            //Update-Database

            if (context.BalanceAccounts.FirstOrDefault() == null)
            {
                var a1 = new BalanceAccount {
                    Name = "Unclassified", Expense = true
                };
                var a2 = new BalanceAccount {
                    Name = "Car Maintenance", Expense = true
                };
                var a3 = new BalanceAccount {
                    Name = "Development", Expense = false
                };
                var a4 = new BalanceAccount {
                    Name = "Consulting", Expense = false
                };
                var a5 = new BalanceAccount {
                    Name = "Training", Expense = false
                };
                var a6 = new BalanceAccount {
                    Name = "Software", Expense = true
                };
                var a7 = new BalanceAccount {
                    Name = "Hosting & Internet", Expense = true
                };

                context.BalanceAccounts.AddRange(a1, a2, a3, a4, a5, a6, a7);
                context.SaveChanges();

                var v1 = new Voucher {
                    Date = DateTime.Now.AddDays(-2), Amount = 800, Text = "Reiser-ST", Paid = false, Expense = false, Remark = true
                };
                var v2 = new Voucher {
                    Date = DateTime.Now.AddDays(-2), Amount = 65, Text = "BP Tankstelle", Paid = false, Expense = true, Remark = true
                };
                var v3 = new Voucher {
                    Date = DateTime.Now.AddDays(-2), Amount = 56, Text = "Amazon", Paid = false, Expense = true
                };
                var v4 = new Voucher {
                    Date = DateTime.Now.AddDays(-3), Amount = 100, Text = "Media Markt", Paid = true, Expense = true
                };
                context.Vouchers.AddRange(v1, v2, v3, v4);
                context.SaveChanges();

                var vd1 = new VoucherDetail {
                    VoucherID = v4.ID, Text = "Ladekabel", Amount = 100, Account = a1
                };
                var vd7 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "Game of Thrones, Season 6", Amount = 29, Account = a6
                };
                var vd2 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "USB Stick", Amount = 11, Account = a1
                };
                var vd3 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "DVI Kabel", Amount = 45, Account = a1
                };
                var vd4 = new VoucherDetail {
                    VoucherID = v2.ID, Text = "Diesel", Amount = 45, Account = a2
                };
                var vd6 = new VoucherDetail {
                    VoucherID = v2.ID, Text = "Reifenwechsel", Amount = 20, Account = a2
                };
                var vd5 = new VoucherDetail {
                    VoucherID = v1.ID, Text = "Remote Support", Amount = 800, Account = a4
                };

                context.VoucherDetails.AddRange(vd1, vd2, vd3, vd4, vd5, vd6, vd7);
                context.SaveChanges();
            }
            ;
        }