Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
26332 amit.gupta 1
 
21714 ashik.ali 2
package com.spice.profitmandi.dao.entity.fofo;
21596 ashik.ali 3
 
35065 aman 4
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
5
 
6
import javax.persistence.*;
21596 ashik.ali 7
import java.io.Serializable;
23019 ashik.ali 8
import java.time.LocalDateTime;
21687 ashik.ali 9
import java.util.Set;
21596 ashik.ali 10
 
11
@Entity
31860 tejbeer 12
@Table(name = "fofo.fofo_order_item", uniqueConstraints = {
28566 tejbeer 13
		@UniqueConstraint(name = "UK_ORDER_ID_AND_ITEM_ID", columnNames = { "order_id", "item_id" }) })
31285 tejbeer 14
 
15
@NamedQueries({
16
		@NamedQuery(name = "FofoOrderItem.selectPartnerMonthlySale", query = "select new com.spice.profitmandi.dao.model.PartnerMonthlySaleModel(fo.fofoId, "
17
				+ " DATE_FORMAT(foi.createTimestamp, '%m-%Y'),sum(CAST(foi.quantity*foi.mop  AS int))) from  FofoOrder fo join FofoOrderItem foi on "
18
				+ " fo.id = foi.orderId  where fo.fofoId in :fofoIds and fo.cancelledTimestamp is null "
19
				+ " and foi.createTimestamp >= :startDate"
35065 aman 20
				+ " group by fo.fofoId,DATE_FORMAT(foi.createTimestamp, '%m-%Y')"),
21
		@NamedQuery(
22
				name = "FofoOrderItem.selectPartnerBrandItemMonthlySale",
23
				query = "select new com.spice.profitmandi.dao.model.BrandItemWisePartnerSaleModel( " +
24
						"foi.brand, " +
25
						"foi.modelName, " +
26
						"foi.modelNumber, " +
27
						"sum(foi.quantity)) " +
28
						"from FofoOrder fo " +
29
						"join FofoOrderItem foi on fo.id = foi.orderId " +
30
						"join Catalog ca on ca.modelNumber = foi.modelNumber " +
31
						"where fo.fofoId in :fofoIds " +
32
						"and foi.brand =:brand " +
33
						"and fo.cancelledTimestamp is null " +
34
						"and foi.createTimestamp >= :startDate " +
35084 aman 35
						"and foi.createTimestamp < :endDate " +
36
						"and ca.categoryId =  10006 " +
37
						"group by foi.brand, foi.modelName, foi.modelNumber,ca.categoryId, fo.fofoId,DATE_FORMAT(foi.createTimestamp, '%m-%Y')"
35065 aman 38
		),
35104 vikas 39
        @NamedQuery(
40
                name = "FofoOrderItem.selectBrandItemsByRegionAndDate",
41
                query = "select new com.spice.profitmandi.dao.model.EligibleRewardItemsModel(" +
42
                        "o.fofoId, pr.regionId, o.id, li.serialNumber, oi.brand, oi.dp, oi.quantity, i.catalogItemId) " +
43
                        "from ActivatedImei ai " +
44
                        "join FofoLineItem li on li.serialNumber = ai.serialNumber " +
45
                        "join FofoOrderItem oi on oi.id = li.fofoOrderItemId " +
46
                        "join FofoOrder o on o.id = oi.orderId " +
47
                        "join Item i on i.id = oi.itemId " +
48
                        "join PartnerRegion pr on pr.fofoId = o.fofoId " +
49
                        "where pr.regionId = :regionId " +
50
                        "and i.brand = :brand " +
51
                        "and o.createTimestamp between :orderStartDate and :orderEndDate " +
52
                        "and not exists (select 1 from SaleRewardHistory srh where srh.imeis = ai.serialNumber) " +
53
                        "group by li.serialNumber"
54
        )
35065 aman 55
 
56
})
28566 tejbeer 57
public class FofoOrderItem implements Serializable {
21596 ashik.ali 58
 
59
	private static final long serialVersionUID = 1L;
60
 
61
	@Id
62
	@Column(name = "id")
63
	@GeneratedValue(strategy = GenerationType.IDENTITY)
64
	private int id;
28566 tejbeer 65
 
21596 ashik.ali 66
	@Column(name = "order_id")
67
	private int orderId;
28566 tejbeer 68
 
34287 vikas.jang 69
	@Column(name = "pending_order_item_id")
70
	private int pendingOrderItemId;
71
 
21596 ashik.ali 72
	@Column(name = "item_id")
73
	private int itemId;
28566 tejbeer 74
 
21596 ashik.ali 75
	@Column(name = "quantity")
76
	private int quantity;
28566 tejbeer 77
 
21596 ashik.ali 78
	@Column(name = "selling_price")
79
	private float sellingPrice;
28566 tejbeer 80
 
21710 ashik.ali 81
	@Column(name = "cost")
82
	private float cost;
28566 tejbeer 83
 
26332 amit.gupta 84
	@Column(name = "mop")
85
	private float mop;
28566 tejbeer 86
 
21895 ashik.ali 87
	@Column(name = "igst_rate")
88
	private float igstRate;
28566 tejbeer 89
 
21895 ashik.ali 90
	@Column(name = "cgst_rate")
91
	private float cgstRate;
28566 tejbeer 92
 
21895 ashik.ali 93
	@Column(name = "sgst_rate")
94
	private float sgstRate;
28566 tejbeer 95
 
21895 ashik.ali 96
	@Column(name = "hsn_code")
97
	private String hsnCode;
28566 tejbeer 98
 
21596 ashik.ali 99
	@Column(name = "dp")
100
	private float dp;
28566 tejbeer 101
 
21596 ashik.ali 102
	@Column(name = "brand")
103
	private String brand;
28566 tejbeer 104
 
21596 ashik.ali 105
	@Column(name = "model_name")
106
	private String modelName;
28566 tejbeer 107
 
21596 ashik.ali 108
	@Column(name = "model_number")
109
	private String modelNumber;
28566 tejbeer 110
 
21596 ashik.ali 111
	@Column(name = "color")
112
	private String color;
28566 tejbeer 113
 
22580 ashik.ali 114
	@Column(name = "discount")
115
	private float discount;
28566 tejbeer 116
 
24094 amit.gupta 117
	@Transient
118
	private boolean doa;
28566 tejbeer 119
 
120
	@Transient
121
	private String itemName;
122
 
24094 amit.gupta 123
	public boolean isDoa() {
124
		return doa;
125
	}
28566 tejbeer 126
 
127
	public String getItemName() {
128
		return itemName;
129
	}
130
 
131
	public void setItemName(String itemName) {
132
		this.itemName = itemName;
133
	}
134
 
24094 amit.gupta 135
	public void setDoa(boolean doa) {
136
		this.doa = doa;
137
	}
28566 tejbeer 138
 
23019 ashik.ali 139
	@Convert(converter = LocalDateTimeAttributeConverter.class)
140
	@Column(name = "create_timestamp")
141
	private LocalDateTime createTimestamp = LocalDateTime.now();
28566 tejbeer 142
 
143
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
144
	@JoinColumn(name = "fofo_order_item_id", insertable = false, updatable = false, nullable = false)
22859 ashik.ali 145
	private Set<FofoLineItem> fofoLineItems;
28566 tejbeer 146
 
21596 ashik.ali 147
	public int getId() {
148
		return id;
149
	}
28566 tejbeer 150
 
21596 ashik.ali 151
	public void setId(int id) {
152
		this.id = id;
153
	}
28566 tejbeer 154
 
21596 ashik.ali 155
	public int getOrderId() {
156
		return orderId;
157
	}
28566 tejbeer 158
 
21596 ashik.ali 159
	public void setOrderId(int orderId) {
160
		this.orderId = orderId;
161
	}
28566 tejbeer 162
 
34287 vikas.jang 163
	public int getPendingOrderItemId() {
164
		return pendingOrderItemId;
165
	}
166
 
167
	public void setPendingOrderItemId(int pendingOrderItemId) {
168
		this.pendingOrderItemId = pendingOrderItemId;
169
	}
170
 
21596 ashik.ali 171
	public int getItemId() {
172
		return itemId;
173
	}
28566 tejbeer 174
 
21596 ashik.ali 175
	public void setItemId(int itemId) {
176
		this.itemId = itemId;
177
	}
28566 tejbeer 178
 
21596 ashik.ali 179
	public int getQuantity() {
180
		return quantity;
181
	}
28566 tejbeer 182
 
21596 ashik.ali 183
	public void setQuantity(int quantity) {
184
		this.quantity = quantity;
185
	}
28566 tejbeer 186
 
21596 ashik.ali 187
	public float getSellingPrice() {
188
		return sellingPrice;
189
	}
28566 tejbeer 190
 
21596 ashik.ali 191
	public void setSellingPrice(float sellingPrice) {
192
		this.sellingPrice = sellingPrice;
193
	}
28566 tejbeer 194
 
21710 ashik.ali 195
	public float getCost() {
196
		return cost;
197
	}
28566 tejbeer 198
 
21710 ashik.ali 199
	public void setCost(float cost) {
200
		this.cost = cost;
201
	}
28566 tejbeer 202
 
26332 amit.gupta 203
	public float getMop() {
204
		return mop;
205
	}
28566 tejbeer 206
 
26332 amit.gupta 207
	public void setMop(float mop) {
208
		this.mop = mop;
209
	}
28566 tejbeer 210
 
21895 ashik.ali 211
	public float getIgstRate() {
212
		return igstRate;
21596 ashik.ali 213
	}
28566 tejbeer 214
 
21895 ashik.ali 215
	public void setIgstRate(float igstRate) {
216
		this.igstRate = igstRate;
21596 ashik.ali 217
	}
28566 tejbeer 218
 
21895 ashik.ali 219
	public float getCgstRate() {
220
		return cgstRate;
21687 ashik.ali 221
	}
28566 tejbeer 222
 
21895 ashik.ali 223
	public void setCgstRate(float cgstRate) {
224
		this.cgstRate = cgstRate;
21687 ashik.ali 225
	}
28566 tejbeer 226
 
21895 ashik.ali 227
	public float getSgstRate() {
228
		return sgstRate;
229
	}
28566 tejbeer 230
 
21895 ashik.ali 231
	public void setSgstRate(float sgstRate) {
232
		this.sgstRate = sgstRate;
233
	}
28566 tejbeer 234
 
21895 ashik.ali 235
	public String getHsnCode() {
236
		return hsnCode;
237
	}
28566 tejbeer 238
 
21895 ashik.ali 239
	public void setHsnCode(String hsnCode) {
240
		this.hsnCode = hsnCode;
241
	}
28566 tejbeer 242
 
21596 ashik.ali 243
	public float getDp() {
244
		return dp;
245
	}
26332 amit.gupta 246
 
21596 ashik.ali 247
	public void setDp(float dp) {
248
		this.dp = dp;
249
	}
28566 tejbeer 250
 
21596 ashik.ali 251
	public String getBrand() {
252
		return brand;
253
	}
28566 tejbeer 254
 
21596 ashik.ali 255
	public void setBrand(String brand) {
256
		this.brand = brand;
257
	}
28566 tejbeer 258
 
21596 ashik.ali 259
	public String getModelName() {
260
		return modelName;
261
	}
28566 tejbeer 262
 
21596 ashik.ali 263
	public void setModelName(String modelName) {
264
		this.modelName = modelName;
265
	}
28566 tejbeer 266
 
21596 ashik.ali 267
	public String getModelNumber() {
268
		return modelNumber;
269
	}
28566 tejbeer 270
 
21596 ashik.ali 271
	public void setModelNumber(String modelNumber) {
272
		this.modelNumber = modelNumber;
273
	}
28566 tejbeer 274
 
21596 ashik.ali 275
	public String getColor() {
276
		return color;
277
	}
28566 tejbeer 278
 
21596 ashik.ali 279
	public void setColor(String color) {
280
		this.color = color;
281
	}
28566 tejbeer 282
 
22580 ashik.ali 283
	public float getDiscount() {
284
		return discount;
285
	}
28566 tejbeer 286
 
22580 ashik.ali 287
	public void setDiscount(float discount) {
288
		this.discount = discount;
289
	}
28566 tejbeer 290
 
23019 ashik.ali 291
	public LocalDateTime getCreateTimestamp() {
292
		return createTimestamp;
293
	}
28566 tejbeer 294
 
23019 ashik.ali 295
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
296
		this.createTimestamp = createTimestamp;
297
	}
