Subversion Repositories SmartDukaan

Rev

Rev 30652 | Rev 33060 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.dao.entity.transaction;

import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
import com.spice.profitmandi.dao.entity.catalog.Item;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * This class basically contains api details
 *
 * @author ashikali
 */
@Entity
@Table(name = "transaction.lineitem")
@NamedQueries({@NamedQuery(name = "LineItem.selectAll", query = "select li from LineItem li"), @NamedQuery(name = "LineItem.selectById", query = "select li from LineItem li where li.id= :id")
})
public class LineItem implements Serializable {

    private static final long serialVersionUID = 1L;

    public LineItem() {
    }

    @Id
    @Column(name = "id", unique = true, updatable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "item_id")
    private Integer itemId;

    @Column(name = "productGroup", length = 100)
    private String productGoup;

    @Column(name = "brand", length = 100)
    private String brand;

    @Column(name = "model_number", length = 100)
    private String modelNumber;

    @Column(name = "model_name", length = 100)
    private String modelName;

    @Column(name = "color", length = 20)
    private String color;

    @Column(name = "extra_info", length = 100)
    private String extraInfo;

    @Column(name = "quantity")
    private Integer quantity;

    @Column(name = "mrp")
    private Float mrp;

    @Column(name = "unit_price")
    private Float unitPrice;

    @Column(name = "unit_weight")
    private Float unitWeight;

    @Column(name = "total_price")
    private Float totalPrice;

    @Column(name = "transfer_price")
    private Float transferPrice;

    @Column(name = "total_weight")
    private Float totalWeight;

    @Column(name = "order_id")
    private Integer orderId;

    @Column(name = "imei_number", length = 20)
    private String imeiNumber;

    @Column(name = "item_number", length = 50)
    private String itemNumber;

    @Column(name = "dealText", length = 100)
    private String dealText;

    @Convert(converter = LocalDateTimeAttributeConverter.class)
    @Column(name = "warranty_expiry_timestamp")
    private LocalDateTime warrantyExpiryTimestamp;

    @Column(name = "nlc")
    private Float nlc;

    @Column(name = "logisticsCost")
    private Float logisticsCost;

    @Column(name = "codCollectionCharges")
    private Float codCollectionCharges;

    @Column(name = "returnQty")
    private int returnQty;

    @Column(name = "igstRate")
    private Float igstRate;

    @Column(name = "cgstRate")
    private Float cgstRate;

    @Column(name = "sgstRate")
    private Float sgstRate;


    @Column(name = "hsnCode")
    private String hsnCode;

    @Convert(converter = LocalDateTimeAttributeConverter.class)
    @Column(name = "damaged_expiry_timestamp")
    private LocalDateTime damagedExpiryTimestamp;

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    //@Fetch(value = FetchMode.SUBSELECT)
    @JoinColumn(name = "item_id", insertable = false, updatable = false, nullable = false, referencedColumnName = "id")
    private Item item;

    public float getTotalTaxRate() {
        return (this.cgstRate == null ? 0 : this.cgstRate) + (this.sgstRate == null ? 0 : this.sgstRate) + (this.igstRate == null ? 0 : this.igstRate);
    }

