Beispiel #1
0
        internal StateInfo(AccountEntry account, IDictionary<string, Asset> assets, IDictionary<string, PriceEntry> prices, IDictionary<string, Quote> quotes, SymbolEntries symbols, long generation)
        {
            this.Status = account.MarginLevelStatus;
            this.Generation = generation;

            this.Balance = account.Balance;
            this.Profit = account.Profit.GetValueOrDefault();
            this.Margin = account.Margin.GetValueOrDefault();
            this.Equity = account.Equity.GetValueOrDefault();
            this.MarginLevel = account.MarginLevel.GetValueOrDefault();
            this.Commission = account.Commission;
            this.Swap = account.Swap;
            this.AgentCommission = account.AgentCommission;

            this.Prices = new Dictionary<string, PriceEntry>(prices);
            this.UnknownSymbols = new SortedSet<string>(account.Trades.Where(o => o.SymbolEntry == null).Select(o => o.Symbol), StringComparer.InvariantCultureIgnoreCase).ToArray();

            var records = new List<TradeRecord>(account.Trades.Count);
            var positions = new List<Position>(account.Trades.Count);

            ResetPositionsProfit(account.Trades);

            foreach (var element in account.Trades)
            {
                if (!TryProcessAsTradeRecord(element, records))
                    TryProcessAsPosition(element, positions);
            }

            this.Quotes = new Dictionary<string, Quote>(quotes);
            this.TradeRecords = records.ToArray();
            this.Positions = positions.ToArray();
            this.Assets = new Dictionary<string, Asset>(assets);
        }
 public FriendshipController(AccountEntry accountEntry, AccountProjection accountProjection, BC.Game.GameProjection gameProjection, FriendshipProjection friendshipProjection)
 {
     AccountEntry         = accountEntry;
     AccountProjection    = accountProjection;
     GameProjection       = gameProjection;
     FriendshipProjection = friendshipProjection;
 }
Beispiel #3
0
        private static void OnAuthenticateRequest(object sender, EventArgs e)
        {
            var application = (HttpApplication)sender;

            var context = application.Context;

            if (context.User != null && context.User.Identity.IsAuthenticated)
            {
                return;
            }

            var cookieName = FormsAuthentication.FormsCookieName;

            var cookie = application.Request.Cookies[cookieName.ToUpper()];

            if (cookie == null)
            {
                return;
            }
            try
            {
                var ticket    = FormsAuthentication.Decrypt(cookie.Value);
                var identity  = new CustomIdentity(AccountEntry.Deserialize(ticket.UserData), ticket.Name);
                var principal = new GenericPrincipal(identity, identity.GetRoles());
                context.User            = principal;
                Thread.CurrentPrincipal = principal;
            }
            catch
            {
            }
        }
Beispiel #4
0
        public static AccountEntry Decode(IByteReader stream)
        {
            AccountEntry decodedAccountEntry = new AccountEntry();

            decodedAccountEntry.AccountID     = AccountID.Decode(stream);
            decodedAccountEntry.Balance       = Int64.Decode(stream);
            decodedAccountEntry.SeqNum        = SequenceNumber.Decode(stream);
            decodedAccountEntry.NumSubEntries = Uint32.Decode(stream);
            int inflationDestPresent = XdrEncoding.DecodeInt32(stream);

            if (inflationDestPresent != 0)
            {
                decodedAccountEntry.InflationDest = AccountID.Decode(stream);
            }
            decodedAccountEntry.Flags      = Uint32.Decode(stream);
            decodedAccountEntry.HomeDomain = String32.Decode(stream);
            decodedAccountEntry.Thresholds = Thresholds.Decode(stream);
            int signerssize = XdrEncoding.DecodeInt32(stream);

            decodedAccountEntry.Signers = new Signer[signerssize];
            for (int i = 0; i < signerssize; i++)
            {
                decodedAccountEntry.Signers[i] = Signer.Decode(stream);
            }
            decodedAccountEntry.Ext = AccountEntryExt.Decode(stream);
            return(decodedAccountEntry);
        }
 private void CreatePayPlanEntries(bool showImplicitlyPaidOffProcs = false)
 {
     _listAccountCharges = AccountEntry.GetAccountCharges(_listPayPlanCharges, _listAdjustments, _listProcs);
     if (showImplicitlyPaidOffProcs)
     {
         _accountCredits = 0;
     }
     else
     {
         _accountCredits = PayPlanEdit.GetAccountCredits(_listAdjustments, _listPaySplits, _listPayments, _listInsPayAsTotal, _listPayPlanCharges);
     }
     LinkChargesToCredits();
     _listPayPlanEntries = new List <PayPlanEdit.PayPlanEntry>();
     _listPayPlanEntries.AddRange(PayPlanEdit.CreatePayPlanEntriesForAccountCharges(_listAccountCharges, _patCur));
     ListPayPlanCreditsCur = ListPayPlanCreditsCur.OrderBy(x => x.ChargeDate).ToList();
     _listPayPlanEntries.AddRange(PayPlanEdit.CreatePayPlanEntriesForPayPlanCredits(_listAccountCharges, ListPayPlanCreditsCur));
     if (ListPayPlanCreditsCur.Exists(x => x.ProcNum == 0))           //only add "Unattached" if there is a credit without a procedure.
     {
         _listPayPlanEntries.Add(PayPlanEdit.CreatePayPlanEntryForUnattachedProcs(ListPayPlanCreditsCur, _patCur.FName));
     }
     _listPayPlanEntries = _listPayPlanEntries
                           .OrderByDescending(x => x.ProcStatOrd)
                           .ThenByDescending(x => x.ProcNumOrd)
                           .ThenBy(x => x.IsChargeOrd)
                           .ThenBy(x => x.DateOrd).ToList();
 }
