FYPBackend / src / main / java / com / cardpaymentsystem / cardplatform / models / ReceiptEntity.java
ReceiptEntity.java
Raw
package com.cardpaymentsystem.cardplatform.models;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Date;
import java.util.Objects;

//essentially operates as a cart and purchase history provider
@Entity
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "receipt", schema = "cardplatform", catalog = "")
public class ReceiptEntity {

    private int receiptId;
    private BigDecimal totalcost;
    private int cardId;
    private boolean checkedOut;
    private Date transactionDate;
    private String failedReason;


    @Id
    @Column(name = "receipt_id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getReceiptId() {
        return receiptId;
    }

    public void setReceiptId(int receiptId) {
        this.receiptId = receiptId;
    }

    @Basic
    @Column(name = "totalcost")
    public BigDecimal getTotalcost() {
        return totalcost;
    }

    public void setTotalcost(BigDecimal totalcost) {
        this.totalcost = totalcost;
    }

    @Basic
    @Column(name = "failed_reason")
    public String getFailedReason(){ return failedReason;}

    public void setFailedReason(String failedReason){ this.failedReason = failedReason; }


    @Basic
    @Column(name = "transaction_date")
    public Date getTransactionDate() {
        return transactionDate;
    }

    public void setTransactionDate(Date transactionDate) {
        this.transactionDate = transactionDate;
    }

    @Basic
    @Column(name = "card_id")
    public int getCardId() {
        return cardId;
    }

    public void setCardId(int cardId) {
        this.cardId = cardId;
    }

    @Basic
    @Column(name = "checked_out")
    public boolean getCheckedOut() {
        return checkedOut;
    }

    public void setCheckedOut(boolean checkedOut) {
        this.checkedOut = checkedOut;
    }


    @Override//Might need to update equals
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ReceiptEntity that = (ReceiptEntity) o;
        return receiptId == that.receiptId && totalcost == that.totalcost;
    }

    @Override
    public int hashCode() {
        return Objects.hash(receiptId, totalcost);
    }
}