Subversion Repositories SmartDukaan

Rev

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

Rev 23074 Rev 23147
Line 20... Line 20...
20
import org.slf4j.Logger;
20
import org.slf4j.Logger;
21
import org.slf4j.LoggerFactory;
21
import org.slf4j.LoggerFactory;
22
import org.springframework.http.HttpHeaders;
22
import org.springframework.http.HttpHeaders;
23
import org.springframework.http.MediaType;
23
import org.springframework.http.MediaType;
24
 
24
 
25
import com.fasterxml.jackson.core.JsonProcessingException;
-
 
26
import com.fasterxml.jackson.databind.JsonNode;
-
 
27
import com.fasterxml.jackson.databind.ObjectMapper;
-
 
28
import com.spice.profitmandi.common.enumuration.SchemeType;
25
import com.spice.profitmandi.common.enumuration.SchemeType;
29
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
26
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
30
import com.spice.profitmandi.common.model.GstRate;
27
import com.spice.profitmandi.common.model.GstRate;
31
import com.spice.profitmandi.common.model.ProfitMandiConstants;
28
import com.spice.profitmandi.common.model.ProfitMandiConstants;
32
import com.spice.profitmandi.common.web.client.RestClient;
29
import com.spice.profitmandi.common.web.client.RestClient;
Line 276... Line 273...
276
			e.printStackTrace();
273
			e.printStackTrace();
277
			return new HashMap<>();
274
			return new HashMap<>();
278
		}
275
		}
279
	}
276
	}
280
	
277
	
-
 
278
	public static Map<Integer, GstRate> getStateTaxRate(List<Integer> itemIds, int stateId) throws ProfitMandiBusinessException{
-
 
279
		try{
-
 
280
			CatalogService.Client catalogClient = getCatalogClient();
-
 
281
			Map<Integer, in.shop2020.model.v1.catalog.GstRate> totalTaxRateMap = catalogClient.getStateTaxRate(itemIds, stateId);
-
 
282
			Map<Integer, GstRate> itemIdGstRateMap = new HashMap<>();
-
 
283
			for(Map.Entry<Integer, in.shop2020.model.v1.catalog.GstRate> totalTaxRateEntry : totalTaxRateMap.entrySet()){
-
 
284
				GstRate gstRate = new GstRate();
-
 
285
				gstRate.setIgstRate(Double.valueOf(totalTaxRateEntry.getValue().getIgstRate()).floatValue());
-
 
286
				gstRate.setCgstRate(Double.valueOf(totalTaxRateEntry.getValue().getCgstRate()).floatValue());
-
 
287
				gstRate.setSgstRate(Double.valueOf(totalTaxRateEntry.getValue().getSgstRate()).floatValue());
-
 
288
				itemIdGstRateMap.put(totalTaxRateEntry.getKey(), gstRate);
-
 
289
			}
-
 
290
			return itemIdGstRateMap;
-
 
291
		}catch(Exception e){
-
 
292
			e.printStackTrace();
-
 
293
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID + ", " + ProfitMandiConstants.STATE_ID, itemIds +", " + stateId, "");
-
 
294
		}
-
 
295
	}
-
 
296
	
-
 
297
	public static Map<Integer, Float> getIgstTaxRate(List<Integer> itemIds) throws ProfitMandiBusinessException{
-
 
298
		try{
-
 
299
			CatalogService.Client catalogClient = getCatalogClient();
-
 
300
			Map<Integer, Double> totalTaxRateMap = catalogClient.getIgstTaxRate(itemIds);
-
 
301
			Map<Integer, Float> itemIdIgstRateMap = new HashMap<>();
-
 
302
			for(Map.Entry<Integer, Double> totalTaxRateEntry : totalTaxRateMap.entrySet()){
-
 
303
				itemIdIgstRateMap.put(totalTaxRateEntry.getKey(), Double.valueOf(totalTaxRateEntry.getValue()).floatValue());
-
 
304
			}
-
 
305
			return itemIdIgstRateMap;
-
 
306
		}catch(Exception e){
-
 
307
			e.printStackTrace();
-
 
308
			throw new ProfitMandiBusinessException(ProfitMandiConstants.ITEM_ID, itemIds, "");
-
 
309
		}
-
 
310
	}
-
 
311
	
281
	public static Map<String, GstRate> getGstRates(String stateName){
312
	public static Map<String, GstRate> getGstRates(String stateName){
282
		try{
313
		try{
283
			CatalogService.Client catalogClient = getCatalogClient();
314
			CatalogService.Client catalogClient = getCatalogClient();
284
			long stateId = getStateId(stateName);
315
			long stateId = getStateId(stateName);
285
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateId);
316
			StateGstRates stateGstRates = catalogClient.getGstRatesByState(stateId);