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