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.entry;
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.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.Index;
28 import javax.persistence.JoinColumn;
29 import javax.persistence.OneToOne;
30 import javax.persistence.Table;
31 import javax.persistence.Temporal;
32 import javax.persistence.TemporalType;
33 import javax.persistence.Transient;
34 import org.mxchange.jfinancials.receipt.Billable;
35 import org.mxchange.jfinancials.receipt.Receipt;
36 import org.mxchange.jshopcore.model.product.GenericProduct;
37 import org.mxchange.jshopcore.model.product.Product;
40 * A class for entryReceipt entries
42 * @author Roland Haeder<roland@mxchange.org>
44 @Entity (name = "receipt_entries")
46 name = "receipt_entries",
48 @Index (name = "entry_receipt_product", columnList = "entry_receipt_id,entry_product_id", unique = true)
51 @SuppressWarnings ("PersistenceUnitPresent")
52 public class ReceiptEntry implements BillableReceiptEntry {
58 private static final long serialVersionUID = 126_498_698_378_571L;
61 * When this entry has been created in database
63 @Basic (optional = false)
64 @Temporal (TemporalType.TIMESTAMP)
65 @Column (name = "entry_created", nullable = false)
66 private Calendar entryCreated;
72 @GeneratedValue (strategy = GenerationType.IDENTITY)
73 @Column (name = "entry_id", nullable = false, updatable = false)
77 * Product being linked in this entryReceipt item
79 @JoinColumn (name = "entry_product_id", referencedColumnName = "product_id", nullable = false, updatable = false, unique = true)
80 @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.ALL, optional = false)
81 private Product entryProduct;
84 * Single product price (being copied here from GenericProduct)
86 @Basic (optional = false)
87 @Column (name = "entry_product_price", nullable = false)
88 private Float entryProductPrice;
93 @Basic (optional = false)
94 @Column (name = "entry_product_quantity", nullable = false)
95 private Long entryProductQuantity;
98 * Connected entryReceipt entry
100 @JoinColumn (name = "entry_receipt_id", referencedColumnName = "receipt_id", nullable = false, updatable = false, unique = true)
101 @OneToOne (targetEntity = Receipt.class, cascade = CascadeType.REFRESH, optional = false)
102 private Billable entryReceipt;
105 @SuppressWarnings ("ReturnOfDateField")
106 public Calendar getEntryCreated () {
107 return this.entryCreated;
111 @SuppressWarnings ("AssignmentToDateFieldFromParameter")
112 public void setEntryCreated (final Calendar entryCreated) {
113 this.entryCreated = entryCreated;
117 public Long getEntryId () {
122 public void setEntryId (final Long entryId) {
123 this.entryId = entryId;
127 public Product getEntryProduct () {
128 return this.entryProduct;
132 public void setEntryProduct (final Product entryProduct) {
133 this.entryProduct = entryProduct;
137 public Float getEntryProductPrice () {
138 return this.entryProductPrice;
142 public void setEntryProductPrice (final Float entryProductPrice) {
143 this.entryProductPrice = entryProductPrice;
147 public Long getEntryProductQuantity () {
148 return this.entryProductQuantity;
152 public void setEntryProductQuantity (final Long entryProductQuantity) {
153 this.entryProductQuantity = entryProductQuantity;
157 public Billable getEntryReceipt () {
158 return this.entryReceipt;
162 public void setEntryReceipt (final Billable entryReceipt) {
163 this.entryReceipt = entryReceipt;