Subversion Repositories SmartDukaan

Rev

Rev 24718 | Rev 26299 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24718 Rev 26213
Line 1... Line 1...
1
package com.spice.profitmandi.dao.entity.fofo;
1
package com.spice.profitmandi.dao.entity.fofo;
2
 
2
 
3
import java.time.LocalDateTime;
3
import java.time.LocalDateTime;
4
import java.time.format.DateTimeFormatter;
4
import java.time.format.DateTimeFormatter;
5
 
5
 
6
import javax.persistence.CascadeType;
-
 
7
import javax.persistence.Column;
6
import javax.persistence.Column;
8
import javax.persistence.Convert;
7
import javax.persistence.Convert;
9
import javax.persistence.Entity;
8
import javax.persistence.Entity;
10
import javax.persistence.EnumType;
9
import javax.persistence.EnumType;
11
import javax.persistence.Enumerated;
10
import javax.persistence.Enumerated;
Line 25... Line 24...
25
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
24
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
26
import com.spice.profitmandi.dao.entity.catalog.Item;
25
import com.spice.profitmandi.dao.entity.catalog.Item;
27
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
26
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
28
 
27
 
29
@NamedQueries({
28
@NamedQueries({
30
	@NamedQuery(
-
 
31
		name = "InventoryItem.selectScannedCount",
-
 
32
		query = "select ii.itemId, sum(ii.initialQuantity) from InventoryItem ii "
29
		@NamedQuery(name = "InventoryItem.selectScannedCount", query = "select ii.itemId, sum(ii.initialQuantity) from InventoryItem ii "
33
				+ "where ii.itemId in :itemIds and ii.fofoId = :fofoId and ii.purchaseId = :purchaseId group by ii.itemId")
30
				+ "where ii.itemId in :itemIds and ii.fofoId = :fofoId and ii.purchaseId = :purchaseId group by ii.itemId") })
34
})
-
 
