| Line 13... |
Line 13... |
| 13 |
import java.util.Arrays;
|
13 |
import java.util.Arrays;
|
| 14 |
import java.util.HashSet;
|
14 |
import java.util.HashSet;
|
| 15 |
import java.util.List;
|
15 |
import java.util.List;
|
| 16 |
import java.util.Map;
|
16 |
import java.util.Map;
|
| 17 |
import java.util.Set;
|
17 |
import java.util.Set;
|
| - |
|
18 |
import java.util.stream.Collectors;
|
| 18 |
|
19 |
|
| 19 |
import javax.mail.internet.InternetAddress;
|
20 |
import javax.mail.internet.InternetAddress;
|
| 20 |
import javax.mail.internet.MimeMessage;
|
21 |
import javax.mail.internet.MimeMessage;
|
| 21 |
import javax.servlet.http.HttpServletRequest;
|
22 |
import javax.servlet.http.HttpServletRequest;
|
| 22 |
|
23 |
|
| Line 47... |
Line 48... |
| 47 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
48 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 48 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
49 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
| 49 |
import com.spice.profitmandi.common.util.PdfUtils;
|
50 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 50 |
import com.spice.profitmandi.common.util.StringUtils;
|
51 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 51 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
52 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| - |
|
53 |
import com.spice.profitmandi.dao.entity.catalog.RangeItem;
|
| - |
|
54 |
import com.spice.profitmandi.dao.entity.catalog.RangeItemPrice;
|
| 52 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
55 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 53 |
import com.spice.profitmandi.dao.entity.dtr.GadgetCopsInsuranceCalc;
|
56 |
import com.spice.profitmandi.dao.entity.dtr.GadgetCopsInsuranceCalc;
|
| 54 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
57 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| 55 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
58 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
| 56 |
import com.spice.profitmandi.dao.entity.dtr.PolicyNumberGenerationSequence;
|
59 |
import com.spice.profitmandi.dao.entity.dtr.PolicyNumberGenerationSequence;
|
| 57 |
import com.spice.profitmandi.dao.entity.dtr.ThirdPartyInvoiceSequence;
|
60 |
import com.spice.profitmandi.dao.entity.dtr.ThirdPartyInvoiceSequence;
|
| 58 |
import com.spice.profitmandi.dao.enumuration.dtr.ThirdParty;
|
61 |
import com.spice.profitmandi.dao.enumuration.dtr.ThirdParty;
|
| 59 |
import com.spice.profitmandi.dao.model.UserCart;
|
62 |
import com.spice.profitmandi.dao.model.UserCart;
|
| - |
|
63 |
import com.spice.profitmandi.dao.repository.catalog.RangeItemPriceRepository;
|
| - |
|
64 |
import com.spice.profitmandi.dao.repository.catalog.RangeItemRepository;
|
| 60 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
65 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 61 |
import com.spice.profitmandi.dao.repository.dtr.GadgetCopsInsuranceCalcRepository;
|
66 |
import com.spice.profitmandi.dao.repository.dtr.GadgetCopsInsuranceCalcRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
67 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
68 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
|
69 |
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
|
| Line 77... |
Line 82... |
| 77 |
public class InsuranceController {
|
82 |
public class InsuranceController {
|
| 78 |
private static final Logger LOGGER = LogManager.getLogger(InsuranceController.class);
|
83 |
private static final Logger LOGGER = LogManager.getLogger(InsuranceController.class);
|
| 79 |
private static final String gadgetCopsFilePath = "/GadgetCops";
|
84 |
private static final String gadgetCopsFilePath = "/GadgetCops";
|
| 80 |
|
85 |
|
| 81 |
@Autowired
|
86 |
@Autowired
|
| 82 |
private GadgetCopsInsuranceCalcRepository gadgetCopsInsuranceCalcRepository;
|
87 |
private RangeItemPriceRepository rangeItemPriceRepository;
|
| - |
|
88 |
|
| - |
|
89 |
@Autowired
|
| - |
|
90 |
private RangeItemRepository rangeItemRepository;
|
| 83 |
|
91 |
|
| 84 |
//This is now unused as we are not supporting multiple companies.
|
92 |
//This is now unused as we are not supporting multiple companies.
|
| 85 |
@Value("${fofo.warehouseIds}")
|
93 |
@Value("${fofo.warehouseIds}")
|
| 86 |
private int[] warehouseIds;
|
94 |
private int[] warehouseIds;
|
| 87 |
|
95 |
|
| Line 89... |
Line 97... |
| 89 |
|
97 |
|
| 90 |
|
98 |
|
| 91 |
@RequestMapping(value = ProfitMandiConstants.URL_INSURANCE_GADGET_COPS_MAPPING, method = RequestMethod.GET)
|
99 |
@RequestMapping(value = ProfitMandiConstants.URL_INSURANCE_GADGET_COPS_MAPPING, method = RequestMethod.GET)
|
| 92 |
public ResponseEntity<?> getById(HttpServletRequest request) {
|
100 |
public ResponseEntity<?> getById(HttpServletRequest request) {
|
| 93 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
101 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| - |
|
102 |
Map<Integer, List<RangeItemPrice>> rangeItemPrices = rangeItemPriceRepository.selectAll().stream().collect(Collectors.groupingBy(RangeItemPrice::getRangeItemId, Collectors.toList()));
|
| 94 |
List<GadgetCopsInsuranceCalc> calcList = gadgetCopsInsuranceCalcRepository.selectAll();
|
103 |
List<RangeItem> rangeItems = rangeItemRepository.selectAll();
|
| 95 |
|
- |
|
| - |
|
104 |
rangeItems.stream().forEach(x-> x.setRangeItemPrices(rangeItemPrices.get(x.getId())));
|
| 96 |
return responseSender.ok(this.toCalcResponseList(calcList));
|
105 |
return responseSender.ok(rangeItems);
|
| 97 |
}
|
106 |
}
|
| 98 |
|
107 |
|
| 99 |
@Autowired
|
108 |
@Autowired
|
| 100 |
ResponseSender<?> responseSender;
|
109 |
ResponseSender<?> responseSender;
|
| - |
|
110 |
|
| - |
|
111 |
@Autowired
|
| - |
|
112 |
GadgetCopsInsuranceCalcRepository gadgetCopsInsuranceCalcRepository;
|
| 101 |
|
113 |
|
| 102 |
@Autowired
|
114 |
@Autowired
|
| 103 |
ThirdPartyInvoiceSequenceRepository thirdPartyInvoiceSequenceRepository;
|
115 |
ThirdPartyInvoiceSequenceRepository thirdPartyInvoiceSequenceRepository;
|
| 104 |
|
116 |
|
| 105 |
@Autowired
|
117 |
@Autowired
|
| Line 350... |
Line 362... |
| 350 |
Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
|
362 |
Set<CustomOrderItem> customerFofoOrderItems = new HashSet<>();
|
| 351 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
363 |
pdfModel.setOrderItems(customerFofoOrderItems);
|
| 352 |
pdfModel.setTncs(Arrays.asList("Please check out Policy Schedule for detailed terms and conditions."));
|
364 |
pdfModel.setTncs(Arrays.asList("Please check out Policy Schedule for detailed terms and conditions."));
|
| 353 |
return pdfModel;
|
365 |
return pdfModel;
|
| 354 |
}
|
366 |
}
|
| 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());
|
- |
|
| 363 |
calcResponse.setSellingPrice(calc.getSellingPrice());
|
- |
|
| 364 |
float taxableInsuranceMargin = (calc.getSellingPrice() - calc.getDealerPrice()) / (1 + ProfitMandiConstants.INSURANCE_TAX_RATE / 100);
|
- |
|
| 365 |
calcResponse.setCashBack((int)taxableInsuranceMargin);
|
- |
|
| 366 |
calcResponseList.add(calcResponse);
|
- |
|
| 367 |
}
|
- |
|
| 368 |
return calcResponseList;
|
- |
|
| 369 |
}
|
- |
|
| 370 |
|
367 |
|
| 371 |
}
|
368 |
}
|