Subversion Repositories SmartDukaan

Rev

Rev 25726 | Rev 30725 | 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.dtr;

import java.io.Serializable;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;

/**
 * This class basically contains insurance details
 * 
 * @author ashikali
 *
 */
@Entity
@Table(name = "dtr.insurance_policy", schema = "dtr")
public class InsurancePolicy implements Serializable {

        private static final long serialVersionUID = 1L;

        public InsurancePolicy() {
        }

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

        @Column(name = "invoice_number")
        private String invoiceNumber;

        @Column(name = "retailer_id")
        private int retailerId;

        @Column(name = "purchase_amount")
        private float purchaseAmount;

        @Column(name = "sale_amount")
        private float saleAmount;

        @Column(name = "selling_price")
        private float sellingPrice;

        @Column(name = "product_name")
        private String productName;

        public String getProductName() {
                return productName;
        }

        public void setProductName(String productName) {
                this.productName = productName;
        }

        @Column(name = "serial_number", unique = true)
        private String serialNumber;

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

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

        @Column(name = "policy_number")
        private String policyNumber;

        @Column(name = "provider_id")
        private int providerId;

        @Column(name = "customer_first_name")
        private String customerFirstName;

        @Column(name = "customer_last_name")
        private String customerLastName;

        @Column(name = "customer_mobile_number")
        private String customerMobileNumber;

        @Column(name = "customer_email_id")
        private String customerEmailId;

        @Column(name = "customer_date_of_birth")
        private LocalDate customerDateOfBirth = LocalDate.now();

        @Column(name = "customer_address1")
        private String customerAddress1;

        @Column(name = "customer_address2")
        private String customerAddress2;

        @Column(name = "customer_city")
        private String customerCity;

        @Column(name = "customer_pin_code")
        private String customerPinCode;

        @Column(name = "customer_state")
        private String customerState;

        @Column(name = "device_invoice_number")
        private String deviceInvoiceNumber;

        @Column(name = "posted", columnDefinition = "tinyint(1) default 0")
        private boolean posted;

        @Transient
        private InsuranceProvider insuranceProvider;

        @Convert(converter = LocalDateTimeAttributeConverter.class)
        @Column(name = "create_timestamp", updatable = false)
        private LocalDateTime createTimestamp = LocalDateTime.now();

        @Convert(converter = LocalDateTimeAttributeConverter.class)
        @Column(name = "invoice_creation_timestamp")
        private LocalDateTime invoiceCreationTimestamp = LocalDateTime.now();

        @Transient
        private String color;

        @Transient
        private String coveragePeriod;

        @Transient
        private int brandId;

        public int getBrandId() {
                return brandId;
        }

        public void setBrandId(int brandId) {
                this.brandId = brandId;
        }

        public String getDeviceInvoiceNumber() {
                return deviceInvoiceNumber;
        }

        public void setDeviceInvoiceNumber(String deviceInvoiceNumber) {
                this.deviceInvoiceNumber = deviceInvoiceNumber;
        }

        public String getCoveragePeriod() {
                return coveragePeriod;
        }

        public void setCoveragePeriod(String coveragePeriod) {
                this.coveragePeriod = coveragePeriod;
        }

        public String getColor() {
                return color;
        }

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

        public String getFormattedCreateTimestamp() {
                if (createTimestamp == null) {
                        return null;
                }
                DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
                return createTimestamp.format(formatter);
        }

        public int getId() {
                return id;
        }

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

        public String getInvoiceNumber() {
                return invoiceNumber;
        }

        public void setInvoiceNumber(String invoiceNumber) {
                this.invoiceNumber = invoiceNumber;
        }

        public int getRetailerId() {
                return retailerId;
        }

        public void setRetailerId(int retailerId) {
                this.retailerId = retailerId;
        }

        public float getPurchaseAmount() {
                return purchaseAmount;
        }

        public void setPurchaseAmount(float purchaseAmount) {
                this.purchaseAmount = purchaseAmount;
        }

        public float getSaleAmount() {
                return saleAmount;
        }

        public void setSaleAmount(float saleAmount) {
                this.saleAmount = saleAmount;
        }

        public float getSellingPrice() {
                return sellingPrice;
        }

        public void setSellingPrice(float sellingPrice) {
                this.sellingPrice = sellingPrice;
        }

        public String getSerialNumber() {
                return serialNumber;
        }

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

        public String getModelName() {
                return modelName;
        }

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

        public String getBrand() {
                return brand;
        }

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

        public String getPolicyNumber() {
                return policyNumber;
        }

        public void setPolicyNumber(String policyNumber) {
                this.policyNumber = policyNumber;
        }

        public int getProviderId() {
                return providerId;
        }

        public void setProviderId(int providerId) {
                this.providerId = providerId;
        }

        public String getCustomerFirstName() {
                return customerFirstName;
        }

        public void setCustomerFirstName(String customerFirstName) {
                this.customerFirstName = customerFirstName;
        }

        public String getCustomerLastName() {
                return customerLastName;
        }

        public void setCustomerLastName(String customerLastName) {
                this.customerLastName = customerLastName;
        }