    public String getItemDescription() {
        StringBuilder itemString = new StringBuilder();
        if (this.getBrand() != null && !this.getBrand().isEmpty()) {
            itemString.append(this.getBrand().trim());
        }
        itemString.append(" ");
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
            itemString.append(this.getModelName().trim());
        }
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
            itemString.append(" ");
            itemString.append(this.getModelNumber().trim());
        }
        if (this.getColor() != null && !this.getColor().isEmpty() && !this.getColor().trim().equals("f_")) {
            itemString.append(" ");
            itemString.append(this.getColor().trim());
        }
        return itemString.toString().replaceAll("\\s+", " ").trim();
    }

    public String getItemDescriptionNoColor() {
        StringBuilder itemString = new StringBuilder();
        if (this.getBrand() != null && !this.getBrand().isEmpty()) {
            itemString.append(this.getBrand().trim());
        }
        itemString.append(" ");
        if (this.getModelName() != null && !this.getModelName().isEmpty()) {
            itemString.append(this.getModelName().trim());
        }
        if (this.getModelNumber() != null && !this.getModelNumber().isEmpty()) {
            itemString.append(" ");
            itemString.append(this.getModelNumber().trim());
        }

        return itemString.toString().replaceAll("\\s+", " ").trim();
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getItemId() {
        return itemId;
    }

    public void setItemId(Integer itemId) {
        this.itemId = itemId;
    }

    public String getProductGoup() {
        return productGoup;
    }

    public void setProductGoup(String productGoup) {
        this.productGoup = productGoup;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getModelNumber() {
        return modelNumber;
    }

    public void setModelNumber(String modelNumber) {
        this.modelNumber = modelNumber;
    }

    public String getModelName() {
        return modelName;
    }

    public void setModelName(String modelName) {
        this.modelName = modelName;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getExtraInfo() {
        return extraInfo;
    }

    public void setExtraInfo(String extraInfo) {
        this.extraInfo = extraInfo;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Float getMrp() {
        return mrp;
    }

    public void setMrp(Float mrp) {
        this.mrp = mrp;
    }

    public Float getUnitPrice() {
        return unitPrice;
    }

    public void setUnitPrice(Float unitPrice) {
        this.unitPrice = unitPrice;
    }

    public Float getUnitWeight() {
        return unitWeight;
    }

    public void setUnitWeight(Float unitWeight) {
        this.unitWeight = unitWeight;
    }

    public Float getTotalPrice() {
        return totalPrice;
    }

    public void setTotalPrice(Float totalPrice) {
        this.totalPrice = totalPrice;
    }

    public Float getTransferPrice() {
        return transferPrice;
    }

    public void setTransferPrice(Float transferPrice) {
        this.transferPrice = transferPrice;
    }

    public Float getTotalWeight() {
        return totalWeight;
    }

    public void setTotalWeight(Float totalWeight) {
        this.totalWeight = totalWeight;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public String getImeiNumber() {
        return imeiNumber;
    }

    public void setImeiNumber(String imeiNumber) {
        this.imeiNumber = imeiNumber;
    }

    public String getItemNumber() {
        return itemNumber;
    }

    public void setItemNumber(String itemNumber) {
        this.itemNumber = itemNumber;
    }

    public String getDealText() {
        return dealText;
    }

    public void setDealText(String dealText) {
        this.dealText = dealText;
    }

    public LocalDateTime getWarrantyExpiryTimestamp() {
        return warrantyExpiryTimestamp;
    }

    public void setWarrantyExpiryTimestamp(LocalDateTime warrantyExpiryTimestamp) {
        this.warrantyExpiryTimestamp = warrantyExpiryTimestamp;
    }

    public Float getNlc() {
        return nlc;
    }

    public void setNlc(Float nlc) {
        this.nlc = nlc;
    }

    public Float getLogisticsCost() {
        return logisticsCost;
    }

    public void setLogisticsCost(Float logisticsCost) {
        this.logisticsCost = logisticsCost;
    }

    public Float getCodCollectionCharges() {
        return codCollectionCharges;
    }

    public void setCodCollectionCharges(Float codCollectionCharges) {
        this.codCollectionCharges = codCollectionCharges;
    }

    public int getReturnQty() {
        return returnQty;
    }

    public void setReturnQty(int returnQty) {
        this.returnQty = returnQty;
    }

    public Float getIgstRate() {
        return igstRate;
    }

    public void setIgstRate(Float igstRate) {
        this.igstRate = igstRate;
    }

    public Float getCgstRate() {
        return cgstRate;
    }

    public void setCgstRate(Float cgstRate) {
        this.cgstRate = cgstRate;
    }

    public Float getSgstRate() {
        return sgstRate;
    }

    public void setSgstRate(Float sgstRate) {
        this.sgstRate = sgstRate;
    }

    public String getHsnCode() {
        return hsnCode;
    }

    public void setHsnCode(String hsnCode) {
        this.hsnCode = hsnCode;
    }

    public LocalDateTime getDamagedExpiryTimestamp() {
        return damagedExpiryTimestamp;
    }

    public void setDamagedExpiryTimestamp(LocalDateTime damagedExpiryTimestamp) {
        this.damagedExpiryTimestamp = damagedExpiryTimestamp;
    }

    public Item getItem() {
        return item;
    }

    public void setItem(Item item) {
        this.item = item;
    }


    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((id == null) ? 0 : id.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        LineItem other = (LineItem) obj;
        if (id == null) {
            if (other.id != null)
                return false;
        } else if (!id.equals(other.id))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "LineItem [id=" + id + ", itemId=" + itemId + ", productGoup=" + productGoup + ", brand=" + brand + ", modelNumber=" + modelNumber + ", modelName=" + modelName + ", color=" + color + ", extraInfo=" + extraInfo + ", quantity=" + quantity + ", mrp=" + mrp + ", unitPrice=" + unitPrice + ", unitWeight=" + unitWeight + ", totalPrice=" + totalPrice + ", transferPrice=" + transferPrice + ", totalWeight=" + totalWeight + ", orderId=" + orderId + ", imeiNumber=" + imeiNumber + ", itemNumber=" + itemNumber + ", dealText=" + dealText + ", warrantyExpiryTimestamp=" + warrantyExpiryTimestamp + ", serialNumber=" + ", nlc=" + nlc + ", logisticsCost=" + logisticsCost + ", codCollectionCharges=" + codCollectionCharges + ", returnQty=" + returnQty + ", igstRate=" + igstRate + ", cgstRate=" + cgstRate + ", sgstRate=" + sgstRate + ", hsnCode=" + hsnCode + ", damagedExpiryTimestamp=" + damagedExpiryTimestamp + ", item=" + item + "]";
    }

}