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