| 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 |
|
| 21617 |
amit.gupta |
15 |
import java.util.Date;
|
|
|
16 |
|
| 4555 |
mandeep.dh |
17 |
import org.apache.commons.logging.Log;
|
|
|
18 |
import org.apache.commons.logging.LogFactory;
|
|
|
19 |
|
|
|
20 |
|
| 4500 |
mandeep.dh |
21 |
/**
|
|
|
22 |
* @author mandeep
|
|
|
23 |
*
|
|
|
24 |
*/
|
|
|
25 |
public class InventoryItem {
|
| 4555 |
mandeep.dh |
26 |
private static Log logger = LogFactory.getLog(InventoryItem.class);
|
|
|
27 |
|
| 4500 |
mandeep.dh |
28 |
private long id;
|
|
|
29 |
private long itemId;
|
|
|
30 |
private String itemNumber;
|
|
|
31 |
private String serialNumber;
|
|
|
32 |
private long initialQuantity;
|
|
|
33 |
private long currentQuantity;
|
|
|
34 |
private long purchaseId;
|
| 6467 |
amar.kumar |
35 |
private long purchaseReturnId;
|
| 5185 |
mandeep.dh |
36 |
private long currentWarehouseId;
|
|
|
37 |
private ScanType lastScanType;
|
| 21617 |
amit.gupta |
38 |
private Date activated;
|
|
|
39 |
private Date created;
|
| 7410 |
amar.kumar |
40 |
private long physicalWarehouseId;
|
|
|
41 |
private TransferLotStatus transferStatus;
|
| 5185 |
mandeep.dh |
42 |
|
| 4500 |
mandeep.dh |
43 |
public static InventoryItem create(in.shop2020.warehouse.InventoryItem thriftInventoryItem) {
|
|
|
44 |
InventoryItem inventoryItem = new InventoryItem();
|
|
|
45 |
inventoryItem.id = thriftInventoryItem.getId();
|
|
|
46 |
inventoryItem.itemId = thriftInventoryItem.getItemId();
|
|
|
47 |
inventoryItem.itemNumber = thriftInventoryItem.getItemNumber();
|
|
|
48 |
inventoryItem.serialNumber = thriftInventoryItem.getSerialNumber();
|
|
|
49 |
inventoryItem.initialQuantity = thriftInventoryItem.getInitialQuantity();
|
|
|
50 |
inventoryItem.currentQuantity = thriftInventoryItem.getCurrentQuantity();
|
|
|
51 |
inventoryItem.purchaseId = thriftInventoryItem.getPurchaseId();
|
| 6467 |
amar.kumar |
52 |
inventoryItem.purchaseReturnId = thriftInventoryItem.getPurchaseReturnId();
|
| 5185 |
mandeep.dh |
53 |
inventoryItem.currentWarehouseId = thriftInventoryItem.getCurrentWarehouseId();
|
|
|
54 |
inventoryItem.lastScanType = thriftInventoryItem.getLastScanType();
|
| 7410 |
amar.kumar |
55 |
inventoryItem.physicalWarehouseId = thriftInventoryItem.getPhysicalWarehouseId();
|
|
|
56 |
inventoryItem.transferStatus = thriftInventoryItem.getTransferStatus();
|
| 21617 |
amit.gupta |
57 |
inventoryItem.created = new Date();
|
| 4500 |
mandeep.dh |
58 |
|
|
|
59 |
return inventoryItem;
|
|
|
60 |
}
|
|
|
61 |
|
| 5110 |
mandeep.dh |
62 |
public in.shop2020.warehouse.InventoryItem convert() throws WarehouseServiceException {
|
| 4500 |
mandeep.dh |
63 |
in.shop2020.warehouse.InventoryItem inventoryItem = new in.shop2020.warehouse.InventoryItem();
|
|
|
64 |
inventoryItem.setId(id);
|
|
|
65 |
inventoryItem.setItemId(itemId);
|
|
|
66 |
inventoryItem.setCurrentQuantity(currentQuantity);
|
|
|
67 |
inventoryItem.setInitialQuantity(initialQuantity);
|
|
|
68 |
inventoryItem.setItemNumber(itemNumber);
|
|
|
69 |
inventoryItem.setPurchaseId(purchaseId);
|
| 6467 |
amar.kumar |
70 |
inventoryItem.setPurchaseReturnId(purchaseReturnId);
|
| 4500 |
mandeep.dh |
71 |
inventoryItem.setSerialNumber(serialNumber);
|
| 5185 |
mandeep.dh |
72 |
inventoryItem.setCurrentWarehouseId(currentWarehouseId);
|
|
|
73 |
inventoryItem.setLastScanType(lastScanType);
|
| 7410 |
amar.kumar |
74 |
inventoryItem.setTransferStatus(transferStatus);
|
| 21617 |
amit.gupta |
75 |
inventoryItem.setPhysicalWarehouseId(physicalWarehouseId);
|
|
|
76 |
if(this.activated!=null) {
|
|
|
77 |
inventoryItem.setActivated(this.activated.getTime());
|
|
|
78 |
}
|
|
|
79 |
if(this.created != null) {
|
|
|
80 |
inventoryItem.setCreated(this.created.getTime());
|
|
|
81 |
}
|
| 4555 |
mandeep.dh |
82 |
|
|
|
83 |
// Setting derived fields
|
|
|
84 |
try {
|
|
|
85 |
Client client = new PurchaseClient().getClient();
|
|
|
86 |
PurchaseOrder purchaseOrder = client.getPurchaseOrderForPurchase(purchaseId);
|
|
|
87 |
inventoryItem.setSupplierId(purchaseOrder.getSupplierId());
|
|
|
88 |
for (LineItem lineItem : purchaseOrder.getLineitems()) {
|
|
|
89 |
if (lineItem.getItemId() == itemId) {
|
|
|
90 |
inventoryItem.setUnitPrice(lineItem.getUnitPrice());
|
| 7672 |
rajveer |
91 |
inventoryItem.setNlc(lineItem.getNlc());
|
| 4555 |
mandeep.dh |
92 |
break;
|
|
|
93 |
}
|
|
|
94 |
}
|
| 5110 |
mandeep.dh |
95 |
} catch (Exception e) {
|
| 4555 |
mandeep.dh |
96 |
logger.error("Could not fetch purchase order for purchase id: " + purchaseId, e);
|
| 5110 |
mandeep.dh |
97 |
throw new WarehouseServiceException(ExceptionType.DATABASE_ERROR, "Could not find item in PO.");
|
| 4555 |
mandeep.dh |
98 |
}
|
|
|
99 |
|
| 4500 |
mandeep.dh |
100 |
return inventoryItem;
|
| 4555 |
mandeep.dh |
101 |
}
|
| 4500 |
mandeep.dh |
102 |
|
| 21617 |
amit.gupta |
103 |
public in.shop2020.warehouse.InventoryItem convert(boolean derived) throws WarehouseServiceException {
|
|
|
104 |
in.shop2020.warehouse.InventoryItem inventoryItem = new in.shop2020.warehouse.InventoryItem();
|
|
|
105 |
inventoryItem.setId(id);
|
|
|
106 |
inventoryItem.setItemId(itemId);
|
|
|
107 |
inventoryItem.setCurrentQuantity(currentQuantity);
|
|
|
108 |
inventoryItem.setInitialQuantity(initialQuantity);
|
|
|
109 |
inventoryItem.setItemNumber(itemNumber);
|
|
|
110 |
inventoryItem.setPurchaseId(purchaseId);
|
|
|
111 |
inventoryItem.setPurchaseReturnId(purchaseReturnId);
|
|
|
112 |
inventoryItem.setSerialNumber(serialNumber);
|
|
|
113 |
inventoryItem.setCurrentWarehouseId(currentWarehouseId);
|
|
|
114 |
inventoryItem.setLastScanType(lastScanType);
|
|
|
115 |
inventoryItem.setTransferStatus(transferStatus);
|
|
|
116 |
inventoryItem.setPhysicalWarehouseId(physicalWarehouseId);
|
|
|
117 |
if(this.activated!=null) {
|
|
|
118 |
inventoryItem.setActivated(this.activated.getTime());
|
|
|
119 |
}
|
|
|
120 |
if(this.created != null) {
|
|
|
121 |
inventoryItem.setCreated(this.created.getTime());
|
|
|
122 |
}
|
|
|
123 |
// Setting derived fields
|
|
|
124 |
if(derived) {
|
|
|
125 |
try {
|
|
|
126 |
Client client = new PurchaseClient().getClient();
|
|
|
127 |
PurchaseOrder purchaseOrder = client.getPurchaseOrderForPurchase(purchaseId);
|
|
|
128 |
inventoryItem.setSupplierId(purchaseOrder.getSupplierId());
|
|
|
129 |
for (LineItem lineItem : purchaseOrder.getLineitems()) {
|
|
|
130 |
if (lineItem.getItemId() == itemId) {
|
|
|
131 |
inventoryItem.setUnitPrice(lineItem.getUnitPrice());
|
|
|
132 |
inventoryItem.setNlc(lineItem.getNlc());
|
|
|
133 |
break;
|
|
|
134 |
}
|
|
|
135 |
}
|
|
|
136 |
} catch (Exception e) {
|
|
|
137 |
logger.error("Could not fetch purchase order for purchase id: " + purchaseId, e);
|
|
|
138 |
throw new WarehouseServiceException(ExceptionType.DATABASE_ERROR, "Could not find item in PO.");
|
|
|
139 |
}
|
|
|
140 |
}
|
|
|
141 |
return inventoryItem;
|
|
|
142 |
}
|
|
|
143 |
|
| 4500 |
mandeep.dh |
144 |
public long getId() {
|
|
|
145 |
return id;
|
|
|
146 |
}
|
|
|
147 |
public void setId(long id) {
|
|
|
148 |
this.id = id;
|
|
|
149 |
}
|
|
|
150 |
public long getItemId() {
|
|
|
151 |
return itemId;
|
|
|
152 |
}
|
|
|
153 |
public void setItemId(long itemId) {
|
|
|
154 |
this.itemId = itemId;
|
|
|
155 |
}
|
|
|
156 |
public String getItemNumber() {
|
|
|
157 |
return itemNumber;
|
|
|
158 |
}
|
|
|
159 |
public void setItemNumber(String itemNumber) {
|
|
|
160 |
this.itemNumber = itemNumber;
|
|
|
161 |
}
|
|
|
162 |
public String getSerialNumber() {
|
|
|
163 |
return serialNumber;
|
|
|
164 |
}
|
|
|
165 |
public void setSerialNumber(String serialNumber) {
|
|
|
166 |
this.serialNumber = serialNumber;
|
|
|
167 |
}
|
|
|
168 |
public long getInitialQuantity() {
|
|
|
169 |
return initialQuantity;
|
|
|
170 |
}
|
|
|
171 |
public void setInitialQuantity(long initialQuantity) {
|
|
|
172 |
this.initialQuantity = initialQuantity;
|
|
|
173 |
}
|
|
|
174 |
public long getCurrentQuantity() {
|
|
|
175 |
return currentQuantity;
|
|
|
176 |
}
|
|
|
177 |
public void setCurrentQuantity(long currentQuantity) {
|
|
|
178 |
this.currentQuantity = currentQuantity;
|
|
|
179 |
}
|
|
|
180 |
public long getPurchaseId() {
|
|
|
181 |
return purchaseId;
|
|
|
182 |
}
|
|
|
183 |
public void setPurchaseId(long purchaseId) {
|
|
|
184 |
this.purchaseId = purchaseId;
|
|
|
185 |
}
|
| 5185 |
mandeep.dh |
186 |
|
| 6467 |
amar.kumar |
187 |
public long getPurchaseReturnId() {
|
|
|
188 |
return purchaseReturnId;
|
|
|
189 |
}
|
|
|
190 |
|
|
|
191 |
public void setPurchaseReturnId(long purchaseReturnId) {
|
|
|
192 |
this.purchaseReturnId = purchaseReturnId;
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
public long getCurrentWarehouseId() {
|
| 5185 |
mandeep.dh |
196 |
return currentWarehouseId;
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
public void setCurrentWarehouseId(long currentWarehouseId) {
|
|
|
200 |
this.currentWarehouseId = currentWarehouseId;
|
|
|
201 |
}
|
|
|
202 |
|
|
|
203 |
public ScanType getLastScanType() {
|
|
|
204 |
return lastScanType;
|
|
|
205 |
}
|
|
|
206 |
|
|
|
207 |
public void setLastScanType(ScanType lastScanType) {
|
|
|
208 |
this.lastScanType = lastScanType;
|
|
|
209 |
}
|
| 7410 |
amar.kumar |
210 |
|
|
|
211 |
public TransferLotStatus getTransferStatus() {
|
|
|
212 |
return transferStatus;
|
|
|
213 |
}
|
|
|
214 |
|
|
|
215 |
public void setTransferStatus(TransferLotStatus transferStatus) {
|
|
|
216 |
this.transferStatus = transferStatus;
|
|
|
217 |
}
|
|
|
218 |
|
|
|
219 |
public long getPhysicalWarehouseId() {
|
|
|
220 |
return physicalWarehouseId;
|
|
|
221 |
}
|
|
|
222 |
|
|
|
223 |
public void setPhysicalWarehouseId(long physicalWarehouseId) {
|
|
|
224 |
this.physicalWarehouseId = physicalWarehouseId;
|
|
|
225 |
}
|
| 21617 |
amit.gupta |
226 |
|
|
|
227 |
public Date getActivated() {
|
|
|
228 |
return activated;
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
public void setActivated(Date activated) {
|
|
|
232 |
this.activated = activated;
|
|
|
233 |
}
|
|
|
234 |
|
|
|
235 |
public Date getCreated() {
|
|
|
236 |
return created;
|
|
|
237 |
}
|
|
|
238 |
|
|
|
239 |
public void setCreated(Date created) {
|
|
|
240 |
this.created = created;
|
|
|
241 |
}
|
| 7410 |
amar.kumar |
242 |
|
| 21617 |
amit.gupta |
243 |
|
|
|
244 |
|
| 4500 |
mandeep.dh |
245 |
}
|