Skip to content

Commit 49e25ca

Browse files
committed
Merge pull request #331 from makarica/DTA2SubAcc
Feature #329: Search also through ancestors for default transfer account
2 parents df10c4c + 99b93e9 commit 49e25ca

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

app/src/main/java/org/gnucash/android/ui/transaction/TransactionFormFragment.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,18 @@ private void initalizeViews() {
485485
mCurrencyTextView.setText(accountCurrency.getSymbol());
486486

487487
if (mUseDoubleEntry){
488-
long accountId = mAccountsDbAdapter.getID(mAccountUID);
489-
long defaultTransferAccountID = mAccountsDbAdapter.getDefaultTransferAccountID(accountId);
488+
String currentAccountUID = mAccountUID;
489+
long defaultTransferAccountID = 0;
490+
491+
do {
492+
long transAccID = mAccountsDbAdapter.getDefaultTransferAccountID(mAccountsDbAdapter.getID(currentAccountUID));
493+
if (transAccID > 0) {
494+
defaultTransferAccountID = transAccID;
495+
}
496+
currentAccountUID = mAccountsDbAdapter.getParentAccountUID(currentAccountUID);
497+
}
498+
while (currentAccountUID != null && defaultTransferAccountID == 0);
499+
490500
if (defaultTransferAccountID > 0){
491501
setSelectedTransferAccount(defaultTransferAccountID);
492502
}

0 commit comments

Comments
 (0)