Beispiel #6
0
        public static void Encode(IByteWriter stream, AccountEntry encodedAccountEntry)
        {
            AccountID.Encode(stream, encodedAccountEntry.AccountID);
            Int64.Encode(stream, encodedAccountEntry.Balance);
            SequenceNumber.Encode(stream, encodedAccountEntry.SeqNum);
            Uint32.Encode(stream, encodedAccountEntry.NumSubEntries);
            if (encodedAccountEntry.InflationDest != null)
            {
                XdrEncoding.EncodeInt32(1, stream);
                AccountID.Encode(stream, encodedAccountEntry.InflationDest);
            }
            else
            {
                XdrEncoding.EncodeInt32(0, stream);
            }
            Uint32.Encode(stream, encodedAccountEntry.Flags);
            String32.Encode(stream, encodedAccountEntry.HomeDomain);
            Thresholds.Encode(stream, encodedAccountEntry.Thresholds);
            int signerssize = encodedAccountEntry.Signers.Length;

            XdrEncoding.EncodeInt32(signerssize, stream);
            for (int i = 0; i < signerssize; i++)
            {
                Signer.Encode(stream, encodedAccountEntry.Signers[i]);
            }
            AccountEntryExt.Encode(stream, encodedAccountEntry.Ext);
        }
Beispiel #7
0
        public static AccountEntry Decode(XdrDataInputStream stream)
        {
            var decodedAccountEntry = new AccountEntry();

            decodedAccountEntry.AccountID     = AccountID.Decode(stream);
            decodedAccountEntry.Balance       = Int64.Decode(stream);
            decodedAccountEntry.SeqNum        = SequenceNumber.Decode(stream);
            decodedAccountEntry.NumSubEntries = Uint32.Decode(stream);
            var InflationDestPresent = stream.ReadInt();

            if (InflationDestPresent != 0)
            {
                decodedAccountEntry.InflationDest = AccountID.Decode(stream);
            }
            decodedAccountEntry.Flags      = Uint32.Decode(stream);
            decodedAccountEntry.HomeDomain = String32.Decode(stream);
            decodedAccountEntry.Thresholds = Thresholds.Decode(stream);
            var signerssize = stream.ReadInt();

            decodedAccountEntry.Signers = new Signer[signerssize];
            for (var i = 0; i < signerssize; i++)
            {
                decodedAccountEntry.Signers[i] = Signer.Decode(stream);
            }
            decodedAccountEntry.Ext = AccountEntryExt.Decode(stream);
            return(decodedAccountEntry);
        }
Beispiel #8
0
        private static void ProcessCreateCommand(string[] parts)
        {
            if (parts.Length < 4)
            {
                Logger.WriteLog(LogType.Command, "Invalid create account command! Usage: create <email> <username> <password>");
                return;
            }

            var salt = new byte[20];

            using (var rng = RandomNumberGenerator.Create())
                rng.GetBytes(salt);

            var data = new AccountEntry
            {
                Email    = parts[1],
                Username = parts[2],
                Password = parts[3],
                Salt     = BitConverter.ToString(salt).Replace("-", "").ToLower()
            };

            data.HashPassword();

            try
            {
                AccountTable.InsertAccount(data);

                Logger.WriteLog(LogType.Command, $"Created account: {parts[2]}! (Password: {parts[3]})");
            }
            catch
            {
                Logger.WriteLog(LogType.Error, "Username or email is already taken!");
            }
        }
Beispiel #9
0
 public SettingsController(AccountEntry accountEntry, AccountProjection accountProjection)
 {
     AccountEntry      = accountEntry;
     AccountProjection = accountProjection;
     CurrentContent    = RenderPersonalInfo;
     Icon = accountEntry.Icon;
 }
        private VNode RenderLogin()
        {
            VNode wrongUsernamePassword()
            {
                return(Text("Wrong Username/Password!", Styles.AbortBtn & Styles.MP4, () => CurrentContent = RenderLogin));
            }

            return(Div(
                       Styles.BorderWhiteSolid & Styles.BCMain & Styles.FitContent & Styles.MY2,
                       Input(Username, s => Username = s, Styles.MP2),
                       Input(Password, s => Password = s, Styles.MP2).WithPassword(),
                       Text("Login ", Styles.TabButton, () =>
            {
                try
                {
                    Account.Commands.LoginAccount(GetUser().ID, Password);
                }
                catch (ArgumentException)
                {
                    CurrentContent = wrongUsernamePassword;
                }
                CurrentUser = GetUser();
            })
                       ));
        }
Beispiel #11
0
            public static LedgerEntryData Decode(XdrDataInputStream stream)
            {
                LedgerEntryData decodedLedgerEntryData = new LedgerEntryData();
                LedgerEntryType discriminant           = LedgerEntryType.Decode(stream);

                decodedLedgerEntryData.Discriminant = discriminant;

                switch (decodedLedgerEntryData.Discriminant.InnerValue)
                {
                case LedgerEntryType.LedgerEntryTypeEnum.ACCOUNT:
                    decodedLedgerEntryData.Account = AccountEntry.Decode(stream);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.TRUSTLINE:
                    decodedLedgerEntryData.TrustLine = TrustLineEntry.Decode(stream);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.OFFER:
                    decodedLedgerEntryData.Offer = OfferEntry.Decode(stream);
                    break;

                case LedgerEntryType.LedgerEntryTypeEnum.DATA:
                    decodedLedgerEntryData.Data = DataEntry.Decode(stream);
                    break;
                }

                return(decodedLedgerEntryData);
            }
