Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
21714 ashik.ali 1
package com.spice.profitmandi.dao.entity.fofo;
21552 ashik.ali 2
 
3
import java.time.LocalDateTime;
23509 amit.gupta 4
import java.time.format.DateTimeFormatter;
21552 ashik.ali 5
 
6
import javax.persistence.Column;
21639 kshitij.so 7
import javax.persistence.Convert;
21552 ashik.ali 8
import javax.persistence.Entity;
9
import javax.persistence.EnumType;
10
import javax.persistence.Enumerated;
21653 ashik.ali 11
import javax.persistence.FetchType;
21552 ashik.ali 12
import javax.persistence.GeneratedValue;
13
import javax.persistence.GenerationType;
14
import javax.persistence.Id;
21653 ashik.ali 15
import javax.persistence.JoinColumn;
21552 ashik.ali 16
import javax.persistence.NamedQueries;
17
import javax.persistence.NamedQuery;
21653 ashik.ali 18
import javax.persistence.OneToOne;
21552 ashik.ali 19
import javax.persistence.Table;
23509 amit.gupta 20
import javax.persistence.Transient;
21552 ashik.ali 21
 
22216 ashik.ali 22
import org.hibernate.annotations.UpdateTimestamp;
23
 
21639 kshitij.so 24
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
21714 ashik.ali 25
import com.spice.profitmandi.dao.entity.catalog.Item;
26
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
21552 ashik.ali 27
 
28
@NamedQueries({
26213 amit.gupta 29
		@NamedQuery(name = "InventoryItem.selectScannedCount", query = "select ii.itemId, sum(ii.initialQuantity) from InventoryItem ii "
30
				+ "where ii.itemId in :itemIds and ii.fofoId = :fofoId and ii.purchaseId = :purchaseId group by ii.itemId") })
