InvoiceDTO.java

package com.tradecloud.dto.api.invoice;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.tradecloud.dto.api.CommonAPIMessage;
import com.tradecloud.dto.api.EventDTO;
import io.swagger.annotations.ApiModel;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Objects;

@ApiModel(description = CommonAPIMessage.IGNORE_READ_ONLY_FIELDS)
public abstract class InvoiceDTO {
    @JsonProperty(access = JsonProperty.Access.AUTO)
    @JsonPropertyDescription(value = "system generate id, send back on update")
    private Long id;
    @JsonPropertyDescription(value = "must be unique within the shipment, multiple reference can be passed as comma seprated by a delimeter")
    private String reference;

    private String shipmentReference;

    @JsonProperty(required = true)
    @JsonPropertyDescription(value = "The currency of the invoice")
    private String currency;

    @JsonPropertyDescription(value = "multiple number can be passed as comma separated by a delimeter")
    private String invoiceNumber;
    @JsonProperty(required = true)
    private String state;

    private String stateName;

    private BigDecimal grossValueVariance = BigDecimal.ZERO;

    @JsonPropertyDescription(value = "The date on the document")
    @JsonProperty(required = true)
    private Date documentDate;

    @JsonProperty(required = true)
    @JsonPropertyDescription(value = "The date the actual document was received")
    private Date receivedDate;
    @JsonProperty(required = true)
    @JsonPropertyDescription(value = "The total value of goods being shipped")
    private BigDecimal grossValue;

    @JsonProperty(access = JsonProperty.Access.AUTO)
    @JsonPropertyDescription(value = "Indicates if the invoice is balanced")
    private boolean balanced;

    @JsonProperty(access = JsonProperty.Access.AUTO)
    @JsonPropertyDescription(value = "Indicates the gross field is out by. If the value is zero, the field is balanced.")
    private BigDecimal grossValueBalance;

    @JsonProperty(access = JsonProperty.Access.AUTO)
    List<EventDTO> eventDTOList;

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getShipmentReference() {
        return shipmentReference;
    }

    public void setShipmentReference(String shipmentReference) {
        this.shipmentReference = shipmentReference;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getCurrency() {
        return currency;
    }

    public void setCurrency(String currency) {
        this.currency = currency;
    }

    public String getInvoiceNumber() {
        return invoiceNumber;
    }

    public void setInvoiceNumber(String invoiceNumber) {
        this.invoiceNumber = invoiceNumber;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public List<EventDTO> getEventDTOList() {
        return eventDTOList;
    }

    public void setEventDTOList(List<EventDTO> eventDTOList) {
        this.eventDTOList = eventDTOList;
    }

    public String getStateName() {
        return stateName;
    }

    public void setStateName(String stateName) {
        this.stateName = stateName;
    }

    public BigDecimal getGrossValueVariance() {
        return grossValueVariance;
    }

    public void setGrossValueVariance(BigDecimal grossValueVariance) {
        this.grossValueVariance = grossValueVariance;
    }

    public Date getDocumentDate() {
        return documentDate;
    }

    public void setDocumentDate(Date documentDate) {
        this.documentDate = documentDate;
    }

    public Date getReceivedDate() {
        return receivedDate;
    }

    public void setReceivedDate(Date receivedDate) {
        this.receivedDate = receivedDate;
    }

    public BigDecimal getGrossValue() {
        return grossValue;
    }

    public void setGrossValue(BigDecimal grossValue) {
        this.grossValue = grossValue;
    }

    public boolean isBalanced() {
        return balanced;
    }

    public void setBalanced(boolean balanced) {
        this.balanced = balanced;
    }

    public BigDecimal getGrossValueBalance() {
        return grossValueBalance;
    }

    public void setGrossValueBalance(BigDecimal grossValueBalance) {
        this.grossValueBalance = grossValueBalance;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        InvoiceDTO that = (InvoiceDTO) o;
        return Objects.equals(reference, that.reference) &&
                Objects.equals(shipmentReference, that.shipmentReference);
    }

    @Override
    public int hashCode() {
        return Objects.hash(reference, shipmentReference);
    }

    public abstract CostingDTO getInvoiceCostingDTO();
}