| 23110 |
ashik.ali |
1 |
package com.spice.profitmandi.dao.entity.transaction;
|
|
|
2 |
|
|
|
3 |
import java.io.Serializable;
|
|
|
4 |
import java.time.LocalDateTime;
|
| 23819 |
govind |
5 |
import java.time.format.DateTimeFormatter;
|
| 28641 |
amit.gupta |
6 |
import java.util.ArrayList;
|
|
|
7 |
import java.util.List;
|
| 23110 |
ashik.ali |
8 |
|
|
|
9 |
import javax.persistence.Column;
|
|
|
10 |
import javax.persistence.Convert;
|
|
|
11 |
import javax.persistence.Entity;
|
|
|
12 |
import javax.persistence.GeneratedValue;
|
|
|
13 |
import javax.persistence.GenerationType;
|
|
|
14 |
import javax.persistence.Id;
|
| 28443 |
tejbeer |
15 |
import javax.persistence.NamedQueries;
|
|
|
16 |
import javax.persistence.NamedQuery;
|
| 23110 |
ashik.ali |
17 |
import javax.persistence.Table;
|
| 23968 |
amit.gupta |
18 |
import javax.persistence.Transient;
|
| 23110 |
ashik.ali |
19 |
|
|
|
20 |
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
|
|
|
21 |
|
|
|
22 |
/**
|
| 23819 |
govind |
23 |
* This class basically contains details
|
| 23110 |
ashik.ali |
24 |
*
|
|
|
25 |
* @author ashikali
|
|
|
26 |
*
|
|
|
27 |
*/
|
| 23968 |
amit.gupta |
28 |
/**
|
|
|
29 |
* @author amit
|
|
|
30 |
*
|
|
|
31 |
*/
|
| 23110 |
ashik.ali |
32 |
@Entity
|
| 23819 |
govind |
33 |
@Table(name = "transaction.price_drop", schema = "transaction")
|
| 28443 |
tejbeer |
34 |
|
|
|
35 |
@NamedQueries({
|
|
|
36 |
@NamedQuery(name = "PriceDrop.selectBrandPendingPriceDropByYearMonth", query = "select new com.spice.profitmandi.dao.model.PriceDropYearMonthModel(i.brand, "
|
|
|
37 |
+ " DATE_FORMAT(pd.affectedOn, '%m-%Y'),sum(cast(pd.amount As int)) ) from PriceDrop pd join PriceDropIMEI pdi on"
|
|
|
38 |
+ " (pd.id = pdi.priceDropId) join InventoryItem it on (pdi.imei = it.serialNumber and pdi.partnerId=it.fofoId)"
|
|
|
39 |
+ " join Item i on i.id = it.itemId where pdi.status ='PENDING' and pdi.partnerId = :fofoId and "
|
|
|
40 |
+ " pd.amount > 0 and pd.affectedOn >= :startDate group by i.brand, DATE_FORMAT(pd.affectedOn, '%m-%Y')"),
|
|
|
41 |
|
| 28641 |
amit.gupta |
42 |
@NamedQuery(name = "PriceDrop.selectSixMonthBrandPriceDropByYearMonth", query = "select new com.spice.profitmandi.dao.model.PriceDropBrandModel(i.brand, "
|
|
|
43 |
+ " sum(cast(pd.amount As int)) ) from PriceDrop pd join PriceDropIMEI pdi on"
|
|
|
44 |
+ " (pd.id = pdi.priceDropId) join InventoryItem it on (pdi.imei = it.serialNumber and pdi.partnerId=it.fofoId)"
|
|
|
45 |
+ " join Item i on i.id = it.itemId where pdi.status ='PENDING' and pdi.partnerId = :fofoId and "
|
|
|
46 |
+ " pd.amount > 0 and pd.affectedOn >= :startDate and pd.affectedOn <= :endDate group by i.brand"),
|
|
|
47 |
|
|
|
48 |
|
| 28455 |
tejbeer |
49 |
@NamedQuery(name = "PriceDrop.selectBrandPendingPriceDropWithDetailsByYearMonth", query = "select new com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel(i.brand, "
|
|
|
50 |
+ " i.modelName,i.modelNumber,cast(pd.amount As int),pdi.imei ) from PriceDrop pd join PriceDropIMEI pdi on"
|
|
|
51 |
+ " (pd.id = pdi.priceDropId) join InventoryItem it on (pdi.imei = it.serialNumber and pdi.partnerId=it.fofoId)"
|
|
|
52 |
+ " join Item i on i.id = it.itemId where pdi.status ='PENDING' and pdi.partnerId = :fofoId and "
|
|
|
53 |
+ " pd.amount > 0 and i.brand = :brand and DATE_FORMAT(pd.affectedOn, '%m-%Y') = :yearMonthValue"),
|
| 28641 |
amit.gupta |
54 |
|
|
|
55 |
@NamedQuery(name = "PriceDrop.selectBrandPendingPriceDropWithDetailsAndSixMonth", query = "select new com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel(i.brand, "
|
|
|
56 |
+ " i.modelName,i.modelNumber,cast(pd.amount As int),pdi.imei ) from PriceDrop pd join PriceDropIMEI pdi on"
|
|
|
57 |
+ " (pd.id = pdi.priceDropId) join InventoryItem it on (pdi.imei = it.serialNumber and pdi.partnerId=it.fofoId)"
|
|
|
58 |
+ " join Item i on i.id = it.itemId where pdi.status ='PENDING' and pdi.partnerId = :fofoId and "
|
|
|
59 |
+ " pd.amount > 0 and i.brand = :brand and pd.affectedOn >= :startDate and pd.affectedOn <= :endDate"),
|
| 28455 |
tejbeer |
60 |
|
| 28641 |
amit.gupta |
61 |
|
| 28443 |
tejbeer |
62 |
})
|
| 23819 |
govind |
63 |
public class PriceDrop implements Serializable {
|
|
|
64 |
|
| 23110 |
ashik.ali |
65 |
private static final long serialVersionUID = 1L;
|
| 23819 |
govind |
66 |
|
| 23110 |
ashik.ali |
67 |
public PriceDrop() {
|
|
|
68 |
}
|
| 23819 |
govind |
69 |
|
| 23110 |
ashik.ali |
70 |
@Id
|
| 23819 |
govind |
71 |
@Column(name = "id")
|
| 23110 |
ashik.ali |
72 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
73 |
private int id;
|
| 23819 |
govind |
74 |
|
| 23951 |
amit.gupta |
75 |
@Column(name = "catalog_id")
|
|
|
76 |
private int catalogItemId;
|
| 24410 |
amit.gupta |
77 |
|
|
|
78 |
@Column(name = "amount")
|
|
|
79 |
private float amount;
|
| 28443 |
tejbeer |
80 |
|
|
|
81 |
@Column(name = "new_dp")
|
| 24410 |
amit.gupta |
82 |
private float newDp;
|
| 28443 |
tejbeer |
83 |
|
|
|
84 |
@Column(name = "old_dp")
|
| 24410 |
amit.gupta |
85 |
private float oldDp;
|
| 28443 |
tejbeer |
86 |
|
|
|
87 |
@Column(name = "mop")
|
| 24410 |
amit.gupta |
88 |
private float mop;
|
| 28443 |
tejbeer |
89 |
|
|
|
90 |
@Column(name = "tp")
|
| 24410 |
amit.gupta |
91 |
private float tp;
|
| 28443 |
tejbeer |
92 |
|
|
|
93 |
@Column(name = "nlc")
|
| 24410 |
amit.gupta |
94 |
private float nlc;
|
| 28443 |
tejbeer |
95 |
|
| 23968 |
amit.gupta |
96 |
@Transient
|
|
|
97 |
private String description;
|
| 23819 |
govind |
98 |
|
| 23968 |
amit.gupta |
99 |
public String getDescription() {
|
|
|
100 |
return description;
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public void setDescription(String description) {
|
|
|
104 |
this.description = description;
|
|
|
105 |
}
|
|
|
106 |
|
| 24049 |
amit.gupta |
107 |
public float getMop() {
|
|
|
108 |
return mop;
|
|
|
109 |
}
|
|
|
110 |
|
|
|
111 |
public void setMop(float mop) {
|
|
|
112 |
this.mop = mop;
|
|
|
113 |
}
|
|
|
114 |
|
| 23968 |
amit.gupta |
115 |
public float getNewDp() {
|
|
|
116 |
return newDp;
|
|
|
117 |
}
|
|
|
118 |
|
|
|
119 |
public void setNewDp(float newDp) {
|
|
|
120 |
this.newDp = newDp;
|
|
|
121 |
}
|
|
|
122 |
|
|
|
123 |
public float getOldDp() {
|
|
|
124 |
return oldDp;
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public void setOldDp(float oldDp) {
|
|
|
128 |
this.oldDp = oldDp;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
public float getTp() {
|
|
|
132 |
return tp;
|
|
|
133 |
}
|
|
|
134 |
|
|
|
135 |
public void setTp(float tp) {
|
|
|
136 |
this.tp = tp;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public float getNlc() {
|
|
|
140 |
return nlc;
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
public void setNlc(float nlc) {
|
|
|
144 |
this.nlc = nlc;
|
|
|
145 |
}
|
|
|
146 |
|
| 28641 |
amit.gupta |
147 |
|
| 23819 |
govind |
148 |
@Column(name = "credit_note_number")
|
|
|
149 |
private String creditNoteNumber;
|
|
|
150 |
|
| 23110 |
ashik.ali |
151 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
152 |
@Column(name = "process_timestamp")
|
| 23874 |
amit.gupta |
153 |
private LocalDateTime processTimestamp;
|
| 23819 |
govind |
154 |
|
| 26400 |
amit.gupta |
155 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
156 |
@Column(name = "complete_timestamp")
|
|
|
157 |
private LocalDateTime completeTimestamp;
|
| 28443 |
tejbeer |
158 |
|
| 23823 |
amit.gupta |
159 |
@Column(name = "price_drop_in")
|
|
|
160 |
private float priceDropIn;
|
| 28443 |
tejbeer |
161 |
|
| 23823 |
amit.gupta |
162 |
@Column(name = "partner_payout")
|
|
|
163 |
private float partnerPayout;
|
| 23819 |
govind |
164 |
|
|
|
165 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
166 |
@Column(name = "created_on")
|
|
|
167 |
private LocalDateTime createdOn = LocalDateTime.now();
|
|
|
168 |
|
|
|
169 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
170 |
@Column(name = "affected_on")
|
| 23874 |
amit.gupta |
171 |
private LocalDateTime affectedOn = LocalDateTime.now();
|
| 23819 |
govind |
172 |
|
|
|
173 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
174 |
@Column(name = "credit_note_date")
|
| 23874 |
amit.gupta |
175 |
private LocalDateTime creditNoteDate;
|
| 23819 |
govind |
176 |
|
| 23110 |
ashik.ali |
177 |
public int getId() {
|
|
|
178 |
return id;
|
|
|
179 |
}
|
| 23819 |
govind |
180 |
|
| 23110 |
ashik.ali |
181 |
public void setId(int id) {
|
|
|
182 |
this.id = id;
|
|
|
183 |
}
|
| 23819 |
govind |
184 |
|
| 23823 |
amit.gupta |
185 |
public float getPriceDropIn() {
|
|
|
186 |
return priceDropIn;
|
|
|
187 |
}
|
|
|
188 |
|
|
|
189 |
public void setPriceDropIn(float priceDropIn) {
|
|
|
190 |
this.priceDropIn = priceDropIn;
|
|
|
191 |
}
|
|
|
192 |
|
| 23951 |
amit.gupta |
193 |
public int getCatalogItemId() {
|
|
|
194 |
return catalogItemId;
|
| 23110 |
ashik.ali |
195 |
}
|
| 23819 |
govind |
196 |
|
| 23951 |
amit.gupta |
197 |
public void setCatalogItemId(int catalogItemId) {
|
|
|
198 |
this.catalogItemId = catalogItemId;
|
| 23110 |
ashik.ali |
199 |
}
|
| 23819 |
govind |
200 |
|
| 23951 |
amit.gupta |
201 |
@Override
|
|
|
202 |
public String toString() {
|
| 28568 |
amit.gupta |
203 |
return "PriceDrop [id=" + id + ", catalogItemId=" + catalogItemId + ", amount=" + amount + ", newDp=" + newDp
|
|
|
204 |
+ ", oldDp=" + oldDp + ", mop=" + mop + ", tp=" + tp + ", nlc=" + nlc + ", description=" + description
|
|
|
205 |
+ ", creditNoteNumber=" + creditNoteNumber + ", processTimestamp=" + processTimestamp
|
|
|
206 |
+ ", completeTimestamp=" + completeTimestamp + ", priceDropIn=" + priceDropIn + ", partnerPayout="
|
|
|
207 |
+ partnerPayout + ", createdOn=" + createdOn + ", affectedOn=" + affectedOn + ", creditNoteDate="
|
|
|
208 |
+ creditNoteDate + "]";
|
| 23951 |
amit.gupta |
209 |
}
|
|
|
210 |
|
| 23110 |
ashik.ali |
211 |
public float getAmount() {
|
|
|
212 |
return amount;
|
|
|
213 |
}
|
| 23819 |
govind |
214 |
|
| 23110 |
ashik.ali |
215 |
public void setAmount(float amount) {
|
|
|
216 |
this.amount = amount;
|
|
|
217 |
}
|
| 23819 |
govind |
218 |
|
| 23110 |
ashik.ali |
219 |
public LocalDateTime getProcessTimestamp() {
|
|
|
220 |
return processTimestamp;
|
|
|
221 |
}
|
| 23819 |
govind |
222 |
|
| 23110 |
ashik.ali |
223 |
public void setProcessTimestamp(LocalDateTime processTimestamp) {
|
|
|
224 |
this.processTimestamp = processTimestamp;
|
|
|
225 |
}
|
| 23819 |
govind |
226 |
|
|
|
227 |
public String getCreditNoteNumber() {
|
|
|
228 |
return creditNoteNumber;
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
public void setCreditNoteNumber(String creditNoteNumber) {
|
|
|
232 |
this.creditNoteNumber = creditNoteNumber;
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
public LocalDateTime getCreatedOn() {
|
|
|
236 |
return createdOn;
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
public void setCreatedOn(LocalDateTime createdOn) {
|
|
|
240 |
this.createdOn = createdOn;
|
|
|
241 |
}
|
|
|
242 |
|
| 23874 |
amit.gupta |
243 |
public LocalDateTime getAffectedOn() {
|
|
|
244 |
return affectedOn;
|
| 23819 |
govind |
245 |
}
|
|
|
246 |
|
| 23874 |
amit.gupta |
247 |
public void setAffectedOn(LocalDateTime affectedOn) {
|
|
|
248 |
this.affectedOn = affectedOn;
|
| 23819 |
govind |
249 |
}
|
|
|
250 |
|
|
|
251 |
public LocalDateTime getCreditNoteDate() {
|
|
|
252 |
return creditNoteDate;
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
public void setCreditNoteDate(LocalDateTime creditNoteDate) {
|
|
|
256 |
this.creditNoteDate = creditNoteDate;
|
|
|
257 |
}
|
|
|
258 |
|
| 23823 |
amit.gupta |
259 |
public float getPartnerPayout() {
|
|
|
260 |
return partnerPayout;
|
| 23819 |
govind |
261 |
}
|
|
|
262 |
|
| 26340 |
amit.gupta |
263 |
public float getDropAmount() {
|
|
|
264 |
return oldDp - newDp;
|
|
|
265 |
}
|
| 28443 |
tejbeer |
266 |
|
| 26332 |
amit.gupta |
267 |
public float getAutoPartnerPayout() {
|
| 28443 |
tejbeer |
268 |
if (this.getPartnerPayout() == 0) {
|
|
|
269 |
return this.getDropAmount() / 1.18f;
|
| 26332 |
amit.gupta |
270 |
} else {
|
|
|
271 |
return this.getPartnerPayout();
|
|
|
272 |
}
|
|
|
273 |
}
|
| 28443 |
tejbeer |
274 |
|
| 23823 |
amit.gupta |
275 |
public void setPartnerPayout(float partnerPayout) {
|
|
|
276 |
this.partnerPayout = partnerPayout;
|
| 23819 |
govind |
277 |
}
|
|
|
278 |
|
|
|
279 |
public String getDate(LocalDateTime ldt) {
|
|
|
280 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
|
281 |
String s = dtf.format(ldt);
|
|
|
282 |
return s;
|
|
|
283 |
}
|
|
|
284 |
|
| 26400 |
amit.gupta |
285 |
public LocalDateTime getCompleteTimestamp() {
|
|
|
286 |
return completeTimestamp;
|
|
|
287 |
}
|
|
|
288 |
|
|
|
289 |
public void setCompleteTimestamp(LocalDateTime completeTimestamp) {
|
|
|
290 |
this.completeTimestamp = completeTimestamp;
|
|
|
291 |
}
|
|
|
292 |
|
| 23110 |
ashik.ali |
293 |
@Override
|
|
|
294 |
public int hashCode() {
|
|
|
295 |
final int prime = 31;
|
|
|
296 |
int result = 1;
|
|
|
297 |
result = prime * result + id;
|
|
|
298 |
return result;
|
|
|
299 |
}
|
| 23819 |
govind |
300 |
|
| 23110 |
ashik.ali |
301 |
@Override
|
|
|
302 |
public boolean equals(Object obj) {
|
|
|
303 |
if (this == obj)
|
|
|
304 |
return true;
|
|
|
305 |
if (obj == null)
|
|
|
306 |
return false;
|
|
|
307 |
if (getClass() != obj.getClass())
|
|
|
308 |
return false;
|
|
|
309 |
PriceDrop other = (PriceDrop) obj;
|
|
|
310 |
if (id != other.id)
|
|
|
311 |
return false;
|
|
|
312 |
return true;
|
|
|
313 |
}
|
| 23819 |
govind |
314 |
|
| 23110 |
ashik.ali |
315 |
}
|