From 7fcaee13e8ccf5438c0a99a129f214b6a084ea0e Mon Sep 17 00:00:00 2001
From: =?utf8?q?Roland=20H=C3=A4der?= <roland@mxchange.org>
Date: Fri, 13 Oct 2017 22:52:58 +0200
Subject: [PATCH] Continued: - renamed <e|E>ntry -> <i|I>tem as this is more
 convincing - added new entity property "itemDiscount" which is an optional
 discount on a   single item
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Signed-off-by: Roland Häder <roland@mxchange.org>
---
 .../receipt/item/BillableReceiptItem.java     |  62 +++++---
 .../model/receipt/item/ReceiptItem.java       | 148 ++++++++++--------
 2 files changed, 120 insertions(+), 90 deletions(-)

diff --git a/src/org/mxchange/jfinancials/model/receipt/item/BillableReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt/item/BillableReceiptItem.java
index 9802067..39db54e 100644
--- a/src/org/mxchange/jfinancials/model/receipt/item/BillableReceiptItem.java
+++ b/src/org/mxchange/jfinancials/model/receipt/item/BillableReceiptItem.java
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.mxchange.jfinancials.model.receipt.entry;
+package org.mxchange.jfinancials.model.receipt.item;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -22,95 +22,109 @@ import org.mxchange.jfinancials.model.receipt.BillableReceipt;
 import org.mxchange.jproduct.model.product.Product;
 
 /**
- * An interface for receipt entries
+ * An interface for receipt items
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-public interface BillableReceiptEntry extends Serializable {
+public interface BillableReceiptItem extends Serializable {
 
 	/**
-	 * Getter when this receipt entry has been created in database
+	 * Getter when this receipt item has been created in database
 	 * <p>
-	 * @return When this entry has been created
+	 * @return When this item has been created
 	 */
-	Date getEntryCreated ();
+	Date getItemCreated ();
 
 	/**
-	 * Setter when this receipt entry has been created in database
+	 * Setter when this receipt item has been created in database
 	 * <p>
-	 * @param entryCreated When this entry has been created
+	 * @param itemCreated When this item has been created
 	 */
-	void setEntryCreated (final Date entryCreated);
+	void setItemCreated (final Date itemCreated);
 
 	/**
 	 * Getter for primary key
 	 * <p>
 	 * @return Primary key
 	 */
-	Long getEntryId ();
+	Long getItemId ();
 
 	/**
 	 * Setter for primary key
 	 * <p>
-	 * @param entryId Primary key
+	 * @param itemId Primary key
 	 */
-	void setEntryId (final Long entryId);
+	void setItemId (final Long itemId);
 
 	/**
 	 * Getter for receipt instance
 	 * <p>
 	 * @return Receipt instance
 	 */
-	BillableReceipt getEntryReceipt ();
+	BillableReceipt getItemReceipt ();
 
 	/**
 	 * Setter for receipt instance
 	 * <p>
-	 * @param entryReceipt Receipt instance
+	 * @param itemReceipt Receipt instance
 	 */
-	void setEntryReceipt (final BillableReceipt entryReceipt);
+	void setItemReceipt (final BillableReceipt itemReceipt);
 
 	/**
 	 * Getter for linked product
 	 * <p>
 	 * @return Product
 	 */
-	Product getEntryProduct ();
+	Product getItemProduct ();
 
 	/**
 	 * Setter for linked product
 	 * <p>
-	 * @param entryProduct Product
+	 * @param itemProduct Product
 	 */
-	void setEntryProduct (final Product entryProduct);
+	void setItemProduct (final Product itemProduct);
 
 	/**
 	 * Getter for product quantity
 	 * <p>
 	 * @return Product quantity
 	 */
-	Long getEntryProductQuantity ();
+	Long getItemProductQuantity ();
 
 	/**
 	 * Setter for product quantity
 	 * <p>
-	 * @param entryProductQuantity Product quantity
+	 * @param itemProductQuantity Product quantity
 	 */