21552 ashik.ali 31
@Entity
26213 amit.gupta 32
@Table(name = "fofo.inventory_item", schema = "fofo")
23983 amit.gupta 33
public class InventoryItem implements Comparable {
26213 amit.gupta 34
 
24607 amit.gupta 35
	public InventoryItem(String serialNumber) {
36
		this.serialNumber = serialNumber;
37
	}
26213 amit.gupta 38
 
24607 amit.gupta 39
	public InventoryItem() {
26213 amit.gupta 40
 
24607 amit.gupta 41
	}
26213 amit.gupta 42
 
21552 ashik.ali 43
	@Id
26213 amit.gupta 44
	@Column(name = "id", unique = true, updatable = false)
21552 ashik.ali 45
	@GeneratedValue(strategy = GenerationType.IDENTITY)
46
	private int id;
26213 amit.gupta 47
 
21552 ashik.ali 48
	@Column(name = "item_id")
26213 amit.gupta 49
	private int itemId;
50
 
21552 ashik.ali 51
	@Column(name = "fofo_id")
26213 amit.gupta 52
	private int fofoId;
53
 
21609 ashik.ali 54
	@Column(name = "serial_number", length = 100)
26213 amit.gupta 55
	private String serialNumber;
56
 
21613 kshitij.so 57
	@Column(name = "initial_quantity")
21552 ashik.ali 58
	private int initialQuantity;
26213 amit.gupta 59
 
21552 ashik.ali 60
	@Column(name = "good_quantity")
26213 amit.gupta 61
	private int goodQuantity;
62
 
21552 ashik.ali 63
	@Column(name = "bad_quantity")
64
	private int badQuantity;
26213 amit.gupta 65
 
21552 ashik.ali 66
	@Column(name = "last_scan_type")
67
	@Enumerated(EnumType.STRING)
68
	private ScanType lastScanType;
26213 amit.gupta 69
 
21633 ashik.ali 70
	@Column(name = "purchase_id")
71
	private int purchaseId;
26213 amit.gupta 72
 
73
	@Column(name = "unit_price")
23110 ashik.ali 74
	private float unitPrice;
26213 amit.gupta 75
 
21710 ashik.ali 76
	@Column(name = "price_drop_amount")
23110 ashik.ali 77
	private float priceDropAmount;
26213 amit.gupta 78
 
22352 ashik.ali 79
	@Column(name = "buy_back", columnDefinition = "tinyint(1) default 1")
80
	private boolean buyBack;
26213 amit.gupta 81
 
22859 ashik.ali 82
	@Column(name = "igst_rate")
83
	private float igstRate;
26213 amit.gupta 84
 
22859 ashik.ali 85
	@Column(name = "cgst_rate")
86
	private float cgstRate;
26213 amit.gupta 87
 
22859 ashik.ali 88
	@Column(name = "sgst_rate")
89
	private float sgstRate;
26213 amit.gupta 90
 
22859 ashik.ali 91
	@Column(name = "hsn_code")
92
	private String hsnCode;
26213 amit.gupta 93
 
21639 kshitij.so 94
	@Convert(converter = LocalDateTimeAttributeConverter.class)
21552 ashik.ali 95
	@Column(name = "create_timestamp")
21640 kshitij.so 96
	private LocalDateTime createTimestamp = LocalDateTime.now();
26213 amit.gupta 97
 
21710 ashik.ali 98
	@Convert(converter = LocalDateTimeAttributeConverter.class)
99
	@Column(name = "update_timestamp")
22216 ashik.ali 100
	@UpdateTimestamp
21710 ashik.ali 101
	private LocalDateTime updateTimestamp = LocalDateTime.now();
26213 amit.gupta 102
 
103
	@OneToOne(fetch = FetchType.LAZY)
104
	@JoinColumn(name = "item_id", insertable = false, updatable = false, nullable = false, referencedColumnName = "id")
21653 ashik.ali 105
	private Item item;
26213 amit.gupta 106
 
107
	@OneToOne(fetch = FetchType.LAZY)
108
	@JoinColumn(name = "purchase_id", insertable = false, updatable = false, nullable = false, referencedColumnName = "id")
23019 ashik.ali 109
	private Purchase purchase;
26213 amit.gupta 110
 
23527 ashik.ali 111
 
26299 amit.gupta 112
	@OneToOne(fetch = FetchType.EAGER)
113
	@JoinColumn(name = "serial_number", insertable = false, updatable = false, referencedColumnName = "serial_number")
114
	private ActivatedImei activatedImei;
26213 amit.gupta 115
 
116
 
117
	public void setUnitPrice(float unitPrice) {
118
		this.unitPrice = unitPrice;
119
	}
120
 
23527 ashik.ali 121
	@Transient
122
	private String itemDescription;
21552 ashik.ali 123
 
124
	public int getId() {
125
		return id;
126
	}
127
 
128
	public void setId(int id) {
129
		this.id = id;
130
	}
131
 
132
	public int getItemId() {
133
		return itemId;
134
	}
135
 
136
	public void setItemId(int itemId) {
137
		this.itemId = itemId;
138
	}
26213 amit.gupta 139
 
21984 kshitij.so 140
	public void setFofoId(int fofoId) {
141
		this.fofoId = fofoId;
142
	}
21552 ashik.ali 143
 
144
	public int getFofoId() {
145
		return fofoId;
146
	}
147
 
21609 ashik.ali 148
	public String getSerialNumber() {
149
		return serialNumber;
21552 ashik.ali 150
	}
26213 amit.gupta 151
 
21609 ashik.ali 152
	public void setSerialNumber(String serialNumber) {
153
		this.serialNumber = serialNumber;
21552 ashik.ali 154
	}
26213 amit.gupta 155
 
21552 ashik.ali 156
	public int getInitialQuantity() {
157
		return initialQuantity;
158
	}
159
 
23110 ashik.ali 160
	public float getUnitPrice() {
21984 kshitij.so 161
		return unitPrice;
162
	}
163
 
164
	public void setUnitPrice(Float unitPrice) {
165
		this.unitPrice = unitPrice;
166
	}
167
 
21552 ashik.ali 168
	public void setInitialQuantity(int initialQuantity) {
169
		this.initialQuantity = initialQuantity;
170
	}
26213 amit.gupta 171
 
172
	public float getNetPrice() {
23110 ashik.ali 173
		return unitPrice - priceDropAmount;
174
	}
21552 ashik.ali 175
 
176
	public int getGoodQuantity() {
177
		return goodQuantity;
178
	}
179
 
180
	public void setGoodQuantity(int goodQuantity) {
181
		this.goodQuantity = goodQuantity;
182
	}
183
 
184
	public int getBadQuantity() {
185
		return badQuantity;
186
	}
187
 
188
	public void setBadQuantity(int badQuantity) {
189
		this.badQuantity = badQuantity;
190
	}
191
 
192
	public ScanType getLastScanType() {
193
		return lastScanType;
194
	}
195
 
196
	public void setLastScanType(ScanType lastScanType) {
197
		this.lastScanType = lastScanType;
198
	}
26213 amit.gupta 199
 
21633 ashik.ali 200
	public int getPurchaseId() {
201
		return purchaseId;
21552 ashik.ali 202
	}
26213 amit.gupta 203
 
21633 ashik.ali 204
	public void setPurchaseId(int purchaseId) {
205
		this.purchaseId = purchaseId;
21552 ashik.ali 206
	}
26213 amit.gupta 207
 
23110 ashik.ali 208
	public float getPriceDropAmount() {
21710 ashik.ali 209
		return priceDropAmount;
210
	}
26213 amit.gupta 211
 
23110 ashik.ali 212
	public void setPriceDropAmount(float priceDropAmount) {
21710 ashik.ali 213
		this.priceDropAmount = priceDropAmount;
214
	}
26213 amit.gupta 215
 
22859 ashik.ali 216
	public float getIgstRate() {
217
		return igstRate;
218
	}
26213 amit.gupta 219
 
22859 ashik.ali 220
	public void setIgstRate(float igstRate) {
221
		this.igstRate = igstRate;
222
	}
26213 amit.gupta 223
 
22859 ashik.ali 224
	public float getCgstRate() {
225
		return cgstRate;
226
	}
26213 amit.gupta 227
 
22859 ashik.ali 228
	public void setCgstRate(float cgstRate) {
229
		this.cgstRate = cgstRate;
230
	}
26213 amit.gupta 231
 
22859 ashik.ali 232
	public float getSgstRate() {
233
		return sgstRate;
234
	}
26213 amit.gupta 235
 
22859 ashik.ali 236
	public void setSgstRate(float sgstRate) {
237
		this.sgstRate = sgstRate;
238
	}
26213 amit.gupta 239
 
22859 ashik.ali 240
	public String getHsnCode() {
241
		return hsnCode;
242
	}
26213 amit.gupta 243
 
22859 ashik.ali 244
	public void setHsnCode(String hsnCode) {
245
		this.hsnCode = hsnCode;
246
	}
21552 ashik.ali 247
 
248
	public LocalDateTime getCreateTimestamp() {
249
		return createTimestamp;
250
	}
251
 
252
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
253
		this.createTimestamp = createTimestamp;
254
	}
