From a08b845c5896af449fabd9cf287eea846b5052ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 16 Jun 2018 15:16:16 +0200 Subject: [PATCH] Continued: - added transaction number to receipt as some receipts contain it - added coupon number to equals()/hashcode() method MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../model/receipt/BillableReceipt.java | 14 ++++++++++ .../model/receipt/FinancialReceipt.java | 27 ++++++++++++++++++- .../receipt_item/FinancialReceiptItem.java | 6 +++++ 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/org/mxchange/jfinancials/model/receipt/BillableReceipt.java b/src/org/mxchange/jfinancials/model/receipt/BillableReceipt.java index 7938dcb..06867ca 100644 --- a/src/org/mxchange/jfinancials/model/receipt/BillableReceipt.java +++ b/src/org/mxchange/jfinancials/model/receipt/BillableReceipt.java @@ -199,6 +199,20 @@ public interface BillableReceipt extends Comparable, Serializab */ void setReceiptSequenceNumber (final Long receiptSequenceNumber); + /** + * Getter for receipt transaction number + *

+ * @return Receipt transaction number + */ + Long getReceiptTransactionNumber (); + + /** + * Setter for receipt transaction number + *

+ * @param receiptTransactionNumber Receipt transaction number + */ + void setReceiptTransactionNumber (final Long receiptTransactionNumber); + @Override boolean equals (final Object object); diff --git a/src/org/mxchange/jfinancials/model/receipt/FinancialReceipt.java b/src/org/mxchange/jfinancials/model/receipt/FinancialReceipt.java index 818496f..8d5d545 100644 --- a/src/org/mxchange/jfinancials/model/receipt/FinancialReceipt.java +++ b/src/org/mxchange/jfinancials/model/receipt/FinancialReceipt.java @@ -53,7 +53,8 @@ import org.mxchange.jusercore.model.user.User; import org.mxchange.jusercore.model.user.Users; /** - * + * Receipt POJO + *

* @author Roland Häder */ @Entity (name = "receipts") @@ -152,6 +153,12 @@ public class FinancialReceipt implements BillableReceipt { @Column (name = "receipt_sequence_number") private Long receiptSequenceNumber; + /** + * Receipt transaction number + */ + @Column (name = "receipt_transaction_number") + private Long receiptTransactionNumber; + /** * Which user this receipt belongs to */ @@ -253,6 +260,8 @@ public class FinancialReceipt implements BillableReceipt { StringUtils.compare(this.getReceiptBarCodeNumber(), billableReceipt.getReceiptBarCodeNumber()), // ... sequence number SafeNumberUtils.compare(this.getReceiptSequenceNumber(), billableReceipt.getReceiptSequenceNumber()), + // ... transaction number + SafeNumberUtils.compare(this.getReceiptTransactionNumber(), billableReceipt.getReceiptTransactionNumber()), // ... payment type this.getReceiptPaymentType().compareTo(billableReceipt.getReceiptPaymentType()), // ... register number @@ -292,6 +301,10 @@ public class FinancialReceipt implements BillableReceipt { return false; } else if (!Objects.equals(this.getReceiptNumber(), receipt.getReceiptNumber())) { return false; + } else if (!Objects.equals(this.getReceiptSequenceNumber(), receipt.getReceiptSequenceNumber())) { + return false; + } else if (!Objects.equals(this.getReceiptTransactionNumber(), receipt.getReceiptTransactionNumber())) { + return false; } else if (this.getReceiptPaymentType() != receipt.getReceiptPaymentType()) { return false; } else if (!Objects.equals(this.getReceiptBranchOffice(), receipt.getReceiptBranchOffice())) { @@ -419,6 +432,16 @@ public class FinancialReceipt implements BillableReceipt { this.receiptSequenceNumber = receiptSequenceNumber; } + @Override + public Long getReceiptTransactionNumber () { + return this.receiptTransactionNumber; + } + + @Override + public void setReceiptTransactionNumber (final Long receiptTransactionNumber) { + this.receiptTransactionNumber = receiptTransactionNumber; + } + @Override public User getReceiptUser () { return this.receiptUser; @@ -435,6 +458,8 @@ public class FinancialReceipt implements BillableReceipt { hash = 89 * hash + Objects.hashCode(this.getReceiptId()); hash = 89 * hash + Objects.hashCode(this.getReceiptNumber()); + hash = 89 * hash + Objects.hashCode(this.getReceiptSequenceNumber()); + hash = 89 * hash + Objects.hashCode(this.getReceiptTransactionNumber()); hash = 89 * hash + Objects.hashCode(this.getReceiptPaymentType()); hash = 89 * hash + Objects.hashCode(this.getReceiptBranchOffice()); hash = 89 * hash + Objects.hashCode(this.getReceiptUser()); diff --git a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java index 0b5071a..b8c69a6 100644 --- a/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java +++ b/src/org/mxchange/jfinancials/model/receipt_item/FinancialReceiptItem.java @@ -256,12 +256,16 @@ public class FinancialReceiptItem implements BillableReceiptItem { if (!Objects.equals(this.getItemId(), receiptItem.getItemId())) { return false; + } else if (!Objects.equals(this.getItemNumber(), receiptItem.getItemNumber())) { + return false; } else if (!Objects.equals(this.getItemProduct(), receiptItem.getItemProduct())) { return false; } else if (!Objects.equals(this.getItemProductQuantity(), receiptItem.getItemProductQuantity())) { return false; } else if (!Objects.equals(this.getItemReceipt(), receiptItem.getItemReceipt())) { return false; + } else if (!Objects.equals(this.getItemCouponNumber(), receiptItem.getItemCouponNumber())) { + return false; } return true; @@ -424,9 +428,11 @@ public class FinancialReceiptItem implements BillableReceiptItem { int hash = 5; hash = 53 * hash + Objects.hashCode(this.getItemId()); + hash = 53 * hash + Objects.hashCode(this.getItemNumber()); hash = 53 * hash + Objects.hashCode(this.getItemProduct()); hash = 53 * hash + Objects.hashCode(this.getItemProductQuantity()); hash = 53 * hash + Objects.hashCode(this.getItemReceipt()); + hash = 53 * hash + Objects.hashCode(this.getItemCouponNumber()); return hash; } -- 2.39.5