Subversion Repositories SmartDukaan

Rev

Rev 26303 | Rev 29093 | 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
 
124
	public LocalDateTime getActivatedTimestamp() {
125
		return activatedTimestamp;
126
	}
127
 
128
	public void setActivatedTimestamp(LocalDateTime activatedTimestamp) {
129
		this.activatedTimestamp = activatedTimestamp;
130
	}
131
 
21552 ashik.ali 132
	public int getId() {
133
		return id;
134
	}
135
 
136
	public void setId(int id) {
137
		this.id = id;
138
	}
139
 
140
	public int getItemId() {
141
		return itemId;
142
	}
143
 
144
	public void setItemId(int itemId) {
145
		this.itemId = itemId;
146
	}
26213 amit.gupta 147
 
21984 kshitij.so 148
	public void setFofoId(int fofoId) {
149
		this.fofoId = fofoId;
150
	}
21552 ashik.ali 151
 
152
	public int getFofoId() {
153
		return fofoId;
154
	}
155
 
21609 ashik.ali 156
	public String getSerialNumber() {
157
		return serialNumber;
21552 ashik.ali 158
	}
26213 amit.gupta 159
 
21609 ashik.ali 160
	public void setSerialNumber(String serialNumber) {
161
		this.serialNumber = serialNumber;
21552 ashik.ali 162
	}
26213 amit.gupta 163
 
21552 ashik.ali 164
	public int getInitialQuantity() {
165
		return initialQuantity;
166
	}
167
 
23110 ashik.ali 168
	public float getUnitPrice() {
21984 kshitij.so 169
		return unitPrice;
170
	}
171
 
172
	public void setUnitPrice(Float unitPrice) {
173
		this.unitPrice = unitPrice;
174
	}
175
 
21552 ashik.ali 176
	public void setInitialQuantity(int initialQuantity) {
177
		this.initialQuantity = initialQuantity;
178
	}
26213 amit.gupta 179
 
180
	public float getNetPrice() {
23110 ashik.ali 181
		return unitPrice - priceDropAmount;
182
	}
21552 ashik.ali 183
 
184
	public int getGoodQuantity() {
185
		return goodQuantity;
186
	}
187
 
188
	public void setGoodQuantity(int goodQuantity) {
189
		this.goodQuantity = goodQuantity;
190
	}
191
 
192
	public int getBadQuantity() {
193
		return badQuantity;
194
	}
195
 
196
	public void setBadQuantity(int badQuantity) {
197
		this.badQuantity = badQuantity;
198
	}
199
 
200
	public ScanType getLastScanType() {
201
		return lastScanType;
202
	}
203
 
204
	public void setLastScanType(ScanType lastScanType) {
205
		this.lastScanType = lastScanType;
206
	}
26213 amit.gupta 207
 
21633 ashik.ali 208
	public int getPurchaseId() {
209
		return purchaseId;
21552 ashik.ali 210
	}
26213 amit.gupta 211
 
21633 ashik.ali 212
	public void setPurchaseId(int purchaseId) {
213
		this.purchaseId = purchaseId;
21552 ashik.ali 214
	}
26213 amit.gupta 215
 
23110 ashik.ali 216
	public float getPriceDropAmount() {
21710 ashik.ali 217
		return priceDropAmount;
218
	}
26213 amit.gupta 219
 
23110 ashik.ali 220
	public void setPriceDropAmount(float priceDropAmount) {
21710 ashik.ali 221
		this.priceDropAmount = priceDropAmount;
222
	}
26213 amit.gupta 223
 
22859 ashik.ali 224
	public float getIgstRate() {
225
		return igstRate;
226
	}
26213 amit.gupta 227
 
22859 ashik.ali 228
	public void setIgstRate(float igstRate) {
229
		this.igstRate = igstRate;
230
	}
26213 amit.gupta 231
 
22859 ashik.ali 232
	public float getCgstRate() {
233
		return cgstRate;
234
	}
26213 amit.gupta 235
 
22859 ashik.ali 236
	public void setCgstRate(float cgstRate) {
237
		this.cgstRate = cgstRate;
238
	}
26213 amit.gupta 239
 
22859 ashik.ali 240
	public float getSgstRate() {
241
		return sgstRate;
242
	}
26213 amit.gupta 243
 
22859 ashik.ali 244
	public void setSgstRate(float sgstRate) {
245
		this.sgstRate = sgstRate;
246
	}
