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 import org.jetbrains.annotations.NotNull;
29 @Entity(tableName = "pattern_accounts",
30 indices = {@Index(name = "un_pattern_accounts", unique = true, value = "id"),
31 @Index(name = "fk_pattern_accounts_pattern", value = "pattern_id"),
32 @Index(name = "fk_pattern_accounts_currency", value = "currency")
33 }, foreignKeys = {@ForeignKey(childColumns = "pattern_id", parentColumns = "id",
34 entity = TemplateHeader.class),
35 @ForeignKey(childColumns = "currency", parentColumns = "id",
36 entity = Currency.class)
38 public class TemplateAccount extends TemplateBase {
40 @ColumnInfo(name = "pattern_id")
41 private Long patternId;
42 @PrimaryKey(autoGenerate = true)
45 @ColumnInfo(name = "acc")
46 private String accountName;
47 @ColumnInfo(name = "position")
49 private Long position;
50 @ColumnInfo(name = "acc_match_group")
51 private Integer accountNameMatchGroup;
52 @ColumnInfo(name = "currency")
53 private Integer currency;
54 @ColumnInfo(name = "currency_match_group")
55 private Integer currencyMatchGroup;
56 @ColumnInfo(name = "amount")
58 @ColumnInfo(name = "amount_match_group")
59 private Integer amountMatchGroup;
60 @ColumnInfo(name = "comment")
61 private String accountComment;
62 @ColumnInfo(name = "comment_match_group")
63 private Integer accountCommentMatchGroup;
64 @ColumnInfo(name = "negate_amount")
65 private Boolean negateAmount;
66 public TemplateAccount(@NotNull Long id, @NonNull Long patternId, @NonNull Long position) {
68 this.patternId = patternId;
69 this.position = position;
74 public void setId(Long id) {
77 public Boolean getNegateAmount() {
80 public void setNegateAmount(Boolean negateAmount) {
81 this.negateAmount = negateAmount;
83 public @NotNull Long getPatternId() {
86 public void setPatternId(@NonNull Long patternId) {
87 this.patternId = patternId;
90 public String getAccountName() {
93 public void setAccountName(@NonNull String accountName) {
94 this.accountName = accountName;
97 public Long getPosition() {
100 public void setPosition(@NonNull Long position) {
101 this.position = position;
103 public void setPosition(int position) {
104 this.position = (long) position;
106 public Integer getAccountNameMatchGroup() {
107 return accountNameMatchGroup;
109 public void setAccountNameMatchGroup(Integer accountNameMatchGroup) {
110 this.accountNameMatchGroup = accountNameMatchGroup;
112 public Integer getCurrency() {
115 public void setCurrency(Integer currency) {
116 this.currency = currency;
118 public Integer getCurrencyMatchGroup() {
119 return currencyMatchGroup;
121 public void setCurrencyMatchGroup(Integer currencyMatchGroup) {
122 this.currencyMatchGroup = currencyMatchGroup;
124 public Float getAmount() {
127 public void setAmount(Float amount) {
128 this.amount = amount;
130 public Integer getAmountMatchGroup() {
131 return amountMatchGroup;
133 public void setAmountMatchGroup(Integer amountMatchGroup) {
134 this.amountMatchGroup = amountMatchGroup;
136 public String getAccountComment() {
137 return accountComment;
139 public void setAccountComment(String accountComment) {
140 this.accountComment = accountComment;
142 public Integer getAccountCommentMatchGroup() {
143 return accountCommentMatchGroup;
145 public void setAccountCommentMatchGroup(Integer accountCommentMatchGroup) {
146 this.accountCommentMatchGroup = accountCommentMatchGroup;