Subversion Repositories SmartDukaan

Rev

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

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