26213 amit.gupta 247
 
22859 ashik.ali 248
	public String getHsnCode() {
249
		return hsnCode;
250
	}
26213 amit.gupta 251
 
22859 ashik.ali 252
	public void setHsnCode(String hsnCode) {
253
		this.hsnCode = hsnCode;
254
	}
21552 ashik.ali 255
 
256
	public LocalDateTime getCreateTimestamp() {
257
		return createTimestamp;
258
	}
259
 
260
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
261
		this.createTimestamp = createTimestamp;
262
	}
26213 amit.gupta 263
 
21710 ashik.ali 264
	public LocalDateTime getUpdateTimestamp() {
265
		return updateTimestamp;
266
	}
26213 amit.gupta 267
 
21710 ashik.ali 268
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
269
		this.updateTimestamp = updateTimestamp;
270
	}
26213 amit.gupta 271
 
21653 ashik.ali 272
	public Item getItem() {
273
		return item;
274
	}
26213 amit.gupta 275
 
21653 ashik.ali 276
	public void setItem(Item item) {
277
		this.item = item;
278
	}
21602 ashik.ali 279
 
22352 ashik.ali 280
	public boolean isBuyBack() {
281
		return buyBack;
282
	}
26213 amit.gupta 283
 
22352 ashik.ali 284
	public void setBuyBack(boolean buyBack) {
285
		this.buyBack = buyBack;
286
	}
26213 amit.gupta 287
 
23019 ashik.ali 288
	public Purchase getPurchase() {
289
		return purchase;
290
	}
26213 amit.gupta 291
 
23019 ashik.ali 292
	public void setPurchase(Purchase purchase) {
293
		this.purchase = purchase;
294
	}
26213 amit.gupta 295
 
296
	public String getFormattedCreateTimestamp() {
297
		if (createTimestamp == null) {
23527 ashik.ali 298
			return null;
299
		}
24402 amit.gupta 300
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
23527 ashik.ali 301
		return createTimestamp.format(formatter);
26213 amit.gupta 302
	}
303
 
23527 ashik.ali 304
	public String getItemDescription() {
305
		return itemDescription;
306
	}
26213 amit.gupta 307
 
23527 ashik.ali 308
	public void setItemDescription(String itemDescription) {
309
		this.itemDescription = itemDescription;
310
	}
26213 amit.gupta 311
 
21602 ashik.ali 312
	@Override
22009 ashik.ali 313
	public int hashCode() {
314
		final int prime = 31;
315
		int result = 1;
26304 amit.gupta 316
		result = prime * result + ((activatedTimestamp == null) ? 0 : activatedTimestamp.hashCode());
317
		result = prime * result + ((activationTimestamp == null) ? 0 : activationTimestamp.hashCode());
26213 amit.gupta 318
		result = prime * result + badQuantity;
319
		result = prime * result + (buyBack ? 1231 : 1237);
320
		result = prime * result + Float.floatToIntBits(cgstRate);
321
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
322
		result = prime * result + fofoId;
323
		result = prime * result + goodQuantity;
324
		result = prime * result + ((hsnCode == null) ? 0 : hsnCode.hashCode());
22009 ashik.ali 325
		result = prime * result + id;
26213 amit.gupta 326
		result = prime * result + Float.floatToIntBits(igstRate);
327
		result = prime * result + initialQuantity;
328
		result = prime * result + ((item == null) ? 0 : item.hashCode());
329
		result = prime * result + ((itemDescription == null) ? 0 : itemDescription.hashCode());
330
		result = prime * result + itemId;
331
		result = prime * result + ((lastScanType == null) ? 0 : lastScanType.hashCode());
332
		result = prime * result + Float.floatToIntBits(priceDropAmount);
333
		result = prime * result + ((purchase == null) ? 0 : purchase.hashCode());
334
		result = prime * result + purchaseId;
335
		result = prime * result + ((serialNumber == null) ? 0 : serialNumber.hashCode());
336
		result = prime * result + Float.floatToIntBits(sgstRate);
337
		result = prime * result + Float.floatToIntBits(unitPrice);
338
		result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
22009 ashik.ali 339
		return result;
340
	}
341
 
342
	@Override
