| 2066 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
| 5217 |
amit.gupta |
3 |
import java.util.Date;
|
| 2105 |
ankur.sing |
4 |
import java.util.HashMap;
|
| 21864 |
ashik.ali |
5 |
import java.util.List;
|
| 2105 |
ankur.sing |
6 |
import java.util.Map;
|
| 4725 |
phani.kuma |
7 |
import java.util.Map.Entry;
|
| 21864 |
ashik.ali |
8 |
|
|
|
9 |
import org.apache.log4j.Logger;
|
|
|
10 |
|
| 2105 |
ankur.sing |
11 |
import com.google.gwt.core.client.GWT;
|
| 21864 |
ashik.ali |
12 |
import com.google.gwt.event.dom.client.ChangeEvent;
|
|
|
13 |
import com.google.gwt.event.dom.client.ChangeHandler;
|
| 2105 |
ankur.sing |
14 |
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
15 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
16 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
17 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
18 |
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
19 |
import com.google.gwt.user.client.Window;
|
|
|
20 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
|
21 |
import com.google.gwt.user.client.ui.Button;
|
|
|
22 |
import com.google.gwt.user.client.ui.CheckBox;
|
|
|
23 |
import com.google.gwt.user.client.ui.DialogBox;
|
|
|
24 |
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
25 |
import com.google.gwt.user.client.ui.ListBox;
|
|
|
26 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
27 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
28 |
import com.google.gwt.user.datepicker.client.DateBox;
|
|
|
29 |
|
| 21864 |
ashik.ali |
30 |
import in.shop2020.catalog.dashboard.server.CatalogServiceImpl;
|
|
|
31 |
import in.shop2020.catalog.dashboard.shared.CategoryHsnCode;
|
|
|
32 |
import in.shop2020.catalog.dashboard.shared.Item;
|
|
|
33 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
|
|
34 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
|
|
35 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
|
|
36 |
|
| 2427 |
ankur.sing |
37 |
/**
|
|
|
38 |
* ItemForm is a DialogBox which is created on the click of Add Item button in ItemActions.
|
|
|
39 |
* This contains UI fields to fill up item attributes. It also contains tables for adding
|
|
|
40 |
* vendor prices and vendor mapping keys.
|
|
|
41 |
*
|
|
|
42 |
*/
|
| 5217 |
amit.gupta |
43 |
public class ItemForm extends DialogBox implements ComingSoon{
|
| 2105 |
ankur.sing |
44 |
|
| 8901 |
vikram.rag |
45 |
interface ItemFormUiBinder extends UiBinder<Widget, ItemForm> {}
|
|
|
46 |
private static ItemFormUiBinder uiBinder = GWT.create(ItemFormUiBinder.class);
|
| 18048 |
kshitij.so |
47 |
|
| 8901 |
vikram.rag |
48 |
private final static CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
|
|
|
49 |
private final int TABLE_INDEX_VENDORID = 0,
|
|
|
50 |
TABLE_INDEX_VENDOR_DESC = 1,
|
|
|
51 |
TABLE_INDEX_ITEM_KEY = 2,
|
|
|
52 |
TABLE_INDEX_MOP = 2,
|
|
|
53 |
TABLE_INDEX_DP = 3,
|
|
|
54 |
TABLE_INDEX_TP = 4,
|
|
|
55 |
TABLE_INDEX_NLC = 5;
|
| 2119 |
ankur.sing |
56 |
|
| 8901 |
vikram.rag |
57 |
private static boolean entityIdMandatory = Utils.isEntityIdMandatory();
|
| 2105 |
ankur.sing |
58 |
|
| 8901 |
vikram.rag |
59 |
@UiField TextBox productGroup, catalogItemId,existingItemId;
|
|
|
60 |
@UiField TextBox brand, modelNumber, modelName, color, comments,holdInventory,defaultInventory;
|
| 18048 |
kshitij.so |
61 |
@UiField TextBox mrp, sellingPrice, weight, bestDealText, bestDealValue, bestSellingRank,bestDealsDetailsText,bestDealsDetailsLink, minStockLevel, numOfDaysStock, freebieItemId,asin,packQuantity;
|
| 8901 |
vikram.rag |
62 |
@UiField DateBox startDate, retireDate, comingSoonStartDate, expectedArrivalDate;
|
|
|
63 |
@UiField Button addButton, cancelButton, comingSoonButton,searchButton;
|
|
|
64 |
@UiField CheckBox defaultForEntity, risky, itemType, hasItemNo, clearance, showSellingPrice;
|
|
|
65 |
@UiField FlexTable headerVendor, vendorTable;
|
|
|
66 |
@UiField FlexTable headerVendorM, vendorTableM;
|
| 21864 |
ashik.ali |
67 |
@UiField ListBox preferredVendor,preferredInsurer, categories, hsnCode;
|
| 8901 |
vikram.rag |
68 |
|
|
|
69 |
public ItemForm(){
|
|
|
70 |
setText("Add New Item");
|
|
|
71 |
setWidget(uiBinder.createAndBindUi(this));
|
|
|
72 |
initVendorKeysHeader();
|
|
|
73 |
initVendorPricesHeader();
|
|
|
74 |
preferredVendor.addItem("select");
|
|
|
75 |
for(Entry<Long, String> e : Utils.getAllVendors().entrySet()){
|
|
|
76 |
preferredVendor.addItem(e.getValue());
|
|
|
77 |
}
|
|
|
78 |
if(!entityIdMandatory) {
|
|
|
79 |
catalogItemId.setEnabled(false);
|
|
|
80 |
}
|
|
|
81 |
preferredInsurer.addItem("select", "0");
|
|
|
82 |
for(Entry<Long, String> e : Utils.getAllInsurers().entrySet()){
|
|
|
83 |
preferredInsurer.addItem(e.getValue(),e.getKey().toString());
|
|
|
84 |
}
|
| 21864 |
ashik.ali |
85 |
|
|
|
86 |
categories.addItem("select", "0");
|
|
|
87 |
for(Entry<Long, String> e : Utils.getAllCategoriesMap().entrySet()){
|
|
|
88 |
categories.addItem(e.getValue(),e.getKey().toString());
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
//System.out.println("\n\n\nInitial ui ..... \n\n\n");
|
|
|
92 |
//hsnCode.addItem("select");
|
|
|
93 |
categories.addChangeHandler(new ChangeHandler() {
|
|
|
94 |
public void onChange(ChangeEvent arg0) {
|
|
|
95 |
hsnCode.clear();
|
|
|
96 |
int categoryId = Integer.parseInt(categories.getValue(categories.getSelectedIndex()));
|
|
|
97 |
System.out.println("fired onChangeEvent categoryId : "+categoryId);
|
|
|
98 |
catalogService.getHsnCodesByCategoryId(categoryId, new AsyncCallback<List<CategoryHsnCode>>() {
|
|
|
99 |
|
|
|
100 |
public void onFailure(Throwable arg0) {
|
|
|
101 |
arg0.printStackTrace();
|
|
|
102 |
}
|
| 8901 |
vikram.rag |
103 |
|
| 21864 |
ashik.ali |
104 |
public void onSuccess(List<CategoryHsnCode> arg0) {
|
|
|
105 |
for(CategoryHsnCode categoryHsnCode : arg0){
|
|
|
106 |
hsnCode.addItem(categoryHsnCode.getDescription() + " ("+ categoryHsnCode.getHsnCode() + ")", categoryHsnCode.getHsnCode());
|
|
|
107 |
}
|
|
|
108 |
}
|
|
|
109 |
|
|
|
110 |
});
|
|
|
111 |
|
|
|
112 |
}
|
|
|
113 |
|
|
|
114 |
});
|
|
|
115 |
|
| 8901 |
vikram.rag |
116 |
}
|
|
|
117 |
|
|
|
118 |
/**
|
|
|
119 |
* initialises vendor item key table header. Creates an Add button and
|
|
|
120 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
121 |
* a new vendor item key.
|
|
|
122 |
*/
|
|
|
123 |
private void initVendorKeysHeader(){
|
|
|
124 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
|
|
125 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
|
|
126 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "400px");
|
|
|
127 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
|
|
|
128 |
|
|
|
129 |
headerVendorM.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
|
|
|
130 |
headerVendorM.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor");
|
|
|
131 |
headerVendorM.setText(0, TABLE_INDEX_ITEM_KEY, "Item Key");
|
|
|
132 |
|
|
|
133 |
headerVendorM.getCellFormatter().setVisible(0, TABLE_INDEX_VENDORID, false);
|
|
|
134 |
|
|
|
135 |
Button addButton = new Button("Add");
|
|
|
136 |
headerVendorM.setWidget(0, TABLE_INDEX_ITEM_KEY + 1, addButton);
|
|
|
137 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
138 |
@Override
|
|
|
139 |
public void onClick(ClickEvent event) {
|
|
|
140 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
|
|
141 |
modelNumber.getText().trim(), color.getText().trim());
|
|
|
142 |
vendorMappingDialog.updateButton.setText("Add");
|
|
|
143 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
|
|
144 |
@Override
|
|
|
145 |
public boolean onUpdate(String key, long vendorId) {
|
|
|
146 |
final int row = vendorTableM.getRowCount();
|
|
|
147 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
|
|
148 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
|
|
149 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "400px");
|
|
|
150 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
|
|
|
151 |
|
|
|
152 |
vendorTableM.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
|
|
|
153 |
vendorTableM.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
|
|
154 |
vendorTableM.setText(row, TABLE_INDEX_ITEM_KEY, key);
|
|
|
155 |
Button removeButton = new Button("X");
|
|
|
156 |
vendorTableM.setWidget(row, TABLE_INDEX_ITEM_KEY + 1, removeButton);
|
|
|
157 |
|
|
|
158 |
vendorTableM.getCellFormatter().setVisible(row, TABLE_INDEX_VENDORID, false);
|
|
|
159 |
removeButton.addClickHandler(new ClickHandler() {
|
|
|
160 |
@Override
|
|
|
161 |
public void onClick(ClickEvent event) {
|
|
|
162 |
vendorTableM.removeRow(row);
|
|
|
163 |
}
|
|
|
164 |
});
|
|
|
165 |
return true;
|
|
|
166 |
}
|
|
|
167 |
});
|
|
|
168 |
vendorMappingDialog.show();
|
|
|
169 |
}
|
|
|
170 |
});
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
/**
|
|
|
174 |
* initialises vendor prices table header. Creates an Add button and
|
|
|
175 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
176 |
* a prices for a new vendor
|
|
|
177 |
*/
|
|
|
178 |
private void initVendorPricesHeader(){
|
|
|
179 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
|
|
180 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
|
|
181 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
|
|
182 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
|
|
183 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
|
|
184 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_NLC, "128px");
|
|
|
185 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_NLC + 1, "50px");
|
|
|
186 |
|
|
|
187 |
headerVendor.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
|
|
|
188 |
headerVendor.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor");
|
|
|
189 |
headerVendor.setText(0, TABLE_INDEX_MOP, "MOP");
|
|
|
190 |
headerVendor.setText(0, TABLE_INDEX_DP, "Dealer Price");
|
|
|
191 |
headerVendor.setText(0, TABLE_INDEX_TP, "Transfer Price");
|
|
|
192 |
headerVendor.setText(0, TABLE_INDEX_NLC, "NLC");
|
|
|
193 |
|
|
|
194 |
headerVendor.getCellFormatter().setVisible(0, TABLE_INDEX_VENDORID, false);
|
|
|
195 |
|
|
|
196 |
Button addButton = new Button("Add");
|
|
|
197 |
headerVendor.setWidget(0, TABLE_INDEX_NLC + 1, addButton);
|
|
|
198 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
199 |
@Override
|
|
|
200 |
public void onClick(ClickEvent event) {
|
|
|
201 |
VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
|
|
|
202 |
vendorPricesDialog.updateButton.setText("Add");
|
|
|
203 |
vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
|
|
204 |
@Override
|
|
|
205 |
public boolean onUpdate(double mop, double dp, double tp, double nlc, long vendorId) {
|
|
|
206 |
if(!vendorExists(vendorId)) {
|
|
|
207 |
Window.alert("Vendor already exists");
|
|
|
208 |
return false;
|
|
|
209 |
}
|
|
|
210 |
/*if(!validateVendorPrices(mop, dp, tp)) {
|
| 2119 |
ankur.sing |
211 |
return false;
|
|
|
212 |
}*/
|
| 8901 |
vikram.rag |
213 |
final int row = vendorTable.getRowCount();
|
|
|
214 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
|
|
215 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
|
|
216 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
|
|
217 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
|
|
218 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
|
|
219 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_NLC, "128px");
|
|
|
220 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_NLC + 1, "50px");
|
| 2105 |
ankur.sing |
221 |
|
| 8901 |
vikram.rag |
222 |
vendorTable.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
|
|
|
223 |
vendorTable.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
|
|
224 |
vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
|
|
225 |
vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
|
|
|
226 |
vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
|
|
|
227 |
vendorTable.setText(row, TABLE_INDEX_NLC, nlc + "");
|
|
|
228 |
|
|
|
229 |
vendorTable.getCellFormatter().setVisible(row, TABLE_INDEX_VENDORID, false);
|
|
|
230 |
|
|
|
231 |
Button removeButton = new Button("X");
|
|
|
232 |
vendorTable.setWidget(row, TABLE_INDEX_NLC + 1, removeButton);
|
|
|
233 |
removeButton.addClickHandler(new ClickHandler() {
|
|
|
234 |
@Override
|
|
|
235 |
public void onClick(ClickEvent event) {
|
|
|
236 |
vendorTable.removeRow(row);
|
|
|
237 |
}
|
|
|
238 |
});
|
|
|
239 |
return true;
|
|
|
240 |
}
|
|
|
241 |
});
|
|
|
242 |
vendorPricesDialog.show();
|
|
|
243 |
}
|
|
|
244 |
});
|
|
|
245 |
}
|
|
|
246 |
@UiHandler("searchButton")
|
|
|
247 |
/**
|
|
|
248 |
* On search button click the item id is searched if it exists then the attributes of the item id are filled into the item form.
|
|
|
249 |
* Else an alert is displayed showing item id does not exists.
|
|
|
250 |
*/
|
|
|
251 |
void searchItem(ClickEvent event){
|
| 21864 |
ashik.ali |
252 |
hsnCode.clear();
|
| 8901 |
vikram.rag |
253 |
preferredVendor.clear();
|
| 21864 |
ashik.ali |
254 |
preferredInsurer.clear();
|
|
|
255 |
categories.clear();
|
| 8901 |
vikram.rag |
256 |
catalogItemId.setText(null);
|
|
|
257 |
productGroup.setText(null);
|
|
|
258 |
brand.setText(null);
|
|
|
259 |
modelNumber.setText(null);
|
|
|
260 |
modelName.setText(null);
|
|
|
261 |
comments.setText(null);
|
|
|
262 |
mrp.setText(null);
|
|
|
263 |
sellingPrice.setText(null);
|
|
|
264 |
weight.setText(null);
|
|
|
265 |
hasItemNo.setValue(null);
|
|
|
266 |
itemType.setValue(null);
|
|
|
267 |
showSellingPrice.setValue(null);
|
|
|
268 |
startDate.setValue(null);
|
|
|
269 |
this.comingSoonStartDate.setValue(null);
|
|
|
270 |
this.expectedArrivalDate.setValue(null);
|
|
|
271 |
bestDealText.setText(null);
|
|
|
272 |
bestDealsDetailsText.setText(null);
|
|
|
273 |
bestDealsDetailsLink.setText(null);
|
|
|
274 |
bestDealValue.setText(null);
|
|
|
275 |
showSellingPrice.setValue(null);
|
|
|
276 |
bestSellingRank.setText(null);
|
|
|
277 |
minStockLevel.setText(null);
|
|
|
278 |
numOfDaysStock.setText(null);
|
|
|
279 |
defaultForEntity.setValue(null);
|
|
|
280 |
freebieItemId.setText(null);
|
|
|
281 |
asin.setText(null);
|
|
|
282 |
holdInventory.setText(null);
|
|
|
283 |
defaultInventory.setText(null);
|
|
|
284 |
color.setText(null);
|
| 18048 |
kshitij.so |
285 |
vendorTable.removeAllRows();
|
|
|
286 |
packQuantity.setText(null);
|
| 8901 |
vikram.rag |
287 |
if(!existingItemId.getText().trim().isEmpty()){
|
|
|
288 |
long id = Long.parseLong(existingItemId.getText().trim());
|
|
|
289 |
|
|
|
290 |
if(id <= 0) {
|
|
|
291 |
throw new NumberFormatException("Invalid value of Item Id");
|
|
|
292 |
}
|
|
|
293 |
else{
|
|
|
294 |
catalogService.getItem(id, new AsyncCallback<Item>() {
|
|
|
295 |
@Override
|
|
|
296 |
public void onFailure(Throwable caught) {
|
|
|
297 |
Window.alert("Unable to fetch item details.");
|
|
|
298 |
}
|
|
|
299 |
@Override
|
|
|
300 |
public void onSuccess(Item result) {
|
|
|
301 |
if(result !=null){
|
|
|
302 |
fillItemForm(result);
|
|
|
303 |
}
|
|
|
304 |
else{
|
|
|
305 |
Window.alert("Invalid Item Id not found");
|
|
|
306 |
}
|
|
|
307 |
}
|
|
|
308 |
});
|
|
|
309 |
|
|
|
310 |
}
|
|
|
311 |
}
|
|
|
312 |
else{
|
|
|
313 |
Window.alert("Please enter item id");
|
|
|
314 |
GWT.log("Please enter an item id ");
|
|
|
315 |
}
|
|
|
316 |
}
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
/**
|
|
|
320 |
* This method is called if the valid item is returned and it populates the item entries in Item Form.
|
|
|
321 |
*
|
|
|
322 |
*/
|
|
|
323 |
public void fillItemForm(Item item){
|
|
|
324 |
int index = 0;
|
|
|
325 |
preferredVendor.addItem("select");
|
|
|
326 |
if (item.getPreferredVendor() == null) {
|
|
|
327 |
preferredVendor.setSelectedIndex(index);
|
|
|
328 |
}
|
| 2105 |
ankur.sing |
329 |
|
| 8901 |
vikram.rag |
330 |
if((item.getVendorPricesMap() == null || item.getVendorPricesMap().isEmpty())) {
|
|
|
331 |
if(item.getPreferredVendor() != null) {
|
|
|
332 |
index++;
|
|
|
333 |
preferredVendor.addItem(Utils.getVendorDesc(item.getPreferredVendor()));
|
|
|
334 |
}
|
| 4762 |
phani.kuma |
335 |
}
|
|
|
336 |
else {
|
| 8901 |
vikram.rag |
337 |
for(VendorPricings vendorDetail : item.getVendorPricesMap().values()){
|
|
|
338 |
index++;
|
|
|
339 |
preferredVendor.addItem(Utils.getVendorDesc(vendorDetail.getVendorId()));
|
|
|
340 |
if(item.getPreferredVendor() != null && item.getPreferredVendor() == vendorDetail.getVendorId()) {
|
|
|
341 |
preferredVendor.setSelectedIndex(index);
|
|
|
342 |
}
|
|
|
343 |
}
|
|
|
344 |
|
|
|
345 |
if(item.getPreferredVendor() != null && !item.getVendorPricesMap().containsKey(item.getPreferredVendor())){
|
|
|
346 |
index++;
|
|
|
347 |
preferredVendor.addItem(Utils.getVendorDesc(item.getPreferredVendor()));
|
|
|
348 |
preferredVendor.setSelectedIndex(index);
|
|
|
349 |
}
|
| 4762 |
phani.kuma |
350 |
}
|
| 8901 |
vikram.rag |
351 |
index=0;
|
|
|
352 |
preferredInsurer.addItem("select","0");
|
|
|
353 |
preferredInsurer.setSelectedIndex(0);
|
|
|
354 |
for (Map.Entry<Long, String> entry : Utils.getAllInsurers().entrySet()){
|
|
|
355 |
index++;
|
|
|
356 |
preferredInsurer.addItem(entry.getValue(),entry.getKey().toString());
|
|
|
357 |
if(item.getPreferredInsurer()==entry.getKey()){
|
|
|
358 |
preferredInsurer.setSelectedIndex(index);
|
|
|
359 |
}
|
| 4762 |
phani.kuma |
360 |
}
|
| 21864 |
ashik.ali |
361 |
index = 0;
|
|
|
362 |
categories.addItem("select", "0");
|
|
|
363 |
categories.setSelectedIndex(0);
|
|
|
364 |
for(Map.Entry<Long, String> entry : Utils.getAllCategoriesMap().entrySet()){
|
|
|
365 |
index ++;
|
|
|
366 |
categories.addItem(entry.getValue(), entry.getKey().toString());
|
|
|
367 |
if(item.getCategoryItemId() == entry.getKey()){
|
|
|
368 |
categories.setSelectedIndex(index);
|
|
|
369 |
}
|
|
|
370 |
}
|
|
|
371 |
|
|
|
372 |
|
| 8901 |
vikram.rag |
373 |
catalogItemId.setText(Long.toString(item.getCatalogItemId()));
|
|
|
374 |
productGroup.setText(item.getProductGroup());
|
|
|
375 |
brand.setText(item.getBrand());
|
|
|
376 |
modelNumber.setText(item.getModelNumber());
|
|
|
377 |
modelName.setText(item.getModelName());
|
|
|
378 |
comments.setText(item.getComments());
|
|
|
379 |
mrp.setText(item.getMrp() != null ? item.getMrp()+"" : "");
|
| 18048 |
kshitij.so |
380 |
packQuantity.setText(item.getPackQuantity().toString());
|
| 8901 |
vikram.rag |
381 |
sellingPrice.setText(item.getSellingPrice() != null ? item.getSellingPrice()+"" : "");
|
|
|
382 |
weight.setText(item.getWeight() != null ? item.getWeight()+"" : "");
|
|
|
383 |
hasItemNo.setValue(item.isHasItemNo());
|
|
|
384 |
itemType.setValue(item.isItemType());
|
|
|
385 |
showSellingPrice.setValue(item.isShowSellingPrice());
|
|
|
386 |
startDate.setValue(new Date(item.getStartDate()));
|
|
|
387 |
if(item.getComingSoonStartDate() != null){
|
|
|
388 |
this.comingSoonStartDate.setValue(new Date(item.getComingSoonStartDate()));
|
|
|
389 |
}else {
|
|
|
390 |
this.comingSoonStartDate.setValue(null);
|
|
|
391 |
}
|
|
|
392 |
if(item.getExpectedArrivalDate() != null){
|
|
|
393 |
this.expectedArrivalDate.setValue(new Date(item.getExpectedArrivalDate()));
|
|
|
394 |
}else {
|
|
|
395 |
this.expectedArrivalDate.setValue(null);
|
|
|
396 |
}
|
|
|
397 |
bestDealText.setText(item.getBestDealsText());
|
|
|
398 |
bestDealsDetailsText.setText(item.getBestDealsDetailsText());
|
|
|
399 |
bestDealsDetailsLink.setText(item.getBestDealsDetailsLink());
|
|
|
400 |
bestDealValue.setText(item.getBestDealsValue() != null ? item.getBestDealsValue()+"" : "");
|
|
|
401 |
showSellingPrice.setValue(item.isShowSellingPrice());
|
|
|
402 |
bestSellingRank.setText(item.getBestSellingRank() != null ? item.getBestSellingRank()+"" : "");
|
|
|
403 |
minStockLevel.setText(item.getMinStockLevel() != null ? item.getMinStockLevel()+"" : "");
|
|
|
404 |
numOfDaysStock.setText(item.getNumOfDaysStock() != null ? item.getNumOfDaysStock()+"" : "");
|
|
|
405 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
|
|
406 |
freebieItemId.setText(item.getFreebieItemId().toString());
|
|
|
407 |
holdInventory.setText(Long.toString(item.getHoldInventory()));
|
|
|
408 |
defaultInventory.setText(Long.toString(item.getDefaultInventory()));
|
|
|
409 |
Map<Long, VendorPricings> map = item.getVendorPricesMap();
|
|
|
410 |
for (Map.Entry<Long, VendorPricings> vendorItem : map.entrySet()) {
|
|
|
411 |
final int row = vendorTable.getRowCount();
|
|
|
412 |
long vendorId = vendorItem.getKey();
|
|
|
413 |
double mop = vendorItem.getValue().getMop();
|
|
|
414 |
double dp = vendorItem.getValue().getDealerPrice();
|
|
|
415 |
double tp = vendorItem.getValue().getTransferPrice();
|
|
|
416 |
double nlc = vendorItem.getValue().getNlc();
|
|
|
417 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
|
|
418 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
|
|
419 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
|
|
420 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
|
|
421 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
|
|
422 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_NLC, "128px");
|
|
|
423 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_NLC + 1, "50px");
|
|
|
424 |
vendorTable.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
|
|
|
425 |
vendorTable.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
|
|
426 |
vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
|
|
427 |
vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
|
|
|
428 |
vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
|
|
|
429 |
vendorTable.setText(row, TABLE_INDEX_NLC, nlc + "");
|
|
|
430 |
vendorTable.getCellFormatter().setVisible(row, TABLE_INDEX_VENDORID, false);
|
|
|
431 |
Button removeButton = new Button("X");
|
|
|
432 |
vendorTable.setWidget(row, TABLE_INDEX_NLC + 1, removeButton);
|
|
|
433 |
removeButton.addClickHandler(new ClickHandler() {
|
|
|
434 |
@Override
|
|
|
435 |
public void onClick(ClickEvent event) {
|
|
|
436 |
vendorTable.removeRow(row);
|
|
|
437 |
}
|
|
|
438 |
});
|
|
|
439 |
}
|
|
|
440 |
}
|
|
|
441 |
|
|
|
442 |
|
|
|
443 |
@UiHandler("addButton")
|
|
|
444 |
/**
|
|
|
445 |
* On add button click a new Item instance is created and all the information from UI fields is dumped in this item instance.
|
|
|
446 |
* This item instance is then passed to the service to be added to the database.
|
|
|
447 |
*/
|
|
|
448 |
void addItem(ClickEvent event) {
|
|
|
449 |
if(entityIdMandatory) {
|
|
|
450 |
long entityId = 0;
|
|
|
451 |
try {
|
|
|
452 |
if(!catalogItemId.getText().trim().isEmpty()) {
|
|
|
453 |
entityId = Long.parseLong(catalogItemId.getText().trim());
|
|
|
454 |
if(entityId <= 0) {
|
|
|
455 |
throw new NumberFormatException("Invalid value of Catalog Item Id");
|
|
|
456 |
}
|
|
|
457 |
}
|
|
|
458 |
else {
|
|
|
459 |
Window.alert("Catalog Item Id can not be empty");
|
|
|
460 |
return;
|
|
|
461 |
}
|
|
|
462 |
} catch(NumberFormatException ex) {
|
|
|
463 |
Window.alert("Invalid value of Catalog Item Id");
|
|
|
464 |
return;
|
|
|
465 |
}
|
|
|
466 |
catalogService.checkEntityId(entityId, new AsyncCallback<Boolean>() {
|
|
|
467 |
@Override
|
|
|
468 |
public void onFailure(Throwable caught) {
|
|
|
469 |
GWT.log("Error checking Catalog Item Id");
|
|
|
470 |
Window.alert("Error checking Catalog Item Id");
|
|
|
471 |
return;
|
|
|
472 |
}
|
|
|
473 |
@Override
|
|
|
474 |
public void onSuccess(Boolean result) {
|
|
|
475 |
if(!result) {
|
|
|
476 |
Window.alert("Invalid value of Catalog Item Id");
|
|
|
477 |
return;
|
|
|
478 |
}
|
|
|
479 |
addNewItem();
|
|
|
480 |
}
|
|
|
481 |
});
|
|
|
482 |
}
|
|
|
483 |
else {
|
|
|
484 |
catalogService.checkSimilarItem(brand.getText().trim(), modelNumber.getText().trim(),
|
|
|
485 |
modelName.getText().trim(), color.getText().trim(), new AsyncCallback<Long>() {
|
|
|
486 |
@Override
|
|
|
487 |
public void onFailure(Throwable caught) {
|
|
|
488 |
GWT.log("Error checking similar item");
|
|
|
489 |
Window.alert("Error checking similar item");
|
|
|
490 |
return;
|
|
|
491 |
}
|
|
|
492 |
@Override
|
|
|
493 |
public void onSuccess(Long result) {
|
|
|
494 |
if(result != 0) {
|
|
|
495 |
Window.alert("Similar product exists with Item Id " + result);
|
|
|
496 |
return;
|
|
|
497 |
}
|
|
|
498 |
addNewItem();
|
|
|
499 |
}
|
|
|
500 |
});
|
|
|
501 |
}
|
|
|
502 |
}
|
|
|
503 |
|
|
|
504 |
private void addNewItem() {
|
|
|
505 |
Item item = new Item();
|
|
|
506 |
if(!productGroup.getText().trim().isEmpty()) {
|
|
|
507 |
item.setProductGroup(productGroup.getText().trim());
|
|
|
508 |
}
|
|
|
509 |
else {
|
|
|
510 |
Window.alert("Product Group can not be empty.");
|
|
|
511 |
return;
|
|
|
512 |
}
|
|
|
513 |
|
|
|
514 |
if(entityIdMandatory) {
|
|
|
515 |
try {
|
|
|
516 |
if(!catalogItemId.getText().trim().isEmpty()) {
|
|
|
517 |
long entityId = Long.parseLong(catalogItemId.getText().trim());
|
|
|
518 |
if(entityId <= 0) {
|
|
|
519 |
throw new NumberFormatException("Invalid value of Catalog Item Id");
|
|
|
520 |
}
|
|
|
521 |
item.setCatalogItemId(entityId);
|
|
|
522 |
}
|
|
|
523 |
else {
|
|
|
524 |
Window.alert("Catalog Item Id can not be empty");
|
|
|
525 |
return;
|
|
|
526 |
}
|
|
|
527 |
} catch(NumberFormatException ex) {
|
|
|
528 |
Window.alert("Invalid value of Catalog Item Id");
|
|
|
529 |
return;
|
|
|
530 |
}
|
|
|
531 |
}
|
|
|
532 |
item.setBrand(brand.getText().trim());
|
|
|
533 |
item.setModelNumber(modelNumber.getText().trim());
|
|
|
534 |
item.setModelName(modelName.getText().trim());
|
|
|
535 |
item.setColor(color.getText().trim());
|
|
|
536 |
item.setComments(comments.getText().trim());
|
|
|
537 |
try {
|
|
|
538 |
if(!mrp.getText().trim().isEmpty()) {
|
|
|
539 |
double mrpValue = Double.parseDouble(mrp.getText().trim());
|
|
|
540 |
if(mrpValue <= 0) {
|
|
|
541 |
throw new NumberFormatException("Negative value of MRP");
|
|
|
542 |
}
|
|
|
543 |
item.setMrp(mrpValue);
|
|
|
544 |
}
|
|
|
545 |
} catch(NumberFormatException ex) {
|
|
|
546 |
Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
|
|
|
547 |
return;
|
|
|
548 |
}
|
|
|
549 |
try {
|
|
|
550 |
if(!sellingPrice.getText().trim().isEmpty()) {
|
|
|
551 |
double spValue = Double.parseDouble(sellingPrice.getText().trim());
|
|
|
552 |
if(spValue <= 0) {
|
|
|
553 |
throw new NumberFormatException("Negative value of Selling price");
|
|
|
554 |
}
|
|
|
555 |
item.setSellingPrice(spValue);
|
|
|
556 |
}
|
|
|
557 |
} catch(NumberFormatException ex) {
|
|
|
558 |
Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
|
|
|
559 |
return;
|
|
|
560 |
}
|
|
|
561 |
try {
|
|
|
562 |
if(!weight.getText().trim().isEmpty()) {
|
|
|
563 |
double wtValue = Double.parseDouble(weight.getText().trim());
|
|
|
564 |
if(wtValue <= 0) {
|
|
|
565 |
throw new NumberFormatException("Negative value of Weight");
|
|
|
566 |
}
|
|
|
567 |
item.setWeight(wtValue);
|
|
|
568 |
}
|
|
|
569 |
} catch(NumberFormatException ex) {
|
|
|
570 |
Window.alert("Invalid weight format/value. Value shoule be greater than zero");
|
|
|
571 |
return;
|
|
|
572 |
}
|
|
|
573 |
try {
|
| 18048 |
kshitij.so |
574 |
if(!packQuantity.getText().trim().isEmpty()) {
|
|
|
575 |
long packQuantityValue = Long.parseLong(packQuantity.getText().trim());
|
|
|
576 |
if(packQuantityValue < 1) {
|
|
|
577 |
throw new NumberFormatException("Illegal value of PackQuantity");
|
|
|
578 |
}
|
|
|
579 |
item.setPackQuantity(packQuantityValue);
|
|
|
580 |
}
|
|
|
581 |
else{
|
|
|
582 |
Window.alert("Invalid PackQuantity format/value. Value should can't be empty");
|
|
|
583 |
return;
|
|
|
584 |
}
|
|
|
585 |
} catch(NumberFormatException ex) {
|
|
|
586 |
Window.alert("Invalid PackQuantity format/value. Value should be greater than zero");
|
|
|
587 |
return;
|
|
|
588 |
}
|
|
|
589 |
try {
|
| 8901 |
vikram.rag |
590 |
if(!startDate.getTextBox().getText().trim().equals("")) {
|
|
|
591 |
item.setStartDate(startDate.getValue().getTime());
|
|
|
592 |
}
|
|
|
593 |
} catch(Exception ex) {
|
|
|
594 |
Window.alert("Invalid start date format");
|
|
|
595 |
return;
|
|
|
596 |
}
|
|
|
597 |
if(comingSoonStartDate.getValue()==null){
|
|
|
598 |
item.setComingSoonStartDate(null);
|
|
|
599 |
}else {
|
|
|
600 |
item.setComingSoonStartDate(comingSoonStartDate.getValue().getTime());
|
|
|
601 |
}
|
|
|
602 |
if(expectedArrivalDate.getValue()==null){
|
|
|
603 |
item.setExpectedArrivalDate(null);
|
|
|
604 |
}else {
|
|
|
605 |
item.setExpectedArrivalDate(expectedArrivalDate.getValue().getTime());
|
|
|
606 |
}
|
|
|
607 |
item.setBestDealsText(bestDealText.getText().trim());
|
|
|
608 |
item.setBestDealsDetailsText(bestDealsDetailsText.getText().trim());
|
|
|
609 |
item.setBestDealsDetailsLink(bestDealsDetailsLink.getText().trim());
|
|
|
610 |
try {
|
|
|
611 |
if(!bestDealValue.getText().trim().equals("")) {
|
|
|
612 |
double bdValue = Double.parseDouble(bestDealValue.getText().trim());
|
|
|
613 |
if(bdValue < 0) {
|
|
|
614 |
throw new NumberFormatException("Negative value of BestDealValue");
|
|
|
615 |
}
|
|
|
616 |
item.setBestDealsValue(bdValue);
|
|
|
617 |
}
|
|
|
618 |
} catch(NumberFormatException ex) {
|
|
|
619 |
Window.alert("Invalid best deal value format");
|
|
|
620 |
return;
|
|
|
621 |
}
|
|
|
622 |
try {
|
|
|
623 |
if(!bestSellingRank.getText().trim().equals("")) {
|
|
|
624 |
long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
|
|
|
625 |
if(bsrValue < 0) {
|
|
|
626 |
throw new NumberFormatException("Negative value of Best Selling Rank");
|
|
|
627 |
}
|
|
|
628 |
item.setBestSellingRank(bsrValue);
|
|
|
629 |
}
|
|
|
630 |
} catch(NumberFormatException ex) {
|
|
|
631 |
Window.alert("Invalid best selling rank format");
|
|
|
632 |
return;
|
|
|
633 |
}
|
|
|
634 |
|
|
|
635 |
try {
|
|
|
636 |
if(!minStockLevel.getText().trim().equals("")) {
|
|
|
637 |
long msl = Long.parseLong(minStockLevel.getText().trim());
|
|
|
638 |
if(msl < 0) {
|
|
|
639 |
throw new NumberFormatException("Negative value of Min Stock Value");
|
|
|
640 |
}
|
|
|
641 |
item.setMinStockLevel(msl);
|
|
|
642 |
}else {
|
|
|
643 |
item.setMinStockLevel(0L);
|
|
|
644 |
}
|
|
|
645 |
} catch(NumberFormatException ex) {
|
|
|
646 |
item.setMinStockLevel(0L);
|
|
|
647 |
Window.alert("Invalid min Stock Level. Setting it to zero(0)");
|
|
|
648 |
return;
|
|
|
649 |
}
|
|
|
650 |
|
|
|
651 |
try {
|
|
|
652 |
if(!numOfDaysStock.getText().trim().equals("")) {
|
|
|
653 |
Long nds = Long.parseLong(numOfDaysStock.getText().trim());
|
|
|
654 |
if(nds < 0) {
|
|
|
655 |
throw new NumberFormatException("Negative value of Num of Days Of Stock");
|
|
|
656 |
}
|
|
|
657 |
item.setNumOfDaysStock(nds.intValue());
|
|
|
658 |
} else {
|
|
|
659 |
item.setNumOfDaysStock(0);
|
|
|
660 |
}
|
|
|
661 |
} catch(NumberFormatException ex) {
|
|
|
662 |
item.setNumOfDaysStock(0);
|
|
|
663 |
Window.alert("Invalid min Stock Level. Setting it to zero(0)");
|
|
|
664 |
return;
|
|
|
665 |
}
|
|
|
666 |
|
|
|
667 |
try {
|
|
|
668 |
if(!freebieItemId.getText().trim().equals("")) {
|
|
|
669 |
long freeItemId = Long.parseLong(freebieItemId.getText().trim());
|
|
|
670 |
if(freeItemId < 0) {
|
|
|
671 |
throw new NumberFormatException("Negative value of freebieItemId ");
|
|
|
672 |
}
|
|
|
673 |
item.setFreebieItemId(new Long(freeItemId));
|
|
|
674 |
}
|
|
|
675 |
} catch(NumberFormatException ex) {
|
|
|
676 |
Window.alert("Invalid freebie ItemId");
|
|
|
677 |
return;
|
|
|
678 |
}
|
|
|
679 |
item.setAsin(asin.getText().trim());
|
|
|
680 |
|
|
|
681 |
try {
|
|
|
682 |
if(!holdInventory.getText().trim().equals("")) {
|
|
|
683 |
long hold_inventory = Long.parseLong(holdInventory.getText().trim());
|
|
|
684 |
if(hold_inventory < 0) {
|
|
|
685 |
throw new NumberFormatException("Negative value of Hold Inventory");
|
|
|
686 |
}
|
|
|
687 |
item.setHoldInventory(hold_inventory);
|
|
|
688 |
}
|
|
|
689 |
} catch(NumberFormatException ex) {
|
|
|
690 |
Window.alert("Invalid Hold Inventory Value");
|
|
|
691 |
return;
|
|
|
692 |
}
|
|
|
693 |
|
|
|
694 |
try {
|
|
|
695 |
if(!defaultInventory.getText().trim().equals("")) {
|
|
|
696 |
long default_inventory = Long.parseLong(defaultInventory.getText().trim());
|
|
|
697 |
if(default_inventory < 0) {
|
|
|
698 |
throw new NumberFormatException("Negative value of Default Inventory");
|
|
|
699 |
}
|
|
|
700 |
item.setDefaultInventory(default_inventory);
|
|
|
701 |
}
|
|
|
702 |
} catch(NumberFormatException ex) {
|
|
|
703 |
Window.alert("Invalid Default Inventory Value");
|
|
|
704 |
return;
|
|
|
705 |
}
|
|
|
706 |
item.setDefaultForEntity(defaultForEntity.getValue());
|
|
|
707 |
item.setRisky(risky.getValue());
|
|
|
708 |
item.setHasItemNo(hasItemNo.getValue());
|
|
|
709 |
item.setItemType(itemType.getValue());
|
|
|
710 |
if(preferredVendor.getSelectedIndex() == 0) {
|
|
|
711 |
Window.alert("Invalid Vendor Selected");
|
|
|
712 |
return;
|
|
|
713 |
}
|
|
|
714 |
else {
|
|
|
715 |
item.setPreferredVendor(Utils.getVendorId(preferredVendor.getItemText(preferredVendor.getSelectedIndex())));
|
|
|
716 |
}
|
|
|
717 |
item.setPreferredInsurer(Long.parseLong(preferredInsurer.getValue(preferredInsurer.getSelectedIndex())));
|
| 21864 |
ashik.ali |
718 |
//item.setCategoryItemId(Integer.parseInt(categories.getValue(categories.getSelectedIndex())));
|
|
|
719 |
item.setHsnCode(hsnCode.getValue(hsnCode.getSelectedIndex()));
|
| 8901 |
vikram.rag |
720 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
| 2105 |
ankur.sing |
721 |
Add the instance to map and set the map to the item instance created above.*/
|
| 8901 |
vikram.rag |
722 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
|
|
723 |
VendorPricings v;
|
|
|
724 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
|
|
725 |
v = new VendorPricings();
|
|
|
726 |
v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP)));
|
|
|
727 |
v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP)));
|
|
|
728 |
v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP)));
|
|
|
729 |
v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID)));
|
|
|
730 |
v.setNlc(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_NLC)));
|
|
|
731 |
vendorPrices.put(v.getVendorId(), v);
|
|
|
732 |
}
|
|
|
733 |
item.setVendorPricesMap(vendorPrices);
|
|
|
734 |
|
|
|
735 |
/*Create an instance of VendorKeys for each row in vendor pricing table. Set the vendor prices to the instance.
|
| 2119 |
ankur.sing |
736 |
Add the instance to map and set the map to the item instance created above.*/
|
| 8901 |
vikram.rag |
737 |
Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
|
|
|
738 |
VendorItemMapping vMapping;
|
|
|
739 |
for(int row = 0; row < vendorTableM.getRowCount(); row++) {
|
|
|
740 |
vMapping = new VendorItemMapping();
|
|
|
741 |
vMapping.setItemKey(vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY));
|
|
|
742 |
vMapping.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID)));
|
|
|
743 |
vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + vMapping.getItemKey(), vMapping);
|
|
|
744 |
}
|
|
|
745 |
item.setVendorKeysMap(vendorMappings);
|
|
|
746 |
if(!Utils.validateItem(item)) {
|
|
|
747 |
return;
|
|
|
748 |
}
|
| 2427 |
ankur.sing |
749 |
|
| 8901 |
vikram.rag |
750 |
/*Service method to add item. */
|
|
|
751 |
catalogService.addItem(item, new AsyncCallback<Long>() {
|
|
|
752 |
@Override
|
|
|
753 |
public void onSuccess(Long result) {
|
|
|
754 |
if(result == null || result == 0) {
|
|
|
755 |
Window.alert("Error while adding item");
|
|
|
756 |
return;
|
|
|
757 |
}
|
|
|
758 |
Window.alert("Item added successfully. Id = " + result);
|
|
|
759 |
hide();
|
|
|
760 |
}
|
|
|
761 |
@Override
|
|
|
762 |
public void onFailure(Throwable caught) {
|
|
|
763 |
caught.printStackTrace();
|
|
|
764 |
Window.alert("Error while adding item");
|
|
|
765 |
}
|
|
|
766 |
});
|
|
|
767 |
}
|
|
|
768 |
|
|
|
769 |
@UiHandler("cancelButton")
|
|
|
770 |
void closeForm(ClickEvent event) {
|
|
|
771 |
this.hide();
|
|
|
772 |
}
|
|
|
773 |
|
|
|
774 |
/**
|
|
|
775 |
* Checks if vendor details already exists corresponding to the vendor Id parameter.
|
|
|
776 |
*/
|
|
|
777 |
private boolean vendorExists(long vendorId) {
|
|
|
778 |
long id;
|
|
|
779 |
for(int i = 0; i < vendorTable.getRowCount(); i++) {
|
|
|
780 |
id = Long.parseLong(vendorTable.getText(i, TABLE_INDEX_VENDORID));
|
|
|
781 |
if(vendorId == id) {
|
|
|
782 |
return false;
|
|
|
783 |
}
|
|
|
784 |
}
|
|
|
785 |
return true;
|
|
|
786 |
}
|
|
|
787 |
|
|
|
788 |
/**
|
|
|
789 |
* validate vendor prices (MOP, DealerPrice, TransferPrice)
|
|
|
790 |
*/
|
|
|
791 |
@SuppressWarnings("unused")
|
| 2566 |
chandransh |
792 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
| 8901 |
vikram.rag |
793 |
double mrpValue;
|
|
|
794 |
try {
|
|
|
795 |
mrpValue = Double.parseDouble(mrp.getText().trim());
|
|
|
796 |
} catch (NumberFormatException ex) {
|
|
|
797 |
Window.alert("Invalid MRP value.");
|
|
|
798 |
return false;
|
|
|
799 |
}
|
|
|
800 |
if(mrpValue < mop) {
|
|
|
801 |
Window.alert("MOP cannot be more than MRP.");
|
|
|
802 |
return false;
|
|
|
803 |
}
|
| 18457 |
kshitij.so |
804 |
// if(tp > mop) {
|
|
|
805 |
// Window.alert("Transfer Price cannot be more than MOP.");
|
|
|
806 |
// return false;
|
|
|
807 |
// }
|
| 8901 |
vikram.rag |
808 |
return true;
|
|
|
809 |
}
|
|
|
810 |
|
| 5217 |
amit.gupta |
811 |
@UiHandler("comingSoonButton")
|
|
|
812 |
void onComingSoonButtonClick(ClickEvent event) {
|
|
|
813 |
ComingSoonDialog cd = new ComingSoonDialog(this);
|
|
|
814 |
cd.show();
|
|
|
815 |
}
|
|
|
816 |
|
|
|
817 |
public void setComingSoonStartDate(Date date){
|
|
|
818 |
this.comingSoonStartDate.setValue(date);
|
|
|
819 |
}
|
|
|
820 |
public void setBestDealsText(String bestDealsText){
|
|
|
821 |
this.bestDealText.setText(bestDealsText);
|
|
|
822 |
}
|
|
|
823 |
|
|
|
824 |
public void setExpectedArrivalDate(Date date){
|
|
|
825 |
this.expectedArrivalDate.setValue(date);
|
|
|
826 |
}
|
|
|
827 |
|
| 6241 |
amit.gupta |
828 |
public void setShowPrice(boolean b){
|
|
|
829 |
this.showSellingPrice.setValue(b);
|
|
|
830 |
}
|
|
|
831 |
|
|
|
832 |
public boolean isShowPrice(){
|
|
|
833 |
return this.showSellingPrice.getValue();
|
|
|
834 |
}
|
|
|
835 |
|
| 5217 |
amit.gupta |
836 |
@Override
|
|
|
837 |
public String getBestDealsText() {
|
|
|
838 |
return this.bestDealText.getValue();
|
|
|
839 |
}
|
|
|
840 |
|
|
|
841 |
@Override
|
|
|
842 |
public Date getComingSoonStartDate() {
|
|
|
843 |
return this.comingSoonStartDate.getValue();
|
|
|
844 |
}
|
|
|
845 |
|
|
|
846 |
@Override
|
|
|
847 |
public Date getExpectedArrivalDate() {
|
| 6241 |
amit.gupta |
848 |
return this.expectedArrivalDate.getValue();
|
| 5217 |
amit.gupta |
849 |
}
|
| 6777 |
vikram.rag |
850 |
|
|
|
851 |
public TextBox getBestDealsDetailsText() {
|
|
|
852 |
return bestDealsDetailsText;
|
|
|
853 |
}
|
|
|
854 |
|
|
|
855 |
public void setBestDealsDetailsText(TextBox bestDealsDetailsText) {
|
|
|
856 |
this.bestDealsDetailsText = bestDealsDetailsText;
|
|
|
857 |
}
|
|
|
858 |
|
|
|
859 |
public TextBox getBestDealsDetailsLink() {
|
|
|
860 |
return bestDealsDetailsLink;
|
|
|
861 |
}
|
|
|
862 |
|
|
|
863 |
public void setBestDealsDetailsLink(TextBox bestDealsDetailsLink) {
|
|
|
864 |
this.bestDealsDetailsLink = bestDealsDetailsLink;
|
|
|
865 |
}
|
| 2066 |
ankur.sing |
866 |
}
|