Beispiel #12
0
        public static void Encode(XdrDataOutputStream stream, AccountEntry encodedAccountEntry)
        {
            AccountID.Encode(stream, encodedAccountEntry.AccountID);
            Int64.Encode(stream, encodedAccountEntry.Balance);
            SequenceNumber.Encode(stream, encodedAccountEntry.SeqNum);
            Uint32.Encode(stream, encodedAccountEntry.NumSubEntries);
            if (encodedAccountEntry.InflationDest != null)
            {
                stream.WriteInt(1);
                AccountID.Encode(stream, encodedAccountEntry.InflationDest);
            }
            else
            {
                stream.WriteInt(0);
            }
            Uint32.Encode(stream, encodedAccountEntry.Flags);
            String32.Encode(stream, encodedAccountEntry.HomeDomain);
            Thresholds.Encode(stream, encodedAccountEntry.Thresholds);
            var signerssize = encodedAccountEntry.Signers.Length;

            stream.WriteInt(signerssize);
            for (var i = 0; i < signerssize; i++)
            {
                Signer.Encode(stream, encodedAccountEntry.Signers[i]);
            }
            AccountEntryExt.Encode(stream, encodedAccountEntry.Ext);
        }
Beispiel #13
0
        /// <summary>
        /// Creates new financial state of account calculator.
        /// </summary>
        /// <param name="trade">valid instance of not started data trade</param>
        /// <param name="feed">valid instance of not started data feed</param>
        public StateCalculator(DataTrade trade, DataFeed feed)
        {
            if (trade == null)
                throw new ArgumentNullException(nameof(trade), "Data trade argument can not be null");

            if (trade.IsStarted)
                throw new ArgumentException("Started data trade can not be used for creating state calculator.", nameof(trade));

            if (feed == null)
                throw new ArgumentNullException(nameof(feed), "Data feed argument can not be null");

            if (feed.IsStarted)
                throw new ArgumentException("Started data feed can not be used for creating state calculator.", nameof(feed));


            this.quotes = new Dictionary<string, Quote>();
            this.calculatorQuotes = new Dictionary<string, Quote>();

            this.calculator = new FinancialCalculator();
            this.account = new AccountEntry(calculator);
            this.calculator.Accounts.Add(this.account);

            this.trade = trade;
            this.feed = feed;

            this.processor = new Processor(this.Calculate);

            this.processor.Exception += this.OnException;
            this.processor.Executed += this.OnExecuted;

            this.updateHandler = new UpdateHandler(trade, feed, this.OnUpdate, processor);
        }
Beispiel #14
0
        public static Projection ForwardProjectFixedIncomeToAccountValue(
            Account currentAccount,
            DateTime nextPayday,
            DateTime projectionDate,
            AccountEntry fixedRecurringIncome)
        {
            // Use only date values
            nextPayday     = nextPayday.Date;
            projectionDate = projectionDate.Date;

            var projection = new Projection
            {
                Account = currentAccount,
                ProjectedAccountValue = currentAccount.Value,
                NextPayday            = nextPayday,
                Date = projectionDate
            };

            var today = DateTime.Today;
            var daysUntilNextPayday = nextPayday - today;
            var daysUntilProjection = projectionDate - today;

            // If a past payday was selected, return the current account value
            if (daysUntilNextPayday.Days < 0)
            {
                // TODO: Log invalid state
                return(projection);
            }

            // If a past day was selected for projection, return the current account value.
            if (daysUntilProjection.Days < 0)
            {
                // TODO: Log invalid state
                return(projection);
            }

            // If the next payday is after the projected date, return the current account value.
            if (daysUntilNextPayday.Days > daysUntilProjection.Days)
            {
                return(projection);
            }

            // At this point, projection date is greater than or equal to the next payday
            // Calculate the number of pay periods elapsed to determine income accrued
            // This will be days from next payday to projection date divided by the pay period frequency
            var daysFromNextPaydayToProjection = projectionDate - nextPayday;
            var payPeriodsElapsed = (int)(daysFromNextPaydayToProjection / fixedRecurringIncome.Frequency);

            // Casting to an integer will round down so we need to add one
            // This is because at least one pay period has occurred at this point
            payPeriodsElapsed++;

            var incomeDelta = fixedRecurringIncome.Value * payPeriodsElapsed;

            return(projection with
            {
                ProjectedAccountValue = projection.Account.Value + incomeDelta
            });
        }
