| 1961 |
ankur.sing |
1 |
package in.shop2020.catalog.dashboard.client;
|
|
|
2 |
|
|
|
3 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| 3558 |
rajveer |
4 |
import in.shop2020.catalog.dashboard.shared.SourcePricings;
|
| 2066 |
ankur.sing |
5 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
| 2119 |
ankur.sing |
6 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
|
|
7 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
| 1961 |
ankur.sing |
8 |
|
|
|
9 |
import java.util.Date;
|
| 2066 |
ankur.sing |
10 |
import java.util.HashMap;
|
| 1992 |
ankur.sing |
11 |
import java.util.Map;
|
|
|
12 |
import java.util.Map.Entry;
|
| 1961 |
ankur.sing |
13 |
|
|
|
14 |
import com.google.gwt.core.client.GWT;
|
|
|
15 |
import com.google.gwt.event.dom.client.ClickEvent;
|
| 1992 |
ankur.sing |
16 |
import com.google.gwt.event.dom.client.ClickHandler;
|
|
|
17 |
import com.google.gwt.resources.client.CssResource;
|
| 1961 |
ankur.sing |
18 |
import com.google.gwt.uibinder.client.UiBinder;
|
|
|
19 |
import com.google.gwt.uibinder.client.UiField;
|
|
|
20 |
import com.google.gwt.user.client.Window;
|
| 2126 |
ankur.sing |
21 |
import com.google.gwt.user.client.rpc.AsyncCallback;
|
| 1961 |
ankur.sing |
22 |
import com.google.gwt.user.client.ui.Button;
|
| 2066 |
ankur.sing |
23 |
import com.google.gwt.user.client.ui.CheckBox;
|
| 1992 |
ankur.sing |
24 |
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
25 |
import com.google.gwt.user.client.ui.HTMLTable.Cell;
|
| 1961 |
ankur.sing |
26 |
import com.google.gwt.user.client.ui.Label;
|
|
|
27 |
import com.google.gwt.user.client.ui.ResizeComposite;
|
|
|
28 |
import com.google.gwt.user.client.ui.TextBox;
|
|
|
29 |
import com.google.gwt.user.client.ui.Widget;
|
| 2068 |
ankur.sing |
30 |
import com.google.gwt.user.datepicker.client.DateBox;
|
| 1961 |
ankur.sing |
31 |
|
| 2427 |
ankur.sing |
32 |
/**
|
|
|
33 |
* Panel contains fields for item details. Some of these fields are editable.
|
|
|
34 |
* It also contains vendor item pricings, vendor item keys, and item availability in tabular format.
|
|
|
35 |
* Item availability is made invisible for time being
|
|
|
36 |
*/
|
| 1961 |
ankur.sing |
37 |
public class ItemDetails extends ResizeComposite {
|
|
|
38 |
|
| 2359 |
ankur.sing |
39 |
private final int TABLE_INDEX_MAPPING_VENDOR_DESC = 0,
|
|
|
40 |
TABLE_INDEX_MAPPING_ITEM_KEY = 1,
|
|
|
41 |
TABLE_INDEX_MAPPING_BUTTON = 2,
|
|
|
42 |
TABLE_INDEX_MAPPING_VENDORID = 3,
|
|
|
43 |
TABLE_INDEX_MAPPING_ITEM_KEY_OLD = 4;
|
|
|
44 |
|
|
|
45 |
private final int TABLE_INDEX_PRICING_VENDOR_DESC = 0,
|
| 3558 |
rajveer |
46 |
TABLE_INDEX_PRICING_MOP = 1,
|
| 2359 |
ankur.sing |
47 |
TABLE_INDEX_PRICING_DP = 2,
|
|
|
48 |
TABLE_INDEX_PRICING_TP = 3,
|
|
|
49 |
TABLE_INDEX_PRICING_BUTTON = 4,
|
|
|
50 |
TABLE_INDEX_PRICING_VENDORID = 5;
|
| 3558 |
rajveer |
51 |
|
|
|
52 |
private final int TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC = 0,
|
|
|
53 |
TABLE_INDEX_SOURCE_PRICING_MRP = 1,
|
|
|
54 |
TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE = 2,
|
|
|
55 |
TABLE_INDEX_SOURCE_PRICING_BUTTON = 3,
|
|
|
56 |
TABLE_INDEX_SOURCE_PRICING_SOURCE_ID = 4;
|
|
|
57 |
|
| 2119 |
ankur.sing |
58 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0,
|
|
|
59 |
TABLE_INDEX_WAREHOUSE_DESC = 1,
|
|
|
60 |
TABLE_INDEX_WAREHOUSE_INV = 2;
|
| 2359 |
ankur.sing |
61 |
|
|
|
62 |
private final String PRICE_WIDTH = "100px", VENDOR_DESC_WIDTH = "130px",
|
|
|
63 |
VENDOR_ID_WIDTH = "100px", ITEM_KEY_WIDTH = "200px",
|
|
|
64 |
BUTTON_WIDTH = "50px";
|
| 2066 |
ankur.sing |
65 |
|
|
|
66 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
|
|
67 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
| 2126 |
ankur.sing |
68 |
private final CatalogServiceAsync catalogService = GWT.create(CatalogService.class);
|
| 2066 |
ankur.sing |
69 |
|
| 1961 |
ankur.sing |
70 |
|
| 2066 |
ankur.sing |
71 |
interface ItemDetailStyle extends CssResource{
|
|
|
72 |
String greenLabel();
|
|
|
73 |
String fieldChanged();
|
|
|
74 |
}
|
| 1961 |
ankur.sing |
75 |
|
| 2105 |
ankur.sing |
76 |
private Item item, newItem;
|
| 2489 |
ankur.sing |
77 |
private CatalogDashboard catalogDashboardPanel;
|
| 2066 |
ankur.sing |
78 |
|
|
|
79 |
@UiField ItemDetailStyle style;
|
|
|
80 |
@UiField Label itemId;
|
|
|
81 |
@UiField TextBox productGroup, brand, modelNumber, modelName, color;
|
| 2105 |
ankur.sing |
82 |
@UiField Label contentCategory, catalogItemId;
|
| 2359 |
ankur.sing |
83 |
@UiField TextBox statusDesc, comments;
|
| 2105 |
ankur.sing |
84 |
@UiField TextBox sellingPrice, mrp, weight;
|
|
|
85 |
@UiField Label addedOn, retireDate, updatedOn;
|
| 2066 |
ankur.sing |
86 |
@UiField Label itemStatus;
|
|
|
87 |
@UiField TextBox bestDealsText, bestDealsValue;
|
|
|
88 |
@UiField FlexTable headerAvailability, availabilityTable;
|
| 2427 |
ankur.sing |
89 |
@UiField FlexTable headerVendorItemKey, tableVendorItemKey;
|
|
|
90 |
@UiField FlexTable headerVendorPrices, tableVendorPrices;
|
| 3558 |
rajveer |
91 |
@UiField FlexTable headerSourcePrices, tableSourcePrices;
|
| 2066 |
ankur.sing |
92 |
@UiField TextBox bestSellingRank;
|
| 3359 |
chandransh |
93 |
@UiField TextBox expectedDelay;
|
|
|
94 |
@UiField TextBox preferredWarehouse;
|
| 2252 |
ankur.sing |
95 |
@UiField CheckBox defaultForEntity, risky;
|
| 2068 |
ankur.sing |
96 |
@UiField DateBox startDate;
|
| 2066 |
ankur.sing |
97 |
|
|
|
98 |
public ItemDetails(Item item){
|
| 2105 |
ankur.sing |
99 |
this();
|
| 2066 |
ankur.sing |
100 |
setItemDetails(item);
|
|
|
101 |
}
|
|
|
102 |
|
|
|
103 |
public ItemDetails() {
|
|
|
104 |
initWidget(uiBinder.createAndBindUi(this));
|
|
|
105 |
initAvailabilityHeader();
|
| 2427 |
ankur.sing |
106 |
initVendorKeysHeader();
|
|
|
107 |
initVendorPricingHeader();
|
| 3558 |
rajveer |
108 |
initSourcePricingHeader();
|
| 2119 |
ankur.sing |
109 |
|
| 2105 |
ankur.sing |
110 |
headerAvailability.setVisible(false);
|
|
|
111 |
availabilityTable.setVisible(false);
|
| 2066 |
ankur.sing |
112 |
}
|
|
|
113 |
|
| 2427 |
ankur.sing |
114 |
/**
|
|
|
115 |
* Sets the UI fields with item object attributes
|
|
|
116 |
* Also populates tables for vendor prices, keys and item availability
|
|
|
117 |
* @param item
|
|
|
118 |
*/
|
| 2066 |
ankur.sing |
119 |
public void setItemDetails(Item item){
|
|
|
120 |
this.item = item;
|
|
|
121 |
itemId.setText(item.getId()+"");
|
|
|
122 |
productGroup.setText(item.getProductGroup());
|
|
|
123 |
brand.setText(item.getBrand());
|
|
|
124 |
modelNumber.setText(item.getModelNumber());
|
|
|
125 |
modelName.setText(item.getModelName());
|
|
|
126 |
color.setText(item.getColor());
|
|
|
127 |
|
| 2359 |
ankur.sing |
128 |
statusDesc.setText(item.getItemStatusDesc());
|
| 2105 |
ankur.sing |
129 |
contentCategory.setText(item.getContentCategory()+"");
|
| 2066 |
ankur.sing |
130 |
comments.setText(item.getComments());
|
|
|
131 |
catalogItemId.setText(item.getCatalogItemId() + "");
|
|
|
132 |
|
| 2489 |
ankur.sing |
133 |
mrp.setText(item.getMrp() != null ? item.getMrp()+"" : "");
|
|
|
134 |
sellingPrice.setText(item.getSellingPrice() != null ? item.getSellingPrice()+"" : "");
|
|
|
135 |
weight.setText(item.getWeight() != null ? item.getWeight()+"" : "");
|
| 3359 |
chandransh |
136 |
expectedDelay.setValue(item.getExpectedDelay()+"");
|
|
|
137 |
preferredWarehouse.setValue(item.getPreferredWarehouse()+"");
|
| 2068 |
ankur.sing |
138 |
|
|
|
139 |
startDate.setValue(new Date(item.getStartDate()));
|
|
|
140 |
addedOn.setText(Utils.getDisplayableDate(item.getAddedOn()));
|
|
|
141 |
retireDate.setText(Utils.getDisplayableDate(item.getRetireDate()));
|
|
|
142 |
updatedOn.setText(Utils.getDisplayableDate(item.getUpdatedOn()));
|
| 1992 |
ankur.sing |
143 |
|
| 2066 |
ankur.sing |
144 |
bestDealsText.setText(item.getBestDealsText());
|
| 2489 |
ankur.sing |
145 |
bestDealsValue.setText(item.getBestDealsValue() != null ? item.getBestDealsValue()+"" : "");
|
|
|
146 |
bestSellingRank.setText(item.getBestSellingRank() != null ? item.getBestSellingRank()+"" : "");
|
| 2066 |
ankur.sing |
147 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
| 2252 |
ankur.sing |
148 |
risky.setValue(item.isRisky());
|
| 1992 |
ankur.sing |
149 |
|
| 2066 |
ankur.sing |
150 |
itemStatus.setText(item.getItemStatus());
|
|
|
151 |
|
|
|
152 |
updateAvailabilityTable(item.getAvailability());
|
| 2427 |
ankur.sing |
153 |
updateVendorKeysTable(item.getVendorKeysMap());
|
|
|
154 |
updateVendorPricingTable(item.getVendorPricesMap());
|
| 3558 |
rajveer |
155 |
updateSourcePricingTable(item.getSourcePricesMap());
|
| 1992 |
ankur.sing |
156 |
}
|
| 2066 |
ankur.sing |
157 |
|
| 2427 |
ankur.sing |
158 |
/**
|
|
|
159 |
* initialise item availability table header.
|
|
|
160 |
*/
|
| 2066 |
ankur.sing |
161 |
private void initAvailabilityHeader(){
|
|
|
162 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
| 2105 |
ankur.sing |
163 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
|
| 2066 |
ankur.sing |
164 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
|
|
165 |
|
|
|
166 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_ID, "Warehouse Id");
|
|
|
167 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
|
|
168 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
|
| 1992 |
ankur.sing |
169 |
|
|
|
170 |
}
|
| 2066 |
ankur.sing |
171 |
|
| 2427 |
ankur.sing |
172 |
/**
|
|
|
173 |
* initialises vendor item key table header. Creates an Add button and
|
|
|
174 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
175 |
* a new vendor item key.
|
|
|
176 |
*/
|
|
|
177 |
private void initVendorKeysHeader(){
|
|
|
178 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
179 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
180 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
|
|
181 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
|
|
182 |
headerVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
| 2119 |
ankur.sing |
183 |
|
| 2427 |
ankur.sing |
184 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDORID, "Vendor Id");
|
|
|
185 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_VENDOR_DESC, "Vendor");
|
|
|
186 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY, "Item Key");
|
|
|
187 |
headerVendorItemKey.setText(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, "Prev Item Key");
|
| 2119 |
ankur.sing |
188 |
|
| 2427 |
ankur.sing |
189 |
headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_VENDORID, false);
|
|
|
190 |
headerVendorItemKey.getCellFormatter().setVisible(0, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 2359 |
ankur.sing |
191 |
|
| 2119 |
ankur.sing |
192 |
Button addButton = new Button("Add");
|
| 2427 |
ankur.sing |
193 |
headerVendorItemKey.setWidget(0, TABLE_INDEX_MAPPING_BUTTON, addButton);
|
| 2119 |
ankur.sing |
194 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
195 |
@Override
|
|
|
196 |
public void onClick(ClickEvent event) {
|
| 2126 |
ankur.sing |
197 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
|
|
198 |
modelNumber.getText().trim(), color.getText().trim());
|
| 2119 |
ankur.sing |
199 |
vendorMappingDialog.updateButton.setText("Add");
|
|
|
200 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
|
|
201 |
@Override
|
|
|
202 |
public boolean onUpdate(String key, long vendorId) {
|
| 2427 |
ankur.sing |
203 |
int row = tableVendorItemKey.getRowCount();
|
|
|
204 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
205 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
206 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
|
|
207 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
| 2119 |
ankur.sing |
208 |
|
| 2427 |
ankur.sing |
209 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDORID, vendorId + "");
|
|
|
210 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
|
|
211 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, key);
|
|
|
212 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, key);
|
| 2359 |
ankur.sing |
213 |
|
| 2427 |
ankur.sing |
214 |
tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_VENDORID, false);
|
|
|
215 |
tableVendorItemKey.getCellFormatter().setVisible(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 2119 |
ankur.sing |
216 |
return true;
|
|
|
217 |
}
|
|
|
218 |
});
|
|
|
219 |
vendorMappingDialog.show();
|
|
|
220 |
}
|
|
|
221 |
});
|
|
|
222 |
}
|
|
|
223 |
|
| 2427 |
ankur.sing |
224 |
/**
|
|
|
225 |
* initialises vendor prices table header. Creates an Add button and
|
|
|
226 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
227 |
* a prices for a new vendor
|
|
|
228 |
*/
|
|
|
229 |
private void initVendorPricingHeader(){
|
|
|
230 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
231 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
232 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
|
|
233 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
|
|
234 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
|
|
235 |
headerVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
| 2066 |
ankur.sing |
236 |
|
| 2427 |
ankur.sing |
237 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDORID, "Vendor Id");
|
|
|
238 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_VENDOR_DESC, "Vendor");
|
|
|
239 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_MOP, "MOP");
|
|
|
240 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_DP, "Dealer Price");
|
|
|
241 |
headerVendorPrices.setText(0, TABLE_INDEX_PRICING_TP, "Transfer Price");
|
| 2105 |
ankur.sing |
242 |
|
| 2427 |
ankur.sing |
243 |
headerVendorPrices.getCellFormatter().setVisible(0, TABLE_INDEX_PRICING_VENDORID, false);
|
| 2359 |
ankur.sing |
244 |
|
| 2105 |
ankur.sing |
245 |
Button addButton = new Button("Add");
|
| 2427 |
ankur.sing |
246 |
headerVendorPrices.setWidget(0, TABLE_INDEX_PRICING_BUTTON, addButton);
|
| 2105 |
ankur.sing |
247 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
248 |
@Override
|
|
|
249 |
public void onClick(ClickEvent event) {
|
| 2119 |
ankur.sing |
250 |
VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
|
|
|
251 |
vendorPricesDialog.updateButton.setText("Add");
|
|
|
252 |
vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| 2105 |
ankur.sing |
253 |
@Override
|
| 2119 |
ankur.sing |
254 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
| 2105 |
ankur.sing |
255 |
if(!vendorExists(vendorId)) {
|
|
|
256 |
Window.alert("Vendor already exists");
|
|
|
257 |
return false;
|
|
|
258 |
}
|
| 2119 |
ankur.sing |
259 |
/*if(!validateVendorPrices(mop, dp, tp)) {
|
| 2105 |
ankur.sing |
260 |
return false;
|
| 2119 |
ankur.sing |
261 |
}*/
|
| 2427 |
ankur.sing |
262 |
int row = tableVendorPrices.getRowCount();
|
|
|
263 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
264 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
265 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
|
|
266 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
|
|
267 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
| 2105 |
ankur.sing |
268 |
|
| 2427 |
ankur.sing |
269 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDORID, vendorId + "");
|
|
|
270 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
|
|
271 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
|
|
272 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
|
|
273 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
| 2359 |
ankur.sing |
274 |
|
| 2427 |
ankur.sing |
275 |
tableVendorPrices.getCellFormatter().setVisible(row, TABLE_INDEX_PRICING_VENDORID, false);
|
| 2105 |
ankur.sing |
276 |
return true;
|
|
|
277 |
}
|
|
|
278 |
});
|
| 2119 |
ankur.sing |
279 |
vendorPricesDialog.show();
|
| 2105 |
ankur.sing |
280 |
}
|
|
|
281 |
});
|
| 2066 |
ankur.sing |
282 |
}
|
| 2105 |
ankur.sing |
283 |
|
| 2427 |
ankur.sing |
284 |
/**
|
| 3558 |
rajveer |
285 |
* initialises source prices table header. Creates an Add button and
|
|
|
286 |
* adds click event listener to it to create and pop up a dialog for adding
|
|
|
287 |
* a prices for a new source
|
|
|
288 |
*/
|
|
|
289 |
private void initSourcePricingHeader(){
|
|
|
290 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, VENDOR_ID_WIDTH);
|
|
|
291 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, VENDOR_DESC_WIDTH);
|
|
|
292 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_MRP, PRICE_WIDTH);
|
|
|
293 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, PRICE_WIDTH);
|
|
|
294 |
headerSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_BUTTON, BUTTON_WIDTH);
|
|
|
295 |
|
|
|
296 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, "Source Id");
|
|
|
297 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, "Source");
|
|
|
298 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_MRP, "MRP");
|
|
|
299 |
headerSourcePrices.setText(0, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, "Selling Price");
|
|
|
300 |
|
|
|
301 |
headerSourcePrices.getCellFormatter().setVisible(0, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
|
|
302 |
|
|
|
303 |
Button addButton = new Button("Add");
|
|
|
304 |
headerSourcePrices.setWidget(0, TABLE_INDEX_SOURCE_PRICING_BUTTON, addButton);
|
|
|
305 |
addButton.addClickHandler(new ClickHandler() {
|
|
|
306 |
@Override
|
|
|
307 |
public void onClick(ClickEvent event) {
|
| 3567 |
rajveer |
308 |
SourcePricesDialog sourcePricesDialog = new SourcePricesDialog(mrp.getText().trim(), sellingPrice.getText().trim());
|
|
|
309 |
//SourcePricesDialog sourcePricesDialog = new SourcePricesDialog();
|
| 3558 |
rajveer |
310 |
sourcePricesDialog.updateButton.setText("Add");
|
|
|
311 |
sourcePricesDialog.setSourcePriceUpdateListener(new SourcePricesDialog.SourcePriceUpdateListener() {
|
|
|
312 |
@Override
|
|
|
313 |
public boolean onUpdate(double mrp, double sellingPrice, long sourceId) {
|
|
|
314 |
if(!sourceExists(sourceId)) {
|
|
|
315 |
Window.alert("Source already exists");
|
|
|
316 |
return false;
|
|
|
317 |
}
|
|
|
318 |
|
|
|
319 |
int row = tableSourcePrices.getRowCount();
|
|
|
320 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, VENDOR_ID_WIDTH);
|
|
|
321 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, VENDOR_DESC_WIDTH);
|
|
|
322 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_MRP, PRICE_WIDTH);
|
|
|
323 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, PRICE_WIDTH);
|
|
|
324 |
|
|
|
325 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, sourceId + "");
|
|
|
326 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, Utils.getSourceDesc(sourceId));
|
|
|
327 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_MRP, mrp + "");
|
|
|
328 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, sellingPrice + "");
|
|
|
329 |
|
|
|
330 |
tableSourcePrices.getCellFormatter().setVisible(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
|
|
331 |
return true;
|
|
|
332 |
}
|
|
|
333 |
});
|
|
|
334 |
sourcePricesDialog.show();
|
|
|
335 |
}
|
|
|
336 |
});
|
|
|
337 |
}
|
|
|
338 |
|
|
|
339 |
/**
|
| 2427 |
ankur.sing |
340 |
* Clear and populate item availability table.
|
|
|
341 |
* @param availabilityMap
|
|
|
342 |
*/
|
| 1992 |
ankur.sing |
343 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
|
|
344 |
availabilityTable.removeAllRows();
|
|
|
345 |
if(availabilityMap == null) {
|
|
|
346 |
return;
|
|
|
347 |
}
|
| 2066 |
ankur.sing |
348 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
| 2105 |
ankur.sing |
349 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_DESC, "300px");
|
| 2066 |
ankur.sing |
350 |
availabilityTable.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_INV, "128px");
|
|
|
351 |
|
| 1992 |
ankur.sing |
352 |
int i=0;
|
|
|
353 |
for(Entry<Long, Long> availability : availabilityMap.entrySet()){
|
| 2066 |
ankur.sing |
354 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_ID, availability.getKey() + "");
|
|
|
355 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
|
|
|
356 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
| 1992 |
ankur.sing |
357 |
i++;
|
|
|
358 |
}
|
|
|
359 |
}
|
| 2119 |
ankur.sing |
360 |
|
| 2427 |
ankur.sing |
361 |
/**
|
|
|
362 |
* Clear and populate vendor item key table with keys in the passed argument.
|
|
|
363 |
* With each row in the table, an edit button is created and click event listener
|
|
|
364 |
* is added to it to edit that vendor item key row.
|
|
|
365 |
* @param vendorKeysMap
|
|
|
366 |
*/
|
|
|
367 |
private void updateVendorKeysTable(Map<String, VendorItemMapping> vendorKeysMap){
|
|
|
368 |
tableVendorItemKey.removeAllRows();
|
| 2119 |
ankur.sing |
369 |
|
| 2427 |
ankur.sing |
370 |
if(vendorKeysMap == null || vendorKeysMap.isEmpty()) {
|
| 2119 |
ankur.sing |
371 |
return;
|
|
|
372 |
}
|
| 2427 |
ankur.sing |
373 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
374 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
375 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY, ITEM_KEY_WIDTH);
|
|
|
376 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_ITEM_KEY_OLD, ITEM_KEY_WIDTH);
|
|
|
377 |
tableVendorItemKey.getColumnFormatter().setWidth(TABLE_INDEX_MAPPING_BUTTON, BUTTON_WIDTH);
|
| 2066 |
ankur.sing |
378 |
|
| 2119 |
ankur.sing |
379 |
int i=0;
|
| 2427 |
ankur.sing |
380 |
for(Entry<String, VendorItemMapping> e : vendorKeysMap.entrySet()){
|
| 2359 |
ankur.sing |
381 |
VendorItemMapping vendorMapping = e.getValue();
|
| 2427 |
ankur.sing |
382 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDORID, vendorMapping.getVendorId() + "");
|
|
|
383 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
|
|
|
384 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY, vendorMapping.getItemKey());
|
|
|
385 |
tableVendorItemKey.setText(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, e.getKey().substring(e.getKey().indexOf(Item.KEY_SEPARATOR)+1));
|
| 2119 |
ankur.sing |
386 |
Button editButton = new Button("Edit");
|
| 2427 |
ankur.sing |
387 |
tableVendorItemKey.setWidget(i, TABLE_INDEX_MAPPING_BUTTON, editButton);
|
| 2119 |
ankur.sing |
388 |
editButton.addClickHandler(new ClickHandler() {
|
|
|
389 |
@Override
|
|
|
390 |
public void onClick(ClickEvent event) {
|
| 2427 |
ankur.sing |
391 |
Cell cell = tableVendorItemKey.getCellForEvent(event);
|
| 2119 |
ankur.sing |
392 |
int row = cell.getRowIndex();
|
| 2427 |
ankur.sing |
393 |
long vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
|
|
394 |
editVendorKey(vendorId, row);
|
| 2119 |
ankur.sing |
395 |
}
|
|
|
396 |
});
|
| 2427 |
ankur.sing |
397 |
tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_VENDORID, false);
|
|
|
398 |
tableVendorItemKey.getCellFormatter().setVisible(i, TABLE_INDEX_MAPPING_ITEM_KEY_OLD, false);
|
| 2359 |
ankur.sing |
399 |
i++;
|
| 2119 |
ankur.sing |
400 |
}
|
|
|
401 |
}
|
|
|
402 |
|
| 2427 |
ankur.sing |
403 |
/**
|
|
|
404 |
* Clear and populate vendor prices table with prices in the passed argument.
|
|
|
405 |
* With each row in the table, an edit button is created and click event listener
|
|
|
406 |
* is added to it to edit that vendor prices row.
|
|
|
407 |
* @param vendorPricingMap
|
|
|
408 |
*/
|
|
|
409 |
private void updateVendorPricingTable(Map<Long, VendorPricings> vendorPricingMap){
|
|
|
410 |
tableVendorPrices.removeAllRows();
|
| 2105 |
ankur.sing |
411 |
|
| 2119 |
ankur.sing |
412 |
if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
|
| 1992 |
ankur.sing |
413 |
return;
|
|
|
414 |
}
|
| 2427 |
ankur.sing |
415 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDORID, VENDOR_ID_WIDTH);
|
|
|
416 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_VENDOR_DESC, VENDOR_DESC_WIDTH);
|
|
|
417 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_MOP, PRICE_WIDTH);
|
|
|
418 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_DP, PRICE_WIDTH);
|
|
|
419 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_TP, PRICE_WIDTH);
|
|
|
420 |
tableVendorPrices.getColumnFormatter().setWidth(TABLE_INDEX_PRICING_BUTTON, BUTTON_WIDTH);
|
| 2066 |
ankur.sing |
421 |
|
|
|
422 |
|
| 1992 |
ankur.sing |
423 |
int i=0;
|
| 2119 |
ankur.sing |
424 |
for(VendorPricings vendorDetail : vendorPricingMap.values()){
|
| 2427 |
ankur.sing |
425 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDORID, vendorDetail.getVendorId() + "");
|
|
|
426 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
|
|
|
427 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_MOP, vendorDetail.getMop() + "");
|
|
|
428 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_DP, vendorDetail.getDealerPrice() + "");
|
|
|
429 |
tableVendorPrices.setText(i, TABLE_INDEX_PRICING_TP, vendorDetail.getTransferPrice() + "");
|
| 1992 |
ankur.sing |
430 |
Button editButton = new Button("Edit");
|
| 2427 |
ankur.sing |
431 |
tableVendorPrices.setWidget(i, TABLE_INDEX_PRICING_BUTTON, editButton);
|
| 1992 |
ankur.sing |
432 |
editButton.addClickHandler(new ClickHandler() {
|
|
|
433 |
@Override
|
|
|
434 |
public void onClick(ClickEvent event) {
|
| 2427 |
ankur.sing |
435 |
Cell cell = tableVendorPrices.getCellForEvent(event);
|
| 1992 |
ankur.sing |
436 |
int row = cell.getRowIndex();
|
| 2427 |
ankur.sing |
437 |
long vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
|
|
438 |
editVendorPrices(vendorId, row);
|
| 1992 |
ankur.sing |
439 |
}
|
|
|
440 |
});
|
| 2427 |
ankur.sing |
441 |
tableVendorPrices.getCellFormatter().setVisible(i, TABLE_INDEX_PRICING_VENDORID, false);
|
| 2359 |
ankur.sing |
442 |
i++;
|
| 1992 |
ankur.sing |
443 |
}
|
|
|
444 |
}
|
| 2066 |
ankur.sing |
445 |
|
| 3558 |
rajveer |
446 |
|
| 2427 |
ankur.sing |
447 |
/**
|
| 3558 |
rajveer |
448 |
* Clear and populate vendor prices table with prices in the passed argument.
|
|
|
449 |
* With each row in the table, an edit button is created and click event listener
|
|
|
450 |
* is added to it to edit that vendor prices row.
|
|
|
451 |
* @param sourcePricingMap
|
|
|
452 |
*/
|
|
|
453 |
private void updateSourcePricingTable(Map<Long, SourcePricings> sourcePricingMap){
|
|
|
454 |
tableSourcePrices.removeAllRows();
|
|
|
455 |
|
|
|
456 |
if(sourcePricingMap == null || sourcePricingMap.isEmpty()) {
|
|
|
457 |
return;
|
|
|
458 |
}
|
|
|
459 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, VENDOR_ID_WIDTH);
|
|
|
460 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, VENDOR_DESC_WIDTH);
|
|
|
461 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_MRP, PRICE_WIDTH);
|
|
|
462 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, PRICE_WIDTH);
|
|
|
463 |
tableSourcePrices.getColumnFormatter().setWidth(TABLE_INDEX_SOURCE_PRICING_BUTTON, BUTTON_WIDTH);
|
|
|
464 |
|
|
|
465 |
int i=0;
|
|
|
466 |
for(SourcePricings sourceDetail : sourcePricingMap.values()){
|
|
|
467 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, sourceDetail.getSourceId() + "");
|
|
|
468 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_DESC, Utils.getSourceDesc(sourceDetail.getSourceId()));
|
|
|
469 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_MRP, sourceDetail.getMrp() + "");
|
|
|
470 |
tableSourcePrices.setText(i, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, sourceDetail.getSellingPrice() + "");
|
|
|
471 |
|
|
|
472 |
Button editButton = new Button("Edit");
|
|
|
473 |
tableSourcePrices.setWidget(i, TABLE_INDEX_SOURCE_PRICING_BUTTON, editButton);
|
|
|
474 |
editButton.addClickHandler(new ClickHandler() {
|
|
|
475 |
@Override
|
|
|
476 |
public void onClick(ClickEvent event) {
|
|
|
477 |
Cell cell = tableSourcePrices.getCellForEvent(event);
|
|
|
478 |
int row = cell.getRowIndex();
|
|
|
479 |
long sourceId = Long.parseLong(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID));
|
|
|
480 |
editSourcePrices(sourceId, row);
|
|
|
481 |
}
|
|
|
482 |
});
|
|
|
483 |
tableSourcePrices.getCellFormatter().setVisible(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID, false);
|
|
|
484 |
i++;
|
|
|
485 |
}
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
|
|
|
489 |
/**
|
| 2427 |
ankur.sing |
490 |
* called on the click event of update item button in ItemActions
|
|
|
491 |
*/
|
| 2126 |
ankur.sing |
492 |
void updateItem() {
|
|
|
493 |
if(item == null) {
|
|
|
494 |
Window.alert("Please select an item to update.");
|
|
|
495 |
return;
|
|
|
496 |
}
|
| 2066 |
ankur.sing |
497 |
try {
|
| 2126 |
ankur.sing |
498 |
if(!createNewItem()) {
|
|
|
499 |
return;
|
|
|
500 |
}
|
| 2252 |
ankur.sing |
501 |
String paramsChanged = isItemChanged();
|
|
|
502 |
if(paramsChanged.equals("")) {
|
| 2066 |
ankur.sing |
503 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
|
|
504 |
return;
|
| 2252 |
ankur.sing |
505 |
} else {
|
|
|
506 |
paramsChanged = "You have changed following items.\n" + paramsChanged;
|
|
|
507 |
Window.alert(paramsChanged);
|
| 2066 |
ankur.sing |
508 |
}
|
|
|
509 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
510 |
ex.printStackTrace();
|
|
|
511 |
GWT.log("Number format exception");
|
|
|
512 |
}
|
|
|
513 |
if(!Utils.validateItem(newItem)) {
|
| 2066 |
ankur.sing |
514 |
return;
|
|
|
515 |
}
|
| 2126 |
ankur.sing |
516 |
|
|
|
517 |
/*if(!validatePrices()) {
|
|
|
518 |
return;
|
|
|
519 |
}*/
|
|
|
520 |
catalogService.updateItem(newItem, new AsyncCallback<Boolean>() {
|
|
|
521 |
@Override
|
|
|
522 |
public void onSuccess(Boolean result) {
|
|
|
523 |
if(result) {
|
|
|
524 |
item = newItem;
|
|
|
525 |
GWT.log("Item updated. Id = " + item.getId());
|
| 2489 |
ankur.sing |
526 |
catalogDashboardPanel.getItemListWidget().updateItem(item);
|
|
|
527 |
getFreshItemFromDB(item.getId());
|
| 2126 |
ankur.sing |
528 |
Window.alert("Item updated successfully.");
|
|
|
529 |
}
|
|
|
530 |
else {
|
|
|
531 |
GWT.log("Error updating item");
|
|
|
532 |
Window.alert("Error updating item");
|
|
|
533 |
}
|
|
|
534 |
}
|
|
|
535 |
@Override
|
|
|
536 |
public void onFailure(Throwable caught) {
|
|
|
537 |
caught.printStackTrace();
|
|
|
538 |
Window.alert("Error while updating item");
|
|
|
539 |
}
|
|
|
540 |
});
|
| 2066 |
ankur.sing |
541 |
}
|
| 2126 |
ankur.sing |
542 |
|
| 2489 |
ankur.sing |
543 |
private void getFreshItemFromDB(long id) {
|
|
|
544 |
catalogService.getItem(id, new AsyncCallback<Item>() {
|
|
|
545 |
@Override
|
|
|
546 |
public void onSuccess(Item result) {
|
|
|
547 |
setItemDetails(result);
|
|
|
548 |
}
|
|
|
549 |
@Override
|
|
|
550 |
public void onFailure(Throwable caught) {
|
|
|
551 |
caught.printStackTrace();
|
|
|
552 |
Window.alert("Unable to fetch item details.");
|
|
|
553 |
}
|
|
|
554 |
});
|
|
|
555 |
}
|
|
|
556 |
|
| 2427 |
ankur.sing |
557 |
/**
|
|
|
558 |
* This method is called while updating item.<br> It will create a new Item object and set
|
|
|
559 |
* its editable attributes with UI fields values and non-editable attributes with old Item
|
|
|
560 |
* object attributes. This new Item object is then passed to the service to update item in the database.
|
|
|
561 |
* <br>If update is successful, the old Item object is replaced with the new Item object.
|
|
|
562 |
* @return true if new Item object is created successfully
|
|
|
563 |
* <br>false if some error occurs due to NumberFormatException
|
|
|
564 |
*/
|
| 2126 |
ankur.sing |
565 |
private boolean createNewItem() {
|
| 2066 |
ankur.sing |
566 |
newItem = new Item();
|
| 2489 |
ankur.sing |
567 |
newItem.setId(item.getId());
|
|
|
568 |
newItem.setVendorCategory(item.getVendorCategory());
|
| 2066 |
ankur.sing |
569 |
newItem.setProductGroup(productGroup.getText().trim());
|
|
|
570 |
newItem.setBrand(brand.getText().trim());
|
|
|
571 |
newItem.setModelNumber(modelNumber.getText().trim());
|
|
|
572 |
newItem.setModelName(modelName.getText().trim());
|
|
|
573 |
newItem.setColor(color.getText().trim());
|
| 2119 |
ankur.sing |
574 |
newItem.setContentCategory(contentCategory.getText());
|
| 2066 |
ankur.sing |
575 |
newItem.setComments(comments.getText().trim());
|
|
|
576 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
| 2126 |
ankur.sing |
577 |
|
| 2068 |
ankur.sing |
578 |
try {
|
| 2126 |
ankur.sing |
579 |
if(!mrp.getText().trim().isEmpty()) {
|
|
|
580 |
double mrpValue = Double.parseDouble(mrp.getText().trim());
|
|
|
581 |
if(mrpValue <= 0) {
|
|
|
582 |
throw new NumberFormatException("Negative value of MRP");
|
|
|
583 |
}
|
|
|
584 |
newItem.setMrp(mrpValue);
|
|
|
585 |
}
|
| 2068 |
ankur.sing |
586 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
587 |
Window.alert("Invalid MRP format/value. Value shoule be greater than zero");
|
|
|
588 |
return false;
|
| 2068 |
ankur.sing |
589 |
}
|
|
|
590 |
try {
|
| 2126 |
ankur.sing |
591 |
if(!sellingPrice.getText().trim().isEmpty()) {
|
|
|
592 |
double spValue = Double.parseDouble(sellingPrice.getText().trim());
|
|
|
593 |
if(spValue <= 0) {
|
|
|
594 |
throw new NumberFormatException("Negative value of Selling price");
|
|
|
595 |
}
|
|
|
596 |
newItem.setSellingPrice(spValue);
|
|
|
597 |
}
|
|
|
598 |
} catch(NumberFormatException ex) {
|
|
|
599 |
Window.alert("Invalid Selling Price format/value. Value shoule be greater than zero");
|
|
|
600 |
return false;
|
| 2068 |
ankur.sing |
601 |
}
|
|
|
602 |
try {
|
| 2126 |
ankur.sing |
603 |
if(!weight.getText().trim().isEmpty()) {
|
|
|
604 |
double wtValue = Double.parseDouble(weight.getText().trim());
|
|
|
605 |
if(wtValue <= 0) {
|
|
|
606 |
throw new NumberFormatException("Negative value of Weight");
|
|
|
607 |
}
|
|
|
608 |
newItem.setWeight(wtValue);
|
|
|
609 |
}
|
| 2068 |
ankur.sing |
610 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
611 |
Window.alert("Invalid weight format/value. Value shoule be greater than zero");
|
|
|
612 |
return false;
|
| 2068 |
ankur.sing |
613 |
}
|
| 2126 |
ankur.sing |
614 |
try {
|
|
|
615 |
if(!startDate.getTextBox().getText().trim().equals("")) {
|
|
|
616 |
newItem.setStartDate(startDate.getValue().getTime());
|
|
|
617 |
}
|
|
|
618 |
} catch(Exception ex) {
|
|
|
619 |
Window.alert("Invalid start date format");
|
|
|
620 |
return false;
|
|
|
621 |
}
|
| 2066 |
ankur.sing |
622 |
newItem.setBestDealsText(bestDealsText.getText().trim());
|
| 2068 |
ankur.sing |
623 |
try {
|
| 2126 |
ankur.sing |
624 |
if(!bestDealsValue.getText().trim().equals("")) {
|
|
|
625 |
double bdValue = Double.parseDouble(bestDealsValue.getText().trim());
|
|
|
626 |
if(bdValue < 0) {
|
|
|
627 |
throw new NumberFormatException("Negative value of BestDealValue");
|
|
|
628 |
}
|
|
|
629 |
newItem.setBestDealsValue(bdValue);
|
|
|
630 |
}
|
| 2068 |
ankur.sing |
631 |
} catch(NumberFormatException ex) {
|
| 2126 |
ankur.sing |
632 |
Window.alert("Invalid best deal value format");
|
|
|
633 |
return false;
|
| 2068 |
ankur.sing |
634 |
}
|
| 3363 |
chandransh |
635 |
|
| 2068 |
ankur.sing |
636 |
try {
|
| 2126 |
ankur.sing |
637 |
if(!bestSellingRank.getText().trim().equals("")) {
|
|
|
638 |
long bsrValue = Long.parseLong(bestSellingRank.getText().trim());
|
|
|
639 |
if(bsrValue < 0) {
|
|
|
640 |
throw new NumberFormatException("Negative value of Best Selling Rank");
|
|
|
641 |
}
|
|
|
642 |
newItem.setBestSellingRank(bsrValue);
|
|
|
643 |
}
|
|
|
644 |
} catch(NumberFormatException ex) {
|
|
|
645 |
Window.alert("Invalid best selling rank format");
|
|
|
646 |
return false;
|
| 2068 |
ankur.sing |
647 |
}
|
| 2066 |
ankur.sing |
648 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
| 2252 |
ankur.sing |
649 |
newItem.setRisky(risky.getValue());
|
| 2119 |
ankur.sing |
650 |
|
| 3363 |
chandransh |
651 |
try {
|
|
|
652 |
String expectedDelayText = expectedDelay.getText().trim();
|
|
|
653 |
if(!expectedDelayText.equals("")){
|
|
|
654 |
newItem.setExpectedDelay(Integer.parseInt(expectedDelayText));
|
|
|
655 |
}
|
|
|
656 |
} catch(NumberFormatException nfe) {
|
|
|
657 |
Window.alert("Invalid expected delay");
|
|
|
658 |
return false;
|
|
|
659 |
}
|
|
|
660 |
|
|
|
661 |
try {
|
|
|
662 |
String preferredWarehouseText = preferredWarehouse.getText().trim();
|
|
|
663 |
if(!preferredWarehouseText.equals("")){
|
|
|
664 |
newItem.setPreferredWarehouse(Long.parseLong(preferredWarehouseText) + "");
|
|
|
665 |
}
|
|
|
666 |
}catch(NumberFormatException nfe){
|
|
|
667 |
Window.alert("Invalid Preferred Warehouse");
|
|
|
668 |
return false;
|
|
|
669 |
}
|
|
|
670 |
|
| 2126 |
ankur.sing |
671 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
|
|
672 |
Add the instance to map and set the map to the item instance created above.*/
|
|
|
673 |
Map<Long, VendorPricings> vendorPrices = new HashMap<Long, VendorPricings>();
|
| 2119 |
ankur.sing |
674 |
VendorPricings v;
|
| 2427 |
ankur.sing |
675 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
| 2119 |
ankur.sing |
676 |
v = new VendorPricings();
|
| 2427 |
ankur.sing |
677 |
v.setMop(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP)));
|
|
|
678 |
v.setDealerPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP)));
|
|
|
679 |
v.setTransferPrice(Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP)));
|
|
|
680 |
v.setVendorId(Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID)));
|
| 2126 |
ankur.sing |
681 |
vendorPrices.put(v.getVendorId(), v);
|
| 2066 |
ankur.sing |
682 |
}
|
| 2126 |
ankur.sing |
683 |
newItem.setVendorPricesMap(vendorPrices);
|
| 2359 |
ankur.sing |
684 |
newItem.setItemStatusDesc(statusDesc.getText().trim());
|
| 2427 |
ankur.sing |
685 |
|
| 2126 |
ankur.sing |
686 |
/*Create an instance of VendorPricings for each row in vendor pricing table. Set the vendor prices to the instance.
|
|
|
687 |
Add the instance to map and set the map to the item instance created above.*/
|
| 2359 |
ankur.sing |
688 |
Map<String, VendorItemMapping> vendorMappings = new HashMap<String, VendorItemMapping>();
|
| 2126 |
ankur.sing |
689 |
VendorItemMapping vMapping;
|
| 2427 |
ankur.sing |
690 |
for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
|
| 2126 |
ankur.sing |
691 |
vMapping = new VendorItemMapping();
|
| 2427 |
ankur.sing |
692 |
vMapping.setItemKey(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY));
|
|
|
693 |
vMapping.setVendorId(Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID)));
|
|
|
694 |
vendorMappings.put(vMapping.getVendorId() + Item.KEY_SEPARATOR + tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD), vMapping);
|
| 2119 |
ankur.sing |
695 |
}
|
| 2359 |
ankur.sing |
696 |
newItem.setVendorKeysMap(vendorMappings);
|
| 2119 |
ankur.sing |
697 |
|
| 3558 |
rajveer |
698 |
/*Create an instance of SourcePricings for each row in source pricing table. Set the source prices to the instance.
|
|
|
699 |
Add the instance to map and set the map to the item instance created above.*/
|
|
|
700 |
Map<Long, SourcePricings> sourcePrices = new HashMap<Long, SourcePricings>();
|
|
|
701 |
SourcePricings s;
|
|
|
702 |
for(int row = 0; row < tableSourcePrices.getRowCount(); row++) {
|
|
|
703 |
s = new SourcePricings();
|
|
|
704 |
s.setMrp(Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_MRP)));
|
|
|
705 |
s.setSellingPrice(Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE)));
|
|
|
706 |
s.setSourceId(Long.parseLong(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID)));
|
|
|
707 |
sourcePrices.put(s.getSourceId(), s);
|
|
|
708 |
}
|
|
|
709 |
newItem.setSourcePricesMap(sourcePrices);
|
|
|
710 |
|
| 2126 |
ankur.sing |
711 |
newItem.setContentCategoryId(item.getContentCategoryId());
|
|
|
712 |
newItem.setFeatureId(item.getFeatureId());
|
|
|
713 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
|
|
714 |
newItem.setAddedOn(item.getAddedOn());
|
|
|
715 |
newItem.setRetireDate(item.getRetireDate());
|
|
|
716 |
newItem.setUpdatedOn(item.getUpdatedOn());
|
|
|
717 |
newItem.setItemStatus(item.getItemStatus());
|
|
|
718 |
newItem.setOtherInfo(item.getOtherInfo());
|
|
|
719 |
newItem.setAvailability(item.getAvailability());
|
| 2119 |
ankur.sing |
720 |
|
| 2126 |
ankur.sing |
721 |
return true;
|
| 2066 |
ankur.sing |
722 |
}
|
|
|
723 |
|
| 2427 |
ankur.sing |
724 |
/**
|
|
|
725 |
* This method is called when Edit button is clicked corresponding to a row in
|
|
|
726 |
* vendor prices table. It will pop up a form to edit the vendor prices.
|
|
|
727 |
* @param vendorId
|
|
|
728 |
* @param row
|
|
|
729 |
*/
|
|
|
730 |
private void editVendorPrices(final long vendorId, final int row) {
|
|
|
731 |
String mop = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP);
|
|
|
732 |
String dp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP);
|
|
|
733 |
String tp = tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP);
|
| 2119 |
ankur.sing |
734 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
|
| 2105 |
ankur.sing |
735 |
pricesDialog.updateButton.setText("Update");
|
| 2119 |
ankur.sing |
736 |
pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| 2066 |
ankur.sing |
737 |
@Override
|
| 2119 |
ankur.sing |
738 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
|
|
739 |
if(!validateVendorPrices(mop, dp, tp)) {
|
| 2105 |
ankur.sing |
740 |
return false;
|
|
|
741 |
}
|
| 2427 |
ankur.sing |
742 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_MOP, mop + "");
|
|
|
743 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_DP, dp + "");
|
|
|
744 |
tableVendorPrices.setText(row, TABLE_INDEX_PRICING_TP, tp + "");
|
| 2105 |
ankur.sing |
745 |
return true;
|
| 2066 |
ankur.sing |
746 |
}
|
|
|
747 |
});
|
|
|
748 |
pricesDialog.show();
|
|
|
749 |
}
|
| 2119 |
ankur.sing |
750 |
|
| 2427 |
ankur.sing |
751 |
/**
|
|
|
752 |
* This method is called when Edit button is clicked corresponding to a row in
|
| 3558 |
rajveer |
753 |
* vendor prices table. It will pop up a form to edit the vendor prices.
|
|
|
754 |
* @param vendorId
|
|
|
755 |
* @param row
|
|
|
756 |
*/
|
|
|
757 |
private void editSourcePrices(final long sourceId, final int row) {
|
|
|
758 |
String mrp = tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_MRP);
|
|
|
759 |
String sellingPrice = tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE);
|
|
|
760 |
SourcePricesDialog pricesDialog = new SourcePricesDialog(mrp, sellingPrice);
|
|
|
761 |
pricesDialog.updateButton.setText("Update");
|
|
|
762 |
pricesDialog.setSourcePriceUpdateListener(new SourcePricesDialog.SourcePriceUpdateListener() {
|
|
|
763 |
@Override
|
|
|
764 |
public boolean onUpdate(double mrp, double sellingPrice, long sourceId) {
|
|
|
765 |
if(!validateSourcePrices(mrp, sellingPrice)) {
|
|
|
766 |
return false;
|
|
|
767 |
}
|
|
|
768 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_MRP, mrp + "");
|
|
|
769 |
tableSourcePrices.setText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE, sellingPrice + "");
|
|
|
770 |
return true;
|
|
|
771 |
}
|
|
|
772 |
});
|
|
|
773 |
pricesDialog.show();
|
|
|
774 |
}
|
|
|
775 |
|
|
|
776 |
|
|
|
777 |
/**
|
|
|
778 |
* This method is called when Edit button is clicked corresponding to a row in
|
| 2427 |
ankur.sing |
779 |
* vendor item key table. It will pop up a form to edit the item key.
|
|
|
780 |
* @param vendorId
|
|
|
781 |
* @param row
|
|
|
782 |
*/
|
|
|
783 |
private void editVendorKey(final long vendorId, final int row) {
|
|
|
784 |
String key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
| 2126 |
ankur.sing |
785 |
VendorMappingDialog mappingDialog = new VendorMappingDialog(productGroup.getText().trim(), brand.getText().trim(),
|
|
|
786 |
modelNumber.getText().trim(), color.getText().trim(), key);
|
| 2119 |
ankur.sing |
787 |
mappingDialog.updateButton.setText("Update");
|
|
|
788 |
mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
|
|
789 |
@Override
|
|
|
790 |
public boolean onUpdate(String itemKey, long vendorId) {
|
|
|
791 |
if(itemKey == null || itemKey.equals("")) {
|
|
|
792 |
Window.alert("Item key cannot be empty.");
|
|
|
793 |
return false;
|
|
|
794 |
}
|
| 2427 |
ankur.sing |
795 |
tableVendorItemKey.setText(row, TABLE_INDEX_MAPPING_ITEM_KEY, itemKey);
|
| 2119 |
ankur.sing |
796 |
return true;
|
|
|
797 |
}
|
|
|
798 |
});
|
|
|
799 |
mappingDialog.show();
|
|
|
800 |
}
|
| 2066 |
ankur.sing |
801 |
|
| 2427 |
ankur.sing |
802 |
/**
|
|
|
803 |
* This method compares all the editable UI fields values with attributes in the item object.
|
|
|
804 |
* If they differ, the attribute name is appended to a string.
|
|
|
805 |
* @return String showing attributes which are changed by the user for confirmation.
|
|
|
806 |
* <br>Empty string if nothing is changed.
|
|
|
807 |
*/
|
| 2252 |
ankur.sing |
808 |
private String isItemChanged() {
|
|
|
809 |
StringBuilder sb = new StringBuilder("");
|
| 2489 |
ankur.sing |
810 |
if(!checkParameterIfEqual(productGroup.getText().trim(), item.getProductGroup())) {
|
| 2387 |
ankur.sing |
811 |
sb.append("\n-Product Group");
|
| 2066 |
ankur.sing |
812 |
}
|
| 2489 |
ankur.sing |
813 |
if(!checkParameterIfEqual(brand.getText().trim(), item.getBrand())) {
|
| 2387 |
ankur.sing |
814 |
sb.append("\n-Brand");
|
| 2066 |
ankur.sing |
815 |
}
|
| 2489 |
ankur.sing |
816 |
if(!checkParameterIfEqual(modelNumber.getText().trim(), item.getModelNumber())) {
|
| 2387 |
ankur.sing |
817 |
sb.append("\n-Model Number");
|
| 2066 |
ankur.sing |
818 |
}
|
| 2489 |
ankur.sing |
819 |
if(!checkParameterIfEqual(modelName.getText().trim(), item.getModelName())) {
|
| 2387 |
ankur.sing |
820 |
sb.append("\n-Model Name");
|
| 2066 |
ankur.sing |
821 |
}
|
| 2489 |
ankur.sing |
822 |
if(!checkParameterIfEqual(color.getText().trim(), item.getColor())) {
|
| 2387 |
ankur.sing |
823 |
sb.append("\n-Color");
|
| 2066 |
ankur.sing |
824 |
}
|
| 2489 |
ankur.sing |
825 |
if(!checkParameterIfEqual(statusDesc.getText().trim(), item.getItemStatusDesc())) {
|
| 2387 |
ankur.sing |
826 |
sb.append("\n-Status Description");
|
| 2359 |
ankur.sing |
827 |
}
|
| 2489 |
ankur.sing |
828 |
if(!checkParameterIfEqual(comments.getText().trim(), item.getComments())) {
|
| 2387 |
ankur.sing |
829 |
sb.append("\n-Comments");
|
| 2066 |
ankur.sing |
830 |
}
|
| 2489 |
ankur.sing |
831 |
if(!checkParameterIfEqual(newItem.getMrp(), item.getMrp())) {
|
| 2387 |
ankur.sing |
832 |
sb.append("\n-MRP");
|
| 2066 |
ankur.sing |
833 |
}
|
| 2489 |
ankur.sing |
834 |
if(!checkParameterIfEqual(newItem.getSellingPrice(), item.getSellingPrice())) {
|
| 2387 |
ankur.sing |
835 |
sb.append("\n-Selling Price");
|
| 2027 |
ankur.sing |
836 |
}
|
| 2489 |
ankur.sing |
837 |
if(!checkParameterIfEqual(newItem.getWeight(), item.getWeight())) {
|
| 2387 |
ankur.sing |
838 |
sb.append("\n-Weight");
|
| 2027 |
ankur.sing |
839 |
}
|
| 2489 |
ankur.sing |
840 |
if(!checkParameterIfEqual(bestDealsText.getText().trim(), item.getBestDealsText())) {
|
| 2387 |
ankur.sing |
841 |
sb.append("\n-Best Deal Text");
|
| 2066 |
ankur.sing |
842 |
}
|
| 2489 |
ankur.sing |
843 |
if(!checkParameterIfEqual(newItem.getBestDealsValue(), item.getBestDealsValue())) {
|
| 2387 |
ankur.sing |
844 |
sb.append("\n-Best Deal Value");
|
| 2027 |
ankur.sing |
845 |
}
|
| 2489 |
ankur.sing |
846 |
if(!checkParameterIfEqual(newItem.getBestSellingRank(), item.getBestSellingRank())) {
|
| 2387 |
ankur.sing |
847 |
sb.append("\n-Best Selling Rank");
|
| 2066 |
ankur.sing |
848 |
}
|
|
|
849 |
if(item.isDefaultForEntity() != defaultForEntity.getValue()) {
|
| 2387 |
ankur.sing |
850 |
sb.append("\n-Default For Entity Flag");
|
| 2066 |
ankur.sing |
851 |
}
|
| 2252 |
ankur.sing |
852 |
if(item.isRisky() != risky.getValue()) {
|
| 2387 |
ankur.sing |
853 |
sb.append("\n-Risky Flag");
|
| 2252 |
ankur.sing |
854 |
}
|
| 2489 |
ankur.sing |
855 |
if(!checkParameterIfEqual(newItem.getStartDate(), item.getStartDate())) {
|
| 2387 |
ankur.sing |
856 |
sb.append("\n-Start Date");
|
| 2068 |
ankur.sing |
857 |
}
|
| 3524 |
chandransh |
858 |
if(!checkParameterIfEqual(newItem.getExpectedDelay(), item.getExpectedDelay())) {
|
| 3362 |
chandransh |
859 |
sb.append("\n-Expected Delay");
|
|
|
860 |
}
|
| 3524 |
chandransh |
861 |
if(!checkParameterIfEqual(newItem.getPreferredWarehouse(), item.getPreferredWarehouse())) {
|
| 3362 |
chandransh |
862 |
sb.append("\n-Preferred Warehouse");
|
|
|
863 |
}
|
|
|
864 |
|
| 2126 |
ankur.sing |
865 |
VendorPricings vendorPricings;
|
| 2066 |
ankur.sing |
866 |
long vendorId;
|
| 2427 |
ankur.sing |
867 |
for(int row = 0; row < tableVendorPrices.getRowCount(); row++) {
|
|
|
868 |
vendorId = Long.parseLong(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_VENDORID));
|
| 2126 |
ankur.sing |
869 |
vendorPricings = item.getVendorPricesMap().get(vendorId);
|
| 2359 |
ankur.sing |
870 |
if(vendorPricings == null) {
|
| 2387 |
ankur.sing |
871 |
sb.append("\n-Vendor Prices (Vendor:" + vendorId + ")");
|
| 2359 |
ankur.sing |
872 |
continue;
|
|
|
873 |
}
|
| 2427 |
ankur.sing |
874 |
if(vendorPricings.getMop() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_MOP))) {
|
| 2387 |
ankur.sing |
875 |
sb.append("\n-MOP (Vendor:" + vendorId + ")");
|
| 2066 |
ankur.sing |
876 |
}
|
| 2427 |
ankur.sing |
877 |
if(vendorPricings.getDealerPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_DP))) {
|
| 2387 |
ankur.sing |
878 |
sb.append("\n-Dealer Price (Vendor:" + vendorId + ")");
|
| 2066 |
ankur.sing |
879 |
}
|
| 2427 |
ankur.sing |
880 |
if(vendorPricings.getTransferPrice() != Double.parseDouble(tableVendorPrices.getText(row, TABLE_INDEX_PRICING_TP))) {
|
| 2387 |
ankur.sing |
881 |
sb.append("\n-Transfer Price (Vendor:" + vendorId + ")");
|
| 2066 |
ankur.sing |
882 |
}
|
|
|
883 |
}
|
| 2387 |
ankur.sing |
884 |
|
| 3558 |
rajveer |
885 |
SourcePricings sourcePricings;
|
|
|
886 |
long sourceId;
|
|
|
887 |
for(int row = 0; row < tableSourcePrices.getRowCount(); row++) {
|
|
|
888 |
sourceId = Long.parseLong(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID));
|
|
|
889 |
sourcePricings = item.getSourcePricesMap().get(sourceId);
|
|
|
890 |
if(sourcePricings == null) {
|
|
|
891 |
sb.append("\n-Source Prices (Source:" + sourceId + ")");
|
|
|
892 |
continue;
|
|
|
893 |
}
|
|
|
894 |
if(sourcePricings.getMrp() != Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_MRP))) {
|
|
|
895 |
sb.append("\n-MRP (Source:" + sourceId + ")");
|
|
|
896 |
}
|
|
|
897 |
if(sourcePricings.getSellingPrice() != Double.parseDouble(tableSourcePrices.getText(row, TABLE_INDEX_SOURCE_PRICING_SELLING_PRICE))) {
|
|
|
898 |
sb.append("\n-Selling Price (Source:" + sourceId + ")");
|
|
|
899 |
}
|
|
|
900 |
}
|
|
|
901 |
|
| 2387 |
ankur.sing |
902 |
VendorItemMapping mapping;
|
|
|
903 |
String old_key, new_key;
|
| 2427 |
ankur.sing |
904 |
for(int row = 0; row < tableVendorItemKey.getRowCount(); row++) {
|
|
|
905 |
vendorId = Long.parseLong(tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_VENDORID));
|
|
|
906 |
old_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY_OLD);
|
|
|
907 |
new_key = tableVendorItemKey.getText(row, TABLE_INDEX_MAPPING_ITEM_KEY);
|
| 2387 |
ankur.sing |
908 |
mapping = item.getVendorKeysMap().get(vendorId + Item.KEY_SEPARATOR + old_key);
|
|
|
909 |
if(mapping == null || !old_key.equals(new_key)) {
|
|
|
910 |
sb.append("\n-Vendor Key (Vendor:" + vendorId + ",Key: = " + old_key + ")");
|
|
|
911 |
continue;
|
|
|
912 |
}
|
|
|
913 |
}
|
| 2252 |
ankur.sing |
914 |
return sb.toString();
|
| 2066 |
ankur.sing |
915 |
}
|
|
|
916 |
|
| 2566 |
chandransh |
917 |
@SuppressWarnings("unused")
|
|
|
918 |
private boolean validatePrices() {
|
| 2066 |
ankur.sing |
919 |
if(newItem.getSellingPrice() > newItem.getMrp()) {
|
|
|
920 |
Window.alert("Selling price cannot be more than MRP");
|
|
|
921 |
return false;
|
|
|
922 |
}
|
| 2119 |
ankur.sing |
923 |
for(VendorPricings v : newItem.getVendorPricesMap().values()) {
|
| 2105 |
ankur.sing |
924 |
if(newItem.getMrp() < v.getMop()) {
|
|
|
925 |
Window.alert("MRP cannot be less than MOP. Vendor: " + v.getVendorId());
|
| 2066 |
ankur.sing |
926 |
return false;
|
|
|
927 |
}
|
| 2105 |
ankur.sing |
928 |
if(v.getTransferPrice() > v.getMop()) {
|
|
|
929 |
Window.alert("Transfer Price cannot be more than MOP. Vendor: " + v.getVendorId());
|
| 2066 |
ankur.sing |
930 |
return false;
|
|
|
931 |
}
|
|
|
932 |
}
|
|
|
933 |
return true;
|
|
|
934 |
}
|
| 2105 |
ankur.sing |
935 |
|
| 2119 |
ankur.sing |
936 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
| 2489 |
ankur.sing |
937 |
if(item.getMrp() != null && item.getMrp() < mop) {
|
| 2105 |
ankur.sing |
938 |
Window.alert("MOP cannot be more than MRP.");
|
|
|
939 |
return false;
|
| 1992 |
ankur.sing |
940 |
}
|
| 2105 |
ankur.sing |
941 |
if(tp > mop) {
|
|
|
942 |
Window.alert("Transfer Price cannot be more than MOP.");
|
|
|
943 |
return false;
|
| 1992 |
ankur.sing |
944 |
}
|
| 2105 |
ankur.sing |
945 |
return true;
|
| 1992 |
ankur.sing |
946 |
}
|
| 3558 |
rajveer |
947 |
|
|
|
948 |
private boolean validateSourcePrices(double mrp, double sellingPrice) {
|
|
|
949 |
if(sellingPrice > mrp) {
|
|
|
950 |
Window.alert("Selling Price cannot be more than MRP.");
|
|
|
951 |
return false;
|
|
|
952 |
}
|
|
|
953 |
return true;
|
|
|
954 |
}
|
|
|
955 |
|
| 2105 |
ankur.sing |
956 |
|
|
|
957 |
public long getItemId() {
|
|
|
958 |
return item == null ? 0 : item.getId();
|
|
|
959 |
}
|
|
|
960 |
|
|
|
961 |
public Item getItem() {
|
|
|
962 |
return item;
|
|
|
963 |
}
|
|
|
964 |
|
| 2427 |
ankur.sing |
965 |
/**
|
|
|
966 |
* This method is used while adding vendor prices to ensure that there is only one row in the table for a vendor.
|
|
|
967 |
* @param vendorId
|
|
|
968 |
* @return true if parameter vendor Id is already added to vendor prices table.
|
|
|
969 |
* <br>else false
|
|
|
970 |
*/
|
| 2105 |
ankur.sing |
971 |
private boolean vendorExists(long vendorId) {
|
|
|
972 |
long id;
|
| 2427 |
ankur.sing |
973 |
for(int i = 0; i < tableVendorPrices.getRowCount(); i++) {
|
|
|
974 |
id = Long.parseLong(tableVendorPrices.getText(i, TABLE_INDEX_PRICING_VENDORID));
|
| 2105 |
ankur.sing |
975 |
if(vendorId == id) {
|
|
|
976 |
return false;
|
|
|
977 |
}
|
| 1992 |
ankur.sing |
978 |
}
|
| 2105 |
ankur.sing |
979 |
return true;
|
| 1992 |
ankur.sing |
980 |
}
|
| 2387 |
ankur.sing |
981 |
|
| 2427 |
ankur.sing |
982 |
/**
|
| 3558 |
rajveer |
983 |
* This method is used while adding source prices to ensure that there is only one row in the table for a source.
|
|
|
984 |
* @param sourceId
|
|
|
985 |
* @return true if parameter vendor Id is already added to source prices table.
|
|
|
986 |
* <br>else false
|
|
|
987 |
*/
|
|
|
988 |
private boolean sourceExists(long sourceId) {
|
|
|
989 |
long id;
|
|
|
990 |
for(int i = 0; i < tableSourcePrices.getRowCount(); i++) {
|
|
|
991 |
id = Long.parseLong(tableSourcePrices.getText(i, TABLE_INDEX_SOURCE_PRICING_SOURCE_ID));
|
|
|
992 |
if(sourceId == id) {
|
|
|
993 |
return false;
|
|
|
994 |
}
|
|
|
995 |
}
|
|
|
996 |
return true;
|
|
|
997 |
}
|
|
|
998 |
|
|
|
999 |
/**
|
| 2427 |
ankur.sing |
1000 |
* This method is used to check if any of the string item attributes is changed by the user.
|
| 2489 |
ankur.sing |
1001 |
* @param o1
|
|
|
1002 |
* @param o2
|
| 2427 |
ankur.sing |
1003 |
* @return true if two strings are equal
|
|
|
1004 |
* <br>true if one of them is null and another is empty.
|
|
|
1005 |
* <br>false otherwise
|
|
|
1006 |
*/
|
| 2489 |
ankur.sing |
1007 |
private boolean checkParameterIfEqual(Object o1, Object o2) {
|
|
|
1008 |
if(o1 == o2) {
|
| 2387 |
ankur.sing |
1009 |
return true;
|
|
|
1010 |
}
|
| 2489 |
ankur.sing |
1011 |
if(o1 != null && o2 != null && o1.equals(o2)) {
|
| 2387 |
ankur.sing |
1012 |
return true;
|
|
|
1013 |
}
|
| 2489 |
ankur.sing |
1014 |
if((o1 == null && o2.equals("")) || (o2 == null && o1.equals(""))) {
|
| 2387 |
ankur.sing |
1015 |
return true;
|
|
|
1016 |
}
|
|
|
1017 |
return false;
|
|
|
1018 |
}
|
| 2489 |
ankur.sing |
1019 |
|
|
|
1020 |
public void setCatalogDashboardPanel(CatalogDashboard catalogDashboardPanel) {
|
|
|
1021 |
this.catalogDashboardPanel = catalogDashboardPanel;
|
|
|
1022 |
}
|
| 1961 |
ankur.sing |
1023 |
}
|