35
@Entity
31
@Entity
36
@Table(name="fofo.inventory_item", schema = "fofo")
32
@Table(name = "fofo.inventory_item", schema = "fofo")
37
public class InventoryItem implements Comparable {
33
public class InventoryItem implements Comparable {
38
	
34
 
39
	public InventoryItem(String serialNumber) {
35
	public InventoryItem(String serialNumber) {
40
		this.serialNumber = serialNumber;
36
		this.serialNumber = serialNumber;
41
	}
37
	}
42
	
38
 
43
	public InventoryItem() {
39
	public InventoryItem() {
44
		
40
 
45
	}
41
	}
46
	
42
 
47
	@Id
43
	@Id
48
	@Column(name="id", unique=true, updatable=false)
44
	@Column(name = "id", unique = true, updatable = false)
49
	@GeneratedValue(strategy = GenerationType.IDENTITY)
45
	@GeneratedValue(strategy = GenerationType.IDENTITY)
50
	private int id;
46
	private int id;
51
	
47
 
52
	@Column(name = "item_id")
48
	@Column(name = "item_id")
53
	private int itemId; 
49
	private int itemId;
54
	
50
 
55
	@Column(name = "fofo_id")
51
	@Column(name = "fofo_id")
56
	private int fofoId; 
52
	private int fofoId;
57
	
53
 
58
	@Column(name = "serial_number", length = 100)
54
	@Column(name = "serial_number", length = 100)
59
	private String serialNumber; 
55
	private String serialNumber;
60
	
56
 
61
	@Column(name = "initial_quantity")
57
	@Column(name = "initial_quantity")
62
	private int initialQuantity;
58
	private int initialQuantity;
63
	
59
 
64
	@Column(name = "good_quantity")
60
	@Column(name = "good_quantity")
65
	private int goodQuantity; 
61
	private int goodQuantity;
66
	
62
 
67
	@Column(name = "bad_quantity")
63
	@Column(name = "bad_quantity")
68
	private int badQuantity;
64
	private int badQuantity;
69
	
65
 
70
	@Column(name = "last_scan_type")
66
	@Column(name = "last_scan_type")
71
	@Enumerated(EnumType.STRING)
67
	@Enumerated(EnumType.STRING)
72
	private ScanType lastScanType;
68
	private ScanType lastScanType;
73
	
69
 
74
	@Column(name = "purchase_id")
70
	@Column(name = "purchase_id")
75
	private int purchaseId;
71
	private int purchaseId;
76
	
72
 
77
	@Column(name="unit_price")
73
	@Column(name = "unit_price")
78
	private float unitPrice;
74
	private float unitPrice;
79
	
75
 
80
	@Column(name = "price_drop_amount")
76
	@Column(name = "price_drop_amount")
81
	private float priceDropAmount;
77
	private float priceDropAmount;
82
	
78
 
83
	@Column(name = "buy_back", columnDefinition = "tinyint(1) default 1")
79
	@Column(name = "buy_back", columnDefinition = "tinyint(1) default 1")
84
	private boolean buyBack;
80
	private boolean buyBack;
85
	
81
 
86
	@Column(name = "igst_rate")
82
	@Column(name = "igst_rate")
87
	private float igstRate;
83
	private float igstRate;
88
	
84
 
89
	@Column(name = "cgst_rate")
85
	@Column(name = "cgst_rate")
90
	private float cgstRate;
86
	private float cgstRate;
91
	
87
 
92
	@Column(name = "sgst_rate")
88
	@Column(name = "sgst_rate")
93
	private float sgstRate;
89
	private float sgstRate;
94
	
90
 
95
	@Column(name = "hsn_code")
91
	@Column(name = "hsn_code")
96
	private String hsnCode;
92
	private String hsnCode;
97
	
93
 
98
	@Convert(converter = LocalDateTimeAttributeConverter.class)
94
	@Convert(converter = LocalDateTimeAttributeConverter.class)
99
	@Column(name = "create_timestamp")
95
	@Column(name = "create_timestamp")
100
	private LocalDateTime createTimestamp = LocalDateTime.now();
96
	private LocalDateTime createTimestamp = LocalDateTime.now();
101
	
97
 
102
	@Convert(converter = LocalDateTimeAttributeConverter.class)
98
	@Convert(converter = LocalDateTimeAttributeConverter.class)
103
	@Column(name = "update_timestamp")
99
	@Column(name = "update_timestamp")
104
	@UpdateTimestamp
100
	@UpdateTimestamp
105
	private LocalDateTime updateTimestamp = LocalDateTime.now();
101
	private LocalDateTime updateTimestamp = LocalDateTime.now();
106
	
102
 
107
	@OneToOne(fetch=FetchType.LAZY)
103
	@OneToOne(fetch = FetchType.LAZY)
108
	@JoinColumn(name="item_id",insertable=false,updatable=false,nullable=false, referencedColumnName = "id")
104
	@JoinColumn(name = "item_id", insertable = false, updatable = false, nullable = false, referencedColumnName = "id")
109
	private Item item;
105
	private Item item;
110
	
106
 
111
	@OneToOne(fetch=FetchType.LAZY)
107
	@OneToOne(fetch = FetchType.LAZY)
112
	@JoinColumn(name="purchase_id",insertable=false,updatable=false,nullable=false, referencedColumnName = "id")
108
	@JoinColumn(name = "purchase_id", insertable = false, updatable = false, nullable = false, referencedColumnName = "id")
113
	private Purchase purchase;
109
	private Purchase purchase;
-
 
110
 
-
 
111
	@Column(name = "activation_timestamp")
-
 
112
	private LocalDateTime activationTimestamp;
114
	
113
	
-
 
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
 
115
	@Transient
128
	@Transient
116
	private String itemDescription;
129
	private String itemDescription;
117
 
130
 
118
	public int getId() {
131
	public int getId() {
119
		return id;
132
		return id;
Line 128... Line 141...
128
	}
141
	}
129
 
142
 
130
	public void setItemId(int itemId) {
143
	public void setItemId(int itemId) {
131
		this.itemId = itemId;
144
		this.itemId = itemId;
132
	}
145
	}
133
	
146
 
134
	public void setFofoId(int fofoId) {
147
	public void setFofoId(int fofoId) {
135
		this.fofoId = fofoId;
148
		this.fofoId = fofoId;
136
	}
149
	}
137
 
150
 
138
	public int getFofoId() {
151
	public int getFofoId() {
Line 140... Line 153...
140
	}
153
	}
141
 
154
 
142
	public String getSerialNumber() {
155
	public String getSerialNumber() {
143
		return serialNumber;
156
		return serialNumber;
144
	}
157
	}
-
 
158
 
145
	public void setSerialNumber(String serialNumber) {
159
	public void setSerialNumber(String serialNumber) {
146
		this.serialNumber = serialNumber;
160
		this.serialNumber = serialNumber;
147
	}
161
	}
148
	
162
 
149
	public int getInitialQuantity() {
163
	public int getInitialQuantity() {
150
		return initialQuantity;
164
		return initialQuantity;
151
	}
165
	}
152
 
166
 
153
	public float getUnitPrice() {
167
	public float getUnitPrice() {
Line 159... Line 173...
159
	}
173
	}
160
 
174
 
161
	public void setInitialQuantity(int initialQuantity) {
175
	public void setInitialQuantity(int initialQuantity) {
162
		this.initialQuantity = initialQuantity;
176
		this.initialQuantity = initialQuantity;
163
	}
177
	}
164
	
178
 
165
	public float getNetPrice(){
179
	public float getNetPrice() {
166
		return unitPrice - priceDropAmount;
180
		return unitPrice - priceDropAmount;
167
	}
181
	}
168
 
182
 
169
	public int getGoodQuantity() {
183
	public int getGoodQuantity() {
170
		return goodQuantity;
184
		return goodQuantity;
Line 187... Line 201...
187
	}
201
	}
188
 
202
 
189
	public void setLastScanType(ScanType lastScanType) {
203
	public void setLastScanType(ScanType lastScanType) {
190
		this.lastScanType = lastScanType;
204
		this.lastScanType = lastScanType;
191
	}
205
	}
192
	
206
 
193
	public int getPurchaseId() {
207
	public int getPurchaseId() {
194
		return purchaseId;
208
		return purchaseId;
195
	}
209
	}
-
 
210
 
196
	public void setPurchaseId(int purchaseId) {
211
	public void setPurchaseId(int purchaseId) {
197
		this.purchaseId = purchaseId;
212
		this.purchaseId = purchaseId;
198
	}
213
	}
199
	
214
 
200
	public float getPriceDropAmount() {
215
	public float getPriceDropAmount() {
201
		return priceDropAmount;
216
		return priceDropAmount;
202
	}
217
	}
-
 
218
 
203
	public void setPriceDropAmount(float priceDropAmount) {
219
	public void setPriceDropAmount(float priceDropAmount) {
204
		this.priceDropAmount = priceDropAmount;
220
		this.priceDropAmount = priceDropAmount;
205
	}
221
	}
206
	
222
 
207
	public float getIgstRate() {
223
	public float getIgstRate() {
208
		return igstRate;
224
		return igstRate;
209
	}
225
	}
-
 
226
 
210
	public void setIgstRate(float igstRate) {
227
	public void setIgstRate(float igstRate) {
211
		this.igstRate = igstRate;
228
		this.igstRate = igstRate;
212
	}
229
	}
-
 
230
 
213
	public float getCgstRate() {
231
	public float getCgstRate() {
214
		return cgstRate;
232
		return cgstRate;
215
	}
233
	}
-
 
234
 
216
	public void setCgstRate(float cgstRate) {
235
	public void setCgstRate(float cgstRate) {
217
		this.cgstRate = cgstRate;
236
		this.cgstRate = cgstRate;
218
	}
237
	}
-
 
238
 
219
	public float getSgstRate() {
239
	public float getSgstRate() {
220
		return sgstRate;
240
		return sgstRate;
221
	}
241
	}
-
 
242
 
222
	public void setSgstRate(float sgstRate) {
243
	public void setSgstRate(float sgstRate) {
223
		this.sgstRate = sgstRate;
244
		this.sgstRate = sgstRate;
224
	}
245
	}
-
 
246
 
225
	public String getHsnCode() {
247
	public String getHsnCode() {
226
		return hsnCode;
248
		return hsnCode;
227
	}
249
	}
-
 
250
 
228
	public void setHsnCode(String hsnCode) {
251
	public void setHsnCode(String hsnCode) {
229
		this.hsnCode = hsnCode;
252
		this.hsnCode = hsnCode;
230
	}
253
	}
231
 
254
 
232
	public LocalDateTime getCreateTimestamp() {
255
	public LocalDateTime getCreateTimestamp() {
Line 234... Line 257...
234
	}
257
	}
235
 
258
 
236
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
259
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
237
		this.createTimestamp = createTimestamp;
260
		this.createTimestamp = createTimestamp;
238
	}
261
	}
