Subversion Repositories SmartDukaan

Rev

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

Rev 21902 Rev 21915
Line 213... Line 213...
213
			return new String[]{"true", "ERROR", "INVALID INPUT"};
213
			return new String[]{"true", "ERROR", "INVALID INPUT"};
214
		}
214
		}
215
		
215
		
216
	}
216
	}
217
	
217
	
-
 
218
	public static Map<String, GstRate> getInterGstRates(){
-
 
219
		try{
-
 
220
			CatalogService.Client catalogClient = getCatalogClient();
-
 
221
			return toGstRateMap(catalogClient.getInterStateGstRates());
-
 
222
		}catch (Exception e) {
-
 
223
			e.printStackTrace();
-
 
224
			return new HashMap<>();
-
 
225
		}
-
 
226
	}
-
 
227
	
218
	public static Map<String, GstRate> getGstRates(String stateName){
228
	public static Map<String, GstRate> getGstRates(String stateName){
219
		try{
229
		try{
220
			CatalogClient client = new CatalogClient();
-
 
221
			CatalogService.Client catalogClient = client.getClient();
230
			CatalogService.Client catalogClient = getCatalogClient();
222
			long stateCode = getStateId(stateName);
231
			long stateId = getStateId(stateName);
223
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateCode);
232
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateId);
224
			Map<String, in.shop2020.model.v1.catalog.GstRate> hsnCodeGstRateMap = stateGstRates.getGstRatesMap();
-
 
225
			Map<String, GstRate> gstRateMap = new HashMap<>();
233
			return toGstRateMap(stateGstRates.getGstRatesMap());
226
			for(Map.Entry<String, in.shop2020.model.v1.catalog.GstRate> entry : hsnCodeGstRateMap.entrySet()){
-
 
227
				in.shop2020.model.v1.catalog.GstRate tGstRate = entry.getValue();
-
 
228
				GstRate gstRate = new GstRate();
-
 
229
				gstRate.setHsnCode(entry.getKey());
-
 
230
				gstRate.setIgstRate(Double.valueOf(tGstRate.getIgstRate()).floatValue());
-
 
231
				gstRate.setCgstRate(Double.valueOf(tGstRate.getCgstRate()).floatValue());
-
 
232
				gstRate.setSgstRate(Double.valueOf(tGstRate.getSgstRate()).floatValue());
-
 
233
				gstRateMap.put(entry.getKey(), gstRate);
-
 
234
			}
-
 
235
			return gstRateMap;
-
 
236
		}catch(Exception e){
234
		}catch(Exception e){
-
 
235
			e.printStackTrace();
237
			return new HashMap<>();
236
			return new HashMap<>();
238
		}
237
		}
239
	}
238
	}
240
	
239
	
-
 
240
	private static CatalogService.Client getCatalogClient() throws Exception{
-
 
241
		try{
-
 
242
			CatalogClient client = new CatalogClient();
-
 
243
			CatalogService.Client catalogClient = client.getClient();
-
 
244
			return catalogClient;
-
 
245
		}catch (Exception e) {
-
 
246
			throw e;
-
 
247
		}
-
 
248
	}
-
 
249
	
-
 
250
	private static Map<String, GstRate> toGstRateMap(Map<String, in.shop2020.model.v1.catalog.GstRate> hsnCodeGstRateMap){
-
 
251
		Map<String, GstRate> gstRateMap = new HashMap<>();
-
 
252
		for(Map.Entry<String, in.shop2020.model.v1.catalog.GstRate> entry : hsnCodeGstRateMap.entrySet()){
-
 
253
			in.shop2020.model.v1.catalog.GstRate tGstRate = entry.getValue();
-
 
254
			GstRate gstRate = new GstRate();
-
 
255
			gstRate.setHsnCode(entry.getKey());
-
 
256
			gstRate.setIgstRate(Double.valueOf(tGstRate.getIgstRate()).floatValue());
-
 
257
			gstRate.setCgstRate(Double.valueOf(tGstRate.getCgstRate()).floatValue());
-
 
258
			gstRate.setSgstRate(Double.valueOf(tGstRate.getSgstRate()).floatValue());
-
 
259
			gstRateMap.put(entry.getKey(), gstRate);
-
 
260
		}
-
 
261
		return gstRateMap;
-
 
262
	}
-
 
263
	
-
 
264
	
241
	public static String getStateCode(String stateName) throws Exception{
265
	public static String getStateCode(String stateName) throws Exception{
242
		return getStateInfo(stateName).getStateCode();
266
		return getStateInfo(stateName).getStateCode();
243
	}
267
	}
244
	
268
	
245
	public static long getStateId(String stateName) throws Exception{
269
	public static long getStateId(String stateName) throws Exception{