Exemple #1
0
    private static async Task <ITransactionModel> SetupExchangeTransaction(CryptoDotComModel original, string[] entryData, Func <string, Type, object> convertFromString)
    {
        original.TransactionType = TransactionType.Sale;

        original.ApplyNonNegative();

        CryptoDotComModel next = new CryptoDotComModel();

        string[] nEntryData = new string[] { entryData[4], entryData[5] };

        await next.InternalInit(original.TimeStamp, original.NativeAmount, original.NativeCurrency, nEntryData, convertFromString);

        return(next);
    }
Exemple #2
0
    private static async Task <List <ITransactionModel> > InitializeFromData(string transactionKind, string[] entryData, Func <string, Type, object> convertFromString)
    {
        List <ITransactionModel> transactions = new List <ITransactionModel>();

        CryptoDotComModel cryptoDotComModel = new CryptoDotComModel();

        cryptoDotComModel.TimeStamp = (DateTime)convertFromString.Invoke(entryData[0], typeof(DateTime));

        if (transactionKind == VIBAN_PURCHASE)
        {
            cryptoDotComModel.CryptoCurrency       = entryData[4];
            cryptoDotComModel.CryptoCurrencyAmount = (decimal)convertFromString.Invoke(entryData[5], typeof(decimal));
        }
        else
        {
            cryptoDotComModel.CryptoCurrency       = entryData[2];
            cryptoDotComModel.CryptoCurrencyAmount = (decimal)convertFromString.Invoke(entryData[3], typeof(decimal));
        }

        cryptoDotComModel.NativeCurrency = entryData[6];
        cryptoDotComModel.NativeAmount   = (decimal)convertFromString.Invoke(entryData[7], typeof(decimal));

        transactions.Add(cryptoDotComModel);

        if (REVERSION.Contains(transactionKind))
        {
            cryptoDotComModel.TransactionType = TransactionType.Reversion;
        }
        else if (transactionKind == CRYPTO_EXHANGE)
        {
            cryptoDotComModel.TransactionType = TransactionType.Sale;

            transactions.Add(await SetupExchangeTransaction(cryptoDotComModel, entryData, convertFromString));
        }
        else if (SALES.Contains(transactionKind))
        {
            cryptoDotComModel.TransactionType = TransactionType.Sale;

            cryptoDotComModel.ApplyNonNegative();
        }
        else
        {
            cryptoDotComModel.TransactionType = TransactionType.Purchase;

            if (REBATES.Contains(transactionKind))
            {
                cryptoDotComModel.TransactionType = TransactionType.Rebate;
            }

            if (FULL_TAX.Contains(transactionKind))
            {
                if (transactionKind == FULL_TAX[0])
                {
                    cryptoDotComModel.TransactionType = TransactionType.Interest;
                }

                cryptoDotComModel.IsFullyTaxed = true;
            }
        }

        cryptoDotComModel.AddUpdateCurrency();

        return(transactions);
    }