Fix balance calculus for sell transaction
This commit is contained in:
parent
cdff187910
commit
b14b98eb97
@ -555,15 +555,54 @@ 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)
|
||||||
{
|
{
|
||||||
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
|
switch (type)
|
||||||
, resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
|
{
|
||||||
|
case "b":
|
||||||
|
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 "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
|
else
|
||||||
{
|
{
|
||||||
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
|
if(symbol.equals(feeSym))
|
||||||
, resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT))));
|
{
|
||||||
|
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))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user