26213 amit.gupta 255
 
21710 ashik.ali 256
	public LocalDateTime getUpdateTimestamp() {
257
		return updateTimestamp;
258
	}
26213 amit.gupta 259
 
21710 ashik.ali 260
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
261
		this.updateTimestamp = updateTimestamp;
262
	}
26213 amit.gupta 263
 
21653 ashik.ali 264
	public Item getItem() {
265
		return item;
266
	}
26213 amit.gupta 267
 
21653 ashik.ali 268
	public void setItem(Item item) {
269
		this.item = item;
270
	}
21602 ashik.ali 271
 
22352 ashik.ali 272
	public boolean isBuyBack() {
273
		return buyBack;
274
	}
26213 amit.gupta 275
 
22352 ashik.ali 276
	public void setBuyBack(boolean buyBack) {
277
		this.buyBack = buyBack;
278
	}
26213 amit.gupta 279
 
23019 ashik.ali 280
	public Purchase getPurchase() {
281
		return purchase;
282
	}
26213 amit.gupta 283
 
23019 ashik.ali 284
	public void setPurchase(Purchase purchase) {
285
		this.purchase = purchase;
286
	}
26213 amit.gupta 287
 
288
	public String getFormattedCreateTimestamp() {
289
		if (createTimestamp == null) {
23527 ashik.ali 290
			return null;
291
		}
24402 amit.gupta 292
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
23527 ashik.ali 293
		return createTimestamp.format(formatter);
26213 amit.gupta 294
	}
295
 
23527 ashik.ali 296
	public String getItemDescription() {
297
		return itemDescription;
298
	}
26213 amit.gupta 299
 
23527 ashik.ali 300
	public void setItemDescription(String itemDescription) {
301
		this.itemDescription = itemDescription;
302
	}
26213 amit.gupta 303
 
21602 ashik.ali 304
	@Override
22009 ashik.ali 305
	public int hashCode() {
306
		final int prime = 31;
307
		int result = 1;
26299 amit.gupta 308
		result = prime * result + ((activatedImei == null) ? 0 : activatedImei.hashCode());
26213 amit.gupta 309
		result = prime * result + badQuantity;
310
		result = prime * result + (buyBack ? 1231 : 1237);
311
		result = prime * result + Float.floatToIntBits(cgstRate);
312
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
313
		result = prime * result + fofoId;
314
		result = prime * result + goodQuantity;
315
		result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());
22009 ashik.ali 316
		result = prime * result + id;
26213 amit.gupta 317
		result = prime * result + Float.floatToIntBits(igstRate);
318
		result = prime * result + initialQuantity;
319
		result = prime * result + ((item == null) ? 0 : item.hashCode());
320
		result = prime * result + ((itemDescription == null) ? 0 : itemDescription.hashCode());
321
		result = prime * result + itemId;
322
		result = prime * result + ((lastScanType == null) ? 0 : lastScanType.hashCode());
323
		result = prime * result + Float.floatToIntBits(priceDropAmount);
324
		result = prime * result + ((purchase == null) ? 0 : purchase.hashCode());
325
		result = prime * result + purchaseId;
