@@ -105,13 +105,24 @@ public void onActivityCreated(Bundle savedInstanceState) {
105105
106106 getDialog ().setTitle ("Transaction splits" );
107107
108- initArgs ();
109108 mSplitItemViewList = new ArrayList <View >();
110109 mSplitsDbAdapter = new SplitsDbAdapter (getActivity ());
111110
112111 //we are editing splits for a new transaction.
113112 // But the user may have already created some splits before. Let's check
114113 List <Split > splitList = ((TransactionFormFragment ) getTargetFragment ()).getSplitList ();
114+ {
115+ Currency currency = null ;
116+ for (Split split : splitList ) {
117+ if (currency == null ) {
118+ currency = split .getAmount ().getCurrency ();
119+ } else if (currency != split .getAmount ().getCurrency ()) {
120+ mMultiCurrency = true ;
121+ }
122+ }
123+ }
124+
125+ initArgs ();
115126 if (!splitList .isEmpty ()) {
116127 //aha! there are some splits. Let's load those instead
117128 loadSplitViews (splitList );
@@ -131,15 +142,8 @@ public void onActivityCreated(Bundle savedInstanceState) {
131142 }
132143
133144 private void loadSplitViews (List <Split > splitList ) {
134- Currency currency = null ;
135145 for (Split split : splitList ) {
136146 addSplitView (split );
137- if (currency == null ) {
138- currency = split .getAmount ().getCurrency ();
139- }
140- else if (currency != split .getAmount ().getCurrency ()) {
141- mMultiCurrency = true ;
142- }
143147 }
144148 if (mMultiCurrency ) {
145149 enableAllControls (false );
@@ -191,8 +195,8 @@ private void initArgs() {
191195 mBaseAmount = new BigDecimal (args .getString (UxArgument .AMOUNT_STRING ));
192196
193197 String conditions = "(" //+ AccountEntry._ID + " != " + mAccountId + " AND "
194- + DatabaseSchema .AccountEntry .COLUMN_CURRENCY + " = '" + mAccountsDbAdapter .getCurrencyCode (mAccountId )
195- + "' AND " + DatabaseSchema .AccountEntry .COLUMN_UID + " != '" + mAccountsDbAdapter .getGnuCashRootAccountUID ()
198+ + ( mMultiCurrency ? "" : ( DatabaseSchema .AccountEntry .COLUMN_CURRENCY + " = '" + mAccountsDbAdapter .getCurrencyCode (mAccountId )
199+ + "' AND " )) + DatabaseSchema .AccountEntry .COLUMN_UID + " != '" + mAccountsDbAdapter .getGnuCashRootAccountUID ()
196200 + "' AND " + DatabaseSchema .AccountEntry .COLUMN_PLACEHOLDER + " = 0"
197201 + ")" ;
198202 mCursor = mAccountsDbAdapter .fetchAccountsOrderedByFullName (conditions );
0 commit comments