-	void setEntryProductQuantity (final Long entryProductQuantity);
+	void setItemProductQuantity (final Long itemProductQuantity);
 
 	/**
 	 * Getter for product single price (copied from GenericProduct)
 	 * <p>
 	 * @return Product single price
 	 */
-	Float getEntryProductPrice ();
+	Float getItemProductPrice ();
 
 	/**
 	 * Setter for product single price (copied from GenericProduct)
 	 * <p>
-	 * @param entryProductPrice Product single price
+	 * @param itemProductPrice Product single price
 	 */
-	void setEntryProductPrice (final Float entryProductPrice);
+	void setItemProductPrice (final Float itemProductPrice);
+
+	/**
+	 * Getter for item discount
+	 * <p>
+	 * @return Item discount
+	 */
+	Float getItemDiscount ();
+
+	/**
+	 * Setter for item discount
+	 * <p>
+	 * @param itemDiscount Item discount
+	 */
+	void setItemDiscount (final Float itemDiscount);
 
 	@Override
 	boolean equals (final Object object);
diff --git a/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItem.java
index b17f7ce..8d9773d 100644
--- a/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItem.java
+++ b/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItem.java
@@ -14,7 +14,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
-package org.mxchange.jfinancials.model.receipt.entry;
+package org.mxchange.jfinancials.model.receipt.item;
 
 import java.util.Date;
 import java.util.Objects;
@@ -38,19 +38,19 @@ import org.mxchange.jproduct.model.product.GenericProduct;
 import org.mxchange.jproduct.model.product.Product;
 
 /**
- * A class for entryReceipt entries
+ * A POJO for receipt items
  * <p>
  * @author Roland Häder<roland@mxchange.org>
  */
-@Entity (name = "receipt_entries")
+@Entity (name = "receipt_items")
 @Table (
-		name = "receipt_entries",
+		name = "receipt_items",
 		indexes = {
-			@Index (name = "entry_receipt_product", columnList = "entry_receipt_id,entry_product_id", unique = true)
+			@Index (name = "item_receipt_product", columnList = "item_receipt_id,item_product_id", unique = true)
 		}
 )
 @SuppressWarnings ("PersistenceUnitPresent")
