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;
26 @Entity(tableName = "transaction_accounts", primaryKeys = {"profile", "transaction_id", "order_no"},
27 foreignKeys = {@ForeignKey(entity = Transaction.class, parentColumns = {"profile", "id"},
28 childColumns = {"profile", "transaction_id"},
29 onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.RESTRICT),
30 @ForeignKey(entity = Account.class, parentColumns = {"profile", "name"},
31 childColumns = {"profile", "account_name"},
32 onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.RESTRICT)
33 }, indices = {@Index(name = "fk_tran_acc_prof_acc", value = {"profile", "account_name"})})
34 public class TransactionAccount {
37 private String profile;
38 @ColumnInfo(name = "transaction_id")
39 private int transactionId;
40 @ColumnInfo(name = "order_no")
42 @ColumnInfo(name = "account_name")
44 private String accountName;
45 @ColumnInfo(defaultValue = "")
47 private String currency = "";
51 private String comment;
52 @ColumnInfo(defaultValue = "0")
53 private int generation = 0;
55 public String getProfile() {
58 public void setProfile(@NonNull String profile) {
59 this.profile = profile;
61 public int getTransactionId() {
64 public void setTransactionId(int transactionId) {
65 this.transactionId = transactionId;
67 public int getOrderNo() {
70 public void setOrderNo(int orderNo) {
71 this.orderNo = orderNo;
74 public String getAccountName() {
77 public void setAccountName(@NonNull String accountName) {
78 this.accountName = accountName;
81 public String getCurrency() {
84 public void setCurrency(@NonNull String currency) {
85 this.currency = currency;
87 public float getAmount() {
90 public void setAmount(float amount) {
93 public String getComment() {
96 public void setComment(String comment) {
97 this.comment = comment;
99 public int getGeneration() {
102 public void setGeneration(int generation) {
103 this.generation = generation;