Beispiel #15
0
        public void Tests(string input, string expectedResult)
        {
            var lines = input.Split(new[] { "\r\n" }, StringSplitOptions.None).Skip(1).ToArray();

            var newEntry = new AccountEntry(lines);

            Assert.AreEqual(newEntry.AccountStatus, expectedResult);
        }
        public ActionResult DeleteConfirmed(long id)
        {
            AccountEntry accountEntry = db.AccountEntries.Find(id);

            db.AccountEntries.Remove(accountEntry);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #17
0
        public AccountEntryVM(AccountEntry entry)
        {
            this.Entry = entry;

            Items = entry.Items
                    .Select(i => new AccountEntryItemVM(i))
                    .ToArray();
        }
Beispiel #18
0
        public void AccountParseTest()
        {
            string xml = "<?xml version='1.0' encoding='UTF-8'?>\n" +
                         "<feed xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' gd:etag='W/&quot;D0UFR347eCp8ImA4WxVQE04.&quot;' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:dxp='http://schemas.google.com/analytics/2009'>" +
                         "<author>" +
                         "<name>Google Analytics</name>" +
                         "</author>" +
                         "<generator>Google Analytics</generator>" +
                         "<id>http://www.google.com/analytics/feeds/accounts/[email protected]</id>" +
                         "<link href='http://www.google.com/analytics/feeds/accounts/default' rel='self' type='application/atom+xml' />" +
                         "<title type='text'>Profile list for [email protected]</title>" +
                         "<updated>2009-01-31T01:01:01+10:00</updated>" +
                         "<entry gd:etag='W/&quot;D0UAR248eCp4ImA9WxVQE04.&quot;'>" +
                         "<dxp:tableId>ga:1234567</dxp:tableId>" +
                         "<dxp:property name='ga:accountId' value='123456' />" +
                         "<dxp:property name='ga:accountName' value='Test Account' />" +
                         "<dxp:property name='ga:profileId' value='1234567' />" +
                         "<dxp:property name='ga:webPropertyId' value='UA-111111-1' />" +
                         "<title type='text'>www.test.com</title>" +
                         "<id>http://www.google.com/analytics/feeds/accounts/ga:1234567</id>" +
                         "<link href='http://www.google.com/analytics' rel='alternate' type='text/html' />" +
                         "<content type='text'/>" +
                         "<updated>2009-01-31T01:01:01+10:00</updated>" +
                         "</entry>" +
                         "</feed>";

            AccountFeed  feed  = Parse(xml);
            AccountEntry entry = feed.Entries[0] as AccountEntry;

            Assert.IsNotNull(entry, "entry");
            Assert.IsNotNull(entry.Properties);
            Assert.IsNotNull(entry.ProfileId);

            Assert.AreEqual("ga:accountId", entry.Properties[0].Name);
            Assert.AreEqual("123456", entry.Properties[0].Value);

            Assert.AreEqual("ga:accountName", entry.Properties[1].Name);
            Assert.AreEqual("Test Account", entry.Properties[1].Value);

            Assert.AreEqual("ga:profileId", entry.Properties[2].Name);
            Assert.AreEqual("1234567", entry.Properties[2].Value);

            Assert.AreEqual("ga:webPropertyId", entry.Properties[3].Name);
            Assert.AreEqual("UA-111111-1", entry.Properties[3].Value);

            Assert.AreEqual("www.test.com", entry.Title.Text);

            Account a = new Account();

            a.AtomEntry = entry;

            Assert.AreEqual("123456", a.AccountId);
            Assert.AreEqual("Test Account", a.AccountName);
            Assert.AreEqual("1234567", a.ProfileId);
            Assert.AreEqual("UA-111111-1", a.WebPropertyId);
            Assert.AreEqual("www.test.com", a.Title);
            Assert.AreEqual("ga:1234567", a.TableId);
        }
Beispiel #19
0
 public FriendshipController(AccountEntry accountEntry, AccountProjection accountProjection, ChessgameProjection gameProjection,
                             FriendshipProjection friendshipProjection, RootController rootController)
 {
     AccountEntry         = accountEntry;
     AccountProjection    = accountProjection;
     GameProjection       = gameProjection;
     FriendshipProjection = friendshipProjection;
     RenderCurrentcontent = RenderOverview;
 }
Beispiel #20
0
        public static AccountEntry GetAccount(string accountName)
        {
            lock (AuthDatabaseAccess.Lock)
            {
                GetAccountByNameCommand.Parameters["@AccountName"].Value = accountName;

                using (var reader = GetAccountByNameCommand.ExecuteReader())
                    return(AccountEntry.Read(reader));
            }
        }
Beispiel #21
0
        void OnAddAccount(object sender, EventArgs e)
        {
            var entry = new AccountEntry(calculator)
            {
                Tag = ++accountsCounter
            };

            this.calculator.Accounts.Add(entry);
            this.m_accounts.Items.Add(entry);
        }
Beispiel #22
0
        void OnAddAccount(object sender, EventArgs e)
        {
            var entry = new AccountEntry(calculator)
            {
                Tag = ++accountsCounter
            };

            this.calculator.Accounts.Add(entry);
            this.m_accounts.Items.Add(entry);
        }
Beispiel #23
0
        public static AccountEntry GetAccount(uint accountId)
        {
            lock (AuthDatabaseAccess.Lock)
            {
                GetAccountByIdCommand.Parameters["@AccountId"].Value = accountId;

                using (var reader = GetAccountByIdCommand.ExecuteReader())
                    return(AccountEntry.Read(reader));
            }
        }
Beispiel #24
0
        private void gridAdjusts_CellClick(object sender, UI.ODGridClickEventArgs e)
        {
            //Update text boxes here
            AccountEntry entry = (AccountEntry)gridAdjusts.SelectedGridRows[0].Tag;             //Only one can be selected at a time.

            labelAmtOriginal.Text = entry.AmountOriginal.ToString("F");                         //Adjustment's start original - Negative or positive it doesn't matter.
            labelAmtUsed.Text     = (entry.AmountOriginal - entry.AmountStart).ToString("F");   //Amount of Adjustment that's been used elsewhere
            labelAmtAvail.Text    = entry.AmountStart.ToString("F");                            //Amount of Adjustment that's left available
            labelCurSplitAmt.Text = (-PaySplitCurAmt).ToString("F");                            //Amount of current PaySplit (We can only access this window from current PaySplitEdit window right now)
            labelAmtEnd.Text      = ((double)entry.AmountStart - PaySplitCurAmt).ToString("F"); //Amount of Adjustment after everything.
        }
Beispiel #25
0
 public static void InsertAccount(AccountEntry entry)
 {
     lock (AuthDatabaseAccess.Lock)
     {
         InsertAccountCommand.Parameters["@Email"].Value    = entry.Email;
         InsertAccountCommand.Parameters["@Username"].Value = entry.Username;
         InsertAccountCommand.Parameters["@Password"].Value = entry.Password;
         InsertAccountCommand.Parameters["@Salt"].Value     = entry.Salt;
         InsertAccountCommand.ExecuteNonQuery();
     }
 }
Beispiel #26
0
        void CalculateLockedVolume(AccountEntry account, MarketState state)
        {
            foreach (var asset in this.assets.Values)
                asset.LockedVolume = 0D;

            var cashAccount = new CashAccountInfo(account, this.assets.Values);

            using (var calculator = new CashAccountCalculator(cashAccount, state))
            {
            }
        }
        public MemberAccount FindMemberAccount(string memberID)
        {
            SqlConnection ClubBaistConnection = new SqlConnection();

            ClubBaistConnection.ConnectionString = @"Data Source= (LocalDB)\MSSQLLocalDB; 
                                  Initial Catalog = aspnet-ClubBaistGolfManagement-53bc9b9d-9d6a-45d4-8429-2a2761773502;
                                                     Integrated Security = True; MultipleActiveResultSets=True";

            SqlCommand thecommand = new SqlCommand();

            thecommand.CommandType = CommandType.StoredProcedure;
            thecommand.Connection  = ClubBaistConnection;
            thecommand.CommandText = "GetMemberAccount";

            SqlParameter memberid = new SqlParameter();

            memberid.ParameterName = "@memberid";

            memberid.SqlDbType = SqlDbType.VarChar;
            memberid.Value     = memberID;
            memberid.Direction = ParameterDirection.Input;

            thecommand.Parameters.Add(memberid);

            ClubBaistConnection.Open();

            SqlDataReader theDataReader;

            theDataReader = thecommand.ExecuteReader();

            MemberAccount       chosenMemberAccount     = new MemberAccount();
            List <AccountEntry> accountEntriesforMember = new List <AccountEntry>();

            if (theDataReader.HasRows)
            {
                while (theDataReader.Read())
                {
                    AccountEntry accountEntry = new AccountEntry();

                    chosenMemberAccount.MemberId = theDataReader["MemberID"].ToString();
                    chosenMemberAccount.Balance  = Decimal.Parse(theDataReader["Balance"].ToString());

                    accountEntry.WhenCharged        = DateTime.Parse(theDataReader["WhenCharged"].ToString());
                    accountEntry.WhenMade           = DateTime.Parse(theDataReader["WhenMade"].ToString());
                    accountEntry.Amount             = Decimal.Parse(theDataReader["Amount"].ToString());
                    accountEntry.PaymentDescription = theDataReader["PaymentDescription"].ToString();

                    accountEntriesforMember.Add(accountEntry);
                }
            }
            ClubBaistConnection.Close();
            chosenMemberAccount.AccountEntries = accountEntriesforMember;
            return(chosenMemberAccount);
        }
 public ActionResult Edit([Bind(Include = "Id,AccountId,Description,Debit,Credit,CreatedDate,ModifiedDate,ModifiedBy,IsEnable,IsDelete")] AccountEntry accountEntry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(accountEntry).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.AccountId = new SelectList(db.Accounts, "Id", "AccNumber", accountEntry.AccountId);
     return(View(accountEntry));
 }
Beispiel #29
0
 private AccountEntry RedactSecrets(AccountEntry entry)
 {
     return(new AccountEntry
     {
         name = entry.name,
         authority = entry.authority,
         resource = entry.resource,
         appid = entry.appid,
         secret = string.IsNullOrEmpty(entry.secret) ? entry.secret : "***",
         token = string.IsNullOrEmpty(entry.token) ? entry.token : "***",
     });
 }
        ///<summary>Creates paysplits for selected charges if there is enough payment left.</summary>
        private void butTransfer_Click(object sender, EventArgs e)
        {
            if (gridCharges.SelectedGridRows.Count == 0)           //Nothing selected, transfer everything.
            {
                gridCharges.SetSelected(true);
            }
            //Make list of positive charges
            List <AccountEntry> listPosCharges = gridCharges.SelectedGridRows.Select(x => (AccountEntry)x.Tag).Where(x => x.AmountEnd > 0).ToList();
            //Make list of negative charges
            List <AccountEntry> listNegCharges = gridCharges.SelectedGridRows.Select(x => (AccountEntry)x.Tag).Where(x => x.AmountEnd < 0).ToList();

            //We need to detect if parent rows are selected (row.DropDownParent==null).   If it is, we need to find all child rows of that row
            //We need to add the child rows into the list of charges even if they aren't explicitly selected
            foreach (GridRow row in gridCharges.SelectedGridRows)
            {
                if (row.DropDownParent != null)
                {
                    continue;
                }
                AccountEntry parentEntry = (AccountEntry)row.Tag;
                //The user has a parent row selected - Make sure all child rows are added to appropriate lists (if they aren't in there already)
                foreach (GridRow row2 in gridCharges.ListGridRows)
                {
                    AccountEntry childEntry = (AccountEntry)row2.Tag;
                    if (parentEntry.AccountEntryNum == childEntry.AccountEntryNum)
                    {
                        continue;                        //Don't add parent row into anything.
                    }
                    if (!listPosCharges.Contains(childEntry) && !listNegCharges.Contains(childEntry) && childEntry.ClinicNum == parentEntry.ClinicNum &&
                        childEntry.PatNum == parentEntry.PatNum && childEntry.ProvNum == parentEntry.ProvNum && childEntry.AmountEnd != 0)
                    {
                        if (childEntry.AmountEnd > 0)
                        {
                            listPosCharges.Add(childEntry);
                        }
                        else
                        {
                            listNegCharges.Add(childEntry);
                        }
                    }
                }
            }
            List <long> listPatNumsForCharges = listPosCharges.Select(x => x.PatNum).Distinct().ToList();
            //Get account entries so if any procs are attached to payment plans, their attached procedures can be attached to the new split from the transfer.
            List <AccountEntry> listEntriesForPats = _results.ListAccountCharges.FindAll(x => x.PatNum.In(listPatNumsForCharges));

            //Sort charge lists so they maintain FIFO order regardless of order selected.
            listPosCharges = listPosCharges.OrderBy(x => x.Date).ToList();
            listNegCharges = listNegCharges.OrderBy(x => x.Date).ToList();
            CreateTransfers(listPosCharges, listNegCharges, listEntriesForPats);
            FillGridSplits();            //Fills charge grid too.
        }
Beispiel #31
0
        public void ThenTheAccountForTheMembershipShouldHaveTheFollowingDebits(int id, Table table)
        {
            var account = repository.GetById <Account>(MembershipId.Parse(id));

            for (int index = 0; index < table.RowCount; index++)
            {
                AccountEntry accountEntry = account.Entries.ElementAt(index);
                accountEntry.ExpectedPaymentOn.Should().Be(DateTime.Parse(table.Rows[index][0]));
                accountEntry.Value.Should().Be(Money.Parse(Decimal.Parse(table.Rows[index][1])));
            }

            account.Should().NotBeNull();
        }
Beispiel #32
0
        internal void AddEntry(AccountEntry entry)
        {
            if (entry != null)
            {
                entries.Add(entry);

                if (EntryAdded != null)
                {
                    var task = ExecuteSynchronized(() => EntryAdded(entry));
                }
            }

            FirePropertyChanged(nameof(Entries));
        }
Beispiel #33
0
        public CashAssets(IEnumerable<AssetInfo> assets, AccountEntry account, MarketState state)
        {
            var query = assets.Select(o => new Asset(account)
            {
                Currency = o.Currency,
                Volume = o.Balance,
                DepositCurrency = o.Balance,
                Rate = 1
            });

            this.assets = query.ToDictionary(o => o.Currency);

            this.CalculateLockedVolume(account, state);
        }
        // GET: AccountEntries/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            AccountEntry accountEntry = db.AccountEntries.Find(id);

            if (accountEntry == null)
            {
                return(HttpNotFound());
            }
            return(View(accountEntry));
        }
