]> git.mxchange.org Git - jfinancials-core.git/blob - src/org/mxchange/jfinancials/receipt/entry/ReceiptEntry.java
Continued a bit:
[jfinancials-core.git] / src / org / mxchange / jfinancials / receipt / entry / ReceiptEntry.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.entry;
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.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;
38
39 /**
40  * A class for entryReceipt entries
41  * <p>
42  * @author Roland Haeder<roland@mxchange.org>
43  */
44 @Entity (name = "receipt_entries")
45 @Table (
46                 name = "receipt_entries",
47                 indexes = {
48                         @Index (name = "entry_receipt_product", columnList = "entry_receipt_id,entry_product_id", unique = true)
49                 }
50 )
51 @SuppressWarnings ("PersistenceUnitPresent")
52 public class ReceiptEntry implements BillableReceiptEntry {
53
54         /**
55          * Serial number
56          */
57         @Transient
58         private static final long serialVersionUID = 126_498_698_378_571L;
59
60         /**
61          * When this entry has been created in database
62          */
63         @Basic (optional = false)
64         @Temporal (TemporalType.TIMESTAMP)
65         @Column (name = "entry_created", nullable = false)
66         private Calendar entryCreated;
67
68         /**
69          * Primary key
70          */
71         @Id
72         @GeneratedValue (strategy = GenerationType.IDENTITY)
73         @Column (name = "entry_id", nullable = false, updatable = false)
74         private Long entryId;
75
76         /**
77          * Product being linked in this entryReceipt item
78          */
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;
82
83         /**
84          * Single product price (being copied here from GenericProduct)
85          */
86         @Basic (optional = false)
87         @Column (name = "entry_product_price", nullable = false)
88         private Float entryProductPrice;
89
90         /**
91          * Product quantity
92          */
93         @Basic (optional = false)
94         @Column (name = "entry_product_quantity", nullable = false)
95         private Long entryProductQuantity;
96
97         /**
98          * Connected entryReceipt entry
99          */
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;
103
104         @Override
105         @SuppressWarnings ("ReturnOfDateField")
106         public Calendar getEntryCreated () {
107                 return this.entryCreated;
108         }
109
110         @Override
111         @SuppressWarnings ("AssignmentToDateFieldFromParameter")
112         public void setEntryCreated (final Calendar entryCreated) {
113                 this.entryCreated = entryCreated;
114         }
115
116         @Override
117         public Long getEntryId () {
118                 return this.entryId;
119         }
120
121         @Override
122         public void setEntryId (final Long entryId) {
123                 this.entryId = entryId;
124         }
125
126         @Override
127         public Product getEntryProduct () {
128                 return this.entryProduct;
129         }
130
131         @Override
132         public void setEntryProduct (final Product entryProduct) {
133                 this.entryProduct = entryProduct;
134         }
135
136         @Override
137         public Float getEntryProductPrice () {
138                 return this.entryProductPrice;
139         }
140
141         @Override
142         public void setEntryProductPrice (final Float entryProductPrice) {
143                 this.entryProductPrice = entryProductPrice;
144         }
145
146         @Override
147         public Long getEntryProductQuantity () {
148                 return this.entryProductQuantity;
149         }
150
151         @Override
152         public void setEntryProductQuantity (final Long entryProductQuantity) {
153                 this.entryProductQuantity = entryProductQuantity;
154         }
155
156         @Override
157         public Billable getEntryReceipt () {
158                 return this.entryReceipt;
159         }
160
161         @Override
162         public void setEntryReceipt (final Billable entryReceipt) {
163                 this.entryReceipt = entryReceipt;
164         }
165
166 }