343
	public boolean equals(Object obj) {
344
		if (this == obj)
345
			return true;
346
		if (obj == null)
347
			return false;
348
		if (getClass() != obj.getClass())
349
			return false;
350
		InventoryItem other = (InventoryItem) obj;
26304 amit.gupta 351
		if (activatedTimestamp == null) {
352
			if (other.activatedTimestamp != null)
353
				return false;
354
		} else if (!activatedTimestamp.equals(other.activatedTimestamp))
355
			return false;
356
		if (activationTimestamp == null) {
357
			if (other.activationTimestamp != null)
358
				return false;
359
		} else if (!activationTimestamp.equals(other.activationTimestamp))
360
			return false;
26213 amit.gupta 361
		if (badQuantity != other.badQuantity)
362
			return false;
363
		if (buyBack != other.buyBack)
364
			return false;
365
		if (Float.floatToIntBits(cgstRate) != Float.floatToIntBits(other.cgstRate))
366
			return false;
367
		if (createTimestamp == null) {
368
			if (other.createTimestamp != null)
369
				return false;
370
		} else if (!createTimestamp.equals(other.createTimestamp))
371
			return false;
372
		if (fofoId != other.fofoId)
373
			return false;
374
		if (goodQuantity != other.goodQuantity)
375
			return false;
376
		if (hsnCode == null) {
377
			if (other.hsnCode != null)
378
				return false;
379
		} else if (!hsnCode.equals(other.hsnCode))
380
			return false;
22009 ashik.ali 381
		if (id != other.id)
382
			return false;
26213 amit.gupta 383
		if (Float.floatToIntBits(igstRate) != Float.floatToIntBits(other.igstRate))
384
			return false;
385
		if (initialQuantity != other.initialQuantity)
386
			return false;
387
		if (item == null) {
388
			if (other.item != null)
389
				return false;
390
		} else if (!item.equals(other.item))
391
			return false;
392
		if (itemDescription == null) {
393
			if (other.itemDescription != null)
394
				return false;
395
		} else if (!itemDescription.equals(other.itemDescription))
396
			return false;
397
		if (itemId != other.itemId)
398
			return false;
399
		if (lastScanType != other.lastScanType)
400
			return false;
401
		if (Float.floatToIntBits(priceDropAmount) != Float.floatToIntBits(other.priceDropAmount))
402
			return false;
403
		if (purchase == null) {
404
			if (other.purchase != null)
405
				return false;
406
		} else if (!purchase.equals(other.purchase))
407
			return false;
408
		if (purchaseId != other.purchaseId)
409
			return false;
410
		if (serialNumber == null) {
411
			if (other.serialNumber != null)
412
				return false;
413
		} else if (!serialNumber.equals(other.serialNumber))
414
			return false;
415
		if (Float.floatToIntBits(sgstRate) != Float.floatToIntBits(other.sgstRate))
416
			return false;
417
		if (Float.floatToIntBits(unitPrice) != Float.floatToIntBits(other.unitPrice))
418
			return false;
419
		if (updateTimestamp == null) {
420
			if (other.updateTimestamp != null)
421
				return false;
422
		} else if (!updateTimestamp.equals(other.updateTimestamp))
423
			return false;
22009 ashik.ali 424
		return true;
425
	}
426
 
427
	@Override
21602 ashik.ali 428
	public String toString() {
21662 kshitij.so 429
		return "InventoryItem [id=" + id + ", itemId=" + itemId + ", fofoId=" + fofoId + ", serialNumber="
430
				+ serialNumber + ", initialQuantity=" + initialQuantity + ", goodQuantity=" + goodQuantity
26304 amit.gupta 431
				+ ", badQuantity=" + badQuantity + ", activationTimestamp=" + activationTimestamp + ", lastScanType="
432
				+ lastScanType + ", purchaseId=" + purchaseId + ", unitPrice=" + unitPrice + ", priceDropAmount="
433
				+ priceDropAmount + ", buyBack=" + buyBack + ", igstRate=" + igstRate + ", cgstRate=" + cgstRate
434
				+ ", sgstRate=" + sgstRate + ", hsnCode=" + hsnCode + ", createTimestamp=" + createTimestamp
435
				+ ", updateTimestamp=" + updateTimestamp + ", item=" + item + ", purchase=" + purchase
436
				+ ", itemDescription=" + itemDescription + ", activatedTimestamp=" + activatedTimestamp + "]";
21602 ashik.ali 437
	}
23983 amit.gupta 438
 
439
	@Override
440
	public int compareTo(Object o) {
441
		return o.hashCode() - this.hashCode();
442
	}
26213 amit.gupta 443
 
21552 ashik.ali 444
}