239
	
262
 
240
	public LocalDateTime getUpdateTimestamp() {
263
	public LocalDateTime getUpdateTimestamp() {
241
		return updateTimestamp;
264
		return updateTimestamp;
242
	}
265
	}
-
 
266
 
243
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
267
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
244
		this.updateTimestamp = updateTimestamp;
268
		this.updateTimestamp = updateTimestamp;
245
	}
269
	}
246
	
270
 
247
	public Item getItem() {
271
	public Item getItem() {
248
		return item;
272
		return item;
249
	}
273
	}
-
 
274
 
250
	public void setItem(Item item) {
275
	public void setItem(Item item) {
251
		this.item = item;
276
		this.item = item;
252
	}
277
	}
253
 
278
 
254
	public boolean isBuyBack() {
279
	public boolean isBuyBack() {
255
		return buyBack;
280
		return buyBack;
256
	}
281
	}
257
	
282
 
258
	public void setBuyBack(boolean buyBack) {
283
	public void setBuyBack(boolean buyBack) {
259
		this.buyBack = buyBack;
284
		this.buyBack = buyBack;
260
	}
285
	}
261
	
286
 
262
	public Purchase getPurchase() {
287
	public Purchase getPurchase() {
263
		return purchase;
288
		return purchase;
264
	}
289
	}
