From: Roland Häder Date: Fri, 13 Oct 2017 20:52:58 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=7fcaee13e8ccf5438c0a99a129f214b6a084ea0e;p=jbonuscard-core.git Continued: - renamed ntry -> tem as this is more convincing - added new entity property "itemDiscount" which is an optional discount on a single item Signed-off-by: Roland Häder --- 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 . */ -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 *

* @author Roland Häder */ -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 *

- * @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 *

- * @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 *

* @return Primary key */ - Long getEntryId (); + Long getItemId (); /** * Setter for primary key *

- * @param entryId Primary key + * @param itemId Primary key */ - void setEntryId (final Long entryId); + void setItemId (final Long itemId); /** * Getter for receipt instance *

* @return Receipt instance */ - BillableReceipt getEntryReceipt (); + BillableReceipt getItemReceipt (); /** * Setter for receipt instance *

- * @param entryReceipt Receipt instance + * @param itemReceipt Receipt instance */ - void setEntryReceipt (final BillableReceipt entryReceipt); + void setItemReceipt (final BillableReceipt itemReceipt); /** * Getter for linked product *

* @return Product */ - Product getEntryProduct (); + Product getItemProduct (); /** * Setter for linked product *

- * @param entryProduct Product + * @param itemProduct Product */ - void setEntryProduct (final Product entryProduct); + void setItemProduct (final Product itemProduct); /** * Getter for product quantity *

* @return Product quantity */ - Long getEntryProductQuantity (); + Long getItemProductQuantity (); /** * Setter for product quantity *

- * @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) *

* @return Product single price */ - Float getEntryProductPrice (); + Float getItemProductPrice (); /** * Setter for product single price (copied from GenericProduct) *

- * @param entryProductPrice Product single price + * @param itemProductPrice Product single price */ - void setEntryProductPrice (final Float entryProductPrice); + void setItemProductPrice (final Float itemProductPrice); + + /** + * Getter for item discount + *

+ * @return Item discount + */ + Float getItemDiscount (); + + /** + * Setter for item discount + *

+ * @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 . */ -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 *

* @author Roland Häder */ -@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 *

- * @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; }