Fix balance calculus for sell transaction

This commit is contained in:
Tanguy Herbron 2018-08-17 04:52:27 +02:00
parent cdff187910
commit b14b98eb97

View File

@ -555,7 +555,16 @@ public class DatabaseManager extends SQLiteOpenHelper{
while(resultatList.moveToNext()) while(resultatList.moveToNext())
{ {
if(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL)).equals(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_FEE_CURRENCY)))) String symbol = resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL));
String feeSym = resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_FEE_CURRENCY));
String type = resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_TYPE));
if(type != null)
{
switch (type)
{
case "b":
if(symbol.equals(feeSym))
{ {
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL)) currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
, resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES)))); , resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
@ -565,6 +574,36 @@ public class DatabaseManager extends SQLiteOpenHelper{
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL)) currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
, resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)))); , resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT))));
} }
break;
case "s":
if(symbol.equals(feeSym))
{
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
, - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) + resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
}
else
{
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
, -resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT))));
}
break;
case "t":
break;
}
}
else
{
if(symbol.equals(feeSym))
{
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
, resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
}
else
{
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
, resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT))));
}
}
} }
resultatList.close(); resultatList.close();