Beispiel #35
0
        AccountEntry GetCurrentAccountEntry()
        {
            AccountEntry result = null;

            if (this.m_accounts.SelectedItems.Count != 1)
            {
                MessageBox.Show("To add or remove trades you should select only one account", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                result = (AccountEntry)this.m_accounts.SelectedItems[0];
            }

            return(result);
        }
 public static void Encode(IByteWriter stream, AccountEntry encodedAccountEntry) {
   AccountID.Encode(stream, encodedAccountEntry.AccountID);
   Int64.Encode(stream, encodedAccountEntry.Balance);
   SequenceNumber.Encode(stream, encodedAccountEntry.SeqNum);
   Uint32.Encode(stream, encodedAccountEntry.NumSubEntries);
   if (encodedAccountEntry.InflationDest != null) {
   XdrEncoding.EncodeInt32(1, stream);
   AccountID.Encode(stream, encodedAccountEntry.InflationDest);
   } else {
   XdrEncoding.EncodeInt32(0, stream);
   }
   Uint32.Encode(stream, encodedAccountEntry.Flags);
   String32.Encode(stream, encodedAccountEntry.HomeDomain);
   Thresholds.Encode(stream, encodedAccountEntry.Thresholds);
   int signerssize = encodedAccountEntry.Signers.Length;
   XdrEncoding.EncodeInt32(signerssize, stream);
   for (int i = 0; i < signerssize; i++) {
     Signer.Encode(stream, encodedAccountEntry.Signers[i]);
   }
   AccountEntryExt.Encode(stream, encodedAccountEntry.Ext);
 }
 public static AccountEntry Decode(IByteReader stream) {
   AccountEntry decodedAccountEntry = new AccountEntry();
   decodedAccountEntry.AccountID = AccountID.Decode(stream);
   decodedAccountEntry.Balance = Int64.Decode(stream);
   decodedAccountEntry.SeqNum = SequenceNumber.Decode(stream);
   decodedAccountEntry.NumSubEntries = Uint32.Decode(stream);
   int inflationDestPresent = XdrEncoding.DecodeInt32(stream);
   if (inflationDestPresent != 0) {
   decodedAccountEntry.InflationDest = AccountID.Decode(stream);
   }
   decodedAccountEntry.Flags = Uint32.Decode(stream);
   decodedAccountEntry.HomeDomain = String32.Decode(stream);
   decodedAccountEntry.Thresholds = Thresholds.Decode(stream);
   int signerssize = XdrEncoding.DecodeInt32(stream);
   decodedAccountEntry.Signers = new Signer[signerssize];
   for (int i = 0; i < signerssize; i++) {
     decodedAccountEntry.Signers[i] = Signer.Decode(stream);
   }
   decodedAccountEntry.Ext = AccountEntryExt.Decode(stream);
   return decodedAccountEntry;
 }
Beispiel #38
0
        internal TradeEntry CreateEntry(AccountEntry owner)
        {
            var result = new TradeEntry(owner)
            {
                Tag = this.Tag,
                Type = TradeRecordTypeFromTradeType(this.Type),
                Side = this.Side,
                Symbol = this.Symbol,
                Price = this.Price,
                Volume = this.Volume,
                Commission = this.Commission,
                AgentCommission = this.AgentCommission,
                Swap = this.Swap,
                //StaticMarginRate = this.Rate,
                ProfitStatus = this.ProfitStatus,
                MarginStatus = this.MarginStatus,
                Profit = this.Profit,
                Margin = this.Margin
            };

            return result;
        }
Beispiel #39
0
        internal AccountData(AccountEntry entry)
            : this()
        {
            if (entry == null)
                throw new ArgumentNullException(nameof(entry));

            this.Tag = entry.Tag != null ? entry.Tag.ToString() : string.Empty;
            this.Type = entry.Type;
            this.Leverage = entry.Leverage;
            this.Balance = entry.Balance;
            this.Currency = entry.Currency;
            this.Profit = entry.Profit;
            this.ProfitStatus = entry.ProfitStatus;
            this.Margin = entry.Margin;
            this.MarginStatus = entry.MarginStatus;

            foreach (var element in entry.Trades)
            {
                var data = new TradeData(element);
                this.Trades.Add(data);
            }
        }
Beispiel #40
0
        internal AccountEntry CreateEntry(FinancialCalculator owner)
        {
            var result = new AccountEntry(owner)
            {
                Tag = this.Tag,
                Type = this.Type,
                Leverage = this.Leverage,
                Balance = this.Balance,
                Currency = this.Currency,
                Profit = this.Profit,
                ProfitStatus = this.ProfitStatus,
                Margin = this.Margin,
                MarginStatus = this.MarginStatus
            };

            foreach (var element in this.Trades)
            {
                var entry = element.CreateEntry(result);
                result.Trades.Add(entry);
            }

            return result;
        }
        public void SignIn(FormsUser formsUser, bool createPersistentCookie)
        {
            var accountEntry = new AccountEntry(formsUser);

            var authTicket = new FormsAuthenticationTicket(1,
                                                           accountEntry.Id.ToString(),
                                                           DateTime.Now,
                                                           DateTime.Now.AddMinutes(45),
                                                           createPersistentCookie,
                                                           accountEntry.Serialize());

            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

            var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName.ToUpper(), encryptedTicket)
            {
                Expires = DateTime.Now.Add(FormsAuthentication.Timeout),
            };

            HttpContext.Current.Response.Cookies.Add(authCookie);

            var identity = new CustomIdentity(authTicket.Name);

            HttpContext.Current.User = new GenericPrincipal(identity, Enumerable.Empty<string>().ToArray());
        }
        public void SignIn(User user, bool createPersistentCookie)
        {
            var accountEntry = new AccountEntry(user);

            var authTicket = new FormsAuthenticationTicket(1,
                                                           user.Login,
                                                           DateTime.Now,
                                                           DateTime.Now.AddMinutes(45),
                                                           createPersistentCookie,
                                                           accountEntry.Serialize());

            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);

            var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
                                 {
                                     Expires = DateTime.Now.Add(FormsAuthentication.Timeout),
                                 };

            HttpContext.Current.Response.Cookies.Add(authCookie);

            var identity = new CustomIdentity(accountEntry, authTicket.Name);

            HttpContext.Current.User = new GenericPrincipal(identity, identity.GetRoles());
        }
