Subversion Repositories SmartDukaan

Rev

Rev 33441 | Rev 33745 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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