Skip to content

Commit

Permalink
Fix: computation of imbalance amount in split editor for Liabilities
Browse files Browse the repository at this point in the history
Fixes codinguser#462
Hide split button when in single-entry mode
Upgrade android build tools version to 23.0.2 and android gradle tools to 1.5.0
  • Loading branch information
codinguser committed Feb 4, 2016
1 parent 1ce3433 commit 8a61607
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Change Log
Version 2.0.6 *(2016-02-29)*
----------------------------
* Fixed: Saving transaction gets slower with increase in size of database
* Fixed: Imbalance amount wrongly computed in split editor (for some accounts)
* Fixed: Amount text boxes in split editor sometimes do not get focus
* Fixed: Crash when creating a new transaction with no transfer account

Version 2.0.5 *(2015-12-12)*
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apply plugin: 'io.fabric'

def versionMajor = 2
def versionMinor = 0
def versionPatch = 5
def versionPatch = 6
def versionBuild = 0

def buildTime() {
Expand All @@ -21,7 +21,7 @@ def gitSha() {

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "org.gnucash.android"
testApplicationId 'org.gnucash.android.test'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 - 2015 Ngewi Fet <ngewif@gmail.com>
* Copyright (c) 2014 - 2016 Ngewi Fet <ngewif@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,8 +43,6 @@
import android.widget.TextView;
import android.widget.Toast;

import com.crashlytics.android.Crashlytics;

import net.objecthunter.exp4j.Expression;
import net.objecthunter.exp4j.ExpressionBuilder;

Expand Down Expand Up @@ -443,14 +441,25 @@ public void afterTextChanged(Editable editable) {
for (View splitItem : mSplitItemViewList) {
SplitViewHolder viewHolder = (SplitViewHolder) splitItem.getTag();
BigDecimal amount = viewHolder.getAmountValue().abs();
long accountId = viewHolder.accountsSpinner.getSelectedItemId();
boolean hasDebitNormalBalance = AccountsDbAdapter.getInstance()
.getAccountType(accountId).hasDebitNormalBalance();

if (viewHolder.splitTypeSwitch.isChecked()) {
imbalance = imbalance.subtract(amount);
if (hasDebitNormalBalance)
imbalance = imbalance.add(amount);
else
imbalance = imbalance.subtract(amount);
} else {
imbalance = imbalance.add(amount);
if (hasDebitNormalBalance)
imbalance = imbalance.subtract(amount);
else
imbalance = imbalance.add(amount);
}

}

TransactionsActivity.displayBalance(mImbalanceTextView, new Money(imbalance.negate(), mCommodity));
TransactionsActivity.displayBalance(mImbalanceTextView, new Money(imbalance, mCommodity));
}
}

Expand All @@ -477,6 +486,9 @@ public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int
AccountType accountType = mAccountsDbAdapter.getAccountType(id);
mTypeToggleButton.setAccountType(accountType);

//refresh the imbalance amount if we change the account
mImbalanceWatcher.afterTextChanged(null);

String fromCurrencyCode = mAccountsDbAdapter.getCurrencyCode(mAccountUID);
String targetCurrencyCode = mAccountsDbAdapter.getCurrencyCode(mAccountsDbAdapter.getUID(id));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public void onActivityCreated(Bundle savedInstanceState) {
mUseDoubleEntry = sharedPrefs.getBoolean(getString(R.string.key_use_double_entry), false);
if (!mUseDoubleEntry){
mDoubleEntryLayout.setVisibility(View.GONE);
mOpenSplitEditor.setVisibility(View.GONE);
}

mAccountUID = getArguments().getString(UxArgument.SELECTED_ACCOUNT_UID);
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'io.fabric.tools:gradle:1.+'
}
}
Expand Down

0 comments on commit 8a61607

Please sign in to comment.