package net.ktnx.mobileledger.dao;
-import android.os.AsyncTask;
-
import androidx.annotation.NonNull;
import androidx.lifecycle.LiveData;
import androidx.room.ColumnInfo;
@Query("SELECT * FROM transactions WHERE id = :transactionId")
public abstract TransactionWithAccounts getByIdWithAccountsSync(long transactionId);
- @Query("SELECT DISTINCT description, CASE WHEN description LIKE :term||'%%' THEN 1 " +
- " WHEN description LIKE '%%:'||:term||'%%' THEN 2 " +
- " WHEN description LIKE '%% '||:term||'%%' THEN 3 " +
+ @Query("SELECT DISTINCT description, CASE WHEN description_uc LIKE :term||'%%' THEN 1 " +
+ " WHEN description_uc LIKE '%%:'||:term||'%%' THEN 2 " +
+ " WHEN description_uc LIKE '%% '||:term||'%%' THEN 3 " +
" ELSE 9 END AS ordering FROM transactions " +
- "WHERE description LIKE '%%'||:term||'%%' " + "ORDER BY ordering, description, rowid ")
+ "WHERE description_uc LIKE '%%'||:term||'%%' ORDER BY ordering, description_uc, rowid ")
public abstract List<DescriptionContainer> lookupDescriptionSync(@NonNull String term);
@androidx.room.Transaction
public abstract TransactionWithAccounts getFirstByDescriptionSync(@NonNull String description);
@androidx.room.Transaction
- @Query("SELECT tr.id, tr.profile_id, tr.ledger_id, tr.description, tr.data_hash, tr.comment, " +
- "tr.year, tr.month, tr.day, tr.generation from transactions tr JOIN " +
- "transaction_accounts t_a ON t_a.transaction_id = tr.id WHERE tr.description = " +
+ @Query("SELECT tr.id, tr.profile_id, tr.ledger_id, tr.description, tr.description_uc, tr" +
+ ".data_hash, tr.comment, tr.year, tr.month, tr.day, tr.generation from transactions tr" +
+ " JOIN transaction_accounts t_a ON t_a.transaction_id = tr.id WHERE tr.description = " +
":description AND t_a.account_name LIKE '%'||:accountTerm||'%' ORDER BY year desc, " +
"month desc, day desc, tr.ledger_id desc LIMIT 1")
public abstract TransactionWithAccounts getFirstByDescriptionHavingAccountSync(
@androidx.room.Transaction
@Query("SELECT distinct(tr.id), tr.ledger_id, tr.profile_id, tr.data_hash, tr.year, tr.month," +
- " tr.day, tr.description, tr.comment, tr.generation FROM transactions tr JOIN " +
- "transaction_accounts ta ON ta.transaction_id=tr.id WHERE ta.account_name LIKE " +
- ":accountName||'%' AND ta.amount <> 0 AND tr.profile_id = :profileId ORDER BY tr.year " +
- "asc, tr.month asc, tr.day asc, tr.ledger_id asc")
+ " tr.day, tr.description, tr.description_uc, tr.comment, tr.generation FROM " +
+ "transactions tr JOIN transaction_accounts ta ON ta.transaction_id=tr.id WHERE ta" +
+ ".account_name LIKE :accountName||'%' AND ta.amount <> 0 AND tr.profile_id = " +
+ ":profileId ORDER BY tr.year asc, tr.month asc, tr.day asc, tr.ledger_id asc")
public abstract LiveData<List<TransactionWithAccounts>> getAllWithAccountsFiltered(
long profileId, String accountName);
}
}
public void storeLast(TransactionWithAccounts rec) {
- AsyncTask.execute(() -> appendSync(rec));
+ BaseDAO.runAsync(() -> appendSync(rec));
}
@androidx.room.Transaction
public void appendSync(TransactionWithAccounts rec) {