326
		result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
327
		result = prime * result + Float.floatToIntBits(sgstRate);
328
		result = prime * result + Float.floatToIntBits(unitPrice);
329
		result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
22009 ashik.ali 330
		return result;
331
	}
332
 
333
	@Override
334
	public boolean equals(Object obj) {
335
		if (this == obj)
336
			return true;
337
		if (obj == null)
338
			return false;
339
		if (getClass() != obj.getClass())
340
			return false;
341
		InventoryItem other = (InventoryItem) obj;
26299 amit.gupta 342
		if (activatedImei == null) {
343
			if (other.activatedImei != null)
26213 amit.gupta 344
				return false;
26299 amit.gupta 345
		} else if (!activatedImei.equals(other.activatedImei))
26213 amit.gupta 346
			return false;
347
		if (badQuantity != other.badQuantity)
348
			return false;
349
		if (buyBack != other.buyBack)
350
			return false;
351
		if (Float.floatToIntBits(cgstRate) != Float.floatToIntBits(other.cgstRate))
352
			return false;
353
		if (createTimestamp == null) {
354
			if (other.createTimestamp != null)
355
				return false;
356
		} else if (!createTimestamp.equals(other.createTimestamp))
357
			return false;
358
		if (fofoId != other.fofoId)
359
			return false;
360
		if (goodQuantity != other.goodQuantity)
361
			return false;
362
		if (hsnCode == null) {
363
			if (other.hsnCode != null)
364
				return false;
365
		} else if (!hsnCode.equals(other.hsnCode))
366
			return false;
22009 ashik.ali 367
		if (id != other.id)
368
			return false;
26213 amit.gupta 369
		if (Float.floatToIntBits(igstRate) != Float.floatToIntBits(other.igstRate))
370
			return false;
371
		if (initialQuantity != other.initialQuantity)
372
			return false;
373
		if (item == null) {
374
			if (other.item != null)
375
				return false;
376
		} else if (!item.equals(other.item))
377
			return false;
378
		if (itemDescription == null) {
379
			if (other.itemDescription != null)
380
				return false;
381
		} else if (!itemDescription.equals(other.itemDescription))
382
			return false;
383
		if (itemId != other.itemId)
384
			return false;
385
		if (lastScanType != other.lastScanType)
386
			return false;
387
		if (Float.floatToIntBits(priceDropAmount) != Float.floatToIntBits(other.priceDropAmount))
388
			return false;
389
		if (purchase == null) {
390
			if (other.purchase != null)
391
				return false;
392
		} else if (!purchase.equals(other.purchase))
393
			return false;
394
		if (purchaseId != other.purchaseId)
395
			return false;
396
		if (serialNumber == null) {
397
			if (other.serialNumber != null)
398
				return false;
399
		} else if (!serialNumber.equals(other.serialNumber))
400
			return false;
401
		if (Float.floatToIntBits(sgstRate) != Float.floatToIntBits(other.sgstRate))
402
			return false;
403
		if (Float.floatToIntBits(unitPrice) != Float.floatToIntBits(other.unitPrice))
404
			return false;
405
		if (updateTimestamp == null) {
406
			if (other.updateTimestamp != null)
407
				return false;
408
		} else if (!updateTimestamp.equals(other.updateTimestamp))
409
			return false;
22009 ashik.ali 410
		return true;
411
	}
412
 
413
	@Override
21602 ashik.ali 414
	public String toString() {
21662 kshitij.so 415
		return "InventoryItem [id=" + id + ", itemId=" + itemId + ", fofoId=" + fofoId + ", serialNumber="
416
				+ serialNumber + ", initialQuantity=" + initialQuantity + ", goodQuantity=" + goodQuantity
417
				+ ", badQuantity=" + badQuantity + ", lastScanType=" + lastScanType + ", purchaseId=" + purchaseId
22352 ashik.ali 418
				+ ", unitPrice=" + unitPrice + ", priceDropAmount=" + priceDropAmount + ", buyBack=" + buyBack
22859 ashik.ali 419
				+ ", igstRate=" + igstRate + ", cgstRate=" + cgstRate + ", sgstRate=" + sgstRate + ", hsnCode="
420
				+ hsnCode + ", createTimestamp=" + createTimestamp + ", updateTimestamp=" + updateTimestamp + ", item="
26299 amit.gupta 421
				+ item + ", purchase=" + purchase + ", activatedImei=" + activatedImei + ", itemDescription="
422
				+ itemDescription + "]";
21602 ashik.ali 423
	}
23983 amit.gupta 424
 
425
	@Override
426
	public int compareTo(Object o) {
427
		return o.hashCode() - this.hashCode();
428
	}
26213 amit.gupta 429
 
21552 ashik.ali 430
}