Beispiel #43
0
        public bool Process(Chain mainChain, IBlockProvider blockProvider)
        {
            var chain = Chain.Clone();
            var chainPosition = chain.Changes.Position;
            var account = Account.Clone();
            var accountPosition = account.Entries.Position;

            bool newChain = false;
            if(!chain.Initialized)
            {
                newChain = true;

                var firstBlock = mainChain.GetBlock(StartHeight);
                chain.Initialize(firstBlock.Header, StartHeight);
            }
            var forkBlock = mainChain.FindFork(chain);
            if(forkBlock.HashBlock != chain.Tip.HashBlock)
            {
                var subChain = chain.CreateSubChain(forkBlock, false, chain.Tip, true);
                chain.SetTip(chain.GetBlock(forkBlock.Height));
                foreach(var e in account.GetInChain(subChain, true)
                                        .Where(c => c.Reason != AccountEntryReason.Lock && c.Reason != AccountEntryReason.Unlock)
                                        .Reverse())
                {
                    var neutralized = e.Neutralize();
                    account.PushAccountEntry(neutralized);
                }
            }

            var unprocessedBlocks = mainChain.ToEnumerable(true)
                                       .TakeWhile(block => block != forkBlock)
                                       .Concat(newChain ? new ChainedBlock[] { forkBlock } : new ChainedBlock[0])
                                       .Reverse().ToArray();
            foreach(var block in unprocessedBlocks)
            {
                List<byte[]> searchedData = new List<byte[]>();
                Scanner.GetScannedPushData(searchedData);
                foreach(var unspent in account.Unspent)
                {
                    searchedData.Add(unspent.OutPoint.ToBytes());
                }

                var fullBlock = blockProvider.GetBlock(block.HashBlock, searchedData);
                if(fullBlock == null)
                    continue;

                List<Tuple<OutPoint, AccountEntry>> spents = new List<Tuple<OutPoint, AccountEntry>>();
                foreach(var spent in FindSpent(fullBlock, account.Unspent))
                {
                    var entry = new AccountEntry(AccountEntryReason.Outcome,
                                                block.HashBlock,
                                                spent, -spent.TxOut.Value);
                    spents.Add(Tuple.Create(entry.Spendable.OutPoint, entry));
                }

                if(CheckDoubleSpend)
                {
                    var spentsDico = spents.ToDictionary(t => t.Item1, t => t.Item2);
                    foreach(var spent in Scanner.FindSpent(fullBlock))
                    {
                        if(!spentsDico.ContainsKey(spent.PrevOut))
                            return false;
                    }
                }

                foreach(var spent in spents)
                {
                    if(account.PushAccountEntry(spent.Item2) == null)
                        return false;
                }

                foreach(var coins in Scanner.ScanCoins(fullBlock, (int)block.Height))
                {
                    int i = 0;
                    foreach(var output in coins.Coins.Outputs)
                    {
                        if(!output.IsNull)
                        {
                            var entry = new AccountEntry(AccountEntryReason.Income, block.HashBlock,
                                                new Spendable(new OutPoint(coins.TxId, i), output), output.Value);
                            if(account.PushAccountEntry(entry) == null)
                                return false;
                        }
                        i++;
                    }
                }

                chain.GetOrAdd(block.Header);
            }

            account.Entries.GoTo(accountPosition);
            Account.Entries.WriteNext(account.Entries);
            Account.Process();

            chain.Changes.GoTo(chainPosition);
            Chain.Changes.WriteNext(chain.Changes);
            Chain.Process();
            return true;
        }
