]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/db/TransactionAccount.java
6d51fec9d44e5cb1c20b8f89fb6f5832b96b01e2
[mobile-ledger.git] / app / src / main / java / net / ktnx / mobileledger / db / TransactionAccount.java
1 /*
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.
8  *
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.
13  *
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/>.
16  */
17
18 package net.ktnx.mobileledger.db;
19
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
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 {
35     @ColumnInfo
36     @NonNull
37     private String profile;
38     @ColumnInfo(name = "transaction_id")
39     private int transactionId;
40     @ColumnInfo(name = "order_no")
41     private int orderNo;
42     @ColumnInfo(name = "account_name")
43     @NonNull
44     private String accountName;
45     @ColumnInfo(defaultValue = "")
46     @NonNull
47     private String currency = "";
48     @ColumnInfo
49     private float amount;
50     @ColumnInfo
51     private String comment;
52     @ColumnInfo(defaultValue = "0")
53     private int generation = 0;
54     @NonNull
55     public String getProfile() {
56         return profile;
57     }
58     public void setProfile(@NonNull String profile) {
59         this.profile = profile;
60     }
61     public int getTransactionId() {
62         return transactionId;
63     }
64     public void setTransactionId(int transactionId) {
65         this.transactionId = transactionId;
66     }
67     public int getOrderNo() {
68         return orderNo;
69     }
70     public void setOrderNo(int orderNo) {
71         this.orderNo = orderNo;
72     }
73     @NonNull
74     public String getAccountName() {
75         return accountName;
76     }
77     public void setAccountName(@NonNull String accountName) {
78         this.accountName = accountName;
79     }
80     @NonNull
81     public String getCurrency() {
82         return currency;
83     }
84     public void setCurrency(@NonNull String currency) {
85         this.currency = currency;
86     }
87     public float getAmount() {
88         return amount;
89     }
90     public void setAmount(float amount) {
91         this.amount = amount;
92     }
93     public String getComment() {
94         return comment;
95     }
96     public void setComment(String comment) {
97         this.comment = comment;
98     }
99     public int getGeneration() {
100         return generation;
101     }
102     public void setGeneration(int generation) {
103         this.generation = generation;
104     }
105 }