Skip to content

Commit bbe3e2d

Browse files
committed
Merge branch 'hotfix/account_balance'
2 parents c2bbc97 + c593851 commit bbe3e2d

File tree

85 files changed

+1741
-658
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1741
-658
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
Change Log
22
===============================================================================
3+
Version 2.0.1 *(2015-11-05)*
4+
----------------------------
5+
* Feature: Menu options for moving/duplicating transactions
6+
* Fixed: Invalid QIF exported, causing crashes when importing on desktop
7+
* Fixed: Account delete dialog not displaying properly / only partially deleting transactions
8+
* Fixed: Moving transaction to another account from within the split editor sets the amount to zero
9+
* Improved: Amounts now use standard commodities & fraction digit on all devices
10+
311
Version 2.0.0 *(2015-11-01)*
412
----------------------------
513
* Feature: Updated app design to use Material Design guidelines

app/build.gradle

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ apply plugin: 'io.fabric'
55

66
def versionMajor = 2
77
def versionMinor = 0
8-
def versionPatch = 0
9-
def versionBuild = 8
8+
def versionPatch = 1
9+
def versionBuild = 3
1010

1111
def buildTime() {
1212
def df = new SimpleDateFormat("yyyyMMdd HH:mm 'UTC'")
@@ -127,9 +127,26 @@ android {
127127
}
128128
}
129129

130+
/**
131+
* Create the Crashlytics properties file when building on CI
132+
* @return
133+
*/
134+
def initCrashlyticsPropertiesIfNeeded() {
135+
def propertiesFile = file('fabric.properties')
136+
if (!propertiesFile.exists()) {
137+
def commentMessage = "This is autogenerated crashlytics property from system environment to prevent key to be committed to source control."
138+
ant.propertyfile(file: "fabric.properties", comment: commentMessage) { //the keys added here are invalid, just placeholders to make builds pass
139+
entry(key: "apiSecret", value: "bd4e83a9a4c35fbf1fbe8d9ccce9443eebb9d5835605f9d06767850e0f1e5b22")
140+
entry(key: "apiKey", value: "46fe045d00d4ad8a71014c53567be3368e10bd64")
141+
}
142+
}
143+
}
144+
130145
def adb = android.getAdbExe().toString()
131146

