| 5185 |
mandeep.dh |
1 |
/**
|
|
|
2 |
*
|
|
|
3 |
*/
|
|
|
4 |
package in.shop2020.inventory.controllers;
|
|
|
5 |
|
| 5945 |
mandeep.dh |
6 |
import in.shop2020.model.v1.inventory.Warehouse;
|
| 5185 |
mandeep.dh |
7 |
import in.shop2020.thrift.clients.CatalogClient;
|
| 5945 |
mandeep.dh |
8 |
import in.shop2020.thrift.clients.InventoryClient;
|
| 5185 |
mandeep.dh |
9 |
import in.shop2020.thrift.clients.PurchaseClient;
|
|
|
10 |
import in.shop2020.thrift.clients.WarehouseClient;
|
|
|
11 |
import in.shop2020.utils.ModelUtils;
|
|
|
12 |
import in.shop2020.warehouse.InventoryItem;
|
| 10489 |
amar.kumar |
13 |
import in.shop2020.warehouse.Scan;
|
| 5185 |
mandeep.dh |
14 |
import in.shop2020.warehouse.ScanType;
|
|
|
15 |
import in.shop2020.warehouse.WarehouseService.Client;
|
|
|
16 |
|
| 9429 |
amar.kumar |
17 |
import java.util.ArrayList;
|
| 10489 |
amar.kumar |
18 |
import java.util.Date;
|
| 5185 |
mandeep.dh |
19 |
import java.util.List;
|
|
|
20 |
|
|
|
21 |
import org.apache.commons.logging.Log;
|
|
|
22 |
import org.apache.commons.logging.LogFactory;
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* @author mandeep
|
|
|
26 |
*
|
|
|
27 |
*/
|
|
|
28 |
public class DoaOutController extends BaseController {
|
|
|
29 |
private Log logger = LogFactory.getLog(DoaOutController.class);
|
|
|
30 |
private String id;
|
| 10497 |
amar.kumar |
31 |
private String creditNote;
|
| 5185 |
mandeep.dh |
32 |
List<InventoryItem> inventoryItems;
|
|
|
33 |
|
|
|
34 |
public String index() {
|
|
|
35 |
try {
|
| 9452 |
amar.kumar |
36 |
//List<InventoryItem> tobeRemovedInventoryItems = new ArrayList<InventoryItem>();
|
| 5185 |
mandeep.dh |
37 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
38 |
inventoryItems = warehouseClient
|
|
|
39 |
.getInventoryItemsFromLastScanType(ScanType.DOA_OUT);
|
| 9452 |
amar.kumar |
40 |
/* for(InventoryItem inventoryItem:inventoryItems) {
|
| 9428 |
amar.kumar |
41 |
if(inventoryItem.getId()<59078 ||
|
|
|
42 |
inventoryItem.getCurrentWarehouseId() == 1 ||
|
| 9429 |
amar.kumar |
43 |
inventoryItem.getCurrentWarehouseId() == 9) {//removing doa_in entries before 2013 and all hotspot entries
|
|
|
44 |
tobeRemovedInventoryItems.add(inventoryItem);
|
| 9428 |
amar.kumar |
45 |
}
|
|
|
46 |
}
|
| 9429 |
amar.kumar |
47 |
for(InventoryItem inventoryItem:tobeRemovedInventoryItems) {
|
|
|
48 |
inventoryItems.remove(inventoryItem);
|
| 9452 |
amar.kumar |
49 |
}*/
|
| 5185 |
mandeep.dh |
50 |
} catch (Exception e) {
|
|
|
51 |
logger.error("Could not fetch inventory items", e);
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
return INDEX;
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
public String update() {
|
|
|
58 |
try {
|
|
|
59 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
60 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
| 5945 |
mandeep.dh |
61 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
| 5185 |
mandeep.dh |
62 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
| 9572 |
amar.kumar |
63 |
warehouseClient.scan(inventoryItem, ScanType.DOA_REPLACED, 1, warehouse.getBillingWarehouseId(), 0);
|
| 5185 |
mandeep.dh |
64 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
|
|
65 |
purchaseClient.unFulfillPO(inventoryItem.getPurchaseId(), inventoryItem.getItemId(), 1);
|
|
|
66 |
} catch (Exception e) {
|
|
|
67 |
logger.error("Could not fetch inventory items", e);
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
return index();
|
|
|
71 |
}
|
| 10308 |
amar.kumar |
72 |
|
|
|
73 |
public String doaReject() {
|
|
|
74 |
try {
|
|
|
75 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
76 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
|
|
77 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
|
|
78 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
|
|
79 |
warehouseClient.scan(inventoryItem, ScanType.DOA_REJECTED, 1, warehouse.getBillingWarehouseId(), 0);
|
|
|
80 |
} catch (Exception e) {
|
|
|
81 |
logger.error("Could not fetch inventory items", e);
|
|
|
82 |
}
|
| 5235 |
mandeep.dh |
83 |
|
| 10308 |
amar.kumar |
84 |
return index();
|
|
|
85 |
}
|
| 10489 |
amar.kumar |
86 |
|
|
|
87 |
public String closeDOAByCreditNote() {
|
|
|
88 |
try {
|
|
|
89 |
Client warehouseClient = new WarehouseClient().getClient();
|
|
|
90 |
InventoryItem inventoryItem = warehouseClient.getInventoryItemFromId(Long.valueOf(id));
|
|
|
91 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
|
|
92 |
Warehouse warehouse = catalogClient.getWarehouse(inventoryItem.getCurrentWarehouseId());
|
|
|
93 |
|
|
|
94 |
Scan scan = new Scan();
|
|
|
95 |
scan.setInventoryItemId(Long.parseLong(id));
|
|
|
96 |
scan.setScannedAt((new Date()).getTime());
|
|
|
97 |
scan.setType(ScanType.DOA_CLOSED_BY_CREDIT_NOTE);
|
|
|
98 |
scan.setQuantity(1);
|
| 10497 |
amar.kumar |
99 |
scan.setRemarks(creditNote);
|
| 10489 |
amar.kumar |
100 |
scan.setWarehouseId(inventoryItem.getCurrentWarehouseId());
|
|
|
101 |
warehouseClient.genericScan(inventoryItem, scan);
|
|
|
102 |
} catch (Exception e) {
|
|
|
103 |
logger.error("Could not fetch inventory items", e);
|
|
|
104 |
}
|
| 10308 |
amar.kumar |
105 |
|
| 10489 |
amar.kumar |
106 |
return index();
|
|
|
107 |
}
|
|
|
108 |
|
| 5235 |
mandeep.dh |
109 |
public String getPONumber(long purchaseId) {
|
|
|
110 |
try {
|
|
|
111 |
in.shop2020.purchase.PurchaseService.Client purchaseClient = new PurchaseClient().getClient();
|
|
|
112 |
return purchaseClient.getPurchaseOrderForPurchase(purchaseId).getPoNumber();
|
|
|
113 |
} catch (Exception e) {
|
|
|
114 |
return "N/A";
|
|
|
115 |
}
|
|
|
116 |
}
|
|
|
117 |
|
| 5185 |
mandeep.dh |
118 |
public String getWarehouseDisplayName(long warehouseId) {
|
|
|
119 |
try {
|
| 5945 |
mandeep.dh |
120 |
in.shop2020.model.v1.inventory.InventoryService.Client catalogClient = new InventoryClient().getClient();
|
| 5185 |
mandeep.dh |
121 |
return catalogClient.getWarehouse(warehouseId).getDisplayName();
|
|
|
122 |
} catch (Exception e) {
|
|
|
123 |
return "N/A";
|
|
|
124 |
}
|
|
|
125 |
}
|
|
|
126 |
|
|
|
127 |
public String getModelName(long itemId) {
|
|
|
128 |
try {
|
| 5945 |
mandeep.dh |
129 |
in.shop2020.model.v1.catalog.CatalogService.Client catalogClient = new CatalogClient()
|
| 5185 |
mandeep.dh |
130 |
.getClient();
|
|
|
131 |
return ModelUtils.extractProductNameFromItem(catalogClient
|
|
|
132 |
.getItem(itemId));
|
|
|
133 |
} catch (Exception e) {
|
|
|
134 |
return "N/A";
|
|
|
135 |
}
|
|
|
136 |
}
|
|
|
137 |
|
|
|
138 |
public String getId() {
|
|
|
139 |
return id;
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
public void setId(String id) {
|
|
|
143 |
this.id = id;
|
|
|
144 |
}
|
|
|
145 |
|
|
|
146 |
public List<InventoryItem> getInventoryItems() {
|
|
|
147 |
return inventoryItems;
|
|
|
148 |
}
|
|
|
149 |
|
|
|
150 |
public void setInventoryItems(List<InventoryItem> inventoryItems) {
|
|
|
151 |
this.inventoryItems = inventoryItems;
|
|
|
152 |
}
|
| 10497 |
amar.kumar |
153 |
|
|
|
154 |
public String getCreditNote() {
|
|
|
155 |
return creditNote;
|
|
|
156 |
}
|
|
|
157 |
|
|
|
158 |
public void setCreditNote(String creditNote) {
|
|
|
159 |
this.creditNote = creditNote;
|
|
|
160 |
}
|
| 5185 |
mandeep.dh |
161 |
|
|
|
162 |
}
|