2 * Copyright © 2021 Damyan Ivanov.
3 * This file is part of MoLe.
4 * MoLe is free software: you can distribute it and/or modify it
5 * under the term of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your opinion), any later version.
9 * MoLe is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License terms for details.
14 * You should have received a copy of the GNU General Public License
15 * along with MoLe. If not, see <https://www.gnu.org/licenses/>.
18 package net.ktnx.mobileledger.db;
20 import androidx.annotation.NonNull;
21 import androidx.room.ColumnInfo;
22 import androidx.room.Entity;
23 import androidx.room.ForeignKey;
24 import androidx.room.Index;
25 import androidx.room.PrimaryKey;
27 @Entity(tableName = "accounts",
28 indices = {@Index(name = "un_account_name", unique = true, value = {"profile_id", "name"}),
29 @Index(name = "fk_account_profile", value = "profile_id")
31 @ForeignKey(entity = Profile.class, parentColumns = "id", childColumns = "profile_id",
32 onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.RESTRICT)
34 public class Account {
36 @PrimaryKey(autoGenerate = true)
38 @ColumnInfo(name = "profile_id")
46 @ColumnInfo(name = "name_upper")
47 private String nameUpper;
48 @ColumnInfo(name = "parent_name")
49 private String parentName;
50 @ColumnInfo(defaultValue = "1")
51 private boolean expanded = true;
52 @ColumnInfo(name = "amounts_expanded", defaultValue = "0")
53 private boolean amountsExpanded = false;
54 @ColumnInfo(defaultValue = "0")
55 private int generation;
59 public void setId(long id) {
62 public long getProfileId() {
65 public void setProfileId(long profileId) {
66 this.profileId = profileId;
69 public String getName() {
72 public void setName(@NonNull String name) {
76 public String getNameUpper() {
79 public void setNameUpper(@NonNull String nameUpper) {
80 this.nameUpper = nameUpper;
82 public int getLevel() {
85 public void setLevel(int level) {
88 public String getParentName() {
91 public void setParentName(String parentName) {
92 this.parentName = parentName;
94 public boolean isExpanded() {
97 public void setExpanded(boolean expanded) {
98 this.expanded = expanded;
100 public boolean isAmountsExpanded() {
101 return amountsExpanded;
103 public void setAmountsExpanded(boolean amountsExpanded) {
104 this.amountsExpanded = amountsExpanded;
106 public int getGeneration() {
109 public void setGeneration(int generation) {
110 this.generation = generation;
114 public String toString() {