Subversion Repositories SmartDukaan

Rev

Rev 29093 | Rev 29571 | 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;
26303 amit.gupta 65
 
66
	@Column(name = "activation_timestamp")
67
	private LocalDateTime activationTimestamp;
26213 amit.gupta 68
 
21552 ashik.ali 69
	@Column(name = "last_scan_type")
70
	@Enumerated(EnumType.STRING)
71
	private ScanType lastScanType;
26213 amit.gupta 72
 
21633 ashik.ali 73
	@Column(name = "purchase_id")
74
	private int purchaseId;
26213 amit.gupta 75
 
76
	@Column(name = "unit_price")
23110 ashik.ali 77
	private float unitPrice;
26213 amit.gupta 78
 
21710 ashik.ali 79
	@Column(name = "price_drop_amount")
23110 ashik.ali 80
	private float priceDropAmount;
26213 amit.gupta 81
 
22352 ashik.ali 82
	@Column(name = "buy_back", columnDefinition = "tinyint(1) default 1")
83
	private boolean buyBack;
26213 amit.gupta 84
 
22859 ashik.ali 85
	@Column(name = "igst_rate")
86
	private float igstRate;
26213 amit.gupta 87
 
22859 ashik.ali 88
	@Column(name = "cgst_rate")
89
	private float cgstRate;
26213 amit.gupta 90
 
22859 ashik.ali 91
	@Column(name = "sgst_rate")
92
	private float sgstRate;
26213 amit.gupta 93
 
22859 ashik.ali 94
	@Column(name = "hsn_code")
95
	private String hsnCode;
26213 amit.gupta 96
 
21639 kshitij.so 97
	@Convert(converter = LocalDateTimeAttributeConverter.class)
21552 ashik.ali 98
	@Column(name = "create_timestamp")
21640 kshitij.so 99
	private LocalDateTime createTimestamp = LocalDateTime.now();
26213 amit.gupta 100
 
21710 ashik.ali 101
	@Convert(converter = LocalDateTimeAttributeConverter.class)
102
	@Column(name = "update_timestamp")
22216 ashik.ali 103
	@UpdateTimestamp
21710 ashik.ali 104
	private LocalDateTime updateTimestamp = LocalDateTime.now();
26213 amit.gupta 105
 
106
	@OneToOne(fetch = FetchType.LAZY)
107
	@JoinColumn(name = "item_id", insertable = false, updatable = false, nullable = false, referencedColumnName = "id")
21653 ashik.ali 108
	private Item item;
26213 amit.gupta 109
 
110
	@OneToOne(fetch = FetchType.LAZY)
111
	@JoinColumn(name = "purchase_id", insertable = false, updatable = false, nullable = false, referencedColumnName = "id")
23019 ashik.ali 112
	private Purchase purchase;
26213 amit.gupta 113
 
114
	public void setUnitPrice(float unitPrice) {
115
		this.unitPrice = unitPrice;
116
	}
117
 
23527 ashik.ali 118
	@Transient
119
	private String itemDescription;
21552 ashik.ali 120
 
26304 amit.gupta 121
	@Transient
122
	private LocalDateTime activatedTimestamp;
123
 
29093 amit.gupta 124
	@Transient
29095 amit.gupta 125
	private boolean priceDropValidated = true;
29093 amit.gupta 126
 
26304 amit.gupta 127
	public LocalDateTime getActivatedTimestamp() {
128
		return activatedTimestamp;
129
	}
130
 
131
	public void setActivatedTimestamp(LocalDateTime activatedTimestamp) {
132
		this.activatedTimestamp = activatedTimestamp;
133
	}
134
 
21552 ashik.ali 135
	public int getId() {
136
		return id;
137
	}
138
 
139
	public void setId(int id) {
140
		this.id = id;
141
	}
142
 
143
	public int getItemId() {
144
		return itemId;
145
	}
146
 
147
	public void setItemId(int itemId) {
148
		this.itemId = itemId;
149
	}
26213 amit.gupta 150
 
21984 kshitij.so 151
	public void setFofoId(int fofoId) {
152
		this.fofoId = fofoId;
153
	}
21552 ashik.ali 154
 
155
	public int getFofoId() {
156
		return fofoId;
157
	}
158
 