-public class ReceiptEntry implements BillableReceiptEntry {
+public class ReceiptItem implements BillableReceiptItem {
 
 	/**
 	 * Serial number
@@ -59,72 +59,78 @@ public class ReceiptEntry implements BillableReceiptEntry {
 	private static final long serialVersionUID = 126_498_698_378_571L;
 
 	/**
-	 * When this entry has been created in database
+	 * When this item has been created in database
 	 */
 	@Basic (optional = false)
 	@Temporal (TemporalType.TIMESTAMP)
-	@Column (name = "entry_created", nullable = false)
-	private Date entryCreated;
+	@Column (name = "item_created", nullable = false)
+	private Date itemCreated;
+
+	/**
+	 * Discount on item
+	 */
+	@Column (name = "item_product_discount")
+	private Float itemDiscount;
 
 	/**
 	 * Primary key
 	 */
 	@Id
 	@GeneratedValue (strategy = GenerationType.IDENTITY)
-	@Column (name = "entry_id", nullable = false, updatable = false)
-	private Long entryId;
+	@Column (name = "item_id", nullable = false, updatable = false)
+	private Long itemId;
 
 	/**
-	 * Product being linked in this entryReceipt item
+	 * Product being linked in this itemReceipt item
 	 */
-	@JoinColumn (name = "entry_product_id", referencedColumnName = "product_id", nullable = false, updatable = false, unique = true)
+	@JoinColumn (name = "item_product_id", referencedColumnName = "product_id", nullable = false, updatable = false)
 	@OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.REFRESH, optional = false)
-	private Product entryProduct;
+	private Product itemProduct;
 
 	/**
 	 * Single product price (being copied here from GenericProduct)
 	 */
 	@Basic (optional = false)
-	@Column (name = "entry_product_price", nullable = false)
-	private Float entryProductPrice;
+	@Column (name = "item_product_price", nullable = false)
+	private Float itemProductPrice;
 
 	/**
 	 * Product quantity
 	 */
 	@Basic (optional = false)
-	@Column (name = "entry_product_quantity", nullable = false)
-	private Long entryProductQuantity;
+	@Column (name = "item_product_quantity", nullable = false)
+	private Long itemProductQuantity;
 
 	/**
-	 * Connected entryReceipt entry
+	 * Connected itemReceipt item
 	 */
-	@JoinColumn (name = "entry_receipt_id", referencedColumnName = "receipt_id", nullable = false, updatable = false, unique = true)
+	@JoinColumn (name = "item_receipt_id", referencedColumnName = "receipt_id", nullable = false, updatable = false)
 	@OneToOne (targetEntity = FinancialReceipt.class, cascade = CascadeType.REFRESH, optional = false)
-	private BillableReceipt entryReceipt;
+	private BillableReceipt itemReceipt;
 
 	/**
 	 * Default constructor
 	 */
-	public ReceiptEntry () {
+	public ReceiptItem () {
 	}
 
 	/**
 	 * Constructor with product, price, quantity and receipt instance
 	 * <p>
-	 * @param entryProduct         Product instance
-	 * @param entryProductPrice    Product price (copied)
-	 * @param entryProductQuantity Product quantity
-	 * @param entryReceipt         FinancialReceipt instance
+	 * @param itemProduct         Product instance
+	 * @param itemProductPrice    Product price (copied)
+	 * @param itemProductQuantity Product quantity
+	 * @param itemReceipt         FinancialReceipt instance
 	 */
-	public ReceiptEntry (final Product entryProduct, final Float entryProductPrice, final Long entryProductQuantity, final BillableReceipt entryReceipt) {
+	public ReceiptItem (final Product itemProduct, final Float itemProductPrice, final Long itemProductQuantity, final BillableReceipt itemReceipt) {
 		// Call other constructor
 		this();
 
 		// Set all values
-		this.entryProduct = entryProduct;
-		this.entryProductPrice = entryProductPrice;
-		this.entryProductQuantity = entryProductQuantity;
-		this.entryReceipt = entryReceipt;
+		this.itemProduct = itemProduct;
+		this.itemProductPrice = itemProductPrice;
+		this.itemProductQuantity = itemProductQuantity;
+		this.itemReceipt = itemReceipt;
 	}
 
 	@Override
@@ -137,17 +143,17 @@ public class ReceiptEntry implements BillableReceiptEntry {
 			return false;
 		}
 
-		final BillableReceiptEntry receiptEntry = (BillableReceiptEntry) object;
+		final BillableReceiptItem receiptItem = (BillableReceiptItem) object;
 
-		if (!Objects.equals(this.getEntryId(), receiptEntry.getEntryId())) {
+		if (!Objects.equals(this.getItemId(), receiptItem.getItemId())) {
 			return false;
-		} else if (!Objects.equals(this.getEntryProduct(), receiptEntry.getEntryProduct())) {
+		} else if (!Objects.equals(this.getItemProduct(), receiptItem.getItemProduct())) {
 			return false;
-		} else if (!Objects.equals(this.getEntryProductPrice(), receiptEntry.getEntryProductPrice())) {
+		} else if (!Objects.equals(this.getItemProductPrice(), receiptItem.getItemProductPrice())) {
 			return false;
-		} else if (!Objects.equals(this.getEntryProductQuantity(), receiptEntry.getEntryProductQuantity())) {
+		} else if (!Objects.equals(this.getItemProductQuantity(), receiptItem.getItemProductQuantity())) {
 			return false;
-		} else if (!Objects.equals(this.getEntryReceipt(), receiptEntry.getEntryReceipt())) {
+		} else if (!Objects.equals(this.getItemReceipt(), receiptItem.getItemReceipt())) {
 			return false;
 		}
 
@@ -156,75 +162,85 @@ public class ReceiptEntry implements BillableReceiptEntry {
 
 	@Override
 	@SuppressWarnings ("ReturnOfDateField")
-	public Date getEntryCreated () {
-		return this.entryCreated;
+	public Date getItemCreated () {
+		return this.itemCreated;
 	}
 
 	@Override
 	@SuppressWarnings ("AssignmentToDateFieldFromParameter")
-	public void setEntryCreated (final Date entryCreated) {
-		this.entryCreated = entryCreated;
+	public void setItemCreated (final Date itemCreated) {
+		this.itemCreated = itemCreated;
+	}
+
+	@Override
+	public Float getItemDiscount () {
+		return this.itemDiscount;
+	}
+
+	@Override
+	public void setItemDiscount (final Float itemDiscount) {
+		this.itemDiscount = itemDiscount;
 	}
 
 	@Override
-	public Long getEntryId () {
-		return this.entryId;
+	public Long getItemId () {
+		return this.itemId;
 	}
 
 	@Override
-	public void setEntryId (final Long entryId) {
-		this.entryId = entryId;
+	public void setItemId (final Long itemId) {
+		this.itemId = itemId;
 	}
 
 	@Override
-	public Product getEntryProduct () {
-		return this.entryProduct;
+	public Product getItemProduct () {
+		return this.itemProduct;
 	}
 
 	@Override
-	public void setEntryProduct (final Product entryProduct) {
-		this.entryProduct = entryProduct;
+	public void setItemProduct (final Product itemProduct) {
+		this.itemProduct = itemProduct;
 	}
 
 	@Override
-	public Float getEntryProductPrice () {
-		return this.entryProductPrice;
+	public Float getItemProductPrice () {
+		return this.itemProductPrice;
 	}
 
 	@Override
-	public void setEntryProductPrice (final Float entryProductPrice) {
-		this.entryProductPrice = entryProductPrice;
+	public void setItemProductPrice (final Float itemProductPrice) {
+		this.itemProductPrice = itemProductPrice;
 	}
 
 	@Override
-	public Long getEntryProductQuantity () {
-		return this.entryProductQuantity;
+	public Long getItemProductQuantity () {
+		return this.itemProductQuantity;
 	}
 
 	@Override
-	public void setEntryProductQuantity (final Long entryProductQuantity) {
-		this.entryProductQuantity = entryProductQuantity;
+	public void setItemProductQuantity (final Long itemProductQuantity) {
+		this.itemProductQuantity = itemProductQuantity;
 	}
 
 	@Override
-	public BillableReceipt getEntryReceipt () {
-		return this.entryReceipt;
+	public BillableReceipt getItemReceipt () {
+		return this.itemReceipt;
 	}
 
 	@Override
-	public void setEntryReceipt (final BillableReceipt entryReceipt) {
-		this.entryReceipt = entryReceipt;
+	public void setItemReceipt (final BillableReceipt itemReceipt) {
+		this.itemReceipt = itemReceipt;
 	}
 
 	@Override
 	public int hashCode () {
 		int hash = 5;
 
-		hash = 53 * hash + Objects.hashCode(this.getEntryId());
-		hash = 53 * hash + Objects.hashCode(this.getEntryProduct());
-		hash = 53 * hash + Objects.hashCode(this.getEntryProductPrice());
-		hash = 53 * hash + Objects.hashCode(this.getEntryProductQuantity());
-		hash = 53 * hash + Objects.hashCode(this.getEntryReceipt());
+		hash = 53 * hash + Objects.hashCode(this.getItemId());
+		hash = 53 * hash + Objects.hashCode(this.getItemProduct());
+		hash = 53 * hash + Objects.hashCode(this.getItemProductPrice());
+		hash = 53 * hash + Objects.hashCode(this.getItemProductQuantity());
+		hash = 53 * hash + Objects.hashCode(this.getItemReceipt());
 
 		return hash;
 	}
-- 
2.39.5