From 4738a65dcc7e5bfe0ba2986a45e2ad4f716d972a Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Mon, 27 Aug 2018 02:48:16 +0200 Subject: [PATCH] [Untested] Fix balance deductions --- .idea/caches/build_file_checksums.ser | Bin 545 -> 540 bytes .../moodl/DataManagers/DatabaseManager.java | 16 ++++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index ade57472755c33bf79039d6ed2cf8f39c522ab98..c7baaf739d989bc42cf5042f3ae94cae9fd2ff69 100644 GIT binary patch delta 75 zcmV-R0JQ(11e^qrm;`vmjm(jpwGt~sI$TwAWpZ;|M|Ej*Z*^{ElfD5qlTiUg8PyUh hQsgO{MjOF-z)RJ-5p)0%XL4a=Y-N*x0Tq)F0uh5M9IOBU delta 81 zcmV-X0IvU>1fc|wm;^R1jY^T6wUe0vL^7xp5}ld>Xcf?C5YOMJAn0@eFhe?ARdZ!> nb6i1WZE0?4b98cHbZ>H8E@yIKWNc+zlkfo>lZOEklkWj74Lu)t diff --git a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java index 7f50807..4abca59 100644 --- a/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java +++ b/app/src/main/java/com/herbron/moodl/DataManagers/DatabaseManager.java @@ -603,6 +603,14 @@ public class DatabaseManager extends SQLiteOpenHelper{ currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL)) , resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)))); } + + if(resultatList.getInt(resultatList.getColumnIndex(KEY_TRANSACTION_DEDUCT)) == 1) + { + currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_PAIR)) + , -(resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_PURCHASE_PRICE)) + * resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) + + resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))))); + } break; case "s": if(symbol.equals(feeSym)) @@ -615,6 +623,14 @@ public class DatabaseManager extends SQLiteOpenHelper{ currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL)) , -resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)))); } + + if(resultatList.getInt(resultatList.getColumnIndex(KEY_TRANSACTION_DEDUCT)) == 1) + { + currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_PAIR)) + , resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_PURCHASE_PRICE)) + * resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) + - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES)))); + } break; case "t": if(isBalanceRelated(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SOURCE))) && isBalanceRelated(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_DESTINATION))))