265
	
290
 
266
	public void setPurchase(Purchase purchase) {
291
	public void setPurchase(Purchase purchase) {
267
		this.purchase = purchase;
292
		this.purchase = purchase;
268
	}
293
	}
269
	
294
 
270
	public String getFormattedCreateTimestamp(){
295
	public String getFormattedCreateTimestamp() {
271
		if(createTimestamp == null){
296
		if (createTimestamp == null) {
272
			return null;
297
			return null;
273
		}
298
		}
274
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
299
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm");
275
		return createTimestamp.format(formatter);
300
		return createTimestamp.format(formatter);
276
    }
301
	}
277
	
302
 
278
	public String getItemDescription() {
303
	public String getItemDescription() {
279
		return itemDescription;
304
		return itemDescription;
280
	}
305
	}
281
	
306
 
282
	public void setItemDescription(String itemDescription) {
307
	public void setItemDescription(String itemDescription) {
283
		this.itemDescription = itemDescription;
308
		this.itemDescription = itemDescription;
284
	}
309
	}
285
	
310
 
286
	@Override
311
	@Override
287
	public int hashCode() {
312
	public int hashCode() {
288
		final int prime = 31;
313
		final int prime = 31;
289
		int result = 1;
314
		int result = 1;
-
 
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());
290
		result = prime * result + id;
323
		result = prime * result + id;
-
 
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());
291
		return result;
337
		return result;
292
	}
338
	}
293
 
339
 
294
	@Override
340
	@Override
295
	public boolean equals(Object obj) {
341
	public boolean equals(Object obj) {
Line 298... Line 344...
298
		if (obj == null)
344
		if (obj == null)
299
			return false;
345
			return false;
300
		if (getClass() != obj.getClass())
346
		if (getClass() != obj.getClass())
301
			return false;
347
			return false;
302
		InventoryItem other = (InventoryItem) obj;
348
		InventoryItem other = (InventoryItem) obj;
-
 
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;
303
		if (id != other.id)
374
		if (id != other.id)
304
			return false;
375
			return false;
-
 
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;
305
		return true;
417
		return true;
306
	}
418
	}
307
 
419
 
308
	@Override
420
	@Override
309
	public String toString() {
421
	public String toString() {
Line 311... Line 423...
311
				+ serialNumber + ", initialQuantity=" + initialQuantity + ", goodQuantity=" + goodQuantity
423
				+ serialNumber + ", initialQuantity=" + initialQuantity + ", goodQuantity=" + goodQuantity
312
				+ ", badQuantity=" + badQuantity + ", lastScanType=" + lastScanType + ", purchaseId=" + purchaseId
424
				+ ", badQuantity=" + badQuantity + ", lastScanType=" + lastScanType + ", purchaseId=" + purchaseId
313
				+ ", unitPrice=" + unitPrice + ", priceDropAmount=" + priceDropAmount + ", buyBack=" + buyBack
425
				+ ", unitPrice=" + unitPrice + ", priceDropAmount=" + priceDropAmount + ", buyBack=" + buyBack
314
				+ ", igstRate=" + igstRate + ", cgstRate=" + cgstRate + ", sgstRate=" + sgstRate + ", hsnCode="
426
				+ ", igstRate=" + igstRate + ", cgstRate=" + cgstRate + ", sgstRate=" + sgstRate + ", hsnCode="
315
				+ hsnCode + ", createTimestamp=" + createTimestamp + ", updateTimestamp=" + updateTimestamp + ", item="
427
				+ hsnCode + ", createTimestamp=" + createTimestamp + ", updateTimestamp=" + updateTimestamp + ", item="
-
 
428
				+ item + ", purchase=" + purchase + ", activationTimestamp=" + activationTimestamp
316
				+ item + ", purchase=" + purchase + "]";
429
				+ ", itemDescription=" + itemDescription + "]";
317
	}
430
	}
318
 
431
 
319
	@Override
432
	@Override
320
	public int compareTo(Object o) {
433
	public int compareTo(Object o) {
321
		return o.hashCode() - this.hashCode();
434
		return o.hashCode() - this.hashCode();
322
	}
435
	}
323
	
436
 
324
}
437
}