]> git.mxchange.org Git - jfinancials-core.git/blob - src/org/mxchange/jfinancials/receipt/Receipt.java
Continued a bit:
[jfinancials-core.git] / src / org / mxchange / jfinancials / receipt / Receipt.java
1 /*
2  * Copyright (C) 2017 Roland Haeder<roland@mxchange.org>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program 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 for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17 package org.mxchange.jfinancials.receipt;
18
19 import java.util.Calendar;
20 import javax.persistence.Basic;
21 import javax.persistence.CascadeType;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.EnumType;
25 import javax.persistence.Enumerated;
26 import javax.persistence.GeneratedValue;
27 import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.JoinColumn;
30 import javax.persistence.OneToOne;
31 import javax.persistence.Table;
32 import javax.persistence.Temporal;
33 import javax.persistence.TemporalType;
34 import javax.persistence.Transient;
35 import org.mxchange.jcontactsbusiness.BusinessContact;
36 import org.mxchange.jcontactsbusiness.CompanyContact;
37 import org.mxchange.jshopcore.model.payment.PaymentType;
38 import org.mxchange.jusercore.model.user.LoginUser;
39 import org.mxchange.jusercore.model.user.User;
40
41 /**
42  *
43  * @author Roland Haeder<roland@mxchange.org>
44  */
45 @Entity (name = "receipts")
46 @Table (
47                 name = "receipts"
48 )
49 @SuppressWarnings ("PersistenceUnitPresent")
50 public class Receipt implements Billable {
51
52         /**
53          * Serial number
54          */
55         @Transient
56         private static final long serialVersionUID = 185_867_217_461L;
57
58         /**
59          * When this receipt has been created
60          */
61         @Basic (optional = false)
62         @Temporal (TemporalType.TIMESTAMP)
63         @Column (name = "receipt_created", nullable = false)
64         private Calendar receiptCreated;
65
66         /**
67          * Primary key
68          */
69         @Id
70         @GeneratedValue (strategy = GenerationType.AUTO)
71         @Column (name = "receipt_id", nullable = false, updatable = false)
72         private Long receiptId;
73
74         /**
75          * Payment type (cash, credit card, EC card ...)
76          */
77         @Basic (optional = false)
78         @Column (name = "receipt_payment_type", nullable = false)
79         @Enumerated (EnumType.STRING)
80         private PaymentType receiptPaymentType;
81
82         /**
83          * Seller instance
84          */
85         @JoinColumn (name = "receipt_seller_id", referencedColumnName = "company_id", nullable = false, updatable = false)
86         @OneToOne (targetEntity = CompanyContact.class, cascade = CascadeType.REFRESH, optional = false)
87         private BusinessContact receiptSeller;
88
89         /**
90          * Which user this receipt belongs to
91          */
92         @JoinColumn (name = "receipt_user_id", referencedColumnName = "user_id", nullable = false, updatable = false)
93         @OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
94         private User receiptUser;
95
96         @Override
97         @SuppressWarnings ("ReturnOfDateField")
98         public Calendar getReceiptCreated () {
99                 return this.receiptCreated;
100         }
101
102         @Override
103         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
104         public void setReceiptCreated (final Calendar receiptCreated) {
105                 this.receiptCreated = receiptCreated;
106         }
107
108         @Override
109         public Long getReceiptId () {
110                 return this.receiptId;
111         }
112
113         @Override
114         public void setReceiptId (final Long receiptId) {
115                 this.receiptId = receiptId;
116         }
117
118         @Override
119         public PaymentType getReceiptPaymentType () {
120                 return this.receiptPaymentType;
121         }
122
123         @Override
124         public void setReceiptPaymentType (final PaymentType receiptPaymentType) {
125                 this.receiptPaymentType = receiptPaymentType;
126         }
127
128         @Override
129         public BusinessContact getReceiptSeller () {
130                 return this.receiptSeller;
131         }
132
133         @Override
134         public void setReceiptSeller (final BusinessContact receiptSeller) {
135                 this.receiptSeller = receiptSeller;
136         }
137
138         @Override
139         public User getReceiptUser () {
140                 return this.receiptUser;
141         }
142
143         @Override
144         public void setReceiptUser (final User receiptUser) {
145                 this.receiptUser = receiptUser;
146         }
147
148 }