private static string GetNoteToSelfMessage(AccountLedgerEntry accountLedgerEntry) { if (accountLedgerEntry.IsTransactionEvent && accountLedgerEntry.Transaction != null) { return(GetNoteToSelfMessage(accountLedgerEntry.Transaction)); } return(null); }
private static ulong?GetTransactionId(AccountLedgerEntry source) { if (source.IsTransactionEvent) { return(source.EventId); } return(null); }
public Account(decimal startingAmount) { Debug.Log(startingAmount.ToString()); this.entries = new List <AccountLedgerEntry>(); AccountLedgerEntry initialEntry = new AccountLedgerEntry( TransactionTypes.Deposit, startingAmount, startingAmount ); this.entries.Add(initialEntry); }
public decimal deposit(decimal amount) { if (amount < 0) { throw new ArgumentOutOfRangeException("Amount cannot be negative"); } decimal newBalance = this.getBalance() + amount; AccountLedgerEntry entry = new AccountLedgerEntry( TransactionTypes.Deposit, amount, newBalance ); this.entries.Add(entry); return(newBalance); }
public decimal withdraw(decimal amount) { if (amount < 0) { throw new ArgumentOutOfRangeException("Amount cannot be negative"); } decimal newBalance = this.getBalance() - amount; if (newBalance < 0) { throw new ArgumentException("Withdrawal will cause account balance to be negative"); } AccountLedgerEntry entry = new AccountLedgerEntry( TransactionTypes.Withdraw, amount, newBalance ); this.entries.Add(entry); return(newBalance); }
private static LedgerEntryType GetLedgerEntryType(AccountLedgerEntry accountLedgerEntry) { switch (accountLedgerEntry.EventType) { case "BLOCK_GENERATED": return(LedgerEntryType.BlockGenerated); case "REJECT_PHASED_TRANSACTION": return(LedgerEntryType.RejectPhasedTransaction); case "TRANSACTION_FEE": return((LedgerEntryType)(int)accountLedgerEntry.Transaction.SubType); case "ORDINARY_PAYMENT": return(LedgerEntryType.OrdinaryPayment); case "ACCOUNT_INFO": return(LedgerEntryType.AccountInfo); case "ALIAS_ASSIGNMENT": return(LedgerEntryType.AliasAssignment); case "ALIAS_BUY": return(LedgerEntryType.AliasBuy); case "ALIAS_DELETE": return(LedgerEntryType.AliasDelete); case "ALIAS_SELL": return(LedgerEntryType.AliasSell); case "ARBITRARY_MESSAGE": return(LedgerEntryType.ArbitraryMessage); case "HUB_ANNOUNCEMENT": return(LedgerEntryType.HubAnnouncement); case "PHASING_VOTE_CASTING": return(LedgerEntryType.PhasingVoteCasting); case "POLL_CREATION": return(LedgerEntryType.PollCreation); case "VOTE_CASTING": return(LedgerEntryType.VoteCasting); case "ACCOUNT_PROPERTY": return(LedgerEntryType.AccountProperty); case "ACCOUNT_PROPERTY_DELETE": return(LedgerEntryType.AccountPropertyDelete); case "ASSET_ASK_ORDER_CANCELLATION": return(LedgerEntryType.AssetAskOrderCancellation); case "ASSET_ASK_ORDER_PLACEMENT": return(LedgerEntryType.AssetAskOrderPlacement); case "ASSET_BID_ORDER_CANCELLATION": return(LedgerEntryType.AssetBidOrderCancellation); case "ASSET_BID_ORDER_PLACEMENT": return(LedgerEntryType.AssetBidOrderPlacement); case "ASSET_DIVIDEND_PAYMENT": return(LedgerEntryType.AssetDividendPayment); case "ASSET_ISSUANCE": return(LedgerEntryType.AssetIssuance); case "ASSET_TRADE": return(LedgerEntryType.AssetTrade); case "ASSET_TRANSFER": return(LedgerEntryType.AssetTransfer); case "ASSET_DELETE": return(LedgerEntryType.AssetDelete); case "DIGITAL_GOODS_DELISTED": return(LedgerEntryType.DigitalGoodsDelisted); case "DIGITAL_GOODS_DELISTING": return(LedgerEntryType.DigitalGoodsDelisting); case "DIGITAL_GOODS_DELIVERY": return(LedgerEntryType.DigitalGoodsDelivery); case "DIGITAL_GOODS_FEEDBACK": return(LedgerEntryType.DigitalGoodsFeedback); case "DIGITAL_GOODS_LISTING": return(LedgerEntryType.DigitalGoodsListing); case "DIGITAL_GOODS_PRICE_CHANGE": return(LedgerEntryType.DigitalGoodsPriceChange); case "DIGITAL_GOODS_PURCHASE": return(LedgerEntryType.DigitalGoodsPurchase); case "DIGITAL_GOODS_PURCHASE_EXPIRED": return(LedgerEntryType.DigitalGoodsPurchaseExpired); case "DIGITAL_GOODS_QUANTITY_CHANGE": return(LedgerEntryType.DigitalGoodsQuantityChange); case "DIGITAL_GOODS_REFUND": return(LedgerEntryType.DigitalGoodsRefund); case "ACCOUNT_CONTROL_EFFECTIVE_BALANCE_LEASING": return(LedgerEntryType.AccountControlEffectiveBalanceLeasing); case "ACCOUNT_CONTROL_PHASING_ONLY": return(LedgerEntryType.AccountControlPhasingOnly); case "CURRENCY_DELETION": return(LedgerEntryType.CurrencyDeletion); case "CURRENCY_DISTRIBUTION": return(LedgerEntryType.CurrencyDistribution); case "CURRENCY_EXCHANGE": return(LedgerEntryType.CurrencyExchange); case "CURRENCY_EXCHANGE_BUY": return(LedgerEntryType.CurrencyExchangeBuy); case "CURRENCY_EXCHANGE_SELL": return(LedgerEntryType.CurrencyExchangeSell); case "CURRENCY_ISSUANCE": return(LedgerEntryType.CurrencyIssuance); case "CURRENCY_MINTING": return(LedgerEntryType.CurrencyMinting); case "CURRENCY_OFFER_EXPIRED": return(LedgerEntryType.CurrencyOfferExpired); case "CURRENCY_OFFER_REPLACED": return(LedgerEntryType.ShufflingReplaced); case "CURRENCY_PUBLISH_EXCHANGE_OFFER": return(LedgerEntryType.CurrencyPublishExchangeOffer); case "CURRENCY_RESERVE_CLAIM": return(LedgerEntryType.CurrencyReserveClaim); case "CURRENCY_RESERVE_INCREASE": return(LedgerEntryType.CurrencyReserveIncrease); case "CURRENCY_TRANSFER": return(LedgerEntryType.CurrencyTransfer); case "CURRENCY_UNDO_CROWDFUNDING": return(LedgerEntryType.CurrencyUndoCrowdfunding); case "TAGGED_DATA_UPLOAD": return(LedgerEntryType.TaggedDataUpload); case "TAGGED_DATA_EXTEND": return(LedgerEntryType.TaggedDataExtend); case "SHUFFLING_REGISTRATION": return(LedgerEntryType.ShufflingRegistration); case "SHUFFLING_PROCESSING": return(LedgerEntryType.ShufflingProcessing); case "SHUFFLING_CANCELLATION": return(LedgerEntryType.ShufflingCancellation); case "SHUFFLING_DISTRIBUTION": return(LedgerEntryType.ShufflingDistribution); default: throw new ArgumentException(); } }