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 = PatternHeader.class),
35 @ForeignKey(childColumns = "currency", parentColumns = "id",
36 entity = Currency.class)
38 public class PatternAccount extends PatternBase {
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 public PatternAccount(@NotNull Long id, @NonNull Long patternId, @NonNull Long position) {
66 this.patternId = patternId;
67 this.position = position;
72 public void setId(Long id) {
75 public @NotNull Long getPatternId() {
78 public void setPatternId(@NonNull Long patternId) {
79 this.patternId = patternId;
82 public String getAccountName() {
85 public void setAccountName(@NonNull String accountName) {
86 this.accountName = accountName;
89 public Long getPosition() {
92 public void setPosition(@NonNull Long position) {
93 this.position = position;
95 public void setPosition(int position) {
96 this.position = (long) position;
98 public Integer getAccountNameMatchGroup() {
99 return accountNameMatchGroup;
101 public void setAccountNameMatchGroup(Integer accountNameMatchGroup) {
102 this.accountNameMatchGroup = accountNameMatchGroup;
104 public Integer getCurrency() {
107 public void setCurrency(Integer currency) {
108 this.currency = currency;
110 public Integer getCurrencyMatchGroup() {
111 return currencyMatchGroup;
113 public void setCurrencyMatchGroup(Integer currencyMatchGroup) {
114 this.currencyMatchGroup = currencyMatchGroup;
116 public Float getAmount() {
119 public void setAmount(Float amount) {
120 this.amount = amount;
122 public Integer getAmountMatchGroup() {
123 return amountMatchGroup;
125 public void setAmountMatchGroup(Integer amountMatchGroup) {
126 this.amountMatchGroup = amountMatchGroup;
128 public String getAccountComment() {
129 return accountComment;
131 public void setAccountComment(String accountComment) {
132 this.accountComment = accountComment;
134 public Integer getAccountCommentMatchGroup() {
135 return accountCommentMatchGroup;
137 public void setAccountCommentMatchGroup(Integer accountCommentMatchGroup) {
138 this.accountCommentMatchGroup = accountCommentMatchGroup;