Subversion Repositories SmartDukaan

Rev

Rev 24425 | Rev 24442 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24425 Rev 24426
Line 200... Line 200...
200
		}
200
		}
201
		arr = new JSONArray();
201
		arr = new JSONArray();
202
		for (int i = 0; i < listdata.size(); i++) {
202
		for (int i = 0; i < listdata.size(); i++) {
203
			arr.put(listdata.get(i));
203
			arr.put(listdata.get(i));
204
		}
204
		}
-
 
205
 
-
 
206
		cartObj.put("cartItems", arr);
205
		Map.Entry<String, Integer> failedBrandItemQty = null;
207
		JSONArray cartMessagesArray = new JSONArray();
206
		for(Map.Entry<String, Integer> minBrandQtyLimit : MIN_BRAND_QTY_LIMIT.entrySet()) {
208
		for(Map.Entry<String, Integer> minBrandQtyLimit : MIN_BRAND_QTY_LIMIT.entrySet()) {
207
			if(brandQtyMap.containsKey(minBrandQtyLimit.getKey())) {
209
			if(brandQtyMap.containsKey(minBrandQtyLimit.getKey())) {
208
				if(brandQtyMap.get(minBrandQtyLimit.getKey()) < minBrandQtyLimit.getValue()) {
210
				if(brandQtyMap.get(minBrandQtyLimit.getKey()) < minBrandQtyLimit.getValue()) {
209
					maxEstimate = -3;
211
					cartMessagesArray.put(new JSONObject()
210
					failedBrandItemQty = minBrandQtyLimit;
212
					.put("messageText", String.format("Minimum qty for %s brand should be %d", minBrandQtyLimit.getKey(), minBrandQtyLimit.getValue()))
211
					break;
213
					.put("type", "warn"));
212
				}
214
				}
213
			}
215
			}
214
		}
216
		}
215
		cartObj.put("cartItems", arr);
217
		
216
		JSONArray cartMessagesArray = new JSONArray();
-
 
217
		for (String message : Arrays.asList("cartMessageOOS", "cartMessageUndeliverable", "cartMessageChanged",
218
		for (String message : Arrays.asList("cartMessageOOS", "cartMessageUndeliverable", "cartMessageChanged",
218
				"cartMessagesMerged")) {
219
				"cartMessagesMerged")) {
219
			int count = cartObj.getInt(message);
220
			int count = cartObj.getInt(message);
220
			if (count > 0) {
221
			if (count > 0) {
221
				String type = "danger";
222
				String type = "danger";
Line 236... Line 237...
236
					if (count == 1) {
237
					if (count == 1) {
237
						cartMessage.put("messageText", "One item is undeliverable");
238
						cartMessage.put("messageText", "One item is undeliverable");
238
					} else {
239
					} else {
239
						cartMessage.put("messageText", "Few items are underiverable");
240
						cartMessage.put("messageText", "Few items are underiverable");
240
					}
241
					}
241
				} else {
242
				} else if(message.equals("cartMessageChanged")){
242
					if (count == 1) {
243
					if (count == 1) {
243
						cartMessage.put("messageText", "One item qty has changed");
244
						cartMessage.put("messageText", "One item qty has changed");
244
					} else {
245
					} else {
245
						cartMessage.put("messageText", "Few items qty have changed");
246
						cartMessage.put("messageText", "Few items qty have changed");
246
					}
247
					}
Line 253... Line 254...
253
		//Hardcode maxEstimate to -3 for managing brands quantity
254
		//Hardcode maxEstimate to -3 for managing brands quantity
254
		if (maxEstimate == -1) {
255
		if (maxEstimate == -1) {
255
			cartObj.put("estimateString", "Can't ship here");
256
			cartObj.put("estimateString", "Can't ship here");
256
		} else if (maxEstimate == -2) {
257
		} else if (maxEstimate == -2) {
257
			cartObj.put("estimateString", "Out of Stock");
258
			cartObj.put("estimateString", "Out of Stock");
258
		} else if(maxEstimate == -3){
-
 
259
			maxEstimate = -1;
-
 
260
			cartObj.put("estimateString", String.format("Minimum qty for %s brand should be %d", failedBrandItemQty.getKey(), failedBrandItemQty.getValue()));
-
 
261
		} else {
259
		} else {
262
			try {
260
			try {
263
				cartObj.put("cod", cartObj.getBoolean("codAllowed"));
261
				cartObj.put("cod", cartObj.getBoolean("codAllowed"));
264
				cartObj.put("estimateString", LogisticsService.getDeliveryDateString(maxEstimate, DeliveryType.COD));
262
				cartObj.put("estimateString", LogisticsService.getDeliveryDateString(maxEstimate, DeliveryType.COD));
265
			} catch (NumberFormatException | JSONException | TException e) {
263
			} catch (NumberFormatException | JSONException | TException e) {