package org.mxchange.jfinancials.model.receipt;
import java.util.Calendar;
+import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@OneToOne (targetEntity = LoginUser.class, cascade = CascadeType.REFRESH, optional = false)
private User receiptUser;
+ /**
+ * Default constructor
+ */
+ public Receipt () {
+ }
+
+ /**
+ * Constructor with payment type, seller and user
+ * <p>
+ * @param receiptPaymentType Payment type
+ * @param receiptSeller Seller instance
+ * @param receiptUser User instance
+ */
+ public Receipt (final PaymentType receiptPaymentType, final BusinessContact receiptSeller, final User receiptUser) {
+ // Call other constructor first
+ this();
+
+ // Set all
+ this.receiptPaymentType = receiptPaymentType;
+ this.receiptSeller = receiptSeller;
+ this.receiptUser = receiptUser;
+ }
+
+ @Override
+ public boolean equals (final Object object) {
+ if (this == object) {
+ return true;
+ }
+ if (null == object) {
+ return false;
+ } else if (this.getClass() != object.getClass()) {
+ return false;
+ }
+
+ final Billable receipt = (Billable) object;
+
+ if (!Objects.equals(this.getReceiptId(), receipt.getReceiptId())) {
+ return false;
+ } else if (this.getReceiptPaymentType() != receipt.getReceiptPaymentType()) {
+ return false;
+ } else if (!Objects.equals(this.getReceiptSeller(), receipt.getReceiptSeller())) {
+ return false;
+ } else if (!Objects.equals(this.getReceiptUser(), receipt.getReceiptUser())) {
+ return false;
+ }
+
+ return true;
+ }
+
@Override
@SuppressWarnings ("ReturnOfDateField")
public Calendar getReceiptCreated () {
this.receiptUser = receiptUser;
}
+ @Override
+ public int hashCode () {
+ int hash = 5;
+
+ hash = 89 * hash + Objects.hashCode(this.getReceiptId());
+ hash = 89 * hash + Objects.hashCode(this.getReceiptPaymentType());
+ hash = 89 * hash + Objects.hashCode(this.getReceiptSeller());
+ hash = 89 * hash + Objects.hashCode(this.getReceiptUser());
+
+ return hash;
+ }
+
}
package org.mxchange.jfinancials.model.receipt.entry;
import java.util.Calendar;
+import java.util.Objects;
+import java.util.logging.Logger;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@SuppressWarnings ("PersistenceUnitPresent")
public class ReceiptEntry implements BillableReceiptEntry {
+ private static final Logger LOG = Logger.getLogger(ReceiptEntry.class.getName());
+
/**
* Serial number
*/
@OneToOne (targetEntity = Receipt.class, cascade = CascadeType.REFRESH, optional = false)
private Billable entryReceipt;
+ /**
+ * Default constructor
+ */
+ public ReceiptEntry () {
+ }
+
+ /**
+ * Constructor with product, price, quantity and receipt instance
+ * <p>
+ * @param entryProduct Product instance
+ * @param entryProductPrice Product price (copied)
+ * @param entryProductQuantity Product quantity
+ * @param entryReceipt Receipt instance
+ */
+ public ReceiptEntry (final Product entryProduct, final Float entryProductPrice, final Long entryProductQuantity, final Billable entryReceipt) {
+ 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 Calendar getEntryCreated () {
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;
+ }
+
}