        public String getCustomerMobileNumber() {
                return customerMobileNumber;
        }

        public void setCustomerMobileNumber(String customerMobileNumber) {
                this.customerMobileNumber = customerMobileNumber;
        }

        public String getCustomerEmailId() {
                return customerEmailId;
        }

        public void setCustomerEmailId(String customerEmailId) {
                this.customerEmailId = customerEmailId;
        }

        public LocalDate getCustomerDateOfBirth() {
                return customerDateOfBirth;
        }

        public void setCustomerDateOfBirth(LocalDate customerDateOfBirth) {
                this.customerDateOfBirth = customerDateOfBirth;
        }

        public String getCustomerAddress1() {
                return customerAddress1;
        }

        public void setCustomerAddress1(String customerAddress1) {
                this.customerAddress1 = customerAddress1;
        }

        public String getCustomerAddress2() {
                return customerAddress2;
        }

        public void setCustomerAddress2(String customerAddress2) {
                this.customerAddress2 = customerAddress2;
        }

        public String getCustomerCity() {
                return customerCity;
        }

        public void setCustomerCity(String customerCity) {
                this.customerCity = customerCity;
        }

        public String getCustomerPinCode() {
                return customerPinCode;
        }

        public void setCustomerPinCode(String customerPinCode) {
                this.customerPinCode = customerPinCode;
        }

        public String getCustomerState() {
                return customerState;
        }

        public void setCustomerState(String customerState) {
                this.customerState = customerState;
        }

        public boolean isPosted() {
                return posted;
        }

        public void setPosted(boolean posted) {
                this.posted = posted;
        }

        public InsuranceProvider getInsuranceProvider() {
                return insuranceProvider;
        }

        public void setInsuranceProvider(InsuranceProvider insuranceProvider) {
                this.insuranceProvider = insuranceProvider;
        }

        public LocalDateTime getCreateTimestamp() {
                return createTimestamp;
        }

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

        public LocalDateTime getInvoiceCreationTimestamp() {
                return invoiceCreationTimestamp;
        }

