File tree Expand file tree Collapse file tree
app/src/org/gnucash/android Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525import android .text .TextUtils ;
2626
2727import android .util .Log ;
28+ import android .support .annotation .NonNull ;
2829import org .gnucash .android .R ;
2930import org .gnucash .android .app .GnuCashApplication ;
3031import org .gnucash .android .model .*;
@@ -1322,4 +1323,26 @@ public int deleteAllRecords(){
13221323 return mDb .delete (AccountEntry .TABLE_NAME , null , null );
13231324 }
13241325
1326+ public int getTransactionMaxSplitNum (@ NonNull String accountUID ) {
1327+ Cursor cursor = mDb .query ("trans_extra_info" ,
1328+ new String []{"MAX(trans_split_count)" },
1329+ "trans_acct_t_uid IN ( SELECT DISTINCT " + TransactionEntry .TABLE_NAME + "_" + TransactionEntry .COLUMN_UID +
1330+ " FROM trans_split_acct WHERE " + AccountEntry .TABLE_NAME + "_" + AccountEntry .COLUMN_UID +
1331+ " = ? )" ,
1332+ new String []{accountUID },
1333+ null ,
1334+ null ,
1335+ null
1336+ );
1337+ try {
1338+ if (cursor .moveToFirst ()) {
1339+ return (int )cursor .getLong (0 );
1340+ } else {
1341+ return 0 ;
1342+ }
1343+ }
1344+ finally {
1345+ cursor .close ();
1346+ }
1347+ }
13251348}
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ private void createTempView() {
164164 SplitEntry .COLUMN_AMOUNT + " ELSE - " + SplitEntry .TABLE_NAME + "_" +
165165 SplitEntry .COLUMN_AMOUNT + " END ) AS trans_acct_balance , COUNT ( DISTINCT " +
166166 AccountEntry .TABLE_NAME + "_" + AccountEntry .COLUMN_CURRENCY +
167- " ) AS trans_currency_count FROM trans_split_acct " +
167+ " ) AS trans_currency_count , COUNT (*) AS trans_split_count FROM trans_split_acct " +
168168 " GROUP BY " + TransactionEntry .TABLE_NAME + "_" + TransactionEntry .COLUMN_UID
169169 );
170170 }
Original file line number Diff line number Diff line change 2727import android .graphics .Color ;
2828import android .os .Bundle ;
2929import android .preference .PreferenceManager ;
30+ import android .support .annotation .NonNull ;
31+ import android .support .annotation .Nullable ;
3032import android .support .v4 .app .FragmentManager ;
3133import android .support .v4 .widget .SimpleCursorAdapter ;
3234import android .text .TextUtils ;
@@ -351,6 +353,11 @@ private void initializeViewsWithAccount(Account account){
351353 String currencyCode = account .getCurrency ().getCurrencyCode ();
352354 setSelectedCurrency (currencyCode );
353355
356+ if (mAccountsDbAdapter .getTransactionMaxSplitNum (mAccount .getUID ()) > 1 )
357+ {
358+ mCurrencySpinner .setEnabled (false );
359+ }
360+
354361 mNameEditText .setText (account .getName ());
355362
356363 if (mUseDoubleEntry ) {
You can’t perform that action at this time.
0 commit comments