Subversion Repositories SmartDukaan

Rev

Rev 29578 | Rev 29927 | 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.fofo;

import java.io.Serializable;
import java.time.LocalDateTime;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.spice.profitmandi.dao.enumuration.catalog.SchemeType;
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;

@Entity
@Table(name = "fofo.scheme_in_out", schema = "fofo")

@NamedQueries({

                @NamedQuery(name = "SchemeInOut.selectPendingActivationGroupByBrandYearMonth", query = "select new com.spice.profitmandi.dao.model.ActivationYearMonthModel(i.brand, "
                                + "   DATE_FORMAT(sio.createTimestamp, '%m-%Y'),sum(cast(sio.amount As int)) ) from Scheme sc join  SchemeInOut sio  on"
                                + " sc.id = sio.schemeId join InventoryItem ii  on ii.id = sio.inventoryItemId"
                                + " join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and sio.createTimestamp >= :startDate and ii.fofoId = :fofoId  "
                                + "  group by i.brand, DATE_FORMAT(sio.createTimestamp, '%m-%Y')"),

                @NamedQuery(name = "SchemeInOut.selectByYearMonthActivationGroupByBrand", query = "select new com.spice.profitmandi.dao.model.ActivationBrandModel(i.brand, "
                                + "  sum(cast(sio.amount As integer )) ) from Scheme sc join  SchemeInOut sio  on"
                                + " sc.id = sio.schemeId join InventoryItem ii  on ii.id = sio.inventoryItemId"
                                + " join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and sio.createTimestamp <= :endDate and ii.fofoId = :fofoId  "
                                + "  group by i.brand"),

                @NamedQuery(name = "SchemeInOut.selectBrandPendingActivationItemDetails", query = "select new com.spice.profitmandi.dao.model.ActivationItemDetailModel(i.brand, "
                                + "  i.modelName,i.modelNumber,cast(sio.amount As integer ),ii.serialNumber, ii.id) from Scheme sc join SchemeInOut sio  on"
                                + "      sc.id = sio.schemeId join InventoryItem ii  on ii.id = sio.inventoryItemId"
                                + "      join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and "
                                + "  ii.fofoId = :fofoId and i.brand = :brand and  DATE_FORMAT(sio.createTimestamp, '%m-%Y') = :yearMonthValue"),

                @NamedQuery(name = "SchemeInOut.selectBrandPendingActivationItemDetailByYearMonth", query = "select new com.spice.profitmandi.dao.model.ActivationItemDetailModel(i.brand, "
                                + "  i.modelName,i.modelNumber,cast(sio.amount As integer ),ii.serialNumber, ii.id) from Scheme sc join SchemeInOut sio  on"
                                + "      sc.id = sio.schemeId join InventoryItem ii  on ii.id = sio.inventoryItemId"
                                + "      join Item i on i.id = ii.itemId where sc.type = 'ACTIVATION' and sio.status ='PENDING' and "
                                + "  ii.fofoId = :fofoId and i.brand = :brand and sio.createTimestamp <= :endDate"),

})
public class SchemeInOut implements Serializable {

        public SchemeInOut(int schemeId, int inventoryItemId) {
                this.schemeId = schemeId;
                this.inventoryItemId = inventoryItemId;
        }

        public SchemeInOut() {
        }

        private static final long serialVersionUID = 1L;

        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        private int id;

        @Column(name = "scheme_id")
        private int schemeId;

        @Column(name = "inventory_item_id")
        private int inventoryItemId;

        @Column(name = "amount")
        private float amount;

        @Column(name = "status")
        @Enumerated(EnumType.STRING)
        private SchemePayoutStatus status;

        @Column(name = "create_timestamp")
        private LocalDateTime createTimestamp = LocalDateTime.now();

        @Column(name = "rolled_back_timestamp")
        private LocalDateTime rolledBackTimestamp;

        @Column(name = "credit_timestamp")
        private LocalDateTime creditTimestamp;

        @Column(name = "description")
        private String statusDescription;

        public int getId() {
                return id;
        }

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

        public SchemePayoutStatus getStatus() {
                return status;
        }