        public void setInvoiceCreationTimestamp(LocalDateTime invoiceCreationTimestamp) {
                this.invoiceCreationTimestamp = invoiceCreationTimestamp;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + ((brand == null) ? 0 : brand.hashCode());
                result = prime * result + brandId;
                result = prime * result + ((color == null) ? 0 : color.hashCode());
                result = prime * result + ((coveragePeriod == null) ? 0 : coveragePeriod.hashCode());
                result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
                result = prime * result + ((customerAddress1 == null) ? 0 : customerAddress1.hashCode());
                result = prime * result + ((customerAddress2 == null) ? 0 : customerAddress2.hashCode());
                result = prime * result + ((customerCity == null) ? 0 : customerCity.hashCode());
                result = prime * result + ((customerDateOfBirth == null) ? 0 : customerDateOfBirth.hashCode());
                result = prime * result + ((customerEmailId == null) ? 0 : customerEmailId.hashCode());
                result = prime * result + ((customerFirstName == null) ? 0 : customerFirstName.hashCode());
                result = prime * result + ((customerLastName == null) ? 0 : customerLastName.hashCode());
                result = prime * result + ((customerMobileNumber == null) ? 0 : customerMobileNumber.hashCode());
                result = prime * result + ((customerPinCode == null) ? 0 : customerPinCode.hashCode());
                result = prime * result + ((customerState == null) ? 0 : customerState.hashCode());
                result = prime * result + ((deviceInvoiceNumber == null) ? 0 : deviceInvoiceNumber.hashCode());
                result = prime * result + id;
                result = prime * result + ((insuranceProvider == null) ? 0 : insuranceProvider.hashCode());
                result = prime * result + ((invoiceCreationTimestamp == null) ? 0 : invoiceCreationTimestamp.hashCode());
                result = prime * result + ((invoiceNumber == null) ? 0 : invoiceNumber.hashCode());
                result = prime * result + ((modelName == null) ? 0 : modelName.hashCode());
                result = prime * result + ((policyNumber == null) ? 0 : policyNumber.hashCode());
                result = prime * result + (posted ? 1231 : 1237);
                result = prime * result + ((productName == null) ? 0 : productName.hashCode());
                result = prime * result + providerId;
                result = prime * result + Float.floatToIntBits(purchaseAmount);
                result = prime * result + retailerId;
                result = prime * result + Float.floatToIntBits(saleAmount);
                result = prime * result + Float.floatToIntBits(sellingPrice);
                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;
                InsurancePolicy other = (InsurancePolicy) obj;
                if (brand == null) {
                        if (other.brand != null)
                                return false;
                } else if (!brand.equals(other.brand))
                        return false;
                if (brandId != other.brandId)
                        return false;
                if (color == null) {
                        if (other.color != null)
                                return false;
                } else if (!color.equals(other.color))
                        return false;
                if (coveragePeriod == null) {
                        if (other.coveragePeriod != null)
                                return false;
                } else if (!coveragePeriod.equals(other.coveragePeriod))
                        return false;
                if (createTimestamp == null) {
                        if (other.createTimestamp != null)
                                return false;
                } else if (!createTimestamp.equals(other.createTimestamp))
                        return false;
                if (customerAddress1 == null) {
                        if (other.customerAddress1 != null)
                                return false;
                } else if (!customerAddress1.equals(other.customerAddress1))
                        return false;
                if (customerAddress2 == null) {
                        if (other.customerAddress2 != null)
                                return false;
                } else if (!customerAddress2.equals(other.customerAddress2))
                        return false;
                if (customerCity == null) {
                        if (other.customerCity != null)
                                return false;
                } else if (!customerCity.equals(other.customerCity))
                        return false;
                if (customerDateOfBirth == null) {
                        if (other.customerDateOfBirth != null)
                                return false;
                } else if (!customerDateOfBirth.equals(other.customerDateOfBirth))
                        return false;
                if (customerEmailId == null) {
                        if (other.customerEmailId != null)
                                return false;
                } else if (!customerEmailId.equals(other.customerEmailId))
                        return false;
                if (customerFirstName == null) {
                        if (other.customerFirstName != null)
                                return false;
                } else if (!customerFirstName.equals(other.customerFirstName))
                        return false;
                if (customerLastName == null) {
                        if (other.customerLastName != null)
                                return false;
                } else if (!customerLastName.equals(other.customerLastName))
                        return false;
                if (customerMobileNumber == null) {
                        if (other.customerMobileNumber != null)
                                return false;
                } else if (!customerMobileNumber.equals(other.customerMobileNumber))
                        return false;
                if (customerPinCode == null) {
                        if (other.customerPinCode != null)
                                return false;
                } else if (!customerPinCode.equals(other.customerPinCode))
                        return false;
                if (customerState == null) {
                        if (other.customerState != null)
                                return false;
                } else if (!customerState.equals(other.customerState))
                        return false;
                if (deviceInvoiceNumber == null) {
                        if (other.deviceInvoiceNumber != null)
                                return false;
                } else if (!deviceInvoiceNumber.equals(other.deviceInvoiceNumber))
                        return false;
                if (id != other.id)
                        return false;
                if (insuranceProvider == null) {
                        if (other.insuranceProvider != null)
                                return false;
                } else if (!insuranceProvider.equals(other.insuranceProvider))
                        return false;
                if (invoiceCreationTimestamp == null) {
                        if (other.invoiceCreationTimestamp != null)
                                return false;
                } else if (!invoiceCreationTimestamp.equals(other.invoiceCreationTimestamp))
                        return false;
                if (invoiceNumber == null) {
                        if (other.invoiceNumber != null)
                                return false;
                } else if (!invoiceNumber.equals(other.invoiceNumber))
                        return false;
                if (modelName == null) {
                        if (other.modelName != null)
                                return false;
                } else if (!modelName.equals(other.modelName))
                        return false;
                if (policyNumber == null) {
                        if (other.policyNumber != null)
                                return false;
                } else if (!policyNumber.equals(other.policyNumber))
                        return false;
                if (posted != other.posted)
                        return false;
                if (productName == null) {
                        if (other.productName != null)
                                return false;
                } else if (!productName.equals(other.productName))
                        return false;
                if (providerId != other.providerId)
                        return false;
                if (Float.floatToIntBits(purchaseAmount) != Float.floatToIntBits(other.purchaseAmount))
                        return false;
                if (retailerId != other.retailerId)
                        return false;
                if (Float.floatToIntBits(saleAmount) != Float.floatToIntBits(other.saleAmount))
                        return false;
                if (Float.floatToIntBits(sellingPrice) != Float.floatToIntBits(other.sellingPrice))
                        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 "InsurancePolicy [id=" + id + ", invoiceNumber=" + invoiceNumber + ", retailerId=" + retailerId
                                + ", purchaseAmount=" + purchaseAmount + ", saleAmount=" + saleAmount + ", sellingPrice=" + sellingPrice
                                + ", productName=" + productName + ", serialNumber=" + serialNumber + ", modelName=" + modelName
                                + ", brand=" + brand + ", policyNumber=" + policyNumber + ", providerId=" + providerId
                                + ", customerFirstName=" + customerFirstName + ", customerLastName=" + customerLastName
                                + ", customerMobileNumber=" + customerMobileNumber + ", customerEmailId=" + customerEmailId
                                + ", customerDateOfBirth=" + customerDateOfBirth + ", customerAddress1=" + customerAddress1
                                + ", customerAddress2=" + customerAddress2 + ", customerCity=" + customerCity + ", customerPinCode="
                                + customerPinCode + ", customerState=" + customerState + ", deviceInvoiceNumber=" + deviceInvoiceNumber
                                + ", posted=" + posted + ", insuranceProvider=" + insuranceProvider + ", createTimestamp="
                                + createTimestamp + ", invoiceCreationTimestamp=" + invoiceCreationTimestamp + ", color=" + color
                                + ", coveragePeriod=" + coveragePeriod + ", brandId=" + brandId + "]";
        }

}