| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.ByteArrayInputStream;
|
3 |
import java.io.ByteArrayInputStream;
|
| 4 |
import java.io.ByteArrayOutputStream;
|
4 |
import java.io.ByteArrayOutputStream;
|
| 5 |
import java.io.InputStream;
|
5 |
import java.io.InputStream;
|
| 6 |
import java.lang.ProcessBuilder.Redirect;
|
6 |
import java.time.DateTimeException;
|
| - |
|
7 |
import java.time.LocalDate;
|
| 7 |
import java.util.ArrayList;
|
8 |
import java.util.ArrayList;
|
| 8 |
import java.util.Collection;
|
9 |
import java.util.Collection;
|
| 9 |
import java.util.HashMap;
|
10 |
import java.util.HashMap;
|
| 10 |
import java.util.HashSet;
|
11 |
import java.util.HashSet;
|
| 11 |
import java.util.Iterator;
|
12 |
import java.util.Iterator;
|
| Line 37... |
Line 38... |
| 37 |
import com.spice.profitmandi.common.model.CartFofo;
|
38 |
import com.spice.profitmandi.common.model.CartFofo;
|
| 38 |
import com.spice.profitmandi.common.model.CustomAddress;
|
39 |
import com.spice.profitmandi.common.model.CustomAddress;
|
| 39 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
40 |
import com.spice.profitmandi.common.model.CustomCustomer;
|
| 40 |
import com.spice.profitmandi.common.model.CustomFofoLineItem;
|
41 |
import com.spice.profitmandi.common.model.CustomFofoLineItem;
|
| 41 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
42 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
| - |
|
43 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
| 42 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
44 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| - |
|
45 |
import com.spice.profitmandi.common.model.GadgetCopsInsuranceModel;
|
| 43 |
import com.spice.profitmandi.common.model.GstRate;
|
46 |
import com.spice.profitmandi.common.model.GstRate;
|
| 44 |
import com.spice.profitmandi.common.model.PdfModel;
|
47 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 45 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
48 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
49 |
import com.spice.profitmandi.common.model.SerialNumberDetail;
|
| - |
|
50 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
| 46 |
import com.spice.profitmandi.common.util.PdfUtils;
|
51 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| 47 |
import com.spice.profitmandi.common.util.StringUtils;
|
52 |
import com.spice.profitmandi.common.util.StringUtils;
|
| 48 |
import com.spice.profitmandi.common.util.Utils;
|
53 |
import com.spice.profitmandi.common.util.Utils;
|
| 49 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
54 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| - |
|
55 |
import com.spice.profitmandi.dao.entity.dtr.GadgetCopsInsuranceCalc;
|
| - |
|
56 |
import com.spice.profitmandi.dao.entity.dtr.InsurancePolicy;
|
| - |
|
57 |
import com.spice.profitmandi.dao.entity.dtr.InsuranceProvider;
|
| - |
|
58 |
import com.spice.profitmandi.dao.entity.dtr.PolicyNumberGenerationSequence;
|
| 50 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
59 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| 51 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
60 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 52 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
61 |
import com.spice.profitmandi.dao.entity.fofo.CurrentInventorySnapshot;
|
| 53 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
62 |
import com.spice.profitmandi.dao.entity.fofo.Customer;
|
| 54 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
63 |
import com.spice.profitmandi.dao.entity.fofo.CustomerAddress;
|
| Line 61... |
Line 70... |
| 61 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
70 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
| 62 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
71 |
import com.spice.profitmandi.dao.entity.fofo.ScanRecord;
|
| 63 |
import com.spice.profitmandi.dao.entity.user.Address;
|
72 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 64 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
73 |
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
|
| 65 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
74 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| - |
|
75 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| - |
|
76 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| - |
|
77 |
import com.spice.profitmandi.dao.repository.dtr.PolicyNumberGenerationSequenceRepository;
|
| 66 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
78 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRegisteredAddressRepository;
|
| 67 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
79 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
| 68 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
80 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 69 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
81 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 70 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
82 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| Line 144... |
Line 156... |
| 144 |
@Autowired
|
156 |
@Autowired
|
| 145 |
CustomerAddressRepository customerAddressRepository;
|
157 |
CustomerAddressRepository customerAddressRepository;
|
| 146 |
|
158 |
|
| 147 |
@Autowired
|
159 |
@Autowired
|
| 148 |
ItemRepository itemRepository;
|
160 |
ItemRepository itemRepository;
|
| - |
|
161 |
|
| - |
|
162 |
@Autowired
|
| - |
|
163 |
InsuranceProviderRepository insuranceProviderRepository;
|
| - |
|
164 |
|
| - |
|
165 |
@Autowired
|
| - |
|
166 |
InsurancePolicyRepository insurancePolicyRepository;
|
| - |
|
167 |
|
| - |
|
168 |
@Autowired
|
| - |
|
169 |
PolicyNumberGenerationSequenceRepository policyNumberGenerationSequenceRepository;
|
| 149 |
|
170 |
|
| 150 |
@Autowired
|
171 |
@Autowired
|
| 151 |
MVCResponseSender mvcResponseSender;
|
172 |
MVCResponseSender mvcResponseSender;
|
| 152 |
|
173 |
|
| 153 |
@Autowired
|
174 |
@Autowired
|
| 154 |
CookiesProcessor cookiesProcessor;
|
175 |
CookiesProcessor cookiesProcessor;
|
| 155 |
|
176 |
|
| 156 |
@Autowired
|
177 |
@Autowired
|
| 157 |
PricingService pricingService;
|
178 |
PricingService pricingService;
|
| 158 |
|
- |
|
| 159 |
|
- |
|
| 160 |
|
- |
|
| 161 |
|
179 |
|
| 162 |
@RequestMapping(value = "/order")
|
180 |
@RequestMapping(value = "/order")
|
| 163 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model) throws Exception{
|
181 |
public String orderIndex(HttpServletRequest request, @RequestParam(name = "cartData") String cartData, Model model) throws Exception{
|
| 164 |
try {
|
182 |
try {
|
| 165 |
cookiesProcessor.getCookiesObject(request);
|
183 |
cookiesProcessor.getCookiesObject(request);
|
| Line 179... |
Line 197... |
| 179 |
System.out.println(cartObject.get(key));
|
197 |
System.out.println(cartObject.get(key));
|
| 180 |
}
|
198 |
}
|
| 181 |
CartFofo cf = new CartFofo();
|
199 |
CartFofo cf = new CartFofo();
|
| 182 |
cf.setItemId(cartObject.getJSONObject(key).getInt("itemId"));
|
200 |
cf.setItemId(cartObject.getJSONObject(key).getInt("itemId"));
|
| 183 |
cf.setQuantity(cartObject.getJSONObject(key).getInt("quantity"));
|
201 |
cf.setQuantity(cartObject.getJSONObject(key).getInt("quantity"));
|
| - |
|
202 |
|
| 184 |
if (cf.getQuantity() <= 0){
|
203 |
if (cf.getQuantity() <= 0){
|
| 185 |
continue;
|
204 |
continue;
|
| 186 |
}
|
205 |
}
|
| 187 |
cartItems.add(cf);
|
206 |
cartItems.add(cf);
|
| 188 |
itemIds.add(cartObject.getJSONObject(key).getInt("itemId"));
|
207 |
itemIds.add(cartObject.getJSONObject(key).getInt("itemId"));
|
| 189 |
}
|
208 |
}
|
| 190 |
Map<Integer, Item> itemMap = new HashMap<Integer, Item>();
|
209 |
Map<Integer, Item> itemMap = new HashMap<Integer, Item>();
|
| - |
|
210 |
Set<Float> prices = new HashSet<>();
|
| - |
|
211 |
Map<Float, GadgetCopsInsuranceCalc> insurancePriceMap = new HashMap<>();
|
| - |
|
212 |
Map<Integer, GadgetCopsInsuranceCalc> itemIdInsurancePrice = new HashMap<>();
|
| 191 |
if (itemIds.size() > 0){
|
213 |
if (itemIds.size() > 0){
|
| 192 |
List<Item> items = itemRepository.selectByIds(itemIds);
|
214 |
List<Item> items = itemRepository.selectByIds(itemIds);
|
| 193 |
for (Item i : items){
|
215 |
for (Item i : items){
|
| 194 |
itemMap.put(i.getId(), i);
|
216 |
itemMap.put(i.getId(), i);
|
| - |
|
217 |
prices.add(i.getSellingPrice());
|
| - |
|
218 |
}
|
| - |
|
219 |
try{
|
| - |
|
220 |
insurancePriceMap = pricingService.getInsurancePrices(prices, ProfitMandiConstants.GADGET_COPS);
|
| - |
|
221 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
222 |
LOGGER.error("Insurance Provider not found : ", profitMandiBusinessException);
|
| - |
|
223 |
return "error";
|
| - |
|
224 |
}
|
| - |
|
225 |
for(Item item : items){
|
| - |
|
226 |
itemIdInsurancePrice.put(item.getId(), insurancePriceMap.get(item.getSellingPrice()));
|
| 195 |
}
|
227 |
}
|
| 196 |
}
|
228 |
}
|
| 197 |
for (CartFofo cf : cartItems){
|
229 |
for (CartFofo cf : cartItems){
|
| 198 |
Item i = itemMap.get(cf.getItemId());
|
230 |
Item i = itemMap.get(cf.getItemId());
|
| 199 |
if (i == null){
|
231 |
if (i == null){
|
| 200 |
continue;
|
232 |
continue;
|
| 201 |
}
|
233 |
}
|
| 202 |
cf.setDisplayName(getValidName(i.getBrand())+" "+getValidName(i.getModelName())+" "+getValidName(i.getModelNumber())+" "+getValidName(i.getColor()).replaceAll("\\s+", " "));
|
234 |
cf.setDisplayName(getValidName(i.getBrand())+" "+getValidName(i.getModelName())+" "+getValidName(i.getModelNumber())+" "+getValidName(i.getColor()).replaceAll("\\s+", " "));
|
| 203 |
cf.setItemType(i.getType());
|
235 |
cf.setItemType(i.getType());
|
| 204 |
}
|
236 |
}
|
| - |
|
237 |
|
| - |
|
238 |
|
| - |
|
239 |
|
| - |
|
240 |
|
| 205 |
model.addAttribute("cartObj", cartItems);
|
241 |
model.addAttribute("cartObj", cartItems);
|
| - |
|
242 |
model.addAttribute("itemIdInsurancePrice", itemIdInsurancePrice);
|
| 206 |
return "order-index";
|
243 |
return "order-index";
|
| 207 |
}
|
244 |
}
|
| 208 |
|
245 |
|
| 209 |
private String getValidName(String name){
|
246 |
private String getValidName(String name){
|
| 210 |
return name!=null?name:"";
|
247 |
return name!=null?name:"";
|
| Line 279... |
Line 316... |
| 279 |
Map<Integer, CustomFofoLineItem> customFofoLineItemMap = new HashMap<>();
|
316 |
Map<Integer, CustomFofoLineItem> customFofoLineItemMap = new HashMap<>();
|
| 280 |
Map<Integer, Float> lineItemPrice = new HashMap<>(); //this is for pricing error
|
317 |
Map<Integer, Float> lineItemPrice = new HashMap<>(); //this is for pricing error
|
| 281 |
float totalAmount = 0;
|
318 |
float totalAmount = 0;
|
| 282 |
for(CustomFofoLineItem customFofoLineItem : createOrderRequest.getFofoLineItems()){
|
319 |
for(CustomFofoLineItem customFofoLineItem : createOrderRequest.getFofoLineItems()){
|
| 283 |
itemIds.add(customFofoLineItem.getItemId());
|
320 |
itemIds.add(customFofoLineItem.getItemId());
|
| 284 |
if(!customFofoLineItem.getSerialNumbers().isEmpty() && customFofoLineItem.getQuantity() != customFofoLineItem.getSerialNumbers().size()){
|
321 |
if(!customFofoLineItem.getSerialNumberDetails().isEmpty() && customFofoLineItem.getQuantity() != customFofoLineItem.getSerialNumberDetails().size()){
|
| 285 |
itemIdQuantity.put(customFofoLineItem.getItemId(), customFofoLineItem.getQuantity());
|
322 |
itemIdQuantity.put(customFofoLineItem.getItemId(), customFofoLineItem.getQuantity());
|
| 286 |
}
|
323 |
}
|
| 287 |
if(!(customFofoLineItem.getSellingPrice() > 0)){
|
324 |
if(!(customFofoLineItem.getSellingPrice() > 0)){
|
| 288 |
lineItemPrice.put(customFofoLineItem.getItemId(), customFofoLineItem.getSellingPrice());
|
325 |
lineItemPrice.put(customFofoLineItem.getItemId(), customFofoLineItem.getSellingPrice());
|
| 289 |
}else{
|
326 |
}else{
|
| 290 |
totalAmount = totalAmount + customFofoLineItem.getSellingPrice() * customFofoLineItem.getQuantity();
|
327 |
totalAmount = totalAmount + customFofoLineItem.getSellingPrice() * customFofoLineItem.getQuantity();
|
| - |
|
328 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
| - |
|
329 |
if(serialNumberDetail.isInsurance() && serialNumberDetail.getAmount() > 0){
|
| - |
|
330 |
totalAmount = totalAmount + serialNumberDetail.getAmount();
|
| - |
|
331 |
}
|
| - |
|
332 |
}
|
| 291 |
}
|
333 |
}
|
| 292 |
customFofoLineItemMap.put(customFofoLineItem.getItemId(), customFofoLineItem);
|
334 |
customFofoLineItemMap.put(customFofoLineItem.getItemId(), customFofoLineItem);
|
| 293 |
}
|
335 |
}
|
| 294 |
if(!itemIdQuantity.isEmpty()){
|
336 |
if(!itemIdQuantity.isEmpty()){
|
| 295 |
// if item quantity does not match with given serialnumbers size
|
337 |
// if item quantity does not match with given serialnumbers size
|
| Line 371... |
Line 413... |
| 371 |
itemMap.put(i.getId(), i);
|
413 |
itemMap.put(i.getId(), i);
|
| 372 |
}
|
414 |
}
|
| 373 |
|
415 |
|
| 374 |
Set<Integer> nonSerializedItemIds = new HashSet<>();
|
416 |
Set<Integer> nonSerializedItemIds = new HashSet<>();
|
| 375 |
Set<String> serialNumbers = new HashSet<>();
|
417 |
Set<String> serialNumbers = new HashSet<>();
|
| 376 |
|
- |
|
| - |
|
418 |
Map<String, Float> insuranceSerialNumberItemPrice = new HashMap<>();
|
| - |
|
419 |
Map<String, Float> insuranceSerialNumberSaleAmount = new HashMap<>();
|
| - |
|
420 |
Map<String, String> serialNumberModelName = new HashMap<>();
|
| - |
|
421 |
Map<String, String> serialNumberBrand = new HashMap<>();
|
| 377 |
Collection<CustomFofoLineItem> lineItemsValues = customFofoLineItemMap.values();
|
422 |
Collection<CustomFofoLineItem> lineItemsValues = customFofoLineItemMap.values();
|
| 378 |
for (CustomFofoLineItem cli : lineItemsValues){
|
423 |
for (CustomFofoLineItem cli : lineItemsValues){
|
| 379 |
|
424 |
|
| 380 |
Item item = itemMap.get(cli.getItemId());
|
425 |
Item item = itemMap.get(cli.getItemId());
|
| 381 |
if (item.getType().equals(ItemType.SERIALIZED)){
|
426 |
if (item.getType().equals(ItemType.SERIALIZED)){
|
| 382 |
for (String s : cli.getSerialNumbers()){
|
427 |
for (SerialNumberDetail serialNumberDetail : cli.getSerialNumberDetails()){
|
| - |
|
428 |
serialNumbers.add(serialNumberDetail.getSerialNumber());
|
| 383 |
serialNumbers.add(s);
|
429 |
if(serialNumberDetail.isInsurance()){
|
| - |
|
430 |
insuranceSerialNumberItemPrice.put(serialNumberDetail.getSerialNumber(), cli.getSellingPrice());
|
| - |
|
431 |
insuranceSerialNumberSaleAmount.put(serialNumberDetail.getSerialNumber(), serialNumberDetail.getAmount());
|
| - |
|
432 |
serialNumberModelName.put(serialNumberDetail.getSerialNumber(), item.getModelName());
|
| - |
|
433 |
serialNumberBrand.put(serialNumberDetail.getSerialNumber(), item.getBrand());
|
| - |
|
434 |
}
|
| 384 |
}
|
435 |
}
|
| 385 |
}
|
436 |
}
|
| 386 |
else{
|
437 |
else{
|
| 387 |
nonSerializedItemIds.add(cli.getItemId());
|
438 |
nonSerializedItemIds.add(cli.getItemId());
|
| 388 |
}
|
439 |
}
|
| Line 392... |
Line 443... |
| 392 |
|
443 |
|
| 393 |
Map<Integer, List<InventoryItem>> serializedInventoryItemMap = new HashMap<Integer, List<InventoryItem>>();
|
444 |
Map<Integer, List<InventoryItem>> serializedInventoryItemMap = new HashMap<Integer, List<InventoryItem>>();
|
| 394 |
Map<Integer, List<InventoryItem>> nonSerializedInventoryItemMap = new HashMap<Integer, List<InventoryItem>>();
|
445 |
Map<Integer, List<InventoryItem>> nonSerializedInventoryItemMap = new HashMap<Integer, List<InventoryItem>>();
|
| 395 |
Map<Integer, List<Float>> itemIdPriceDropAmount = new HashMap<>();
|
446 |
Map<Integer, List<Float>> itemIdPriceDropAmount = new HashMap<>();
|
| 396 |
|
447 |
|
| 397 |
if (serialNumbers.size() > 0 ){
|
448 |
if (!serialNumbers.isEmpty()){
|
| 398 |
List<InventoryItem> serializedInventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoDetails.getFofoId(), serialNumbers);
|
449 |
List<InventoryItem> serializedInventoryItems = inventoryItemRepository.selectByFofoIdSerialNumbers(fofoDetails.getFofoId(), serialNumbers);
|
| - |
|
450 |
LOGGER.info("serializedInventoryItems {}", serializedInventoryItems);
|
| 399 |
for (InventoryItem it : serializedInventoryItems){
|
451 |
for (InventoryItem it : serializedInventoryItems){
|
| 400 |
if (it.getGoodQuantity() == 1){
|
452 |
if (it.getGoodQuantity() == 1){
|
| 401 |
if (serializedInventoryItemMap.containsKey(it.getItemId())){
|
453 |
if (serializedInventoryItemMap.containsKey(it.getItemId())){
|
| 402 |
serializedInventoryItemMap.get(it.getItemId()).add(it);
|
454 |
serializedInventoryItemMap.get(it.getItemId()).add(it);
|
| 403 |
itemIdPriceDropAmount.get(it.getItemId()).add(it.getUnitPrice() - (it.getPriceDropAmount()==null?0:it.getPriceDropAmount()));
|
455 |
itemIdPriceDropAmount.get(it.getItemId()).add(it.getUnitPrice() - (it.getPriceDropAmount()==null?0:it.getPriceDropAmount()));
|
| Line 412... |
Line 464... |
| 412 |
}
|
464 |
}
|
| 413 |
}
|
465 |
}
|
| 414 |
}
|
466 |
}
|
| 415 |
}
|
467 |
}
|
| 416 |
|
468 |
|
| 417 |
if (nonSerializedItemIds.size() > 0){
|
469 |
if (!nonSerializedItemIds.isEmpty()){
|
| 418 |
List<InventoryItem> nonSerializedInventoryItems = inventoryItemRepository.selectByFofoIdItemIds(fofoDetails.getFofoId(), nonSerializedItemIds);
|
470 |
List<InventoryItem> nonSerializedInventoryItems = inventoryItemRepository.selectByFofoIdItemIds(fofoDetails.getFofoId(), nonSerializedItemIds);
|
| 419 |
for (InventoryItem it : nonSerializedInventoryItems){
|
471 |
for (InventoryItem it : nonSerializedInventoryItems){
|
| 420 |
if (it.getGoodQuantity() > 0){
|
472 |
if (it.getGoodQuantity() > 0){
|
| 421 |
if (nonSerializedInventoryItemMap.containsKey(it.getItemId())){
|
473 |
if (nonSerializedInventoryItemMap.containsKey(it.getItemId())){
|
| 422 |
nonSerializedInventoryItemMap.get(it.getItemId()).add(it);
|
474 |
nonSerializedInventoryItemMap.get(it.getItemId()).add(it);
|
| Line 434... |
Line 486... |
| 434 |
List<Integer> itemIdSerialNumbers = new ArrayList<Integer>();
|
486 |
List<Integer> itemIdSerialNumbers = new ArrayList<Integer>();
|
| 435 |
|
487 |
|
| 436 |
for (Item i : items){
|
488 |
for (Item i : items){
|
| 437 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(i.getId());
|
489 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(i.getId());
|
| 438 |
if (i.getType().equals(ItemType.SERIALIZED)){
|
490 |
if (i.getType().equals(ItemType.SERIALIZED)){
|
| 439 |
if (customFofoLineItem ==null || customFofoLineItem.getSerialNumbers().size() ==0){
|
491 |
if (customFofoLineItem ==null || customFofoLineItem.getSerialNumberDetails().isEmpty()){
|
| 440 |
invalidItemIdSerialNumbers.add(i.getId());
|
492 |
invalidItemIdSerialNumbers.add(i.getId());
|
| 441 |
}
|
493 |
}
|
| 442 |
}
|
494 |
}
|
| 443 |
else{
|
495 |
else{
|
| 444 |
if (customFofoLineItem == null || customFofoLineItem.getSerialNumbers().size() > 0 ){
|
496 |
if (customFofoLineItem == null || !customFofoLineItem.getSerialNumberDetails().isEmpty()){
|
| 445 |
itemIdSerialNumbers.add(i.getId());
|
497 |
itemIdSerialNumbers.add(i.getId());
|
| 446 |
}
|
498 |
}
|
| 447 |
}
|
499 |
}
|
| 448 |
}
|
500 |
}
|
| 449 |
|
501 |
|
| Line 471... |
Line 523... |
| 471 |
//Lets reduce quantity and decide what inventory items to use.
|
523 |
//Lets reduce quantity and decide what inventory items to use.
|
| 472 |
for (Item i : items){
|
524 |
for (Item i : items){
|
| 473 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(i.getId());
|
525 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(i.getId());
|
| 474 |
if (i.getType().equals(ItemType.SERIALIZED)){
|
526 |
if (i.getType().equals(ItemType.SERIALIZED)){
|
| 475 |
//TODO:handle null
|
527 |
//TODO:handle null
|
| 476 |
if (serializedInventoryItemMap.get(i.getId()) == null || customFofoLineItem.getSerialNumbers().size() != serializedInventoryItemMap.get(i.getId()).size()){
|
528 |
if (serializedInventoryItemMap.get(i.getId()) == null || customFofoLineItem.getSerialNumberDetails().size() != serializedInventoryItemMap.get(i.getId()).size()){
|
| 477 |
//not enough serial numbers
|
529 |
//not enough serial numbers
|
| - |
|
530 |
LOGGER.info("serialNumbers {}", serialNumbers);
|
| - |
|
531 |
LOGGER.info("serializedInventoryItemMap {}", serializedInventoryItemMap);
|
| - |
|
532 |
LOGGER.info("itemId {}", i.getId());
|
| 478 |
System.out.println("not enough serial numbers");
|
533 |
LOGGER.error("not enough serial numbers");
|
| 479 |
return "error";
|
534 |
return "error";
|
| 480 |
}
|
535 |
}
|
| 481 |
List<InventoryItem> inventoryItemsSerializedserialized = serializedInventoryItemMap.get(i.getId());
|
536 |
List<InventoryItem> inventoryItemsSerializedserialized = serializedInventoryItemMap.get(i.getId());
|
| 482 |
for (InventoryItem it : inventoryItemsSerializedserialized){
|
537 |
for (InventoryItem it : inventoryItemsSerializedserialized){
|
| 483 |
it.setGoodQuantity(0);
|
538 |
it.setGoodQuantity(0);
|
| Line 510... |
Line 565... |
| 510 |
inventoryItemsToBill.put(i.getId(), inventoryItemsNonSerializedUsed);
|
565 |
inventoryItemsToBill.put(i.getId(), inventoryItemsNonSerializedUsed);
|
| 511 |
}
|
566 |
}
|
| 512 |
}
|
567 |
}
|
| 513 |
|
568 |
|
| 514 |
// mop price validation
|
569 |
// mop price validation
|
| 515 |
//TODO: Amit Gupta need to be commented out
|
- |
|
| 516 |
/*Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
570 |
Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
| 517 |
Map<Integer, Float> itemIdPrinceMap = pricingService.getPrice(itemIds, fofoDetails.getFofoId());
|
571 |
Map<Integer, Float> itemIdPriceMap = pricingService.getPrices(itemIds, fofoDetails.getFofoId());
|
| - |
|
572 |
//LOGGER.info("itemIdPriceMap = {}", itemIdPriceMap);
|
| 518 |
for(Map.Entry<Integer, Float> entry : itemIdPrinceMap.entrySet()){
|
573 |
for(Map.Entry<Integer, Float> entry : itemIdPriceMap.entrySet()){
|
| 519 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(entry.getKey());
|
574 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(entry.getKey());
|
| 520 |
if(customFofoLineItem.getSellingPrice() < entry.getValue()){
|
575 |
if(customFofoLineItem.getSellingPrice() < entry.getValue()){
|
| 521 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoLineItem.getSellingPrice());
|
576 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoLineItem.getSellingPrice());
|
| 522 |
}
|
577 |
}
|
| 523 |
}
|
578 |
}
|
| 524 |
|
579 |
|
| 525 |
if(invalidMopItemIdPriceMap.isEmpty()){
|
580 |
if(!invalidMopItemIdPriceMap.isEmpty()){
|
| 526 |
LOGGER.error("Invalid itemIds mop prices should be greater than mop prices {}", invalidMopItemIdPriceMap);
|
581 |
LOGGER.error("Invalid itemIds mop prices should be greater than mop prices {}", invalidMopItemIdPriceMap);
|
| 527 |
return "error";
|
582 |
return "error";
|
| 528 |
}*/
|
583 |
}
|
| 529 |
|
584 |
|
| 530 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
585 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
| 531 |
try{
|
586 |
try{
|
| 532 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoDetails.getFofoId());
|
587 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoDetails.getFofoId());
|
| 533 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
588 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
| Line 549... |
Line 604... |
| 549 |
|
604 |
|
| 550 |
if(!StringUtils.isValidMobile(customCustomer.getMobileNumber())){
|
605 |
if(!StringUtils.isValidMobile(customCustomer.getMobileNumber())){
|
| 551 |
LOGGER.error("invalid customer mobileNumber {} ", customCustomer.getMobileNumber());
|
606 |
LOGGER.error("invalid customer mobileNumber {} ", customCustomer.getMobileNumber());
|
| 552 |
return "error";
|
607 |
return "error";
|
| 553 |
}
|
608 |
}
|
| 554 |
|
609 |
|
| - |
|
610 |
LocalDate dateOfBirth = null;
|
| - |
|
611 |
try{
|
| - |
|
612 |
dateOfBirth = StringUtils.toDate(customCustomer.getDateOfBirth());
|
| - |
|
613 |
}catch(DateTimeException dateTimeException){
|
| - |
|
614 |
LOGGER.error("Unable to parse dateOfBirth", dateTimeException);
|
| - |
|
615 |
return "error";
|
| - |
|
616 |
}
|
| - |
|
617 |
|
| 555 |
Customer customer = null;
|
618 |
Customer customer = null;
|
| 556 |
try{
|
619 |
try{
|
| 557 |
customer = customerRepository.selectByMobileNumber(customCustomer.getMobileNumber());
|
620 |
customer = customerRepository.selectByMobileNumber(customCustomer.getMobileNumber());
|
| 558 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
621 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| 559 |
LOGGER.error("Error : ", profitMandiBusinessException);
|
622 |
LOGGER.error("Error : ", profitMandiBusinessException);
|
| 560 |
customer = new Customer();
|
623 |
customer = new Customer();
|
| - |
|
624 |
customer.setFirstName(customCustomer.getFirstName());
|
| 561 |
customer.setName(customCustomer.getName());
|
625 |
customer.setLastName(customCustomer.getLastName());
|
| - |
|
626 |
customer.setDateOfBirth(dateOfBirth);
|
| 562 |
customer.setEmailId(customCustomer.getEmailId());
|
627 |
customer.setEmailId(customCustomer.getEmailId());
|
| 563 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
628 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
| 564 |
customerRepository.persist(customer);
|
629 |
customerRepository.persist(customer);
|
| 565 |
}
|
630 |
}
|
| 566 |
//TODO:Check if createOrderRequest contains addressId
|
631 |
//TODO:Check if createOrderRequest contains addressId
|
| Line 621... |
Line 686... |
| 621 |
fofoLineItem.setModelName(item.getModelName());
|
686 |
fofoLineItem.setModelName(item.getModelName());
|
| 622 |
fofoLineItem.setModelNumber(item.getModelNumber());
|
687 |
fofoLineItem.setModelNumber(item.getModelNumber());
|
| 623 |
fofoLineItem.setColor(item.getColor());
|
688 |
fofoLineItem.setColor(item.getColor());
|
| 624 |
fofoLineItemRepository.persist(fofoLineItem);
|
689 |
fofoLineItemRepository.persist(fofoLineItem);
|
| 625 |
LOGGER.info("\n\n");
|
690 |
LOGGER.info("\n\n");
|
| 626 |
if(!customFofoLineItem.getSerialNumbers().isEmpty()){
|
691 |
if(!customFofoLineItem.getSerialNumberDetails().isEmpty()){
|
| 627 |
for(String serialNumber : customFofoLineItem.getSerialNumbers()){
|
692 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
| 628 |
FofoLineItemSerialNumber fofoLineItemSerialNumber = new FofoLineItemSerialNumber();
|
693 |
FofoLineItemSerialNumber fofoLineItemSerialNumber = new FofoLineItemSerialNumber();
|
| 629 |
fofoLineItemSerialNumber.setFofoLineItemId(fofoLineItem.getId());
|
694 |
fofoLineItemSerialNumber.setFofoLineItemId(fofoLineItem.getId());
|
| 630 |
fofoLineItemSerialNumber.setSerialNumber(serialNumber);
|
695 |
fofoLineItemSerialNumber.setSerialNumber(serialNumberDetail.getSerialNumber());
|
| 631 |
fofoLineItemSerialNumberRepository.persist(fofoLineItemSerialNumber);
|
696 |
fofoLineItemSerialNumberRepository.persist(fofoLineItemSerialNumber);
|
| 632 |
}
|
697 |
}
|
| 633 |
}
|
698 |
}
|
| 634 |
|
699 |
|
| 635 |
for(CurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots){
|
700 |
for(CurrentInventorySnapshot currentInventorySnapshot : currentInventorySnapshots){
|
| Line 651... |
Line 716... |
| 651 |
scanRecord.setQuantity(inventoryItemQuantityUsed.get(inventoryItem.getId()));
|
716 |
scanRecord.setQuantity(inventoryItemQuantityUsed.get(inventoryItem.getId()));
|
| 652 |
scanRecord.setType(ScanType.SALE);
|
717 |
scanRecord.setType(ScanType.SALE);
|
| 653 |
scanRecordRepository.persist(scanRecord);
|
718 |
scanRecordRepository.persist(scanRecord);
|
| 654 |
}
|
719 |
}
|
| 655 |
}
|
720 |
}
|
| - |
|
721 |
|
| - |
|
722 |
// insurance calculation is insurance flag is enabled
|
| - |
|
723 |
if(!insuranceSerialNumberItemPrice.isEmpty()){
|
| - |
|
724 |
Map<Float, GadgetCopsInsuranceCalc> insurancePricesMap = pricingService.getInsurancePrices(new HashSet<>(insuranceSerialNumberItemPrice.values()), ProfitMandiConstants.GADGET_COPS);
|
| - |
|
725 |
InsuranceProvider insuranceProvider = insuranceProviderRepository.selectByName(ProfitMandiConstants.GADGET_COPS);
|
| - |
|
726 |
|
| - |
|
727 |
|
| - |
|
728 |
Map<Float, Float> invalidInsurancePurchaseSaleAmount = new HashMap<>();
|
| - |
|
729 |
Map<Float, Float> invalidInsuranceSalePurchaseAmount = new HashMap<>();
|
| - |
|
730 |
for(Map.Entry<String, Float> entry : insuranceSerialNumberItemPrice.entrySet()){
|
| - |
|
731 |
if(insuranceSerialNumberSaleAmount.get(entry.getKey()) < insurancePricesMap.get(entry.getValue()).getDealerPrice()){
|
| - |
|
732 |
invalidInsurancePurchaseSaleAmount.put(insurancePricesMap.get(entry.getValue()).getDealerPrice(), insuranceSerialNumberSaleAmount.get(entry.getKey()));
|
| - |
|
733 |
}
|
| - |
|
734 |
|
| - |
|
735 |
if(insuranceSerialNumberSaleAmount.get(entry.getKey()) > insurancePricesMap.get(entry.getValue()).getSellingPrice()){
|
| - |
|
736 |
invalidInsuranceSalePurchaseAmount.put(insuranceSerialNumberSaleAmount.get(entry.getKey()), insurancePricesMap.get(entry.getValue()).getDealerPrice());
|
| - |
|
737 |
}
|
| - |
|
738 |
}
|
| - |
|
739 |
|
| - |
|
740 |
// insurance sale amount can not be lesser than insurance purchase amount
|
| - |
|
741 |
if(!invalidInsurancePurchaseSaleAmount.isEmpty()){
|
| - |
|
742 |
LOGGER.error("Invalid Insurance prices [{}], insurance sale amount can not be lesser than insurance purchase amount", invalidInsurancePurchaseSaleAmount);
|
| - |
|
743 |
return "error";
|
| - |
|
744 |
}
|
| - |
|
745 |
|
| - |
|
746 |
if(!invalidInsuranceSalePurchaseAmount.isEmpty()){
|
| - |
|
747 |
LOGGER.error("Invalid Insurance prices [{}], insurance sale amount can not be greater than than insurance max amount", invalidInsuranceSalePurchaseAmount);
|
| - |
|
748 |
return "error";
|
| - |
|
749 |
}
|
| - |
|
750 |
|
| - |
|
751 |
|
| - |
|
752 |
for(Map.Entry<String, Float> entry : insuranceSerialNumberItemPrice.entrySet()){
|
| - |
|
753 |
PolicyNumberGenerationSequence policyNumberGenerationSequence = null;
|
| - |
|
754 |
try{
|
| - |
|
755 |
policyNumberGenerationSequence = policyNumberGenerationSequenceRepository.select();
|
| - |
|
756 |
policyNumberGenerationSequence.setSequence(policyNumberGenerationSequence.getSequence() + 1);
|
| - |
|
757 |
policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
|
| - |
|
758 |
}catch(ProfitMandiBusinessException profitMandiBusinessException){
|
| - |
|
759 |
policyNumberGenerationSequence = new PolicyNumberGenerationSequence();
|
| - |
|
760 |
policyNumberGenerationSequence.setSequence(1);
|
| - |
|
761 |
policyNumberGenerationSequenceRepository.persist(policyNumberGenerationSequence);
|
| - |
|
762 |
}
|
| - |
|
763 |
InsurancePolicy insurancePolicy = new InsurancePolicy();
|
| - |
|
764 |
insurancePolicy.setInvoiceNumber(invoiceNumberGenerationSequence.getPrefix() + invoiceNumberGenerationSequence.getSequence());
|
| - |
|
765 |
insurancePolicy.setRetailerId(fofoDetails.getFofoId());
|
| - |
|
766 |
insurancePolicy.setPurchaseAmount(insurancePricesMap.get(entry.getValue()).getDealerPrice());
|
| - |
|
767 |
insurancePolicy.setSaleAmount(insuranceSerialNumberSaleAmount.get(entry.getKey()));
|
| - |
|
768 |
insurancePolicy.setSellingPrice(entry.getValue());
|
| - |
|
769 |
insurancePolicy.setSerialNumber(entry.getKey());
|
| - |
|
770 |
insurancePolicy.setModelName(serialNumberModelName.get(entry.getKey()));
|
| - |
|
771 |
insurancePolicy.setBrand(serialNumberBrand.get(entry.getKey()));
|
| - |
|
772 |
insurancePolicy.setPolicyNumber(StringUtils.generatePolicyNumber(ProfitMandiConstants.POLICY_NUMBER_PREFIX, policyNumberGenerationSequence.getSequence()));
|
| - |
|
773 |
insurancePolicy.setProviderId(insuranceProvider.getId());
|
| - |
|
774 |
insurancePolicyRepository.persist(insurancePolicy);
|
| - |
|
775 |
GadgetCopsInsuranceModel gadgetCopsInsuranceModel = new GadgetCopsInsuranceModel();
|
| - |
|
776 |
gadgetCopsInsuranceModel.setBrand(serialNumberBrand.get(entry.getKey()));
|
| - |
|
777 |
gadgetCopsInsuranceModel.setModelName(serialNumberModelName.get(entry.getKey()));
|
| - |
|
778 |
gadgetCopsInsuranceModel.setSerialNumber(entry.getKey());
|
| - |
|
779 |
gadgetCopsInsuranceModel.setCustomerFirstName(customer.getFirstName());
|
| - |
|
780 |
gadgetCopsInsuranceModel.setCustomerLastName(customer.getLastName());
|
| - |
|
781 |
gadgetCopsInsuranceModel.setCustomerDateOfBirth(customer.getDateOfBirth());
|
| - |
|
782 |
gadgetCopsInsuranceModel.setCustomerMobileNumber(customer.getMobileNumber());
|
| - |
|
783 |
gadgetCopsInsuranceModel.setCustomerEmailId(customer.getEmailId());
|
| - |
|
784 |
gadgetCopsInsuranceModel.setCustomerAddress1(customerAddress.getLine1());
|
| - |
|
785 |
gadgetCopsInsuranceModel.setCustomerAddress2(customerAddress.getLine2());
|
| - |
|
786 |
gadgetCopsInsuranceModel.setCustomerCity(customerAddress.getCity());
|
| - |
|
787 |
gadgetCopsInsuranceModel.setCustomerPinCode(customerAddress.getPinCode());
|
| - |
|
788 |
gadgetCopsInsuranceModel.setCustomerState(customerAddress.getState());
|
| - |
|
789 |
gadgetCopsInsuranceModel.setPrice(insurancePolicy.getSellingPrice());
|
| - |
|
790 |
gadgetCopsInsuranceModel.setInvoiceNumber(insurancePolicy.getInvoiceNumber());
|
| - |
|
791 |
gadgetCopsInsuranceModel.setPolicyNumber(insurancePolicy.getPolicyNumber());
|
| - |
|
792 |
InsuranceUtils.submitToGadgetCops(gadgetCopsInsuranceModel);
|
| - |
|
793 |
}
|
| - |
|
794 |
}
|
| 656 |
return "redirect:/get-order/?orderId="+fofoOrder.getId();
|
795 |
return "redirect:/get-order/?orderId="+fofoOrder.getId();
|
| 657 |
}
|
796 |
}
|
| 658 |
|
797 |
|
| 659 |
private CustomerAddress createCustomerAddress(CustomAddress customAddress){
|
798 |
private CustomerAddress createCustomerAddress(CustomAddress customAddress){
|
| 660 |
CustomerAddress customerAddress = new CustomerAddress();
|
799 |
CustomerAddress customerAddress = new CustomerAddress();
|
| Line 718... |
Line 857... |
| 718 |
|
857 |
|
| 719 |
@RequestMapping(value = "/generateInvoice")
|
858 |
@RequestMapping(value = "/generateInvoice")
|
| 720 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws Throwable{
|
859 |
public ResponseEntity<?> generateInvoice(HttpServletRequest request, HttpServletResponse response, @RequestParam(name = ProfitMandiConstants.ORDER_ID) int orderId) throws Throwable{
|
| 721 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(), ProfitMandiConstants.ORDER_ID, orderId);
|
860 |
LOGGER.info("Request received at url {} with params [{}={}] ", request.getRequestURI(), ProfitMandiConstants.ORDER_ID, orderId);
|
| 722 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
861 |
LoginDetails fofoDetails = cookiesProcessor.getCookiesObject(request);
|
| 723 |
|
- |
|
| 724 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
862 |
FofoOrder fofoOrder = fofoOrderRepository.selectByFofoIdAndOrderId(fofoDetails.getFofoId(), orderId);
|
| - |
|
863 |
|
| 725 |
PdfModel pdfModel = new PdfModel();
|
864 |
PdfModel pdfModel = new PdfModel();
|
| 726 |
pdfModel.setAuther("profitmandi");
|
865 |
pdfModel.setAuther("profitmandi");
|
| 727 |
pdfModel.setTitle("Retailer Invoice");
|
866 |
pdfModel.setTitle("Retailer Invoice");
|
| - |
|
867 |
|
| - |
|
868 |
// insurance calculation
|
| - |
|
869 |
float insuranceTotalAmount = 0;
|
| - |
|
870 |
List<InsurancePolicy> insurancePolicies = insurancePolicyRepository.selectByInvoiceNumber(fofoOrder.getInvoiceNumber());
|
| - |
|
871 |
Set<Integer> insuranceProviderIds = new HashSet<>(insurancePolicies.size());
|
| - |
|
872 |
for(InsurancePolicy insurancePolicy : insurancePolicies){
|
| - |
|
873 |
insuranceProviderIds.add(insurancePolicy.getProviderId());
|
| - |
|
874 |
insuranceTotalAmount = insuranceTotalAmount + insurancePolicy.getSaleAmount();
|
| - |
|
875 |
}
|
| - |
|
876 |
List<InsuranceProvider> insuranceProviders = insuranceProviderRepository.selectByIds(insuranceProviderIds);
|
| - |
|
877 |
Map<Integer, String> insuranceProviderIdNameMap = new HashMap<>(insuranceProviders.size());
|
| - |
|
878 |
for(InsuranceProvider insuranceProvider : insuranceProviders){
|
| - |
|
879 |
insuranceProviderIdNameMap.put(insuranceProvider.getId(), insuranceProvider.getName());
|
| - |
|
880 |
}
|
| - |
|
881 |
Set<CustomInsurancePolicy> customInsurancePolicies = new HashSet<>();
|
| - |
|
882 |
final float totalInsuranceTaxRate = 18;
|
| - |
|
883 |
for(InsurancePolicy insurancePolicy : insurancePolicies){
|
| - |
|
884 |
float taxableInsurancePrice = insurancePolicy.getSaleAmount() / (1 + totalInsuranceTaxRate / 100);
|
| - |
|
885 |
CustomInsurancePolicy customInsurancePolicy = new CustomInsurancePolicy();
|
| - |
|
886 |
customInsurancePolicy.setDescription(insuranceProviderIdNameMap.get(insurancePolicy.getProviderId()) + " Protection (" + insurancePolicy.getSerialNumber() + ")");
|
| - |
|
887 |
customInsurancePolicy.setHsnCode("");
|
| - |
|
888 |
customInsurancePolicy.setRate(taxableInsurancePrice);
|
| - |
|
889 |
customInsurancePolicy.setIgstRate(18);
|
| - |
|
890 |
customInsurancePolicy.setIgstAmount(taxableInsurancePrice * 18 /100);
|
| - |
|
891 |
customInsurancePolicy.setCgstRate(18);
|
| - |
|
892 |
customInsurancePolicy.setCgstAmount(taxableInsurancePrice * 9 /100);
|
| - |
|
893 |
customInsurancePolicy.setSgstRate(9);
|
| - |
|
894 |
customInsurancePolicy.setSgstAmount(taxableInsurancePrice * 9 /100);
|
| - |
|
895 |
customInsurancePolicies.add(customInsurancePolicy);
|
| - |
|
896 |
}
|
| - |
|
897 |
pdfModel.setInsurancePolicies(customInsurancePolicies);
|
| 728 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
898 |
Customer customer = customerRepository.selectById(fofoOrder.getCustomerId());
|
| 729 |
CustomCustomer customCustomer = new CustomCustomer();
|
899 |
CustomCustomer customCustomer = new CustomCustomer();
|
| - |
|
900 |
customCustomer.setFirstName(customer.getFirstName());
|
| 730 |
customCustomer.setName(customer.getName());
|
901 |
customCustomer.setLastName(customer.getLastName());
|
| - |
|
902 |
customCustomer.setDateOfBirth(StringUtils.toString(customer.getDateOfBirth()));
|
| 731 |
customCustomer.setEmailId(customer.getEmailId());
|
903 |
customCustomer.setEmailId(customer.getEmailId());
|
| 732 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
904 |
customCustomer.setMobileNumber(customer.getMobileNumber());
|
| 733 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
905 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| 734 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
906 |
customCustomer.setAddress(this.createCustomAddress(customerAddress));
|
| 735 |
pdfModel.setCustomer(customCustomer);
|
907 |
pdfModel.setCustomer(customCustomer);
|
| 736 |
pdfModel.setInvoiceNumber(fofoOrder.getInvoiceNumber());
|
908 |
pdfModel.setInvoiceNumber(fofoOrder.getInvoiceNumber());
|
| 737 |
pdfModel.setTotalAmount(fofoOrder.getTotalAmount());
|
909 |
pdfModel.setTotalAmount(fofoOrder.getTotalAmount() + insuranceTotalAmount);
|
| 738 |
|
910 |
|
| 739 |
Retailer retailer = retailerRepository.selectById(fofoDetails.getFofoId());
|
911 |
Retailer retailer = retailerRepository.selectById(fofoDetails.getFofoId());
|
| 740 |
User user = userRepository.selectById(userAccountRepository.selectUserIdByRetailerId(retailer.getId()));
|
912 |
User user = userRepository.selectById(userAccountRepository.selectUserIdByRetailerId(retailer.getId()));
|
| 741 |
CustomRetailer customRetailer = new CustomRetailer();
|
913 |
CustomRetailer customRetailer = new CustomRetailer();
|
| 742 |
customRetailer.setBusinessName(retailer.getName());
|
914 |
customRetailer.setBusinessName(retailer.getName());
|