| 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 |
|
| 23968 |
amit.gupta |
93 |
@Transient
|
|
|
94 |
private String description;
|
| 23819 |
govind |
95 |
|
| 23968 |
amit.gupta |
96 |
public String getDescription() {
|
|
|
97 |
return description;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public void setDescription(String description) {
|
|
|
101 |
this.description = description;
|
|
|
102 |
}
|
|
|
103 |
|
| 24049 |
amit.gupta |
104 |
public float getMop() {
|
|
|
105 |
return mop;
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
public void setMop(float mop) {
|
|
|
109 |
this.mop = mop;
|
|
|
110 |
}
|
|
|
111 |
|
| 23968 |
amit.gupta |
112 |
public float getNewDp() {
|
|
|
113 |
return newDp;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
public void setNewDp(float newDp) {
|
|
|
117 |
this.newDp = newDp;
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
public float getOldDp() {
|
|
|
121 |
return oldDp;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
public void setOldDp(float oldDp) {
|
|
|
125 |
this.oldDp = oldDp;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
public float getTp() {
|
|
|
129 |
return tp;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
public void setTp(float tp) {
|
|
|
133 |
this.tp = tp;
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
public float getNlc() {
|
|
|
137 |
return nlc;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
public void setNlc(float nlc) {
|
|
|
141 |
this.nlc = nlc;
|
|
|
142 |
}
|
|
|
143 |
|
| 30958 |
amit.gupta |
144 |
|
| 23819 |
govind |
145 |
@Column(name = "credit_note_number")
|
|
|
146 |
private String creditNoteNumber;
|
|
|
147 |
|
| 23110 |
ashik.ali |
148 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
149 |
@Column(name = "process_timestamp")
|
| 23874 |
amit.gupta |
150 |
private LocalDateTime processTimestamp;
|
| 23819 |
govind |
151 |
|
| 26400 |
amit.gupta |
152 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
153 |
@Column(name = "complete_timestamp")
|
|
|
154 |
private LocalDateTime completeTimestamp;
|
| 28443 |
tejbeer |
155 |
|
| 23823 |
amit.gupta |
156 |
@Column(name = "price_drop_in")
|
|
|
157 |
private float priceDropIn;
|
| 28443 |
tejbeer |
158 |
|
| 23823 |
amit.gupta |
159 |
@Column(name = "partner_payout")
|
|
|
160 |
private float partnerPayout;
|
| 23819 |
govind |
161 |
|
|
|
162 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
163 |
@Column(name = "created_on")
|
|
|
164 |
private LocalDateTime createdOn = LocalDateTime.now();
|
|
|
165 |
|
|
|
166 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
167 |
@Column(name = "affected_on")
|
| 23874 |
amit.gupta |
168 |
private LocalDateTime affectedOn = LocalDateTime.now();
|
| 23819 |
govind |
169 |
|
|
|
170 |
@Convert(converter = LocalDateTimeAttributeConverter.class)
|
|
|
171 |
@Column(name = "credit_note_date")
|
| 23874 |
amit.gupta |
172 |
private LocalDateTime creditNoteDate;
|
| 23819 |
govind |
173 |
|
| 23110 |
ashik.ali |
174 |
public int getId() {
|
|
|
175 |
return id;
|
|
|
176 |
}
|
| 23819 |
govind |
177 |
|
| 23110 |
ashik.ali |
178 |
public void setId(int id) {
|
|
|
179 |
this.id = id;
|
|
|
180 |
}
|
| 23819 |
govind |
181 |
|
| 23823 |
amit.gupta |
182 |
public float getPriceDropIn() {
|
|
|
183 |
return priceDropIn;
|
|
|
184 |
}
|
|
|
185 |
|
|
|
186 |
public void setPriceDropIn(float priceDropIn) {
|
|
|
187 |
this.priceDropIn = priceDropIn;
|
|
|
188 |
}
|
|
|
189 |
|
| 23951 |
amit.gupta |
190 |
public int getCatalogItemId() {
|
|
|
191 |
return catalogItemId;
|
| 23110 |
ashik.ali |
192 |
}
|
| 23819 |
govind |
193 |
|
| 23951 |
amit.gupta |
194 |
public void setCatalogItemId(int catalogItemId) {
|
|
|
195 |
this.catalogItemId = catalogItemId;
|
| 23110 |
ashik.ali |
196 |
}
|
| 23819 |
govind |
197 |
|
| 23951 |
amit.gupta |
198 |
@Override
|
|
|
199 |
public String toString() {
|
| 28568 |
amit.gupta |
200 |
return "PriceDrop [id=" + id + ", catalogItemId=" + catalogItemId + ", amount=" + amount + ", newDp=" + newDp
|
|
|
201 |
+ ", oldDp=" + oldDp + ", mop=" + mop + ", tp=" + tp + ", nlc=" + nlc + ", description=" + description
|
|
|
202 |
+ ", creditNoteNumber=" + creditNoteNumber + ", processTimestamp=" + processTimestamp
|
|
|
203 |
+ ", completeTimestamp=" + completeTimestamp + ", priceDropIn=" + priceDropIn + ", partnerPayout="
|
|
|
204 |
+ partnerPayout + ", createdOn=" + createdOn + ", affectedOn=" + affectedOn + ", creditNoteDate="
|
|
|
205 |
+ creditNoteDate + "]";
|
| 23951 |
amit.gupta |
206 |
}
|
|
|
207 |
|
| 23110 |
ashik.ali |
208 |
public float getAmount() {
|
|
|
209 |
return amount;
|
|
|
210 |
}
|
| 23819 |
govind |
211 |
|
| 23110 |
ashik.ali |
212 |
public void setAmount(float amount) {
|
|
|
213 |
this.amount = amount;
|
|
|
214 |
}
|
| 23819 |
govind |
215 |
|
| 23110 |
ashik.ali |
216 |
public LocalDateTime getProcessTimestamp() {
|
|
|
217 |
return processTimestamp;
|
|
|
218 |
}
|
| 23819 |
govind |
219 |
|
| 23110 |
ashik.ali |
220 |
public void setProcessTimestamp(LocalDateTime processTimestamp) {
|
|
|
221 |
this.processTimestamp = processTimestamp;
|
|
|
222 |
}
|
| 23819 |
govind |
223 |
|
|
|
224 |
public String getCreditNoteNumber() {
|
|
|
225 |
return creditNoteNumber;
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
public void setCreditNoteNumber(String creditNoteNumber) {
|
|
|
229 |
this.creditNoteNumber = creditNoteNumber;
|
|
|
230 |
}
|
|
|
231 |
|
|
|
232 |
public LocalDateTime getCreatedOn() {
|
|
|
233 |
return createdOn;
|
|
|
234 |
}
|
|
|
235 |
|
|
|
236 |
public void setCreatedOn(LocalDateTime createdOn) {
|
|
|
237 |
this.createdOn = createdOn;
|
|
|
238 |
}
|
|
|
239 |
|
| 23874 |
amit.gupta |
240 |
public LocalDateTime getAffectedOn() {
|
|
|
241 |
return affectedOn;
|
| 23819 |
govind |
242 |
}
|
|
|
243 |
|
| 23874 |
amit.gupta |
244 |
public void setAffectedOn(LocalDateTime affectedOn) {
|
|
|
245 |
this.affectedOn = affectedOn;
|
| 23819 |
govind |
246 |
}
|
|
|
247 |
|
|
|
248 |
public LocalDateTime getCreditNoteDate() {
|
|
|
249 |
return creditNoteDate;
|
|
|
250 |
}
|
|
|
251 |
|
|
|
252 |
public void setCreditNoteDate(LocalDateTime creditNoteDate) {
|
|
|
253 |
this.creditNoteDate = creditNoteDate;
|
|
|
254 |
}
|
|
|
255 |
|
| 23823 |
amit.gupta |
256 |
public float getPartnerPayout() {
|
|
|
257 |
return partnerPayout;
|
| 23819 |
govind |
258 |
}
|
|
|
259 |
|
| 26340 |
amit.gupta |
260 |
public float getDropAmount() {
|
|
|
261 |
return oldDp - newDp;
|
|
|
262 |
}
|
| 28443 |
tejbeer |
263 |
|
| 30958 |
amit.gupta |
264 |
public float getAutoPartnerPayout(LocalDateTime creditDate) {
|
|
|
265 |
if (creditDate.toLocalDate().isAfter(LocalDate.of(2022, 9, 15))) {
|
|
|
266 |
return this.getDropAmount();
|
| 26332 |
amit.gupta |
267 |
} else {
|
| 30958 |
amit.gupta |
268 |
if (this.getPartnerPayout() == 0) {
|
|
|
269 |
return this.getDropAmount() / 1.18f;
|
|
|
270 |
} else {
|
|
|
271 |
return this.getPartnerPayout();
|
|
|
272 |
}
|
| 26332 |
amit.gupta |
273 |
}
|
|
|
274 |
}
|
| 28443 |
tejbeer |
275 |
|
| 23823 |
amit.gupta |
276 |
public void setPartnerPayout(float partnerPayout) {
|
|
|
277 |
this.partnerPayout = partnerPayout;
|
| 23819 |
govind |
278 |
}
|
|
|
279 |
|
|
|
280 |
public String getDate(LocalDateTime ldt) {
|
|
|
281 |
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
|
|
282 |
String s = dtf.format(ldt);
|
|
|
283 |
return s;
|
|
|
284 |
}
|
|
|
285 |
|
| 26400 |
amit.gupta |
286 |
public LocalDateTime getCompleteTimestamp() {
|
|
|
287 |
return completeTimestamp;
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
public void setCompleteTimestamp(LocalDateTime completeTimestamp) {
|
|
|
291 |
this.completeTimestamp = completeTimestamp;
|
|
|
292 |
}
|
|
|
293 |
|
| 23110 |
ashik.ali |
294 |
@Override
|
|
|
295 |
public int hashCode() {
|
|
|
296 |
final int prime = 31;
|
|
|
297 |
int result = 1;
|
|
|
298 |
result = prime * result + id;
|
|
|
299 |
return result;
|
|
|
300 |
}
|
| 23819 |
govind |
301 |
|
| 23110 |
ashik.ali |
302 |
@Override
|
|
|
303 |
public boolean equals(Object obj) {
|
|
|
304 |
if (this == obj)
|
|
|
305 |
return true;
|
|
|
306 |
if (obj == null)
|
|
|
307 |
return false;
|
|
|
308 |
if (getClass() != obj.getClass())
|
|
|
309 |
return false;
|
|
|
310 |
PriceDrop other = (PriceDrop) obj;
|
|
|
311 |
if (id != other.id)
|
|
|
312 |
return false;
|
|
|
313 |
return true;
|
|
|
314 |
}
|
| 23819 |
govind |
315 |
|
| 23110 |
ashik.ali |
316 |
}
|