Ejemplo n.º 1
0
        private void CreateBuyTransaction(
            Account account,
            DateTime transactionDate,
            string tickerSymbol,
            string description,
            decimal price,
            decimal quantity,
            decimal comission)
        {
            var total = (price * quantity) + comission;

            var cashTransaction = new CashTransaction
            {
                TransactionDate = transactionDate,
                Description     = description,
                Amount          = -total
            };

            var assetTransaction = new AssetTransaction
            {
                TransactionType = TransactionType.BuySell,
                TransactionDate = transactionDate,
                TickerSymbol    = tickerSymbol,
                Description     = description,
                Price           = price,
                Quantity        = quantity,
                Commission      = comission,
                Amount          = total,
                CashTransaction = cashTransaction
            };

            account.CashTransactions.Add(cashTransaction);
            account.AssetTransactions.Add(assetTransaction);
        }
Ejemplo n.º 2
0
        private void CreateDividendTransaction(
            Account account,
            DateTime transactionDate,
            string tickerSymbol,
            string description,
            decimal amount)
        {
            var cashTransaction = new CashTransaction
            {
                TransactionDate = transactionDate,
                Description     = description,
                Amount          = amount
            };

            var assetTransaction = new AssetTransaction
            {
                TransactionType = TransactionType.Dividend,
                TransactionDate = transactionDate,
                TickerSymbol    = tickerSymbol,
                Description     = description,
                Amount          = amount,
                CashTransaction = cashTransaction
            };

            account.CashTransactions.Add(cashTransaction);
            account.AssetTransactions.Add(assetTransaction);
        }