| Line 43... |
Line 43... |
| 43 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
43 |
import com.spice.profitmandi.common.model.CustomFofoOrderItem;
|
| 44 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
44 |
import com.spice.profitmandi.common.model.CustomInsurancePolicy;
|
| 45 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
45 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 46 |
import com.spice.profitmandi.common.model.GadgetCopsInsuranceModel;
|
46 |
import com.spice.profitmandi.common.model.GadgetCopsInsuranceModel;
|
| 47 |
import com.spice.profitmandi.common.model.GstRate;
|
47 |
import com.spice.profitmandi.common.model.GstRate;
|
| 48 |
import com.spice.profitmandi.common.model.MopPriceModel;
|
48 |
import com.spice.profitmandi.common.model.PriceModel;
|
| 49 |
import com.spice.profitmandi.common.model.PdfModel;
|
49 |
import com.spice.profitmandi.common.model.PdfModel;
|
| 50 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
50 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 51 |
import com.spice.profitmandi.common.model.SerialNumberDetail;
|
51 |
import com.spice.profitmandi.common.model.SerialNumberDetail;
|
| 52 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
52 |
import com.spice.profitmandi.common.util.InsuranceUtils;
|
| 53 |
import com.spice.profitmandi.common.util.PdfUtils;
|
53 |
import com.spice.profitmandi.common.util.PdfUtils;
|
| Line 239... |
Line 239... |
| 239 |
continue;
|
239 |
continue;
|
| 240 |
}
|
240 |
}
|
| 241 |
cf.setDisplayName(getValidName(i.getBrand())+" "+getValidName(i.getModelName())+" "+getValidName(i.getModelNumber())+" "+getValidName(i.getColor()).replaceAll("\\s+", " "));
|
241 |
cf.setDisplayName(getValidName(i.getBrand())+" "+getValidName(i.getModelName())+" "+getValidName(i.getModelNumber())+" "+getValidName(i.getColor()).replaceAll("\\s+", " "));
|
| 242 |
cf.setItemType(i.getType());
|
242 |
cf.setItemType(i.getType());
|
| 243 |
}
|
243 |
}
|
| 244 |
Map<Integer, MopPriceModel> mopPriceMap = pricingService.getPurchasePriceMopPriceNotFound(itemIds, loginDetails.getFofoId());
|
244 |
Map<Integer, PriceModel> mopPriceMap = pricingService.getPurchasePriceMopPriceNotFound(itemIds, loginDetails.getFofoId());
|
| 245 |
LOGGER.info("mopPriceMap {}", mopPriceMap);
|
245 |
LOGGER.info("mopPriceMap {}", mopPriceMap);
|
| 246 |
model.addAttribute("cartObj", cartItems);
|
246 |
model.addAttribute("cartObj", cartItems);
|
| 247 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
247 |
model.addAttribute("mopPriceMap", mopPriceMap);
|
| 248 |
return "order-index";
|
248 |
return "order-index";
|
| 249 |
}catch (Exception e) {
|
249 |
}catch (Exception e) {
|
| Line 385... |
Line 385... |
| 385 |
itemIdQuantity.put(customFofoLineItem.getItemId(), customFofoLineItem.getQuantity());
|
385 |
itemIdQuantity.put(customFofoLineItem.getItemId(), customFofoLineItem.getQuantity());
|
| 386 |
}
|
386 |
}
|
| 387 |
if(!(customFofoLineItem.getSellingPrice() > 0)){
|
387 |
if(!(customFofoLineItem.getSellingPrice() > 0)){
|
| 388 |
lineItemPrice.put(customFofoLineItem.getItemId(), customFofoLineItem.getSellingPrice());
|
388 |
lineItemPrice.put(customFofoLineItem.getItemId(), customFofoLineItem.getSellingPrice());
|
| 389 |
}else{
|
389 |
}else{
|
| 390 |
totalAmount = totalAmount + customFofoLineItem.getSellingPrice() * customFofoLineItem.getQuantity();
|
390 |
totalAmount = totalAmount + customFofoLineItem.getSellingPrice() * customFofoLineItem.getQuantity() + customFofoLineItem.getDiscountAmount();
|
| 391 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
391 |
for(SerialNumberDetail serialNumberDetail : customFofoLineItem.getSerialNumberDetails()){
|
| 392 |
if(serialNumberDetail.isInsurance() && serialNumberDetail.getAmount() > 0){
|
392 |
if(serialNumberDetail.isInsurance() && serialNumberDetail.getAmount() > 0){
|
| 393 |
totalAmount = totalAmount + serialNumberDetail.getAmount();
|
393 |
totalAmount = totalAmount + serialNumberDetail.getAmount();
|
| 394 |
}
|
394 |
}
|
| 395 |
}
|
395 |
}
|
| Line 639... |
Line 639... |
| 639 |
}
|
639 |
}
|
| 640 |
}
|
640 |
}
|
| 641 |
|
641 |
|
| 642 |
// mop price validation
|
642 |
// mop price validation
|
| 643 |
Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
643 |
Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
| - |
|
644 |
Map<Integer, Float> invalidDiscountAmountMap = new HashMap<>();
|
| 644 |
Map<Integer, MopPriceModel> itemIdMopPriceMap = pricingService.getPurchasePriceMopPriceNotFound(itemIds, fofoDetails.getFofoId());
|
645 |
Map<Integer, PriceModel> itemIdMopPriceMap = pricingService.getPurchasePriceMopPriceNotFound(itemIds, fofoDetails.getFofoId());
|
| 645 |
for(Map.Entry<Integer, MopPriceModel> entry : itemIdMopPriceMap.entrySet()){
|
646 |
for(Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()){
|
| 646 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(entry.getKey());
|
647 |
CustomFofoLineItem customFofoLineItem = customFofoLineItemMap.get(entry.getKey());
|
| 647 |
if(entry.getValue().getPrice() < Float.MAX_VALUE && customFofoLineItem.getSellingPrice() < entry.getValue().getPrice()){
|
648 |
if(entry.getValue().getPrice() < Float.MAX_VALUE && customFofoLineItem.getSellingPrice() < entry.getValue().getPrice()){
|
| 648 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoLineItem.getSellingPrice());
|
649 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoLineItem.getSellingPrice());
|
| 649 |
}
|
650 |
}
|
| - |
|
651 |
if(entry.getValue().isMop() && customFofoLineItem.getDiscountAmount() > entry.getValue().getMaxDiscountAmount()){
|
| - |
|
652 |
invalidDiscountAmountMap.put(entry.getKey(), customFofoLineItem.getDiscountAmount());
|
| - |
|
653 |
}
|
| 650 |
}
|
654 |
}
|
| 651 |
|
655 |
|
| 652 |
if(!invalidMopItemIdPriceMap.isEmpty()){
|
656 |
if(!invalidMopItemIdPriceMap.isEmpty()){
|
| 653 |
LOGGER.error("Invalid itemIds selling prices{} should be greater than mop prices {}", invalidMopItemIdPriceMap, itemIdMopPriceMap);
|
657 |
LOGGER.error("Invalid itemIds selling prices{} should be greater than mop prices {}", invalidMopItemIdPriceMap, itemIdMopPriceMap);
|
| 654 |
throw new ProfitMandiBusinessException("invalidMopItemIdPrice", invalidMopItemIdPriceMap, "");
|
658 |
throw new ProfitMandiBusinessException("invalidMopItemIdPrice", invalidMopItemIdPriceMap, "");
|
| 655 |
}
|
659 |
}
|
| - |
|
660 |
|
| - |
|
661 |
if(!invalidMopItemIdPriceMap.isEmpty()){
|
| - |
|
662 |
LOGGER.error("Invalid itemIds discount amounts {} should be less than maxDiscount prices {}", invalidDiscountAmountMap, itemIdMopPriceMap);
|
| - |
|
663 |
throw new ProfitMandiBusinessException("invalidMopItemIdPrice", invalidDiscountAmountMap, "");
|
| - |
|
664 |
}
|
| 656 |
|
665 |
|
| 657 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
666 |
InvoiceNumberGenerationSequence invoiceNumberGenerationSequence = null;
|
| 658 |
try{
|
667 |
try{
|
| 659 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoDetails.getFofoId());
|
668 |
invoiceNumberGenerationSequence = invoiceNumberGenerationSequenceRepository.selectByFofoId(fofoDetails.getFofoId());
|
| 660 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
669 |
invoiceNumberGenerationSequence.setSequence(invoiceNumberGenerationSequence.getSequence() + 1);
|
| Line 747... |
Line 756... |
| 747 |
fofoLineItem.setItemId(customFofoLineItem.getItemId());
|
756 |
fofoLineItem.setItemId(customFofoLineItem.getItemId());
|
| 748 |
fofoLineItem.setQuantity(customFofoLineItem.getQuantity());
|
757 |
fofoLineItem.setQuantity(customFofoLineItem.getQuantity());
|
| 749 |
fofoLineItem.setSellingPrice(customFofoLineItem.getSellingPrice());
|
758 |
fofoLineItem.setSellingPrice(customFofoLineItem.getSellingPrice());
|
| 750 |
fofoLineItem.setOrderId(fofoOrder.getId());
|
759 |
fofoLineItem.setOrderId(fofoOrder.getId());
|
| 751 |
fofoLineItem.setDp(customFofoLineItem.getSellingPrice());
|
760 |
fofoLineItem.setDp(customFofoLineItem.getSellingPrice());
|
| - |
|
761 |
fofoLineItem.setDiscount(customFofoLineItem.getDiscountAmount());
|
| 752 |
Item item = itemMap.get(customFofoLineItem.getItemId());
|
762 |
Item item = itemMap.get(customFofoLineItem.getItemId());
|
| 753 |
GstRate gstRate = gstRateMap.get(item.getHsnCode());
|
763 |
GstRate gstRate = gstRateMap.get(item.getHsnCode());
|
| 754 |
fofoLineItem.setIgstRate(gstRate.getIgstRate());
|
764 |
fofoLineItem.setIgstRate(gstRate.getIgstRate());
|
| 755 |
fofoLineItem.setCgstRate(gstRate.getCgstRate());
|
765 |
fofoLineItem.setCgstRate(gstRate.getCgstRate());
|
| 756 |
fofoLineItem.setSgstRate(gstRate.getSgstRate());
|
766 |
fofoLineItem.setSgstRate(gstRate.getSgstRate());
|