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 @Entity(tableName = "transaction_accounts", foreignKeys = {
28 @ForeignKey(entity = Transaction.class, parentColumns = {"id"},
29 childColumns = {"transaction_id"}, onDelete = ForeignKey.CASCADE,
30 onUpdate = ForeignKey.RESTRICT)
31 }, indices = {@Index(name = "fk_trans_acc_trans", value = {"transaction_id"}),
32 @Index(name = "un_transaction_accounts", unique = true,
33 value = {"transaction_id", "order_no"})
35 public class TransactionAccount {
37 @PrimaryKey(autoGenerate = true)
39 @ColumnInfo(name = "transaction_id")
40 private long transactionId;
41 @ColumnInfo(name = "order_no")
43 @ColumnInfo(name = "account_name")
45 private String accountName;
46 @ColumnInfo(defaultValue = "")
48 private String currency = "";
52 private String comment;
53 @ColumnInfo(defaultValue = "0")
54 private long generation = 0;
58 public void setId(long id) {
62 public long getTransactionId() {
65 public void setTransactionId(long transactionId) {
66 this.transactionId = transactionId;
68 public int getOrderNo() {
71 public void setOrderNo(int orderNo) {
72 this.orderNo = orderNo;
75 public String getAccountName() {
78 public void setAccountName(@NonNull String accountName) {
79 this.accountName = accountName;
82 public String getCurrency() {
85 public void setCurrency(@NonNull String currency) {
86 this.currency = currency;
88 public float getAmount() {
91 public void setAmount(float amount) {
94 public String getComment() {
97 public void setComment(String comment) {
98 this.comment = comment;
100 public long getGeneration() {
103 public void setGeneration(long generation) {
104 this.generation = generation;
107 public void copyDataFrom(TransactionAccount o) {
109 transactionId = o.transactionId;
111 accountName = o.accountName;
112 currency = o.currency;
115 generation = o.generation;