@@ -224,9 +224,6 @@ public void onActivityCreated(Bundle savedInstanceState) {
224224 mAccountsDbAdapter = new AccountsDbAdapter (getActivity ());
225225 mAccountType = mAccountsDbAdapter .getAccountType (mAccountUID );
226226
227- //updateTransferAccountsList must only be called after initializing mAccountsDbAdapter
228- updateTransferAccountsList ();
229-
230227 ArrayAdapter <CharSequence > recurrenceAdapter = ArrayAdapter .createFromResource (getActivity (),
231228 R .array .recurrence_period_strings , android .R .layout .simple_spinner_item );
232229 recurrenceAdapter .setDropDownViewResource (android .R .layout .simple_spinner_dropdown_item );
@@ -235,6 +232,13 @@ public void onActivityCreated(Bundle savedInstanceState) {
235232 String transactionUID = getArguments ().getString (UxArgument .SELECTED_TRANSACTION_UID );
236233 mTransactionsDbAdapter = new TransactionsDbAdapter (getActivity ());
237234 mTransaction = mTransactionsDbAdapter .getTransaction (transactionUID );
235+ if (mTransaction != null ) {
236+ mMultiCurrency = mTransactionsDbAdapter .getNumCurrencies (mTransaction .getUID ()) > 1 ;
237+ }
238+
239+ //updateTransferAccountsList must only be called after initializing mAccountsDbAdapter
240+ // it needs mMultiCurrency to be properly initialized
241+ updateTransferAccountsList ();
238242
239243 mDoubleAccountSpinner .setOnItemSelectedListener (new AdapterView .OnItemSelectedListener () {
240244 @ Override
@@ -328,7 +332,6 @@ public void onItemClick(AdapterView<?> adapterView, View view, int position, lon
328332 * This method is called if the fragment is used for editing a transaction
329333 */
330334 private void initializeViewsWithTransaction (){
331- mMultiCurrency = mTransactionsDbAdapter .getNumCurrencies (mTransaction .getUID ()) > 1 ;
332335 mDescriptionEditText .setText (mTransaction .getDescription ());
333336
334337 mTransactionTypeButton .setAccountType (mAccountType );
@@ -448,8 +451,8 @@ private void updateTransferAccountsList(){
448451 String accountUID = ((TransactionsActivity )getActivity ()).getCurrentAccountUID ();
449452
450453 String conditions = "(" + DatabaseSchema .AccountEntry .COLUMN_UID + " != '" + accountUID
451- + "' AND " + DatabaseSchema .AccountEntry .COLUMN_CURRENCY + " = '" + mAccountsDbAdapter .getCurrencyCode (accountUID )
452- + "' AND " + DatabaseSchema .AccountEntry .COLUMN_UID + " != '" + mAccountsDbAdapter .getGnuCashRootAccountUID ()
454+ + "' AND " + ( mMultiCurrency ? "" : ( DatabaseSchema .AccountEntry .COLUMN_CURRENCY + " = '" + mAccountsDbAdapter .getCurrencyCode (accountUID )
455+ + "' AND " )) + DatabaseSchema .AccountEntry .COLUMN_UID + " != '" + mAccountsDbAdapter .getGnuCashRootAccountUID ()
453456 + "' AND " + DatabaseSchema .AccountEntry .COLUMN_PLACEHOLDER + " = 0"
454457 + ")" ;
455458
0 commit comments