2 * Copyright (C) 2017 Roland Haeder<roland@mxchange.org>
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.
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.
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/>.
17 package org.mxchange.jfinancials.receipt;
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;
43 * @author Roland Haeder<roland@mxchange.org>
45 @Entity (name = "receipts")
49 @SuppressWarnings ("PersistenceUnitPresent")
50 public class Receipt implements Billable {
56 private static final long serialVersionUID = 185_867_217_461L;
59 * When this receipt has been created
61 @Basic (optional = false)
62 @Temporal (TemporalType.TIMESTAMP)
63 @Column (name = "receipt_created", nullable = false)
64 private Calendar receiptCreated;
70 @GeneratedValue (strategy = GenerationType.AUTO)
71 @Column (name = "receipt_id", nullable = false, updatable = false)
72 private Long receiptId;
75 * Payment type (cash, credit card, EC card ...)
77 @Basic (optional = false)
78 @Column (name = "receipt_payment_type", nullable = false)
79 @Enumerated (EnumType.STRING)
80 private PaymentType receiptPaymentType;
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;
90 * Which user this receipt belongs to
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;
97 @SuppressWarnings ("ReturnOfDateField")
98 public Calendar getReceiptCreated () {
99 return this.receiptCreated;
103 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
104 public void setReceiptCreated (final Calendar receiptCreated) {
105 this.receiptCreated = receiptCreated;
109 public Long getReceiptId () {
110 return this.receiptId;
114 public void setReceiptId (final Long receiptId) {
115 this.receiptId = receiptId;
119 public PaymentType getReceiptPaymentType () {
120 return this.receiptPaymentType;
124 public void setReceiptPaymentType (final PaymentType receiptPaymentType) {
125 this.receiptPaymentType = receiptPaymentType;
129 public BusinessContact getReceiptSeller () {
130 return this.receiptSeller;
134 public void setReceiptSeller (final BusinessContact receiptSeller) {
135 this.receiptSeller = receiptSeller;
139 public User getReceiptUser () {
140 return this.receiptUser;
144 public void setReceiptUser (final User receiptUser) {
145 this.receiptUser = receiptUser;