@Delete
public abstract void deleteSync(Transaction item);
+ @Delete
+ public abstract void deleteSync(Transaction... items);
+
@Delete
public abstract void deleteSync(List<Transaction> items);
public abstract TransactionWithAccounts getFirstByDescriptionSync(@NonNull String description);
@androidx.room.Transaction
- @Query("SELECT * 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")
+ @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 = " +
+ ":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(
@NonNull String description, @NonNull String accountTerm);
- @Query("SELECT * from transactions WHERE profile_id = :profileId ORDER BY " +
- "year desc, month desc, day desc, ledger_id desc")
- public abstract List<Transaction> allForProfileSync(long profileId);
+ @Query("SELECT * from transactions WHERE profile_id = :profileId")
+ public abstract List<Transaction> getAllForProfileUnorderedSync(long profileId);
@Query("SELECT generation FROM transactions WHERE profile_id = :profileId LIMIT 1")
protected abstract TransactionGenerationContainer getGenerationPOJOSync(long profileId);
public abstract List<TransactionWithAccounts> getAllWithAccountsFilteredSync(long profileId,
String accountName);
- public long getGenerationSync(long profileId) {
- TransactionGenerationContainer result = getGenerationPOJOSync(profileId);
-
- if (result == null)
- return 0;
- return result.generation;
- }
@Query("DELETE FROM transactions WHERE profile_id = :profileId AND generation <> " +
":currentGeneration")
public abstract int purgeOldTransactionsSync(long profileId, long currentGeneration);
".id=transaction_accounts.transaction_id AND tr.profile_id=:profileId) AND generation " +
"<> :currentGeneration")
public abstract int purgeOldTransactionAccountsSync(long profileId, long currentGeneration);
+
+ @Query("DELETE FROM transactions WHERE profile_id = :profileId")
+ public abstract int deleteAllSync(long profileId);
+
+ @Query("SELECT * FROM transactions where profile_id = :profileId AND ledger_id = :ledgerId")
+ public abstract Transaction getByLedgerId(long profileId, long ledgerId);
+ public long getGenerationSync(long profileId) {
+ TransactionGenerationContainer result = getGenerationPOJOSync(profileId);
+
+ if (result == null)
+ return 0;
+ return result.generation;
+ }
public void storeTransactionsSync(List<TransactionWithAccounts> list, long profileId) {
long generation = getGenerationSync(profileId) + 1;
trAccDao.getByOrderNoSync(trAcc.getTransactionId(), trAcc.getOrderNo());
if (existingAcc != null) {
existingAcc.copyDataFrom(trAcc);
- trAccDao.updateSync(trAcc);
- trAcc = existingAcc;
+ trAccDao.updateSync(existingAcc);
}
else
trAcc.setId(trAccDao.insertSync(trAcc));
}
}
- @Query("SELECT * FROM transactions where profile_id = :profileId AND ledger_id = :ledgerId")
- public abstract Transaction getByLedgerId(long profileId, long ledgerId);
static class TransactionGenerationContainer {
@ColumnInfo
long generation;