21609 ashik.ali 159
	public String getSerialNumber() {
160
		return serialNumber;
21552 ashik.ali 161
	}
26213 amit.gupta 162
 
21609 ashik.ali 163
	public void setSerialNumber(String serialNumber) {
164
		this.serialNumber = serialNumber;
21552 ashik.ali 165
	}
26213 amit.gupta 166
 
21552 ashik.ali 167
	public int getInitialQuantity() {
168
		return initialQuantity;
169
	}
170
 
23110 ashik.ali 171
	public float getUnitPrice() {
21984 kshitij.so 172
		return unitPrice;
173
	}
174
 
175
	public void setUnitPrice(Float unitPrice) {
176
		this.unitPrice = unitPrice;
177
	}
178
 
21552 ashik.ali 179
	public void setInitialQuantity(int initialQuantity) {
180
		this.initialQuantity = initialQuantity;
181
	}
26213 amit.gupta 182
 
183
	public float getNetPrice() {
23110 ashik.ali 184
		return unitPrice - priceDropAmount;
185
	}
21552 ashik.ali 186
 
187
	public int getGoodQuantity() {
188
		return goodQuantity;
189
	}
190
 
191
	public void setGoodQuantity(int goodQuantity) {
192
		this.goodQuantity = goodQuantity;
193
	}
194
 
195
	public int getBadQuantity() {
196
		return badQuantity;
197
	}
198
 
199
	public void setBadQuantity(int badQuantity) {
200
		this.badQuantity = badQuantity;
201
	}
202
 
203
	public ScanType getLastScanType() {
204
		return lastScanType;
205
	}
206
 
207
	public void setLastScanType(ScanType lastScanType) {
208
		this.lastScanType = lastScanType;
209
	}
26213 amit.gupta 210
 
21633 ashik.ali 211
	public int getPurchaseId() {
212
		return purchaseId;
21552 ashik.ali 213
	}
26213 amit.gupta 214
 
21633 ashik.ali 215
	public void setPurchaseId(int purchaseId) {
216
		this.purchaseId = purchaseId;
21552 ashik.ali 217
	}
26213 amit.gupta 218
 
23110 ashik.ali 219
	public float getPriceDropAmount() {
21710 ashik.ali 220
		return priceDropAmount;
221
	}
26213 amit.gupta 222
 
23110 ashik.ali 223
	public void setPriceDropAmount(float priceDropAmount) {
21710 ashik.ali 224
		this.priceDropAmount = priceDropAmount;
225
	}
26213 amit.gupta 226
 
22859 ashik.ali 227
	public float getIgstRate() {
228
		return igstRate;
229
	}
26213 amit.gupta 230
 
22859 ashik.ali 231
	public void setIgstRate(float igstRate) {
232
		this.igstRate = igstRate;
233
	}
26213 amit.gupta 234
 
22859 ashik.ali 235
	public float getCgstRate() {
236
		return cgstRate;
237
	}
26213 amit.gupta 238
 
22859 ashik.ali 239
	public void setCgstRate(float cgstRate) {
240
		this.cgstRate = cgstRate;
241
	}
26213 amit.gupta 242
 
22859 ashik.ali 243
	public float getSgstRate() {
244
		return sgstRate;
245
	}
26213 amit.gupta 246
 
22859 ashik.ali 247
	public void setSgstRate(float sgstRate) {
248
		this.sgstRate = sgstRate;
249
	}
26213 amit.gupta 250
 
22859 ashik.ali 251
	public String getHsnCode() {
252
		return hsnCode;
253
	}
26213 amit.gupta 254
 
22859 ashik.ali 255
	public void setHsnCode(String hsnCode) {
256
		this.hsnCode = hsnCode;
257
	}
21552 ashik.ali 258
 
259
	public LocalDateTime getCreateTimestamp() {
260
		return createTimestamp;
261
	}
262
 
263
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
264
		this.createTimestamp = createTimestamp;
265
	}
26213 amit.gupta 266
 
21710 ashik.ali 267
	public LocalDateTime getUpdateTimestamp() {
268
		return updateTimestamp;
269
	}
26213 amit.gupta 270
 
21710 ashik.ali 271
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
272
		this.updateTimestamp = updateTimestamp;
273
	}
26213 amit.gupta 274
 
