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", unique = false,
32 value = "pattern_id"),
33 @Index(name = "fk_pattern_accounts_currency", unique = false, value = "currency")
34 }, foreignKeys = {@ForeignKey(childColumns = "pattern_id", parentColumns = "id",
35 entity = PatternHeader.class),
36 @ForeignKey(childColumns = "currency", parentColumns = "id",
37 entity = Currency.class)
39 public class PatternAccount extends PatternBase {
41 @ColumnInfo(name = "pattern_id")
42 private Long patternId;
43 @PrimaryKey(autoGenerate = true)
46 @ColumnInfo(name = "acc")
47 private String accountName;
48 @ColumnInfo(name = "position")
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")
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 public PatternAccount(@NotNull Long id, @NonNull Long patternId, @NonNull Long position) {
67 this.patternId = patternId;
68 this.position = position;
73 public void setId(Long id) {
76 public @NotNull Long getPatternId() {
79 public void setPatternId(@NonNull Long patternId) {
80 this.patternId = patternId;
83 public String getAccountName() {
86 public void setAccountName(@NonNull String accountName) {
87 this.accountName = accountName;
90 public Long getPosition() {
93 public void setPosition(@NonNull Long position) {
94 this.position = position;
96 public void setPosition(int position) {
97 this.position = (long) position;
99 public Integer getAccountNameMatchGroup() {
100 return accountNameMatchGroup;
102 public void setAccountNameMatchGroup(Integer accountNameMatchGroup) {
103 this.accountNameMatchGroup = accountNameMatchGroup;
105 public Integer getCurrency() {
108 public void setCurrency(Integer currency) {
109 this.currency = currency;
111 public Integer getCurrencyMatchGroup() {
112 return currencyMatchGroup;
114 public void setCurrencyMatchGroup(Integer currencyMatchGroup) {
115 this.currencyMatchGroup = currencyMatchGroup;
117 public Float getAmount() {
120 public void setAmount(Float amount) {
121 this.amount = amount;
123 public Integer getAmountMatchGroup() {
124 return amountMatchGroup;
126 public void setAmountMatchGroup(Integer amountMatchGroup) {
127 this.amountMatchGroup = amountMatchGroup;
129 public String getAccountComment() {
130 return accountComment;
132 public void setAccountComment(String accountComment) {
133 this.accountComment = accountComment;
135 public Integer getAccountCommentMatchGroup() {
136 return accountCommentMatchGroup;
138 public void setAccountCommentMatchGroup(Integer accountCommentMatchGroup) {
139 this.accountCommentMatchGroup = accountCommentMatchGroup;