public async Task <string> SubTransfer(string currency, decimal amount, TransactionDirection direction, string subUserId, AccountType?accountType = null, AccountType?subAccountType = null, string clientOid = null) { if (clientOid == null) { clientOid = Guid.NewGuid().ToString("d"); } var dict = new Dictionary <string, object>(); dict.Add("clientOid", clientOid); dict.Add("currency", currency); dict.Add("amount", amount.ToString()); dict.Add("direction", direction == TransactionDirection.In ? "IN" : "OUT"); dict.Add("subUserId", subUserId); if (accountType is AccountType a1) { dict.Add("accountType", a1.AccountName.ToUpper()); } if (subAccountType is AccountType a2) { dict.Add("subAccountType", a2.AccountName.ToUpper()); } var jobj = await MakeRequest(HttpMethod.Post, "/api/v1/accounts/sub-transfer", reqParams : dict); return(jobj["orderId"].ToObject <string>()); }
public Transaction(string description, decimal amount, YearMonth yearMonth, TransactionDirection transactionDirection) { Description = description; Amount = amount; YearMonth = yearMonth; TransactionDirection = transactionDirection; }
public static void PrintHistory(string credential, DateTime filterDate, TransactionDirection direction = TransactionDirection.Any) { var meRecent = acManager.GetBankAccountByCredentials(new AuthenticatedOperation() { Token = credential }); var txes = meRecent.TransactionHistory.Where(x => x.Timestamp >= filterDate && MatchDirection(direction, x.Direction)).OrderBy(x => DateTime.MaxValue - x.Timestamp).ToList(); var bdy = "Transaction history: \n"; bdy += "Time | Message | Amount | Balance Then | Recipient?\n"; foreach (var tx in txes) { var balanceThen = meRecent.TransactionHistory.Where(x => x.Timestamp <= tx.Timestamp).Sum(x => x.Money.Amount * (x.Direction == TransactionDirection.Incoming ? 1 : -1)); var dir = tx.Direction == TransactionDirection.Incoming ? "" : "-"; var sentToPart = tx.Direction == TransactionDirection.Outgoing && tx.OtherPartyIban != meRecent.Iban ? $" | Sent to :{tx.OtherPartyIban}" : ""; bdy += $"{tx.Timestamp.ToLocalTime().ToString("u")} | {tx.Message} | {dir}{tx.Money.Amount} HUF | {balanceThen} HUF {sentToPart} \n"; } Console.WriteLine(bdy); }
public static string GenerateTransactionDescription( TransactionDirection transactionDirection, ITransactionOwner from, ITransactionOwner to, decimal amount ) { string message = string.Empty; string date = DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss"); switch (transactionDirection) { case TransactionDirection.In: message = string.Format("{0} have sent {1}{2} to you on {3}.", from.TransactionDetailDisplayName, amount, to.AssetsUnit, date); break; case TransactionDirection.Out: message = string.Format("You sent {0}{1} to {2} on {3}", amount, from.AssetsUnit, to.TransactionDetailDisplayName, date); break; default: break; } return(message); }
private TransferType GetTransactionSize(TransactionDirection direction, uint val) { TransferType type; switch (val) { case 0: type = TransferType.Byte; break; case 1: type = TransferType.Word; break; case 2: type = TransferType.DoubleWord; break; default: type = TransferType.DoubleWord; this.Log(LogLevel.Warning, "{0} transaction size has been truncated to 4 bytes.", direction); break; } return(type); }
public OrderEvent(string symbol, OrderType orderType, int quantity, TransactionDirection orderDirection, DateTime orderTime) { this.Symbol = symbol; this.OrderType = orderType; this.Quantity = quantity; this.OrderDirection = orderDirection; this.OrderTime = orderTime; }
public void ConvertToString_WithValidValue_ReturnsCorrectConvertion(TransactionDirection input, string expectedResult) { var writerRow = new Mock <IWriterRow>(); var result = _transactionDirectionConverter.ConvertToString(input, writerRow.Object, null); result.Should().Be(expectedResult); }
public FillEvent(DateTime timeIndex, string symbol, string exchange, int quantity, TransactionDirection direction, decimal fillCost, decimal comission = decimal.Zero) { this.TimeIndex = timeIndex; this.Symbol = symbol; this.Exchange = exchange; this.Quantity = quantity; this.Direction = direction; this.FillCost = fillCost; this.Comission = comission == decimal.Zero ? this.CalculateIbComission() : comission; }
public List <TransactionDetailDomainEntity> GetLastDateRangeAndTransactionDirectionListByTransactionDetailOwner( ITransactionDetailOwner transactionOwner, TransactionDirection transactionDirection, DateTime startDate, DateTime endDate) { return(GetOrderedDescListBy( td => td.OwnerType == transactionOwner.OwnerType.ToInt() && td.OwnerId == transactionOwner.OwnerId && td.CreateDate >= startDate && td.CreateDate <= endDate && td.TransactionDirection == transactionDirection.ToInt(), td => td.CreateDate)); }
public async Task <string> CreateContinuationTokenAsync( string address, TransactionDirection direction, string afterHash) { var receiptPartitionKey = GetReceiptPartitionKey(afterHash); var receiptsInTransaction = await _transactionReceipts.GetDataAsync(receiptPartitionKey); TransactionReceiptEntity firstAddressReceipt; string indexAddress; string nonIndexAddress; switch (direction) { case TransactionDirection.Incoming: firstAddressReceipt = receiptsInTransaction.FirstOrDefault(x => x.To == address); indexAddress = firstAddressReceipt?.To; nonIndexAddress = firstAddressReceipt?.From; break; case TransactionDirection.Outgoing: firstAddressReceipt = receiptsInTransaction.FirstOrDefault(x => x.From == address); indexAddress = firstAddressReceipt?.From; nonIndexAddress = firstAddressReceipt?.To; break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } if (firstAddressReceipt != null) { var(partitionKey, rowKey) = GetByAddressIndexKeys ( blockNumber: firstAddressReceipt.BlockNumber, indexAddress: indexAddress, nonIndexAddress: nonIndexAddress, hash: firstAddressReceipt.Hash, index: firstAddressReceipt.Index ); return(JsonConvert.SerializeObject(new TableContinuationToken { NextPartitionKey = partitionKey, NextRowKey = rowKey }).StringToHex()); } else { return(null); } }
private void Initialize(uint index, TransactionDirection direction, DateTime startTime, DateTime endTime) { initializing = true; InitializeBasics(); this.index = index; this.direction = direction; if (direction == TransactionDirection.In) { headerBackColor = Color.FromArgb(240, 240, 255); FrameColor = Color.FromArgb(62, 72, 251); } else if (direction == TransactionDirection.Out) { headerBackColor = Color.FromArgb(252, 250, 227); FrameColor = Color.FromArgb(250, 189, 35); } else { headerBackColor = Color.FromArgb(240, 240, 255); FrameColor = Color.FromArgb(62, 72, 251); } this.startTime = startTime; this.endTime = endTime; HeadlineBackColor = BodyBackColor = HeaderBackColor; HeadlineForeColor = headerForeColor = BodyForeColor = Color.Black; HeadlineFont = new Font("Lucida Console", 8); HeaderFont = new Font("Lucida Console", 8); BodyFont = new Font("Lucida Console", 8); headerRowsPerCol = 5; framePenWidth = 1; testScenario = -1; contextID = null; previewImage = null; initializing = false; Recalibrate(); }
public TransactionDetailDomainEntity With( string description, DateTime createDate, AccountTransactionDomainEntity accountTransaction, ITransactionDetailOwner transactionDetailOwner, TransactionDirection transactionDirection) { Description = description; CreateDate = createDate; AccountTransaction = accountTransaction; TransactionDetailOwner = transactionDetailOwner; TransactionDirection = transactionDirection; return(this); }
//TODO might have gone a bit crazy with the VerifyJournal public Transaction( Journal journal, TransactionDirection direction, Account account = null, Decimal amount = 0M, string note = "" ) { _journal = journal; journal.AddTransaction(this); Direction = direction; Account = account; Amount = amount; Note = note; }
public TransactionDetailDomainEntity CreateTransactionDetail(TransactionDirection transactionDirection) { string description = ApiUtils.GenerateTransactionDescription( transactionDirection, FromTransactionOwner, ToTransactionOwner, Amount); if (transactionDirection == TransactionDirection.In) { return(coreContext.New <TransactionDetailDomainEntity>() .With(description, TransactionDate, this, (ITransactionDetailOwner)FromTransactionOwner, transactionDirection)); } else { return(coreContext.New <TransactionDetailDomainEntity>() .With(description, TransactionDate, this, (ITransactionDetailOwner)ToTransactionOwner, transactionDirection)); } }
public VisualTransaction(SerializationInfo info, StreamingContext ctx) { initializing = true; InitializeBasics(); index = info.GetUInt32("index"); direction = (TransactionDirection)info.GetValue("direction", typeof(TransactionDirection)); startTime = (DateTime)info.GetValue("startTime", typeof(DateTime)); endTime = (DateTime)info.GetValue("endTime", typeof(DateTime)); HeadlineBackColor = (Color)info.GetValue("HeadlineBackColor", typeof(Color)); HeadlineForeColor = (Color)info.GetValue("HeadlineForeColor", typeof(Color)); headerBackColor = (Color)info.GetValue("headerBackColor", typeof(Color)); headerForeColor = (Color)info.GetValue("headerForeColor", typeof(Color)); BodyBackColor = (Color)info.GetValue("BodyBackColor", typeof(Color)); BodyForeColor = (Color)info.GetValue("BodyForeColor", typeof(Color)); HeadlineFont = (Font)info.GetValue("HeadlineFont", typeof(Font)); HeaderFont = (Font)info.GetValue("HeaderFont", typeof(Font)); BodyFont = (Font)info.GetValue("BodyFont", typeof(Font)); headerRowsPerCol = info.GetInt32("headerRowsPerCol"); framePenWidth = (int)info.GetValue("framePenWidth", typeof(int)); frameColor = (Color)info.GetValue("frameColor", typeof(Color)); HeadlineText = info.GetString("HeadlineText"); bodyBox.Rtf = info.GetString("BodyRtf"); contextID = info.GetString("contextID"); previewImage = (Image)info.GetValue("previewImage", typeof(Image)); TestScenario = info.GetInt32("TestScenario"); initializing = false; Recalibrate(); }
public async Task <(IEnumerable <TransactionReceipt> Transactions, string ContinuationToken)> GetAsync( string address, TransactionDirection direction, int take, string continuationToken) { INoSQLTableStorage <AzureIndex> byAddressIndices; IEnumerable <AzureIndex> indices; switch (direction) { case TransactionDirection.Incoming: byAddressIndices = _byToIndices; break; case TransactionDirection.Outgoing: byAddressIndices = _byFromIndices; break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } var partitionKey = GetAddressIndexPartitionKey(address); (indices, continuationToken) = await byAddressIndices .GetDataWithContinuationTokenAsync(partitionKey, take, continuationToken); var receiptKeys = indices .Select(x => new Tuple <string, string>(x.PrimaryPartitionKey, x.PrimaryRowKey)); var receipts = (await _transactionReceipts.GetDataAsync(receiptKeys)) .Select(x => new TransactionReceipt ( amount: x.Amount, blockNumber: x.BlockNumber, @from: x.From, hash: x.Hash, index: x.Index, timestamp: x.TransactionTimestamp, to: x.To )); return(receipts, continuationToken); }
public BigInteger GetValue(IEnumerable <string> aAddreses, out TransactionDirection aTxDirection) { BigInteger lResult = 0; aTxDirection = TransactionDirection.Unknown; var lNormalizedAddresses = aAddreses.Select(lAddress => lAddress.ToLowerInvariant()); if (lNormalizedAddresses.Contains(To.ToLowerInvariant())) { lResult += Amount; aTxDirection = TransactionDirection.Credit; } if (lNormalizedAddresses.Contains(From.ToLowerInvariant())) { lResult -= Amount; aTxDirection = aTxDirection == TransactionDirection.Credit ? TransactionDirection.Both : TransactionDirection.Debit; } return(lResult); }
private async Task <IEnumerable <TransactionReceipt> > GetHistoryAsync( string address, TransactionDirection transactionDirection, int take, string afterHash) { var continuationToken = await _transactionReceiptRepository.CreateContinuationTokenAsync ( address, transactionDirection, afterHash ); var(transactionReceipts, _) = await _transactionReceiptRepository.GetAsync ( address, transactionDirection, take, continuationToken ); return(transactionReceipts); }
public BigInteger GetValue(string[] aAddresses, out TransactionDirection aTxType, out string aLastToAddress, out string aLastFromAddress) { BigInteger lResult = 0; BigInteger lAllOutputs = 0; BigInteger lAllInputs = 0; int lOtherAddressCount = 0; aTxType = TransactionDirection.Unknown; aLastFromAddress = DefaultAddress; aLastToAddress = aLastFromAddress; string lLastUserToAddress = null; string lLastUserFromAddress = null; if (Outputs != null) { foreach (var lOutput in Outputs) { if (Array.IndexOf(aAddresses, lOutput.Address) == -1) { lOtherAddressCount++; // address not found so count the addresses not belonging to you. aLastToAddress = lOutput.Address; } else { lResult += lOutput.Amount; lLastUserToAddress = lOutput.Address; } lAllOutputs += lOutput.Amount; } } else { lOtherAddressCount++; // this is a tx but no outputs then the outputs don;t belong to you } if (Inputs != null) { foreach (var lInput in Inputs) { if (Array.IndexOf(aAddresses, lInput.Address) == -1) { lOtherAddressCount++; aLastFromAddress = lInput.Address; } else { lResult -= lInput.Amount; lLastUserFromAddress = lInput.Address; } lAllInputs += lInput.Amount; } } else { lOtherAddressCount++; // no inputs because we don't store external address then 1 our more inputs are not yours. } this.TxFee = (long)(lAllInputs - lAllOutputs); if (lResult < 0) { aTxType = TransactionDirection.Debit; if (lOtherAddressCount == 0) { aTxType = TransactionDirection.Both; } if (aLastFromAddress == DefaultAddress && lLastUserFromAddress != null) { aLastFromAddress = lLastUserFromAddress; } if (aLastToAddress == DefaultAddress && lLastUserToAddress != null) { aLastToAddress = lLastUserToAddress; } } else if (lResult > 0) { aTxType = TYPE_Credit; if (lLastUserToAddress != null) { aLastToAddress = lLastUserToAddress; } if (aLastFromAddress == DefaultAddress) { this.TxFee = 0; // we don't know what the fee is because we dont have all the inputs. if (lLastUserFromAddress != null) { aLastFromAddress = lLastUserFromAddress; } } } return(lResult); }
public void AddHeaderField (string name, TransactionDirection direction) { AddHeaderField (name, (direction == TransactionDirection.In) ? "in" : "out"); }
public VisualTransaction (uint index, TransactionDirection direction) { Initialize(index, direction, DateTime.Now, DateTime.Now); }
public VisualTransaction(SerializationInfo info, StreamingContext ctx) { initializing = true; InitializeBasics(); index = info.GetUInt32("index"); direction = (TransactionDirection) info.GetValue ("direction", typeof (TransactionDirection)); startTime = (DateTime) info.GetValue("startTime", typeof(DateTime)); endTime = (DateTime)info.GetValue("endTime", typeof(DateTime)); HeadlineBackColor = (Color)info.GetValue("HeadlineBackColor", typeof(Color)); HeadlineForeColor = (Color)info.GetValue("HeadlineForeColor", typeof(Color)); headerBackColor = (Color)info.GetValue("headerBackColor", typeof(Color)); headerForeColor = (Color) info.GetValue("headerForeColor", typeof(Color)); BodyBackColor = (Color)info.GetValue("BodyBackColor", typeof(Color)); BodyForeColor = (Color)info.GetValue("BodyForeColor", typeof(Color)); HeadlineFont = (Font)info.GetValue("HeadlineFont", typeof(Font)); HeaderFont = (Font)info.GetValue("HeaderFont", typeof(Font)); BodyFont = (Font)info.GetValue("BodyFont", typeof(Font)); headerRowsPerCol = info.GetInt32("headerRowsPerCol"); framePenWidth = (int) info.GetValue("framePenWidth", typeof(int)); frameColor = (Color) info.GetValue("frameColor", typeof(Color)); HeadlineText = info.GetString("HeadlineText"); bodyBox.Rtf = info.GetString("BodyRtf"); contextID = info.GetString("contextID"); previewImage = (Image) info.GetValue("previewImage", typeof(Image)); TestScenario = info.GetInt32("TestScenario"); initializing = false; Recalibrate(); }
// TODO: Convert to extension private static int GetNumericDirection(TransactionDirection dir) { return dir == TransactionDirection.Buy ? 1 : dir == TransactionDirection.Sell ? -1 : 0; }
public void AddHeaderField(string name, TransactionDirection direction) { AddHeaderField(name, (direction == TransactionDirection.In) ? "in" : "out"); }
public void ConvertFromString_WithValidValue_ReturnsCorrectConvertion(string input, TransactionDirection expectedResult) { var readerRow = new Mock <IReaderRow>(); var result = _transactionDirectionConverter.ConvertFromString(input, readerRow.Object, null); result.Should().Be(expectedResult); }
// TODO: Convert to extension private static int GetNumericDirection(TransactionDirection dir) { return(dir == TransactionDirection.Buy ? 1 : dir == TransactionDirection.Sell ? -1 : 0); }
/// <summary> /// Method to list transactions for specify address. /// </summary> /// <param name="address"></param> /// <param name="direction"></param> /// <returns></returns> public ListTransactionsForAddressResult ListTransactionsForAddress(string address, TransactionDirection direction = TransactionDirection.BOTH) { ListTransactionsForAddressResult final = new ListTransactionsForAddressResult(); final.transactions = new List <Transaction>(); ListTransactionsResult list = ListTransactions(1000000); var transactions = list.result.Where(x => x.address == address); if (direction == TransactionDirection.SENT) { transactions = transactions.Where(x => x.category == "send"); } else if (direction == TransactionDirection.RECEIVED) { transactions = transactions.Where(x => x.category == "receive"); } transactions = transactions.Select(x => x).OrderByDescending(x => x.blockindex); foreach (Transaction trans in transactions) { final.transactions.Add(trans); } return(final); }
public void AddTransaction(string description, decimal amount, YearMonth yearMonth, TransactionDirection transactionDirection) { OriginalTransactions.Add(new Transaction(description, amount, yearMonth, transactionDirection)); var existingGroupedTransaction = SearchGroupedTransaction(yearMonth, transactionDirection); if (existingGroupedTransaction == null) { var groupedTransaction = new GroupedTransaction(amount, yearMonth, transactionDirection); TransactionsPerMonthYear.Add(groupedTransaction); } else { existingGroupedTransaction.RaiseAmount(amount); } }
public void DoOperation(Storage storage, int resourceId, decimal quantity, decimal price, TransactionDirection direction) { var transactionId = DateTime.Now.Ticks; if (direction == TransactionDirection.Income) { storage.DoIncomeOperation(resourceId, quantity, price); } else { } }
public List <TransactionDetailDomainEntity> GetLastTransactionDetailDateRangeAndTransactionDirectionList( TransactionDirection transactionDirection, DateTime startDate, DateTime endDate) { return(coreContext.Query <ITransactionDetailRepository>() .GetLastDateRangeAndTransactionDirectionListByTransactionDetailOwner(this, transactionDirection, startDate, endDate)); }
public VisualTransaction (uint index, TransactionDirection direction, DateTime startTime, DateTime endTime) { Initialize(index, direction, startTime, endTime); }
public static int ToInt(this TransactionDirection transactionDirection) { return(Convert.ToInt32(transactionDirection)); }
public void ToggleDirectionCommand_toggles_transaction_direction(TransactionDirection initialDirection, TransactionDirection toggledDirection) { var transaction = new Transaction(_journal, initialDirection); var vm = new TransactionViewModel(transaction, _mockAccountRepository); vm.PropertyChanged += _changeCounter.HandlePropertyChange; bool hasTransactionModifiedBeenCalled = false; vm.TransactionModified += (o, e) => { hasTransactionModifiedBeenCalled = true; }; vm.ToggleDirectionCommand.Execute(null); Assert.AreEqual(toggledDirection, transaction.Direction); Assert.AreEqual(7, _changeCounter.NoOfPropertiesChanged); Assert.AreEqual(7, _changeCounter.TotalChangeCount); Assert.AreEqual(1, _changeCounter.ChangeCount("ToggleDirectionText")); Assert.AreEqual(1, _changeCounter.ChangeCount("AmountIn")); Assert.AreEqual(1, _changeCounter.ChangeCount("AmountOut")); Assert.AreEqual(1, _changeCounter.ChangeCount("IsAmountInEnabled")); Assert.AreEqual(1, _changeCounter.ChangeCount("IsAmountOutEnabled")); Assert.AreEqual(1, _changeCounter.ChangeCount("AmountInBackgroundColour")); Assert.AreEqual(1, _changeCounter.ChangeCount("AmountOutBackgroundColour")); Assert.IsTrue(hasTransactionModifiedBeenCalled); }
public XmlMapperManager(TransactionDirection transactionDirection) { this.TransactionDirection = transactionDirection; }
public static bool MatchDirection(TransactionDirection d1, TransactionDirection d2) { return(d1 == TransactionDirection.Any || (d2 == TransactionDirection.Any || (d1 == d2))); }
private void Initialize (uint index, TransactionDirection direction, DateTime startTime, DateTime endTime) { initializing = true; InitializeBasics(); this.index = index; this.direction = direction; if (direction == TransactionDirection.In) { headerBackColor = Color.FromArgb(240, 240, 255); FrameColor = Color.FromArgb(62, 72, 251); } else if (direction == TransactionDirection.Out) { headerBackColor = Color.FromArgb(252, 250, 227); FrameColor = Color.FromArgb(250, 189, 35); } else { headerBackColor = Color.FromArgb(240, 240, 255); FrameColor = Color.FromArgb(62, 72, 251); } this.startTime = startTime; this.endTime = endTime; HeadlineBackColor = BodyBackColor = HeaderBackColor; HeadlineForeColor = headerForeColor = BodyForeColor = Color.Black; HeadlineFont = new Font("Lucida Console", 8); HeaderFont = new Font("Lucida Console", 8); BodyFont = new Font("Lucida Console", 8); headerRowsPerCol = 5; framePenWidth = 1; testScenario = -1; contextID = null; previewImage = null; initializing = false; Recalibrate(); }
private GroupedTransaction SearchGroupedTransaction(YearMonth yearMonth, TransactionDirection transactionDirection) { return(TransactionsPerMonthYear .SingleOrDefault(transaction => transaction.YearMonth == yearMonth && transaction.TransactionDirection == transactionDirection)); }
public GroupedTransaction(decimal amount, YearMonth yearMonth, TransactionDirection transactionDirection) { Amount = amount; YearMonth = yearMonth; TransactionDirection = transactionDirection; }