Subversion Repositories SmartDukaan

Rev

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

Rev 23296 Rev 23333
Line 34... Line 34...
34
import com.spice.profitmandi.thrift.clients.TransactionClient;
34
import com.spice.profitmandi.thrift.clients.TransactionClient;
35
import com.spice.profitmandi.thrift.clients.UserClient;
35
import com.spice.profitmandi.thrift.clients.UserClient;
36
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
36
import com.spice.profitmandi.thrift.clients.config.ConfigClient;
37
 
37
 
38
import in.shop2020.model.v1.catalog.CatalogService;
38
import in.shop2020.model.v1.catalog.CatalogService;
39
import in.shop2020.model.v1.catalog.StateGstRates;
-
 
40
import in.shop2020.model.v1.inventory.InventoryService;
39
import in.shop2020.model.v1.inventory.InventoryService;
41
import in.shop2020.model.v1.inventory.StateInfo;
40
import in.shop2020.model.v1.inventory.StateInfo;
42
import in.shop2020.model.v1.order.RechargeOrderStatus;
41
import in.shop2020.model.v1.order.RechargeOrderStatus;
43
import in.shop2020.model.v1.order.RechargePlan;
42
import in.shop2020.model.v1.order.RechargePlan;
44
import in.shop2020.model.v1.order.RechargeType;
43
import in.shop2020.model.v1.order.RechargeType;
Line 265... Line 264...
265
			return "";
264
			return "";
266
		}
265
		}
267
		return iconUrl==null?"":iconUrl;
266
		return iconUrl==null?"":iconUrl;
268
	}
267
	}
269
	
268
	
270
	public static Map<String, GstRate> getInterGstRates(){
-
 
271
		try{
-
 
272
			CatalogService.Client catalogClient = getCatalogClient();
-
 
273
			return toGstRateMap(catalogClient.getInterStateGstRates());
-
 
274
		}catch (Exception e) {
-
 
275
			e.printStackTrace();
-
 
276
			return new HashMap<>();
-
 
277
		}
-
 
278
	}
-
 
279
	
-
 
280
	public static Map<Integer, GstRate> getStateTaxRate(List<Integer> itemIds, int stateId) throws ProfitMandiBusinessException{
269
	public static Map<Integer, GstRate> getStateTaxRate(List<Integer> itemIds, int stateId) throws ProfitMandiBusinessException{
281
		List<Long> longItemIds = new ArrayList<>();
270
		List<Long> longItemIds = new ArrayList<>();
282
		for(int itemId : itemIds){
271
		for(int itemId : itemIds){
283
			longItemIds.add(Long.valueOf(itemId));
272
			longItemIds.add(Long.valueOf(itemId));
284
		}
273
		}
Line 317... Line 306...
317
			e.printStackTrace();
306
			e.printStackTrace();
318
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, itemIds, "");
307
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, itemIds, "");
319
		}
308
		}
320
	}
309
	}
321
	
310
	
322
	public static Map<String, GstRate> getGstRates(String stateName){
-
 
323
		try{
-
 
324
			CatalogService.Client catalogClient = getCatalogClient();
-
 
325
			long stateId = getStateId(stateName);
-
 
326
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateId);
-
 
327
			return toGstRateMap(stateGstRates.getGstRatesMap());
-
 
328
		}catch(Exception e){
-
 
329
			e.printStackTrace();
-
 
330
			return new HashMap<>();	
-
 
331
		}
-
 
332
	}
-
 
333
	
-
 
334
	private static CatalogService.Client getCatalogClient() throws Exception{
311
	private static CatalogService.Client getCatalogClient() throws Exception{
335
		try{
312
		try{
336
			CatalogClient client = new CatalogClient();
313
			CatalogClient client = new CatalogClient();
337
			CatalogService.Client catalogClient = client.getClient();
314
			CatalogService.Client catalogClient = client.getClient();
338
			return catalogClient;
315
			return catalogClient;
339
		}catch (Exception e) {
316
		}catch (Exception e) {
340
			throw e;
317
			throw e;
341
		}
318
		}
342
	}
319
	}
343
	
320
	
344
	private static Map<String, GstRate> toGstRateMap(Map<String, in.shop2020.model.v1.catalog.GstRate> hsnCodeGstRateMap){
-
 
345
		Map<String, GstRate> gstRateMap = new HashMap<>();
-
 
346
		for(Map.Entry<String, in.shop2020.model.v1.catalog.GstRate> entry : hsnCodeGstRateMap.entrySet()){
-
 
347
			in.shop2020.model.v1.catalog.GstRate tGstRate = entry.getValue();
-
 
348
			GstRate gstRate = new GstRate();
-
 
349
			gstRate.setHsnCode(entry.getKey());
-
 
350
			gstRate.setIgstRate(Double.valueOf(tGstRate.getIgstRate()).floatValue());
-
 
351
			gstRate.setCgstRate(Double.valueOf(tGstRate.getCgstRate()).floatValue());
-
 
352
			gstRate.setSgstRate(Double.valueOf(tGstRate.getSgstRate()).floatValue());
-
 
353
			gstRateMap.put(entry.getKey(), gstRate);
-
 
354
		}
-
 
355
		return gstRateMap;
-
 
356
	}
-
 
357
	
-
 
358
	
321
	
359
	public static String getStateCode(String stateName) throws Exception{
322
	public static String getStateCode(String stateName) throws Exception{
360
		return getStateInfo(stateName).getStateCode();
323
		return getStateInfo(stateName).getStateCode();
361
	}
324
	}
362
	
325