]> git.ktnx.net Git - mobile-ledger.git/blob - app/src/main/java/net/ktnx/mobileledger/db/TransactionAccount.java
describe transaction_accounts to Room
[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
25 @Entity(tableName = "transaction_accounts", primaryKeys = {"profile", "transaction_id", "order_no"},
26         foreignKeys = {@ForeignKey(entity = Transaction.class, parentColumns = {"profile", "id"},
27                                    childColumns = {"profile", "transaction_id"},
28                                    onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.RESTRICT),
29                        @ForeignKey(entity = Account.class, parentColumns = {"profile", "name"},
30                                    childColumns = {"profile", "account_name"},
31                                    onDelete = ForeignKey.CASCADE, onUpdate = ForeignKey.RESTRICT)
32         })
33 public class TransactionAccount {
34     @ColumnInfo
35     @NonNull
36     private String profile;
37     @ColumnInfo(name = "transaction_id")
38     private int transactionId;
39     @ColumnInfo(name = "order_no")
40     private int orderNo;
41     @ColumnInfo(name = "account_name")
42     @NonNull
43     private String accountName;
44     @ColumnInfo(defaultValue = "")
45     @NonNull
46     private String currency = "";
47     @ColumnInfo
48     private float amount;
49     @ColumnInfo
50     private String comment;
51     @ColumnInfo(defaultValue = "0")
52     private int generation = 0;
53     @NonNull
54     public String getProfile() {
55         return profile;
56     }
57     public void setProfile(@NonNull String profile) {
58         this.profile = profile;
59     }
60     public int getTransactionId() {
61         return transactionId;
62     }
63     public void setTransactionId(int transactionId) {
64         this.transactionId = transactionId;
65     }
66     public int getOrderNo() {
67         return orderNo;
68     }
69     public void setOrderNo(int orderNo) {
70         this.orderNo = orderNo;
71     }
72     @NonNull
73     public String getAccountName() {
74         return accountName;
75     }
76     public void setAccountName(@NonNull String accountName) {
77         this.accountName = accountName;
78     }
79     @NonNull
80     public String getCurrency() {
81         return currency;
82     }
83     public void setCurrency(@NonNull String currency) {
84         this.currency = currency;
85     }
86     public float getAmount() {
87         return amount;
88     }
89     public void setAmount(float amount) {
90         this.amount = amount;
91     }
92     public String getComment() {
93         return comment;
94     }
95     public void setComment(String comment) {
96         this.comment = comment;
97     }
98     public int getGeneration() {
99         return generation;
100     }
101     public void setGeneration(int generation) {
102         this.generation = generation;
103     }
104 }