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