| 1961 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| 4431 |
phani.kuma |
4 |
import in.shop2020.catalog.dashboard.shared.ItemInventory;
|
| 3558 |
rajveer |
5 |
import in.shop2020.catalog.dashboard.shared.SourcePricings;
|
| 2066 |
ankur.sing |
6 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
| 2119 |
ankur.sing |
7 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
|
|
8 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
| 1961 |
ankur.sing |
9 |
|
| 5427 |
amit.gupta |
10 |
import java.util.ArrayList;
|
| 1961 |
ankur.sing |
11 |
import java.util.Date;
|
| 2066 |
ankur.sing |
12 |
import java.util.HashMap;
|
| 5427 |
amit.gupta |
13 |
import java.util.Iterator;
|
|
|
14 |
import java.util.List;
|
| 1992 |
ankur.sing |
15 |
import java.util.Map;
|
|
|
16 |
import java.util.Map.Entry;
|
| 1961 |
ankur.sing |
17 |
|
|
|
18 |
import com.google.gwt.core.client.GWT;
|
| 5427 |
amit.gupta |
19 |
import com.google.gwt.dom.client.Style.Unit;
|
| 1961 |
ankur.sing |
20 |
import com.google.gwt.event.dom.client.ClickEvent;
|
| 1992 |
ankur.sing |
21 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
22 |
import com.google.gwt.resources.client.CssResource;
|
| 1961 |
ankur.sing |
23 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
24 |
import com.google.gwt.uibinder.client.UiField;
|
| 5427 |
amit.gupta |
25 |
import com.google.gwt.uibinder.client.UiHandler;
|
| 1961 |
ankur.sing |
26 |
import com.google.gwt.user.client.Window;
|
| 2126 |
ankur.sing |
27 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
| 1961 |
ankur.sing |
28 |
import com.google.gwt.user.client.ui.Button;
|
| 2066 |
ankur.sing |
29 |
import com.google.gwt.user.client.ui.CheckBox;
|
| 5427 |
amit.gupta |
30 |
import com.google.gwt.user.client.ui.DialogBox;
|
| 1992 |
ankur.sing |
31 |
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
32 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
| 1961 |
ankur.sing |
33 |
import com.google.gwt.user.client.ui.Label;
|
| 4506 |
phani.kuma |
34 |
import com.google.gwt.user.client.ui.ListBox;
|
| 1961 |
ankur.sing |
35 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
|
|
36 |
import com.google.gwt.user.client.ui.TextBox;
|
| 5427 |
amit.gupta |
37 |
import com.google.gwt.user.client.ui.VerticalPanel;
|
| 1961 |
ankur.sing |
38 |
import com.google.gwt.user.client.ui.Widget;
|
| 2068 |
ankur.sing |
39 |
import com.google.gwt.user.datepicker.client.DateBox;
|
| 1961 |
ankur.sing |
40 |
|
| 2427 |
ankur.sing |
41 |
/**
|
|
|
42 |
* Panel contains fields for item details. Some of these fields are editable.
|
|
|
43 |
* It also contains vendor item pricings, vendor item keys, and item availability in tabular format.
|
|
|
44 |
* Item availability is made invisible for time being
|
|
|
45 |
*/
|
| 5217 |
amit.gupta |
46 |
public class ItemDetails extends ResizeComposite implements ComingSoon {
|
| 1961 |
ankur.sing |
47 |
|
| 2359 |
ankur.sing |
48 |
private final int TABLE_INDEX_MAPPING_VENDOR_DESC = 0,
|
|
|
49 |
TABLE_INDEX_MAPPING_ITEM_KEY = 1,
|
|
|
50 |
TABLE_INDEX_MAPPING_BUTTON = 2,
|
|
|
51 |
TABLE_INDEX_MAPPING_VENDORID = 3,
|
|
|
52 |
TABLE_INDEX_MAPPING_ITEM_KEY_OLD = 4;
|
|
|
53 |
|
|
|
54 |
private final int TABLE_INDEX_PRICING_VENDOR_DESC = 0,
|
| 3558 |
rajveer |
55 |
TABLE_INDEX_PRICING_MOP = 1,
|
| 2359 |
ankur.sing |
56 |
TABLE_INDEX_PRICING_DP = 2,
|
|
|
57 |
TABLE_INDEX_PRICING_TP = 3,
|
|
|
58 |
TABLE_INDEX_PRICING_BUTTON = 4,
|
|
|
59 |
TABLE_INDEX_PRICING_VENDORID = 5;
|
| 3558 |
rajveer |
60 |
|
|
|
61 |
private final int TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC = 0,
|
|
|
62 |
TABLE_INDEX_SOURCE_PRICING_MRP = 1,
|
|
|
63 |
TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE = 2,
|
|
|
64 |
TABLE_INDEX_SOURCE_PRICING_BUTTON = 3,
|
|
|
65 |
TABLE_INDEX_SOURCE_PRICING_SOURCE_ID = 4;
|
|
|
66 |
|
| 2119 |
ankur.sing |
67 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0,
|
|
|
68 |
TABLE_INDEX_WAREHOUSE_DESC = 1,
|
| 4431 |
phani.kuma |
69 |
TABLE_INDEX_WAREHOUSE_INVA = 2,
|
|
|
70 |
TABLE_INDEX_WAREHOUSE_INVR = 3,
|
|
|
71 |
TABLE_INDEX_WAREHOUSE_GET_BUTTON = 4,
|
|
|
72 |
TABLE_INDEX_WAREHOUSE_UPDATE_BUTTON = 5;
|
| 2359 |
ankur.sing |
73 |
|
| 4423 |
phani.kuma |
74 |
private final int TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID = 0,
|
|
|
75 |
TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP = 1,
|
|
|
76 |
TABLE_INDEX_SIMILAR_ITEMS_BRAND = 2,
|
|
|
77 |
TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER = 3,
|
|
|
78 |
TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME = 4,
|
|
|
79 |
TABLE_INDEX_SIMILAR_ITEMS_CATEGORY = 5,
|
|
|
80 |
TABLE_INDEX_SIMILAR_ITEMS_BUTTON = 6;
|
|
|
81 |
|
| 5427 |
amit.gupta |
82 |
private final String MANDATORY_MRP = "MRP",
|
|
|
83 |
MANDATORY_WEIGHT = "Weight",
|
|
|
84 |
MANDATORY_BEST_DEAL_TEXT = "Best Deal Text",
|
|
|
85 |
MANDATORY_BRAND = "Brand",
|
|
|
86 |
MANDATORY_MODEL_NO = "Model Number",
|
|
|
87 |
MANDATORY_MODEL_NAME = "Model Name";
|
|
|
88 |
|
|
|
89 |
private final String OPTIONAL_SELLING_PRICE = "Selling Price",
|
|
|
90 |
OPTIONAL_VENDOR_PRICING = "Vendor Pricing",
|
|
|
91 |
OPTIONAL_PREFERRED_VENDOR = "Preferred Vendor",
|
|
|
92 |
OPTIONAL_SOURCE_PRICING = "Source Pricing";
|
|
|
93 |
|
| 2359 |
ankur.sing |
94 |
private final String PRICE_WIDTH = "100px", VENDOR_DESC_WIDTH = "130px",
|
|
|
95 |
VENDOR_ID_WIDTH = "100px", ITEM_KEY_WIDTH = "200px",
|
|
|
96 |
BUTTON_WIDTH = "50px";
|
| 2066 |
ankur.sing |
97 |
|
| 4649 |
phani.kuma |
98 |
private Map<String, String> ConfigMap;
|
| 2066 |
ankur.sing |
99 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
|
|
100 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
| 2126 |
ankur.sing |
101 |
private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
|
| 5427 |
amit.gupta |
102 |
Map<String, Object> mandatoryChangedValMap;
|
|
|
103 |
Map<String, Object> optionalChangedValMap;
|
| 2066 |
ankur.sing |
104 |
|
| 1961 |
ankur.sing |
105 |
|
| 2066 |
ankur.sing |
106 |
interface ItemDetailStyle extends CssResource{
|
|
|
107 |
String greenLabel();
|
|
|
108 |
String fieldChanged();
|
|
|
109 |
}
|
| 1961 |
ankur.sing |
110 |
|
| 2105 |
ankur.sing |
111 |
private Item item, newItem;
|
| 2489 |
ankur.sing |
112 |
private CatalogDashboard catalogDashboardPanel;
|
| 2066 |
ankur.sing |
113 |
|
|
|
114 |
@UiField ItemDetailStyle style;
|
|
|
115 |
@UiField Label itemId;
|
| 4762 |
phani.kuma |
116 |
@UiField TextBox brand, modelNumber, modelName, color;
|
|
|
117 |
@UiField Label contentCategory, catalogItemId, productGroup;
|
| 2359 |
ankur.sing |
118 |
@UiField TextBox statusDesc, comments;
|
| 2105 |
ankur.sing |
119 |
@UiField TextBox sellingPrice, mrp, weight;
|
|
|
120 |
@UiField Label addedOn, retireDate, updatedOn;
|
| 2066 |
ankur.sing |
121 |
@UiField Label itemStatus;
|
|
|
122 |
@UiField TextBox bestDealsText, bestDealsValue;
|
|
|
123 |
@UiField FlexTable headerAvailability, availabilityTable;
|
| 2427 |
ankur.sing |
124 |
@UiField FlexTable headerVendorItemKey, tableVendorItemKey;
|
|
|
125 |
@UiField FlexTable headerVendorPrices, tableVendorPrices;
|
| 3558 |
rajveer |
126 |
@UiField FlexTable headerSourcePrices, tableSourcePrices;
|
| 2066 |
ankur.sing |
127 |
@UiField TextBox bestSellingRank;
|
| 3359 |
chandransh |
128 |
@UiField TextBox expectedDelay;
|
| 5384 |
phani.kuma |
129 |
@UiField CheckBox defaultForEntity, risky, warehouseStickiness, itemType, hasItemNo;
|
| 5217 |
amit.gupta |
130 |
@UiField DateBox startDate, expectedArrivalDate, comingSoonStartDate;
|
| 4423 |
phani.kuma |
131 |
@UiField FlexTable headerSimilarItems, tableSimilarItems;
|
| 5384 |
phani.kuma |
132 |
@UiField ListBox preferredVendor;
|
| 5217 |
amit.gupta |
133 |
@UiField Button comingSoonButton;
|
| 2066 |
ankur.sing |
134 |
|
|
|
135 |
public ItemDetails(Item item){
|
| 2105 |
ankur.sing |
136 |
this();
|
| 2066 |
ankur.sing |
137 |
setItemDetails(item);
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
public ItemDetails() {
|
|
|
141 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
142 |
initAvailabilityHeader();
|
| 2427 |
ankur.sing |
143 |
initVendorKeysHeader();
|
|
|
144 |
initVendorPricingHeader();
|
| 3558 |
rajveer |
145 |
initSourcePricingHeader();
|
| 4423 |
phani.kuma |
146 |
initSimilarItemList();
|
| 4506 |
phani.kuma |
147 |
preferredVendor.addItem("null");
|
| 4649 |
phani.kuma |
148 |
getConfigdataforPriceCompare();
|
| 2066 |
ankur.sing |
149 |
}
|
|
|
150 |
|
| 4649 |
phani.kuma |
151 |
public void getConfigdataforPriceCompare(){
|
|
|
152 |
catalogService.getConfigdataforPriceCompare(new AsyncCallback<Map<String,String>>() {
|
|
|
153 |
@Override
|
|
|
154 |
public void onSuccess(Map<String, String> result) {
|
|
|
155 |
ConfigMap = result;
|
|
|
156 |
}
|
|
|
157 |
@Override
|
|
|
158 |
public void onFailure(Throwable caught) {
|
|
|
159 |
caught.printStackTrace();
|
|
|
160 |
}
|
|
|
161 |
});
|
|
|
162 |
}
|
|
|
163 |
|
| 2427 |
ankur.sing |
164 |
/**
|
|
|
165 |
* Sets the UI fields with item object attributes
|
|
|
166 |
* Also populates tables for vendor prices, keys and item availability
|
|
|
167 |
* @param item
|
|
|
168 |
*/
|
| 2066 |
ankur.sing |
169 |
public void setItemDetails(Item item){
|
|
|
170 |
this.item = item;
|
|
|
171 |
itemId.setText(item.getId()+"");
|
|
|
172 |
productGroup.setText(item.getProductGroup());
|
|
|
173 |
brand.setText(item.getBrand());
|
|
|
174 |
modelNumber.setText(item.getModelNumber());
|
|
|
175 |
modelName.setText(item.getModelName());
|
|
|
176 |
color.setText(item.getColor());
|
|
|
177 |
|
| 2359 |
ankur.sing |
178 |
statusDesc.setText(item.getItemStatusDesc());
|
| 2105 |
ankur.sing |
179 |
contentCategory.setText(item.getContentCategory()+"");
|
| 2066 |
ankur.sing |
180 |
comments.setText(item.getComments());
|
|
|
181 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
|
|
182 |
|
| 4583 |
phani.kuma |
183 |
preferredVendor.clear();
|
|
|
184 |
int index = -1;
|
|
|
185 |
if (item.getPreferredVendor() == null) {
|
|
|
186 |
index++;
|
|
|
187 |
preferredVendor.addItem("null");
|
|
|
188 |
}
|
|
|
189 |
|
|
|
190 |
if((item.getVendorPricesMap() == null || item.getVendorPricesMap().isEmpty())) {
|
|
|
191 |
if(item.getPreferredVendor() != null) {
|
|
|
192 |
index++;
|
|
|
193 |
preferredVendor.addItem(Utils.getVendorDesc(item.getPreferredVendor()));
|
|
|
194 |
}
|
|
|
195 |
}
|
|
|
196 |
else {
|
|
|
197 |
for(VendorPricings vendorDetail : item.getVendorPricesMap().values()){
|
|
|
198 |
index++;
|
|
|
199 |
preferredVendor.addItem(Utils.getVendorDesc(vendorDetail.getVendorId()));
|
|
|
200 |
if(item.getPreferredVendor() != null && item.getPreferredVendor() == vendorDetail.getVendorId()) {
|
| 4506 |
phani.kuma |
201 |
preferredVendor.setSelectedIndex(index);
|
|
|
202 |
}
|
| 4583 |
phani.kuma |
203 |
}
|
|
|
204 |
|
|
|
205 |
if(item.getPreferredVendor() != null && !item.getVendorPricesMap().containsKey(item.getPreferredVendor())){
|
|
|
206 |
index++;
|
|
|
207 |
preferredVendor.addItem(Utils.getVendorDesc(item.getPreferredVendor()));
|
|
|
208 |
preferredVendor.setSelectedIndex(index);
|
|
|
209 |
}
|
| 4506 |
phani.kuma |
210 |
}
|
| 5384 |
phani.kuma |
211 |
|
| 2489 |
ankur.sing |
212 |
mrp.setText(item.getMrp() != null ? item.getMrp()+"" : "");
|
|
|
213 |
sellingPrice.setText(item.getSellingPrice() != null ? item.getSellingPrice()+"" : "");
|
|
|
214 |
weight.setText(item.getWeight() != null ? item.getWeight()+"" : "");
|
| 3359 |
chandransh |
215 |
expectedDelay.setValue(item.getExpectedDelay()+"");
|
| 4413 |
anupam.sin |
216 |
warehouseStickiness.setValue(item.isWarehouseStickiness());
|
| 2068 |
ankur.sing |
217 |
|
| 5384 |
phani.kuma |
218 |
hasItemNo.setValue(item.isHasItemNo());
|
|
|
219 |
itemType.setValue(item.isItemType());
|
|
|
220 |
|
| 2068 |
ankur.sing |
221 |
startDate.setValue(new Date(item.getStartDate()));
|
| 5217 |
amit.gupta |
222 |
if(item.getComingSoonStartDate() != null){
|
|
|
223 |
comingSoonStartDate.setValue(new Date(item.getComingSoonStartDate()));
|
|
|
224 |
}else {
|
|
|
225 |
comingSoonStartDate.setValue(null);
|
|
|
226 |
}
|
|
|
227 |
|
|
|
228 |
if(item.getExpectedArrivalDate() != null){
|
|
|
229 |
expectedArrivalDate.setValue(new Date(item.getExpectedArrivalDate()));
|
|
|
230 |
}else {
|
|
|
231 |
expectedArrivalDate.setValue(null);
|
|
|
232 |
}
|
| 2068 |
ankur.sing |
233 |
addedOn.setText(Utils.getDisplayableDate(item.getAddedOn()));
|
|
|
234 |
retireDate.setText(Utils.getDisplayableDate(item.getRetireDate()));
|
|
|
235 |
updatedOn.setText(Utils.getDisplayableDate(item.getUpdatedOn()));
|
| 1992 |
ankur.sing |
236 |
|
| 2066 |
ankur.sing |
237 |
bestDealsText.setText(item.getBestDealsText());
|
| 2489 |
ankur.sing |
238 |
bestDealsValue.setText(item.getBestDealsValue() != null ? item.getBestDealsValue()+"" : "");
|
|
|
239 |
bestSellingRank.setText(item.getBestSellingRank() != null ? item.getBestSellingRank()+"" : "");
|
| 2066 |
ankur.sing |
240 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
| 2252 |
ankur.sing |
241 |
risky.setValue(item.isRisky());
|
| 1992 |
ankur.sing |
242 |
|
| 2066 |
ankur.sing |
243 |
itemStatus.setText(item.getItemStatus());
|
|
|
244 |
|
| 4431 |
phani.kuma |
245 |
updateAvailabilityTable(item.getItemInventory());
|
| 2427 |
ankur.sing |
246 |
updateVendorKeysTable(item.getVendorKeysMap());
|
|
|
247 |
updateVendorPricingTable(item.getVendorPricesMap());
|
| 3558 |
rajveer |
248 |
updateSourcePricingTable(item.getSourcePricesMap());
|
| 4423 |
phani.kuma |
249 |
updateSimilarItemsTable(item.getSimilarItems());
|
| 1992 |
ankur.sing |
250 |
}
|
| 2066 |
ankur.sing |
251 |
|
| 2427 |
ankur.sing |
252 |
/**
|
|
|
253 |
* initialise item availability table header.
|
|
|
254 |
*/
|
| 2066 |
ankur.sing |
255 |
private void initAvailabilityHeader(){
|
| 4431 |
phani.kuma |
256 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "100px");
|
| 2105 |
ankur.sing |
257 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
|
| 4431 |
phani.kuma |
258 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INVA, "100px");
|
|
|
259 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INVR, "100px");
|
|
|
260 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_GET_BUTTON, "100px");
|
|
|
261 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_UPDATE_BUTTON, "100px");
|
| 2066 |
ankur.sing |
262 |
|
|
|
263 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_ID, "Warehouse Id");
|
|
|
264 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
| 4431 |
phani.kuma |
265 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INVA, "Availability");
|
|
|
266 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INVR, "Reserved");
|
|
|
267 |
|
|
|
268 |
Button getLiveDataButton = new Button("Get Live Data");
|
|
|
269 |
headerAvailability.setWidget(0, TABLE_INDEX_WAREHOUSE_GET_BUTTON, getLiveDataButton);
|
|
|
270 |
getLiveDataButton.addClickHandler(new ClickHandler() {
|
|
|
271 |
@Override
|
|
|
272 |
public void onClick(ClickEvent event) {
|
|
|
273 |
catalogService.getProdItemInventory(item.getId(), new AsyncCallback<Map<Long, ItemInventory>>() {
|
|
|
274 |
@Override
|
|
|
275 |
public void onSuccess(Map<Long, ItemInventory> itemInventoryMap) {
|
|
|
276 |
if(itemInventoryMap != null) {
|
|
|
277 |
GWT.log("Inventory Data fetched");
|
|
|
278 |
item.setItemInventory(itemInventoryMap);
|
|
|
279 |
updateAvailabilityTable(item.getItemInventory());
|
|
|
280 |
}
|
|
|
281 |
else {
|
|
|
282 |
GWT.log("Error fetching Inventory Data");
|
|
|
283 |
Window.alert("Error fetching Inventory Data");
|
|
|
284 |
}
|
|
|
285 |
}
|
|
|
286 |
@Override
|
|
|
287 |
public void onFailure(Throwable caught) {
|
|
|
288 |
caught.printStackTrace();
|
|
|
289 |
Window.alert("Error fetching Inventory Data");
|
|
|
290 |
}
|
|
|
291 |
});
|
|
|
292 |
}
|
|
|
293 |
});
|
|
|
294 |
|
|
|
295 |
Button updateLiveDataButton = new Button("Update Live Data");
|
|
|
296 |
headerAvailability.setWidget(0, TABLE_INDEX_WAREHOUSE_UPDATE_BUTTON, updateLiveDataButton);
|
|
|
297 |
/* code to be rewritten later
|
|
|
298 |
updateLiveDataButton.addClickHandler(new ClickHandler() {
|
|
|
299 |
@Override
|
|
|
300 |
public void onClick(ClickEvent event) {
|
|
|
301 |
catalogService.getProdItemInventory(item.getId(), new AsyncCallback<Map<Long, ItemInventory>>() {
|
|
|
302 |
@Override
|
|
|
303 |
public void onSuccess(Map<Long, ItemInventory> itemInventoryMap) {
|
|
|
304 |
if(itemInventoryMap != null) {
|
|
|
305 |
GWT.log("Inventory Data fetched");
|
|
|
306 |
item.setItemInventory(itemInventoryMap);
|
|
|
307 |
updateAvailabilityTable(item.getItemInventory());
|
|
|
308 |
}
|
|
|
309 |
else {
|
|
|
310 |
GWT.log("Error fetching Inventory Data");
|
|
|
311 |
Window.alert("Error fetching Inventory Data");
|
|
|
312 |
}
|
|
|
313 |
}
|
|
|
314 |
@Override
|
|
|
315 |
public void onFailure(Throwable caught) {
|
|
|
316 |
caught.printStackTrace();
|
|
|
317 |
Window.alert("Error fetching Inventory Data");
|
|
|
318 |
}
|
|
|
319 |
});
|
|
|
320 |
}
|
|
|
321 |
});
|
|
|
322 |
*/
|
|
|
323 |
headerAvailability.getCellFormatter().setVisible(0, TABLE_INDEX_WAREHOUSE_UPDATE_BUTTON, false);
|
| 1992 |
ankur.sing |
324 |
|
|
|
325 |
}
|
| 2066 |
ankur.sing |
326 |
|
| 2427 |
ankur.sing |
327 |
/**
|
|
|
328 |
* initialises vendor item key table header. Creates an Add button and
|
|
|
329 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
330 |
* a new vendor item key.
|
|
|
331 |
*/
|
|
|
332 |
private void initVendorKeysHeader(){
|
|
|
333 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
334 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
335 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
|
|
336 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
|
|
337 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
| 2119 |
ankur.sing |
338 |
|
| 2427 |
ankur.sing |
339 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDORID, "Vendor Id");
|
|
|
340 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDOR_DESC, "Vendor");
|
|
|
341 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY, "Item Key");
|
|
|
342 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, "Prev Item Key");
|
| 2119 |
ankur.sing |
343 |
|
| 2427 |
ankur.sing |
344 |
headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_VENDORID, false);
|
|
|
345 |
headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 2359 |
ankur.sing |
346 |
|
| 2119 |
ankur.sing |
347 |
Button addButton = new Button("Add");
|
| 2427 |
ankur.sing |
348 |
headerVendorItemKey.setWidget(0, TABLE_INDEX_MAPPING_BUTTON, addButton);
|
| 2119 |
ankur.sing |
349 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
350 |
@Override
|
|
|
351 |
public void onClick(ClickEvent event) {
|
| 2126 |
ankur.sing |
352 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
|
|
353 |
modelNumber.getText().trim(), color.getText().trim());
|
| 2119 |
ankur.sing |
354 |
vendorMappingDialog.updateButton.setText("Add");
|
|
|
355 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
|
|
356 |
@Override
|
|
|
357 |
public boolean onUpdate(String key, long vendorId) {
|
| 2427 |
ankur.sing |
358 |
int row = tableVendorItemKey.getRowCount();
|
|
|
359 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
360 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
361 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
|
|
362 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
| 2119 |
ankur.sing |
363 |
|
| 2427 |
ankur.sing |
364 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDORID, vendorId + "");
|
|
|
365 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
|
|
366 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, key);
|
|
|
367 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, key);
|
| 2359 |
ankur.sing |
368 |
|
| 2427 |
ankur.sing |
369 |
tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_VENDORID, false);
|
|
|
370 |
tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 2119 |
ankur.sing |
371 |
return true;
|
|
|
372 |
}
|
|
|
373 |
});
|
|
|
374 |
vendorMappingDialog.show();
|
|
|
375 |
}
|
|
|
376 |
});
|
|
|
377 |
}
|
|
|
378 |
|
| 2427 |
ankur.sing |
379 |
/**
|
|
|
380 |
* initialises vendor prices table header. Creates an Add button and
|
|
|
381 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
382 |
* a prices for a new vendor
|
|
|
383 |
*/
|
|
|
384 |
private void initVendorPricingHeader(){
|
|
|
385 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
386 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
387 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
|
|
388 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
|
|
389 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
|
|
390 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
| 2066 |
ankur.sing |
391 |
|
| 2427 |
ankur.sing |
392 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
|
|
|
393 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
|
|
|
394 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
|
|
|
395 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
|
|
|
396 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
|
| 2105 |
ankur.sing |
397 |
|
| 2427 |
ankur.sing |
398 |
headerVendorPrices.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
|
| 2359 |
ankur.sing |
399 |
|
| 2105 |
ankur.sing |
400 |
Button addButton = new Button("Add");
|
| 2427 |
ankur.sing |
401 |
headerVendorPrices.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
|
| 2105 |
ankur.sing |
402 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
403 |
@Override
|
|
|
404 |
public void onClick(ClickEvent event) {
|
| 2119 |
ankur.sing |
405 |
VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
|
|
|
406 |
vendorPricesDialog.updateButton.setText("Add");
|
|
|
407 |
vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| 2105 |
ankur.sing |
408 |
@Override
|
| 2119 |
ankur.sing |
409 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
| 2105 |
ankur.sing |
410 |
if(!vendorExists(vendorId)) {
|
|
|
411 |
Window.alert("Vendor already exists");
|
|
|
412 |
return false;
|
|
|
413 |
}
|
| 2119 |
ankur.sing |
414 |
/*if(!validateVendorPrices(mop, dp, tp)) {
|
| 2105 |
ankur.sing |
415 |
return false;
|
| 2119 |
ankur.sing |
416 |
}*/
|
| 2427 |
ankur.sing |
417 |
int row = tableVendorPrices.getRowCount();
|
|
|
418 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
419 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
420 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
|
|
421 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
|
|
422 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
| 2105 |
ankur.sing |
423 |
|
| 2427 |
ankur.sing |
424 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
|
|
|
425 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
|
|
426 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
|
|
427 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
|
|
428 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
| 2359 |
ankur.sing |
429 |
|
| 2427 |
ankur.sing |
430 |
tableVendorPrices.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
|
| 2105 |
ankur.sing |
431 |
return true;
|
|
|
432 |
}
|
|
|
433 |
});
|
| 2119 |
ankur.sing |
434 |
vendorPricesDialog.show();
|
| 2105 |
ankur.sing |
435 |
}
|
|
|
436 |
});
|
| 2066 |
ankur.sing |
437 |
}
|
| 2105 |
ankur.sing |
438 |
|
| 2427 |
ankur.sing |
439 |
/**
|
| 3558 |
rajveer |
440 |
* initialises source prices table header. Creates an Add button and
|
|
|
441 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
442 |
* a prices for a new source
|
|
|
443 |
*/
|
|
|
444 |
private void initSourcePricingHeader(){
|
|
|
445 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, VENDOR_ID_WIDTH);
|
|
|
446 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, VENDOR_DESC_WIDTH);
|
|
|
447 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_MRP, PRICE_WIDTH);
|
|
|
448 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, PRICE_WIDTH);
|
|
|
449 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_BUTTON, BUTTON_WIDTH);
|
|
|
450 |
|
|
|
451 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, "Source Id");
|
|
|
452 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, "Source");
|
|
|
453 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_MRP, "MRP");
|
|
|
454 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, "Selling Price");
|
|
|
455 |
|
|
|
456 |
headerSourcePrices.getCellFormatter().setVisible(0, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
|
|
457 |
|
|
|
458 |
Button addButton = new Button("Add");
|
|
|
459 |
headerSourcePrices.setWidget(0, TABLE_INDEX_SOURCE_PRICING_BUTTON, addButton);
|
|
|
460 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
461 |
@Override
|
|
|
462 |
public void onClick(ClickEvent event) {
|
| 3567 |
rajveer |
463 |
SourcePricesDialog sourcePricesDialog = new SourcePricesDialog(mrp.getText().trim(), sellingPrice.getText().trim());
|
|
|
464 |
//SourcePricesDialog sourcePricesDialog = new SourcePricesDialog();
|
| 3558 |
rajveer |
465 |
sourcePricesDialog.updateButton.setText("Add");
|
|
|
466 |
sourcePricesDialog.setSourcePriceUpdateListener(new SourcePricesDialog.SourcePriceUpdateListener() {
|
|
|
467 |
@Override
|
|
|
468 |
public boolean onUpdate(double mrp, double sellingPrice, long sourceId) {
|
|
|
469 |
if(!sourceExists(sourceId)) {
|
|
|
470 |
Window.alert("Source already exists");
|
|
|
471 |
return false;
|
|
|
472 |
}
|
|
|
473 |
|
|
|
474 |
int row = tableSourcePrices.getRowCount();
|
|
|
475 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, VENDOR_ID_WIDTH);
|
|
|
476 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, VENDOR_DESC_WIDTH);
|
|
|
477 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_MRP, PRICE_WIDTH);
|
|
|
478 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, PRICE_WIDTH);
|
|
|
479 |
|
|
|
480 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, sourceId + "");
|
|
|
481 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, Utils.getSourceDesc(sourceId));
|
|
|
482 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_MRP, mrp + "");
|
|
|
483 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, sellingPrice + "");
|
|
|
484 |
|
|
|
485 |
tableSourcePrices.getCellFormatter().setVisible(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
|
|
486 |
return true;
|
|
|
487 |
}
|
|
|
488 |
});
|
|
|
489 |
sourcePricesDialog.show();
|
|
|
490 |
}
|
|
|
491 |
});
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
/**
|
| 4423 |
phani.kuma |
495 |
* initialises similar items table header. Creates an Add button and
|
|
|
496 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
497 |
* a new similar item.
|
|
|
498 |
*/
|
|
|
499 |
private void initSimilarItemList() {
|
|
|
500 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, PRICE_WIDTH);
|
|
|
501 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, PRICE_WIDTH);
|
|
|
502 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BRAND, PRICE_WIDTH);
|
|
|
503 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, PRICE_WIDTH);
|
|
|
504 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, PRICE_WIDTH);
|
|
|
505 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, "150px");
|
|
|
506 |
headerSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BUTTON, BUTTON_WIDTH);
|
|
|
507 |
|
|
|
508 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, "Catalog ItemId");
|
|
|
509 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, "Product Group");
|
|
|
510 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_BRAND, "Brand");
|
|
|
511 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, "Model Number");
|
|
|
512 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, "Model Name");
|
|
|
513 |
headerSimilarItems.setText(0, TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, "Category");
|
|
|
514 |
|
|
|
515 |
Button addButton = new Button("Add");
|
|
|
516 |
headerSimilarItems.setWidget(0, TABLE_INDEX_SIMILAR_ITEMS_BUTTON, addButton);
|
|
|
517 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
518 |
@Override
|
|
|
519 |
public void onClick(ClickEvent event) {
|
|
|
520 |
AddSimilarItemDialog addSimilarItemDialog = new AddSimilarItemDialog();
|
|
|
521 |
addSimilarItemDialog.setAddSimilarItemUpdateListener(new AddSimilarItemDialog.AddSimilarItemUpdateListener() {
|
|
|
522 |
@Override
|
|
|
523 |
public boolean onUpdate(long catalogItemId) {
|
|
|
524 |
if (item.getSimilarItems().containsKey(catalogItemId)) {
|
|
|
525 |
Window.alert("Similar Item exists.");
|
|
|
526 |
return false;
|
|
|
527 |
}
|
|
|
528 |
else {
|
|
|
529 |
catalogService.addSimilarItem(item.getId(), catalogItemId, new AsyncCallback<Item>() {
|
|
|
530 |
@Override
|
|
|
531 |
public void onSuccess(Item similarItem) {
|
|
|
532 |
if(similarItem != null) {
|
|
|
533 |
GWT.log("Similar Item Added");
|
|
|
534 |
Map<Long, Item> newsimilarItems = item.getSimilarItems();
|
|
|
535 |
newsimilarItems.put(similarItem.getCatalogItemId(), similarItem);
|
|
|
536 |
item.setSimilarItems(newsimilarItems);
|
|
|
537 |
updateSimilarItemsTable(item.getSimilarItems());
|
|
|
538 |
Window.alert("Similar Item Added successfully.");
|
|
|
539 |
}
|
|
|
540 |
else {
|
|
|
541 |
GWT.log("Error Adding Similar Item");
|
|
|
542 |
Window.alert("Error Adding Similar Item");
|
|
|
543 |
}
|
|
|
544 |
}
|
|
|
545 |
@Override
|
|
|
546 |
public void onFailure(Throwable caught) {
|
|
|
547 |
caught.printStackTrace();
|
|
|
548 |
Window.alert("Error deleting Similar Item");
|
|
|
549 |
}
|
|
|
550 |
});
|
|
|
551 |
return true;
|
|
|
552 |
}
|
|
|
553 |
}
|
|
|
554 |
});
|
|
|
555 |
addSimilarItemDialog.show();
|
|
|
556 |
}
|
|
|
557 |
});
|
|
|
558 |
}
|
|
|
559 |
|
|
|
560 |
/**
|
| 2427 |
ankur.sing |
561 |
* Clear and populate item availability table.
|
|
|
562 |
* @param availabilityMap
|
|
|
563 |
*/
|
| 4431 |
phani.kuma |
564 |
private void updateAvailabilityTable(Map<Long, ItemInventory> itemInventoryMap){
|
| 1992 |
ankur.sing |
565 |
availabilityTable.removeAllRows();
|
| 4431 |
phani.kuma |
566 |
if(itemInventoryMap == null || itemInventoryMap.isEmpty()) {
|
| 1992 |
ankur.sing |
567 |
return;
|
|
|
568 |
}
|
| 4431 |
phani.kuma |
569 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "100px");
|
| 2105 |
ankur.sing |
570 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
|
| 4431 |
phani.kuma |
571 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INVA, "100px");
|
|
|
572 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INVR, "100px");
|
|
|
573 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_GET_BUTTON, "100px");
|
|
|
574 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_UPDATE_BUTTON, "100px");
|
| 2066 |
ankur.sing |
575 |
|
| 1992 |
ankur.sing |
576 |
int i=0;
|
| 4431 |
phani.kuma |
577 |
for(ItemInventory warehousedata : itemInventoryMap.values()){
|
|
|
578 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_ID, warehousedata.getWarehouseId() + "");
|
|
|
579 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(warehousedata.getWarehouseId()) + "");
|
|
|
580 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INVA, warehousedata.getAvailability() + "");
|
|
|
581 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INVR, warehousedata.getReserved() + "");
|
| 1992 |
ankur.sing |
582 |
i++;
|
|
|
583 |
}
|
|
|
584 |
}
|
| 4423 |
phani.kuma |
585 |
|
| 2427 |
ankur.sing |
586 |
/**
|
|
|
587 |
* Clear and populate vendor item key table with keys in the passed argument.
|
|
|
588 |
* With each row in the table, an edit button is created and click event listener
|
|
|
589 |
* is added to it to edit that vendor item key row.
|
|
|
590 |
* @param vendorKeysMap
|
|
|
591 |
*/
|
|
|
592 |
private void updateVendorKeysTable(Map<String, VendorItemMapping> vendorKeysMap){
|
|
|
593 |
tableVendorItemKey.removeAllRows();
|
| 2119 |
ankur.sing |
594 |
|
| 2427 |
ankur.sing |
595 |
if(vendorKeysMap == null || vendorKeysMap.isEmpty()) {
|
| 2119 |
ankur.sing |
596 |
return;
|
|
|
597 |
}
|
| 2427 |
ankur.sing |
598 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
599 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
600 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
|
|
601 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
|
|
602 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
| 2066 |
ankur.sing |
603 |
|
| 2119 |
ankur.sing |
604 |
int i=0;
|
| 2427 |
ankur.sing |
605 |
for(Entry<String, VendorItemMapping> e : vendorKeysMap.entrySet()){
|
| 2359 |
ankur.sing |
606 |
VendorItemMapping vendorMapping = e.getValue();
|
| 2427 |
ankur.sing |
607 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDORID, vendorMapping.getVendorId() + "");
|
|
|
608 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
|
|
|
609 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY, vendorMapping.getItemKey());
|
|
|
610 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1));
|
| 2119 |
ankur.sing |
611 |
Button editButton = new Button("Edit");
|
| 2427 |
ankur.sing |
612 |
tableVendorItemKey.setWidget(i, TABLE_INDEX_MAPPING_BUTTON, editButton);
|
| 2119 |
ankur.sing |
613 |
editButton.addClickHandler(new ClickHandler() {
|
|
|
614 |
@Override
|
|
|
615 |
public void onClick(ClickEvent event) {
|
| 2427 |
ankur.sing |
616 |
Cell cell = tableVendorItemKey.getCellForEvent(event);
|
| 2119 |
ankur.sing |
617 |
int row = cell.getRowIndex();
|
| 2427 |
ankur.sing |
618 |
long vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
|
|
619 |
editVendorKey(vendorId, row);
|
| 2119 |
ankur.sing |
620 |
}
|
|
|
621 |
});
|
| 2427 |
ankur.sing |
622 |
tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_VENDORID, false);
|
|
|
623 |
tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 2359 |
ankur.sing |
624 |
i++;
|
| 2119 |
ankur.sing |
625 |
}
|
|
|
626 |
}
|
|
|
627 |
|
| 2427 |
ankur.sing |
628 |
/**
|
|
|
629 |
* Clear and populate vendor prices table with prices in the passed argument.
|
|
|
630 |
* With each row in the table, an edit button is created and click event listener
|
|
|
631 |
* is added to it to edit that vendor prices row.
|
|
|
632 |
* @param vendorPricingMap
|
|
|
633 |
*/
|
|
|
634 |
private void updateVendorPricingTable(Map<Long, VendorPricings> vendorPricingMap){
|
|
|
635 |
tableVendorPrices.removeAllRows();
|
| 2105 |
ankur.sing |
636 |
|
| 2119 |
ankur.sing |
637 |
if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
|
| 1992 |
ankur.sing |
638 |
return;
|
|
|
639 |
}
|
| 2427 |
ankur.sing |
640 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
641 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
642 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
|
|
643 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
|
|
644 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
|
|
645 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
| 2066 |
ankur.sing |
646 |
|
|
|
647 |
|
| 1992 |
ankur.sing |
648 |
int i=0;
|
| 2119 |
ankur.sing |
649 |
for(VendorPricings vendorDetail : vendorPricingMap.values()){
|
| 2427 |
ankur.sing |
650 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
|
|
|
651 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
|
|
|
652 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
|
|
|
653 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
|
|
|
654 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
|
| 1992 |
ankur.sing |
655 |
Button editButton = new Button("Edit");
|
| 2427 |
ankur.sing |
656 |
tableVendorPrices.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
|
| 1992 |
ankur.sing |
657 |
editButton.addClickHandler(new ClickHandler() {
|
|
|
658 |
@Override
|
|
|
659 |
public void onClick(ClickEvent event) {
|
| 2427 |
ankur.sing |
660 |
Cell cell = tableVendorPrices.getCellForEvent(event);
|
| 1992 |
ankur.sing |
661 |
int row = cell.getRowIndex();
|
| 2427 |
ankur.sing |
662 |
long vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
|
|
663 |
editVendorPrices(vendorId, row);
|
| 1992 |
ankur.sing |
664 |
}
|
|
|
665 |
});
|
| 2427 |
ankur.sing |
666 |
tableVendorPrices.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
|
| 2359 |
ankur.sing |
667 |
i++;
|
| 1992 |
ankur.sing |
668 |
}
|
|
|
669 |
}
|
| 2066 |
ankur.sing |
670 |
|
| 2427 |
ankur.sing |
671 |
/**
|
| 3558 |
rajveer |
672 |
* Clear and populate vendor prices table with prices in the passed argument.
|
|
|
673 |
* With each row in the table, an edit button is created and click event listener
|
|
|
674 |
* is added to it to edit that vendor prices row.
|
|
|
675 |
* @param sourcePricingMap
|
|
|
676 |
*/
|
|
|
677 |
private void updateSourcePricingTable(Map<Long, SourcePricings> sourcePricingMap){
|
|
|
678 |
tableSourcePrices.removeAllRows();
|
|
|
679 |
|
|
|
680 |
if(sourcePricingMap == null || sourcePricingMap.isEmpty()) {
|
|
|
681 |
return;
|
|
|
682 |
}
|
|
|
683 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, VENDOR_ID_WIDTH);
|
|
|
684 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, VENDOR_DESC_WIDTH);
|
|
|
685 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_MRP, PRICE_WIDTH);
|
|
|
686 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, PRICE_WIDTH);
|
|
|
687 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_BUTTON, BUTTON_WIDTH);
|
|
|
688 |
|
|
|
689 |
int i=0;
|
|
|
690 |
for(SourcePricings sourceDetail : sourcePricingMap.values()){
|
|
|
691 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, sourceDetail.getSourceId() + "");
|
|
|
692 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, Utils.getSourceDesc(sourceDetail.getSourceId()));
|
|
|
693 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_MRP, sourceDetail.getMrp() + "");
|
|
|
694 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, sourceDetail.getSellingPrice() + "");
|
|
|
695 |
|
|
|
696 |
Button editButton = new Button("Edit");
|
|
|
697 |
tableSourcePrices.setWidget(i, TABLE_INDEX_SOURCE_PRICING_BUTTON, editButton);
|
|
|
698 |
editButton.addClickHandler(new ClickHandler() {
|
|
|
699 |
@Override
|
|
|
700 |
public void onClick(ClickEvent event) {
|
|
|
701 |
Cell cell = tableSourcePrices.getCellForEvent(event);
|
|
|
702 |
int row = cell.getRowIndex();
|
|
|
703 |
long sourceId = Long.parseLong(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID));
|
|
|
704 |
editSourcePrices(sourceId, row);
|
|
|
705 |
}
|
|
|
706 |
});
|
|
|
707 |
tableSourcePrices.getCellFormatter().setVisible(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
|
|
708 |
i++;
|
|
|
709 |
}
|
|
|
710 |
}
|
|
|
711 |
|
|
|
712 |
/**
|
| 4423 |
phani.kuma |
713 |
* Clear and populate similar items table with items in the passed argument.
|
|
|
714 |
* With each row in the table, an delete button is created and click event listener
|
|
|
715 |
* is added to it to delete that similar item row.
|
|
|
716 |
* @param similarItems
|
|
|
717 |
*/
|
|
|
718 |
private void updateSimilarItemsTable(Map<Long, Item> similarItems){
|
|
|
719 |
tableSimilarItems.removeAllRows();
|
|
|
720 |
|
|
|
721 |
if(similarItems == null || similarItems.isEmpty()) {
|
|
|
722 |
return;
|
|
|
723 |
}
|
|
|
724 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, PRICE_WIDTH);
|
|
|
725 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, PRICE_WIDTH);
|
|
|
726 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BRAND, PRICE_WIDTH);
|
|
|
727 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, PRICE_WIDTH);
|
|
|
728 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, PRICE_WIDTH);
|
|
|
729 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, "150px");
|
|
|
730 |
tableSimilarItems.getColumnFormatter().setWidth(TABLE_INDEX_SIMILAR_ITEMS_BUTTON, BUTTON_WIDTH);
|
|
|
731 |
|
|
|
732 |
|
|
|
733 |
int i=0;
|
|
|
734 |
for(Item similarItemDetail : similarItems.values()){
|
|
|
735 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID, similarItemDetail.getCatalogItemId() + "");
|
|
|
736 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_PRODUCT_GROUP, similarItemDetail.getProductGroup() + "");
|
|
|
737 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_BRAND, similarItemDetail.getBrand() + "");
|
|
|
738 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NUMBER, similarItemDetail.getModelNumber() + "");
|
|
|
739 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_MODEL_NAME, similarItemDetail.getModelName() + "");
|
|
|
740 |
tableSimilarItems.setText(i, TABLE_INDEX_SIMILAR_ITEMS_CATEGORY, similarItemDetail.getContentCategory() + "");
|
|
|
741 |
|
|
|
742 |
Button deleteButton = new Button("Delete");
|
|
|
743 |
tableSimilarItems.setWidget(i, TABLE_INDEX_SIMILAR_ITEMS_BUTTON, deleteButton);
|
|
|
744 |
deleteButton.addClickHandler(new ClickHandler() {
|
|
|
745 |
@Override
|
|
|
746 |
public void onClick(ClickEvent event) {
|
|
|
747 |
Cell cell = tableSimilarItems.getCellForEvent(event);
|
|
|
748 |
final int row = cell.getRowIndex();
|
|
|
749 |
long catalogItemId = Long.parseLong(tableSimilarItems.getText(row, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID));
|
|
|
750 |
|
|
|
751 |
catalogService.deleteSimilarItem(item.getId(), catalogItemId, new AsyncCallback<Boolean>() {
|
|
|
752 |
@Override
|
|
|
753 |
public void onSuccess(Boolean result) {
|
|
|
754 |
if(result) {
|
|
|
755 |
GWT.log("Similar Item deleted");
|
|
|
756 |
long catalogItemId = Long.parseLong(tableSimilarItems.getText(row, TABLE_INDEX_SIMILAR_ITEMS_CATALOG_ITEM_ID));
|
|
|
757 |
tableSimilarItems.removeRow(row);
|
|
|
758 |
Map<Long, Item> newsimilarItems = item.getSimilarItems();
|
|
|
759 |
newsimilarItems.remove(catalogItemId);
|
|
|
760 |
item.setSimilarItems(newsimilarItems);
|
|
|
761 |
}
|
|
|
762 |
else {
|
|
|
763 |
GWT.log("Error deleting Similar Item");
|
|
|
764 |
Window.alert("Error deleting Similar Item");
|
|
|
765 |
}
|
|
|
766 |
}
|
|
|
767 |
@Override
|
|
|
768 |
public void onFailure(Throwable caught) {
|
|
|
769 |
caught.printStackTrace();
|
|
|
770 |
Window.alert("Error deleting Similar Item");
|
|
|
771 |
}
|
|
|
772 |
});
|
|
|
773 |
}
|
|
|
774 |
});
|
|
|
775 |
i++;
|
|
|
776 |
}
|
|
|
777 |
}
|
|
|
778 |
|
|
|
779 |
/**
|
| 2427 |
ankur.sing |
780 |
* called on the click event of update item button in ItemActions
|
|
|
781 |
*/
|
| 2126 |
ankur.sing |
782 |
void updateItem() {
|
|
|
783 |
if(item == null) {
|
|
|
784 |
Window.alert("Please select an item to update.");
|
|
|
785 |
return;
|
|
|
786 |
}
|
| 2066 |
ankur.sing |
787 |
try {
|
| 2126 |
ankur.sing |
788 |
if(!createNewItem()) {
|
|
|
789 |
return;
|
|
|
790 |
}
|
| 2066 |
ankur.sing |
791 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
792 |
ex.printStackTrace();
|
|
|
793 |
GWT.log("Number format exception");
|
|
|
794 |
}
|
| 5427 |
amit.gupta |
795 |
String paramsChanged = isItemChanged();
|
|
|
796 |
if(paramsChanged.equals("")) {
|
|
|
797 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
|
|
798 |
return;
|
|
|
799 |
} else {
|
|
|
800 |
if(item.getSameItemsWithDifferentColors().size()>0 && optionalChangedValMap.size()>0 ){
|
|
|
801 |
createDialog(paramsChanged);
|
|
|
802 |
} else {
|
|
|
803 |
paramsChanged = "You have changed following items.\n" + paramsChanged;
|
|
|
804 |
Window.alert(paramsChanged);
|
|
|
805 |
validateNUpdate();
|
|
|
806 |
}
|
|
|
807 |
}
|
|
|
808 |
}
|
|
|
809 |
|
|
|
810 |
|
|
|
811 |
private void validateNUpdate() {
|
|
|
812 |
if(!Utils.validateItem(newItem)) {
|
| 2066 |
ankur.sing |
813 |
return;
|
|
|
814 |
}
|
| 2126 |
ankur.sing |
815 |
|
| 4649 |
phani.kuma |
816 |
final String[] messageList = new String[2];
|
|
|
817 |
|
|
|
818 |
String sellingpricemessage = compareSellingPricewithBreakEven();
|
|
|
819 |
if(sellingpricemessage.equals("false")) {
|
|
|
820 |
return;
|
|
|
821 |
}
|
|
|
822 |
else if(!sellingpricemessage.equals("true")) {
|
|
|
823 |
messageList[0] = sellingpricemessage;
|
|
|
824 |
}
|
|
|
825 |
|
|
|
826 |
String preferredvendormessage = checkTransferPriceforPreferredVendor();
|
|
|
827 |
if(preferredvendormessage.equals("false")) {
|
|
|
828 |
return;
|
|
|
829 |
}
|
|
|
830 |
else if(!preferredvendormessage.equals("true")) {
|
|
|
831 |
messageList[1] = preferredvendormessage;
|
|
|
832 |
}
|
|
|
833 |
|
| 2126 |
ankur.sing |
834 |
/*if(!validatePrices()) {
|
|
|
835 |
return;
|
|
|
836 |
}*/
|
|
|
837 |
catalogService.updateItem(newItem, new AsyncCallback<Boolean>() {
|
|
|
838 |
@Override
|
|
|
839 |
public void onSuccess(Boolean result) {
|
|
|
840 |
if(result) {
|
| 4649 |
phani.kuma |
841 |
for(int i = 0; i < messageList.length; i++) {
|
|
|
842 |
if(messageList[i] != null) {
|
|
|
843 |
logAuthorization(messageList[i]);
|
|
|
844 |
}
|
|
|
845 |
}
|
| 5427 |
amit.gupta |
846 |
if(optionalChangedValMap.size()>0 || mandatoryChangedValMap.size()>0){
|
|
|
847 |
for(Long itemId : item.getSameItemsWithDifferentColors()){
|
|
|
848 |
updateItem(itemId);
|
|
|
849 |
}
|
|
|
850 |
}
|
| 2126 |
ankur.sing |
851 |
item = newItem;
|
|
|
852 |
GWT.log("Item updated. Id = " + item.getId());
|
| 2489 |
ankur.sing |
853 |
catalogDashboardPanel.getItemListWidget().updateItem(item);
|
|
|
854 |
getFreshItemFromDB(item.getId());
|
| 2126 |
ankur.sing |
855 |
Window.alert("Item updated successfully.");
|
|
|
856 |
}
|
|
|
857 |
else {
|
|
|
858 |
GWT.log("Error updating item");
|
|
|
859 |
Window.alert("Error updating item");
|
|
|
860 |
}
|
|
|
861 |
}
|
|
|
862 |
@Override
|
|
|
863 |
public void onFailure(Throwable caught) {
|
|
|
864 |
caught.printStackTrace();
|
|
|
865 |
Window.alert("Error while updating item");
|
|
|
866 |
}
|
|
|
867 |
});
|
| 2066 |
ankur.sing |
868 |
}
|
| 2126 |
ankur.sing |
869 |
|
| 2489 |
ankur.sing |
870 |
private void getFreshItemFromDB(long id) {
|
|
|
871 |
catalogService.getItem(id, new AsyncCallback<Item>() {
|
|
|
872 |
@Override
|
|
|
873 |
public void onSuccess(Item result) {
|
|
|
874 |
setItemDetails(result);
|
|
|
875 |
}
|
|
|
876 |
@Override
|
|
|
877 |
public void onFailure(Throwable caught) {
|
|
|
878 |
caught.printStackTrace();
|
|
|
879 |
Window.alert("Unable to fetch item details.");
|
|
|
880 |
}
|
|
|
881 |
});
|
|
|
882 |
}
|
|
|
883 |
|
| 2427 |
ankur.sing |
884 |
/**
|
|
|
885 |
* This method is called while updating item.<br> It will create a new Item object and set
|
|
|
886 |
* its editable attributes with UI fields values and non-editable attributes with old Item
|
|
|
887 |
* object attributes. This new Item object is then passed to the service to update item in the database.
|
|
|
888 |
* <br>If update is successful, the old Item object is replaced with the new Item object.
|
|
|
889 |
* @return true if new Item object is created successfully
|
|
|
890 |
* <br>false if some error occurs due to NumberFormatException
|
|
|
891 |
*/
|
| 2126 |
ankur.sing |
892 |
private boolean createNewItem() {
|
| 2066 |
ankur.sing |
893 |
newItem = new Item();
|
| 2489 |
ankur.sing |
894 |
newItem.setId(item.getId());
|
| 2066 |
ankur.sing |
895 |
newItem.setProductGroup(productGroup.getText().trim());
|
|
|
896 |
newItem.setBrand(brand.getText().trim());
|
|
|
897 |
newItem.setModelNumber(modelNumber.getText().trim());
|
|
|
898 |
newItem.setModelName(modelName.getText().trim());
|
|
|
899 |
newItem.setColor(color.getText().trim());
|
| 2119 |
ankur.sing |
900 |
newItem.setContentCategory(contentCategory.getText());
|
| 2066 |
ankur.sing |
901 |
newItem.setComments(comments.getText().trim());
|
|
|
902 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
| 2126 |
ankur.sing |
903 |
|
| 2068 |
ankur.sing |
904 |
try {
|
| 2126 |
ankur.sing |
905 |
if(!mrp.getText().trim().isEmpty()) {
|
|
|
906 |
double mrpValue = Double.parseDouble(mrp.getText().trim());
|
|
|
907 |
if(mrpValue <= 0) {
|
|
|
908 |
throw new NumberFormatException("Negative value of MRP");
|
|
|
909 |
}
|
|
|
910 |
newItem.setMrp(mrpValue);
|
|
|
911 |
}
|
| 2068 |
ankur.sing |
912 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
913 |
Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
|
|
|
914 |
return false;
|
| 2068 |
ankur.sing |
915 |
}
|
|
|
916 |
try {
|
| 2126 |
ankur.sing |
917 |
if(!sellingPrice.getText().trim().isEmpty()) {
|
|
|
918 |
double spValue = Double.parseDouble(sellingPrice.getText().trim());
|
|
|
919 |
if(spValue <= 0) {
|
|
|
920 |
throw new NumberFormatException("Negative value of Selling price");
|
|
|
921 |
}
|
|
|
922 |
newItem.setSellingPrice(spValue);
|
|
|
923 |
}
|
|
|
924 |
} catch(NumberFormatException ex) {
|
|
|
925 |
Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
|
|
|
926 |
return false;
|
| 2068 |
ankur.sing |
927 |
}
|
|
|
928 |
try {
|
| 2126 |
ankur.sing |
929 |
if(!weight.getText().trim().isEmpty()) {
|
|
|
930 |
double wtValue = Double.parseDouble(weight.getText().trim());
|
|
|
931 |
if(wtValue <= 0) {
|
|
|
932 |
throw new NumberFormatException("Negative value of Weight");
|
|
|
933 |
}
|
|
|
934 |
newItem.setWeight(wtValue);
|
|
|
935 |
}
|
| 2068 |
ankur.sing |
936 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
937 |
Window.alert("Invalid weight format/value. Value shoule be greater than zero");
|
|
|
938 |
return false;
|
| 2068 |
ankur.sing |
939 |
}
|
| 2126 |
ankur.sing |
940 |
try {
|
|
|
941 |
if(!startDate.getTextBox().getText().trim().equals("")) {
|
|
|
942 |
newItem.setStartDate(startDate.getValue().getTime());
|
|
|
943 |
}
|
|
|
944 |
} catch(Exception ex) {
|
|
|
945 |
Window.alert("Invalid start date format");
|
|
|
946 |
return false;
|
|
|
947 |
}
|
| 2066 |
ankur.sing |
948 |
newItem.setBestDealsText(bestDealsText.getText().trim());
|
| 5217 |
amit.gupta |
949 |
Date comingSoonStartDt = comingSoonStartDate.getValue();
|
|
|
950 |
Date expectedArrivalDt = expectedArrivalDate.getValue();
|
|
|
951 |
if(comingSoonStartDt == null){
|
|
|
952 |
newItem.setComingSoonStartDate(null);
|
|
|
953 |
}else {
|
|
|
954 |
newItem.setComingSoonStartDate(comingSoonStartDt.getTime());
|
|
|
955 |
}
|
|
|
956 |
if(expectedArrivalDt == null){
|
|
|
957 |
newItem.setExpectedArrivalDate(null);
|
|
|
958 |
}else {
|
|
|
959 |
newItem.setExpectedArrivalDate(expectedArrivalDt.getTime());
|
|
|
960 |
}
|
| 2068 |
ankur.sing |
961 |
try {
|
| 2126 |
ankur.sing |
962 |
if(!bestDealsValue.getText().trim().equals("")) {
|
|
|
963 |
double bdValue = Double.parseDouble(bestDealsValue.getText().trim());
|
|
|
964 |
if(bdValue < 0) {
|
|
|
965 |
throw new NumberFormatException("Negative value of BestDealValue");
|
|
|
966 |
}
|
|
|
967 |
newItem.setBestDealsValue(bdValue);
|
|
|
968 |
}
|
| 2068 |
ankur.sing |
969 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
970 |
Window.alert("Invalid best deal value format");
|
|
|
971 |
return false;
|
| 2068 |
ankur.sing |
972 |
}
|
| 3363 |
chandransh |
973 |
|
| 2068 |
ankur.sing |
974 |
try {
|
| 2126 |
ankur.sing |
975 |
if(!bestSellingRank.getText().trim().equals("")) {
|
|
|
976 |
long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
|
|
|
977 |
if(bsrValue < 0) {
|
|
|
978 |
throw new NumberFormatException("Negative value of Best Selling Rank");
|
|
|
979 |
}
|
|
|
980 |
newItem.setBestSellingRank(bsrValue);
|
|
|
981 |
}
|
|
|
982 |
} catch(NumberFormatException ex) {
|
|
|
983 |
Window.alert("Invalid best selling rank format");
|
|
|
984 |
return false;
|
| 2068 |
ankur.sing |
985 |
}
|
| 2066 |
ankur.sing |
986 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
| 2252 |
ankur.sing |
987 |
newItem.setRisky(risky.getValue());
|
| 2119 |
ankur.sing |
988 |
|
| 3363 |
chandransh |
989 |
try {
|
|
|
990 |
String expectedDelayText = expectedDelay.getText().trim();
|
|
|
991 |
if(!expectedDelayText.equals("")){
|
|
|
992 |
newItem.setExpectedDelay(Integer.parseInt(expectedDelayText));
|
|
|
993 |
}
|
|
|
994 |
} catch(NumberFormatException nfe) {
|
|
|
995 |
Window.alert("Invalid expected delay");
|
|
|
996 |
return false;
|
|
|
997 |
}
|
|
|
998 |
|
| 4583 |
phani.kuma |
999 |
if((item.getPreferredVendor() == null || item.getVendorPricesMap() == null || item.getVendorPricesMap().isEmpty()) && preferredVendor.getSelectedIndex() == 0) {
|
|
|
1000 |
newItem.setPreferredVendor(item.getPreferredVendor());
|
|
|
1001 |
}
|
|
|
1002 |
else {
|
| 4506 |
phani.kuma |
1003 |
long vendorId = Utils.getVendorId(preferredVendor.getItemText(preferredVendor.getSelectedIndex()));
|
|
|
1004 |
newItem.setPreferredVendor(vendorId);
|
|
|
1005 |
}
|
|
|
1006 |
|
| 4413 |
anupam.sin |
1007 |
newItem.setWarehouseStickiness(warehouseStickiness.getValue());
|
| 5384 |
phani.kuma |
1008 |
newItem.setHasItemNo(hasItemNo.getValue());
|
|
|
1009 |
newItem.setItemType(itemType.getValue());
|
| 4413 |
anupam.sin |
1010 |
|
| 2126 |
ankur.sing |
1011 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
|
|
1012 |
Add the instance to map and set the map to the item instance created above.*/
|
|
|
1013 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
| 2119 |
ankur.sing |
1014 |
VendorPricings v;
|
| 2427 |
ankur.sing |
1015 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
| 2119 |
ankur.sing |
1016 |
v = new VendorPricings();
|
| 2427 |
ankur.sing |
1017 |
v.setMop(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP)));
|
|
|
1018 |
v.setDealerPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP)));
|
|
|
1019 |
v.setTransferPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP)));
|
|
|
1020 |
v.setVendorId(Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID)));
|
| 2126 |
ankur.sing |
1021 |
vendorPrices.put(v.getVendorId(), v);
|
| 2066 |
ankur.sing |
1022 |
}
|
| 2126 |
ankur.sing |
1023 |
newItem.setVendorPricesMap(vendorPrices);
|
| 2359 |
ankur.sing |
1024 |
newItem.setItemStatusDesc(statusDesc.getText().trim());
|
| 2427 |
ankur.sing |
1025 |
|
| 2126 |
ankur.sing |
1026 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
|
|
1027 |
Add the instance to map and set the map to the item instance created above.*/
|
| 2359 |
ankur.sing |
1028 |
Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
|
| 2126 |
ankur.sing |
1029 |
VendorItemMapping vMapping;
|
| 2427 |
ankur.sing |
1030 |
for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
|
| 2126 |
ankur.sing |
1031 |
vMapping = new VendorItemMapping();
|
| 2427 |
ankur.sing |
1032 |
vMapping.setItemKey(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY));
|
|
|
1033 |
vMapping.setVendorId(Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID)));
|
|
|
1034 |
vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD), vMapping);
|
| 2119 |
ankur.sing |
1035 |
}
|
| 2359 |
ankur.sing |
1036 |
newItem.setVendorKeysMap(vendorMappings);
|
| 2119 |
ankur.sing |
1037 |
|
| 3558 |
rajveer |
1038 |
/*Create an instance of SourcePricings for each row in source pricing table. Set the source prices to the instance.
|
|
|
1039 |
Add the instance to map and set the map to the item instance created above.*/
|
|
|
1040 |
Map<Long, SourcePricings> sourcePrices = new HashMap<Long, SourcePricings>();
|
|
|
1041 |
SourcePricings s;
|
|
|
1042 |
for(int row = 0; row < tableSourcePrices.getRowCount(); row++) {
|
|
|
1043 |
s = new SourcePricings();
|
|
|
1044 |
s.setMrp(Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_MRP)));
|
|
|
1045 |
s.setSellingPrice(Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE)));
|
|
|
1046 |
s.setSourceId(Long.parseLong(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID)));
|
|
|
1047 |
sourcePrices.put(s.getSourceId(), s);
|
|
|
1048 |
}
|
|
|
1049 |
newItem.setSourcePricesMap(sourcePrices);
|
|
|
1050 |
|
| 2126 |
ankur.sing |
1051 |
newItem.setContentCategoryId(item.getContentCategoryId());
|
|
|
1052 |
newItem.setFeatureId(item.getFeatureId());
|
|
|
1053 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
|
|
1054 |
newItem.setAddedOn(item.getAddedOn());
|
|
|
1055 |
newItem.setRetireDate(item.getRetireDate());
|
|
|
1056 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
|
|
1057 |
newItem.setItemStatus(item.getItemStatus());
|
| 4431 |
phani.kuma |
1058 |
newItem.setItemInventory(item.getItemInventory());
|
| 4423 |
phani.kuma |
1059 |
newItem.setSimilarItems(item.getSimilarItems());
|
| 2119 |
ankur.sing |
1060 |
|
| 2126 |
ankur.sing |
1061 |
return true;
|
| 2066 |
ankur.sing |
1062 |
}
|
|
|
1063 |
|
| 2427 |
ankur.sing |
1064 |
/**
|
|
|
1065 |
* This method is called when Edit button is clicked corresponding to a row in
|
|
|
1066 |
* vendor prices table. It will pop up a form to edit the vendor prices.
|
|
|
1067 |
* @param vendorId
|
|
|
1068 |
* @param row
|
|
|
1069 |
*/
|
|
|
1070 |
private void editVendorPrices(final long vendorId, final int row) {
|
|
|
1071 |
String mop = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP);
|
|
|
1072 |
String dp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP);
|
|
|
1073 |
String tp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP);
|
| 2119 |
ankur.sing |
1074 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
|
| 2105 |
ankur.sing |
1075 |
pricesDialog.updateButton.setText("Update");
|
| 2119 |
ankur.sing |
1076 |
pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| 2066 |
ankur.sing |
1077 |
@Override
|
| 2119 |
ankur.sing |
1078 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
|
|
1079 |
if(!validateVendorPrices(mop, dp, tp)) {
|
| 2105 |
ankur.sing |
1080 |
return false;
|
|
|
1081 |
}
|
| 2427 |
ankur.sing |
1082 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
|
|
1083 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
|
|
1084 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
| 2105 |
ankur.sing |
1085 |
return true;
|
| 2066 |
ankur.sing |
1086 |
}
|
|
|
1087 |
});
|
|
|
1088 |
pricesDialog.show();
|
|
|
1089 |
}
|
| 2119 |
ankur.sing |
1090 |
|
| 2427 |
ankur.sing |
1091 |
/**
|
|
|
1092 |
* This method is called when Edit button is clicked corresponding to a row in
|
| 3558 |
rajveer |
1093 |
* vendor prices table. It will pop up a form to edit the vendor prices.
|
|
|
1094 |
* @param vendorId
|
|
|
1095 |
* @param row
|
|
|
1096 |
*/
|
|
|
1097 |
private void editSourcePrices(final long sourceId, final int row) {
|
|
|
1098 |
String mrp = tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_MRP);
|
|
|
1099 |
String sellingPrice = tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE);
|
|
|
1100 |
SourcePricesDialog pricesDialog = new SourcePricesDialog(mrp, sellingPrice);
|
|
|
1101 |
pricesDialog.updateButton.setText("Update");
|
|
|
1102 |
pricesDialog.setSourcePriceUpdateListener(new SourcePricesDialog.SourcePriceUpdateListener() {
|
|
|
1103 |
@Override
|
|
|
1104 |
public boolean onUpdate(double mrp, double sellingPrice, long sourceId) {
|
|
|
1105 |
if(!validateSourcePrices(mrp, sellingPrice)) {
|
|
|
1106 |
return false;
|
|
|
1107 |
}
|
|
|
1108 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_MRP, mrp + "");
|
|
|
1109 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, sellingPrice + "");
|
|
|
1110 |
return true;
|
|
|
1111 |
}
|
|
|
1112 |
});
|
|
|
1113 |
pricesDialog.show();
|
|
|
1114 |
}
|
|
|
1115 |
|
|
|
1116 |
|
|
|
1117 |
/**
|
|
|
1118 |
* This method is called when Edit button is clicked corresponding to a row in
|
| 2427 |
ankur.sing |
1119 |
* vendor item key table. It will pop up a form to edit the item key.
|
|
|
1120 |
* @param vendorId
|
|
|
1121 |
* @param row
|
|
|
1122 |
*/
|
|
|
1123 |
private void editVendorKey(final long vendorId, final int row) {
|
|
|
1124 |
String key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
| 2126 |
ankur.sing |
1125 |
VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
|
|
1126 |
modelNumber.getText().trim(), color.getText().trim(), key);
|
| 2119 |
ankur.sing |
1127 |
mappingDialog.updateButton.setText("Update");
|
|
|
1128 |
mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
|
|
1129 |
@Override
|
|
|
1130 |
public boolean onUpdate(String itemKey, long vendorId) {
|
|
|
1131 |
if(itemKey == null || itemKey.equals("")) {
|
|
|
1132 |
Window.alert("Item key cannot be empty.");
|
|
|
1133 |
return false;
|
|
|
1134 |
}
|
| 2427 |
ankur.sing |
1135 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, itemKey);
|
| 2119 |
ankur.sing |
1136 |
return true;
|
|
|
1137 |
}
|
|
|
1138 |
});
|
|
|
1139 |
mappingDialog.show();
|
|
|
1140 |
}
|
| 2066 |
ankur.sing |
1141 |
|
| 2427 |
ankur.sing |
1142 |
/**
|
|
|
1143 |
* This method compares all the editable UI fields values with attributes in the item object.
|
|
|
1144 |
* If they differ, the attribute name is appended to a string.
|
|
|
1145 |
* @return String showing attributes which are changed by the user for confirmation.
|
|
|
1146 |
* <br>Empty string if nothing is changed.
|
|
|
1147 |
*/
|
| 2252 |
ankur.sing |
1148 |
private String isItemChanged() {
|
|
|
1149 |
StringBuilder sb = new StringBuilder("");
|
| 5427 |
amit.gupta |
1150 |
mandatoryChangedValMap = new HashMap<String, Object>();
|
|
|
1151 |
optionalChangedValMap = new HashMap<String, Object>();
|
| 2489 |
ankur.sing |
1152 |
if(!checkParameterIfEqual(brand.getText().trim(), item.getBrand())) {
|
| 5427 |
amit.gupta |
1153 |
mandatoryChangedValMap.put(MANDATORY_BRAND, brand.getText().trim());
|
| 2387 |
ankur.sing |
1154 |
sb.append("\n-Brand");
|
| 2066 |
ankur.sing |
1155 |
}
|
| 2489 |
ankur.sing |
1156 |
if(!checkParameterIfEqual(modelNumber.getText().trim(), item.getModelNumber())) {
|
| 5427 |
amit.gupta |
1157 |
mandatoryChangedValMap.put(MANDATORY_MODEL_NO, modelNumber.getText().trim());
|
| 2387 |
ankur.sing |
1158 |
sb.append("\n-Model Number");
|
| 2066 |
ankur.sing |
1159 |
}
|
| 2489 |
ankur.sing |
1160 |
if(!checkParameterIfEqual(modelName.getText().trim(), item.getModelName())) {
|
| 5427 |
amit.gupta |
1161 |
mandatoryChangedValMap.put(MANDATORY_MODEL_NAME, modelName.getText().trim());
|
| 2387 |
ankur.sing |
1162 |
sb.append("\n-Model Name");
|
| 2066 |
ankur.sing |
1163 |
}
|
| 2489 |
ankur.sing |
1164 |
if(!checkParameterIfEqual(color.getText().trim(), item.getColor())) {
|
| 2387 |
ankur.sing |
1165 |
sb.append("\n-Color");
|
| 2066 |
ankur.sing |
1166 |
}
|
| 2489 |
ankur.sing |
1167 |
if(!checkParameterIfEqual(statusDesc.getText().trim(), item.getItemStatusDesc())) {
|
| 2387 |
ankur.sing |
1168 |
sb.append("\n-Status Description");
|
| 2359 |
ankur.sing |
1169 |
}
|
| 2489 |
ankur.sing |
1170 |
if(!checkParameterIfEqual(comments.getText().trim(), item.getComments())) {
|
| 2387 |
ankur.sing |
1171 |
sb.append("\n-Comments");
|
| 2066 |
ankur.sing |
1172 |
}
|
| 2489 |
ankur.sing |
1173 |
if(!checkParameterIfEqual(newItem.getMrp(), item.getMrp())) {
|
| 5427 |
amit.gupta |
1174 |
mandatoryChangedValMap.put(MANDATORY_MRP, newItem.getMrp());
|
| 2387 |
ankur.sing |
1175 |
sb.append("\n-MRP");
|
| 2066 |
ankur.sing |
1176 |
}
|
| 2489 |
ankur.sing |
1177 |
if(!checkParameterIfEqual(newItem.getSellingPrice(), item.getSellingPrice())) {
|
| 5427 |
amit.gupta |
1178 |
optionalChangedValMap.put(OPTIONAL_SELLING_PRICE, newItem.getSellingPrice());
|
| 2387 |
ankur.sing |
1179 |
sb.append("\n-Selling Price");
|
| 2027 |
ankur.sing |
1180 |
}
|
| 2489 |
ankur.sing |
1181 |
if(!checkParameterIfEqual(newItem.getWeight(), item.getWeight())) {
|
| 5427 |
amit.gupta |
1182 |
mandatoryChangedValMap.put(MANDATORY_WEIGHT, newItem.getWeight());
|
| 2387 |
ankur.sing |
1183 |
sb.append("\n-Weight");
|
| 2027 |
ankur.sing |
1184 |
}
|
| 2489 |
ankur.sing |
1185 |
if(!checkParameterIfEqual(bestDealsText.getText().trim(), item.getBestDealsText())) {
|
| 5427 |
amit.gupta |
1186 |
mandatoryChangedValMap.put(MANDATORY_BEST_DEAL_TEXT, bestDealsText.getText().trim());
|
| 2387 |
ankur.sing |
1187 |
sb.append("\n-Best Deal Text");
|
| 2066 |
ankur.sing |
1188 |
}
|
| 2489 |
ankur.sing |
1189 |
if(!checkParameterIfEqual(newItem.getBestDealsValue(), item.getBestDealsValue())) {
|
| 2387 |
ankur.sing |
1190 |
sb.append("\n-Best Deal Value");
|
| 2027 |
ankur.sing |
1191 |
}
|
| 2489 |
ankur.sing |
1192 |
if(!checkParameterIfEqual(newItem.getBestSellingRank(), item.getBestSellingRank())) {
|
| 2387 |
ankur.sing |
1193 |
sb.append("\n-Best Selling Rank");
|
| 2066 |
ankur.sing |
1194 |
}
|
|
|
1195 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
| 2387 |
ankur.sing |
1196 |
sb.append("\n-Default For Entity Flag");
|
| 2066 |
ankur.sing |
1197 |
}
|
| 2252 |
ankur.sing |
1198 |
if(item.isRisky() != risky.getValue()) {
|
| 2387 |
ankur.sing |
1199 |
sb.append("\n-Risky Flag");
|
| 2252 |
ankur.sing |
1200 |
}
|
| 2489 |
ankur.sing |
1201 |
if(!checkParameterIfEqual(newItem.getStartDate(), item.getStartDate())) {
|
| 2387 |
ankur.sing |
1202 |
sb.append("\n-Start Date");
|
| 2068 |
ankur.sing |
1203 |
}
|
| 5217 |
amit.gupta |
1204 |
if(!checkParameterIfEqual(newItem.getExpectedArrivalDate(), item.getExpectedArrivalDate())) {
|
|
|
1205 |
sb.append("\n-Expected Arrival Date");
|
|
|
1206 |
}
|
|
|
1207 |
if(!checkParameterIfEqual(newItem.getComingSoonStartDate(), item.getComingSoonStartDate())) {
|
|
|
1208 |
sb.append("\n-Coming Soon Start Date");
|
|
|
1209 |
}
|
| 3524 |
chandransh |
1210 |
if(!checkParameterIfEqual(newItem.getExpectedDelay(), item.getExpectedDelay())) {
|
| 3362 |
chandransh |
1211 |
sb.append("\n-Expected Delay");
|
|
|
1212 |
}
|
| 4413 |
anupam.sin |
1213 |
if(item.isWarehouseStickiness() != warehouseStickiness.getValue()) {
|
|
|
1214 |
sb.append("\n-Warehouse Stickiness Flag");
|
|
|
1215 |
}
|
| 4506 |
phani.kuma |
1216 |
if(!checkParameterIfEqual(newItem.getPreferredVendor(), item.getPreferredVendor())) {
|
| 5427 |
amit.gupta |
1217 |
optionalChangedValMap.put(OPTIONAL_PREFERRED_VENDOR, newItem.getPreferredVendor());
|
| 4506 |
phani.kuma |
1218 |
sb.append("\n-Preferred Vendor");
|
|
|
1219 |
}
|
| 5384 |
phani.kuma |
1220 |
if(item.isHasItemNo() != hasItemNo.getValue()) {
|
|
|
1221 |
sb.append("\n-Has Item Number Flag");
|
|
|
1222 |
}
|
|
|
1223 |
if(item.isItemType() != itemType.getValue()) {
|
|
|
1224 |
sb.append("\n-Has Serial Number Flag");
|
|
|
1225 |
}
|
| 3362 |
chandransh |
1226 |
|
| 2126 |
ankur.sing |
1227 |
VendorPricings vendorPricings;
|
| 2066 |
ankur.sing |
1228 |
long vendorId;
|
| 5427 |
amit.gupta |
1229 |
boolean vendorPricingsChanged = false;
|
| 2427 |
ankur.sing |
1230 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
|
|
1231 |
vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
| 2126 |
ankur.sing |
1232 |
vendorPricings = item.getVendorPricesMap().get(vendorId);
|
| 2359 |
ankur.sing |
1233 |
if(vendorPricings == null) {
|
| 2387 |
ankur.sing |
1234 |
sb.append("\n-Vendor Prices (Vendor:" + vendorId + ")");
|
| 5427 |
amit.gupta |
1235 |
vendorPricingsChanged = true;
|
| 2359 |
ankur.sing |
1236 |
continue;
|
|
|
1237 |
}
|
| 2427 |
ankur.sing |
1238 |
if(vendorPricings.getMop() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP))) {
|
| 5427 |
amit.gupta |
1239 |
vendorPricingsChanged = true;
|
| 2387 |
ankur.sing |
1240 |
sb.append("\n-MOP (Vendor:" + vendorId + ")");
|
| 2066 |
ankur.sing |
1241 |
}
|
| 2427 |
ankur.sing |
1242 |
if(vendorPricings.getDealerPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP))) {
|
| 5427 |
amit.gupta |
1243 |
vendorPricingsChanged = true;
|
| 2387 |
ankur.sing |
1244 |
sb.append("\n-Dealer Price (Vendor:" + vendorId + ")");
|
| 2066 |
ankur.sing |
1245 |
}
|
| 2427 |
ankur.sing |
1246 |
if(vendorPricings.getTransferPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP))) {
|
| 5427 |
amit.gupta |
1247 |
vendorPricingsChanged = true;
|
| 2066 |
ankur.sing |
1248 |
}
|
|
|
1249 |
}
|
| 5427 |
amit.gupta |
1250 |
if(vendorPricingsChanged){
|
|
|
1251 |
sb.append("\n-Vendor Pricing");
|
|
|
1252 |
optionalChangedValMap.put(OPTIONAL_VENDOR_PRICING, newItem.getVendorPricesMap());
|
|
|
1253 |
}
|
| 2387 |
ankur.sing |
1254 |
|
| 3558 |
rajveer |
1255 |
SourcePricings sourcePricings;
|
| 5427 |
amit.gupta |
1256 |
boolean sourcePricingsChanged = false;
|
| 3558 |
rajveer |
1257 |
long sourceId;
|
|
|
1258 |
for(int row = 0; row < tableSourcePrices.getRowCount(); row++) {
|
|
|
1259 |
sourceId = Long.parseLong(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID));
|
|
|
1260 |
sourcePricings = item.getSourcePricesMap().get(sourceId);
|
|
|
1261 |
if(sourcePricings == null) {
|
| 5427 |
amit.gupta |
1262 |
sourcePricingsChanged = true;
|
| 3558 |
rajveer |
1263 |
sb.append("\n-Source Prices (Source:" + sourceId + ")");
|
|
|
1264 |
continue;
|
|
|
1265 |
}
|
|
|
1266 |
if(sourcePricings.getMrp() != Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_MRP))) {
|
| 5427 |
amit.gupta |
1267 |
sourcePricingsChanged = true;
|
| 3558 |
rajveer |
1268 |
sb.append("\n-MRP (Source:" + sourceId + ")");
|
|
|
1269 |
}
|
|
|
1270 |
if(sourcePricings.getSellingPrice() != Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE))) {
|
| 5427 |
amit.gupta |
1271 |
sourcePricingsChanged = true;
|
| 3558 |
rajveer |
1272 |
sb.append("\n-Selling Price (Source:" + sourceId + ")");
|
|
|
1273 |
}
|
|
|
1274 |
}
|
| 5427 |
amit.gupta |
1275 |
if(sourcePricingsChanged){
|
|
|
1276 |
sb.append("\n-Source Pricing");
|
|
|
1277 |
optionalChangedValMap.put(OPTIONAL_SOURCE_PRICING, newItem.getSourcePricesMap());
|
|
|
1278 |
}
|
| 3558 |
rajveer |
1279 |
|
| 5427 |
amit.gupta |
1280 |
|
| 2387 |
ankur.sing |
1281 |
VendorItemMapping mapping;
|
|
|
1282 |
String old_key, new_key;
|
| 2427 |
ankur.sing |
1283 |
for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
|
|
|
1284 |
vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
|
|
1285 |
old_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD);
|
|
|
1286 |
new_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
| 2387 |
ankur.sing |
1287 |
mapping = item.getVendorKeysMap().get(vendorId + Item.KEY_SEPARATOR + old_key);
|
|
|
1288 |
if(mapping == null || !old_key.equals(new_key)) {
|
|
|
1289 |
sb.append("\n-Vendor Key (Vendor:" + vendorId + ",Key: = " + old_key + ")");
|
|
|
1290 |
continue;
|
|
|
1291 |
}
|
|
|
1292 |
}
|
| 2252 |
ankur.sing |
1293 |
return sb.toString();
|
| 2066 |
ankur.sing |
1294 |
}
|
|
|
1295 |
|
| 2566 |
chandransh |
1296 |
@SuppressWarnings("unused")
|
|
|
1297 |
private boolean validatePrices() {
|
| 2066 |
ankur.sing |
1298 |
if(newItem.getSellingPrice() > newItem.getMrp()) {
|
|
|
1299 |
Window.alert("Selling price cannot be more than MRP");
|
|
|
1300 |
return false;
|
|
|
1301 |
}
|
| 2119 |
ankur.sing |
1302 |
for(VendorPricings v : newItem.getVendorPricesMap().values()) {
|
| 2105 |
ankur.sing |
1303 |
if(newItem.getMrp() < v.getMop()) {
|
|
|
1304 |
Window.alert("MRP cannot be less than MOP. Vendor: " + v.getVendorId());
|
| 2066 |
ankur.sing |
1305 |
return false;
|
|
|
1306 |
}
|
| 2105 |
ankur.sing |
1307 |
if(v.getTransferPrice() > v.getMop()) {
|
|
|
1308 |
Window.alert("Transfer Price cannot be more than MOP. Vendor: " + v.getVendorId());
|
| 2066 |
ankur.sing |
1309 |
return false;
|
|
|
1310 |
}
|
|
|
1311 |
}
|
|
|
1312 |
return true;
|
|
|
1313 |
}
|
| 2105 |
ankur.sing |
1314 |
|
| 2119 |
ankur.sing |
1315 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
| 2489 |
ankur.sing |
1316 |
if(item.getMrp() != null && item.getMrp() < mop) {
|
| 2105 |
ankur.sing |
1317 |
Window.alert("MOP cannot be more than MRP.");
|
|
|
1318 |
return false;
|
| 1992 |
ankur.sing |
1319 |
}
|
| 2105 |
ankur.sing |
1320 |
if(tp > mop) {
|
|
|
1321 |
Window.alert("Transfer Price cannot be more than MOP.");
|
|
|
1322 |
return false;
|
| 1992 |
ankur.sing |
1323 |
}
|
| 2105 |
ankur.sing |
1324 |
return true;
|
| 1992 |
ankur.sing |
1325 |
}
|
| 3558 |
rajveer |
1326 |
|
|
|
1327 |
private boolean validateSourcePrices(double mrp, double sellingPrice) {
|
|
|
1328 |
if(sellingPrice > mrp) {
|
|
|
1329 |
Window.alert("Selling Price cannot be more than MRP.");
|
|
|
1330 |
return false;
|
|
|
1331 |
}
|
|
|
1332 |
return true;
|
|
|
1333 |
}
|
|
|
1334 |
|
| 2105 |
ankur.sing |
1335 |
|
|
|
1336 |
public long getItemId() {
|
|
|
1337 |
return item == null ? 0 : item.getId();
|
|
|
1338 |
}
|
|
|
1339 |
|
|
|
1340 |
public Item getItem() {
|
|
|
1341 |
return item;
|
|
|
1342 |
}
|
|
|
1343 |
|
| 2427 |
ankur.sing |
1344 |
/**
|
|
|
1345 |
* This method is used while adding vendor prices to ensure that there is only one row in the table for a vendor.
|
|
|
1346 |
* @param vendorId
|
|
|
1347 |
* @return true if parameter vendor Id is already added to vendor prices table.
|
|
|
1348 |
* <br>else false
|
|
|
1349 |
*/
|
| 2105 |
ankur.sing |
1350 |
private boolean vendorExists(long vendorId) {
|
|
|
1351 |
long id;
|
| 2427 |
ankur.sing |
1352 |
for(int i = 0; i < tableVendorPrices.getRowCount(); i++) {
|
|
|
1353 |
id = Long.parseLong(tableVendorPrices.getText(i, TABLE_INDEX_PRICING_VENDORID));
|
| 2105 |
ankur.sing |
1354 |
if(vendorId == id) {
|
|
|
1355 |
return false;
|
|
|
1356 |
}
|
| 1992 |
ankur.sing |
1357 |
}
|
| 2105 |
ankur.sing |
1358 |
return true;
|
| 1992 |
ankur.sing |
1359 |
}
|
| 2387 |
ankur.sing |
1360 |
|
| 2427 |
ankur.sing |
1361 |
/**
|
| 3558 |
rajveer |
1362 |
* This method is used while adding source prices to ensure that there is only one row in the table for a source.
|
|
|
1363 |
* @param sourceId
|
|
|
1364 |
* @return true if parameter vendor Id is already added to source prices table.
|
|
|
1365 |
* <br>else false
|
|
|
1366 |
*/
|
|
|
1367 |
private boolean sourceExists(long sourceId) {
|
|
|
1368 |
long id;
|
|
|
1369 |
for(int i = 0; i < tableSourcePrices.getRowCount(); i++) {
|
|
|
1370 |
id = Long.parseLong(tableSourcePrices.getText(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID));
|
|
|
1371 |
if(sourceId == id) {
|
|
|
1372 |
return false;
|
|
|
1373 |
}
|
|
|
1374 |
}
|
|
|
1375 |
return true;
|
|
|
1376 |
}
|
|
|
1377 |
|
|
|
1378 |
/**
|
| 2427 |
ankur.sing |
1379 |
* This method is used to check if any of the string item attributes is changed by the user.
|
| 2489 |
ankur.sing |
1380 |
* @param o1
|
|
|
1381 |
* @param o2
|
| 2427 |
ankur.sing |
1382 |
* @return true if two strings are equal
|
|
|
1383 |
* <br>true if one of them is null and another is empty.
|
|
|
1384 |
* <br>false otherwise
|
|
|
1385 |
*/
|
| 2489 |
ankur.sing |
1386 |
private boolean checkParameterIfEqual(Object o1, Object o2) {
|
|
|
1387 |
if(o1 == o2) {
|
| 2387 |
ankur.sing |
1388 |
return true;
|
|
|
1389 |
}
|
| 2489 |
ankur.sing |
1390 |
if(o1 != null && o2 != null && o1.equals(o2)) {
|
| 2387 |
ankur.sing |
1391 |
return true;
|
|
|
1392 |
}
|
| 2489 |
ankur.sing |
1393 |
if((o1 == null && o2.equals("")) || (o2 == null && o1.equals(""))) {
|
| 2387 |
ankur.sing |
1394 |
return true;
|
|
|
1395 |
}
|
|
|
1396 |
return false;
|
|
|
1397 |
}
|
| 2489 |
ankur.sing |
1398 |
|
|
|
1399 |
public void setCatalogDashboardPanel(CatalogDashboard catalogDashboardPanel) {
|
|
|
1400 |
this.catalogDashboardPanel = catalogDashboardPanel;
|
|
|
1401 |
}
|
| 4649 |
phani.kuma |
1402 |
|
|
|
1403 |
private String compareSellingPricewithBreakEven() {
|
|
|
1404 |
String message = "false";
|
|
|
1405 |
if(newItem.getWeight() == null) {
|
|
|
1406 |
Window.alert("Weight is empty.");
|
|
|
1407 |
return message;
|
|
|
1408 |
}
|
|
|
1409 |
if(newItem.getSellingPrice() == null) {
|
|
|
1410 |
Window.alert("Selling Price is empty.");
|
|
|
1411 |
return message;
|
|
|
1412 |
}
|
|
|
1413 |
|
|
|
1414 |
double transferPrice;
|
|
|
1415 |
if(newItem.getPreferredVendor() == null && !newItem.getVendorPricesMap().isEmpty()) {
|
|
|
1416 |
transferPrice = -1;
|
|
|
1417 |
for(VendorPricings vendorDetail : newItem.getVendorPricesMap().values()){
|
|
|
1418 |
if(transferPrice > vendorDetail.getTransferPrice() || transferPrice == -1){
|
|
|
1419 |
transferPrice = vendorDetail.getTransferPrice();
|
|
|
1420 |
}
|
|
|
1421 |
}
|
|
|
1422 |
}
|
|
|
1423 |
else if(!newItem.getVendorPricesMap().isEmpty() && newItem.getVendorPricesMap().containsKey(newItem.getPreferredVendor())){
|
|
|
1424 |
transferPrice = newItem.getVendorPricesMap().get(newItem.getPreferredVendor()).getTransferPrice();
|
|
|
1425 |
}
|
|
|
1426 |
else{
|
|
|
1427 |
Window.alert("Add vendor to Vendor Prices and then change the Selling Price.");
|
|
|
1428 |
return message;
|
|
|
1429 |
}
|
|
|
1430 |
|
|
|
1431 |
double weightfactor = Math.ceil((newItem.getWeight() * 1000)/Double.parseDouble(ConfigMap.get("courier_weight_factor")));
|
|
|
1432 |
double couriercost = Double.parseDouble(ConfigMap.get("courier_cost_factor")) * weightfactor;
|
|
|
1433 |
double costfactor = (Double.parseDouble(ConfigMap.get("transfer_price_percentage")) * transferPrice)/100;
|
|
|
1434 |
double breakeven;
|
|
|
1435 |
if(costfactor < Double.parseDouble(ConfigMap.get("transfer_price_factor"))){
|
|
|
1436 |
breakeven = transferPrice + couriercost + Double.parseDouble(ConfigMap.get("breakeven_additon_factor"));
|
|
|
1437 |
}
|
|
|
1438 |
else{
|
|
|
1439 |
breakeven = (transferPrice + couriercost)/Double.parseDouble(ConfigMap.get("breakeven_divisor"));
|
|
|
1440 |
}
|
|
|
1441 |
|
|
|
1442 |
if(breakeven > newItem.getSellingPrice()) {
|
|
|
1443 |
message = "Selling Price("+newItem.getSellingPrice()+") is less than Breakeven Price("+breakeven+").";
|
|
|
1444 |
if(Window.confirm(message)){
|
|
|
1445 |
return message;
|
|
|
1446 |
}
|
|
|
1447 |
else{
|
|
|
1448 |
message = "false";
|
|
|
1449 |
Window.alert("Updation of Item is canceled.");
|
|
|
1450 |
return message;
|
|
|
1451 |
}
|
|
|
1452 |
}
|
|
|
1453 |
else {
|
|
|
1454 |
message = "true";
|
|
|
1455 |
return message;
|
|
|
1456 |
}
|
|
|
1457 |
}
|
|
|
1458 |
|
|
|
1459 |
private String checkTransferPriceforPreferredVendor() {
|
|
|
1460 |
String message = "false";
|
|
|
1461 |
if(newItem.getPreferredVendor() == null) {
|
|
|
1462 |
message = "true";
|
|
|
1463 |
return message;
|
|
|
1464 |
}
|
|
|
1465 |
else if(!newItem.getVendorPricesMap().isEmpty() && newItem.getVendorPricesMap().containsKey(newItem.getPreferredVendor())){
|
|
|
1466 |
double transferPrice = newItem.getVendorPricesMap().get(newItem.getPreferredVendor()).getTransferPrice();
|
|
|
1467 |
double mintransferPrice = -1;
|
|
|
1468 |
String minvendor = "";
|
|
|
1469 |
boolean compareTransferPrices = false;
|
|
|
1470 |
for(VendorPricings vendorDetail : newItem.getVendorPricesMap().values()){
|
|
|
1471 |
if(mintransferPrice > vendorDetail.getTransferPrice() || mintransferPrice == -1){
|
|
|
1472 |
mintransferPrice = vendorDetail.getTransferPrice();
|
|
|
1473 |
minvendor = Utils.getVendorDesc(vendorDetail.getVendorId());
|
|
|
1474 |
}
|
|
|
1475 |
}
|
|
|
1476 |
if(!checkParameterIfEqual(newItem.getPreferredVendor(), item.getPreferredVendor()) || item.getVendorPricesMap().isEmpty()) {
|
|
|
1477 |
compareTransferPrices = true;
|
|
|
1478 |
}
|
|
|
1479 |
else {
|
|
|
1480 |
double oldmintransferPrice = -1;
|
|
|
1481 |
for(VendorPricings vendorDetail : item.getVendorPricesMap().values()){
|
|
|
1482 |
if(oldmintransferPrice > vendorDetail.getTransferPrice() || oldmintransferPrice == -1){
|
|
|
1483 |
oldmintransferPrice = vendorDetail.getTransferPrice();
|
|
|
1484 |
}
|
|
|
1485 |
}
|
|
|
1486 |
if(mintransferPrice < oldmintransferPrice){
|
|
|
1487 |
compareTransferPrices = true;
|
|
|
1488 |
}
|
|
|
1489 |
}
|
|
|
1490 |
if(compareTransferPrices && transferPrice > mintransferPrice){
|
|
|
1491 |
message = "Transfer Price("+transferPrice+") of Preferred Vendor("+Utils.getVendorDesc(newItem.getPreferredVendor())+") is more than Transfer Price("+mintransferPrice+") of "+minvendor+".";
|
|
|
1492 |
if(Window.confirm(message)){
|
|
|
1493 |
return message;
|
|
|
1494 |
}
|
|
|
1495 |
else{
|
|
|
1496 |
message = "false";
|
|
|
1497 |
Window.alert("Updation of Item is canceled.");
|
|
|
1498 |
return message;
|
|
|
1499 |
}
|
|
|
1500 |
}
|
|
|
1501 |
else {
|
|
|
1502 |
message = "true";
|
|
|
1503 |
return message;
|
|
|
1504 |
}
|
|
|
1505 |
}
|
|
|
1506 |
else{
|
|
|
1507 |
Window.alert("Add vendor to Vendor Prices and then change the Preferred Vendor.");
|
|
|
1508 |
return message;
|
|
|
1509 |
}
|
|
|
1510 |
}
|
|
|
1511 |
|
|
|
1512 |
public void logAuthorization(String message) {
|
|
|
1513 |
String username = catalogDashboardPanel.uname;
|
|
|
1514 |
catalogService.addAuthorizationLog(newItem.getId(), username, message, new AsyncCallback<Boolean>() {
|
|
|
1515 |
@Override
|
|
|
1516 |
public void onSuccess(Boolean result) {
|
|
|
1517 |
if(result) {
|
|
|
1518 |
GWT.log("Event is added");
|
|
|
1519 |
}
|
|
|
1520 |
else {
|
|
|
1521 |
GWT.log("Error adding the event");
|
|
|
1522 |
Window.alert("Error adding the event");
|
|
|
1523 |
}
|
|
|
1524 |
}
|
|
|
1525 |
@Override
|
|
|
1526 |
public void onFailure(Throwable caught) {
|
|
|
1527 |
caught.printStackTrace();
|
|
|
1528 |
Window.alert("Error while adding the event");
|
|
|
1529 |
}
|
|
|
1530 |
});
|
|
|
1531 |
}
|
| 5217 |
amit.gupta |
1532 |
|
|
|
1533 |
@Override
|
|
|
1534 |
public void setComingSoonStartDate(Date date) {
|
|
|
1535 |
this.comingSoonStartDate.setValue(date);
|
|
|
1536 |
|
|
|
1537 |
}
|
|
|
1538 |
|
|
|
1539 |
@Override
|
|
|
1540 |
public void setBestDealsText(String bestDealsText) {
|
|
|
1541 |
this.bestDealsText.setValue(bestDealsText);
|
|
|
1542 |
|
|
|
1543 |
}
|
|
|
1544 |
|
|
|
1545 |
@Override
|
|
|
1546 |
public void setExpectedArrivalDate(Date date) {
|
|
|
1547 |
this.expectedArrivalDate.setValue(date);
|
|
|
1548 |
|
|
|
1549 |
}
|
|
|
1550 |
|
|
|
1551 |
@Override
|
|
|
1552 |
public String getBestDealsText() {
|
|
|
1553 |
return this.bestDealsText.getValue();
|
|
|
1554 |
}
|
|
|
1555 |
|
|
|
1556 |
@Override
|
|
|
1557 |
public Date getComingSoonStartDate() {
|
|
|
1558 |
return this.comingSoonStartDate.getValue();
|
|
|
1559 |
}
|
|
|
1560 |
|
|
|
1561 |
@Override
|
|
|
1562 |
public Date getExpectedArrivalDate() {
|
|
|
1563 |
return this.expectedArrivalDate.getValue();
|
|
|
1564 |
}
|
|
|
1565 |
@UiHandler("comingSoonButton")
|
|
|
1566 |
void onComingSoonButtonClick(ClickEvent event) {
|
|
|
1567 |
ComingSoonDialog cd = new ComingSoonDialog(this);
|
|
|
1568 |
cd.show();
|
|
|
1569 |
}
|
| 5427 |
amit.gupta |
1570 |
|
|
|
1571 |
private void createDialog(String changedString) {
|
|
|
1572 |
VerticalPanel vp = new VerticalPanel();
|
|
|
1573 |
final DialogBox db = new DialogBox();
|
|
|
1574 |
db.setText("Changed fields");
|
|
|
1575 |
|
|
|
1576 |
vp.add(new Label("Check the fields to update all SKUs with similar entity."));
|
|
|
1577 |
vp.add(new Label("--------------------------------------------------------"));
|
|
|
1578 |
CheckBox allChecked = new CheckBox("Select all");
|
|
|
1579 |
if(optionalChangedValMap.size()>1){
|
|
|
1580 |
allChecked.setName("all");
|
|
|
1581 |
allChecked.addClickHandler(new ClickHandler() {
|
|
|
1582 |
@Override
|
|
|
1583 |
public void onClick(ClickEvent event) {
|
|
|
1584 |
CheckBox cb = (CheckBox)event.getSource();
|
|
|
1585 |
VerticalPanel vp = (VerticalPanel)cb.getParent();
|
|
|
1586 |
Iterator<Widget> iterator = vp.iterator();
|
|
|
1587 |
while(iterator.hasNext()){
|
|
|
1588 |
Widget w = iterator.next();
|
|
|
1589 |
if(w instanceof CheckBox){
|
|
|
1590 |
CheckBox cbox = (CheckBox)w;
|
|
|
1591 |
if(cbox.getName()!="all"){
|
|
|
1592 |
cbox.setValue(cb.getValue());
|
|
|
1593 |
}
|
|
|
1594 |
}
|
|
|
1595 |
}
|
|
|
1596 |
if(cb.getValue()){
|
|
|
1597 |
cb.setText("Deselect all");
|
|
|
1598 |
}else {
|
|
|
1599 |
cb.setText("Select all");
|
|
|
1600 |
}
|
|
|
1601 |
}
|
|
|
1602 |
});
|
|
|
1603 |
vp.add(allChecked);
|
|
|
1604 |
}
|
|
|
1605 |
String[] changedFields = changedString.split("\n-");
|
|
|
1606 |
for(String changeField : changedFields){
|
|
|
1607 |
if(optionalChangedValMap.containsKey(changeField)){
|
|
|
1608 |
CheckBox ch = new CheckBox(changeField);
|
|
|
1609 |
ch.getElement().getStyle().setPadding(10d, Unit.PX);
|
|
|
1610 |
vp.add(ch);
|
|
|
1611 |
} else {
|
|
|
1612 |
Label l = new Label(changeField);
|
|
|
1613 |
l.getElement().getStyle().setMarginLeft(10d, Unit.PX);
|
|
|
1614 |
l.getElement().getStyle().setPadding(10d, Unit.PX);
|
|
|
1615 |
vp.add(l);
|
|
|
1616 |
}
|
|
|
1617 |
}
|
|
|
1618 |
|
|
|
1619 |
Button submitButton = new Button();
|
|
|
1620 |
submitButton.setText("Update");
|
|
|
1621 |
submitButton.addClickHandler(new ClickHandler() {
|
|
|
1622 |
|
|
|
1623 |
@Override
|
|
|
1624 |
public void onClick(ClickEvent event) {
|
|
|
1625 |
Button b = (Button)event.getSource();
|
|
|
1626 |
VerticalPanel vp = (VerticalPanel)b.getParent();
|
|
|
1627 |
Iterator<Widget> iterator = vp.iterator();
|
|
|
1628 |
while(iterator.hasNext()){
|
|
|
1629 |
Widget w = iterator.next();
|
|
|
1630 |
if(w instanceof CheckBox){
|
|
|
1631 |
CheckBox cbox = (CheckBox)w;
|
|
|
1632 |
if(cbox.getName()!="all"){
|
|
|
1633 |
if(!cbox.getValue()){
|
|
|
1634 |
optionalChangedValMap.remove(cbox.getText());
|
|
|
1635 |
}
|
|
|
1636 |
}
|
|
|
1637 |
}
|
|
|
1638 |
}
|
|
|
1639 |
db.hide();
|
|
|
1640 |
List<Item> items = new ArrayList<Item>();
|
|
|
1641 |
items.add(newItem);
|
|
|
1642 |
validateNUpdate();
|
|
|
1643 |
/*for(Long id : item.getSameItemsWithDifferentColors()){
|
|
|
1644 |
catalogService.getItem(id, new AsyncCallback<Item>() {
|
|
|
1645 |
@Override
|
|
|
1646 |
public void onSuccess(Item result) {
|
|
|
1647 |
items.add(e)
|
|
|
1648 |
}
|
|
|
1649 |
@Override
|
|
|
1650 |
public void onFailure(Throwable caught) {
|
|
|
1651 |
caught.printStackTrace();
|
|
|
1652 |
Window.alert("Unable to fetch item details.");
|
|
|
1653 |
}
|
|
|
1654 |
});
|
|
|
1655 |
}*/
|
|
|
1656 |
}
|
|
|
1657 |
|
|
|
1658 |
});
|
|
|
1659 |
vp.add(submitButton);
|
|
|
1660 |
db.add(vp);
|
|
|
1661 |
db.center();
|
|
|
1662 |
db.show();
|
|
|
1663 |
}
|
|
|
1664 |
|
|
|
1665 |
private void updateItem(Long itemId) {
|
|
|
1666 |
catalogService.getItem(itemId, new AsyncCallback<Item>() {
|
|
|
1667 |
@Override
|
|
|
1668 |
public void onSuccess(Item result) {
|
|
|
1669 |
final Item res = result;
|
|
|
1670 |
if(mandatoryChangedValMap.containsKey(MANDATORY_BRAND)){
|
|
|
1671 |
result.setBrand((String)mandatoryChangedValMap.get(MANDATORY_BRAND));
|
|
|
1672 |
}
|
|
|
1673 |
if(mandatoryChangedValMap.containsKey(MANDATORY_BEST_DEAL_TEXT)){
|
|
|
1674 |
result.setBestDealsText((String)mandatoryChangedValMap.get(MANDATORY_BEST_DEAL_TEXT));
|
|
|
1675 |
}
|
|
|
1676 |
if(mandatoryChangedValMap.containsKey(MANDATORY_MODEL_NAME)){
|
|
|
1677 |
result.setModelName((String)mandatoryChangedValMap.get(MANDATORY_MODEL_NAME));
|
|
|
1678 |
}
|
|
|
1679 |
if(mandatoryChangedValMap.containsKey(MANDATORY_MODEL_NO)){
|
|
|
1680 |
result.setModelNumber((String)mandatoryChangedValMap.get(MANDATORY_MODEL_NO));
|
|
|
1681 |
}
|
|
|
1682 |
if(mandatoryChangedValMap.containsKey(MANDATORY_WEIGHT)){
|
|
|
1683 |
result.setWeight((Double)mandatoryChangedValMap.get(MANDATORY_WEIGHT));
|
|
|
1684 |
}
|
|
|
1685 |
if(mandatoryChangedValMap.containsKey(MANDATORY_MRP)){
|
|
|
1686 |
result.setMrp((Double)mandatoryChangedValMap.get(MANDATORY_MRP));
|
|
|
1687 |
}
|
|
|
1688 |
if(optionalChangedValMap.containsKey(OPTIONAL_PREFERRED_VENDOR)){
|
|
|
1689 |
result.setPreferredVendor((Long)optionalChangedValMap.get(OPTIONAL_PREFERRED_VENDOR));
|
|
|
1690 |
}
|
|
|
1691 |
if(optionalChangedValMap.containsKey(OPTIONAL_SELLING_PRICE)){
|
|
|
1692 |
result.setSellingPrice((Double)optionalChangedValMap.get(OPTIONAL_SELLING_PRICE));
|
|
|
1693 |
}
|
|
|
1694 |
if(optionalChangedValMap.containsKey(OPTIONAL_SOURCE_PRICING)){
|
|
|
1695 |
result.setSourcePricesMap((Map<Long, SourcePricings>) optionalChangedValMap.get(OPTIONAL_SOURCE_PRICING));
|
|
|
1696 |
}
|
|
|
1697 |
if(optionalChangedValMap.containsKey(OPTIONAL_VENDOR_PRICING)){
|
|
|
1698 |
result.setVendorPricesMap((Map<Long, VendorPricings>) optionalChangedValMap.get(OPTIONAL_VENDOR_PRICING));
|
|
|
1699 |
}
|
|
|
1700 |
catalogService.updateItem(result, new AsyncCallback<Boolean>() {
|
|
|
1701 |
|
|
|
1702 |
@Override
|
|
|
1703 |
public void onSuccess(Boolean result1) {
|
|
|
1704 |
if(result1) {
|
|
|
1705 |
Window.alert(res.getId() + " updated Successfully");
|
|
|
1706 |
}
|
|
|
1707 |
|
|
|
1708 |
}
|
|
|
1709 |
|
|
|
1710 |
@Override
|
|
|
1711 |
public void onFailure(Throwable caught) {
|
|
|
1712 |
caught.printStackTrace();
|
|
|
1713 |
Window.alert("Error updating item " + res.getId());
|
|
|
1714 |
|
|
|
1715 |
}
|
|
|
1716 |
});
|
|
|
1717 |
}
|
|
|
1718 |
@Override
|
|
|
1719 |
public void onFailure(Throwable caught) {
|
|
|
1720 |
caught.printStackTrace();
|
|
|
1721 |
Window.alert("Unable to fetch item details.");
|
|
|
1722 |
}
|
|
|
1723 |
});
|
|
|
1724 |
}
|
| 1961 |
ankur.sing |
1725 |
}
|