to be used in the transaction description auto-completion, preferring
transactions that contain an account matching the filter
the idea is useful for ledgers manipulated by multiple people with
personal accounts who enter transactions with the same description
one would expect the auto-completion to pick a transaction that uses
accounts of the user rather than transaction using other users'
accounts
private String uuid;
private String name;
private boolean permitPosting;
private String uuid;
private String name;
private boolean permitPosting;
+ private String preferredAccountsFilter;
private String url;
private boolean authEnabled;
private String authUserName;
private String url;
private boolean authEnabled;
private String authUserName;
List<MobileLedgerProfile> list = new ArrayList<>();
SQLiteDatabase db = MLDB.getDatabase();
try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
List<MobileLedgerProfile> list = new ArrayList<>();
SQLiteDatabase db = MLDB.getDatabase();
try (Cursor cursor = db.rawQuery("SELECT uuid, name, url, use_authentication, auth_user, " +
- "auth_password, permit_posting, theme, order_no FROM " +
+ "auth_password, permit_posting, theme, order_no, " +
+ "preferred_accounts_filter FROM " +
"profiles order by order_no", null))
{
while (cursor.moveToNext()) {
"profiles order by order_no", null))
{
while (cursor.moveToNext()) {
item.setPostingPermitted(cursor.getInt(6) == 1);
item.setThemeId(cursor.getInt(7));
item.orderNo = cursor.getInt(8);
item.setPostingPermitted(cursor.getInt(6) == 1);
item.setThemeId(cursor.getInt(7));
item.orderNo = cursor.getInt(8);
+ item.setPreferredAccountsFilter(cursor.getString(9));
list.add(item);
if (item.getUuid().equals(currentProfileUUID)) result = item;
}
list.add(item);
if (item.getUuid().equals(currentProfileUUID)) result = item;
}
+ public String getPreferredAccountsFilter() {
+ return preferredAccountsFilter;
+ }
+ public void setPreferredAccountsFilter(String preferredAccountsFilter) {
+ this.preferredAccountsFilter = preferredAccountsFilter;
+ }
+ public void setPreferredAccountsFilter(CharSequence preferredAccountsFilter) {
+ setPreferredAccountsFilter(String.valueOf(preferredAccountsFilter));
+ }
public boolean isPostingPermitted() {
return permitPosting;
}
public boolean isPostingPermitted() {
return permitPosting;
}
// permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeId));
db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
"use_authentication, auth_user, " +
// permitPosting ? "TRUE" : "FALSE", authEnabled ? "TRUE" : "FALSE", themeId));
db.execSQL("REPLACE INTO profiles(uuid, name, permit_posting, url, " +
"use_authentication, auth_user, " +
- "auth_password, theme, order_no) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)",
+ "auth_password, theme, order_no, preferred_accounts_filter) " +
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
new Object[]{uuid, name, permitPosting, url, authEnabled,
authEnabled ? authUserName : null,
new Object[]{uuid, name, permitPosting, url, authEnabled,
authEnabled ? authUserName : null,
- authEnabled ? authPassword : null, themeId, orderNo
+ authEnabled ? authPassword : null, themeId, orderNo,
+ preferredAccountsFilter
});
db.setTransactionSuccessful();
}
});
db.setTransactionSuccessful();
}
class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable {
private static final String DB_NAME = "MoLe.db";
class MobileLedgerDatabase extends SQLiteOpenHelper implements AutoCloseable {
private static final String DB_NAME = "MoLe.db";
- private static final int LATEST_REVISION = 21;
+ private static final int LATEST_REVISION = 22;
private static final String CREATE_DB_SQL = "create_db";
private final Application mContext;
private static final String CREATE_DB_SQL = "create_db";
private final Application mContext;
create table account_values(profile varchar not null, account varchar not null, currency varchar not null default '', keep boolean, value decimal not null );
create unique index un_account_values on account_values(profile,account,currency);
create table description_history(description varchar not null primary key, keep boolean, description_upper varchar);
create table account_values(profile varchar not null, account varchar not null, currency varchar not null default '', keep boolean, value decimal not null );
create unique index un_account_values on account_values(profile,account,currency);
create table description_history(description varchar not null primary key, keep boolean, description_upper varchar);
-create table profiles(uuid varchar not null primary key, name not null, url not null, use_authentication boolean not null, auth_user varchar, auth_password varchar, order_no integer, permit_posting boolean default 0, theme integer default -1);
+create table profiles(uuid varchar not null primary key, name not null, url not null, use_authentication boolean not null, auth_user varchar, auth_password varchar, order_no integer, permit_posting boolean default 0, theme integer default -1, preferred_accounts_filter varchar);
create table transactions(profile varchar not null, id integer not null, data_hash varchar not null, date varchar not null, description varchar not null, keep boolean not null default 0);
create unique index un_transactions_id on transactions(profile,id);
create unique index un_transactions_data_hash on transactions(profile,data_hash);
create table transactions(profile varchar not null, id integer not null, data_hash varchar not null, date varchar not null, description varchar not null, keep boolean not null default 0);
create unique index un_transactions_id on transactions(profile,id);
create unique index un_transactions_data_hash on transactions(profile,data_hash);
--- /dev/null
+alter table profiles add preferred_accounts_filter varchar;
\ No newline at end of file