132147
afterEvaluate {
148+
initCrashlyticsPropertiesIfNeeded()
149+
133150
task grantAnimationPermissionDevel(type: Exec, dependsOn: 'installDevelopmentDebug') { // or install{productFlavour}{buildType}
134151
commandLine "$adb", 'devices'
135152
standardOutput = new ByteArrayOutputStream()
@@ -138,11 +155,13 @@ afterEvaluate {
138155
output.eachLine {
139156
def serial = it.split("\\s")[0]
140157
commandLine "$adb -s $serial shell pm grant $android.productFlavors.development.applicationId android.permission.SET_ANIMATION_SCALE".split(' ')
158+
commandLine "$adb -s $serial shell pm grant $android.productFlavors.development.applicationId android.permission.WRITE_EXTERNAL_STORAGE".split(' ')
141159
}
142160
}
143161

144162
task grantAnimationPermissionProduction(type: Exec, dependsOn: 'installProductionDebug'){
145163
commandLine "$adb -e shell pm grant $android.defaultConfig.applicationId android.permission.SET_ANIMATION_SCALE".split(' ')
164+
commandLine "$adb -e shell pm grant $android.defaultConfig.applicationId android.permission.WRITE_EXTERNAL_STORAGE".split(' ')
146165
}
147166
// When launching individual tests from Android Studio, it seems that only the assemble tasks
148167
// get called directly, not the install* versions
@@ -173,7 +192,6 @@ dependencies {
173192
'org.jraf:android-switch-backport:2.0.1@aar',
174193
'com.github.PhilJay:MPAndroidChart:v2.1.3',
175194
'joda-time:joda-time:2.7',
176-
'org.ocpsoft.prettytime:prettytime:3.2.7.Final',
177195
'com.google.android.gms:play-services-drive:7.0.0',
178196
'com.jakewharton:butterknife:7.0.1',
179197
'com.kobakei:ratethisapp:0.0.3',
@@ -188,7 +206,7 @@ dependencies {
188206
exclude module: 'httpclient'
189207
}
190208

191-
compile('com.crashlytics.sdk.android:crashlytics:2.5.0@aar') {
209+
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
192210
transitive = true;
193211
}
194212

app/src/androidTest/java/org/gnucash/android/test/ui/AccountsActivityTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.gnucash.android.db.TransactionsDbAdapter;
4141
import org.gnucash.android.model.Account;
4242
import org.gnucash.android.model.AccountType;
43+
import org.gnucash.android.model.Commodity;
4344
import org.gnucash.android.model.Money;
4445
import org.gnucash.android.model.Split;
4546
import org.gnucash.android.model.Transaction;
@@ -80,7 +81,7 @@
8081
@RunWith(AndroidJUnit4.class)
8182
public class AccountsActivityTest extends ActivityInstrumentationTestCase2<AccountsActivity> {
8283
private static final String DUMMY_ACCOUNT_CURRENCY_CODE = "USD";
83-
private static final Currency DUMMY_ACCOUNT_CURRENCY = Currency.getInstance(DUMMY_ACCOUNT_CURRENCY_CODE);
84+
private static final Commodity DUMMY_ACCOUNT_CURRENCY = Commodity.getInstance(DUMMY_ACCOUNT_CURRENCY_CODE);
8485
private static final String DUMMY_ACCOUNT_NAME = "Dummy account";
8586
public static final String DUMMY_ACCOUNT_UID = "dummy-account";
8687
private DatabaseHelper mDbHelper;
@@ -115,7 +116,7 @@ public void setUp() throws Exception {
115116

116117
Account account = new Account(DUMMY_ACCOUNT_NAME);
117118
account.setUID(DUMMY_ACCOUNT_UID);
118-
account.setCurrency(Currency.getInstance(DUMMY_ACCOUNT_CURRENCY_CODE));
119+
account.setCommodity(Commodity.getInstance(DUMMY_ACCOUNT_CURRENCY_CODE));
119120
mAccountsDbAdapter.addRecord(account);
120121
refreshAccountsList();
121122
}
@@ -201,7 +202,7 @@ public void testCreateAccount(){
201202
@Test
202203
public void testChangeParentAccount() {
203204
final String accountName = "Euro Account";
204-
Account account = new Account(accountName, Currency.getInstance("EUR"));
205+
Account account = new Account(accountName, Commodity.EUR);
205206
mAccountsDbAdapter.addRecord(account);
206207

207208
refreshAccountsList();
@@ -282,7 +283,7 @@ public void editingAccountShouldNotDeleteTransactions(){
282283
.perform(click());
283284

284285
Account account = new Account("Transfer Account");
285-
account.setCurrency(DUMMY_ACCOUNT_CURRENCY);
286+
account.setCommodity(Commodity.getInstance(DUMMY_ACCOUNT_CURRENCY.getCurrencyCode()));
286287
Transaction transaction = new Transaction("Simple trxn");
287288
transaction.setCurrencyCode(DUMMY_ACCOUNT_CURRENCY.getCurrencyCode());
288289
Split split = new Split(new Money(BigDecimal.TEN, DUMMY_ACCOUNT_CURRENCY), account.getUID());

app/src/androidTest/java/org/gnucash/android/test/ui/ExportTransactionsTest.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.gnucash.android.test.ui;
1818

1919
import android.Manifest;
20+
import android.app.AlertDialog;
2021
import android.content.pm.PackageManager;
2122
import android.database.SQLException;
2223
import android.database.sqlite.SQLiteDatabase;
@@ -48,8 +49,10 @@
4849
import org.gnucash.android.ui.account.AccountsActivity;
4950
import org.junit.After;
5051
import org.junit.Before;
52+
import org.junit.FixMethodOrder;
5153
import org.junit.Test;
5254
import org.junit.runner.RunWith;
55+
import org.junit.runners.MethodSorters;
5356

5457
import java.io.File;
5558
import java.util.Currency;
@@ -68,6 +71,7 @@
6871
import static org.hamcrest.Matchers.allOf;
6972

7073
@RunWith(AndroidJUnit4.class)
74+
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
7175
public class ExportTransactionsTest extends
7276
ActivityInstrumentationTestCase2<AccountsActivity> {
7377

@@ -136,7 +140,7 @@ public void testOfxExport(){
136140
}
137141

138142
@Test
139-
public void shouldNotOfferXmlExportInSingleEntryMode(){
143+
public void whenInSingleEntry_shouldHideXmlExportOption(){
140144
PreferenceManager.getDefaultSharedPreferences(mAcccountsActivity)
141145
.edit().putBoolean(mAcccountsActivity.getString(R.string.key_use_double_entry), false)
142146
.commit();
@@ -174,7 +178,7 @@ public void testExport(ExportFormat format){
174178
mAcccountsActivity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE,
175179
Manifest.permission.READ_EXTERNAL_STORAGE}, 0x23);
176180

177-
onView(withId(android.R.id.button1)).perform(click());
181+
onView(withId(AlertDialog.BUTTON_POSITIVE)).perform(click());
178182
}
179183
}
180184

@@ -216,7 +220,7 @@ public void testDeleteTransactionsAfterExport(){
216220
* Does not work on Travis yet
217221
*/
218222
@Test
219-
public void shouldCreateExportSchedule(){
223+
public void testShouldCreateExportSchedule(){
220224
DrawerActions.openDrawer(R.id.drawer_layout);
221225
onView(withText(R.string.nav_menu_export)).perform(click());
222226

app/src/androidTest/java/org/gnucash/android/test/ui/PieChartReportTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.gnucash.android.importer.GncXmlImporter;
4343
import org.gnucash.android.model.Account;
4444
import org.gnucash.android.model.AccountType;
45+
import org.gnucash.android.model.Commodity;
4546
import org.gnucash.android.model.Money;
4647
import org.gnucash.android.model.Split;
4748
import org.gnucash.android.model.Transaction;
@@ -94,7 +95,7 @@ public class PieChartReportTest extends ActivityInstrumentationTestCase2<Reports
9495
private static final String GIFTS_RECEIVED_INCOME_ACCOUNT_UID = "b01950c0df0890b6543209d51c8e0b0f";
9596
private static final String GIFTS_RECEIVED_INCOME_ACCOUNT_NAME = "Gifts Received";
9697

97-
public static final Currency CURRENCY = Currency.getInstance("USD");
98+
public static final Commodity CURRENCY = Commodity.getInstance("USD");
9899

99100
private AccountsDbAdapter mAccountsDbAdapter;
100101
private TransactionsDbAdapter mTransactionsDbAdapter;

app/src/androidTest/java/org/gnucash/android/test/ui/TransactionsActivityTest.java

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.gnucash.android.db.SplitsDbAdapter;
3737
import org.gnucash.android.db.TransactionsDbAdapter;
3838
import org.gnucash.android.model.Account;
39+
import org.gnucash.android.model.Commodity;
3940
import org.gnucash.android.model.Money;
4041
import org.gnucash.android.model.Split;
4142
import org.gnucash.android.model.Transaction;
@@ -56,6 +57,7 @@
5657
import java.util.List;
5758
import java.util.Locale;
5859

60+
import static android.support.test.espresso.Espresso.onData;
5961
import static android.support.test.espresso.Espresso.onView;
6062
import static android.support.test.espresso.action.ViewActions.clearText;
6163
import static android.support.test.espresso.action.ViewActions.click;
@@ -69,6 +71,7 @@
6971
import static android.support.test.espresso.matcher.ViewMatchers.withText;
7072
import static org.assertj.core.api.Assertions.assertThat;
7173
import static org.hamcrest.Matchers.allOf;
74+
import static org.hamcrest.Matchers.instanceOf;
7275
import static org.hamcrest.Matchers.is;
7376
import static org.hamcrest.Matchers.not;
7477

@@ -121,11 +124,11 @@ public void setUp() throws Exception {
121124
mTransactionTimeMillis = System.currentTimeMillis();
122125
Account account = new Account(DUMMY_ACCOUNT_NAME);
123126
account.setUID(DUMMY_ACCOUNT_UID);
124-
account.setCurrency(Currency.getInstance(CURRENCY_CODE));
127+
account.setCommodity(Commodity.getInstance(CURRENCY_CODE));
125128

126129
Account account2 = new Account(TRANSFER_ACCOUNT_NAME);
127130
account2.setUID(TRANSFER_ACCOUNT_UID);
128-
account2.setCurrency(Currency.getInstance(CURRENCY_CODE));
131+
account2.setCommodity(Commodity.getInstance(CURRENCY_CODE));
129132

130133
mAccountsDbAdapter.addRecord(account);
131134
mAccountsDbAdapter.addRecord(account2);
@@ -475,6 +478,79 @@ public void testDeleteTransaction(){
475478
assertEquals(0, mTransactionsDbAdapter.getTransactionsCount(id));
476479
}
477480

481+
@Test
482+
public void testMoveTransaction(){
483+
Account account = new Account("Move account");
484+
account.setCommodity(Commodity.getInstance(CURRENCY_CODE));
485+
mAccountsDbAdapter.addRecord(account);
486+
487+
assertThat(mTransactionsDbAdapter.getAllTransactionsForAccount(account.getUID())).hasSize(0);
488+
489+
onView(withId(R.id.options_menu)).perform(click());
490+
onView(withText(R.string.menu_move_transaction)).perform(click());
491+
492+
onView(withId(R.id.btn_save)).perform(click());
493+
494+
assertThat(mTransactionsDbAdapter.getAllTransactionsForAccount(DUMMY_ACCOUNT_UID)).hasSize(0);
495+
496+
assertThat(mTransactionsDbAdapter.getAllTransactionsForAccount(account.getUID())).hasSize(1);
497+
498+
}
499+
500+
// @Test //// FIXME: 03.11.2015 fix and re-enable this test
501+
public void editingSplit_shouldNotSetAmountToZero(){
502+
setDoubleEntryEnabled(true);
503+
mTransactionsDbAdapter.deleteAllRecords();
504+
505+
Account account = new Account("Z Account", Commodity.getInstance(CURRENCY_CODE));
506+
mAccountsDbAdapter.addRecord(account);
507+
508+
onView(withId(R.id.fab_create_transaction)).perform(click());
509+
510+
onView(withId(R.id.input_transaction_name)).perform(typeText("Test Split"));
511+
onView(withId(R.id.input_transaction_amount)).perform(typeText("1024"));
512+
513+
onView(withId(R.id.menu_save)).perform(click());
514+
515+
onView(withText("Test Split")).perform(click());
516+
onView(withId(R.id.fab_edit_transaction)).perform(click());
517+
518+
onView(withId(R.id.btn_split_editor)).perform(click());
519+
520+
// onView(withSpinnerText(DUMMY_ACCOUNT_NAME)).perform(click()); //// FIXME: 03.11.2015 properly select the spinner
521+
onData(withId(R.id.input_accounts_spinner))
522+
.inAdapterView(withId(R.id.split_list_layout))
523+
.atPosition(1)
524+
.perform(click());
525+
onData(allOf(is(instanceOf(String.class)), is(account.getFullName()))).perform(click());
526+
// onView(withText(account.getFullName())).perform(click());
527+
528+
onView(withId(R.id.menu_save)).perform(click());
529+
onView(withId(R.id.menu_save)).perform(click());
530+
531+
//split should have moved from account, it should now be empty
532+
onView(withId(R.id.empty_view)).check(matches(isDisplayed()));
533+
534+
assertThat(mAccountsDbAdapter.getAccountBalance(DUMMY_ACCOUNT_UID)).isEqualTo(Money.createZeroInstance(CURRENCY_CODE));
535+
536+
//split
537+
assertThat(mAccountsDbAdapter.getAccountBalance(account.getUID())).isEqualTo(new Money("1024", CURRENCY_CODE));
538+
}
539+
540+
@Test
541+
public void testDuplicateTransaction(){
542+
assertThat(mTransactionsDbAdapter.getAllTransactionsForAccount(DUMMY_ACCOUNT_UID)).hasSize(1);
543+
544+
onView(withId(R.id.options_menu)).perform(click());
545+
onView(withText(R.string.menu_duplicate_transaction)).perform(click());
546+
547+
List<Transaction> dummyAccountTrns = mTransactionsDbAdapter.getAllTransactionsForAccount(DUMMY_ACCOUNT_UID);
548+
assertThat(dummyAccountTrns).hasSize(2);
549+
550+
assertThat(dummyAccountTrns.get(0).getDescription()).isEqualTo(dummyAccountTrns.get(1).getDescription());
551+
assertThat(dummyAccountTrns.get(0).getTimeMillis()).isNotEqualTo(dummyAccountTrns.get(1).getTimeMillis());
552+
}
553+
478554
//TODO: add normal transaction recording
479555
@Test
480556
public void testLegacyIntentTransactionRecording(){

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
<action android:name="android.intent.action.BOOT_COMPLETED"/>
159159
</intent-filter>
160160
</receiver>
161-
<meta-data android:name="io.fabric.ApiKey" android:value="46fe045d00d4ad8a71014c53567be3368e10bd64"/>
162161
</application>
163162

164163
</manifest>

app/src/main/java/org/gnucash/android/app/GnuCashApplication.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import org.gnucash.android.db.ScheduledActionDbAdapter;
4141
import org.gnucash.android.db.SplitsDbAdapter;
4242
import org.gnucash.android.db.TransactionsDbAdapter;
43+
import org.gnucash.android.model.Commodity;
4344
import org.gnucash.android.service.SchedulerService;
4445

4546
import java.util.Currency;
@@ -122,6 +123,8 @@ public void onCreate(){
122123
mScheduledActionDbAdapter = new ScheduledActionDbAdapter(mDb);
123124
mCommoditiesDbAdapter = new CommoditiesDbAdapter(mDb);
124125
mPricesDbAdapter = new PricesDbAdapter(mDb);
126+
127+
Commodity.DEFAULT_COMMODITY = mCommoditiesDbAdapter.getCommodity(getDefaultCurrencyCode());
125128
}
126129

127130
public static AccountsDbAdapter getAccountsDbAdapter() {
@@ -212,6 +215,15 @@ public static String getDefaultCurrencyCode(){
212215
return currencyCode;
213216
}
214217

218+
/**
219+
* Returns the default commodity
220+
* @return Default commodity of application
221+
* @see #getDefaultCurrencyCode()
222+
*/
223+
public static Commodity getDefaultCommodity(){
224+
return Commodity.DEFAULT_COMMODITY;
225+
}
226+
215227
/**
216228
* Returns the default locale which is used for currencies, while handling special cases for
217229
* locales which are not supported for currency such as en_GB

0 commit comments

Comments
 (0)