| 1961 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| 2066 |
ankur.sing |
4 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
| 1961 |
ankur.sing |
5 |
|
|
|
6 |
import java.util.Date;
|
| 2066 |
ankur.sing |
7 |
import java.util.HashMap;
|
| 1992 |
ankur.sing |
8 |
import java.util.Map;
|
|
|
9 |
import java.util.Map.Entry;
|
| 1961 |
ankur.sing |
10 |
|
|
|
11 |
import com.google.gwt.core.client.GWT;
|
|
|
12 |
import com.google.gwt.event.dom.client.ClickEvent;
|
| 1992 |
ankur.sing |
13 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
14 |
import com.google.gwt.resources.client.CssResource;
|
| 1961 |
ankur.sing |
15 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
16 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
17 |
import com.google.gwt.uibinder.client.UiHandler;
|
|
|
18 |
import com.google.gwt.user.client.Window;
|
|
|
19 |
import com.google.gwt.user.client.ui.Button;
|
| 2066 |
ankur.sing |
20 |
import com.google.gwt.user.client.ui.CheckBox;
|
| 1992 |
ankur.sing |
21 |
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
22 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
| 1961 |
ankur.sing |
23 |
import com.google.gwt.user.client.ui.Label;
|
| 2066 |
ankur.sing |
24 |
import com.google.gwt.user.client.ui.ListBox;
|
| 1961 |
ankur.sing |
25 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
|
|
26 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
27 |
import com.google.gwt.user.client.ui.Widget;
|
|
|
28 |
|
|
|
29 |
public class ItemDetails extends ResizeComposite {
|
|
|
30 |
|
| 2066 |
ankur.sing |
31 |
private final int TABLE_INDEX_VENDORID = 0, TABLE_INDEX_VENDOR_DESC = 1, TABLE_INDEX_MOP = 2, TABLE_INDEX_DP = 3, TABLE_INDEX_TP = 4;
|
|
|
32 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0, TABLE_INDEX_WAREHOUSE_DESC = 1, TABLE_INDEX_WAREHOUSE_INV = 2;
|
|
|
33 |
private Item newItem;
|
|
|
34 |
|
|
|
35 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
|
|
36 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
|
|
37 |
|
|
|
38 |
public interface ItemUpdateListener {
|
| 1992 |
ankur.sing |
39 |
void onItemUpdate(Item item);
|
| 2066 |
ankur.sing |
40 |
}
|
| 1961 |
ankur.sing |
41 |
|
| 2066 |
ankur.sing |
42 |
interface ItemDetailStyle extends CssResource{
|
|
|
43 |
String greenLabel();
|
|
|
44 |
String fieldChanged();
|
|
|
45 |
}
|
| 1961 |
ankur.sing |
46 |
|
| 2066 |
ankur.sing |
47 |
private ItemUpdateListener itemUpdateListener;
|
|
|
48 |
|
|
|
49 |
private Item item;
|
|
|
50 |
|
|
|
51 |
@UiField ItemDetailStyle style;
|
|
|
52 |
@UiField Label itemId;
|
|
|
53 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
|
|
54 |
@UiField Label category, catalogItemId;
|
|
|
55 |
@UiField TextBox comments;
|
|
|
56 |
@UiField TextBox sellingPrice, mrp, /*mop, dealerPrice, transferPrice,*/ weight;
|
|
|
57 |
@UiField Label addedOn, startDate, retireDate, updatedOn;
|
|
|
58 |
@UiField Label itemStatus;
|
|
|
59 |
@UiField TextBox bestDealsText, bestDealsValue;
|
|
|
60 |
@UiField FlexTable headerAvailability, availabilityTable;
|
|
|
61 |
@UiField FlexTable headerPricing, pricingTable;
|
|
|
62 |
@UiField TextBox bestSellingRank;
|
|
|
63 |
@UiField CheckBox defaultForEntity;
|
|
|
64 |
@UiField Button submit;
|
|
|
65 |
|
|
|
66 |
public ItemDetails(Item item){
|
|
|
67 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
68 |
initAvailabilityHeader();
|
|
|
69 |
initPricingHeader();
|
|
|
70 |
setItemDetails(item);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
public ItemDetails() {
|
|
|
74 |
this.item = null;
|
|
|
75 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
76 |
initAvailabilityHeader();
|
|
|
77 |
initPricingHeader();
|
|
|
78 |
}
|
|
|
79 |
|
|
|
80 |
public void setItemDetails(Item item){
|
|
|
81 |
this.item = item;
|
|
|
82 |
itemId.setText(item.getId()+"");
|
|
|
83 |
productGroup.setText(item.getProductGroup());
|
|
|
84 |
brand.setText(item.getBrand());
|
|
|
85 |
modelNumber.setText(item.getModelNumber());
|
|
|
86 |
modelName.setText(item.getModelName());
|
|
|
87 |
color.setText(item.getColor());
|
|
|
88 |
|
|
|
89 |
category.setText(item.getCategory()+"");
|
|
|
90 |
comments.setText(item.getComments());
|
|
|
91 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
|
|
92 |
|
|
|
93 |
mrp.setText(item.getMrp()+"");
|
|
|
94 |
sellingPrice.setText(item.getSellingPrice()+"");
|
|
|
95 |
/*mop.setText(item.getMop()+"");
|
| 1961 |
ankur.sing |
96 |
dealerPrice.setText(item.getDealerPrice()+"");
|
| 1992 |
ankur.sing |
97 |
transferPrice.setText(item.getTransferPrice()+"");*/
|
| 2066 |
ankur.sing |
98 |
weight.setText(item.getWeight()+"");
|
| 1992 |
ankur.sing |
99 |
|
| 2066 |
ankur.sing |
100 |
addedOn.setText(getDisplayableDate(item.getAddedOn()));
|
|
|
101 |
startDate.setText(getDisplayableDate(item.getStartDate()));
|
|
|
102 |
retireDate.setText(getDisplayableDate(item.getRetireDate()));
|
|
|
103 |
updatedOn.setText(getDisplayableDate(item.getUpdatedOn()));
|
|
|
104 |
|
|
|
105 |
bestDealsText.setText(item.getBestDealsText());
|
|
|
106 |
bestDealsValue.setText(item.getBestDealsValue()+"");
|
|
|
107 |
|
|
|
108 |
bestSellingRank.setText(item.getBestSellingRank()+"");
|
|
|
109 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
| 1992 |
ankur.sing |
110 |
|
| 2066 |
ankur.sing |
111 |
itemStatus.setText(item.getItemStatus());
|
|
|
112 |
|
|
|
113 |
updateAvailabilityTable(item.getAvailability());
|
|
|
114 |
|
|
|
115 |
updatePricingTable(item.getVendorPricings());
|
| 1992 |
ankur.sing |
116 |
}
|
| 2066 |
ankur.sing |
117 |
|
|
|
118 |
private void initAvailabilityHeader(){
|
| 1992 |
ankur.sing |
119 |
// Initialize the header.
|
| 2066 |
ankur.sing |
120 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
|
|
121 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "128px");
|
|
|
122 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
|
|
123 |
|
|
|
124 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_ID, "Warehouse Id");
|
|
|
125 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
|
|
126 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
|
| 1992 |
ankur.sing |
127 |
|
|
|
128 |
}
|
| 2066 |
ankur.sing |
129 |
|
|
|
130 |
private void initPricingHeader(){
|
|
|
131 |
// Initialize the header.
|
|
|
132 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
|
|
133 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
|
|
134 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
|
|
135 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
|
|
136 |
headerPricing.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
|
|
137 |
|
|
|
138 |
headerPricing.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
|
|
|
139 |
headerPricing.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor Desc");
|
|
|
140 |
headerPricing.setText(0, TABLE_INDEX_MOP, "MOP");
|
|
|
141 |
headerPricing.setText(0, TABLE_INDEX_DP, "Dealer Price");
|
|
|
142 |
headerPricing.setText(0, TABLE_INDEX_TP, "Transfer Price");
|
|
|
143 |
}
|
|
|
144 |
|
| 1992 |
ankur.sing |
145 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
|
|
146 |
availabilityTable.removeAllRows();
|
|
|
147 |
if(availabilityMap == null) {
|
|
|
148 |
return;
|
|
|
149 |
}
|
| 2066 |
ankur.sing |
150 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
|
|
151 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "128px");
|
|
|
152 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
|
|
153 |
|
|
|
154 |
|
| 1992 |
ankur.sing |
155 |
int i=0;
|
|
|
156 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()){
|
| 2066 |
ankur.sing |
157 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_ID, availability.getKey() + "");
|
|
|
158 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
|
|
|
159 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
| 1992 |
ankur.sing |
160 |
i++;
|
|
|
161 |
}
|
|
|
162 |
}
|
| 2066 |
ankur.sing |
163 |
|
| 1992 |
ankur.sing |
164 |
private void updatePricingTable(Map<Long, double[]> pricings){
|
|
|
165 |
pricingTable.removeAllRows();
|
|
|
166 |
if(pricings == null || pricings.isEmpty()) {
|
|
|
167 |
return;
|
|
|
168 |
}
|
| 2066 |
ankur.sing |
169 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
|
|
170 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
|
|
171 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
|
|
172 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
|
|
173 |
pricingTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
|
|
174 |
|
|
|
175 |
|
| 1992 |
ankur.sing |
176 |
int i=0;
|
|
|
177 |
for(Entry<Long, double[]> pricing : pricings.entrySet()){
|
| 2066 |
ankur.sing |
178 |
pricingTable.setText(i, TABLE_INDEX_VENDORID, pricing.getKey() + "");
|
|
|
179 |
pricingTable.setText(i, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(pricing.getKey()));
|
|
|
180 |
pricingTable.setText(i, TABLE_INDEX_MOP, pricing.getValue()[Item.INDEX_MOP] + "");
|
|
|
181 |
pricingTable.setText(i, TABLE_INDEX_DP, pricing.getValue()[Item.INDEX_DP] + "");
|
|
|
182 |
pricingTable.setText(i, TABLE_INDEX_TP, pricing.getValue()[Item.INDEX_TP] + "");
|
| 1992 |
ankur.sing |
183 |
Button editButton = new Button("Edit");
|
| 2066 |
ankur.sing |
184 |
pricingTable.setWidget(i, TABLE_INDEX_TP + 1, editButton);
|
| 1992 |
ankur.sing |
185 |
i++;
|
|
|
186 |
editButton.addClickHandler(new ClickHandler() {
|
|
|
187 |
@Override
|
|
|
188 |
public void onClick(ClickEvent event) {
|
|
|
189 |
Cell cell = pricingTable.getCellForEvent(event);
|
|
|
190 |
int row = cell.getRowIndex();
|
| 2066 |
ankur.sing |
191 |
long vendorId = Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID));
|
| 1992 |
ankur.sing |
192 |
updateVendorPrices(vendorId, row);
|
|
|
193 |
}
|
|
|
194 |
});
|
|
|
195 |
}
|
|
|
196 |
}
|
| 2066 |
ankur.sing |
197 |
|
|
|
198 |
|
|
|
199 |
//TODO: This code is duplicated between here and OrderList. Move it to a Utility class.
|
|
|
200 |
private String getDisplayableDate(Long millis){
|
|
|
201 |
Date date = new Date();
|
|
|
202 |
date.setTime(millis);
|
|
|
203 |
String dateString = date.toString();
|
|
|
204 |
dateString = dateString.substring(0, dateString.lastIndexOf(" "));
|
|
|
205 |
dateString = dateString.substring(0, dateString.lastIndexOf(" "));
|
|
|
206 |
return dateString;
|
|
|
207 |
}
|
|
|
208 |
|
|
|
209 |
public void setItemUpdateListener(ItemUpdateListener itemUpdatelistener) {
|
|
|
210 |
this.itemUpdateListener = itemUpdatelistener;
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
@UiHandler("submit")
|
|
|
214 |
void onSubmitPressed(ClickEvent clickEvent) {
|
|
|
215 |
//long id = Long.parseLong(this.itemId.getText());
|
|
|
216 |
try {
|
|
|
217 |
if(!isItemChanged()) {
|
|
|
218 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
|
|
219 |
return;
|
|
|
220 |
}
|
|
|
221 |
updateItem();
|
|
|
222 |
if(!validatePrices()) {
|
|
|
223 |
return;
|
|
|
224 |
}
|
|
|
225 |
//updateItem();
|
|
|
226 |
} catch(NumberFormatException ex) {
|
|
|
227 |
return;
|
|
|
228 |
}
|
|
|
229 |
itemUpdateListener.onItemUpdate(newItem);
|
| 2027 |
ankur.sing |
230 |
GWT.log("Item updated. Id = " + item.getId());
|
| 2066 |
ankur.sing |
231 |
item = newItem;
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
private void updateItem() throws NumberFormatException {
|
|
|
235 |
newItem = new Item();
|
|
|
236 |
newItem.setId(Long.parseLong(itemId.getText()));
|
|
|
237 |
newItem.setProductGroup(productGroup.getText().trim());
|
|
|
238 |
newItem.setBrand(brand.getText().trim());
|
|
|
239 |
newItem.setModelNumber(modelNumber.getText().trim());
|
|
|
240 |
newItem.setModelName(modelName.getText().trim());
|
|
|
241 |
newItem.setColor(color.getText().trim());
|
|
|
242 |
newItem.setCategory(Long.parseLong(category.getText()));
|
|
|
243 |
newItem.setComments(comments.getText().trim());
|
|
|
244 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
|
|
245 |
newItem.setFeatureId(item.getFeatureId());
|
|
|
246 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
|
|
247 |
newItem.setMrp(Double.parseDouble(mrp.getText().trim()));
|
|
|
248 |
newItem.setSellingPrice(Double.parseDouble(sellingPrice.getText().trim()));
|
|
|
249 |
newItem.setWeight(Double.parseDouble(weight.getText().trim()));
|
|
|
250 |
newItem.setAddedOn(item.getAddedOn());
|
|
|
251 |
newItem.setStartDate(item.getStartDate());
|
|
|
252 |
newItem.setRetireDate(item.getRetireDate());
|
|
|
253 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
|
|
254 |
newItem.setItemStatus(item.getItemStatus());
|
|
|
255 |
newItem.setOtherInfo(item.getOtherInfo());
|
|
|
256 |
newItem.setBestDealsText(bestDealsText.getText().trim());
|
|
|
257 |
newItem.setBestDealsValue(Double.parseDouble(bestDealsValue.getText().trim()));
|
|
|
258 |
newItem.setBestSellingRank(Long.parseLong(bestSellingRank.getText().trim()));
|
|
|
259 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
|
|
260 |
newItem.setAvailability(item.getAvailability());
|
|
|
261 |
Map<Long, double[]> vendorPrices = new HashMap<Long, double[]>();
|
|
|
262 |
double[] arr;
|
|
|
263 |
for(int row = 0; row < pricingTable.getRowCount(); row++) {
|
|
|
264 |
arr = new double[3];
|
|
|
265 |
arr[Item.INDEX_MOP] = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_MOP));
|
|
|
266 |
arr[Item.INDEX_DP] = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_DP));
|
|
|
267 |
arr[Item.INDEX_TP] = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_TP));
|
|
|
268 |
vendorPrices.put(Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID)), arr);
|
|
|
269 |
newItem.setMop(arr[Item.INDEX_MOP]);
|
|
|
270 |
newItem.setDealerPrice(arr[Item.INDEX_DP]);
|
|
|
271 |
newItem.setTransferPrice(arr[Item.INDEX_TP]);
|
|
|
272 |
}
|
|
|
273 |
newItem.setVendorPricings(vendorPrices);
|
| 2027 |
ankur.sing |
274 |
|
| 2066 |
ankur.sing |
275 |
/*item.setProductGroup(productGroup.getText().trim());
|
|
|
276 |
item.setBrand(brand.getText().trim());
|
|
|
277 |
item.setModelName(modelName.getText().trim());
|
|
|
278 |
item.setModelNumber(modelNumber.getText().trim());
|
|
|
279 |
item.setColor(color.getText().trim());
|
|
|
280 |
item.setComments(comments.getText().trim());
|
|
|
281 |
item.setMrp(Double.parseDouble(this.mrp.getText()));
|
|
|
282 |
item.setSellingPrice(Double.parseDouble(this.sellingPrice.getText()));
|
|
|
283 |
item.setWeight(Double.parseDouble(this.weight.getText()));
|
|
|
284 |
item.setBestDealsText(bestDealsText.getText().trim());
|
|
|
285 |
item.setBestDealsValue(Double.parseDouble(bestDealsValue.getText().trim()));
|
|
|
286 |
item.setBestSellingRank(Long.parseLong(bestSellingRank.getText().trim()));
|
|
|
287 |
item.setDefaultForEntity(defaultForEntity.getValue());
|
|
|
288 |
for(int row = 0; row < pricingTable.getRowCount(); row++) {
|
|
|
289 |
long vendorId = Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID));
|
|
|
290 |
double mop = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_MOP));
|
|
|
291 |
double dp = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_DP));
|
|
|
292 |
double tp = Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_TP));
|
|
|
293 |
item.getVendorPricings().get(vendorId)[Item.INDEX_MOP] = mop;
|
|
|
294 |
item.getVendorPricings().get(vendorId)[Item.INDEX_DP] = dp;
|
|
|
295 |
item.getVendorPricings().get(vendorId)[Item.INDEX_TP] = tp;
|
|
|
296 |
item.setMop(mop);
|
|
|
297 |
item.setDealerPrice(dp);
|
|
|
298 |
item.setTransferPrice(tp);
|
|
|
299 |
}*/
|
|
|
300 |
}
|
|
|
301 |
|
|
|
302 |
private void updateVendorPrices(final long vendorId, final int row) {
|
|
|
303 |
String mop = pricingTable.getText(row, TABLE_INDEX_MOP);
|
|
|
304 |
String dp = pricingTable.getText(row, TABLE_INDEX_DP);
|
|
|
305 |
String tp = pricingTable.getText(row, TABLE_INDEX_TP);
|
|
|
306 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
|
|
|
307 |
pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
|
|
308 |
@Override
|
|
|
309 |
public void onPriceUpdate(double mop, double dp, double tp) {
|
|
|
310 |
pricingTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
|
|
311 |
pricingTable.setText(row, TABLE_INDEX_DP, dp + "");
|
|
|
312 |
pricingTable.setText(row, TABLE_INDEX_TP, tp + "");
|
|
|
313 |
/*item.getVendorPricings().get(vendorId)[Item.INDEX_MOP] = mop;
|
|
|
314 |
item.getVendorPricings().get(vendorId)[Item.INDEX_DP] = dp;
|
|
|
315 |
item.getVendorPricings().get(vendorId)[Item.INDEX_TP] = tp;
|
|
|
316 |
item.setMop(mop);
|
|
|
317 |
item.setDealerPrice(dp);
|
|
|
318 |
item.setTransferPrice(tp);*/
|
|
|
319 |
}
|
|
|
320 |
});
|
|
|
321 |
pricesDialog.show();
|
|
|
322 |
}
|
|
|
323 |
|
|
|
324 |
private boolean isItemChanged() {
|
|
|
325 |
if(!productGroup.getText().trim().equals(item.getProductGroup())) {
|
|
|
326 |
return true;
|
|
|
327 |
}
|
|
|
328 |
if(!brand.getText().trim().equals(item.getBrand())) {
|
|
|
329 |
return true;
|
|
|
330 |
}
|
|
|
331 |
if(!modelNumber.getText().trim().equals(item.getModelNumber())) {
|
|
|
332 |
return true;
|
|
|
333 |
}
|
|
|
334 |
if(!modelName.getText().trim().equals(item.getModelName())) {
|
|
|
335 |
return true;
|
|
|
336 |
}
|
|
|
337 |
if(!color.getText().trim().equals(item.getColor())) {
|
|
|
338 |
return true;
|
|
|
339 |
}
|
|
|
340 |
if(!comments.getText().trim().equals(item.getComments())) {
|
|
|
341 |
return true;
|
|
|
342 |
}
|
|
|
343 |
try {
|
|
|
344 |
if(item.getMrp() != Double.parseDouble(mrp.getText().trim())) {
|
|
|
345 |
return true;
|
|
|
346 |
}
|
|
|
347 |
} catch(NumberFormatException ex) {
|
|
|
348 |
Window.alert("Invalid MRP format");
|
|
|
349 |
throw new NumberFormatException();
|
|
|
350 |
}
|
|
|
351 |
try {
|
|
|
352 |
if(item.getSellingPrice() != Double.parseDouble(sellingPrice.getText().trim())) {
|
|
|
353 |
return true;
|
|
|
354 |
}
|
|
|
355 |
} catch(NumberFormatException ex) {
|
| 2027 |
ankur.sing |
356 |
Window.alert("Invalid Selling Price format");
|
|
|
357 |
throw new NumberFormatException();
|
|
|
358 |
}
|
| 2066 |
ankur.sing |
359 |
try {
|
|
|
360 |
if(item.getWeight() != Double.parseDouble(weight.getText().trim())) {
|
|
|
361 |
return true;
|
|
|
362 |
}
|
|
|
363 |
} catch(NumberFormatException ex) {
|
| 2027 |
ankur.sing |
364 |
Window.alert("Invalid Weight format");
|
|
|
365 |
throw new NumberFormatException();
|
|
|
366 |
}
|
| 2066 |
ankur.sing |
367 |
if(!bestDealsText.getText().trim().equals(item.getBestDealsText())) {
|
|
|
368 |
return true;
|
|
|
369 |
}
|
|
|
370 |
try {
|
|
|
371 |
if(item.getBestDealsValue() != Double.parseDouble(bestDealsValue.getText().trim())) {
|
|
|
372 |
return true;
|
|
|
373 |
}
|
|
|
374 |
} catch(NumberFormatException ex) {
|
| 2027 |
ankur.sing |
375 |
Window.alert("Invalid Best Deals Value format");
|
|
|
376 |
throw new NumberFormatException();
|
|
|
377 |
}
|
| 2066 |
ankur.sing |
378 |
try{
|
|
|
379 |
if(item.getBestSellingRank() != Long.parseLong(bestSellingRank.getText().trim())) {
|
|
|
380 |
return true;
|
| 1992 |
ankur.sing |
381 |
}
|
| 2066 |
ankur.sing |
382 |
} catch (NumberFormatException ex) {
|
|
|
383 |
Window.alert("Invalid Best Selling Rank format");
|
|
|
384 |
throw new NumberFormatException();
|
|
|
385 |
}
|
|
|
386 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
|
|
387 |
return true;
|
|
|
388 |
}
|
|
|
389 |
|
|
|
390 |
double[] vendorPrices;
|
|
|
391 |
long vendorId;
|
|
|
392 |
for(int row = 0; row < pricingTable.getRowCount(); row++) {
|
|
|
393 |
vendorId = Long.parseLong(pricingTable.getText(row, TABLE_INDEX_VENDORID));
|
|
|
394 |
vendorPrices = item.getVendorPricings().get(vendorId);
|
|
|
395 |
if(vendorPrices[Item.INDEX_MOP] != Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_MOP))) {
|
|
|
396 |
return true;
|
|
|
397 |
}
|
|
|
398 |
if(vendorPrices[Item.INDEX_DP] != Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_DP))) {
|
|
|
399 |
return true;
|
|
|
400 |
}
|
|
|
401 |
if(vendorPrices[Item.INDEX_TP] != Double.parseDouble(pricingTable.getText(row, TABLE_INDEX_TP))) {
|
|
|
402 |
return true;
|
|
|
403 |
}
|
|
|
404 |
}
|
|
|
405 |
return false;
|
|
|
406 |
}
|
|
|
407 |
|
|
|
408 |
private boolean validatePrices() {
|
|
|
409 |
if(newItem.getSellingPrice() > newItem.getMrp()) {
|
|
|
410 |
Window.alert("Selling price cannot be more than MRP");
|
|
|
411 |
return false;
|
|
|
412 |
}
|
|
|
413 |
for(Entry<Long, double[]> v : newItem.getVendorPricings().entrySet()) {
|
|
|
414 |
if(newItem.getMrp() < v.getValue()[Item.INDEX_MOP]) {
|
|
|
415 |
Window.alert("MRP cannot be less than MOP. Vendor: " + v.getKey());
|
|
|
416 |
return false;
|
|
|
417 |
}
|
|
|
418 |
if(v.getValue()[Item.INDEX_TP] > v.getValue()[Item.INDEX_MOP]) {
|
|
|
419 |
Window.alert("Transfer Price cannot be more than MOP. Vendor: " + v.getKey());
|
|
|
420 |
return false;
|
|
|
421 |
}
|
|
|
422 |
}
|
|
|
423 |
return true;
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
/*
|
| 1992 |
ankur.sing |
427 |
@UiHandler("sellingPrice")
|
|
|
428 |
void onSPUpdate(KeyPressEvent keyPressEvent) {
|
|
|
429 |
if(Double.parseDouble(sellingPrice.getText()) != item.getSellingPrice()) {
|
|
|
430 |
sellingPrice.getElement().addClassName(style.fieldChanged());
|
|
|
431 |
} else {
|
|
|
432 |
sellingPrice.getElement().addClassName(style.greenLabel());
|
|
|
433 |
}
|
|
|
434 |
}
|
| 2066 |
ankur.sing |
435 |
|
| 1992 |
ankur.sing |
436 |
@UiHandler("mop")
|
|
|
437 |
void onMOPUpdate(KeyPressEvent keyPressEvent) {
|
|
|
438 |
if(Double.parseDouble(mop.getText()) != item.getMop()) {
|
|
|
439 |
mop.getElement().addClassName(style.fieldChanged());
|
|
|
440 |
} else {
|
|
|
441 |
mop.getElement().addClassName(style.greenLabel());
|
|
|
442 |
}
|
|
|
443 |
}
|
| 2066 |
ankur.sing |
444 |
|
| 1992 |
ankur.sing |
445 |
@UiHandler("dealerPrice")
|
|
|
446 |
void onDPUpdate(KeyPressEvent keyPressEvent) {
|
|
|
447 |
if(Double.parseDouble(dealerPrice.getText()) != item.getDealerPrice()) {
|
|
|
448 |
dealerPrice.getElement().addClassName(style.fieldChanged());
|
|
|
449 |
} else {
|
|
|
450 |
dealerPrice.getElement().addClassName(style.greenLabel());
|
|
|
451 |
}
|
|
|
452 |
}
|
| 2066 |
ankur.sing |
453 |
|
| 1992 |
ankur.sing |
454 |
@UiHandler("transferPrice")
|
|
|
455 |
void onTPUpdate(KeyPressEvent keyPressEvent) {
|
|
|
456 |
if(Double.parseDouble(transferPrice.getText()) != item.getTransferPrice()) {
|
|
|
457 |
transferPrice.getElement().addClassName(style.fieldChanged());
|
|
|
458 |
} else {
|
|
|
459 |
transferPrice.getElement().addClassName(style.greenLabel());
|
|
|
460 |
}
|
|
|
461 |
}
|
| 2066 |
ankur.sing |
462 |
|
| 1992 |
ankur.sing |
463 |
@UiHandler("weight")
|
|
|
464 |
void onWeightUpdate(KeyPressEvent keyPressEvent) {
|
|
|
465 |
if(Double.parseDouble(weight.getText()) != item.getWeight()) {
|
|
|
466 |
weight.getElement().addClassName(style.fieldChanged());
|
|
|
467 |
} else {
|
|
|
468 |
weight.getElement().addClassName(style.greenLabel());
|
|
|
469 |
}
|
|
|
470 |
}
|
| 2066 |
ankur.sing |
471 |
|
| 1992 |
ankur.sing |
472 |
void applyDefaultStyles() {
|
|
|
473 |
sellingPrice.getElement().addClassName(style.greenLabel());
|
|
|
474 |
mop.getElement().addClassName(style.greenLabel());
|
|
|
475 |
dealerPrice.getElement().addClassName(style.greenLabel());
|
|
|
476 |
transferPrice.getElement().addClassName(style.greenLabel());
|
|
|
477 |
weight.getElement().addClassName(style.greenLabel());
|
|
|
478 |
}*/
|
| 2066 |
ankur.sing |
479 |
|
| 1961 |
ankur.sing |
480 |
}
|