Subversion Repositories SmartDukaan

Rev

Rev 28307 | Rev 29597 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
22866 ashik.ali 1
package com.spice.profitmandi.web.controller;
2
 
22889 amit.gupta 3
import java.io.ByteArrayOutputStream;
4
import java.io.File;
5
import java.io.FileOutputStream;
6
import java.io.IOException;
7
import java.io.OutputStream;
8
import java.text.MessageFormat;
9
import java.time.LocalDate;
22907 amit.gupta 10
import java.time.LocalDateTime;
22889 amit.gupta 11
import java.time.format.DateTimeFormatter;
22932 amit.gupta 12
import java.util.ArrayList;
22889 amit.gupta 13
import java.util.Arrays;
14
import java.util.HashSet;
15
import java.util.List;
16
import java.util.Map;
17
import java.util.Set;
18
 
19
import javax.mail.internet.InternetAddress;
20
import javax.mail.internet.MimeMessage;
22866 ashik.ali 21
import javax.servlet.http.HttpServletRequest;
22
 
22889 amit.gupta 23
import org.apache.commons.io.FileUtils;
26655 amit.gupta 24
import org.apache.logging.log4j.LogManager;
25
import org.apache.logging.log4j.Logger;
22993 amit.gupta 26
import org.json.JSONObject;
22866 ashik.ali 27
import org.springframework.beans.factory.annotation.Autowired;
23015 amit.gupta 28
import org.springframework.beans.factory.annotation.Value;
22866 ashik.ali 29
import org.springframework.http.ResponseEntity;
22889 amit.gupta 30
import org.springframework.mail.javamail.JavaMailSender;
31
import org.springframework.mail.javamail.MimeMessageHelper;
22866 ashik.ali 32
import org.springframework.stereotype.Controller;
33
import org.springframework.transaction.annotation.Transactional;
22889 amit.gupta 34
import org.springframework.web.bind.annotation.RequestBody;
22866 ashik.ali 35
import org.springframework.web.bind.annotation.RequestMapping;
36
import org.springframework.web.bind.annotation.RequestMethod;
37
 
22889 amit.gupta 38
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
39
import com.spice.profitmandi.common.model.CustomAddress;
40
import com.spice.profitmandi.common.model.CustomCustomer;
41
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
42
import com.spice.profitmandi.common.model.CustomOrderItem;
43
import com.spice.profitmandi.common.model.CustomRetailer;
44
import com.spice.profitmandi.common.model.GadgetCopsDocumentInsuranceModel;
22932 amit.gupta 45
import com.spice.profitmandi.common.model.GadgetCopsInsuranceCalcResponse;
22889 amit.gupta 46
import com.spice.profitmandi.common.model.PdfModel;
22866 ashik.ali 47
import com.spice.profitmandi.common.model.ProfitMandiConstants;
22889 amit.gupta 48
import com.spice.profitmandi.common.util.InsuranceUtils;
49
import com.spice.profitmandi.common.util.PdfUtils;
50
import com.spice.profitmandi.common.util.StringUtils;
22866 ashik.ali 51
import com.spice.profitmandi.common.web.util.ResponseSender;
22889 amit.gupta 52
import com.spice.profitmandi.dao.entity.dtr.Document;
53
import com.spice.profitmandi.dao.entity.dtr.GadgetCopsInsuranceCalc;
54
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
55
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
56
import com.spice.profitmandi.dao.entity.dtr.PolicyNumberGenerationSequence;
57
import com.spice.profitmandi.dao.entity.dtr.ThirdPartyInvoiceSequence;
58
import com.spice.profitmandi.dao.enumuration.dtr.ThirdParty;
59
import com.spice.profitmandi.dao.model.UserCart;
60
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
22866 ashik.ali 61
import com.spice.profitmandi.dao.repository.dtr.GadgetCopsInsuranceCalcRepository;
22889 amit.gupta 62
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
63
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
64
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
65
import com.spice.profitmandi.dao.repository.dtr.ThirdPartyInvoiceSequenceRepository;
66
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
67
import com.spice.profitmandi.dao.repository.fofo.InvoiceNumberGenerationSequenceRepository;
22898 amit.gupta 68
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
22889 amit.gupta 69
import com.spice.profitmandi.service.pricing.PricingService;
70
import com.spice.profitmandi.service.wallet.WalletService;
26655 amit.gupta 71
import com.spice.profitmandi.web.processor.OtpProcessor;
22866 ashik.ali 72
 
