| Line 1... |
Line 1... |
| 1 |
package in.shop2020.catalog.dashboard.client;
|
1 |
package in.shop2020.catalog.dashboard.client;
|
| 2 |
|
2 |
|
| 3 |
import in.shop2020.catalog.dashboard.shared.Item;
|
3 |
import in.shop2020.catalog.dashboard.shared.Item;
|
| 4 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
4 |
import in.shop2020.catalog.dashboard.shared.Utils;
|
| - |
|
5 |
import in.shop2020.catalog.dashboard.shared.VendorItemMapping;
|
| 5 |
import in.shop2020.catalog.dashboard.shared.VendorDetails;
|
6 |
import in.shop2020.catalog.dashboard.shared.VendorPricings;
|
| 6 |
|
7 |
|
| 7 |
import java.util.Date;
|
8 |
import java.util.Date;
|
| 8 |
import java.util.HashMap;
|
9 |
import java.util.HashMap;
|
| 9 |
import java.util.Map;
|
10 |
import java.util.Map;
|
| 10 |
import java.util.Map.Entry;
|
11 |
import java.util.Map.Entry;
|
| Line 27... |
Line 28... |
| 27 |
import com.google.gwt.user.client.ui.Widget;
|
28 |
import com.google.gwt.user.client.ui.Widget;
|
| 28 |
import com.google.gwt.user.datepicker.client.DateBox;
|
29 |
import com.google.gwt.user.datepicker.client.DateBox;
|
| 29 |
|
30 |
|
| 30 |
public class ItemDetails extends ResizeComposite {
|
31 |
public class ItemDetails extends ResizeComposite {
|
| 31 |
|
32 |
|
| 32 |
private final int TABLE_INDEX_VENDORID = 0, TABLE_INDEX_VENDOR_DESC = 1,
|
33 |
private final int TABLE_INDEX_VENDORID = 0,
|
| 33 |
TABLE_INDEX_ITEM_KEY = 2, TABLE_INDEX_MOP = 3, TABLE_INDEX_DP = 4, TABLE_INDEX_TP = 5;
|
34 |
TABLE_INDEX_VENDOR_DESC = 1,
|
| - |
|
35 |
TABLE_INDEX_ITEM_KEY = 2,
|
| - |
|
36 |
TABLE_INDEX_MOP = 2,
|
| - |
|
37 |
TABLE_INDEX_DP = 3,
|
| - |
|
38 |
TABLE_INDEX_TP = 4;
|
| 34 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0, TABLE_INDEX_WAREHOUSE_DESC = 1, TABLE_INDEX_WAREHOUSE_INV = 2;
|
39 |
private final int TABLE_INDEX_WAREHOUSE_ID = 0,
|
| - |
|
40 |
TABLE_INDEX_WAREHOUSE_DESC = 1,
|
| - |
|
41 |
TABLE_INDEX_WAREHOUSE_INV = 2;
|
| 35 |
|
42 |
|
| 36 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
43 |
interface ItemDetailsUiBinder extends UiBinder<Widget, ItemDetails> {}
|
| 37 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
44 |
private static ItemDetailsUiBinder uiBinder = GWT.create(ItemDetailsUiBinder.class);
|
| 38 |
|
45 |
|
| 39 |
public interface ItemUpdateListener {
|
46 |
public interface ItemUpdateListener {
|
| Line 72... |
Line 79... |
| 72 |
}
|
79 |
}
|
| 73 |
|
80 |
|
| 74 |
public ItemDetails() {
|
81 |
public ItemDetails() {
|
| 75 |
initWidget(uiBinder.createAndBindUi(this));
|
82 |
initWidget(uiBinder.createAndBindUi(this));
|
| 76 |
initAvailabilityHeader();
|
83 |
initAvailabilityHeader();
|
| - |
|
84 |
initMappingHeader();
|
| 77 |
initPricingHeader();
|
85 |
initPricingHeader();
|
| - |
|
86 |
|
| 78 |
headerAvailability.setVisible(false);
|
87 |
headerAvailability.setVisible(false);
|
| 79 |
availabilityTable.setVisible(false);
|
88 |
availabilityTable.setVisible(false);
|
| 80 |
}
|
89 |
}
|
| 81 |
|
90 |
|
| 82 |
public void setItemDetails(Item item){
|
91 |
public void setItemDetails(Item item){
|
| Line 109... |
Line 118... |
| 109 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
118 |
defaultForEntity.setValue(item.isDefaultForEntity());
|
| 110 |
|
119 |
|
| 111 |
itemStatus.setText(item.getItemStatus());
|
120 |
itemStatus.setText(item.getItemStatus());
|
| 112 |
|
121 |
|
| 113 |
updateAvailabilityTable(item.getAvailability());
|
122 |
updateAvailabilityTable(item.getAvailability());
|
| 114 |
|
- |
|
| - |
|
123 |
updateMappingTable(item.getVendorMappingsMap());
|
| 115 |
updatePricingTable(item.getVendorDetails());
|
124 |
updatePricingTable(item.getVendorPricesMap());
|
| 116 |
}
|
125 |
}
|
| 117 |
|
126 |
|
| 118 |
private void initAvailabilityHeader(){
|
127 |
private void initAvailabilityHeader(){
|
| 119 |
// Initialize the header.
|
128 |
// Initialize the header.
|
| 120 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
129 |
headerAvailability.getColumnFormatter().setWidth(TABLE_INDEX_WAREHOUSE_ID, "128px");
|
| Line 125... |
Line 134... |
| 125 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
134 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_DESC, "Warehouse Desc");
|
| 126 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
|
135 |
headerAvailability.setText(0, TABLE_INDEX_WAREHOUSE_INV, "Availability");
|
| 127 |
|
136 |
|
| 128 |
}
|
137 |
}
|
| 129 |
|
138 |
|
| - |
|
139 |
private void initMappingHeader(){
|
| - |
|
140 |
// Initialize the header.
|
| - |
|
141 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| - |
|
142 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| - |
|
143 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
|
| - |
|
144 |
headerVendorM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
|
| - |
|
145 |
|
| - |
|
146 |
headerVendorM.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
|
| - |
|
147 |
headerVendorM.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor Desc");
|
| - |
|
148 |
headerVendorM.setText(0, TABLE_INDEX_ITEM_KEY, "Item Key");
|
| - |
|
149 |
|
| - |
|
150 |
Button addButton = new Button("Add");
|
| - |
|
151 |
headerVendorM.setWidget(0, TABLE_INDEX_ITEM_KEY + 1, addButton);
|
| - |
|
152 |
addButton.addClickHandler(new ClickHandler() {
|
| - |
|
153 |
@Override
|
| - |
|
154 |
public void onClick(ClickEvent event) {
|
| - |
|
155 |
VendorMappingDialog vendorMappingDialog = new VendorMappingDialog();
|
| - |
|
156 |
vendorMappingDialog.updateButton.setText("Add");
|
| - |
|
157 |
vendorMappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
| - |
|
158 |
@Override
|
| - |
|
159 |
public boolean onUpdate(String key, long vendorId) {
|
| - |
|
160 |
int row = vendorTableM.getRowCount();
|
| - |
|
161 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| - |
|
162 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| - |
|
163 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
|
| - |
|
164 |
|
| - |
|
165 |
vendorTableM.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
|
| - |
|
166 |
vendorTableM.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
| - |
|
167 |
vendorTableM.setText(row, TABLE_INDEX_ITEM_KEY, key);
|
| - |
|
168 |
return true;
|
| - |
|
169 |
}
|
| - |
|
170 |
});
|
| - |
|
171 |
vendorMappingDialog.show();
|
| - |
|
172 |
}
|
| - |
|
173 |
});
|
| - |
|
174 |
}
|
| - |
|
175 |
|
| - |
|
176 |
|
| 130 |
private void initPricingHeader(){
|
177 |
private void initPricingHeader(){
|
| 131 |
// Initialize the header.
|
178 |
// Initialize the header.
|
| 132 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
179 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| 133 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
180 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| 134 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
|
181 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
|
| 135 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
182 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
| 136 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
183 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
| 137 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
184 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
| - |
|
185 |
headerVendor.getColumnFormatter().setWidth(TABLE_INDEX_TP + 1, "50px");
|
| 138 |
|
186 |
|
| 139 |
headerVendor.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
|
187 |
headerVendor.setText(0, TABLE_INDEX_VENDORID, "Vendor Id");
|
| 140 |
headerVendor.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor Desc");
|
188 |
headerVendor.setText(0, TABLE_INDEX_VENDOR_DESC, "Vendor Desc");
|
| 141 |
headerVendor.setText(0, TABLE_INDEX_ITEM_KEY, "Item Key");
|
189 |
headerVendor.setText(0, TABLE_INDEX_ITEM_KEY, "Item Key");
|
| 142 |
headerVendor.setText(0, TABLE_INDEX_MOP, "MOP");
|
190 |
headerVendor.setText(0, TABLE_INDEX_MOP, "MOP");
|
| Line 146... |
Line 194... |
| 146 |
Button addButton = new Button("Add");
|
194 |
Button addButton = new Button("Add");
|
| 147 |
headerVendor.setWidget(0, TABLE_INDEX_TP + 1, addButton);
|
195 |
headerVendor.setWidget(0, TABLE_INDEX_TP + 1, addButton);
|
| 148 |
addButton.addClickHandler(new ClickHandler() {
|
196 |
addButton.addClickHandler(new ClickHandler() {
|
| 149 |
@Override
|
197 |
@Override
|
| 150 |
public void onClick(ClickEvent event) {
|
198 |
public void onClick(ClickEvent event) {
|
| 151 |
VendorPricesDialog vendorDialog = new VendorPricesDialog();
|
199 |
VendorPricesDialog vendorPricesDialog = new VendorPricesDialog();
|
| 152 |
vendorDialog.updateButton.setText("Add");
|
200 |
vendorPricesDialog.updateButton.setText("Add");
|
| 153 |
vendorDialog.setVendorDetailsUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
201 |
vendorPricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| 154 |
@Override
|
202 |
@Override
|
| 155 |
public boolean onUpdate(String key, double mop, double dp, double tp, long vendorId) {
|
203 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
| 156 |
if(!vendorExists(vendorId)) {
|
204 |
if(!vendorExists(vendorId)) {
|
| 157 |
Window.alert("Vendor already exists");
|
205 |
Window.alert("Vendor already exists");
|
| 158 |
return false;
|
206 |
return false;
|
| 159 |
}
|
207 |
}
|
| 160 |
if(!validateVendorDetails(key, mop, dp, tp)) {
|
208 |
/*if(!validateVendorPrices(mop, dp, tp)) {
|
| 161 |
return false;
|
209 |
return false;
|
| 162 |
}
|
210 |
}*/
|
| 163 |
int row = vendorTable.getRowCount();
|
211 |
int row = vendorTable.getRowCount();
|
| 164 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
212 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| 165 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
213 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| 166 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
|
- |
|
| 167 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
214 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
| 168 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
215 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
| 169 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
216 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
| 170 |
|
217 |
|
| 171 |
vendorTable.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
|
218 |
vendorTable.setText(row, TABLE_INDEX_VENDORID, vendorId + "");
|
| 172 |
vendorTable.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
219 |
vendorTable.setText(row, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorId));
|
| 173 |
vendorTable.setText(row, TABLE_INDEX_ITEM_KEY, key);
|
- |
|
| 174 |
vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
220 |
vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
| 175 |
vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
|
221 |
vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
|
| 176 |
vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
|
222 |
vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
|
| 177 |
return true;
|
223 |
return true;
|
| 178 |
}
|
224 |
}
|
| 179 |
});
|
225 |
});
|
| 180 |
vendorDialog.show();
|
226 |
vendorPricesDialog.show();
|
| 181 |
}
|
227 |
}
|
| 182 |
});
|
228 |
});
|
| 183 |
}
|
229 |
}
|
| 184 |
|
- |
|
| 185 |
|
230 |
|
| 186 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
231 |
private void updateAvailabilityTable(Map<Long, Long> availabilityMap){
|
| 187 |
availabilityTable.removeAllRows();
|
232 |
availabilityTable.removeAllRows();
|
| 188 |
if(availabilityMap == null) {
|
233 |
if(availabilityMap == null) {
|
| 189 |
return;
|
234 |
return;
|
| Line 199... |
Line 244... |
| 199 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
|
244 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_DESC, Utils.getWarehouseDesc(availability.getKey()));
|
| 200 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
245 |
availabilityTable.setText(i, TABLE_INDEX_WAREHOUSE_INV, availability.getValue() + "");
|
| 201 |
i++;
|
246 |
i++;
|
| 202 |
}
|
247 |
}
|
| 203 |
}
|
248 |
}
|
| - |
|
249 |
|
| - |
|
250 |
private void updateMappingTable(Map<Long, VendorItemMapping> vendorMappingsMap){
|
| - |
|
251 |
vendorTableM.removeAllRows();
|
| - |
|
252 |
|
| - |
|
253 |
if(vendorMappingsMap == null || vendorMappingsMap.isEmpty()) {
|
| - |
|
254 |
return;
|
| - |
|
255 |
}
|
| - |
|
256 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| - |
|
257 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| - |
|
258 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
|
| - |
|
259 |
vendorTableM.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY + 1, "50px");
|
| 204 |
|
260 |
|
| - |
|
261 |
int i=0;
|
| - |
|
262 |
for(VendorItemMapping vendorMapping : vendorMappingsMap.values()){
|
| - |
|
263 |
vendorTableM.setText(i, TABLE_INDEX_VENDORID, vendorMapping.getVendorId() + "");
|
| - |
|
264 |
vendorTableM.setText(i, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorMapping.getVendorId()));
|
| - |
|
265 |
vendorTableM.setText(i, TABLE_INDEX_ITEM_KEY, vendorMapping.getItemKey());
|
| - |
|
266 |
Button editButton = new Button("Edit");
|
| - |
|
267 |
vendorTableM.setWidget(i, TABLE_INDEX_ITEM_KEY + 1, editButton);
|
| - |
|
268 |
i++;
|
| - |
|
269 |
editButton.addClickHandler(new ClickHandler() {
|
| - |
|
270 |
@Override
|
| - |
|
271 |
public void onClick(ClickEvent event) {
|
| - |
|
272 |
Cell cell = vendorTableM.getCellForEvent(event);
|
| - |
|
273 |
int row = cell.getRowIndex();
|
| - |
|
274 |
long vendorId = Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID));
|
| - |
|
275 |
updateVendorMapping(vendorId, row);
|
| - |
|
276 |
}
|
| - |
|
277 |
});
|
| - |
|
278 |
}
|
| - |
|
279 |
}
|
| - |
|
280 |
|
| 205 |
private void updatePricingTable(Map<Long, VendorDetails> vendorDetailsMap){
|
281 |
private void updatePricingTable(Map<Long, VendorPricings> vendorPricingMap){
|
| 206 |
vendorTable.removeAllRows();
|
282 |
vendorTable.removeAllRows();
|
| 207 |
|
283 |
|
| 208 |
if(vendorDetailsMap == null || vendorDetailsMap.isEmpty()) {
|
284 |
if(vendorPricingMap == null || vendorPricingMap.isEmpty()) {
|
| 209 |
return;
|
285 |
return;
|
| 210 |
}
|
286 |
}
|
| 211 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
287 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDORID, "128px");
|
| 212 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
288 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_VENDOR_DESC, "128px");
|
| 213 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_ITEM_KEY, "250px");
|
- |
|
| 214 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
289 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_MOP, "128px");
|
| 215 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
290 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_DP, "128px");
|
| 216 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
291 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP, "128px");
|
| - |
|
292 |
vendorTable.getColumnFormatter().setWidth(TABLE_INDEX_TP + 1, "50px");
|
| 217 |
|
293 |
|
| 218 |
|
294 |
|
| 219 |
int i=0;
|
295 |
int i=0;
|
| 220 |
for(VendorDetails vendorDetail : vendorDetailsMap.values()){
|
296 |
for(VendorPricings vendorDetail : vendorPricingMap.values()){
|
| 221 |
vendorTable.setText(i, TABLE_INDEX_VENDORID, vendorDetail.getVendorId() + "");
|
297 |
vendorTable.setText(i, TABLE_INDEX_VENDORID, vendorDetail.getVendorId() + "");
|
| 222 |
vendorTable.setText(i, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
|
298 |
vendorTable.setText(i, TABLE_INDEX_VENDOR_DESC, Utils.getVendorDesc(vendorDetail.getVendorId()));
|
| 223 |
vendorTable.setText(i, TABLE_INDEX_ITEM_KEY, vendorDetail.getItemKey());
|
- |
|
| 224 |
vendorTable.setText(i, TABLE_INDEX_MOP, vendorDetail.getMop() + "");
|
299 |
vendorTable.setText(i, TABLE_INDEX_MOP, vendorDetail.getMop() + "");
|
| 225 |
vendorTable.setText(i, TABLE_INDEX_DP, vendorDetail.getDealerPrice() + "");
|
300 |
vendorTable.setText(i, TABLE_INDEX_DP, vendorDetail.getDealerPrice() + "");
|
| 226 |
vendorTable.setText(i, TABLE_INDEX_TP, vendorDetail.getTransferPrice() + "");
|
301 |
vendorTable.setText(i, TABLE_INDEX_TP, vendorDetail.getTransferPrice() + "");
|
| 227 |
Button editButton = new Button("Edit");
|
302 |
Button editButton = new Button("Edit");
|
| 228 |
vendorTable.setWidget(i, TABLE_INDEX_TP + 1, editButton);
|
303 |
vendorTable.setWidget(i, TABLE_INDEX_TP + 1, editButton);
|
| Line 249... |
Line 324... |
| 249 |
updateItem();
|
324 |
updateItem();
|
| 250 |
if(!isItemChanged()) {
|
325 |
if(!isItemChanged()) {
|
| 251 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
326 |
Window.alert("Nothing to update. Please change intended item parameters and try again.");
|
| 252 |
return;
|
327 |
return;
|
| 253 |
}
|
328 |
}
|
| 254 |
|
- |
|
| 255 |
if(!validatePrices()) {
|
329 |
if(!Utils.validateItem(newItem)) {
|
| 256 |
return;
|
330 |
return;
|
| 257 |
}
|
331 |
}
|
| - |
|
332 |
|
| - |
|
333 |
/*if(!validatePrices()) {
|
| - |
|
334 |
return;
|
| - |
|
335 |
}*/
|
| 258 |
//updateItem(); -- Calling this method above. A new item is created with updated data.
|
336 |
//updateItem(); -- Calling this method above. A new item is created with updated data.
|
| 259 |
} catch(NumberFormatException ex) {
|
337 |
} catch(NumberFormatException ex) {
|
| 260 |
return;
|
338 |
return;
|
| 261 |
}
|
339 |
}
|
| 262 |
itemUpdateListener.onItemUpdate(newItem);
|
340 |
itemUpdateListener.onItemUpdate(newItem);
|
| Line 270... |
Line 348... |
| 270 |
newItem.setProductGroup(productGroup.getText().trim());
|
348 |
newItem.setProductGroup(productGroup.getText().trim());
|
| 271 |
newItem.setBrand(brand.getText().trim());
|
349 |
newItem.setBrand(brand.getText().trim());
|
| 272 |
newItem.setModelNumber(modelNumber.getText().trim());
|
350 |
newItem.setModelNumber(modelNumber.getText().trim());
|
| 273 |
newItem.setModelName(modelName.getText().trim());
|
351 |
newItem.setModelName(modelName.getText().trim());
|
| 274 |
newItem.setColor(color.getText().trim());
|
352 |
newItem.setColor(color.getText().trim());
|
| 275 |
newItem.setContentCategory(Long.parseLong(contentCategory.getText()));
|
353 |
newItem.setContentCategory(contentCategory.getText());
|
| 276 |
newItem.setComments(comments.getText().trim());
|
354 |
newItem.setComments(comments.getText().trim());
|
| 277 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
355 |
newItem.setCatalogItemId(Long.parseLong(catalogItemId.getText()));
|
| 278 |
newItem.setFeatureId(item.getFeatureId());
|
356 |
newItem.setFeatureId(item.getFeatureId());
|
| 279 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
357 |
newItem.setFeatureDescription(item.getFeatureDescription());
|
| 280 |
try {
|
358 |
try {
|
| Line 316... |
Line 394... |
| 316 |
throw new NumberFormatException();
|
394 |
throw new NumberFormatException();
|
| 317 |
}
|
395 |
}
|
| 318 |
|
396 |
|
| 319 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
397 |
newItem.setDefaultForEntity(defaultForEntity.getValue());
|
| 320 |
newItem.setAvailability(item.getAvailability());
|
398 |
newItem.setAvailability(item.getAvailability());
|
| - |
|
399 |
|
| 321 |
Map<Long, VendorDetails> vendorDetails = new HashMap<Long, VendorDetails>();
|
400 |
Map<Long, VendorPricings> vendorPricings = new HashMap<Long, VendorPricings>();
|
| 322 |
VendorDetails v;
|
401 |
VendorPricings v;
|
| 323 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
402 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
| 324 |
v = new VendorDetails();
|
403 |
v = new VendorPricings();
|
| 325 |
v.setItemKey(vendorTable.getText(row, TABLE_INDEX_ITEM_KEY));
|
- |
|
| 326 |
v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP)));
|
404 |
v.setMop(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP)));
|
| 327 |
v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP)));
|
405 |
v.setDealerPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP)));
|
| 328 |
v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP)));
|
406 |
v.setTransferPrice(Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_TP)));
|
| 329 |
v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID)));
|
407 |
v.setVendorId(Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID)));
|
| 330 |
vendorDetails.put(v.getVendorId(), v);
|
408 |
vendorPricings.put(v.getVendorId(), v);
|
| 331 |
newItem.setMop(v.getMop());
|
409 |
newItem.setMop(v.getMop());
|
| 332 |
newItem.setDealerPrice(v.getDealerPrice());
|
410 |
newItem.setDealerPrice(v.getDealerPrice());
|
| 333 |
newItem.setTransferPrice(v.getTransferPrice());
|
411 |
newItem.setTransferPrice(v.getTransferPrice());
|
| 334 |
}
|
412 |
}
|
| - |
|
413 |
newItem.setVendorPricesMap(vendorPricings);
|
| - |
|
414 |
|
| - |
|
415 |
Map<Long, VendorItemMapping> vendorMapping = new HashMap<Long, VendorItemMapping>();
|
| - |
|
416 |
VendorItemMapping vM;
|
| - |
|
417 |
for(int row = 0; row < vendorTableM.getRowCount(); row++) {
|
| - |
|
418 |
vM = new VendorItemMapping();
|
| - |
|
419 |
vM.setVendorId(Long.parseLong(vendorTableM.getText(row, TABLE_INDEX_VENDORID)));
|
| - |
|
420 |
vM.setItemKey(vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY));
|
| - |
|
421 |
vendorMapping.put(vM.getVendorId(), vM);
|
| - |
|
422 |
}
|
| 335 |
newItem.setVendorDetails(vendorDetails);
|
423 |
newItem.setVendorMappingsMap(vendorMapping);
|
| - |
|
424 |
|
| 336 |
|
425 |
|
| 337 |
/*item.setProductGroup(productGroup.getText().trim());
|
426 |
/*item.setProductGroup(productGroup.getText().trim());
|
| 338 |
item.setBrand(brand.getText().trim());
|
427 |
item.setBrand(brand.getText().trim());
|
| 339 |
item.setModelName(modelName.getText().trim());
|
428 |
item.setModelName(modelName.getText().trim());
|
| 340 |
item.setModelNumber(modelNumber.getText().trim());
|
429 |
item.setModelNumber(modelNumber.getText().trim());
|
| Line 364... |
Line 453... |
| 364 |
private void updateVendorPrices(final long vendorId, final int row) {
|
453 |
private void updateVendorPrices(final long vendorId, final int row) {
|
| 365 |
String mop = vendorTable.getText(row, TABLE_INDEX_MOP);
|
454 |
String mop = vendorTable.getText(row, TABLE_INDEX_MOP);
|
| 366 |
String dp = vendorTable.getText(row, TABLE_INDEX_DP);
|
455 |
String dp = vendorTable.getText(row, TABLE_INDEX_DP);
|
| 367 |
String tp = vendorTable.getText(row, TABLE_INDEX_TP);
|
456 |
String tp = vendorTable.getText(row, TABLE_INDEX_TP);
|
| 368 |
String key = vendorTable.getText(row, TABLE_INDEX_ITEM_KEY);
|
457 |
String key = vendorTable.getText(row, TABLE_INDEX_ITEM_KEY);
|
| 369 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(key, mop, dp, tp);
|
458 |
VendorPricesDialog pricesDialog = new VendorPricesDialog(mop, dp, tp);
|
| 370 |
pricesDialog.updateButton.setText("Update");
|
459 |
pricesDialog.updateButton.setText("Update");
|
| 371 |
pricesDialog.setVendorDetailsUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
460 |
pricesDialog.setVendorPriceUpdateListener(new VendorPricesDialog.VendorPriceUpdateListener() {
|
| 372 |
@Override
|
461 |
@Override
|
| 373 |
public boolean onUpdate(String itemKey, double mop, double dp, double tp, long vendorId) {
|
462 |
public boolean onUpdate(double mop, double dp, double tp, long vendorId) {
|
| 374 |
if(!validateVendorDetails(itemKey, mop, dp, tp)) {
|
463 |
if(!validateVendorPrices(mop, dp, tp)) {
|
| 375 |
return false;
|
464 |
return false;
|
| 376 |
}
|
465 |
}
|
| 377 |
vendorTable.setText(row, TABLE_INDEX_ITEM_KEY, itemKey);
|
- |
|
| 378 |
vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
466 |
vendorTable.setText(row, TABLE_INDEX_MOP, mop + "");
|
| 379 |
vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
|
467 |
vendorTable.setText(row, TABLE_INDEX_DP, dp + "");
|
| 380 |
vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
|
468 |
vendorTable.setText(row, TABLE_INDEX_TP, tp + "");
|
| 381 |
return true;
|
469 |
return true;
|
| 382 |
}
|
470 |
}
|
| 383 |
});
|
471 |
});
|
| 384 |
pricesDialog.show();
|
472 |
pricesDialog.show();
|
| 385 |
}
|
473 |
}
|
| - |
|
474 |
|
| - |
|
475 |
private void updateVendorMapping(final long vendorId, final int row) {
|
| - |
|
476 |
String key = vendorTableM.getText(row, TABLE_INDEX_ITEM_KEY);
|
| - |
|
477 |
VendorMappingDialog mappingDialog = new VendorMappingDialog(key);
|
| - |
|
478 |
mappingDialog.updateButton.setText("Update");
|
| - |
|
479 |
mappingDialog.setVendorMappingUpdateListener(new VendorMappingDialog.VendorMappingUpdateListener() {
|
| - |
|
480 |
@Override
|
| - |
|
481 |
public boolean onUpdate(String itemKey, long vendorId) {
|
| - |
|
482 |
if(itemKey == null || itemKey.equals("")) {
|
| - |
|
483 |
Window.alert("Item key cannot be empty.");
|
| - |
|
484 |
return false;
|
| - |
|
485 |
}
|
| - |
|
486 |
vendorTableM.setText(row, TABLE_INDEX_ITEM_KEY, itemKey);
|
| - |
|
487 |
return true;
|
| - |
|
488 |
}
|
| - |
|
489 |
});
|
| - |
|
490 |
mappingDialog.show();
|
| - |
|
491 |
}
|
| 386 |
|
492 |
|
| 387 |
private boolean isItemChanged() {
|
493 |
private boolean isItemChanged() {
|
| 388 |
if(!productGroup.getText().trim().equals(item.getProductGroup())) {
|
494 |
if(!productGroup.getText().trim().equals(item.getProductGroup())) {
|
| 389 |
return true;
|
495 |
return true;
|
| 390 |
}
|
496 |
}
|
| Line 452... |
Line 558... |
| 452 |
|
558 |
|
| 453 |
if(newItem.getStartDate() != item.getStartDate()) {
|
559 |
if(newItem.getStartDate() != item.getStartDate()) {
|
| 454 |
return true;
|
560 |
return true;
|
| 455 |
}
|
561 |
}
|
| 456 |
|
562 |
|
| 457 |
VendorDetails vendorDetails;
|
563 |
VendorPricings vendorDetails;
|
| 458 |
long vendorId;
|
564 |
long vendorId;
|
| 459 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
565 |
for(int row = 0; row < vendorTable.getRowCount(); row++) {
|
| 460 |
vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
|
566 |
vendorId = Long.parseLong(vendorTable.getText(row, TABLE_INDEX_VENDORID));
|
| 461 |
vendorDetails = item.getVendorDetails().get(vendorId);
|
567 |
vendorDetails = item.getVendorPricesMap().get(vendorId);
|
| 462 |
if(vendorDetails.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP))) {
|
568 |
if(vendorDetails.getMop() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_MOP))) {
|
| 463 |
return true;
|
569 |
return true;
|
| 464 |
}
|
570 |
}
|
| 465 |
if(vendorDetails.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP))) {
|
571 |
if(vendorDetails.getDealerPrice() != Double.parseDouble(vendorTable.getText(row, TABLE_INDEX_DP))) {
|
| 466 |
return true;
|
572 |
return true;
|
| Line 475... |
Line 581... |
| 475 |
private boolean validatePrices() {
|
581 |
private boolean validatePrices() {
|
| 476 |
if(newItem.getSellingPrice() > newItem.getMrp()) {
|
582 |
if(newItem.getSellingPrice() > newItem.getMrp()) {
|
| 477 |
Window.alert("Selling price cannot be more than MRP");
|
583 |
Window.alert("Selling price cannot be more than MRP");
|
| 478 |
return false;
|
584 |
return false;
|
| 479 |
}
|
585 |
}
|
| 480 |
for(VendorDetails v : newItem.getVendorDetails().values()) {
|
586 |
for(VendorPricings v : newItem.getVendorPricesMap().values()) {
|
| 481 |
if(newItem.getMrp() < v.getMop()) {
|
587 |
if(newItem.getMrp() < v.getMop()) {
|
| 482 |
Window.alert("MRP cannot be less than MOP. Vendor: " + v.getVendorId());
|
588 |
Window.alert("MRP cannot be less than MOP. Vendor: " + v.getVendorId());
|
| 483 |
return false;
|
589 |
return false;
|
| 484 |
}
|
590 |
}
|
| 485 |
if(v.getTransferPrice() > v.getMop()) {
|
591 |
if(v.getTransferPrice() > v.getMop()) {
|
| Line 488... |
Line 594... |
| 488 |
}
|
594 |
}
|
| 489 |
}
|
595 |
}
|
| 490 |
return true;
|
596 |
return true;
|
| 491 |
}
|
597 |
}
|
| 492 |
|
598 |
|
| 493 |
private boolean validateVendorDetails(String key, double mop, double dp, double tp) {
|
599 |
private boolean validateVendorPrices(double mop, double dp, double tp) {
|
| 494 |
if(key == null || key.isEmpty()) {
|
- |
|
| 495 |
Window.alert("Item key cannot be empty");
|
- |
|
| 496 |
return false;
|
- |
|
| 497 |
}
|
- |
|
| 498 |
if(item.getMrp() < mop) {
|
600 |
if(item.getMrp() < mop) {
|
| 499 |
Window.alert("MOP cannot be more than MRP.");
|
601 |
Window.alert("MOP cannot be more than MRP.");
|
| 500 |
return false;
|
602 |
return false;
|
| 501 |
}
|
603 |
}
|
| 502 |
if(tp > mop) {
|
604 |
if(tp > mop) {
|