        public void setStatus(SchemePayoutStatus status) {
                this.status = status;
        }

        public LocalDateTime getCreditTimestamp() {
                return creditTimestamp;
        }

        public void setCreditTimestamp(LocalDateTime creditTimestamp) {
                this.creditTimestamp = creditTimestamp;
        }

        public String getStatusDescription() {
                return statusDescription;
        }

        public void setStatusDescription(String statusDescription) {
                this.statusDescription = statusDescription;
        }

        @Transient
        private int reference;

        public int getReference() {
                return reference;
        }

        public void setReference(int reference) {
                this.reference = reference;
        }

        @Transient
        private String serialNumber;

        @Transient
        private String storeCode;

        @Transient
        private SchemeType schemeType;

        public String getStoreCode() {
                return storeCode;
        }

        public void setStoreCode(String storeCode) {
                this.storeCode = storeCode;
        }

        public SchemeType getSchemeType() {
                return schemeType;
        }

        public void setSchemeType(SchemeType schemeType) {
                this.schemeType = schemeType;
        }

        public String getSerialNumber() {
                return serialNumber;
        }

        public void setSerialNumber(String serialNumber) {
                this.serialNumber = serialNumber;
        }

        public int getSchemeId() {
                return schemeId;
        }

        public void setSchemeId(int schemeId) {
                this.schemeId = schemeId;
        }

        public int getInventoryItemId() {
                return inventoryItemId;
        }

        public void setInventoryItemId(int inventoryItemId) {
                this.inventoryItemId = inventoryItemId;
        }

        public float getAmount() {
                return amount;
        }

        public void setAmount(float amount) {
                this.amount = amount;
        }

        public LocalDateTime getCreateTimestamp() {
                return createTimestamp;
        }

        public void setCreateTimestamp(LocalDateTime createTimestamp) {
                this.createTimestamp = createTimestamp;
        }

        public LocalDateTime getRolledBackTimestamp() {
                return rolledBackTimestamp;
        }

        public void setRolledBackTimestamp(LocalDateTime rolledBackTimestamp) {
                this.rolledBackTimestamp = rolledBackTimestamp;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + Float.floatToIntBits(amount);
                result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
                result = prime * result + id;
                result = prime * result + inventoryItemId;
                result = prime * result + ((rolledBackTimestamp == null) ? 0 : rolledBackTimestamp.hashCode());
                result = prime * result + schemeId;
                result = prime * result + ((schemeType == null) ? 0 : schemeType.hashCode());
                result = prime * result + ((serialNumber == null) ? 0 : serialNumber.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;
                SchemeInOut other = (SchemeInOut) obj;
                if (Float.floatToIntBits(amount) != Float.floatToIntBits(other.amount))
                        return false;
                if (createTimestamp == null) {
                        if (other.createTimestamp != null)
                                return false;
                } else if (!createTimestamp.equals(other.createTimestamp))
                        return false;
                if (id != other.id)
                        return false;
                if (inventoryItemId != other.inventoryItemId)
                        return false;
                if (rolledBackTimestamp == null) {
                        if (other.rolledBackTimestamp != null)
                                return false;
                } else if (!rolledBackTimestamp.equals(other.rolledBackTimestamp))
                        return false;
                if (schemeId != other.schemeId)
                        return false;
                if (schemeType != other.schemeType)
                        return false;
                if (serialNumber == null) {
                        if (other.serialNumber != null)
                                return false;
                } else if (!serialNumber.equals(other.serialNumber))
                        return false;
                return true;
        }

        @Override
        public String toString() {
                return "SchemeInOut [id=" + id + ", schemeId=" + schemeId + ", inventoryItemId=" + inventoryItemId + ", amount="
                                + amount + ", status=" + status + ", createTimestamp=" + createTimestamp + ", rolledBackTimestamp="
                                + rolledBackTimestamp + ", creditTimestamp=" + creditTimestamp + ", statusDescription="
                                + statusDescription + ", reference=" + reference + ", serialNumber=" + serialNumber + ", storeCode="
                                + storeCode + ", schemeType=" + schemeType + "]";
        }

}