Subversion Repositories SmartDukaan

Rev

Rev 24886 | Blame | Last modification | View Log | RSS feed

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

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

import com.spice.profitmandi.dao.enumuration.dtr.RewardType;

@Entity
@Table(name = "fofo.target_slab", schema = "fofo")
public class TargetSlab {

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

        @Column(name = "slab_name")
        private String slabName;

        @Column(name = "min_target_percentage")
        private float minTargetPercentage;

        @Column(name = "max_target_percentage")
        private float maxTargetPercentage;

        // 100 has special meaning i.e. special gift
        @Column(name = "reward_percentage")
        private float rewardPercentage;

        @Column(name = "target_id")
        private int targetId;

        @Column(name = "reward_type")
        private RewardType rewardType;

        public String getRewardString() {
                if (rewardType.equals(RewardType.SPECIAL)) {
                        return "Actuals + Special Gift";
                } else {
                        if (rewardPercentage == 0) {
                                return "Margins on Actual";
                        }
                        return String.format("%s %.1f%% on %s", (rewardPercentage < 0) ? "Reduction of" : "Extra", Math.abs(rewardPercentage),
                                        rewardType.getValue());
                }
        }

        public TargetSlab(String slabName, float minTargetPercentage, float maxTargetPercentage, RewardType rewardType,
                        float rewardPercentage) {
                super();
                this.slabName = slabName;
                this.minTargetPercentage = minTargetPercentage;
                this.maxTargetPercentage = maxTargetPercentage;
                this.rewardPercentage = rewardPercentage;
                this.rewardType = rewardType;
        }

        public TargetSlab() {

        }

        public int getId() {
                return id;
        }

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

        public String getSlabName() {
                return slabName;
        }

        public void setSlabName(String slabName) {
                this.slabName = slabName;
        }

        public float getMinTargetPercentage() {
                return minTargetPercentage;
        }

        public void setMinTargetPercentage(float minTargetPercentage) {
                this.minTargetPercentage = minTargetPercentage;
        }

        public float getMaxTargetPercentage() {
                return maxTargetPercentage;
        }

        public void setMaxTargetPercentage(float maxTargetPercentage) {
                this.maxTargetPercentage = maxTargetPercentage;
        }

        public float getRewardPercentage() {
                return rewardPercentage;
        }

        public void setRewardPercentage(float rewardPercentage) {
                this.rewardPercentage = rewardPercentage;
        }

        public int getTargetId() {
                return targetId;
        }

        public void setTargetId(int targetId) {
                this.targetId = targetId;
        }

}