28566 tejbeer 298
 
22859 ashik.ali 299
	public Set<FofoLineItem> getFofoLineItems() {
300
		return fofoLineItems;
21687 ashik.ali 301
	}
28566 tejbeer 302
 
22859 ashik.ali 303
	public void setFofoLineItems(Set<FofoLineItem> fofoLineItems) {
304
		this.fofoLineItems = fofoLineItems;
21687 ashik.ali 305
	}
28566 tejbeer 306
 
21602 ashik.ali 307
	@Override
21924 ashik.ali 308
	public int hashCode() {
309
		final int prime = 31;
310
		int result = 1;
28566 tejbeer 311
		result = prime * result + ((brand == null) ? 0 : brand.hashCode());
312
		result = prime * result + Float.floatToIntBits(cgstRate);
313
		result = prime * result + ((color == null) ? 0 : color.hashCode());
314
		result = prime * result + Float.floatToIntBits(cost);
315
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
316
		result = prime * result + Float.floatToIntBits(discount);
317
		result = prime * result + (doa ? 1231 : 1237);
318
		result = prime * result + Float.floatToIntBits(dp);
319
		result = prime * result + ((fofoLineItems == null) ? 0 : fofoLineItems.hashCode());
320
		result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());
21924 ashik.ali 321
		result = prime * result + id;
