Subversion Repositories SmartDukaan

Rev

Rev 33736 | Rev 35600 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33736 Rev 33745
Line 7... Line 7...
7
 
7
 
8
import java.time.LocalDateTime;
8
import java.time.LocalDateTime;
9
import java.util.List;
9
import java.util.List;
10
 
10
 
11
public class ItemCriteriaPayout {
11
public class ItemCriteriaPayout {
12
	private AmountType amountType;
12
    private AmountType amountType;
13
	private ItemCriteria itemCriteria;
13
    private ItemCriteria itemCriteria;
14
	private LocalDateTime startDate;
14
    private LocalDateTime startDate;
15
	private LocalDateTime endDate;
15
    private LocalDateTime endDate;
16
	private List<PayoutSlab> payoutSlabs;
16
    private List<PayoutSlab> payoutSlabs;
17
	private String itemCriteriaString;
17
    private String itemCriteriaString;
18
	private long achievedValue;
18
    private long achievedValue;
19
	private long shortValue;
19
    private long shortValue;
20
	private PayoutSlab currentSlab;
20
    private PayoutSlab currentSlab;
21
	private PayoutSlab nextSlab;
21
    private PayoutSlab nextSlab;
22
 
22
 
23
	@JsonIgnore
23
    @JsonIgnore
24
	public String getCurretPayoutString() {
24
    public String getCurretPayoutString() {
25
		String templateString = null;
25
        String templateString = null;
26
		if (this.getAmountType().equals(AmountType.FIXED)) {
26
        if (this.getAmountType().equals(AmountType.FIXED)) {
27
			templateString = "Rs. %f per pc";
27
            templateString = "Rs. %f per pc";
28
		} else if (this.getAmountType().equals(AmountType.PERCENTAGE)) {
28
        } else if (this.getAmountType().equals(AmountType.PERCENTAGE)) {
29
			templateString = "%f %%";
29
            templateString = "%f %%";
30
		} else {
30
        } else {
31
			templateString = "%f %%";
31
            templateString = "%f %%";
32
		}
32
        }
33
		return String.format(templateString, this.getCurrentSlab().getPayoutAmount());
33
        return String.format(templateString, this.getCurrentSlab().getPayoutAmount());
34
	}
34
    }
35
 
35
 
36
	public LocalDateTime getStartDate() {
36
    public LocalDateTime getStartDate() {
37
		return startDate;
37
        return startDate;
38
	}
38
    }
39
 
39
 
40
	public void setStartDate(LocalDateTime startDate) {
40
    public void setStartDate(LocalDateTime startDate) {
41
		this.startDate = startDate;
41
        this.startDate = startDate;
42
	}
42
    }
43
 
43
 
44
	public LocalDateTime getEndDate() {
44
    public LocalDateTime getEndDate() {
45
		return endDate;
45
        return endDate;
46
	}
46
    }
47
 
47
 
48
	public void setEndDate(LocalDateTime endDate) {
48
    public void setEndDate(LocalDateTime endDate) {
49
		this.endDate = endDate;
49
        this.endDate = endDate;
50
	}
50
    }
51
 
51
 
52
	public long getShortValue() {
52
    public long getShortValue() {
53
		return shortValue;
53
        return shortValue;
54
	}
54
    }
55
 
55
 
56
 
56
 
57
	public void setShortValue(long shortValue) {
57
    public void setShortValue(long shortValue) {
58
		this.shortValue = shortValue;
58
        this.shortValue = shortValue;
59
	}
59
    }
60
 
60
 
61
 
61
 
62
	public PayoutSlab getCurrentSlab() {
62
    public PayoutSlab getCurrentSlab() {
63
		return currentSlab;
63
        return currentSlab;
64
	}
64
    }
65
 
65
 
66
 
66
 
67
	public void setCurrentSlab(PayoutSlab currentSlab) {
67
    public void setCurrentSlab(PayoutSlab currentSlab) {
68
		this.currentSlab = currentSlab;
68
        this.currentSlab = currentSlab;
69
	}
69
    }
70
 
70
 
71
 
71
 
72
	public PayoutSlab getNextSlab() {
72
    public PayoutSlab getNextSlab() {
73
		return nextSlab;
73
        return nextSlab;
74
	}
74
    }
75
 
75
 
76
 
76
 
77
	public void setNextSlab(PayoutSlab nextSlab) {
77
    public void setNextSlab(PayoutSlab nextSlab) {
78
		this.nextSlab = nextSlab;
78
        this.nextSlab = nextSlab;
79
	}
79
    }
80
 
80
 
81
 
81
 
82
	public ItemCriteria getItemCriteria() {
82
    public ItemCriteria getItemCriteria() {
83
        return itemCriteria;
83
        return itemCriteria;
84
    }
84
    }
85
 
85
 
86
 
86
 
87
	public AmountType getAmountType() {
87
    public AmountType getAmountType() {
88
		return amountType;
88
        return amountType;
89
	}
89
    }
90
 
-
 
91
 
-
 
92
 
90
 
93
	public void setAmountType(AmountType amountType) {
-
 
94
		this.amountType = amountType;
-
 
95
	}
-
 
96
 
91
 
-
 
92
    public void setAmountType(AmountType amountType) {
-
 
93
        this.amountType = amountType;
-
 
94
    }
97
 
95
 
98
 
96
 
99
	public long getAchievedValue() {
97
    public long getAchievedValue() {
100
		return achievedValue;
98
        return achievedValue;
101
	}
99
    }
102
 
100
 
103
 
101
 
104
	public void setAchievedValue(long achievedValue) {
102
    public void setAchievedValue(long achievedValue) {
105
		this.achievedValue = achievedValue;
103
        this.achievedValue = achievedValue;
106
	}
104
    }
107
 
105
 
108
 
106
 
109
	public String getItemCriteriaString() {
107
    public String getItemCriteriaString() {
110
        return itemCriteriaString;
108
        return itemCriteriaString;
111
    }
109
    }
112
 
110
 
113
    public void setItemCriteriaString(String itemCriteriaString) {
111
    public void setItemCriteriaString(String itemCriteriaString) {
114
        this.itemCriteriaString = itemCriteriaString;
112
        this.itemCriteriaString = itemCriteriaString;
115
    }
113
    }
116
 
114
 
117
    @Override
115
    @Override
118
	public int hashCode() {
116
    public int hashCode() {
119
		final int prime = 31;
117
        final int prime = 31;
120
		int result = 1;
118
        int result = 1;
121
		result = prime * result + ((amountType == null) ? 0 : amountType.hashCode());
119
        result = prime * result + ((amountType == null) ? 0 : amountType.hashCode());
122
		result = prime * result + ((currentSlab == null) ? 0 : currentSlab.hashCode());
120
        result = prime * result + ((currentSlab == null) ? 0 : currentSlab.hashCode());
123
		result = prime * result + ((itemCriteria == null) ? 0 : itemCriteria.hashCode());
121
        result = prime * result + ((itemCriteria == null) ? 0 : itemCriteria.hashCode());
124
		result = prime * result + ((itemCriteriaString == null) ? 0 : itemCriteriaString.hashCode());
122
        result = prime * result + ((itemCriteriaString == null) ? 0 : itemCriteriaString.hashCode());
125
		return result;
123
        return result;
126
	}
124
    }
127
 
-
 
128
 
125
 
129
 
126
 
130
	@Override
127
    @Override
131
	public boolean equals(Object obj) {
128
    public boolean equals(Object obj) {
132
		if (this == obj)
129
        if (this == obj)
133
			return true;
130
            return true;
134
		if (obj == null)
131
        if (obj == null)
135
			return false;
132
            return false;
136
		if (getClass() != obj.getClass())
133
        if (getClass() != obj.getClass())
137
			return false;
134
            return false;
138
		ItemCriteriaPayout other = (ItemCriteriaPayout) obj;
135
        ItemCriteriaPayout other = (ItemCriteriaPayout) obj;
139
		if (amountType != other.amountType)
136
        if (amountType != other.amountType)
140
			return false;
137
            return false;
141
		if (currentSlab == null) {
138
        if (currentSlab == null) {
142
			if (other.currentSlab != null)
139
            if (other.currentSlab != null)
143
				return false;
140
                return false;
144
		} else if (!currentSlab.equals(other.currentSlab))
141
        } else if (!currentSlab.equals(other.currentSlab))
145
			return false;
142
            return false;
146
		if (itemCriteria == null) {
143
        if (itemCriteria == null) {
147
			if (other.itemCriteria != null)
144
            if (other.itemCriteria != null)
148
				return false;
145
                return false;
149
		} else if (!itemCriteria.equals(other.itemCriteria))
146
        } else if (!itemCriteria.equals(other.itemCriteria))
150
			return false;
147
            return false;
151
		if (itemCriteriaString == null) {
148
        if (itemCriteriaString == null) {
152
			if (other.itemCriteriaString != null)
149
            if (other.itemCriteriaString != null)
153
				return false;
150
                return false;
154
		} else if (!itemCriteriaString.equals(other.itemCriteriaString))
151
        } else if (!itemCriteriaString.equals(other.itemCriteriaString))
155
			return false;
152
            return false;
156
		return true;
153
        return true;
157
	}
154
    }
158
 
155
 
159
    public void setItemCriteria(ItemCriteria itemCriteria) {
156
    public void setItemCriteria(ItemCriteria itemCriteria) {
160
        this.itemCriteria = itemCriteria;
157
        this.itemCriteria = itemCriteria;
161
    }
158
    }
162
 
159
 
Line 167... Line 164...
167
    public void setPayoutSlabs(List<PayoutSlab> payoutSlabs) {
164
    public void setPayoutSlabs(List<PayoutSlab> payoutSlabs) {
168
        this.payoutSlabs = payoutSlabs;
165
        this.payoutSlabs = payoutSlabs;
169
    }
166
    }
170
 
167
 
171
 
168
 
-
 
169
    @Override
-
 
170
    public String toString() {
-
 
171
        return "ItemCriteriaPayout [amountType=" + amountType + ", itemCriteria=" + itemCriteria + ", payoutSlabs="
-
 
172
                + payoutSlabs + ", itemCriteriaString=" + itemCriteriaString + ", achievedValue=" + achievedValue
-
 
173
                + ", shortValue=" + shortValue + ", currentSlab=" + currentSlab + ", nextSlab=" + nextSlab + "]";
-
 
174
    }
-
 
175
 
-
 
176
    public boolean isWithinRange(LocalDateTime testDate) {
-
 
177
        if (startDate == null) return true;
-
 
178
        return !(testDate.isBefore(startDate) || testDate.isAfter(endDate));
-
 
179
    }
-
 
180
 
-
 
181
 
-
 
182
    public LocalDateTime getBillingEndDate() {
-
 
183
        return this.endDate == null ? null : this.endDate.plusDays(90);
-
 
184
    }
-
 
185
 
-
 
186
    public LocalDateTime getBillingStartDate() {
-
 
187
        return this.startDate == null ? null : this.startDate.minusDays(30);
-
 
188
    }
-
 
189
 
172
 
190
 
173
	@Override
-
 
174
	public String toString() {
-
 
175
		return "ItemCriteriaPayout [amountType=" + amountType + ", itemCriteria=" + itemCriteria + ", payoutSlabs="
-
 
176
				+ payoutSlabs + ", itemCriteriaString=" + itemCriteriaString + ", achievedValue=" + achievedValue
-
 
177
				+ ", shortValue=" + shortValue + ", currentSlab=" + currentSlab + ", nextSlab=" + nextSlab + "]";
-
 
178
	}
-
 
179
 
-
 
180
	public boolean isWithinRange(LocalDateTime testDate) {
-
 
181
		if(startDate==null) return true;
-
 
182
		return !(testDate.isBefore(startDate) || testDate.isAfter(endDate));
-
 
183
	}
-
 
184
 
-
 
185
 
-
 
186
	public LocalDateTime getBillingEndDate() {
-
 
187
		return this.endDate.plusDays(90);
-
 
188
	}
-
 
189
 
-
 
190
	public LocalDateTime getBillingStartDate() {
-
 
191
		return this.startDate.minusDays(30);
-
 
192
	}
-
 
193
    
-
 
194
    
-
 
195
    
-
 
196
    
-
 
197
}
191
}