21653 ashik.ali 275
	public Item getItem() {
276
		return item;
277
	}
26213 amit.gupta 278
 
21653 ashik.ali 279
	public void setItem(Item item) {
280
		this.item = item;
281
	}
21602 ashik.ali 282
 
22352 ashik.ali 283
	public boolean isBuyBack() {
284
		return buyBack;
285
	}
26213 amit.gupta 286
 
22352 ashik.ali 287
	public void setBuyBack(boolean buyBack) {
288
		this.buyBack = buyBack;
289
	}
26213 amit.gupta 290
 
23019 ashik.ali 291
	public Purchase getPurchase() {
292
		return purchase;
293
	}
26213 amit.gupta 294
 
23019 ashik.ali 295
	public void setPurchase(Purchase purchase) {
296
		this.purchase = purchase;
297
	}
26213 amit.gupta 298
 
299
	public String getFormattedCreateTimestamp() {
300
		if (createTimestamp == null) {
23527 ashik.ali 301
			return null;
302
		}
24402 amit.gupta 303
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
23527 ashik.ali 304
		return createTimestamp.format(formatter);
26213 amit.gupta 305
	}
306
 
23527 ashik.ali 307
	public String getItemDescription() {
308
		return itemDescription;
309
	}
26213 amit.gupta 310
 
23527 ashik.ali 311
	public void setItemDescription(String itemDescription) {
312
		this.itemDescription = itemDescription;
313
	}
26213 amit.gupta 314
 
21602 ashik.ali 315
	@Override
22009 ashik.ali 316
	public int hashCode() {
317
		final int prime = 31;
318
		int result = 1;
26304 amit.gupta 319
		result = prime * result + ((activatedTimestamp == null) ? 0 : activatedTimestamp.hashCode());
320
		result = prime * result + ((activationTimestamp == null) ? 0 : activationTimestamp.hashCode());
26213 amit.gupta 321
		result = prime * result + badQuantity;
322
		result = prime * result + (buyBack ? 1231 : 1237);
323
		result = prime * result + Float.floatToIntBits(cgstRate);
324
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
325
		result = prime * result + fofoId;
326
		result = prime * result + goodQuantity;
327
		result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());
22009 ashik.ali 328
		result = prime * result + id;
26213 amit.gupta 329
		result = prime * result + Float.floatToIntBits(igstRate);
330
		result = prime * result + initialQuantity;
331
		result = prime * result + ((item == null) ? 0 : item.hashCode());
332
		result = prime * result + ((itemDescription == null) ? 0 : itemDescription.hashCode());
333
		result = prime * result + itemId;
334
		result = prime * result + ((lastScanType == null) ? 0 : lastScanType.hashCode());
335
		result = prime * result + Float.floatToIntBits(priceDropAmount);
336
		result = prime * result + ((purchase == null) ? 0 : purchase.hashCode());
337
		result = prime * result + purchaseId;
338
		result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
339
		result = prime * result + Float.floatToIntBits(sgstRate);
340
		result = prime * result + Float.floatToIntBits(unitPrice);
341
		result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
22009 ashik.ali 342
		return result;
343
	}
344
 
345
	@Override
