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