PlannedSettlementSearchResult.java
package com.tradecloud.dto.plannedsettlement;
import com.tradecloud.common.base.PersistenceBase;
import com.tradecloud.domain.base.utils.MathUtils;
import com.tradecloud.domain.model.ordermanagement.OrderType;
import com.tradecloud.domain.model.shipment.ShippingMode;
import com.tradecloud.domain.party.Employee;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.math.BigDecimal;
import java.util.Date;
/**
* Created by ds on 2017/06/05.
*/
@XmlRootElement(name = "PlannedSettlementSearchResult")
@XmlAccessorType(XmlAccessType.FIELD)
public class PlannedSettlementSearchResult extends PersistenceBase {
private String orderReference;
private String invoiceReference;
private String shipmentReference;
private String currency;
private Date settlementDate;
private BigDecimal unpaidAmount;
private BigDecimal paidAmount;
private BigDecimal percent;
private BigDecimal totalAmount;
private BigDecimal invoiceAmount;
private BigDecimal orderAmount;
private Employee buyer;
private Long id;
private String splitPaymentType;
private String plannedSettlementType;
private Long orderId;
private Long invoiceId;
private String supplierName;
private BigDecimal updatableAmount;
private Date createdDate;
private String organisationName;
private Date shipmentCreateDate;
private Date billOfLadingDate;
private Date deliveredDateToFD;
private String paymentDates;
private String paymentReferences;
private String orderState;
private BigDecimal amount;
private BigDecimal totalPlannedAmount;
private String erpPaymentId;
private String paymentTerm;
private String paymentMethod;
private String orderComments;
private String nominatedBank;
private BigDecimal forwardRate;
private Long shipmentId;
private ShippingMode shippingMode = ShippingMode.SEA;
private String invoiceState;
private boolean canAllocateAmount;
private String shippingReference;
public String getPaymentDates() {
return paymentDates;
}
public void setPaymentDates(String paymentDates) {
this.paymentDates = paymentDates;
}
public String getPaymentReferences() {
return paymentReferences;
}
public void setPaymentReferences(String paymentReferences) {
this.paymentReferences = paymentReferences;
}
public String getOrderReference() {
return orderReference;
}
public void setOrderReference(String orderReference) {
this.orderReference = orderReference;
}
public String getInvoiceReference() {
return invoiceReference;
}
public void setInvoiceReference(String invoiceReference) {
this.invoiceReference = invoiceReference;
}
public String getShipmentReference() {
return shipmentReference;
}
public void setShipmentReference(String shipmentReference) {
this.shipmentReference = shipmentReference;
}
public String getCurrency() {
return currency;
}
public void setCurrency(String currency) {
this.currency = currency;
}
public Date getSettlementDate() {
return settlementDate;
}
public void setSettlementDate(Date settlementDate) {
this.settlementDate = settlementDate;
}
public BigDecimal getUnpaidAmount() {
return MathUtils.subtract(totalAmount, paidAmount == null ? BigDecimal.ZERO : paidAmount);
}
public void setUnpaidAmount(BigDecimal unpaidAmount) {
this.unpaidAmount = unpaidAmount;
}
public BigDecimal getPaidAmount() {
return paidAmount == null ? BigDecimal.ZERO : paidAmount;
}
public void setPaidAmount(BigDecimal paidAmount) {
this.paidAmount = paidAmount;
}
public BigDecimal getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(BigDecimal totalAmount) {
this.totalAmount = totalAmount;
}
public Employee getBuyer() {
return buyer;
}
public void setBuyer(Employee buyer) {
this.buyer = buyer;
}
public BigDecimal getPercent() {
if (orderAmount != null) {
if (MathUtils.isNonZero(orderAmount)) {
return MathUtils.fromPercent(MathUtils.divideVA(totalAmount, orderAmount));
} else {
return percent;
}
}
if (invoiceAmount != null) {
if (MathUtils.isNonZero(invoiceAmount)) {
return MathUtils.fromPercent(MathUtils.divideVA(totalAmount, invoiceAmount));
}
}
return percent;
}
public void setPercent(BigDecimal percent) {
this.percent = percent;
}
@Override
public Long getId() {
return id;
}
@Override
public void setId(Long id) {
this.id = id;
}
public BigDecimal getInvoiceAmount() {
return invoiceAmount;
}
public void setInvoiceAmount(BigDecimal invoiceAmount) {
this.invoiceAmount = invoiceAmount;
}
public BigDecimal getOrderAmount() {
return orderAmount;
}
public void setOrderAmount(BigDecimal orderAmount) {
this.orderAmount = orderAmount;
}
public String getSplitPaymentType() {
return splitPaymentType;
}
public void setSplitPaymentType(String splitPaymentType) {
this.splitPaymentType = splitPaymentType;
}
public String getPlannedSettlementType() {
return plannedSettlementType;
}
public void setPlannedSettlementType(String plannedSettlementType) {
this.plannedSettlementType = plannedSettlementType;
}
public Long getOrderId() {
return orderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
public Long getInvoiceId() {
return invoiceId;
}
public void setInvoiceId(Long invoiceId) {
this.invoiceId = invoiceId;
}
public String getSupplierName() {
return supplierName;
}
public void setSupplierName(String supplierName) {
this.supplierName = supplierName;
}
public boolean isOrder() {
return orderId != null && orderAmount != null;
}
public BigDecimal getUpdatableAmount() {
return updatableAmount;
}
public void setUpdatableAmount(BigDecimal updatableAmount) {
this.updatableAmount = updatableAmount;
}
public Date getCreatedDate() {
return createdDate;
}
public void setCreatedDate(Date createdDate) {
this.createdDate = createdDate;
}
public String getOrganisationName() {
return organisationName;
}
public void setOrganisationName(String organisationName) {
this.organisationName = organisationName;
}
public Date getShipmentCreateDate() {
return shipmentCreateDate;
}
public void setShipmentCreateDate(Date shipmentCreateDate) {
this.shipmentCreateDate = shipmentCreateDate;
}
public Date getBillOfLadingDate() {
return billOfLadingDate;
}
public void setBillOfLadingDate(Date billOfLadingDate) {
this.billOfLadingDate = billOfLadingDate;
}
public Date getDeliveredDateToFD() {
return deliveredDateToFD;
}
public void setDeliveredDateToFD(Date deliveredDateToFD) {
this.deliveredDateToFD = deliveredDateToFD;
}
public String getOrderState() {
return orderState;
}
public void setOrderState(String orderState) {
this.orderState = orderState;
}
public BigDecimal getAmount() {
return amount;
}
public void setAmount(BigDecimal amount) {
this.amount = amount;
}
public BigDecimal getTotalPlannedAmount() {
if (totalPlannedAmount == null) totalPlannedAmount = BigDecimal.ZERO;
return totalPlannedAmount;
}
public void setTotalPlannedAmount(BigDecimal totalPlannedAmount) {
this.totalPlannedAmount = totalPlannedAmount;
}
@Override
public String toString() {
return "PlannedSettlementSearchResult{" +
"orderReference='" + orderReference + '\'' +
", invoiceReference='" + invoiceReference + '\'' +
", shipmentReference='" + shipmentReference + '\'' +
", currency='" + currency + '\'' +
'}';
}
public boolean isReallocationAllowed() {
return getTotalPlannedAmount().compareTo(getTotalAmount()) <= 0 && getTotalPlannedAmount().compareTo(BigDecimal.ZERO) > 0;
}
public String getErpPaymentId() {
return erpPaymentId;
}
public void setErpPaymentId(String erpPaymentId) {
this.erpPaymentId = erpPaymentId;
}
public String getPaymentTerm() {
return paymentTerm;
}
public void setPaymentTerm(String paymentTerm) {
this.paymentTerm = paymentTerm;
}
public String getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(String paymentMethod) {
this.paymentMethod = paymentMethod;
}
public String getOrderComments() {
return orderComments;
}
public void setOrderComments(String orderComments) {
this.orderComments = orderComments;
}
public BigDecimal getForwardRate() {
return forwardRate;
}
public void setForwardRate(BigDecimal forwardRate) {
this.forwardRate = forwardRate;
}
public String getNominatedBank() {
return nominatedBank;
}
public void setNominatedBank(String nominatedBank) {
this.nominatedBank = nominatedBank;
}
public String getPaidInFull() {
return MathUtils.isZero(getUnpaidAmount())||isOverPaid() ? "YES" : "NO";
}
public OrderType getOrderType() {
return OrderType.PURCHASE_ORDER;
}
public Long getShipmentId() {
return shipmentId;
}
public void setShipmentId(Long shipmentId) {
this.shipmentId = shipmentId;
}
public ShippingMode getShippingMode() {
return shippingMode;
}
public void setShippingMode(ShippingMode shippingMode) {
this.shippingMode = shippingMode;
}
public boolean isOverPaid() {
BigDecimal paidAmount1 = getUnpaidAmount();
return paidAmount1 !=null && !MathUtils.areNumbersCloselyEqual(BigDecimal.ZERO,paidAmount1.abs(),4) && paidAmount1.doubleValue()<0;
}
public String getInvoiceState() {
return invoiceState;
}
public void setInvoiceState(String invoiceState) {
this.invoiceState = invoiceState;
}
public boolean isCanAllocateAmount() {
return canAllocateAmount;
}
public void setCanAllocateAmount(boolean canAllocateAmount) {
this.canAllocateAmount = canAllocateAmount;
}
public String getShippingReference() {
return shippingReference;
}
public void setShippingReference(String shippingReference) {
this.shippingReference = shippingReference;
}
}