Beispiel #44
0
 public MarginAccountInfo(AccountEntry entry)
 {
     this.entry = entry;
 }
Beispiel #45
0
 public static IMarginAccountInfo ToMarginAccountInfo(AccountEntry account)
 {
     return new MarginAccountInfo(account);
 }
Beispiel #46
0
		///<summary>Creates a split similar to how CreateSplitsForPayment does it, but with selected rows of the grid.  If payAmt=0, pay charge in full.</summary>
		private void CreateSplit(AccountEntry charge,double payAmt) {
			PaySplit split=new PaySplit();
			split.DatePay=DateTime.Today;
			if(charge.GetType()==typeof(Procedure)) {//Row selected is a Procedure.
				Procedure proc=(Procedure)charge.Tag;
				split.ProcNum=charge.PriKey;
			}
			else if(charge.GetType()==typeof(PayPlanCharge)) {//Row selected is a PayPlanCharge.
				PayPlanCharge payPlanCharge=(PayPlanCharge)charge.Tag;
				split.PayPlanNum=payPlanCharge.PayPlanNum;
			}
			else if(charge.Tag.GetType()==typeof(Adjustment)) {//Row selected is an Adjustment.
				//Do nothing, nothing to link.
			}
			else {//PaySplits and overpayment refunds.
				//Do nothing, nothing to link.
			}
			double chargeAmt=charge.AmountEnd;
			if(Math.Abs(chargeAmt)<Math.Abs(payAmt) || payAmt==0) {//Full payment of charge
				split.SplitAmt=chargeAmt;
				charge.AmountEnd=0;//Reflect payment in underlying datastructure
			}
			else {//Partial payment of charge
				charge.AmountEnd-=payAmt;
				split.SplitAmt=payAmt;
			}
			if(!PrefC.GetBool(PrefName.EasyNoClinics)) {//Not no clinics
				split.ClinicNum=charge.ClinicNum;
			}
			split.ProvNum=charge.ProvNum;
			split.PatNum=charge.PatNum;
			split.ProcDate=charge.Date;
			split.PayNum=PaymentCur.PayNum;
			charge.ListPaySplits.Add(split);
			ListSplitsCur.Add(split);
		}
