From: Roland Häder Date: Fri, 13 Oct 2017 20:25:00 +0000 (+0200) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e1a1204cd28d761f8c5e69b6991540f862ddfcee;p=jfinancials-core.git Continued: - renamed + moved to proper package/class name Signed-off-by: Roland Häder --- diff --git a/src/org/mxchange/jfinancials/model/receipt/entry/BillableReceiptEntry.java b/src/org/mxchange/jfinancials/model/receipt/entry/BillableReceiptEntry.java deleted file mode 100644 index 9802067..0000000 --- a/src/org/mxchange/jfinancials/model/receipt/entry/BillableReceiptEntry.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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; - -import java.io.Serializable; -import java.util.Date; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; -import org.mxchange.jproduct.model.product.Product; - -/** - * An interface for receipt entries - *

- * @author Roland Häder - */ -public interface BillableReceiptEntry extends Serializable { - - /** - * Getter when this receipt entry has been created in database - *

- * @return When this entry has been created - */ - Date getEntryCreated (); - - /** - * Setter when this receipt entry has been created in database - *

- * @param entryCreated When this entry has been created - */ - void setEntryCreated (final Date entryCreated); - - /** - * Getter for primary key - *

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

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

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

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

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

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

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

- * @param entryProductQuantity Product quantity - */ - void setEntryProductQuantity (final Long entryProductQuantity); - - /** - * Getter for product single price (copied from GenericProduct) - *

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

- * @param entryProductPrice Product single price - */ - void setEntryProductPrice (final Float entryProductPrice); - - @Override - boolean equals (final Object object); - - @Override - int hashCode (); - -} diff --git a/src/org/mxchange/jfinancials/model/receipt/entry/ReceiptEntry.java b/src/org/mxchange/jfinancials/model/receipt/entry/ReceiptEntry.java deleted file mode 100644 index b17f7ce..0000000 --- a/src/org/mxchange/jfinancials/model/receipt/entry/ReceiptEntry.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) 2016, 2017 Roland Häder - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * 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; - -import java.util.Date; -import java.util.Objects; -import javax.persistence.Basic; -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.Index; -import javax.persistence.JoinColumn; -import javax.persistence.OneToOne; -import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import org.mxchange.jfinancials.model.receipt.BillableReceipt; -import org.mxchange.jfinancials.model.receipt.FinancialReceipt; -import org.mxchange.jproduct.model.product.GenericProduct; -import org.mxchange.jproduct.model.product.Product; - -/** - * A class for entryReceipt entries - *

- * @author Roland Häder - */ -@Entity (name = "receipt_entries") -@Table ( - name = "receipt_entries", - indexes = { - @Index (name = "entry_receipt_product", columnList = "entry_receipt_id,entry_product_id", unique = true) - } -) -@SuppressWarnings ("PersistenceUnitPresent") -public class ReceiptEntry implements BillableReceiptEntry { - - /** - * Serial number - */ - @Transient - private static final long serialVersionUID = 126_498_698_378_571L; - - /** - * When this entry has been created in database - */ - @Basic (optional = false) - @Temporal (TemporalType.TIMESTAMP) - @Column (name = "entry_created", nullable = false) - private Date entryCreated; - - /** - * Primary key - */ - @Id - @GeneratedValue (strategy = GenerationType.IDENTITY) - @Column (name = "entry_id", nullable = false, updatable = false) - private Long entryId; - - /** - * Product being linked in this entryReceipt item - */ - @JoinColumn (name = "entry_product_id", referencedColumnName = "product_id", nullable = false, updatable = false, unique = true) - @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.REFRESH, optional = false) - private Product entryProduct; - - /** - * Single product price (being copied here from GenericProduct) - */ - @Basic (optional = false) - @Column (name = "entry_product_price", nullable = false) - private Float entryProductPrice; - - /** - * Product quantity - */ - @Basic (optional = false) - @Column (name = "entry_product_quantity", nullable = false) - private Long entryProductQuantity; - - /** - * Connected entryReceipt entry - */ - @JoinColumn (name = "entry_receipt_id", referencedColumnName = "receipt_id", nullable = false, updatable = false, unique = true) - @OneToOne (targetEntity = FinancialReceipt.class, cascade = CascadeType.REFRESH, optional = false) - private BillableReceipt entryReceipt; - - /** - * Default constructor - */ - public ReceiptEntry () { - } - - /** - * 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 - */ - public ReceiptEntry (final Product entryProduct, final Float entryProductPrice, final Long entryProductQuantity, final BillableReceipt entryReceipt) { - // Call other constructor - this(); - - // Set all values - this.entryProduct = entryProduct; - this.entryProductPrice = entryProductPrice; - this.entryProductQuantity = entryProductQuantity; - this.entryReceipt = entryReceipt; - } - - @Override - public boolean equals (final Object object) { - if (this == object) { - return true; - } else if (null == object) { - return false; - } else if (this.getClass() != object.getClass()) { - return false; - } - - final BillableReceiptEntry receiptEntry = (BillableReceiptEntry) object; - - if (!Objects.equals(this.getEntryId(), receiptEntry.getEntryId())) { - return false; - } else if (!Objects.equals(this.getEntryProduct(), receiptEntry.getEntryProduct())) { - return false; - } else if (!Objects.equals(this.getEntryProductPrice(), receiptEntry.getEntryProductPrice())) { - return false; - } else if (!Objects.equals(this.getEntryProductQuantity(), receiptEntry.getEntryProductQuantity())) { - return false; - } else if (!Objects.equals(this.getEntryReceipt(), receiptEntry.getEntryReceipt())) { - return false; - } - - return true; - } - - @Override - @SuppressWarnings ("ReturnOfDateField") - public Date getEntryCreated () { - return this.entryCreated; - } - - @Override - @SuppressWarnings ("AssignmentToDateFieldFromParameter") - public void setEntryCreated (final Date entryCreated) { - this.entryCreated = entryCreated; - } - - @Override - public Long getEntryId () { - return this.entryId; - } - - @Override - public void setEntryId (final Long entryId) { - this.entryId = entryId; - } - - @Override - public Product getEntryProduct () { - return this.entryProduct; - } - - @Override - public void setEntryProduct (final Product entryProduct) { - this.entryProduct = entryProduct; - } - - @Override - public Float getEntryProductPrice () { - return this.entryProductPrice; - } - - @Override - public void setEntryProductPrice (final Float entryProductPrice) { - this.entryProductPrice = entryProductPrice; - } - - @Override - public Long getEntryProductQuantity () { - return this.entryProductQuantity; - } - - @Override - public void setEntryProductQuantity (final Long entryProductQuantity) { - this.entryProductQuantity = entryProductQuantity; - } - - @Override - public BillableReceipt getEntryReceipt () { - return this.entryReceipt; - } - - @Override - public void setEntryReceipt (final BillableReceipt entryReceipt) { - this.entryReceipt = entryReceipt; - } - - @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()); - - return hash; - } - -} diff --git a/src/org/mxchange/jfinancials/model/receipt/item/BillableReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt/item/BillableReceiptItem.java new file mode 100644 index 0000000..9802067 --- /dev/null +++ b/src/org/mxchange/jfinancials/model/receipt/item/BillableReceiptItem.java @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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; + +import java.io.Serializable; +import java.util.Date; +import org.mxchange.jfinancials.model.receipt.BillableReceipt; +import org.mxchange.jproduct.model.product.Product; + +/** + * An interface for receipt entries + *

+ * @author Roland Häder + */ +public interface BillableReceiptEntry extends Serializable { + + /** + * Getter when this receipt entry has been created in database + *

+ * @return When this entry has been created + */ + Date getEntryCreated (); + + /** + * Setter when this receipt entry has been created in database + *

+ * @param entryCreated When this entry has been created + */ + void setEntryCreated (final Date entryCreated); + + /** + * Getter for primary key + *

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

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

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

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

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

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

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

+ * @param entryProductQuantity Product quantity + */ + void setEntryProductQuantity (final Long entryProductQuantity); + + /** + * Getter for product single price (copied from GenericProduct) + *

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

+ * @param entryProductPrice Product single price + */ + void setEntryProductPrice (final Float entryProductPrice); + + @Override + boolean equals (final Object object); + + @Override + int hashCode (); + +} diff --git a/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItem.java new file mode 100644 index 0000000..b17f7ce --- /dev/null +++ b/src/org/mxchange/jfinancials/model/receipt/item/ReceiptItem.java @@ -0,0 +1,232 @@ +/* + * Copyright (C) 2016, 2017 Roland Häder + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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; + +import java.util.Date; +import java.util.Objects; +import javax.persistence.Basic; +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.JoinColumn; +import javax.persistence.OneToOne; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; +import org.mxchange.jfinancials.model.receipt.BillableReceipt; +import org.mxchange.jfinancials.model.receipt.FinancialReceipt; +import org.mxchange.jproduct.model.product.GenericProduct; +import org.mxchange.jproduct.model.product.Product; + +/** + * A class for entryReceipt entries + *

+ * @author Roland Häder + */ +@Entity (name = "receipt_entries") +@Table ( + name = "receipt_entries", + indexes = { + @Index (name = "entry_receipt_product", columnList = "entry_receipt_id,entry_product_id", unique = true) + } +) +@SuppressWarnings ("PersistenceUnitPresent") +public class ReceiptEntry implements BillableReceiptEntry { + + /** + * Serial number + */ + @Transient + private static final long serialVersionUID = 126_498_698_378_571L; + + /** + * When this entry has been created in database + */ + @Basic (optional = false) + @Temporal (TemporalType.TIMESTAMP) + @Column (name = "entry_created", nullable = false) + private Date entryCreated; + + /** + * Primary key + */ + @Id + @GeneratedValue (strategy = GenerationType.IDENTITY) + @Column (name = "entry_id", nullable = false, updatable = false) + private Long entryId; + + /** + * Product being linked in this entryReceipt item + */ + @JoinColumn (name = "entry_product_id", referencedColumnName = "product_id", nullable = false, updatable = false, unique = true) + @OneToOne (targetEntity = GenericProduct.class, cascade = CascadeType.REFRESH, optional = false) + private Product entryProduct; + + /** + * Single product price (being copied here from GenericProduct) + */ + @Basic (optional = false) + @Column (name = "entry_product_price", nullable = false) + private Float entryProductPrice; + + /** + * Product quantity + */ + @Basic (optional = false) + @Column (name = "entry_product_quantity", nullable = false) + private Long entryProductQuantity; + + /** + * Connected entryReceipt entry + */ + @JoinColumn (name = "entry_receipt_id", referencedColumnName = "receipt_id", nullable = false, updatable = false, unique = true) + @OneToOne (targetEntity = FinancialReceipt.class, cascade = CascadeType.REFRESH, optional = false) + private BillableReceipt entryReceipt; + + /** + * Default constructor + */ + public ReceiptEntry () { + } + + /** + * 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 + */ + public ReceiptEntry (final Product entryProduct, final Float entryProductPrice, final Long entryProductQuantity, final BillableReceipt entryReceipt) { + // Call other constructor + this(); + + // Set all values + this.entryProduct = entryProduct; + this.entryProductPrice = entryProductPrice; + this.entryProductQuantity = entryProductQuantity; + this.entryReceipt = entryReceipt; + } + + @Override + public boolean equals (final Object object) { + if (this == object) { + return true; + } else if (null == object) { + return false; + } else if (this.getClass() != object.getClass()) { + return false; + } + + final BillableReceiptEntry receiptEntry = (BillableReceiptEntry) object; + + if (!Objects.equals(this.getEntryId(), receiptEntry.getEntryId())) { + return false; + } else if (!Objects.equals(this.getEntryProduct(), receiptEntry.getEntryProduct())) { + return false; + } else if (!Objects.equals(this.getEntryProductPrice(), receiptEntry.getEntryProductPrice())) { + return false; + } else if (!Objects.equals(this.getEntryProductQuantity(), receiptEntry.getEntryProductQuantity())) { + return false; + } else if (!Objects.equals(this.getEntryReceipt(), receiptEntry.getEntryReceipt())) { + return false; + } + + return true; + } + + @Override + @SuppressWarnings ("ReturnOfDateField") + public Date getEntryCreated () { + return this.entryCreated; + } + + @Override + @SuppressWarnings ("AssignmentToDateFieldFromParameter") + public void setEntryCreated (final Date entryCreated) { + this.entryCreated = entryCreated; + } + + @Override + public Long getEntryId () { + return this.entryId; + } + + @Override + public void setEntryId (final Long entryId) { + this.entryId = entryId; + } + + @Override + public Product getEntryProduct () { + return this.entryProduct; + } + + @Override + public void setEntryProduct (final Product entryProduct) { + this.entryProduct = entryProduct; + } + + @Override + public Float getEntryProductPrice () { + return this.entryProductPrice; + } + + @Override + public void setEntryProductPrice (final Float entryProductPrice) { + this.entryProductPrice = entryProductPrice; + } + + @Override + public Long getEntryProductQuantity () { + return this.entryProductQuantity; + } + + @Override + public void setEntryProductQuantity (final Long entryProductQuantity) { + this.entryProductQuantity = entryProductQuantity; + } + + @Override + public BillableReceipt getEntryReceipt () { + return this.entryReceipt; + } + + @Override + public void setEntryReceipt (final BillableReceipt entryReceipt) { + this.entryReceipt = entryReceipt; + } + + @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()); + + return hash; + } + +}