]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/db/TemplateAccount.java
8651e3fee09ba66ac857788e30a62e0e04894e84
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / TemplateAccount.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 import org.jetbrains.annotations.NotNull;
28
29 @Entity(tableName = "template_accounts",
30         indices = {@Index(name = "fk_template_accounts_template", value = "template_id"),
31                    @Index(name = "fk_template_accounts_currency", value = "currency")
32         }, foreignKeys = {@ForeignKey(childColumns = "template_id", parentColumns = "id",
33                                       entity = TemplateHeader.class, onDelete = ForeignKey.CASCADE,
34                                       onUpdate = ForeignKey.RESTRICT),
35                           @ForeignKey(childColumns = "currency", parentColumns = "id",
36                                       entity = Currency.class, onDelete = ForeignKey.RESTRICT,
37                                       onUpdate = ForeignKey.RESTRICT)
38 })
39 public class TemplateAccount extends TemplateBase {
40     @PrimaryKey(autoGenerate = true)
41     @NotNull
42     private Long id;
43     @NonNull
44     @ColumnInfo(name = "template_id")
45     private Long templateId;
46     @ColumnInfo(name = "acc")
47     private String accountName;
48     @ColumnInfo(name = "position")
49     @NonNull
50     private Long position;
51     @ColumnInfo(name = "acc_match_group")
52     private Integer accountNameMatchGroup;
53     @ColumnInfo(name = "currency")
54     private Integer currency;
55     @ColumnInfo(name = "currency_match_group")
56     private Integer currencyMatchGroup;
57     @ColumnInfo(name = "amount")
58     private Float amount;
59     @ColumnInfo(name = "amount_match_group")
60     private Integer amountMatchGroup;
61     @ColumnInfo(name = "comment")
62     private String accountComment;
63     @ColumnInfo(name = "comment_match_group")
64     private Integer accountCommentMatchGroup;
65     @ColumnInfo(name = "negate_amount")
66     private Boolean negateAmount;
67     public TemplateAccount(@NotNull Long id, @NonNull Long templateId, @NonNull Long position) {
68         this.id = id;
69         this.templateId = templateId;
70         this.position = position;
71     }
72     public Long getId() {
73         return id;
74     }
75     public void setId(Long id) {
76         this.id = id;
77     }
78     public Boolean getNegateAmount() {
79         return negateAmount;
80     }
81     public void setNegateAmount(Boolean negateAmount) {
82         this.negateAmount = negateAmount;
83     }
84     public @NotNull Long getTemplateId() {
85         return templateId;
86     }
87     public void setTemplateId(@NonNull Long templateId) {
88         this.templateId = templateId;
89     }
90     @NonNull
91     public String getAccountName() {
92         return accountName;
93     }
94     public void setAccountName(@NonNull String accountName) {
95         this.accountName = accountName;
96     }
97     @NonNull
98     public Long getPosition() {
99         return position;
100     }
101     public void setPosition(@NonNull Long position) {
102         this.position = position;
103     }
104     public void setPosition(int position) {
105         this.position = (long) position;
106     }
107     public Integer getAccountNameMatchGroup() {
108         return accountNameMatchGroup;
109     }
110     public void setAccountNameMatchGroup(Integer accountNameMatchGroup) {
111         this.accountNameMatchGroup = accountNameMatchGroup;
112     }
113     public Integer getCurrency() {
114         return currency;
115     }
116     public void setCurrency(Integer currency) {
117         this.currency = currency;
118     }
119     public Integer getCurrencyMatchGroup() {
120         return currencyMatchGroup;
121     }
122     public void setCurrencyMatchGroup(Integer currencyMatchGroup) {
123         this.currencyMatchGroup = currencyMatchGroup;
124     }
125     public Float getAmount() {
126         return amount;
127     }
128     public void setAmount(Float amount) {
129         this.amount = amount;
130     }
131     public Integer getAmountMatchGroup() {
132         return amountMatchGroup;
133     }
134     public void setAmountMatchGroup(Integer amountMatchGroup) {
135         this.amountMatchGroup = amountMatchGroup;
136     }
137     public String getAccountComment() {
138         return accountComment;
139     }
140     public void setAccountComment(String accountComment) {
141         this.accountComment = accountComment;
142     }
143     public Integer getAccountCommentMatchGroup() {
144         return accountCommentMatchGroup;
145     }
146     public void setAccountCommentMatchGroup(Integer accountCommentMatchGroup) {
147         this.accountCommentMatchGroup = accountCommentMatchGroup;
148     }
149 }