Beispiel #47
0
		///<summary>Simple sort that sorts based on date.</summary>
		private int AccountEntrySort(AccountEntry x,AccountEntry y) {
			return x.Date.CompareTo(y.Date);
		}
Beispiel #48
0
        public void Process(Chain mainChain, IBlockProvider blockProvider)
        {
            bool newChain = false;
            if(!Chain.Initialized)
            {
                newChain = true;

                var firstBlock = mainChain.GetBlock(StartHeight);
                Chain.Initialize(firstBlock.Header, StartHeight);
            }
            var forkBlock = mainChain.FindFork(Chain);
            if(forkBlock.HashBlock != Chain.Tip.HashBlock)
            {
                Chain.SetTip(Chain.GetBlock(forkBlock.Height));
                foreach(var e in Account.GetInChain(Chain, false)
                                            .Where(e => e.Reason != AccountEntryReason.ChainBlockChanged))
                {
                    var neutralized = e.Neutralize();
                    Account.PushAccountEntry(neutralized);
                }
            }

            var unprocessedBlocks = mainChain.ToEnumerable(true)
                                       .TakeWhile(block => block != forkBlock)
                                       .Concat(newChain ? new ChainedBlock[] { forkBlock } : new ChainedBlock[0])
                                       .Reverse().ToArray();
            foreach(var block in unprocessedBlocks)
            {
                List<byte[]> searchedData = new List<byte[]>();
                Scanner.GetScannedPushData(searchedData);
                foreach(var unspent in Account.Unspent)
                {
                    searchedData.Add(unspent.OutPoint.ToBytes());
                }

                var fullBlock = blockProvider.GetBlock(block.HashBlock, searchedData);
                if(fullBlock != null)
                {
                    foreach(var spent in Scanner.FindSpent(fullBlock, Account.Unspent))
                    {
                        var entry = new AccountEntry(AccountEntryReason.Outcome,
                                                    block.HashBlock,
                                                    spent, -spent.TxOut.Value);
                        Account.PushAccountEntry(entry);
                    }
                    foreach(var coins in Scanner.ScanCoins(fullBlock, (int)block.Height))
                    {
                        int i = 0;
                        foreach(var output in coins.Coins.Outputs)
                        {
                            if(!output.IsNull)
                            {
                                var entry = new AccountEntry(AccountEntryReason.Income, block.HashBlock,
                                                    new Spendable(new OutPoint(coins.TxId, i), output), output.Value);
                                Account.PushAccountEntry(entry);
                            }
                            i++;
                        }
                    }
                }
                Chain.GetOrAdd(block.Header);
            }
        }
Beispiel #49
0
 public CashAccountInfo(AccountEntry entry, IEnumerable<Asset> assets)
 {
     this.entry = entry;
     this.assets = assets;
 }