| Line 4... |
Line 4... |
| 4 |
import in.shop2020.model.v1.catalog.Item;
|
4 |
import in.shop2020.model.v1.catalog.Item;
|
| 5 |
import in.shop2020.model.v1.catalog.ItemType;
|
5 |
import in.shop2020.model.v1.catalog.ItemType;
|
| 6 |
import in.shop2020.model.v1.catalog.Warehouse;
|
6 |
import in.shop2020.model.v1.catalog.Warehouse;
|
| 7 |
import in.shop2020.model.v1.catalog.WarehouseType;
|
7 |
import in.shop2020.model.v1.catalog.WarehouseType;
|
| 8 |
import in.shop2020.model.v1.order.LineItem;
|
8 |
import in.shop2020.model.v1.order.LineItem;
|
| - |
|
9 |
import in.shop2020.purchase.Invoice;
|
| 9 |
import in.shop2020.purchase.PurchaseOrder;
|
10 |
import in.shop2020.purchase.PurchaseOrder;
|
| 10 |
import in.shop2020.purchase.PurchaseServiceException;
|
11 |
import in.shop2020.purchase.PurchaseServiceException;
|
| 11 |
import in.shop2020.thrift.clients.CatalogClient;
|
12 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 12 |
import in.shop2020.thrift.clients.PurchaseClient;
|
13 |
import in.shop2020.thrift.clients.PurchaseClient;
|
| 13 |
import in.shop2020.thrift.clients.WarehouseClient;
|
14 |
import in.shop2020.thrift.clients.WarehouseClient;
|
| Line 16... |
Line 17... |
| 16 |
import in.shop2020.warehouse.ScanType;
|
17 |
import in.shop2020.warehouse.ScanType;
|
| 17 |
import in.shop2020.warehouse.WarehouseService.Client;
|
18 |
import in.shop2020.warehouse.WarehouseService.Client;
|
| 18 |
import in.shop2020.warehouse.WarehouseServiceException;
|
19 |
import in.shop2020.warehouse.WarehouseServiceException;
|
| 19 |
|
20 |
|
| 20 |
import java.util.ArrayList;
|
21 |
import java.util.ArrayList;
|
| - |
|
22 |
import java.util.Calendar;
|
| - |
|
23 |
import java.util.Date;
|
| 21 |
import java.util.HashMap;
|
24 |
import java.util.HashMap;
|
| 22 |
import java.util.List;
|
25 |
import java.util.List;
|
| 23 |
import java.util.Map;
|
26 |
import java.util.Map;
|
| 24 |
|
27 |
|
| 25 |
import javax.servlet.ServletContext;
|
28 |
import javax.servlet.ServletContext;
|
| 26 |
|
29 |
|
| - |
|
30 |
import org.apache.commons.lang.StringUtils;
|
| 27 |
import org.apache.struts2.convention.annotation.Result;
|
31 |
import org.apache.struts2.convention.annotation.Result;
|
| 28 |
import org.apache.struts2.convention.annotation.Results;
|
32 |
import org.apache.struts2.convention.annotation.Results;
|
| 29 |
import org.apache.thrift.TException;
|
33 |
import org.apache.thrift.TException;
|
| 30 |
import org.apache.thrift.transport.TTransportException;
|
34 |
import org.apache.thrift.transport.TTransportException;
|
| 31 |
import org.slf4j.Logger;
|
35 |
import org.slf4j.Logger;
|
| Line 47... |
Line 51... |
| 47 |
private String itemId;
|
51 |
private String itemId;
|
| 48 |
private String itemNo;
|
52 |
private String itemNo;
|
| 49 |
private String errorMsg = "";
|
53 |
private String errorMsg = "";
|
| 50 |
private List<Item> items;
|
54 |
private List<Item> items;
|
| 51 |
private List<LineItem> lineItems;
|
55 |
private List<LineItem> lineItems;
|
| - |
|
56 |
private List<Invoice> invoices;
|
| 52 |
|
57 |
|
| 53 |
private String purchaseOrderId;
|
58 |
private String purchaseOrderId;
|
| 54 |
private Warehouse warehouse;
|
59 |
private Warehouse warehouse;
|
| 55 |
|
60 |
|
| 56 |
public String editNew() {
|
61 |
public String editNew() {
|
| 57 |
purchaseOrderId = request.getParameter("poId");
|
62 |
purchaseOrderId = request.getParameter("poId");
|
| - |
|
63 |
|
| - |
|
64 |
try {
|
| - |
|
65 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
| - |
|
66 |
invoices = purchaseClient.getInvoices(getPreviousDay(getPreviousDay(new Date())).getTime());
|
| - |
|
67 |
} catch (Exception e) {
|
| - |
|
68 |
logger.error("Error loading invoices", e);
|
| - |
|
69 |
}
|
| - |
|
70 |
|
| 58 |
return "new";
|
71 |
return "new";
|
| 59 |
}
|
72 |
}
|
| 60 |
|
73 |
|
| - |
|
74 |
private Date getPreviousDay(Date date) {
|
| - |
|
75 |
Calendar calendar = Calendar.getInstance();
|
| - |
|
76 |
calendar.setTime(date);
|
| - |
|
77 |
calendar.add(Calendar.DAY_OF_MONTH, -1);
|
| - |
|
78 |
return calendar.getTime();
|
| - |
|
79 |
}
|
| - |
|
80 |
|
| 61 |
public String create() {
|
81 |
public String create() {
|
| 62 |
this.purchaseOrderId = request.getParameter("poId");
|
82 |
this.purchaseOrderId = request.getParameter("poId");
|
| 63 |
long poId = Long.parseLong(purchaseOrderId);
|
83 |
long poId = Long.parseLong(purchaseOrderId);
|
| 64 |
String invoiceNumber = request.getParameter("invoiceNo");
|
84 |
String invoiceNumber = request.getParameter("invoiceNo");
|
| 65 |
String fc = request.getParameter("freightCharges").trim();
|
85 |
String fc = request.getParameter("freightCharges").trim();
|
| Line 178... |
Line 198... |
| 178 |
for (in.shop2020.purchase.LineItem lineItem : purchaseOrder.getLineitems()) {
|
198 |
for (in.shop2020.purchase.LineItem lineItem : purchaseOrder.getLineitems()) {
|
| 179 |
itemsQuantityMapFromPO.put(lineItem.getItemId(), (long) lineItem.getUnfulfilledQuantity());
|
199 |
itemsQuantityMapFromPO.put(lineItem.getItemId(), (long) lineItem.getUnfulfilledQuantity());
|
| 180 |
}
|
200 |
}
|
| 181 |
|
201 |
|
| 182 |
Client warehouseClient = new WarehouseClient().getClient();
|
202 |
Client warehouseClient = new WarehouseClient().getClient();
|
| 183 |
|
- |
|
| 184 |
for (LineItem lineItem : lineItems) {
|
203 |
for (LineItem lineItem : lineItems) {
|
| 185 |
if (lineItem.getItem_id() == -1 && lineItem.getItem_number().isEmpty() && lineItem.getSerial_number().isEmpty()) {
|
204 |
if (lineItem.getItem_id() == -1 && lineItem.getItem_number().isEmpty() && lineItem.getSerial_number().isEmpty()) {
|
| 186 |
lineItem.setExtra_info(ScanRecordType.BLANK.name());
|
205 |
lineItem.setExtra_info(ScanRecordType.BLANK.name());
|
| 187 |
}
|
206 |
}
|
| 188 |
else {
|
207 |
else {
|
| 189 |
lineItem.setExtra_info(ScanRecordType.VALID.name());
|
208 |
lineItem.setExtra_info(ScanRecordType.VALID.name());
|
| 190 |
if (ItemType.SERIALIZED.name().equals(lineItem.getProductGroup())) {
|
- |
|
| 191 |
if (lineItem.getSerial_number().isEmpty()) {
|
209 |
if (StringUtils.isNotBlank(lineItem.getSerial_number())) {
|
| 192 |
lineItem.setExtra_info("Serial number not present.");
|
- |
|
| 193 |
areValidScans = false;
|
- |
|
| 194 |
continue;
|
- |
|
| 195 |
}
|
- |
|
| 196 |
|
- |
|
| 197 |
try {
|
210 |
try {
|
| 198 |
warehouseClient.getInventoryItem(lineItem.getSerial_number());
|
211 |
warehouseClient.getInventoryItem(lineItem.getSerial_number());
|
| 199 |
lineItem.setExtra_info("Item scanned already.");
|
212 |
lineItem.setExtra_info("Item scanned already.");
|
| 200 |
areValidScans = false;
|
213 |
areValidScans = false;
|
| 201 |
continue;
|
214 |
continue;
|
| 202 |
}
|
- |
|
| 203 |
catch (Exception e) {
|
215 |
} catch (Exception e) {
|
| 204 |
}
|
216 |
}
|
| 205 |
}
|
217 |
}
|
| 206 |
|
218 |
|
| - |
|
219 |
if (lineItem.getItem_id() == -1 &&
|
| 207 |
if (lineItem.getItem_id() == -1 && lineItem.getItem_number().isEmpty()) {
|
220 |
(StringUtils.isBlank(lineItem.getItem_number()) ||
|
| - |
|
221 |
StringUtils.isBlank(lineItem.getSerial_number())))
|
| - |
|
222 |
{
|
| 208 |
lineItem.setExtra_info("Item not selected/Item number not present.");
|
223 |
lineItem.setExtra_info("Item not selected/Item or serial number not present");
|
| 209 |
areValidScans = false;
|
224 |
areValidScans = false;
|
| 210 |
continue;
|
225 |
continue;
|
| 211 |
}
|
226 |
}
|
| 212 |
|
227 |
|
| 213 |
if (lineItem.getItem_id() == -1) {
|
228 |
if (lineItem.getItem_id() == -1) {
|
| Line 261... |
Line 276... |
| 261 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
276 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
| 262 |
PurchaseOrder purchaseOrder = purchaseClient.getPurchaseOrderForPurchase(id);
|
277 |
PurchaseOrder purchaseOrder = purchaseClient.getPurchaseOrderForPurchase(id);
|
| 263 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
278 |
in.shop2020.model.v1.catalog.InventoryService.Client catalogClient = new CatalogClient().getClient();
|
| 264 |
|
279 |
|
| 265 |
for (in.shop2020.purchase.LineItem lineItem : purchaseOrder.getLineitems()) {
|
280 |
for (in.shop2020.purchase.LineItem lineItem : purchaseOrder.getLineitems()) {
|
| 266 |
Item item = new Item();
|
- |
|
| 267 |
item.setId(lineItem.getItemId());
|
281 |
items.add(catalogClient.getItem(lineItem.getItemId()));
|
| 268 |
item.setBrand(lineItem.getBrand());
|
- |
|
| 269 |
item.setModelName(lineItem.getModelName());
|
- |
|
| 270 |
item.setModelNumber(lineItem.getModelNumber());
|
- |
|
| 271 |
item.setColor(lineItem.getColor());
|
- |
|
| 272 |
item.setProductGroup(catalogClient.getItem(lineItem.getItemId()).getType().name());
|
- |
|
| 273 |
items.add(item);
|
- |
|
| 274 |
}
|
282 |
}
|
| 275 |
|
283 |
|
| 276 |
warehouse = catalogClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, purchaseOrder.getSupplierId(), PurchaseOrderController.WAREHOUSE_ID, PurchaseOrderController.WAREHOUSE_ID).get(0);
|
284 |
warehouse = catalogClient.getWarehouses(WarehouseType.OURS, InventoryType.GOOD, purchaseOrder.getSupplierId(), PurchaseOrderController.WAREHOUSE_ID, PurchaseOrderController.WAREHOUSE_ID).get(0);
|
| 277 |
} catch (Exception e) {
|
285 |
} catch (Exception e) {
|
| 278 |
logger.error("Could not find items in PO with purchase: " + id, e);
|
286 |
logger.error("Could not find items in PO with purchase: " + id, e);
|
| 279 |
}
|
287 |
}
|
| 280 |
}
|
288 |
}
|
| Line 376... |
Line 384... |
| 376 |
}
|
384 |
}
|
| 377 |
|
385 |
|
| 378 |
public Warehouse getWarehouse() {
|
386 |
public Warehouse getWarehouse() {
|
| 379 |
return warehouse;
|
387 |
return warehouse;
|
| 380 |
}
|
388 |
}
|
| - |
|
389 |
|
| - |
|
390 |
public List<Invoice> getInvoices() {
|
| - |
|
391 |
return invoices;
|
| - |
|
392 |
}
|
| - |
|
393 |
|
| - |
|
394 |
public void setInvoices(List<Invoice> invoices) {
|
| - |
|
395 |
this.invoices = invoices;
|
| - |
|
396 |
}
|
| 381 |
}
|
397 |
}
|