CostingClientConfig.java
package com.tradecloud.domain.configuration;
import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.CustomVat;
import com.tradecloud.domain.Vat;
import com.tradecloud.domain.agent.AgentCommissionBasedOnType;
import com.tradecloud.domain.container.ContainerTypeMetaData;
import com.tradecloud.domain.costing.*;
import com.tradecloud.domain.costing.actual.ActualCostAllocationMethod;
import com.tradecloud.domain.model.RateFeedDateCustomsCalc;
import com.tradecloud.domain.model.RateOfExchangeType;
import com.tradecloud.domain.model.organisationalunit.OrganisationalUnit;
import com.tradecloud.domain.model.payment.PaymentBasis;
import com.tradecloud.domain.settlement.SettlementDateCalculation;
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.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
/**
* A holder for costing client configuration values.
*/
@Entity
@Table(name = "costingclientconfig")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "CostingClientConfig")
public class CostingClientConfig extends PersistenceBase {
private static final long serialVersionUID = 1L;
/**
* For finalised consignments, not signed-off, refresh the exchange rates used for conversion of transaction currency to costing currency.
* This needs to simulate the action of unfinalise, refresh and finalise.
*/
@XmlAttribute
@NotNull
private int numberOfDaysForCostingRateRefresh;
@XmlAttribute
@NotNull
private int actualCostingDueDateDays;
/**
* Default is {@link CostAllocationMethod#VALUE}.
*/
@XmlAttribute
@Enumerated(value = EnumType.STRING)
@NotNull
private CostAllocationMethod clcVariableCostDistributionMethod;
@OneToMany
@JoinTable(name = "costingclientconfig_costgrouptolerances",
joinColumns = @JoinColumn(name = "config_id"),
inverseJoinColumns = @JoinColumn(name = "costgrouptolerance_id"))
@ForeignKey(name = "fk_costingclientconfig", inverseName = "fk_costgrouptolerance")
@XmlElementWrapper(name = "CostGroupTolerances")
@XmlElement(name = "CostGroupTolerance")
private Set<CostGroupTolerance> costGroupTolerances;
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "costingclientconfig_costlinetolerances",
joinColumns = @JoinColumn(name = "config_id"),
inverseJoinColumns = @JoinColumn(name = "costlinetolerance_id"))
@ForeignKey(name = "fk_costingclientconfig", inverseName = "fk_costlinetolerance")
@XmlElementWrapper(name = "CostLineTolerances")
@XmlElement(name = "CostLineTolerance")
private Set<CostLineTolerance> costLineTolerances;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@XmlElementWrapper(name = "alcCostGroupsDefaultOverridesFromElcs")
@XmlElement(name = "alcCostGroupsDefaultOverridesFromElc")
private Set<AlcDefaultOverridesFromCLCEntry> alcDefaultOverridesFromCLCEntries;
/**
* If selected, a value can only be captured in the cost sheet if a foreign agent is selected on the order.
*/
@XmlAttribute
@NotNull
private boolean foreignAgents;
/**
* If selected, a value can only be captured in the cost sheet if a warehousing agent is selected on the order.
*/
@XmlAttribute
@NotNull
private boolean warehousingAgents;
/**
* If selected, a value can only be captured in the cost sheet if a merchandising agent is selected on the order.
*/
@XmlAttribute
@NotNull
private boolean merchandisingAgents;
/**
* If selected, a value can only be captured in the cost sheet if a sourcing agent is selected on the order.
*/
@XmlAttribute
@NotNull
private boolean sourcingAgents;
/**
* {@value ValidationAction#WARNING} allows the user to continue, {@value ValidationAction#REJECT} means the user cannot continue.
* Defaults to {@link ValidationAction#WARNING}.
*/
@XmlAttribute
@Enumerated(value = EnumType.STRING)
@NotNull
private ValidationAction toleranceValidationAction;
/**
* Defaults to true.
*/
@XmlAttribute
@NotNull
private boolean forceCommentOnWarningAcceptance;
/**
* If selected item volumes are summed for LCL container type and value used in rate table lookups.
* Defaults to true.
*/
@XmlAttribute
@NotNull
private boolean useLCLContainerVolumes;
/**
* If the field is enabled, the View CLC Costing on the shipment should be visible.
* Defaults to true.
*/
@XmlAttribute
@NotNull
private boolean validateIndirectCostLines;
/**
* If selected indirect cost line validated on saving Invoice against estimate cost.
* Defaults to true.
*/
@XmlAttribute
@NotNull
private boolean enableShipmentCLC;
/**
* Default is {@link ActualCostAllocationMethod#VALUE}.
*/
@XmlAttribute
@Enumerated(value = EnumType.STRING)
@NotNull
private ActualCostAllocationMethod alcVariableCostDistributionMethod;
/**
* CLC starting point for settlement data calculation.
* Defaults to EST_DEP_DATE.
*/
@XmlAttribute
@OneToOne
@ForeignKey(name = "fk_clcpaymentbasis")
@JoinColumn(name = "clcpaymentbasis_code")
@NotNull
private PaymentBasis clcPaymentBasis;
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "costingclientconfig_settlementdatecalculations",
joinColumns = @JoinColumn(name = "config_id"),
inverseJoinColumns = @JoinColumn(name = "settlementdatecalculation_id", unique = true))
@ForeignKey(name = "fk_costingclientconfig", inverseName = "fk_settlementdatecalculation")
@OrderBy("costingType desc, costGroup")
@XmlElementWrapper(name = "SettlementDateCalculations")
@XmlElement(name = "SettlementDateCalculation")
private Set<SettlementDateCalculation> settlementDateCalculations;
/**
* ALC starting point for settlement data calculation.
* Defaults to BILL_OF_LADING_DATE.
*/
@XmlAttribute
@OneToOne
@ForeignKey(name = "fk_alcpaymentbasis")
@JoinColumn(name = "alcpaymentbasis_code")
@NotNull
private PaymentBasis alcPaymentBasis;
@OneToMany
@JoinTable(name = "costingclientconfig_containertypemetadata",
joinColumns = @JoinColumn(name = "config_id"),
inverseJoinColumns = @JoinColumn(name = "containertypemetadata_id", unique = true))
@ForeignKey(name = "fk_costingclientconfig", inverseName = "fk_containertypemetadata")
@XmlElementWrapper(name = "ContainerTypeMetaDataList")
@XmlElement(name = "ContainerTypeMetaData")
private Set<ContainerTypeMetaData> containerTypeMetaData;
/**
* Determines how the indirect cost distribution is done at CLC level.
*/
@XmlAttribute
@Enumerated(value = EnumType.STRING)
@NotNull
private ClcIndirectCostDistributionType clcIndirectCostDistribution;
/**
* Determines how the indirect cost distribution is done at ALC level.
*/
@XmlAttribute
@Enumerated(value = EnumType.STRING)
@NotNull
private AlcIndirectCostDistributionType alcIndirectCostDistribution;
/**
* Type of rate of exchange that will be used for VAT and customs duty calculations at the moment. Applicable to both ALC and CLC costs.
* Can be either forward or spot.
*/
@XmlAttribute
@Enumerated(value = EnumType.STRING)
private RateOfExchangeType rateOfExchangeType;
@XmlAttribute
@Enumerated(value = EnumType.STRING)
private RateOfExchangeType elcRateOfExchangeType;
@XmlAttribute
@Enumerated(value = EnumType.STRING)
private RateOfExchangeType shipmentCLCRateOfExchangeType;
@XmlAttribute
@Enumerated(value = EnumType.STRING)
private RateFeedDateCustomsCalc rateFeedDateCustomsCalc;
@XmlAttribute
@Enumerated(value = EnumType.STRING)
private RateFeedDateCustomsCalc elcRateFeedDateCustomsCalc;
/**
* indicates if we default invoice costing to actual or do the actual costing.
*/
@XmlAttribute
@Enumerated(value = EnumType.STRING)
private ALCRateDefault alcRateDefault;
@Enumerated(value = EnumType.STRING)
private ALCRateDefault alcInternalProvRate;
@Enumerated(value = EnumType.STRING)
private ALCRateDefault alcSupplyAdditionalRate;
@Enumerated(value = EnumType.STRING)
private ALCRateDefault alcCustomsRate;
@Enumerated(value = EnumType.STRING)
@Column
@XmlAttribute
private AgentCommissionBasedOnType agentCostApplicationBasis;
private boolean inclSupplyHangerCostLine;
private boolean showSABSWarning;
private int facilityFeePaymentTerm;
private boolean displayVat;
private boolean displayTradeFinance;
private boolean serviceFeeInclusiveInterest;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinTable(name = "costingclientconfig_vat",
joinColumns = @JoinColumn(name = "config_id"),
inverseJoinColumns = @JoinColumn(name = "vat_id", unique = true))
@ForeignKey(name = "fk_costingclientconfig", inverseName = "fk_vat")
private List<Vat> vatList;
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinTable(name = "costingclientconfig_customvat",
joinColumns = @JoinColumn(name = "config_id"),
inverseJoinColumns = @JoinColumn(name = "customvat_id", unique = true))
private List<CustomVat> customVatList;
@Enumerated(value = EnumType.STRING)
@XmlAttribute
@NotNull
private ErrorWarningOption minimumCostLineValidation;
private boolean elcGlcVariance;
private BigDecimal elcGlcLowerTolerance;
private BigDecimal elcGlcUpperTolerance;
private transient boolean buyingCommission;
@Enumerated(value = EnumType.STRING)
@XmlAttribute
@NotNull
private ALCRateofExchangeForCustomsCalculation alcRoeForCustomCalc;
@Enumerated(value = EnumType.STRING)
@XmlAttribute
@NotNull
private ALCRateDefault alcAgentRateDefault;
private boolean ignoreToleranceCheck;
@XmlTransient
@ManyToMany(fetch = FetchType.EAGER)
@JoinTable(name = "costingclientconfig_organisationalUnits", joinColumns = {@JoinColumn(name = "costingclientconfig_id", unique = false)},
inverseJoinColumns = {@JoinColumn(name = "organisationalUnit_id", unique = false)})
private Set<OrganisationalUnit> organisationalUnits = new HashSet<>();
@OneToMany(cascade = CascadeType.ALL, orphanRemoval = true)
@JoinTable(name = "costingclientconfig_costingcomparisonsetup",
joinColumns = @JoinColumn(name = "config_id"),
inverseJoinColumns = @JoinColumn(name = "costingcomparisonsetup_id", unique = true))
private List<CostingComparisonSetup> costingComparisonSetups = new LinkedList<>();
private boolean detailedCostComparison;
@Enumerated(value = EnumType.STRING)
private ALCRateDefault alcFinanceRate;
public int getNumberOfDaysForCostingRateRefresh() {
return numberOfDaysForCostingRateRefresh;
}
public void setNumberOfDaysForCostingRateRefresh(int numberOfDaysForCostingRateRefresh) {
this.numberOfDaysForCostingRateRefresh = numberOfDaysForCostingRateRefresh;
}
public CostAllocationMethod getClcVariableCostDistributionMethod() {
return clcVariableCostDistributionMethod;
}
public void setClcVariableCostDistributionMethod(CostAllocationMethod clcVariableCostDistributionMethod) {
this.clcVariableCostDistributionMethod = clcVariableCostDistributionMethod;
}
public Set<CostGroupTolerance> getCostGroupTolerances() {
return costGroupTolerances;
}
public void setCostGroupTolerances(Set<CostGroupTolerance> costGroupTolerances) {
this.costGroupTolerances = costGroupTolerances;
}
public Set<CostLineTolerance> getCostLineTolerances() {
return costLineTolerances;
}
public void setCostLineTolerances(Set<CostLineTolerance> costLineTolerances) {
this.costLineTolerances = costLineTolerances;
}
public Set<AlcDefaultOverridesFromCLCEntry> getAlcDefaultOverridesFromCLCEntries() {
return alcDefaultOverridesFromCLCEntries;
}
public void setAlcDefaultOverridesFromCLCEntries(Set<AlcDefaultOverridesFromCLCEntry> alcDefaultOverridesFromCLCEntries) {
this.alcDefaultOverridesFromCLCEntries = alcDefaultOverridesFromCLCEntries;
}
public boolean isForeignAgents() {
return foreignAgents;
}
public void setForeignAgents(boolean foreignAgents) {
this.foreignAgents = foreignAgents;
}
public boolean isWarehousingAgents() {
return warehousingAgents;
}
public void setWarehousingAgents(boolean warehousingAgents) {
this.warehousingAgents = warehousingAgents;
}
public boolean isMerchandisingAgents() {
return merchandisingAgents;
}
public void setMerchandisingAgents(boolean merchandisingAgents) {
this.merchandisingAgents = merchandisingAgents;
}
public boolean isSourcingAgents() {
return sourcingAgents;
}
public void setSourcingAgents(boolean sourcingAgents) {
this.sourcingAgents = sourcingAgents;
}
public ValidationAction getToleranceValidationAction() {
return toleranceValidationAction;
}
public void setToleranceValidationAction(ValidationAction toleranceValidationAction) {
this.toleranceValidationAction = toleranceValidationAction;
}
public boolean isForceCommentOnWarningAcceptance() {
return forceCommentOnWarningAcceptance;
}
public void setForceCommentOnWarningAcceptance(boolean forceCommentOnWarningAcceptance) {
this.forceCommentOnWarningAcceptance = forceCommentOnWarningAcceptance;
}
public boolean isUseLCLContainerVolumes() {
return useLCLContainerVolumes;
}
public void setUseLCLContainerVolumes(boolean useLCLContainerVolumes) {
this.useLCLContainerVolumes = useLCLContainerVolumes;
}
public ActualCostAllocationMethod getAlcVariableCostDistributionMethod() {
return alcVariableCostDistributionMethod;
}
public void setAlcVariableCostDistributionMethod(ActualCostAllocationMethod alcVariableCostDistributionMethod) {
this.alcVariableCostDistributionMethod = alcVariableCostDistributionMethod;
}
public PaymentBasis getClcPaymentBasis() {
return clcPaymentBasis;
}
public void setClcPaymentBasis(PaymentBasis clcPaymentBasis) {
this.clcPaymentBasis = clcPaymentBasis;
}
public PaymentBasis getAlcPaymentBasis() {
return alcPaymentBasis;
}
public void setAlcPaymentBasis(PaymentBasis alcPaymentBasis) {
this.alcPaymentBasis = alcPaymentBasis;
}
public Set<SettlementDateCalculation> getSettlementDateCalculations() {
return settlementDateCalculations;
}
public void setSettlementDateCalculations(Set<SettlementDateCalculation> settlementDateCalculations) {
this.settlementDateCalculations = settlementDateCalculations;
}
public Set<ContainerTypeMetaData> getContainerTypeMetaData() {
return containerTypeMetaData;
}
public void setContainerTypeMetaData(Set<ContainerTypeMetaData> containerTypeMetaData) {
this.containerTypeMetaData = containerTypeMetaData;
}
public ClcIndirectCostDistributionType getClcIndirectCostDistribution() {
return clcIndirectCostDistribution;
}
public void setClcIndirectCostDistribution(ClcIndirectCostDistributionType clcIndirectCostDistribution) {
this.clcIndirectCostDistribution = clcIndirectCostDistribution;
}
public AlcIndirectCostDistributionType getAlcIndirectCostDistribution() {
return alcIndirectCostDistribution;
}
public void setAlcIndirectCostDistribution(AlcIndirectCostDistributionType alcIndirectCostDistribution) {
this.alcIndirectCostDistribution = alcIndirectCostDistribution;
}
public RateOfExchangeType getRateOfExchangeType() {
return rateOfExchangeType;
}
public void setRateOfExchangeType(RateOfExchangeType rateOfExchangeType) {
this.rateOfExchangeType = rateOfExchangeType;
}
public int getActualCostingDueDateDays() {
return actualCostingDueDateDays;
}
public void setActualCostingDueDateDays(int actualCostingDueDateDays) {
this.actualCostingDueDateDays = actualCostingDueDateDays;
}
public boolean isValidateIndirectCostLines() {
return validateIndirectCostLines;
}
public void setValidateIndirectCostLines(boolean validateIndirectCostLines) {
this.validateIndirectCostLines = validateIndirectCostLines;
}
public ALCRateDefault getAlcRateDefault() {
return alcRateDefault;
}
public void setAlcRateDefault(ALCRateDefault alcRateDefault) {
this.alcRateDefault = alcRateDefault;
}
public AgentCommissionBasedOnType getAgentCostApplicationBasis() {
return agentCostApplicationBasis;
}
public void setAgentCostApplicationBasis(AgentCommissionBasedOnType agentCostApplicationBasis) {
this.agentCostApplicationBasis = agentCostApplicationBasis;
}
public boolean isInclSupplyHangerCostLine() {
return inclSupplyHangerCostLine;
}
public void setInclSupplyHangerCostLine(boolean inclSupplyHangerCostLine) {
this.inclSupplyHangerCostLine = inclSupplyHangerCostLine;
}
public RateFeedDateCustomsCalc getRateFeedDateCustomsCalc() {
return rateFeedDateCustomsCalc;
}
public void setRateFeedDateCustomsCalc(RateFeedDateCustomsCalc rateFeedDateCustomsCalc) {
this.rateFeedDateCustomsCalc = rateFeedDateCustomsCalc;
}
public boolean isShowSABSWarning() {
return showSABSWarning;
}
public void setShowSABSWarning(boolean showSABSWarning) {
this.showSABSWarning = showSABSWarning;
}
public List<Vat> getVatList() {
return vatList;
}
public void setVatList(List<Vat> vatList) {
this.vatList = vatList;
}
public List<CustomVat> getCustomVatList() {
return customVatList;
}
public void setCustomVatList(List<CustomVat> customVatList) {
this.customVatList = customVatList;
}
public int getFacilityFeePaymentTerm() {
return facilityFeePaymentTerm;
}
public void setFacilityFeePaymentTerm(int facilityFeePaymentTerm) {
this.facilityFeePaymentTerm = facilityFeePaymentTerm;
}
public ErrorWarningOption getMinimumCostLineValidation() {
return minimumCostLineValidation;
}
public void setMinimumCostLineValidation(ErrorWarningOption minimumCostLineValidation) {
this.minimumCostLineValidation = minimumCostLineValidation;
}
public boolean isDisplayVat() {
return displayVat;
}
public void setDisplayVat(boolean displayVat) {
this.displayVat = displayVat;
}
public boolean isElcGlcVariance() {
return elcGlcVariance;
}
public void setElcGlcVariance(boolean elcGlcVariance) {
this.elcGlcVariance = elcGlcVariance;
}
public BigDecimal getElcGlcLowerTolerance() {
return elcGlcLowerTolerance;
}
public void setElcGlcLowerTolerance(BigDecimal elcGlcLowerTolerance) {
this.elcGlcLowerTolerance = elcGlcLowerTolerance;
}
public BigDecimal getElcGlcUpperTolerance() {
return elcGlcUpperTolerance;
}
public void setElcGlcUpperTolerance(BigDecimal elcGlcUpperTolerance) {
this.elcGlcUpperTolerance = elcGlcUpperTolerance;
}
public boolean isDisplayTradeFinance() {
return displayTradeFinance;
}
public void setDisplayTradeFinance(boolean displayTradeFinance) {
this.displayTradeFinance = displayTradeFinance;
}
public ALCRateDefault getAlcInternalProvRate() {
return alcInternalProvRate;
}
public void setAlcInternalProvRate(ALCRateDefault alcInternalProvRate) {
this.alcInternalProvRate = alcInternalProvRate;
}
public ALCRateDefault getAlcSupplyAdditionalRate() {
return alcSupplyAdditionalRate;
}
public void setAlcSupplyAdditionalRate(ALCRateDefault alcSupplyAdditionalRate) {
this.alcSupplyAdditionalRate = alcSupplyAdditionalRate;
}
public boolean isBuyingCommission() {
return buyingCommission;
}
public void setBuyingCommission(boolean buyingCommission) {
this.buyingCommission = buyingCommission;
}
public boolean isServiceFeeInclusiveInterest() {
return serviceFeeInclusiveInterest;
}
public void setServiceFeeInclusiveInterest(boolean serviceFeeInclusiveInterest) {
this.serviceFeeInclusiveInterest = serviceFeeInclusiveInterest;
}
public RateFeedDateCustomsCalc getElcRateFeedDateCustomsCalc() {
return elcRateFeedDateCustomsCalc;
}
public void setElcRateFeedDateCustomsCalc(RateFeedDateCustomsCalc elcRateFeedDateCustomsCalc) {
this.elcRateFeedDateCustomsCalc = elcRateFeedDateCustomsCalc;
}
public RateOfExchangeType getElcRateOfExchangeType() {
return elcRateOfExchangeType;
}
public void setElcRateOfExchangeType(RateOfExchangeType elcRateOfExchangeType) {
this.elcRateOfExchangeType = elcRateOfExchangeType;
}
public boolean isEnableShipmentCLC() {
return enableShipmentCLC;
}
public void setEnableShipmentCLC(boolean enableShipmentCLC) {
this.enableShipmentCLC = enableShipmentCLC;
}
public RateOfExchangeType getShipmentCLCRateOfExchangeType() {
return shipmentCLCRateOfExchangeType;
}
public void setShipmentCLCRateOfExchangeType(RateOfExchangeType shipmentCLCRateOfExchangeType) {
this.shipmentCLCRateOfExchangeType = shipmentCLCRateOfExchangeType;
}
public ALCRateDefault getAlcCustomsRate() {
return alcCustomsRate;
}
public void setAlcCustomsRate(ALCRateDefault alcCustomsRate) {
this.alcCustomsRate = alcCustomsRate;
}
public ALCRateofExchangeForCustomsCalculation getAlcRoeForCustomCalc() {
return alcRoeForCustomCalc;
}
public void setAlcRoeForCustomCalc(ALCRateofExchangeForCustomsCalculation alcRoeForCustomCalc) {
this.alcRoeForCustomCalc = alcRoeForCustomCalc;
}
public ALCRateDefault getAlcAgentRateDefault() {
return alcAgentRateDefault;
}
public void setAlcAgentRateDefault(ALCRateDefault alcAgentRateDefault) {
this.alcAgentRateDefault = alcAgentRateDefault;
}
public boolean isIgnoreToleranceCheck() {
return ignoreToleranceCheck;
}
public void setIgnoreToleranceCheck(boolean ignoreToleranceCheck) {
this.ignoreToleranceCheck = ignoreToleranceCheck;
}
public Set<OrganisationalUnit> getOrganisationalUnits() {
return organisationalUnits;
}
public void setOrganisationalUnits(Set<OrganisationalUnit> organisationalUnits) {
this.organisationalUnits = organisationalUnits;
}
public boolean canApplyToleranceCheckConfig(OrganisationalUnit orderOrganisationalUnit) {
return organisationalUnits == null || organisationalUnits.isEmpty() ||
organisationalUnits.stream().filter(ou -> ou.getId().equals(orderOrganisationalUnit.getId())).count() > 0;
}
public List<CostingComparisonSetup> getCostingComparisonSetups() {
return costingComparisonSetups;
}
public void setCostingComparisonSetups(List<CostingComparisonSetup> costingComparisonSetups) {
this.costingComparisonSetups = costingComparisonSetups;
}
public boolean isDetailedCostComparison() {
return detailedCostComparison;
}
public void setDetailedCostComparison(boolean detailedCostComparison) {
this.detailedCostComparison = detailedCostComparison;
}
public ALCRateDefault getAlcFinanceRate() {
return alcFinanceRate;
}
public void setAlcFinanceRate(ALCRateDefault alcFinanceRate) {
this.alcFinanceRate = alcFinanceRate;
}
}