Subversion Repositories SmartDukaan

Rev

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