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 = "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),
34 @ForeignKey(childColumns = "currency", parentColumns = "id",
35 entity = Currency.class)
37 public class TemplateAccount extends TemplateBase {
38 @PrimaryKey(autoGenerate = true)
42 @ColumnInfo(name = "template_id")
43 private Long templateId;
44 @ColumnInfo(name = "acc")
45 private String accountName;
46 @ColumnInfo(name = "position")
48 private Long position;
49 @ColumnInfo(name = "acc_match_group")
50 private Integer accountNameMatchGroup;
51 @ColumnInfo(name = "currency")
52 private Integer currency;
53 @ColumnInfo(name = "currency_match_group")
54 private Integer currencyMatchGroup;
55 @ColumnInfo(name = "amount")
57 @ColumnInfo(name = "amount_match_group")
58 private Integer amountMatchGroup;
59 @ColumnInfo(name = "comment")
60 private String accountComment;
61 @ColumnInfo(name = "comment_match_group")
62 private Integer accountCommentMatchGroup;
63 @ColumnInfo(name = "negate_amount")
64 private Boolean negateAmount;
65 public TemplateAccount(@NotNull Long id, @NonNull Long templateId, @NonNull Long position) {
67 this.templateId = templateId;
68 this.position = position;
73 public void setId(Long id) {
76 public Boolean getNegateAmount() {
79 public void setNegateAmount(Boolean negateAmount) {
80 this.negateAmount = negateAmount;
82 public @NotNull Long getTemplateId() {
85 public void setTemplateId(@NonNull Long templateId) {
86 this.templateId = templateId;
89 public String getAccountName() {
92 public void setAccountName(@NonNull String accountName) {
93 this.accountName = accountName;
96 public Long getPosition() {
99 public void setPosition(@NonNull Long position) {
100 this.position = position;
102 public void setPosition(int position) {
103 this.position = (long) position;
105 public Integer getAccountNameMatchGroup() {
106 return accountNameMatchGroup;
108 public void setAccountNameMatchGroup(Integer accountNameMatchGroup) {
109 this.accountNameMatchGroup = accountNameMatchGroup;
111 public Integer getCurrency() {
114 public void setCurrency(Integer currency) {
115 this.currency = currency;
117 public Integer getCurrencyMatchGroup() {
118 return currencyMatchGroup;
120 public void setCurrencyMatchGroup(Integer currencyMatchGroup) {
121 this.currencyMatchGroup = currencyMatchGroup;
123 public Float getAmount() {
126 public void setAmount(Float amount) {
127 this.amount = amount;
129 public Integer getAmountMatchGroup() {
130 return amountMatchGroup;
132 public void setAmountMatchGroup(Integer amountMatchGroup) {
133 this.amountMatchGroup = amountMatchGroup;
135 public String getAccountComment() {
136 return accountComment;
138 public void setAccountComment(String accountComment) {
139 this.accountComment = accountComment;
141 public Integer getAccountCommentMatchGroup() {
142 return accountCommentMatchGroup;
144 public void setAccountCommentMatchGroup(Integer accountCommentMatchGroup) {
145 this.accountCommentMatchGroup = accountCommentMatchGroup;