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