final AccountValueDAO valueDAO = DB.get()
.getAccountValueDAO();
Account account = accountWithAmounts.account;
- Account existingAccount = getByNameSync(account.getProfileId(), account.getName());
- if (existingAccount != null) {
- existingAccount.setGeneration(account.getGeneration());
- account = existingAccount;
- updateSync(account);
- }
- else {
- long accountId = insertSync(account);
- account.setId(accountId);
- }
+ account.setId(insertSync(account));
for (AccountValue value : accountWithAmounts.amounts) {
value.setAccountId(account.getId());
value.setGeneration(account.getGeneration());
@Delete
public abstract void deleteSync(List<Account> items);
- @Query("SELECT * FROM accounts WHERE profile_id=:profileId")
+ @Query("SELECT * FROM accounts WHERE profile_id=:profileId ORDER BY name")
public abstract LiveData<List<Account>> getAll(long profileId);
@Transaction
- @Query("SELECT * FROM accounts WHERE profile_id = :profileId")
+ @Query("SELECT * FROM accounts WHERE profile_id = :profileId ORDER BY name")
public abstract LiveData<List<AccountWithAmounts>> getAllWithAmounts(long profileId);
@Query("SELECT * FROM accounts WHERE id=:id")