22889 amit.gupta 73
import in.shop2020.model.v1.order.WalletReferenceType;
74
 
22866 ashik.ali 75
@Controller
22889 amit.gupta 76
@Transactional(rollbackFor = Throwable.class)
22866 ashik.ali 77
public class InsuranceController {
23568 govind 78
	private static final Logger LOGGER = LogManager.getLogger(InsuranceController.class);
22889 amit.gupta 79
	private static final String gadgetCopsFilePath = "/GadgetCops";
22866 ashik.ali 80
 
81
	@Autowired
22889 amit.gupta 82
	private GadgetCopsInsuranceCalcRepository gadgetCopsInsuranceCalcRepository;
23015 amit.gupta 83
 
84
	//This is now unused as we are not supporting multiple companies.
85
	@Value("${fofo.warehouseIds}")
86
	private int[] warehouseIds; 
26655 amit.gupta 87
 
88
	@Autowired OtpProcessor otpProcessor;
89
 
22889 amit.gupta 90
 
91
	@RequestMapping(value = ProfitMandiConstants.URL_INSURANCE_GADGET_COPS_MAPPING, method = RequestMethod.GET)
92
	public ResponseEntity<?> getById(HttpServletRequest request) {
93
		LOGGER.info("requested url : " + request.getRequestURL().toString());
22932 amit.gupta 94
		List<GadgetCopsInsuranceCalc> calcList = gadgetCopsInsuranceCalcRepository.selectAll();
95
 
96
		return responseSender.ok(this.toCalcResponseList(calcList));
22889 amit.gupta 97
	}
98
 
99
	@Autowired
22866 ashik.ali 100
	ResponseSender<?> responseSender;
22889 amit.gupta 101
 
102
	@Autowired
103
	ThirdPartyInvoiceSequenceRepository thirdPartyInvoiceSequenceRepository;
104
 
105
	@Autowired
106
	DocumentRepository documentRepository;
107
 
108
	@Autowired
109
	InvoiceNumberGenerationSequenceRepository invoiceNumberGenerationSequenceRepository;
22866 ashik.ali 110
 
22889 amit.gupta 111
	@Autowired
112
	InsurancePolicyRepository insurancePolicyRepository;
113
 
114
	@Autowired
115
	PricingService pricingService;
22866 ashik.ali 116
 
117
	@Autowired
22889 amit.gupta 118
	JavaMailSender mailSender;
119
 
120
	@Autowired
121
	InsuranceProviderRepository insuranceProviderRepository;
122
 
123
	@Autowired
124
	UserAccountRepository userAccountRepository;
22866 ashik.ali 125
 
22889 amit.gupta 126
	@Autowired
127
	WalletService walletService;
128
 
129
	@Autowired
22898 amit.gupta 130
	UserWalletRepository userWalletRepositoy;
131
 
132
	@Autowired
22889 amit.gupta 133
	PolicyNumberGenerationSequenceRepository policyNumberGenerationSequenceRepository;
134
 
135
	@RequestMapping(value = ProfitMandiConstants.URL_DAMAGE_INSURANCE, method = RequestMethod.POST)
23015 amit.gupta 136
	public ResponseEntity<?> createDamageProtection(HttpServletRequest request,
22889 amit.gupta 137
			@RequestBody GadgetCopsDocumentInsuranceModel insuranceModel) throws Throwable {
22894 amit.gupta 138
		insuranceModel.setCustomerDateOfBirth(StringUtils.fromHypendatedDate(insuranceModel.getCustomerDateOfBirthString()));
22896 amit.gupta 139
		insuranceModel.setInvoiceCreationDate(LocalDate.now());
22893 amit.gupta 140
		insuranceModel.validate();
141
		int userId = (int) request.getAttribute("userId");
142
		UserCart uc = userAccountRepository.getUserCart(userId);
143
		PolicyNumberGenerationSequence policyNumberGenerationSequence = null;
144
		try {
145
			policyNumberGenerationSequence = policyNumberGenerationSequenceRepository.select();
146
			policyNumberGenerationSequence.setSequence(policyNumberGenerationSequence.getSequence() + 1);
147
			policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
148
		} catch (ProfitMandiBusinessException profitMandiBusinessException) {
149
			policyNumberGenerationSequence = new PolicyNumberGenerationSequence();
150
			policyNumberGenerationSequence.setSequence(1);
151
			policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
152
		}
153
		String policyNumber = StringUtils.generatePolicyNumber(ProfitMandiConstants.POLICY_NUMBER_PREFIX,
154
				policyNumberGenerationSequence.getSequence());
22889 amit.gupta 155
 
22893 amit.gupta 156
		InsuranceProvider insuranceProvider = insuranceProviderRepository
157
				.selectByName(ProfitMandiConstants.GADGET_COPS);
158
		Set<Float> devicePriceSet = new HashSet<>();
159
		devicePriceSet.add(insuranceModel.getPrice());
160
		Map<Float, GadgetCopsInsuranceCalc> insurancePricesMap = pricingService.getInsurancePrices(devicePriceSet,
161
				ProfitMandiConstants.GADGET_COPS);
162
		InsurancePolicy insurancePolicy = new InsurancePolicy();
163
		insurancePolicy.setInvoiceNumber(insuranceModel.getInvoiceNumber());
164
		insurancePolicy.setRetailerId(uc.getUserId());
165
		insurancePolicy.setPurchaseAmount(insurancePricesMap.get(insuranceModel.getPrice()).getDealerPrice());
166
		insurancePolicy.setSaleAmount(insurancePricesMap.get(insuranceModel.getPrice()).getSellingPrice());
167
		insurancePolicy.setSellingPrice(insuranceModel.getPrice());
168
		insurancePolicy.setSerialNumber(insuranceModel.getSerialNumber());
169
		insurancePolicy.setModelName(insuranceModel.getModelName());
170
		insurancePolicy.setBrand(insuranceModel.getBrand());
171
		insurancePolicy.setPolicyNumber(policyNumber);
172
		insurancePolicy.setProviderId(insuranceProvider.getId());
173
		insurancePolicy.setCustomerFirstName(insuranceModel.getCustomerFirstName());
174
		insurancePolicy.setCustomerLastName(insuranceModel.getCustomerFirstName());
175
		insurancePolicy.setCustomerMobileNumber(insuranceModel.getCustomerMobileNumber());
176
		insurancePolicy.setCustomerEmailId(insuranceModel.getCustomerEmailId());
177
		insurancePolicy.setCustomerDateOfBirth(insuranceModel.getCustomerDateOfBirth());
178
		insurancePolicy.setCustomerAddress1(insuranceModel.getCustomerAddress1());
179
		insurancePolicy.setCustomerAddress2(insuranceModel.getCustomerAddress2());
180
		insurancePolicy.setCustomerCity(insuranceModel.getCustomerCity());
181
		insurancePolicy.setCustomerPinCode(insuranceModel.getCustomerPinCode());
182
		insurancePolicy.setCustomerState(insuranceModel.getCustomerState());
183
		insurancePolicyRepository.persist(insurancePolicy);
22915 amit.gupta 184
		insuranceModel.setPolicyNumber(insurancePolicy.getPolicyNumber());
22913 amit.gupta 185
		String walletDescription = "Purchased Damage Protection policy " + insurancePolicy.getPolicyNumber() 
186
			+ " for " + insurancePolicy.getCustomerFirstName();
22893 amit.gupta 187
 
22999 amit.gupta 188
		walletService.consumeAmountFromWallet(uc.getUserId(), insurancePolicy.getId(), 
26516 amit.gupta 189
				WalletReferenceType.DAMAGE_PROTECTION, walletDescription, insurancePolicy.getSaleAmount(), LocalDateTime.now());
22898 amit.gupta 190
 
22893 amit.gupta 191
		try{
192
			InsuranceUtils.submitToGadgetCops(insuranceModel);
193
			insurancePolicy.setPosted(true);
194
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
195
			LOGGER.info("Unable to submit insurance policy details to {}", insuranceProvider.getName(), profitMandiBusinessException);
22994 amit.gupta 196
			throw new ProfitMandiBusinessException("", "", "GDTCPSServerDown_1000");
22893 amit.gupta 197
		}
198
		insurancePolicyRepository.persist(insurancePolicy);			
22889 amit.gupta 199
 
22893 amit.gupta 200
		PdfModel pdfModel = this.getInvoicePdfModel(insurancePolicy);
201
		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
24873 amit.gupta 202
		PdfUtils.generateAndWrite(Arrays.asList(pdfModel), byteArrayOutputStream);
22889 amit.gupta 203
 
22893 amit.gupta 204
		Document deviceDocument = documentRepository.selectById(insuranceModel.getDeviceImageDocumentId());
205
		File deviceImg = new File(deviceDocument.getPath() + deviceDocument.getName());
206
		Document invoiceDocument = documentRepository.selectById(insuranceModel.getDeviceImageDocumentId());
207
		File deviceInvoiceImg = new File(invoiceDocument.getPath() + invoiceDocument.getName());
22889 amit.gupta 208
 
23015 amit.gupta 209
		List<File> attachments = this.savePolicyDocs(insurancePolicy.getPolicyNumber(), byteArrayOutputStream, deviceImg, deviceInvoiceImg);
22893 amit.gupta 210
		String messageText = MessageFormat.format(
211
				"Dear {0}, Thank you for purchasing Damage Protection Plan. Your Policy number is {1}",
212
				insurancePolicy.getCustomerFirstName(), insurancePolicy.getPolicyNumber());
28308 amit.gupta 213
		//TODO: add template if needed
28307 amit.gupta 214
		otpProcessor.sendSms("", messageText, insurancePolicy.getCustomerMobileNumber());
23015 amit.gupta 215
		messageText += "\n Please find your Invoice and Documents submitted by you.";
22913 amit.gupta 216
		String subject = "Your Gadget Cop damage Protection purchase is successful";
22893 amit.gupta 217
		this.sendMailWithAttachments(insuranceModel.getCustomerEmailId() , subject, messageText, attachments);
22913 amit.gupta 218
 
22917 amit.gupta 219
		float taxableInsuranceMargin = (insurancePolicy.getSaleAmount() - insurancePolicy.getPurchaseAmount()) / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
22913 amit.gupta 220
		walletService.addAmountToWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.CASHBACK, "Cashback against insurance policy", 
26516 amit.gupta 221
				taxableInsuranceMargin, LocalDateTime.now());
22889 amit.gupta 222
		LOGGER.info("requested url : " + request.getRequestURL().toString());
22993 amit.gupta 223
		JSONObject jsonObject = new JSONObject();
23000 amit.gupta 224
		jsonObject.put("policyNumber", insurancePolicy.getPolicyNumber());
225
		jsonObject.put("premiumCharged", insurancePolicy.getSaleAmount());
22997 amit.gupta 226
		return responseSender.ok(jsonObject.toString());
22866 ashik.ali 227
	}
