]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/db/Account.java
more pronounced day/month delimiters in the transaction list
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / Account.java
1 /*
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.
8  *
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.
13  *
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/>.
16  */
17
18 package net.ktnx.mobileledger.db;
19
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;
26
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")
30         }, foreignKeys = {
31         @ForeignKey(entity = Profile.class, parentColumns = "id", childColumns = "profile_id",
32                     onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.RESTRICT)
33 })
34 public class Account {
35     @ColumnInfo
36     @PrimaryKey(autoGenerate = true)
37     long id;
38     @ColumnInfo(name = "profile_id")
39     long profileId;
40     @ColumnInfo
41     int level;
42     @ColumnInfo
43     @NonNull
44     private String name;
45     @NonNull
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 long generation;
56     public long getId() {
57         return id;
58     }
59     public void setId(long id) {
60         this.id = id;
61     }
62     public long getProfileId() {
63         return profileId;
64     }
65     public void setProfileId(long profileId) {
66         this.profileId = profileId;
67     }
68     @NonNull
69     public String getName() {
70         return name;
71     }
72     public void setName(@NonNull String name) {
73         this.name = name;
74     }
75     @NonNull
76     public String getNameUpper() {
77         return nameUpper;
78     }
79     public void setNameUpper(@NonNull String nameUpper) {
80         this.nameUpper = nameUpper;
81     }
82     public int getLevel() {
83         return level;
84     }
85     public void setLevel(int level) {
86         this.level = level;
87     }
88     public String getParentName() {
89         return parentName;
90     }
91     public void setParentName(String parentName) {
92         this.parentName = parentName;
93     }
94     public boolean isExpanded() {
95         return expanded;
96     }
97     public void setExpanded(boolean expanded) {
98         this.expanded = expanded;
99     }
100     public boolean isAmountsExpanded() {
101         return amountsExpanded;
102     }
103     public void setAmountsExpanded(boolean amountsExpanded) {
104         this.amountsExpanded = amountsExpanded;
105     }
106     public long getGeneration() {
107         return generation;
108     }
109     public void setGeneration(long generation) {
110         this.generation = generation;
111     }
112     @NonNull
113     @Override
114     public String toString() {
115         return getName();
116     }
117 }