ExportParty.java

package com.tradecloud.domain.export;

import com.tradecloud.domain.common.Currency;
import com.tradecloud.domain.common.Incoterm;
import com.tradecloud.domain.configuration.PriceCode;
import com.tradecloud.domain.export.utils.UCRCodeOptions;
import com.tradecloud.domain.model.payment.PaymentMethod;
import com.tradecloud.domain.model.payment.PaymentTerm;
import com.tradecloud.domain.party.base.Address;
import com.tradecloud.domain.party.base.Company;
import com.tradecloud.domain.party.base.Contact;
import com.tradecloud.domain.place.*;
import com.tradecloud.domain.supplier.SupplierCommon;
import org.apache.log4j.Logger;
import org.hibernate.annotations.ForeignKey;

import javax.persistence.*;
import javax.xml.bind.annotation.*;
import java.util.List;

/**
 * ExportParty.
 */
@Entity
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@NamedQueries({
        @NamedQuery(name = "findByExternalReference",
                query = "from ExportParty e where e.externalReference=:externalReference")})

@XmlRootElement(name = "ExportParty")
@Table(name = "exportparty")
public class ExportParty extends Company implements SupplierCommon {

    private static final long serialVersionUID = 1L;
    private static transient Logger log = Logger.getLogger(ExportParty.class);

    @ManyToOne
    @XmlElement(name = "PaymentTerm", required = false)
    private PaymentTerm paymentTerm;

    @ManyToOne
    @XmlElement(name = "PaymentMethod", required = false)
    private PaymentMethod paymentMethod;

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @XmlElement(name = "DeliveryAddress")
    private Address deliveryAddress;

    @ManyToOne
    @XmlElement(name = "PreferredIncoterm")
    private Incoterm preferredIncoterm;

    @XmlAttribute
    private String customsCode;

    @XmlAttribute
    private String ucrCustomerCode;

    @ManyToOne
    @XmlElement(name = "CustomerCategory")
    private CustomerCategory customerCategory;

    public String getUcrCustomerCode() {
        return ucrCustomerCode;
    }

    public void setUcrCustomerCode(String ucrCustomerCode) {
        this.ucrCustomerCode = ucrCustomerCode;
    }

    @XmlAttribute
    @Enumerated(EnumType.STRING)
    private UCRCodeOptions ucrCodeOption;

    @ManyToOne
    @ForeignKey(name = "exportparty_countryofdestination_fk")
    private Country countryOfDestination;

    @ManyToOne
    @ForeignKey(name = "exportparty_placeofloading_fk")
    @XmlElement(name = "PlaceOfLoading")
    private PlaceOfLoading placeOfLoading;

    @ManyToOne
    @ForeignKey(name = "exportparty_placeofdischarge_fk")
    @XmlElement(name = "PlaceOfDischarge")
    private PlaceOfDischarge placeOfDischarge;

    private String placeOfEntry;

    @ManyToOne
    @ForeignKey(name = "exportparty_currency_fk")
    @XmlElement(name = "Currency")
    private Currency currency;

    private byte[] image;

    @ManyToOne
    private NamedPlace placeOfIssue;

    @ManyToOne
    @ForeignKey(name = "exportparty_placeOfCustom_fk")
    @XmlElement(name = "PlaceOfCustom")
    private PlaceOfCustom placeOfCustom;

