Schedule4Part1.java
package com.tradecloud.domain.duties;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* Entity representing Schedule 2 Part 1 - Anti-Dumping.
*/
@Entity
@Table(name = "schedule4Part1")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "schedule4Part1")
public class Schedule4Part1 extends TypedDutySchedule implements Serializable, Cloneable {
private static final long serialVersionUID = 1L;
@Transient
public final int PART1_MAX_LENGTH = 3;
/**
* The method that will be used to calculate the "Other Duty" values.
*/
@Enumerated(value = EnumType.STRING)
@XmlAttribute
private DutyCalculationMethod calculationMethod;
@XmlAttribute
private String rebateCode;
@Enumerated(value = EnumType.STRING)
@XmlAttribute
private RebateOptions rebateOptions = RebateOptions.LESS;
@XmlAttribute
private boolean vatExemption;
public Schedule4Part1() {
super();
if (getDutyRate() == null) {
dutyRate = new TypedDutyRate();
dutyRate.setValue(BigDecimal.ZERO);
dutyRate.setPercentage(BigDecimal.valueOf(100));
dutyRate.setOtherDuty1(new OtherDuty());
dutyRate.setOtherDuty2(new OtherDuty());
dutyRate.setOtherDuty3(new OtherDuty());
}
dutyRate.setType(DutyType.ORDINARY);
dutyRate.setValue(BigDecimal.ZERO);
dutyRate.setPercentage(BigDecimal.valueOf(100));
}
public Schedule4Part1(Schedule4Part1 schedule4Part1) {
super(schedule4Part1);
calculationMethod = schedule4Part1.calculationMethod;
}
public DutyCalculationMethod getCalculationMethod() {
return calculationMethod;
}
public void setCalculationMethod(DutyCalculationMethod calculationMethod) {
this.calculationMethod = calculationMethod;
}
@Override
public Schedule4Part1 clone() {
Schedule4Part1 clone = new Schedule4Part1();
clone.setCalculationMethod(calculationMethod);
clone.setVatExemption(vatExemption);
clone.setTariffHeading(getTariffHeading() != null ? getTariffHeading().clone() : null);
clone.setValid(isValid());
clone.setDutyRate(dutyRate != null ? dutyRate.clone() : null);
return clone;
}
@Override
public String toString() {
return new ToStringBuilder(this).append("calculationMethod", calculationMethod).toString();
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (!(obj instanceof Schedule4Part1)) {
return false;
}
Schedule4Part1 other = (Schedule4Part1) obj;
return new EqualsBuilder().appendSuper(super.equals(obj)).append(calculationMethod, other.calculationMethod).isEquals();
}
@Override
public int hashCode() {
return new HashCodeBuilder().appendSuper(super.hashCode()).append(calculationMethod).toHashCode();
}
@Override
public String getCostlineCode() {
//don't match costlines
return null;
}
@Override
protected boolean getDoCheckProof() {
return false;
}
@Override
protected int getPart1MaxLength() {
return PART1_MAX_LENGTH;
}
@Override
protected boolean getDoCheckPercentage() {
return false;
}
@Override
protected boolean getDoCheckValue() {
return true;
}
public String getRebateCode() {
return rebateCode;
}
public void setRebateCode(String rebateCode) {
this.rebateCode = rebateCode;
}
public RebateOptions getRebateOptions() {
return rebateOptions;
}
public void setRebateOptions(RebateOptions rebateOptions) {
this.rebateOptions = rebateOptions;
}
public boolean isVatExemption() {
return vatExemption;
}
public void setVatExemption(boolean vatExemption) {
this.vatExemption = vatExemption;
}
@Override
public String getType() {
return "S4";
}
}