SupplierValueOverrides.java
package com.tradecloud.domain.supplier;
import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.common.Currency;
import com.tradecloud.domain.common.Incoterm;
import com.tradecloud.domain.document.invoice.UnitPricePerItem;
import com.tradecloud.domain.model.payment.ActualPaymentBasis;
import com.tradecloud.domain.model.payment.EstimatedPaymentBasis;
import com.tradecloud.domain.model.payment.PaymentMethod;
import com.tradecloud.domain.model.payment.PaymentTerm;
import com.tradecloud.domain.party.Bank;
import com.tradecloud.domain.party.ServiceProvider;
import com.tradecloud.domain.party.base.Address;
import com.tradecloud.domain.party.base.Contact;
import com.tradecloud.domain.party.base.ValueOverrides;
import com.tradecloud.domain.place.NamedPlace;
import com.tradecloud.domain.treasury.TreasuryBank;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.ForeignKey;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.*;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
/**
* Used for holding any value overrides of the default supplier values.
* <p>
* We don't want to extend Abstract supplier here as Hibernate will then include it in the various
* search results.
*
* @author ronan
*/
@Entity
@Table(name = "suppliervalueoverrides")
// , uniqueConstraints = { @UniqueConstraint(columnNames = { "organisationalunitsupplier_id" }) })
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "SupplierValueOverrides")
public class SupplierValueOverrides extends PersistenceBase implements ValueOverrides {
@OneToOne
@NotNull
@XmlTransient
private OrganisationalUnitSupplier organisationalUnitSupplier;
@XmlAttribute
private Boolean active;
/**
* UID.
*/
private static final long serialVersionUID = 1L;
@OneToOne(cascade = CascadeType.ALL)
@XmlElement(name = "PhysicalAddress")
private Address physicalAddress;
@OneToOne(cascade = CascadeType.ALL)
@XmlElement(name = "PostalAddress")
private Address postalAddress;
@OneToMany(cascade = CascadeType.ALL)
@Fetch(value = FetchMode.SUBSELECT)
@XmlElementWrapper(name = "Contacts")
@XmlElement(name = "Contact")
private List<Contact> contacts;
@ManyToOne
@XmlElement(name = "PaymentTerm", required = true)
private PaymentTerm paymentTerm;
@ManyToOne
@XmlElement(name = "PaymentMethod", required = true)
private PaymentMethod paymentMethod;
@ManyToOne
@XmlElement(name = "EstimatedPaymentBasis", required = true)
private EstimatedPaymentBasis estimatedPaymentBasis;
@ManyToOne
@XmlElement(name = "ActualPaymentBasis", required = true)
private ActualPaymentBasis actualPaymentBasis;
@ManyToOne
@XmlElement(name = "Currency", required = true)
@ForeignKey(name = "fk_currency")
private Currency currency;
@ManyToOne
@XmlElement(name = "Incoterm", required = true)
private Incoterm incoterm;
@Enumerated(value = EnumType.STRING)
@XmlAttribute
private UnitPricePerItem unitPricePerItem;
/**
* The freight forwarder used by this supplier.
*/
@XmlElement(name = "FreightForwarder")
@ManyToOne
@ForeignKey(name = "fk_freightforwarder")
private ServiceProvider freightForwarder;
/**
* The agent who will be responsible for clearing this supplier's goods.
*/
@XmlElement(name = "ClearingAgent")
@ManyToOne
@ForeignKey(name = "fk_clearingagent")
private ServiceProvider clearingAgent;
/**
* The transporter who will transport this supplier's goods to the final destination.
*/
@XmlElement(name = "Transporter")
@ManyToOne
@ForeignKey(name = "fk_transporter")
private ServiceProvider transporter;
/**
* Indicates if the supplier supports part shipments.
*/
@XmlAttribute(required = true)
// @NotNull
private Boolean allowPartShipment;
/**
* Indicates if the supplier supports trans shipments.
*/
@XmlAttribute(required = true)
// @NotNull
private Boolean allowTransShipment;
/**
* Indicates that a LC can be drawn for X% more than the face value of the LC. Should not be less than 0 and more than 10.
*/
@XmlAttribute
private BigDecimal lcToleranceAbove;
/**
* Indicates that a LC can be drawn for X% less than the face value of the LC. Should not be less than 0 or more than 10.
*/
@XmlAttribute
private BigDecimal lcToleranceBelow;
@XmlAttribute
private Integer presentationDays;
/**
* ERPTA-70 make this an input field.
*/
@XmlElement(name = "PlaceOfExpiry")
private String placeOfExpiry;
@ManyToOne
@XmlElement(name = "Bank")
private Bank advisingBank;
@XmlAttribute
private String salesTaxRegistrationNumber;
@XmlAttribute
private String vatRegistrationNumber;
@XmlAttribute
private String companyRegistrationNumber;
@XmlAttribute
private String warehouseCode;
@ManyToOne
@XmlElement(name = "NominatedBank")
@JoinColumn(name = "nominatedBank_code")
private TreasuryBank nominatedBank;
@ManyToOne
private NamedPlace namedPlace;
@XmlAttribute
private boolean template;
/**
* Constructor.
*/
public SupplierValueOverrides() {
super();
}
public SupplierValueOverrides(OrganisationalUnitSupplier organisationalUnitSupplier) {
super();
this.organisationalUnitSupplier = organisationalUnitSupplier;
}
public PaymentTerm getPaymentTerm() {
return paymentTerm;
}
public void setPaymentTerm(PaymentTerm paymentTerm) {
this.paymentTerm = paymentTerm;
}
public PaymentMethod getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(PaymentMethod paymentMethod) {
this.paymentMethod = paymentMethod;
}
public EstimatedPaymentBasis getEstimatedPaymentBasis() {
return estimatedPaymentBasis;
}
public void setEstimatedPaymentBasis(EstimatedPaymentBasis estimatedPaymentBasis) {
this.estimatedPaymentBasis = estimatedPaymentBasis;
}
public ActualPaymentBasis getActualPaymentBasis() {
return actualPaymentBasis;
}
public void setActualPaymentBasis(ActualPaymentBasis actualPaymentBasis) {
this.actualPaymentBasis = actualPaymentBasis;
}
public Currency getCurrency() {
return currency;
}
public void setCurrency(Currency currency) {
this.currency = currency;
}
public Incoterm getIncoterm() {
return incoterm;
}
public void setIncoterm(Incoterm incoterm) {
this.incoterm = incoterm;
}
public UnitPricePerItem getUnitPricePerItem() {
return unitPricePerItem;
}
public void setUnitPricePerItem(UnitPricePerItem unitPricePerItem) {
this.unitPricePerItem = unitPricePerItem;
}
public ServiceProvider getFreightForwarder() {
return freightForwarder;
}
public void setFreightForwarder(ServiceProvider freightForwarder) {
this.freightForwarder = freightForwarder;
}
public ServiceProvider getClearingAgent() {
return clearingAgent;
}
public void setClearingAgent(ServiceProvider clearingAgent) {
this.clearingAgent = clearingAgent;
}
public ServiceProvider getTransporter() {
return transporter;
}
public void setTransporter(ServiceProvider transporter) {
this.transporter = transporter;
}
public Boolean getAllowPartShipment() {
return allowPartShipment;
}
public void setAllowPartShipment(Boolean allowPartShipment) {
this.allowPartShipment = allowPartShipment;
}
public Boolean getAllowTransShipment() {
return allowTransShipment;
}
public void setAllowTransShipment(Boolean allowTransShipment) {
this.allowTransShipment = allowTransShipment;
}
public BigDecimal getLcToleranceAbove() {
return lcToleranceAbove;
}
public void setLcToleranceAbove(BigDecimal lcToleranceAbove) {
this.lcToleranceAbove = lcToleranceAbove;
}
public BigDecimal getLcToleranceBelow() {
return lcToleranceBelow;
}
public void setLcToleranceBelow(BigDecimal lcToleranceBelow) {
this.lcToleranceBelow = lcToleranceBelow;
}
public Integer getPresentationDays() {
return presentationDays;
}
public void setPresentationDays(Integer presentationDays) {
this.presentationDays = presentationDays;
}
public String getPlaceOfExpiry() {
return placeOfExpiry;
}
public void setPlaceOfExpiry(String placeOfExpiry) {
this.placeOfExpiry = placeOfExpiry;
}
public Bank getAdvisingBank() {
return advisingBank;
}
public void setAdvisingBank(Bank advisingBank) {
this.advisingBank = advisingBank;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
public Address getPhysicalAddress() {
return physicalAddress;
}
public void setPhysicalAddress(Address physicalAddress) {
this.physicalAddress = physicalAddress;
}
public Address getPostalAddress() {
return postalAddress;
}
public void setPostalAddress(Address postalAddress) {
this.postalAddress = postalAddress;
}
public List<Contact> getContacts() {
return contacts;
}
public void setContacts(List<Contact> contacts) {
this.contacts = contacts;
}
public String getSalesTaxRegistrationNumber() {
return salesTaxRegistrationNumber;
}
public void setSalesTaxRegistrationNumber(String salesTaxRegistrationNumber) {
this.salesTaxRegistrationNumber = salesTaxRegistrationNumber;
}
public String getVatRegistrationNumber() {
return vatRegistrationNumber;
}
public void setVatRegistrationNumber(String vatRegistrationNumber) {
this.vatRegistrationNumber = vatRegistrationNumber;
}
public String getCompanyRegistrationNumber() {
return companyRegistrationNumber;
}
public void setCompanyRegistrationNumber(String companyRegistrationNumber) {
this.companyRegistrationNumber = companyRegistrationNumber;
}
public String getWarehouseCode() {
return warehouseCode;
}
public void setWarehouseCode(String warehouseCode) {
this.warehouseCode = warehouseCode;
}
public OrganisationalUnitSupplier getOrganisationalUnitSupplier() {
return organisationalUnitSupplier;
}
public void setOrganisationalUnitSupplier(OrganisationalUnitSupplier organisationalUnitSupplier) {
this.organisationalUnitSupplier = organisationalUnitSupplier;
}
public TreasuryBank getNominatedBank() {
return nominatedBank;
}
public void setNominatedBank(TreasuryBank nominatedBank) {
this.nominatedBank = nominatedBank;
}
public NamedPlace getNamedPlace() {
return namedPlace;
}
public void setNamedPlace(NamedPlace namedPlace) {
this.namedPlace = namedPlace;
}
public boolean isTemplate() {
return template;
}
public void setTemplate(boolean template) {
this.template = template;
}
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), organisationalUnitSupplier, active, physicalAddress, postalAddress, contacts,
paymentTerm, paymentMethod, estimatedPaymentBasis, actualPaymentBasis, currency, incoterm, unitPricePerItem,
freightForwarder, clearingAgent, transporter, allowPartShipment, allowTransShipment, lcToleranceAbove,
lcToleranceBelow, presentationDays, placeOfExpiry, advisingBank, salesTaxRegistrationNumber,
vatRegistrationNumber, companyRegistrationNumber, warehouseCode, nominatedBank);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
SupplierValueOverrides that = (SupplierValueOverrides) o;
return Objects.equals(organisationalUnitSupplier, that.organisationalUnitSupplier) &&
Objects.equals(active, that.active) &&
Objects.equals(physicalAddress, that.physicalAddress) &&
Objects.equals(postalAddress, that.postalAddress) &&
Objects.equals(contacts, that.contacts) &&
Objects.equals(paymentTerm, that.paymentTerm) &&
Objects.equals(paymentMethod, that.paymentMethod) &&
Objects.equals(estimatedPaymentBasis, that.estimatedPaymentBasis) &&
Objects.equals(actualPaymentBasis, that.actualPaymentBasis) &&
Objects.equals(currency, that.currency) &&
Objects.equals(incoterm, that.incoterm) &&
unitPricePerItem == that.unitPricePerItem &&
Objects.equals(freightForwarder, that.freightForwarder) &&
Objects.equals(clearingAgent, that.clearingAgent) &&
Objects.equals(transporter, that.transporter) &&
Objects.equals(allowPartShipment, that.allowPartShipment) &&
Objects.equals(allowTransShipment, that.allowTransShipment) &&
Objects.equals(lcToleranceAbove, that.lcToleranceAbove) &&
Objects.equals(lcToleranceBelow, that.lcToleranceBelow) &&
Objects.equals(presentationDays, that.presentationDays) &&
Objects.equals(placeOfExpiry, that.placeOfExpiry) &&
Objects.equals(advisingBank, that.advisingBank) &&
Objects.equals(salesTaxRegistrationNumber, that.salesTaxRegistrationNumber) &&
Objects.equals(vatRegistrationNumber, that.vatRegistrationNumber) &&
Objects.equals(companyRegistrationNumber, that.companyRegistrationNumber) &&
Objects.equals(warehouseCode, that.warehouseCode) &&
Objects.equals(nominatedBank, that.nominatedBank) &&
Objects.equals(namedPlace, that.namedPlace) &&
Objects.equals(template, that.template);
}
public Boolean getActive() {
return active;
}
public void setActive(Boolean active) {
this.active = active;
}
}