Subversion Repositories SmartDukaan

Rev

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