346
	public boolean equals(Object obj) {
347
		if (this == obj)
348
			return true;
349
		if (obj == null)
350
			return false;
351
		if (getClass() != obj.getClass())
352
			return false;
353
		InventoryItem other = (InventoryItem) obj;
26304 amit.gupta 354
		if (activatedTimestamp == null) {
355
			if (other.activatedTimestamp != null)
356
				return false;
357
		} else if (!activatedTimestamp.equals(other.activatedTimestamp))
358
			return false;
359
		if (activationTimestamp == null) {
360
			if (other.activationTimestamp != null)
361
				return false;
362
		} else if (!activationTimestamp.equals(other.activationTimestamp))
363
			return false;
26213 amit.gupta 364
		if (badQuantity != other.badQuantity)
365
			return false;
366
		if (buyBack != other.buyBack)
367
			return false;
368
		if (Float.floatToIntBits(cgstRate) != Float.floatToIntBits(other.cgstRate))
369
			return false;
370
		if (createTimestamp == null) {
371
			if (other.createTimestamp != null)
372
				return false;
373
		} else if (!createTimestamp.equals(other.createTimestamp))
374
			return false;
375
		if (fofoId != other.fofoId)
376
			return false;
377
		if (goodQuantity != other.goodQuantity)
378
			return false;
379
		if (hsnCode == null) {
380
			if (other.hsnCode != null)
381
				return false;
382
		} else if (!hsnCode.equals(other.hsnCode))
383
			return false;
22009 ashik.ali 384
		if (id != other.id)
385
			return false;
26213 amit.gupta 386
		if (Float.floatToIntBits(igstRate) != Float.floatToIntBits(other.igstRate))
387
			return false;
388
		if (initialQuantity != other.initialQuantity)
389
			return false;
390
		if (item == null) {
391
			if (other.item != null)
392
				return false;
393
		} else if (!item.equals(other.item))
394
			return false;
395
		if (itemDescription == null) {
396
			if (other.itemDescription != null)
397
				return false;
398
		} else if (!itemDescription.equals(other.itemDescription))
399
			return false;
400
		if (itemId != other.itemId)
401
			return false;
402
		if (lastScanType != other.lastScanType)
403
			return false;
404
		if (Float.floatToIntBits(priceDropAmount) != Float.floatToIntBits(other.priceDropAmount))
405
			return false;
406
		if (purchase == null) {
407
			if (other.purchase != null)
408
				return false;
409
		} else if (!purchase.equals(other.purchase))
410
			return false;
411
		if (purchaseId != other.purchaseId)
412
			return false;
413
		if (serialNumber == null) {
414
			if (other.serialNumber != null)
415
				return false;
416
		} else if (!serialNumber.equals(other.serialNumber))
417
			return false;
418
		if (Float.floatToIntBits(sgstRate) != Float.floatToIntBits(other.sgstRate))
419
			return false;
420
		if (Float.floatToIntBits(unitPrice) != Float.floatToIntBits(other.unitPrice))
421
			return false;
422
		if (updateTimestamp == null) {
423
			if (other.updateTimestamp != null)
424
				return false;
425
		} else if (!updateTimestamp.equals(other.updateTimestamp))
426
			return false;
22009 ashik.ali 427
		return true;
428
	}
29093 amit.gupta 429
 
430
 
22009 ashik.ali 431
 
29093 amit.gupta 432
	public LocalDateTime getActivationTimestamp() {
433
		return activationTimestamp;
434
	}
435
 
436
	public void setActivationTimestamp(LocalDateTime activationTimestamp) {
437
		this.activationTimestamp = activationTimestamp;
438
	}
439
 
440
	public boolean isPriceDropValidated() {
29095 amit.gupta 441
		return priceDropValidated;
29093 amit.gupta 442
	}
443
 
444
	public void setPriceDropValidated(boolean priceDropValidated) {
445
		this.priceDropValidated = priceDropValidated;
446
	}
447
 
22009 ashik.ali 448
	@Override
21602 ashik.ali 449
	public String toString() {
21662 kshitij.so 450
		return "InventoryItem [id=" + id + ", itemId=" + itemId + ", fofoId=" + fofoId + ", serialNumber="
451
				+ serialNumber + ", initialQuantity=" + initialQuantity + ", goodQuantity=" + goodQuantity
26304 amit.gupta 452
				+ ", badQuantity=" + badQuantity + ", activationTimestamp=" + activationTimestamp + ", lastScanType="
453
				+ lastScanType + ", purchaseId=" + purchaseId + ", unitPrice=" + unitPrice + ", priceDropAmount="
454
				+ priceDropAmount + ", buyBack=" + buyBack + ", igstRate=" + igstRate + ", cgstRate=" + cgstRate
455
				+ ", sgstRate=" + sgstRate + ", hsnCode=" + hsnCode + ", createTimestamp=" + createTimestamp
456
				+ ", updateTimestamp=" + updateTimestamp + ", item=" + item + ", purchase=" + purchase
457
				+ ", itemDescription=" + itemDescription + ", activatedTimestamp=" + activatedTimestamp + "]";
21602 ashik.ali 458
	}
23983 amit.gupta 459
 
460
	@Override
461
	public int compareTo(Object o) {
462
		return o.hashCode() - this.hashCode();
463
	}
26213 amit.gupta 464
 
21552 ashik.ali 465
}