Subversion Repositories SmartDukaan

Rev

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

Rev 24873 Rev 26516
Line 181... Line 181...
181
		insuranceModel.setPolicyNumber(insurancePolicy.getPolicyNumber());
181
		insuranceModel.setPolicyNumber(insurancePolicy.getPolicyNumber());
182
		String walletDescription = "Purchased Damage Protection policy " + insurancePolicy.getPolicyNumber() 
182
		String walletDescription = "Purchased Damage Protection policy " + insurancePolicy.getPolicyNumber() 
183
			+ " for " + insurancePolicy.getCustomerFirstName();
183
			+ " for " + insurancePolicy.getCustomerFirstName();
184
		
184
		
185
		walletService.consumeAmountFromWallet(uc.getUserId(), insurancePolicy.getId(), 
185
		walletService.consumeAmountFromWallet(uc.getUserId(), insurancePolicy.getId(), 
186
				WalletReferenceType.DAMAGE_PROTECTION, walletDescription, insurancePolicy.getSaleAmount());
186
				WalletReferenceType.DAMAGE_PROTECTION, walletDescription, insurancePolicy.getSaleAmount(), LocalDateTime.now());
187
		
187
		
188
		try{
188
		try{
189
			InsuranceUtils.submitToGadgetCops(insuranceModel);
189
			InsuranceUtils.submitToGadgetCops(insuranceModel);
190
			insurancePolicy.setPosted(true);
190
			insurancePolicy.setPosted(true);
191
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
191
		}catch (ProfitMandiBusinessException profitMandiBusinessException) {
Line 212... Line 212...
212
		String subject = "Your Gadget Cop damage Protection purchase is successful";
212
		String subject = "Your Gadget Cop damage Protection purchase is successful";
213
		this.sendMailWithAttachments(insuranceModel.getCustomerEmailId() , subject, messageText, attachments);
213
		this.sendMailWithAttachments(insuranceModel.getCustomerEmailId() , subject, messageText, attachments);
214
 
214
 
215
		float taxableInsuranceMargin = (insurancePolicy.getSaleAmount() - insurancePolicy.getPurchaseAmount()) / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
215
		float taxableInsuranceMargin = (insurancePolicy.getSaleAmount() - insurancePolicy.getPurchaseAmount()) / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
216
		walletService.addAmountToWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.CASHBACK, "Cashback against insurance policy", 
216
		walletService.addAmountToWallet(uc.getUserId(), insurancePolicy.getId(), WalletReferenceType.CASHBACK, "Cashback against insurance policy", 
217
				taxableInsuranceMargin);
217
				taxableInsuranceMargin, LocalDateTime.now());
218
		LOGGER.info("requested url : " + request.getRequestURL().toString());
218
		LOGGER.info("requested url : " + request.getRequestURL().toString());
219
		JSONObject jsonObject = new JSONObject();
219
		JSONObject jsonObject = new JSONObject();
220
		jsonObject.put("policyNumber", insurancePolicy.getPolicyNumber());
220
		jsonObject.put("policyNumber", insurancePolicy.getPolicyNumber());
221
		jsonObject.put("premiumCharged", insurancePolicy.getSaleAmount());
221
		jsonObject.put("premiumCharged", insurancePolicy.getSaleAmount());
222
		return responseSender.ok(jsonObject.toString());
222
		return responseSender.ok(jsonObject.toString());