| 4500 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.warehouse.domain;
|
|
|
5 |
|
| 5110 |
mandeep.dh |
6 |
import in.shop2020.generic.ExceptionType;
|
| 4555 |
mandeep.dh |
7 |
import in.shop2020.purchase.LineItem;
|
|
|
8 |
import in.shop2020.purchase.PurchaseOrder;
|
|
|
9 |
import in.shop2020.purchase.PurchaseService.Client;
|
|
|
10 |
import in.shop2020.thrift.clients.PurchaseClient;
|
| 5185 |
mandeep.dh |
11 |
import in.shop2020.warehouse.ScanType;
|
| 7410 |
amar.kumar |
12 |
import in.shop2020.warehouse.TransferLotStatus;
|
| 5110 |
mandeep.dh |
13 |
import in.shop2020.warehouse.WarehouseServiceException;
|
| 4500 |
mandeep.dh |
14 |
|
| 4555 |
mandeep.dh |
15 |
import org.apache.commons.logging.Log;
|
|
|
16 |
import org.apache.commons.logging.LogFactory;
|
|
|
17 |
|
|
|
18 |
|
| 4500 |
mandeep.dh |
19 |
/**
|
|
|
20 |
* @author mandeep
|
|
|
21 |
*
|
|
|
22 |
*/
|
|
|
23 |
public class InventoryItem {
|
| 4555 |
mandeep.dh |
24 |
private static Log logger = LogFactory.getLog(InventoryItem.class);
|
|
|
25 |
|
| 4500 |
mandeep.dh |
26 |
private long id;
|
|
|
27 |
private long itemId;
|
|
|
28 |
private String itemNumber;
|
|
|
29 |
private String serialNumber;
|
|
|
30 |
private long initialQuantity;
|
|
|
31 |
private long currentQuantity;
|
|
|
32 |
private long purchaseId;
|
| 6467 |
amar.kumar |
33 |
private long purchaseReturnId;
|
| 5185 |
mandeep.dh |
34 |
private long currentWarehouseId;
|
|
|
35 |
private ScanType lastScanType;
|
| 7410 |
amar.kumar |
36 |
private long physicalWarehouseId;
|
|
|
37 |
private TransferLotStatus transferStatus;
|
| 5185 |
mandeep.dh |
38 |
|
| 4500 |
mandeep.dh |
39 |
public static InventoryItem create(in.shop2020.warehouse.InventoryItem thriftInventoryItem) {
|
|
|
40 |
InventoryItem inventoryItem = new InventoryItem();
|
|
|
41 |
inventoryItem.id = thriftInventoryItem.getId();
|
|
|
42 |
inventoryItem.itemId = thriftInventoryItem.getItemId();
|
|
|
43 |
inventoryItem.itemNumber = thriftInventoryItem.getItemNumber();
|
|
|
44 |
inventoryItem.serialNumber = thriftInventoryItem.getSerialNumber();
|
|
|
45 |
inventoryItem.initialQuantity = thriftInventoryItem.getInitialQuantity();
|
|
|
46 |
inventoryItem.currentQuantity = thriftInventoryItem.getCurrentQuantity();
|
|
|
47 |
inventoryItem.purchaseId = thriftInventoryItem.getPurchaseId();
|
| 6467 |
amar.kumar |
48 |
inventoryItem.purchaseReturnId = thriftInventoryItem.getPurchaseReturnId();
|
| 5185 |
mandeep.dh |
49 |
inventoryItem.currentWarehouseId = thriftInventoryItem.getCurrentWarehouseId();
|
|
|
50 |
inventoryItem.lastScanType = thriftInventoryItem.getLastScanType();
|
| 7410 |
amar.kumar |
51 |
inventoryItem.physicalWarehouseId = thriftInventoryItem.getPhysicalWarehouseId();
|
|
|
52 |
inventoryItem.transferStatus = thriftInventoryItem.getTransferStatus();
|
| 4500 |
mandeep.dh |
53 |
|
|
|
54 |
return inventoryItem;
|
|
|
55 |
}
|
|
|
56 |
|
| 5110 |
mandeep.dh |
57 |
public in.shop2020.warehouse.InventoryItem convert() throws WarehouseServiceException {
|
| 4500 |
mandeep.dh |
58 |
in.shop2020.warehouse.InventoryItem inventoryItem = new in.shop2020.warehouse.InventoryItem();
|
|
|
59 |
inventoryItem.setId(id);
|
|
|
60 |
inventoryItem.setItemId(itemId);
|
|
|
61 |
inventoryItem.setCurrentQuantity(currentQuantity);
|
|
|
62 |
inventoryItem.setInitialQuantity(initialQuantity);
|
|
|
63 |
inventoryItem.setItemNumber(itemNumber);
|
|
|
64 |
inventoryItem.setPurchaseId(purchaseId);
|
| 6467 |
amar.kumar |
65 |
inventoryItem.setPurchaseReturnId(purchaseReturnId);
|
| 4500 |
mandeep.dh |
66 |
inventoryItem.setSerialNumber(serialNumber);
|
| 5185 |
mandeep.dh |
67 |
inventoryItem.setCurrentWarehouseId(currentWarehouseId);
|
|
|
68 |
inventoryItem.setLastScanType(lastScanType);
|
| 7410 |
amar.kumar |
69 |
inventoryItem.setTransferStatus(transferStatus);
|
|
|
70 |
inventoryItem.setPhysicalWarehouseId(physicalWarehouseId);
|
| 4555 |
mandeep.dh |
71 |
|
|
|
72 |
// Setting derived fields
|
|
|
73 |
try {
|
|
|
74 |
Client client = new PurchaseClient().getClient();
|
|
|
75 |
PurchaseOrder purchaseOrder = client.getPurchaseOrderForPurchase(purchaseId);
|
|
|
76 |
inventoryItem.setSupplierId(purchaseOrder.getSupplierId());
|
|
|
77 |
for (LineItem lineItem : purchaseOrder.getLineitems()) {
|
|
|
78 |
if (lineItem.getItemId() == itemId) {
|
|
|
79 |
inventoryItem.setUnitPrice(lineItem.getUnitPrice());
|
| 7672 |
rajveer |
80 |
inventoryItem.setNlc(lineItem.getNlc());
|
| 4555 |
mandeep.dh |
81 |
break;
|
|
|
82 |
}
|
|
|
83 |
}
|
| 5110 |
mandeep.dh |
84 |
} catch (Exception e) {
|
| 4555 |
mandeep.dh |
85 |
logger.error("Could not fetch purchase order for purchase id: " + purchaseId, e);
|
| 5110 |
mandeep.dh |
86 |
throw new WarehouseServiceException(ExceptionType.DATABASE_ERROR, "Could not find item in PO.");
|
| 4555 |
mandeep.dh |
87 |
}
|
|
|
88 |
|
| 4500 |
mandeep.dh |
89 |
return inventoryItem;
|
| 4555 |
mandeep.dh |
90 |
}
|
| 4500 |
mandeep.dh |
91 |
|
|
|
92 |
public long getId() {
|
|
|
93 |
return id;
|
|
|
94 |
}
|
|
|
95 |
public void setId(long id) {
|
|
|
96 |
this.id = id;
|
|
|
97 |
}
|
|
|
98 |
public long getItemId() {
|
|
|
99 |
return itemId;
|
|
|
100 |
}
|
|
|
101 |
public void setItemId(long itemId) {
|
|
|
102 |
this.itemId = itemId;
|
|
|
103 |
}
|
|
|
104 |
public String getItemNumber() {
|
|
|
105 |
return itemNumber;
|
|
|
106 |
}
|
|
|
107 |
public void setItemNumber(String itemNumber) {
|
|
|
108 |
this.itemNumber = itemNumber;
|
|
|
109 |
}
|
|
|
110 |
public String getSerialNumber() {
|
|
|
111 |
return serialNumber;
|
|
|
112 |
}
|
|
|
113 |
public void setSerialNumber(String serialNumber) {
|
|
|
114 |
this.serialNumber = serialNumber;
|
|
|
115 |
}
|
|
|
116 |
public long getInitialQuantity() {
|
|
|
117 |
return initialQuantity;
|
|
|
118 |
}
|
|
|
119 |
public void setInitialQuantity(long initialQuantity) {
|
|
|
120 |
this.initialQuantity = initialQuantity;
|
|
|
121 |
}
|
|
|
122 |
public long getCurrentQuantity() {
|
|
|
123 |
return currentQuantity;
|
|
|
124 |
}
|
|
|
125 |
public void setCurrentQuantity(long currentQuantity) {
|
|
|
126 |
this.currentQuantity = currentQuantity;
|
|
|
127 |
}
|
|
|
128 |
public long getPurchaseId() {
|
|
|
129 |
return purchaseId;
|
|
|
130 |
}
|
|
|
131 |
public void setPurchaseId(long purchaseId) {
|
|
|
132 |
this.purchaseId = purchaseId;
|
|
|
133 |
}
|
| 5185 |
mandeep.dh |
134 |
|
| 6467 |
amar.kumar |
135 |
public long getPurchaseReturnId() {
|
|
|
136 |
return purchaseReturnId;
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
public void setPurchaseReturnId(long purchaseReturnId) {
|
|
|
140 |
this.purchaseReturnId = purchaseReturnId;
|
|
|
141 |
}
|
|
|
142 |
|
|
|
143 |
public long getCurrentWarehouseId() {
|
| 5185 |
mandeep.dh |
144 |
return currentWarehouseId;
|
|
|
145 |
}
|
|
|
146 |
|
|
|
147 |
public void setCurrentWarehouseId(long currentWarehouseId) {
|
|
|
148 |
this.currentWarehouseId = currentWarehouseId;
|
|
|
149 |
}
|
|
|
150 |
|
|
|
151 |
public ScanType getLastScanType() {
|
|
|
152 |
return lastScanType;
|
|
|
153 |
}
|
|
|
154 |
|
|
|
155 |
public void setLastScanType(ScanType lastScanType) {
|
|
|
156 |
this.lastScanType = lastScanType;
|
|
|
157 |
}
|
| 7410 |
amar.kumar |
158 |
|
|
|
159 |
public TransferLotStatus getTransferStatus() {
|
|
|
160 |
return transferStatus;
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
public void setTransferStatus(TransferLotStatus transferStatus) {
|
|
|
164 |
this.transferStatus = transferStatus;
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
public long getPhysicalWarehouseId() {
|
|
|
168 |
return physicalWarehouseId;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
public void setPhysicalWarehouseId(long physicalWarehouseId) {
|
|
|
172 |
this.physicalWarehouseId = physicalWarehouseId;
|
|
|
173 |
}
|
|
|
174 |
|
| 4500 |
mandeep.dh |
175 |
}
|