    @OneToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE}, fetch = FetchType.LAZY)
    private PriceCode priceCode;

    private boolean principleConsignee;

    private boolean exportInvoiceAddress;

    @OneToOne(fetch = FetchType.LAZY)
    private ExportParty principleExportParty;

    private boolean canGetDutyRefund;

    private String tpinNumber;
    private String idfNumber;
    @Enumerated(value = EnumType.STRING)
    private CommercialInvoiceTemplate commercialInvoiceTemplate;
    private String sarsRebateItemCode;
    private String defermentAccount;

    public ExportParty() {
        super();
    }

    public ExportParty(String name, String externalReference) {
        super(name);
        setExternalReference(externalReference);
    }

    public ExportParty(String name) {
        super(name);
    }

    public ExportParty(Address physicalAddress, Address postalAddress, List<Contact> contacts, String name, String externalReference,
                       String salesTaxRegistrationNumber, String vatRegistrationNumber, String companyRegistrationNumber, String
                               warehouseCode) {
        super(name);
    }

    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 Incoterm getPreferredIncoterm() {
        return preferredIncoterm;
    }

    public void setPreferredIncoterm(Incoterm preferredIncoterm) {
        this.preferredIncoterm = preferredIncoterm;
    }

    public Address getDeliveryAddress() {
        return deliveryAddress;
    }

    public void setDeliveryAddress(Address deliveryAddress) {
        this.deliveryAddress = deliveryAddress;
    }

    public boolean isExportInvoiceAddress() {
        return exportInvoiceAddress;
    }

    public void setExportInvoiceAddress(boolean exportInvoiceAddress) {
        this.exportInvoiceAddress = exportInvoiceAddress;
    }

    public String getCustomsCode() {
        return customsCode;
    }

    public void setCustomsCode(String customsCode) {
        this.customsCode = customsCode;
    }

    public Country getCountryOfDestination() {
        return countryOfDestination;
    }

    public void setCountryOfDestination(Country countryOfDestination) {
        this.countryOfDestination = countryOfDestination;
    }

    public PlaceOfLoading getPlaceOfLoading() {
        return placeOfLoading;
    }

    public void setPlaceOfLoading(PlaceOfLoading placeOfLoading) {
        this.placeOfLoading = placeOfLoading;
    }

    public PlaceOfDischarge getPlaceOfDischarge() {
        return placeOfDischarge;
    }

    public void setPlaceOfDischarge(PlaceOfDischarge placeOfDischarge) {
        this.placeOfDischarge = placeOfDischarge;
    }

    public String getPlaceOfEntry() {
        return placeOfEntry;
    }

    public void setPlaceOfEntry(String placeOfEntry) {
        this.placeOfEntry = placeOfEntry;
    }

    public Currency getCurrency() {
        return currency;
    }

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

    public byte[] getImage() {
        return image;
    }

    public void setImage(byte[] image) {
        this.image = image;
    }

    public NamedPlace getPlaceOfIssue() {
        return placeOfIssue;
    }

    public void setPlaceOfIssue(NamedPlace placeOfIssue) {
        this.placeOfIssue = placeOfIssue;
    }

    public PlaceOfCustom getPlaceOfCustom() {
        return placeOfCustom;
    }

    public void setPlaceOfCustom(PlaceOfCustom placeOfCustom) {
        this.placeOfCustom = placeOfCustom;
    }

    @Override
    public String getNameAndOrgNameAndExternalReference() {
        return getName() + " - " + getExternalReference();
    }

    @Override
    public String getNameAndOrgName() {
        return getName();
    }

    public PriceCode getPriceCode() {
        return priceCode;
    }

    public void setPriceCode(PriceCode priceCode) {
        this.priceCode = priceCode;
    }

    public CustomerCategory getCustomerCategory() {
        return customerCategory;
    }

    public void setCustomerCategory(CustomerCategory customerCategory) {
        this.customerCategory = customerCategory;
    }

    public UCRCodeOptions getUcrCodeOption() {
        return ucrCodeOption;
    }

    public void setUcrCodeOption(UCRCodeOptions ucrCodeOption) {
        this.ucrCodeOption = ucrCodeOption;
    }

    public boolean isPrincipleConsignee() {
        return principleConsignee;
    }

    public void setPrincipleConsignee(boolean principleConsignee) {
        this.principleConsignee = principleConsignee;
    }

    public ExportParty getPrincipleExportParty() {
        return principleExportParty;
    }

    public void setPrincipleExportParty(ExportParty principleExportParty) {
        this.principleExportParty = principleExportParty;
    }

    public boolean isCanGetDutyRefund() {
        return canGetDutyRefund;
    }

    public void setCanGetDutyRefund(boolean canGetDutyRefund) {
        this.canGetDutyRefund = canGetDutyRefund;
    }

    public String getTpinNumber() {
        return tpinNumber;
    }

    public void setTpinNumber(String tpinNumber) {
        this.tpinNumber = tpinNumber;
    }

    public String getIdfNumber() {
        return idfNumber;
    }

    public void setIdfNumber(String idfNumber) {
        this.idfNumber = idfNumber;
    }

    public CommercialInvoiceTemplate getCommercialInvoiceTemplate() {
        return commercialInvoiceTemplate;
    }

    public void setCommercialInvoiceTemplate(CommercialInvoiceTemplate commercialInvoiceTemplate) {
        this.commercialInvoiceTemplate = commercialInvoiceTemplate;
    }

    public String getSarsRebateItemCode() {
        return sarsRebateItemCode;
    }

    public void setSarsRebateItemCode(String sarsRebateItemCode) {
        this.sarsRebateItemCode = sarsRebateItemCode;
    }

    public String getDefermentAccount() {
        return defermentAccount;
    }

    public void setDefermentAccount(String defermentAccount) {
        this.defermentAccount = defermentAccount;
    }

}