28566 tejbeer 322
		result = prime * result + Float.floatToIntBits(igstRate);
323
		result = prime * result + itemId;
324
		result = prime * result + ((itemName == null) ? 0 : itemName.hashCode());
325
		result = prime * result + ((modelName == null) ? 0 : modelName.hashCode());
326
		result = prime * result + ((modelNumber == null) ? 0 : modelNumber.hashCode());
327
		result = prime * result + Float.floatToIntBits(mop);
328
		result = prime * result + orderId;
329
		result = prime * result + quantity;
330
		result = prime * result + Float.floatToIntBits(sellingPrice);
331
		result = prime * result + Float.floatToIntBits(sgstRate);
21924 ashik.ali 332
		return result;
333
	}
28566 tejbeer 334
 
21924 ashik.ali 335
	@Override
336
	public boolean equals(Object obj) {
337
		if (this == obj)
338
			return true;
339
		if (obj == null)
340
			return false;
341
		if (getClass() != obj.getClass())
342
			return false;
22859 ashik.ali 343
		FofoOrderItem other = (FofoOrderItem) obj;
28566 tejbeer 344
		if (brand == null) {
345
			if (other.brand != null)
346
				return false;
347
		} else if (!brand.equals(other.brand))
348
			return false;
349
		if (Float.floatToIntBits(cgstRate) != Float.floatToIntBits(other.cgstRate))
350
			return false;
351
		if (color == null) {
352
			if (other.color != null)
353
				return false;
354
		} else if (!color.equals(other.color))
355
			return false;
356
		if (Float.floatToIntBits(cost) != Float.floatToIntBits(other.cost))
357
			return false;
358
		if (createTimestamp == null) {
359
			if (other.createTimestamp != null)
360
				return false;
361
		} else if (!createTimestamp.equals(other.createTimestamp))
362
			return false;
363
		if (Float.floatToIntBits(discount) != Float.floatToIntBits(other.discount))
364
			return false;
365
		if (doa != other.doa)
366
			return false;
367
		if (Float.floatToIntBits(dp) != Float.floatToIntBits(other.dp))
368
			return false;
369
		if (fofoLineItems == null) {
370
			if (other.fofoLineItems != null)
371
				return false;
372
		} else if (!fofoLineItems.equals(other.fofoLineItems))
373
			return false;
374
		if (hsnCode == null) {
375
			if (other.hsnCode != null)
376
				return false;
377
		} else if (!hsnCode.equals(other.hsnCode))
378
			return false;
21924 ashik.ali 379
		if (id != other.id)
380
			return false;
28566 tejbeer 381
		if (Float.floatToIntBits(igstRate) != Float.floatToIntBits(other.igstRate))
382
			return false;
383
		if (itemId != other.itemId)
384
			return false;
385
		if (itemName == null) {
386
			if (other.itemName != null)
387
				return false;
388
		} else if (!itemName.equals(other.itemName))
389
			return false;
390
		if (modelName == null) {
391
			if (other.modelName != null)
392
				return false;
393
		} else if (!modelName.equals(other.modelName))
394
			return false;
395
		if (modelNumber == null) {
396
			if (other.modelNumber != null)
397
				return false;
398
		} else if (!modelNumber.equals(other.modelNumber))
399
			return false;
400
		if (Float.floatToIntBits(mop) != Float.floatToIntBits(other.mop))
401
			return false;
402
		if (orderId != other.orderId)
403
			return false;
404
		if (quantity != other.quantity)
405
			return false;
406
		if (Float.floatToIntBits(sellingPrice) != Float.floatToIntBits(other.sellingPrice))
407
			return false;
408
		if (Float.floatToIntBits(sgstRate) != Float.floatToIntBits(other.sgstRate))
409
			return false;
21924 ashik.ali 410
		return true;
411
	}
28566 tejbeer 412
 
21924 ashik.ali 413
	@Override
21602 ashik.ali 414
	public String toString() {
22859 ashik.ali 415
		return "FofoOrderItem [id=" + id + ", orderId=" + orderId + ", itemId=" + itemId + ", quantity=" + quantity
26332 amit.gupta 416
				+ ", sellingPrice=" + sellingPrice + ", cost=" + cost + ", mop=" + mop + ", igstRate=" + igstRate
417
				+ ", cgstRate=" + cgstRate + ", sgstRate=" + sgstRate + ", hsnCode=" + hsnCode + ", dp=" + dp
418
				+ ", brand=" + brand + ", modelName=" + modelName + ", modelNumber=" + modelNumber + ", color=" + color
28566 tejbeer 419
				+ ", discount=" + discount + ", doa=" + doa + ", itemName=" + itemName + ", createTimestamp="
420
				+ createTimestamp + ", fofoLineItems=" + fofoLineItems + "]";
21602 ashik.ali 421
	}
28566 tejbeer 422
 
21596 ashik.ali 423
}