| Line 16... |
Line 16... |
| 16 |
import com.google.gwt.resources.client.CssResource;
|
16 |
import com.google.gwt.resources.client.CssResource;
|
| 17 |
import com.google.gwt.uibinder.client.UiBinder;
|
17 |
import com.google.gwt.uibinder.client.UiBinder;
|
| 18 |
import com.google.gwt.uibinder.client.UiField;
|
18 |
import com.google.gwt.uibinder.client.UiField;
|
| 19 |
import com.google.gwt.uibinder.client.UiHandler;
|
19 |
import com.google.gwt.uibinder.client.UiHandler;
|
| 20 |
import com.google.gwt.user.client.Window;
|
20 |
import com.google.gwt.user.client.Window;
|
| - |
|
21 |
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.Button;
|
| 22 |
import com.google.gwt.user.client.ui.CheckBox;
|
23 |
import com.google.gwt.user.client.ui.CheckBox;
|
| 23 |
import com.google.gwt.user.client.ui.FlexTable;
|
24 |
import com.google.gwt.user.client.ui.FlexTable;
|
| 24 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
25 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
| 25 |
import com.google.gwt.user.client.ui.Label;
|
26 |
import com.google.gwt.user.client.ui.Label;
|
| Line 40... |
Line 41... |
| 40 |
TABLE_INDEX_WAREHOUSE_DESC = 1,
|
41 |
TABLE_INDEX_WAREHOUSE_DESC = 1,
|
| 41 |
TABLE_INDEX_WAREHOUSE_INV = 2;
|
42 |
TABLE_INDEX_WAREHOUSE_INV = 2;
|
| 42 |
|
43 |
|
| 43 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
44 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
| 44 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
45 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
| - |
|
46 |
private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
|
| 45 |
|
47 |
|
| 46 |
public interface ItemUpdateListener {
|
- |
|
| 47 |
void onItemUpdate(Item item);
|
- |
|
| 48 |
}
|
- |
|
| 49 |
|
48 |
|
| 50 |
interface ItemDetailStyle extends CssResource{
|
49 |
interface ItemDetailStyle extends CssResource{
|
| 51 |
String greenLabel();
|
50 |
String greenLabel();
|
| 52 |
String fieldChanged();
|
51 |
String fieldChanged();
|
| 53 |
}
|
52 |
}
|
| 54 |
|
53 |
|
| 55 |
private ItemUpdateListener itemUpdateListener;
|
- |
|
| 56 |
|
- |
|
| 57 |
private Item item, newItem;
|
54 |
private Item item, newItem;
|
| 58 |
|
55 |
|
| 59 |
@UiField ItemDetailStyle style;
|
56 |
@UiField ItemDetailStyle style;
|
| 60 |
@UiField Label itemId;
|
57 |
@UiField Label itemId;
|
| 61 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
58 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
| Line 68... |
Line 65... |
| 68 |
@UiField FlexTable headerAvailability, availabilityTable;
|
65 |
@UiField FlexTable headerAvailability, availabilityTable;
|
| 69 |
@UiField FlexTable headerVendorM, vendorTableM;
|
66 |
@UiField FlexTable headerVendorM, vendorTableM;
|
| 70 |
@UiField FlexTable headerVendor, vendorTable;
|
67 |
@UiField FlexTable headerVendor, vendorTable;
|
| 71 |
@UiField TextBox bestSellingRank;
|
68 |
@UiField TextBox bestSellingRank;
|
| 72 |
@UiField CheckBox defaultForEntity;
|
69 |
@UiField CheckBox defaultForEntity;
|
| 73 |
@UiField Button submit;
|
70 |
//@UiField Button submit;
|
| 74 |
@UiField DateBox startDate;
|
71 |
@UiField DateBox startDate;
|
| 75 |
|
72 |
|
| 76 |
public ItemDetails(Item item){
|
73 |
public ItemDetails(Item item){
|
| 77 |
this();
|
74 |
this();
|
| 78 |
setItemDetails(item);
|
75 |
setItemDetails(item);
|
| Line 99... |
Line 96... |
| 99 |
|
96 |
|
| 100 |
contentCategory.setText(item.getContentCategory()+"");
|
97 |
contentCategory.setText(item.getContentCategory()+"");
|
| 101 |
comments.setText(item.getComments());
|
98 |
comments.setText(item.getComments());
|
| 102 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
99 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
| 103 |
|
100 |
|
| 104 |
mrp.setText(item.getMrp()+"");
|
101 |
mrp.setText(item.getMrp() != -1 ? item.getMrp()+"" : "");
|
| 105 |
sellingPrice.setText(item.getSellingPrice()+"");
|
102 |
sellingPrice.setText(item.getSellingPrice() != -1 ? item.getSellingPrice()+"" : "");
|
| 106 |
weight.setText(item.getWeight()+"");
|
103 |
weight.setText(item.getWeight() != 1 ? item.getWeight()+"" : "");
|
| 107 |
|
104 |
|
| 108 |
startDate.setValue(new Date(item.getStartDate()));
|
105 |
startDate.setValue(new Date(item.getStartDate()));
|
| 109 |
|
- |
|
| 110 |
addedOn.setText(Utils.getDisplayableDate(item.getAddedOn()));
|
106 |
addedOn.setText(Utils.getDisplayableDate(item.getAddedOn()));
|
| 111 |
retireDate.setText(Utils.getDisplayableDate(item.getRetireDate()));
|
107 |
retireDate.setText(Utils.getDisplayableDate(item.getRetireDate()));
|
| 112 |
updatedOn.setText(Utils.getDisplayableDate(item.getUpdatedOn()));
|
108 |
updatedOn.setText(Utils.getDisplayableDate(item.getUpdatedOn()));
|
| 113 |
|
109 |
|
| 114 |
bestDealsText.setText(item.getBestDealsText());
|
110 |
bestDealsText.setText(item.getBestDealsText());
|
| 115 |
bestDealsValue.setText(item.getBestDealsValue()+"");
|
111 |
bestDealsValue.setText(item.getBestDealsValue() != -1 ? item.getBestDealsValue()+"" : "");
|
| 116 |
|
- |
|
| 117 |
bestSellingRank.setText(item.getBestSellingRank()+"");
|
112 |
bestSellingRank.setText(item.getBestSellingRank() != -1 ? item.getBestSellingRank()+"" : "");
|
| 118 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
113 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
| 119 |
|
114 |
|
| 120 |
itemStatus.setText(item.getItemStatus());
|
115 |
itemStatus.setText(item.getItemStatus());
|
| 121 |
|
116 |
|
| 122 |
updateAvailabilityTable(item.getAvailability());
|
117 |
updateAvailabilityTable(item.getAvailability());
|
| Line 150... |
Line 145... |
| 150 |
Button addButton = new Button("Add");
|
145 |
Button addButton = new Button("Add");
|
| 151 |
headerVendorM.setWidget(0, TABLE_INDEX_ITEM_KEY + 1, addButton);
|
146 |
headerVendorM.setWidget(0, TABLE_INDEX_ITEM_KEY + 1, addButton);
|
| 152 |
addButton.addClickHandler(new ClickHandler() {
|
147 |
addButton.addClickHandler(new ClickHandler() {
|
| 153 |
@Override
|
148 |
@Override
|
| 154 |
public void onClick(ClickEvent event) {
|
149 |
public void onClick(ClickEvent event) {
|
| 155 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog();
|
150 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
| - |
|
151 |
modelNumber.getText().trim(), color.getText().trim());
|
| 156 |
vendorMappingDialog.updateButton.setText("Add");
|
152 |
vendorMappingDialog.updateButton.setText("Add");
|
| 157 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
153 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
| 158 |
@Override
|
154 |
@Override
|
| 159 |
public boolean onUpdate(String key, long vendorId) {
|
155 |
public boolean onUpdate(String key, long vendorId) {
|
| 160 |
int row = vendorTableM.getRowCount();
|
156 |
int row = vendorTableM.getRowCount();
|
| Line 312... |
Line 308... |
| 312 |
}
|
308 |
}
|
| 313 |
});
|
309 |
});
|
| 314 |
}
|
310 |
}
|
| 315 |
}
|
311 |
}
|
| 316 |
|
312 |
|
| 317 |
public void setItemUpdateListener(ItemUpdateListener itemUpdatelistener) {
|
- |
|
| 318 |
this.itemUpdateListener = itemUpdatelistener;
|
- |
|
| 319 |
}
|
313 |
|
| 320 |
|
- |
|
| 321 |
@UiHandler("submit")
|
314 |
void updateItem() {
|
| - |
|
315 |
if(item == null) {
|
| 322 |
void onSubmitPressed(ClickEvent clickEvent) {
|
316 |
Window.alert("Please select an item to update.");
|
| - |
|
317 |
return;
|
| - |
|
318 |
}
|
| 323 |
try {
|
319 |
try {
|
| 324 |
updateItem();
|
- |
|
| 325 |
if(!isItemChanged()) {
|
320 |
if(!createNewItem()) {
|
| 326 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
- |
|
| 327 |
return;
|
321 |
return;
|
| 328 |
}
|
322 |
}
|
| 329 |
if(!Utils.validateItem(newItem)) {
|
323 |
if(!isItemChanged()) {
|
| - |
|
324 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
| 330 |
return;
|
325 |
return;
|
| 331 |
}
|
326 |
}
|
| 332 |
|
- |
|
| 333 |
/*if(!validatePrices()) {
|
- |
|
| 334 |
return;
|
- |
|
| 335 |
}*/
|
- |
|
| 336 |
//updateItem(); -- Calling this method above. A new item is created with updated data.
|
- |
|
| 337 |
} catch(NumberFormatException ex) {
|
327 |
} catch(NumberFormatException ex) {
|
| - |
|
328 |
ex.printStackTrace();
|
| - |
|
329 |
GWT.log("Number format exception");
|
| - |
|
330 |
}
|
| - |
|
331 |
if(!Utils.validateItem(newItem)) {
|
| 338 |
return;
|
332 |
return;
|
| 339 |
}
|
333 |
}
|
| - |
|
334 |
|
| - |
|
335 |
/*if(!validatePrices()) {
|
| - |
|
336 |
return;
|
| - |
|
337 |
}*/
|
| - |
|
338 |
//updateItem(); -- Calling this method above. A new item is created with updated data.
|
| - |
|
339 |
catalogService.updateItem(newItem, new AsyncCallback<Boolean>() {
|
| - |
|
340 |
@Override
|
| - |
|
341 |
public void onSuccess(Boolean result) {
|
| - |
|
342 |
if(result) {
|
| 340 |
itemUpdateListener.onItemUpdate(newItem);
|
343 |
item = newItem;
|
| 341 |
GWT.log("Item updated. Id = " + item.getId());
|
344 |
GWT.log("Item updated. Id = " + item.getId());
|
| - |
|
345 |
Window.alert("Item updated successfully.");
|
| - |
|
346 |
}
|
| 342 |
item = newItem;
|
347 |
else {
|
| - |
|
348 |
GWT.log("Error updating item");
|
| - |
|
349 |
Window.alert("Error updating item");
|
| - |
|
350 |
}
|
| - |
|
351 |
}
|
| - |
|
352 |
@Override
|
| - |
|
353 |
public void onFailure(Throwable caught) {
|
| - |
|
354 |
caught.printStackTrace();
|
| - |
|
355 |
Window.alert("Error while updating item");
|
| - |
|
356 |
}
|
| - |
|
357 |
});
|
| 343 |
}
|
358 |
}
|
| 344 |
|
359 |
|
| 345 |
private void updateItem() throws NumberFormatException {
|
360 |
private boolean createNewItem() {
|
| 346 |
newItem = new Item();
|
361 |
newItem = new Item();
|
| 347 |
newItem.setId(Long.parseLong(itemId.getText()));
|
362 |
newItem.setId(Long.parseLong(itemId.getText()));
|
| 348 |
newItem.setProductGroup(productGroup.getText().trim());
|
363 |
newItem.setProductGroup(productGroup.getText().trim());
|
| 349 |
newItem.setBrand(brand.getText().trim());
|
364 |
newItem.setBrand(brand.getText().trim());
|
| 350 |
newItem.setModelNumber(modelNumber.getText().trim());
|
365 |
newItem.setModelNumber(modelNumber.getText().trim());
|
| 351 |
newItem.setModelName(modelName.getText().trim());
|
366 |
newItem.setModelName(modelName.getText().trim());
|
| 352 |
newItem.setColor(color.getText().trim());
|
367 |
newItem.setColor(color.getText().trim());
|
| 353 |
newItem.setContentCategory(contentCategory.getText());
|
368 |
newItem.setContentCategory(contentCategory.getText());
|
| 354 |
newItem.setComments(comments.getText().trim());
|
369 |
newItem.setComments(comments.getText().trim());
|
| 355 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
370 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
| 356 |
newItem.setFeatureId(item.getFeatureId());
|
371 |
|
| 357 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
- |
|
| 358 |
try {
|
372 |
try {
|
| - |
|
373 |
if(!mrp.getText().trim().isEmpty()) {
|
| 359 |
newItem.setMrp(Double.parseDouble(mrp.getText().trim()));
|
374 |
double mrpValue = Double.parseDouble(mrp.getText().trim());
|
| - |
|
375 |
if(mrpValue <= 0) {
|
| - |
|
376 |
throw new NumberFormatException("Negative value of MRP");
|
| - |
|
377 |
}
|
| - |
|
378 |
newItem.setMrp(mrpValue);
|
| - |
|
379 |
} else {
|
| - |
|
380 |
newItem.setMrp(-1);
|
| - |
|
381 |
}
|
| 360 |
} catch(NumberFormatException ex) {
|
382 |
} catch(NumberFormatException ex) {
|
| 361 |
Window.alert("Invalid MRP format");
|
383 |
Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
|
| 362 |
throw new NumberFormatException();
|
384 |
return false;
|
| 363 |
}
|
385 |
}
|
| 364 |
try {
|
386 |
try {
|
| - |
|
387 |
if(!sellingPrice.getText().trim().isEmpty()) {
|
| 365 |
newItem.setSellingPrice(Double.parseDouble(sellingPrice.getText().trim()));
|
388 |
double spValue = Double.parseDouble(sellingPrice.getText().trim());
|
| - |
|
389 |
if(spValue <= 0) {
|
| - |
|
390 |
throw new NumberFormatException("Negative value of Selling price");
|
| - |
|
391 |
}
|
| - |
|
392 |
newItem.setSellingPrice(spValue);
|
| - |
|
393 |
} else {
|
| - |
|
394 |
newItem.setSellingPrice(-1);
|
| 366 |
}
|
395 |
}
|
| 367 |
catch(NumberFormatException ex) {
|
396 |
} catch(NumberFormatException ex) {
|
| 368 |
Window.alert("Invalid Selling Price format");
|
397 |
Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
|
| 369 |
throw new NumberFormatException();
|
398 |
return false;
|
| 370 |
}
|
399 |
}
|
| 371 |
try {
|
400 |
try {
|
| - |
|
401 |
if(!weight.getText().trim().isEmpty()) {
|
| 372 |
newItem.setWeight(Double.parseDouble(weight.getText().trim()));
|
402 |
double wtValue = Double.parseDouble(weight.getText().trim());
|
| - |
|
403 |
if(wtValue <= 0) {
|
| - |
|
404 |
throw new NumberFormatException("Negative value of Weight");
|
| - |
|
405 |
}
|
| - |
|
406 |
newItem.setWeight(wtValue);
|
| - |
|
407 |
} else {
|
| - |
|
408 |
newItem.setWeight(-1);
|
| - |
|
409 |
}
|
| 373 |
} catch(NumberFormatException ex) {
|
410 |
} catch(NumberFormatException ex) {
|
| - |
|
411 |
Window.alert("Invalid weight format/value. Value shoule be greater than zero");
|
| - |
|
412 |
return false;
|
| - |
|
413 |
}
|
| - |
|
414 |
try {
|
| - |
|
415 |
if(!startDate.getTextBox().getText().trim().equals("")) {
|
| - |
|
416 |
newItem.setStartDate(startDate.getValue().getTime());
|
| - |
|
417 |
}
|
| - |
|
418 |
} catch(Exception ex) {
|
| 374 |
Window.alert("Invalid Weight format");
|
419 |
Window.alert("Invalid start date format");
|
| 375 |
throw new NumberFormatException();
|
420 |
return false;
|
| 376 |
}
|
421 |
}
|
| 377 |
newItem.setAddedOn(item.getAddedOn());
|
- |
|
| 378 |
newItem.setStartDate(startDate.getValue().getTime());
|
- |
|
| 379 |
newItem.setRetireDate(item.getRetireDate());
|
- |
|
| 380 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
- |
|
| 381 |
newItem.setItemStatus(item.getItemStatus());
|
- |
|
| 382 |
newItem.setOtherInfo(item.getOtherInfo());
|
- |
|
| 383 |
newItem.setBestDealsText(bestDealsText.getText().trim());
|
422 |
newItem.setBestDealsText(bestDealsText.getText().trim());
|
| 384 |
try {
|
423 |
try {
|
| - |
|
424 |
if(!bestDealsValue.getText().trim().equals("")) {
|
| 385 |
newItem.setBestDealsValue(Double.parseDouble(bestDealsValue.getText().trim()));
|
425 |
double bdValue = Double.parseDouble(bestDealsValue.getText().trim());
|
| - |
|
426 |
if(bdValue < 0) {
|
| - |
|
427 |
throw new NumberFormatException("Negative value of BestDealValue");
|
| - |
|
428 |
}
|
| - |
|
429 |
newItem.setBestDealsValue(bdValue);
|
| - |
|
430 |
} else {
|
| - |
|
431 |
newItem.setBestDealsValue(-1);
|
| - |
|
432 |
}
|
| 386 |
} catch(NumberFormatException ex) {
|
433 |
} catch(NumberFormatException ex) {
|
| 387 |
Window.alert("Invalid Best Deals Value format");
|
434 |
Window.alert("Invalid best deal value format");
|
| 388 |
throw new NumberFormatException();
|
435 |
return false;
|
| 389 |
}
|
436 |
}
|
| 390 |
try {
|
437 |
try {
|
| - |
|
438 |
if(!bestSellingRank.getText().trim().equals("")) {
|
| 391 |
newItem.setBestSellingRank(Long.parseLong(bestSellingRank.getText().trim()));
|
439 |
long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
|
| - |
|
440 |
if(bsrValue < 0) {
|
| - |
|
441 |
throw new NumberFormatException("Negative value of Best Selling Rank");
|
| - |
|
442 |
}
|
| - |
|
443 |
newItem.setBestSellingRank(bsrValue);
|
| - |
|
444 |
} else {
|
| - |
|
445 |
newItem.setBestSellingRank(-1);
|
| - |
|
446 |
}
|
| - |
|
447 |
|
| 392 |
} catch (NumberFormatException ex) {
|
448 |
} catch(NumberFormatException ex) {
|
| 393 |
Window.alert("Invalid Best Selling Rank format");
|
449 |
Window.alert("Invalid best selling rank format");
|
| 394 |
throw new NumberFormatException();
|
450 |
return false;
|
| 395 |
}
|
451 |
}
|
| 396 |
|
- |
|
| 397 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
452 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
| 398 |
newItem.setAvailability(item.getAvailability());
|
- |
|
| 399 |
|
453 |
|
| - |
|
454 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
| - |
|
455 |
Add the instance to map and set the map to the item instance created above.*/
|
| 400 |
Map<Long, VendorPricings> vendorPricings = new HashMap<Long, VendorPricings>();
|
456 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
| 401 |
VendorPricings v;
|
457 |
VendorPricings v;
|
| 402 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
458 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
| 403 |
v = new VendorPricings();
|
459 |
v = new VendorPricings();
|
| 404 |
v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP)));
|
460 |
v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP)));
|
| 405 |
v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP)));
|
461 |
v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP)));
|
| 406 |
v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP)));
|
462 |
v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP)));
|
| 407 |
v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID)));
|
463 |
v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID)));
|
| 408 |
vendorPricings.put(v.getVendorId(), v);
|
464 |
vendorPrices.put(v.getVendorId(), v);
|
| 409 |
newItem.setMop(v.getMop());
|
465 |
newItem.setMop(v.getMop());
|
| 410 |
newItem.setDealerPrice(v.getDealerPrice());
|
466 |
newItem.setDealerPrice(v.getDealerPrice());
|
| 411 |
newItem.setTransferPrice(v.getTransferPrice());
|
467 |
newItem.setTransferPrice(v.getTransferPrice());
|
| 412 |
}
|
468 |
}
|
| 413 |
newItem.setVendorPricesMap(vendorPricings);
|
469 |
newItem.setVendorPricesMap(vendorPrices);
|
| 414 |
|
470 |
|
| - |
|
471 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
| - |
|
472 |
Add the instance to map and set the map to the item instance created above.*/
|
| 415 |
Map<Long, VendorItemMapping> vendorMapping = new HashMap<Long, VendorItemMapping>();
|
473 |
Map<Long, VendorItemMapping> vendorMappings = new HashMap<Long, VendorItemMapping>();
|
| 416 |
VendorItemMapping vM;
|
474 |
VendorItemMapping vMapping;
|
| 417 |
for(int row = 0; row < vendorTableM.getRowCount(); row++) {
|
475 |
for(int row = 0; row < vendorTableM.getRowCount(); row++) {
|
| 418 |
vM = new VendorItemMapping();
|
476 |
vMapping = new VendorItemMapping();
|
| 419 |
vM.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID)));
|
477 |
vMapping.setItemKey(vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY));
|
| 420 |
vM.setItemKey(vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY));
|
478 |
vMapping.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID)));
|
| 421 |
vendorMapping.put(vM.getVendorId(), vM);
|
479 |
vendorMappings.put(vMapping.getVendorId(), vMapping);
|
| 422 |
}
|
480 |
}
|
| 423 |
newItem.setVendorMappingsMap(vendorMapping);
|
481 |
newItem.setVendorMappingsMap(vendorMappings);
|
| 424 |
|
- |
|
| 425 |
|
482 |
|
| 426 |
/*item.setProductGroup(productGroup.getText().trim());
|
483 |
newItem.setContentCategoryId(item.getContentCategoryId());
|
| 427 |
item.setBrand(brand.getText().trim());
|
484 |
newItem.setFeatureId(item.getFeatureId());
|
| 428 |
item.setModelName(modelName.getText().trim());
|
485 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
| 429 |
item.setModelNumber(modelNumber.getText().trim());
|
486 |
newItem.setAddedOn(item.getAddedOn());
|
| 430 |
item.setColor(color.getText().trim());
|
487 |
newItem.setRetireDate(item.getRetireDate());
|
| 431 |
item.setComments(comments.getText().trim());
|
488 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
| 432 |
item.setMrp(Double.parseDouble(this.mrp.getText()));
|
489 |
newItem.setItemStatus(item.getItemStatus());
|
| 433 |
item.setSellingPrice(Double.parseDouble(this.sellingPrice.getText()));
|
- |
|
| 434 |
item.setWeight(Double.parseDouble(this.weight.getText()));
|
- |
|
| 435 |
item.setBestDealsText(bestDealsText.getText().trim());
|
490 |
newItem.setOtherInfo(item.getOtherInfo());
|
| 436 |
item.setBestDealsValue(Double.parseDouble(bestDealsValue.getText().trim()));
|
- |
|
| 437 |
item.setBestSellingRank(Long.parseLong(bestSellingRank.getText().trim()));
|
- |
|
| 438 |
item.setDefaultForEntity(defaultForEntity.getValue());
|
491 |
newItem.setAvailability(item.getAvailability());
|
| 439 |
for(int row = 0; row < pricingTable.getRowCount(); row++) {
|
- |
|
| 440 |
long vendorId = Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID));
|
- |
|
| 441 |
double mop = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_MOP));
|
- |
|
| 442 |
double dp = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_DP));
|
- |
|
| 443 |
double tp = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_TP));
|
- |
|
| 444 |
item.getVendorPricings().get(vendorId)[Item.INDEX_MOP] = mop;
|
- |
|
| 445 |
item.getVendorPricings().get(vendorId)[Item.INDEX_DP] = dp;
|
- |
|
| 446 |
item.getVendorPricings().get(vendorId)[Item.INDEX_TP] = tp;
|
- |
|
| 447 |
item.setMop(mop);
|
492 |
|
| 448 |
item.setDealerPrice(dp);
|
- |
|
| 449 |
item.setTransferPrice(tp);
|
- |
|
| 450 |
}*/
|
493 |
return true;
|
| 451 |
}
|
494 |
}
|
| 452 |
|
495 |
|
| 453 |
private void updateVendorPrices(final long vendorId, final int row) {
|
496 |
private void updateVendorPrices(final long vendorId, final int row) {
|
| 454 |
String mop = vendorTable.getText(row, TABLE_INDEX_MOP);
|
497 |
String mop = vendorTable.getText(row, TABLE_INDEX_MOP);
|
| 455 |
String dp = vendorTable.getText(row, TABLE_INDEX_DP);
|
498 |
String dp = vendorTable.getText(row, TABLE_INDEX_DP);
|
| Line 472... |
Line 515... |
| 472 |
pricesDialog.show();
|
515 |
pricesDialog.show();
|
| 473 |
}
|
516 |
}
|
| 474 |
|
517 |
|
| 475 |
private void updateVendorMapping(final long vendorId, final int row) {
|
518 |
private void updateVendorMapping(final long vendorId, final int row) {
|
| 476 |
String key = vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY);
|
519 |
String key = vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY);
|
| 477 |
VendorMappingDialog mappingDialog = new VendorMappingDialog(key);
|
520 |
VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
| - |
|
521 |
modelNumber.getText().trim(), color.getText().trim(), key);
|
| 478 |
mappingDialog.updateButton.setText("Update");
|
522 |
mappingDialog.updateButton.setText("Update");
|
| 479 |
mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
523 |
mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
| 480 |
@Override
|
524 |
@Override
|
| 481 |
public boolean onUpdate(String itemKey, long vendorId) {
|
525 |
public boolean onUpdate(String itemKey, long vendorId) {
|
| 482 |
if(itemKey == null || itemKey.equals("")) {
|
526 |
if(itemKey == null || itemKey.equals("")) {
|
| Line 507... |
Line 551... |
| 507 |
return true;
|
551 |
return true;
|
| 508 |
}
|
552 |
}
|
| 509 |
if(!comments.getText().trim().equals(item.getComments())) {
|
553 |
if(!comments.getText().trim().equals(item.getComments())) {
|
| 510 |
return true;
|
554 |
return true;
|
| 511 |
}
|
555 |
}
|
| 512 |
try {
|
- |
|
| 513 |
if(item.getMrp() != Double.parseDouble(mrp.getText().trim())) {
|
556 |
if(newItem.getMrp() != item.getMrp()) {
|
| 514 |
return true;
|
557 |
return true;
|
| 515 |
}
|
- |
|
| 516 |
} catch(NumberFormatException ex) {
|
- |
|
| 517 |
Window.alert("Invalid MRP format");
|
- |
|
| 518 |
throw new NumberFormatException();
|
- |
|
| 519 |
}
|
558 |
}
|
| 520 |
try {
|
- |
|
| 521 |
if(item.getSellingPrice() != Double.parseDouble(sellingPrice.getText().trim())) {
|
559 |
if(newItem.getSellingPrice() != item.getSellingPrice()) {
|
| 522 |
return true;
|
560 |
return true;
|
| 523 |
}
|
- |
|
| 524 |
} catch(NumberFormatException ex) {
|
- |
|
| 525 |
Window.alert("Invalid Selling Price format");
|
- |
|
| 526 |
throw new NumberFormatException();
|
- |
|
| 527 |
}
|
561 |
}
|
| 528 |
try {
|
- |
|
| 529 |
if(item.getWeight() != Double.parseDouble(weight.getText().trim())) {
|
562 |
if(newItem.getWeight() != item.getWeight()) {
|
| 530 |
return true;
|
563 |
return true;
|
| 531 |
}
|
- |
|
| 532 |
} catch(NumberFormatException ex) {
|
- |
|
| 533 |
Window.alert("Invalid Weight format");
|
- |
|
| 534 |
throw new NumberFormatException();
|
- |
|
| 535 |
}
|
564 |
}
|
| 536 |
if(!bestDealsText.getText().trim().equals(item.getBestDealsText())) {
|
565 |
if(!bestDealsText.getText().trim().equals(item.getBestDealsText())) {
|
| 537 |
return true;
|
566 |
return true;
|
| 538 |
}
|
567 |
}
|
| 539 |
try {
|
- |
|
| 540 |
if(item.getBestDealsValue() != Double.parseDouble(bestDealsValue.getText().trim())) {
|
568 |
if(newItem.getBestDealsValue() != item.getBestDealsValue()) {
|
| 541 |
return true;
|
569 |
return true;
|
| 542 |
}
|
- |
|
| 543 |
} catch(NumberFormatException ex) {
|
- |
|
| 544 |
Window.alert("Invalid Best Deals Value format");
|
- |
|
| 545 |
throw new NumberFormatException();
|
- |
|
| 546 |
}
|
570 |
}
|
| 547 |
try{
|
- |
|
| 548 |
if(item.getBestSellingRank() != Long.parseLong(bestSellingRank.getText().trim())) {
|
571 |
if(newItem.getBestSellingRank() != item.getBestSellingRank()) {
|
| 549 |
return true;
|
572 |
return true;
|
| 550 |
}
|
- |
|
| 551 |
} catch (NumberFormatException ex) {
|
- |
|
| 552 |
Window.alert("Invalid Best Selling Rank format");
|
- |
|
| 553 |
throw new NumberFormatException();
|
- |
|
| 554 |
}
|
573 |
}
|
| 555 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
574 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
| 556 |
return true;
|
575 |
return true;
|
| 557 |
}
|
576 |
}
|
| 558 |
|
- |
|
| 559 |
if(newItem.getStartDate() != item.getStartDate()) {
|
577 |
if(newItem.getStartDate() != item.getStartDate()) {
|
| 560 |
return true;
|
578 |
return true;
|
| 561 |
}
|
579 |
}
|
| 562 |
|
- |
|
| 563 |
VendorPricings vendorDetails;
|
580 |
VendorPricings vendorPricings;
|
| 564 |
long vendorId;
|
581 |
long vendorId;
|
| 565 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
582 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
| 566 |
vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
|
583 |
vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
|
| 567 |
vendorDetails = item.getVendorPricesMap().get(vendorId);
|
584 |
vendorPricings = item.getVendorPricesMap().get(vendorId);
|
| 568 |
if(vendorDetails.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP))) {
|
585 |
if(vendorPricings.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP))) {
|
| 569 |
return true;
|
586 |
return true;
|
| 570 |
}
|
587 |
}
|
| 571 |
if(vendorDetails.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP))) {
|
588 |
if(vendorPricings.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP))) {
|
| 572 |
return true;
|
589 |
return true;
|
| 573 |
}
|
590 |
}
|
| 574 |
if(vendorDetails.getTransferPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP))) {
|
591 |
if(vendorPricings.getTransferPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP))) {
|
| 575 |
return true;
|
592 |
return true;
|
| 576 |
}
|
593 |
}
|
| 577 |
}
|
594 |
}
|
| 578 |
return false;
|
595 |
return false;
|
| 579 |
}
|
596 |
}
|
| Line 595... |
Line 612... |
| 595 |
}
|
612 |
}
|
| 596 |
return true;
|
613 |
return true;
|
| 597 |
}
|
614 |
}
|
| 598 |
|
615 |
|
| 599 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
616 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
| 600 |
if(item.getMrp() < mop) {
|
617 |
if(item.getMrp() != -1 && item.getMrp() < mop) {
|
| 601 |
Window.alert("MOP cannot be more than MRP.");
|
618 |
Window.alert("MOP cannot be more than MRP.");
|
| 602 |
return false;
|
619 |
return false;
|
| 603 |
}
|
620 |
}
|
| 604 |
if(tp > mop) {
|
621 |
if(tp > mop) {
|
| 605 |
Window.alert("Transfer Price cannot be more than MOP.");
|
622 |
Window.alert("Transfer Price cannot be more than MOP.");
|