228
 
22889 amit.gupta 229
	private void sendMailWithAttachments(String email, String subject, String body, List<File> attachments) throws Exception {
230
 
231
    	MimeMessage message = mailSender.createMimeMessage();
22910 amit.gupta 232
    	MimeMessageHelper helper = new MimeMessageHelper(message,true);
22913 amit.gupta 233
    	helper.setSubject(subject);
22889 amit.gupta 234
    	helper.setText(body);
23016 amit.gupta 235
    	String[] cc = {"backup@shop2020.in", "gadgetcops.01@gmail.com"};
22889 amit.gupta 236
    	//String[] cc = {"amit.gupta@shop2020.in"};
22916 amit.gupta 237
    	helper.setCc(cc);
22918 amit.gupta 238
    	helper.setTo(email);
23839 amit.gupta 239
    	InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "ProfitMandi Admin");
240
    	helper.setTo("help@smartdukaan.com");
22889 amit.gupta 241
    	helper.setFrom(senderAddress);
242
    	for (File file : attachments) {
243
    		helper.addAttachment(file.getName(), file);
244
    	}
245
    	mailSender.send(message);
246
 
247
	}
248
 
249
	private List<File> savePolicyDocs(String policyNumber, ByteArrayOutputStream pdfInvoiceStream, File deviceImg,
250
			File deviceInvoiceImg) throws Exception {
251
		// save file to gadgetCops/policyname
252
		String policyFolderPath = gadgetCopsFilePath + File.separator + policyNumber;
253
		File destDeviceInvoiceImg = new File(policyFolderPath + File.separator + "deviceInvoice.jpg");
254
		File destDeviceImg = new File(policyFolderPath + File.separator + "device.jpg");
255
		FileUtils.copyFile(deviceImg, destDeviceImg);
256
		FileUtils.copyFile(deviceInvoiceImg, destDeviceInvoiceImg);
257
 
258
		OutputStream outStream = null;
259
		try {
260
			outStream = new FileOutputStream(policyFolderPath + File.separator + "invoice.pdf");
261
			pdfInvoiceStream.writeTo(outStream);
22911 amit.gupta 262
			pdfInvoiceStream.flush();
22889 amit.gupta 263
		} catch (IOException e) {
264
			e.printStackTrace();
265
		} finally {
266
			outStream.close();
267
			pdfInvoiceStream.close();
268
		}
269
 
270
		File pdfInvoice = new File(policyFolderPath + File.separator + "invoice.pdf");
271
		return Arrays.asList(pdfInvoice, destDeviceImg, destDeviceInvoiceImg);
272
	}
273
 
22907 amit.gupta 274
	public String getFormattedDate(LocalDateTime localDate) {
22889 amit.gupta 275
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
276
		return localDate.format(formatter);
277
	}
278
 
279
	private PdfModel getInvoicePdfModel(InsurancePolicy insurancePolicy) throws ProfitMandiBusinessException {
280
 
281
		PdfModel pdfModel = new PdfModel();
282
		pdfModel.setAuther("profitmandi");
283
		pdfModel.setTitle("Retailer Invoice");
22907 amit.gupta 284
		pdfModel.setInvoiceDate(getFormattedDate(insurancePolicy.getCreateTimestamp()));
22889 amit.gupta 285
 
286
		// insurance calculation
287
		Set<CustomInsurancePolicy> customInsurancePolicies = new HashSet<>();
288
		final float totalInsuranceTaxRate = 18;
289
 
290
		float taxableInsurancePrice = insurancePolicy.getSaleAmount() / (1 + totalInsuranceTaxRate / 100);
291
		CustomInsurancePolicy customInsurancePolicy = new CustomInsurancePolicy();
292
		customInsurancePolicy.setDescription("Damage Protection Plan for device IMEI #"
293
				+ insurancePolicy.getSerialNumber() + "\n Certificate No. " + insurancePolicy.getPolicyNumber());
294
		customInsurancePolicy.setHsnCode("998716");
295
		customInsurancePolicy.setRate(taxableInsurancePrice);
296
		customInsurancePolicy.setIgstRate(18);
297
		customInsurancePolicy.setIgstAmount(taxableInsurancePrice * 18 / 100);
298
		customInsurancePolicy.setCgstRate(9);
299
		customInsurancePolicy.setCgstAmount(taxableInsurancePrice * 9 / 100);
300
		customInsurancePolicy.setSgstRate(9);
301
		customInsurancePolicy.setSgstAmount(taxableInsurancePrice * 9 / 100);
302
		customInsurancePolicy.setNetAmount(insurancePolicy.getSaleAmount());
303
		customInsurancePolicies.add(customInsurancePolicy);
304
 
305
		pdfModel.setInsurancePolicies(customInsurancePolicies);
306
		CustomCustomer customCustomer = new CustomCustomer();
307
		customCustomer.setFirstName(insurancePolicy.getCustomerFirstName());
308
		customCustomer.setLastName(insurancePolicy.getCustomerLastName());
309
		customCustomer.setEmailId(insurancePolicy.getCustomerEmailId());
310
		customCustomer.setMobileNumber(insurancePolicy.getCustomerMobileNumber());
311
 
312
		CustomAddress customAddress = new CustomAddress();
313
		customAddress.setName(insurancePolicy.getCustomerFirstName() + " " + insurancePolicy.getCustomerLastName());
314
		customAddress.setLine1(insurancePolicy.getCustomerAddress1());
315
		customAddress.setLine2(insurancePolicy.getCustomerAddress2());
316
		customAddress.setLandmark("");
317
		customAddress.setCity(insurancePolicy.getCustomerCity());
318
		customAddress.setPinCode(insurancePolicy.getCustomerPinCode());
319
		customAddress.setState(insurancePolicy.getCustomerState());
320
		customAddress.setPhoneNumber(insurancePolicy.getCustomerMobileNumber());
321
		customCustomer.setAddress(customAddress);
322
		pdfModel.setCustomer(customCustomer);
323
 
324
		// TODO get invoice number for damageProtection provider
325
		pdfModel.setInvoiceNumber(thirdPartyInvoiceSequenceRepository.getNextSequence(ThirdParty.GADGET_COP));
326
		pdfModel.setTotalAmount(gadgetCopsInsuranceCalcRepository.selectByPrice(insurancePolicy.getSellingPrice()));
327
 
328
		// Here bill is generated on behalf of GadgetCop
329
		ThirdPartyInvoiceSequence damageProtectionProvider = thirdPartyInvoiceSequenceRepository
330
				.selectByThirdParty(ThirdParty.GADGET_COP);
331
		// Gadget Cop
332
		// Gadget cop mobile
333
		CustomRetailer customRetailer = new CustomRetailer();
334
		customRetailer.setBusinessName(damageProtectionProvider.getName());
335
		customRetailer.setMobileNumber(damageProtectionProvider.getMobileNumber());
336
		customRetailer.setGstNumber(damageProtectionProvider.getGstNumber());
22912 amit.gupta 337
		//customRetailer.setAddress(address);
338
 
22889 amit.gupta 339
		CustomAddress providerAddress = new CustomAddress();
340
		providerAddress.setCity(damageProtectionProvider.getCity());
341
		providerAddress.setLine1(damageProtectionProvider.getLine1());
342
		providerAddress.setLine2(damageProtectionProvider.getLine2());
343
		providerAddress.setPinCode(damageProtectionProvider.getPin());
344
		providerAddress.setPhoneNumber(damageProtectionProvider.getMobileNumber());
345
		providerAddress.setState(damageProtectionProvider.getState());
22912 amit.gupta 346
 
347
		customRetailer.setAddress(providerAddress);
22889 amit.gupta 348
		pdfModel.setRetailer(customRetailer);
349
 
350
		Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
351
		pdfModel.setOrderItems(customerFofoOrderItems);
23001 amit.gupta 352
		pdfModel.setTncs(Arrays.asList("Please check out Policy Schedule for detailed terms and conditions."));
22889 amit.gupta 353
		return pdfModel;
354
	}
22932 amit.gupta 355
 
356
	private List<GadgetCopsInsuranceCalcResponse> toCalcResponseList (List<GadgetCopsInsuranceCalc> calcList) {
357
		List<GadgetCopsInsuranceCalcResponse> calcResponseList = new ArrayList<>();
358
		for (GadgetCopsInsuranceCalc calc : calcList) {
359
			GadgetCopsInsuranceCalcResponse calcResponse = new GadgetCopsInsuranceCalcResponse();
360
			calcResponse.setDealerPrice(calc.getDealerPrice());
361
			calcResponse.setPriceRangeMax(calc.getPriceRangeMax());
362
			calcResponse.setPriceRangeMin(calc.getPriceRangeMin());
22999 amit.gupta 363
			calcResponse.setSellingPrice(calc.getSellingPrice());
22932 amit.gupta 364
			float taxableInsuranceMargin = (calc.getSellingPrice() - calc.getDealerPrice()) / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
22937 amit.gupta 365
			calcResponse.setCashBack((int)taxableInsuranceMargin);
22932 amit.gupta 366
			calcResponseList.add(calcResponse);
367
		}
368
		return calcResponseList;
369
	}
22889 amit.gupta 370
 
22866 ashik.ali 371
}