| Line 282... |
Line 282... |
| 282 |
@Autowired
|
282 |
@Autowired
|
| 283 |
private SessionFactory sessionFactory;
|
283 |
private SessionFactory sessionFactory;
|
| 284 |
|
284 |
|
| 285 |
@Autowired
|
285 |
@Autowired
|
| 286 |
private Mongo mongoClient;
|
286 |
private Mongo mongoClient;
|
| 287 |
|
287 |
|
| 288 |
@Autowired
|
288 |
@Autowired
|
| 289 |
private PendingOrderRepository pendingOrderRepository;
|
289 |
private PendingOrderRepository pendingOrderRepository;
|
| 290 |
|
290 |
|
| 291 |
@Autowired
|
291 |
@Autowired
|
| 292 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
292 |
private PendingOrderItemRepository pendingOrderItemRepository;
|
| 293 |
|
293 |
|
| 294 |
@Override
|
294 |
@Override
|
| 295 |
public int createOrder(CreateOrderRequest createOrderRequest, int fofoId, boolean accessoriesDeals)
|
295 |
public int createOrder(CreateOrderRequest createOrderRequest, int fofoId, boolean accessoriesDeals)
|
| Line 486... |
Line 486... |
| 486 |
}
|
486 |
}
|
| 487 |
}
|
487 |
}
|
| 488 |
|
488 |
|
| 489 |
Map<Integer, PriceModel> itemIdMopPriceMap = pricingService
|
489 |
Map<Integer, PriceModel> itemIdMopPriceMap = pricingService
|
| 490 |
.getPurchasePriceMopPriceNotFound(itemIdCustomFofoOrderItemMap.keySet(), fofoId);
|
490 |
.getPurchasePriceMopPriceNotFound(itemIdCustomFofoOrderItemMap.keySet(), fofoId);
|
| 491 |
LOGGER.info("itemIdMopMap {}",itemIdMopPriceMap);
|
491 |
LOGGER.info("itemIdMopMap {}", itemIdMopPriceMap);
|
| 492 |
if (accessoriesDeals) {
|
492 |
if (accessoriesDeals) {
|
| 493 |
this.validateDpPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
|
493 |
this.validateDpPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
|
| 494 |
} else {
|
494 |
} else {
|
| 495 |
this.validateMopPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
|
495 |
this.validateMopPrice(itemIdMopPriceMap, itemIdCustomFofoOrderItemMap);
|
| 496 |
}
|
496 |
}
|
| Line 669... |
Line 669... |
| 669 |
"Serial Number returned by partner, but in transit");
|
669 |
"Serial Number returned by partner, but in transit");
|
| 670 |
}
|
670 |
}
|
| 671 |
}
|
671 |
}
|
| 672 |
} catch (Exception e) {
|
672 |
} catch (Exception e) {
|
| 673 |
int itemId = warehouseInventoryItem.getItemId();
|
673 |
int itemId = warehouseInventoryItem.getItemId();
|
| 674 |
if(serialNumberOrderIdMap.containsKey(serialNumber)) {
|
674 |
if (serialNumberOrderIdMap.containsKey(serialNumber)) {
|
| - |
|
675 |
FofoOrder fofoOrder = fofoOrderRepository
|
| 675 |
FofoOrder fofoOrder = fofoOrderRepository.selectByOrderId(serialNumberOrderIdMap.get(serialNumber));
|
676 |
.selectByOrderId(serialNumberOrderIdMap.get(serialNumber));
|
| 676 |
PdfModel pdfModel = this.getInvoicePdfModel(fofoOrder.getId());
|
677 |
PdfModel pdfModel = this.getInvoicePdfModel(fofoOrder.getId());
|
| 677 |
this.modifyDummyModel(fofoOrder, pdfModel, itemId, serialNumber);
|
678 |
this.modifyDummyModel(fofoOrder, pdfModel, itemId, serialNumber);
|
| 678 |
return pdfModel;
|
679 |
return pdfModel;
|
| 679 |
}
|
680 |
}
|
| 680 |
// Map this serialNumber for dummy billing
|
681 |
// Map this serialNumber for dummy billing
|
| Line 1123... |
Line 1124... |
| 1123 |
CustomFofoOrderItem customFofoOrderItem = entry.getValue();
|
1124 |
CustomFofoOrderItem customFofoOrderItem = entry.getValue();
|
| 1124 |
PriceModel priceModel = itemIdMopPriceMap.get(itemId);
|
1125 |
PriceModel priceModel = itemIdMopPriceMap.get(itemId);
|
| 1125 |
if (customFofoOrderItem.getSerialNumberDetails().stream()
|
1126 |
if (customFofoOrderItem.getSerialNumberDetails().stream()
|
| 1126 |
.filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber()))
|
1127 |
.filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber()))
|
| 1127 |
.collect(Collectors.toList()).size() > 0) {
|
1128 |
.collect(Collectors.toList()).size() > 0) {
|
| 1128 |
if (priceModel.getPrice() > customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount()) {
|
1129 |
if (priceModel.getPrice() > customFofoOrderItem.getSellingPrice()
|
| - |
|
1130 |
+ customFofoOrderItem.getDiscountAmount()) {
|
| 1129 |
throw new ProfitMandiBusinessException("Selling Price for ",
|
1131 |
throw new ProfitMandiBusinessException("Selling Price for ",
|
| 1130 |
itemRepository.selectById(itemId).getItemDescription(), "FFORDR_1010");
|
1132 |
itemRepository.selectById(itemId).getItemDescription(), "FFORDR_1010");
|
| 1131 |
}
|
1133 |
}
|
| 1132 |
} else {
|
1134 |
} else {
|
| 1133 |
if (priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
|
1135 |
if (priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
|
| Line 1142... |
Line 1144... |
| 1142 |
private void validateMopPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
|
1144 |
private void validateMopPrice(Map<Integer, PriceModel> itemIdMopPriceMap,
|
| 1143 |
Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
|
1145 |
Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
|
| 1144 |
Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
1146 |
Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
|
| 1145 |
for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
|
1147 |
for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
|
| 1146 |
CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
|
1148 |
CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
|
| 1147 |
if (customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount() < entry.getValue().getPrice()) {
|
1149 |
if (customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount() < entry.getValue()
|
| - |
|
1150 |
.getPrice()) {
|
| 1148 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
|
1151 |
invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
|
| 1149 |
}
|
1152 |
}
|
| 1150 |
}
|
1153 |
}
|
| 1151 |
|
1154 |
|
| 1152 |
if (!invalidMopItemIdPriceMap.isEmpty()) {
|
1155 |
if (!invalidMopItemIdPriceMap.isEmpty()) {
|
| Line 1532... |
Line 1535... |
| 1532 |
customer.setLastName(customCustomer.getLastName());
|
1535 |
customer.setLastName(customCustomer.getLastName());
|
| 1533 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
1536 |
customer.setMobileNumber(customCustomer.getMobileNumber());
|
| 1534 |
customer.setEmailId(customCustomer.getEmailId());
|
1537 |
customer.setEmailId(customCustomer.getEmailId());
|
| 1535 |
customerRepository.persist(customer);
|
1538 |
customerRepository.persist(customer);
|
| 1536 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
1539 |
CustomerAddress customerAddress = customerAddressRepository.selectById(fofoOrder.getCustomerAddressId());
|
| - |
|
1540 |
customerAddress.setName(customCustomer.getFirstName());
|
| - |
|
1541 |
customerAddress.setLastName(customCustomer.getLastName());
|
| 1537 |
if (!customerAddress.getState().equalsIgnoreCase(customCustomer.getAddress().getState())) {
|
1542 |
if (!customerAddress.getState().equalsIgnoreCase(customCustomer.getAddress().getState())) {
|
| 1538 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
1543 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectByOrderId(fofoOrder.getId());
|
| 1539 |
resetTaxation(fofoOrder.getFofoId(), customerAddress, fofoOrderItems);
|
1544 |
resetTaxation(fofoOrder.getFofoId(), customerAddress, fofoOrderItems);
|
| 1540 |
}
|
1545 |
}
|
| 1541 |
this.setCustomerAddress(customerAddress, customCustomer.getAddress());
|
1546 |
this.setCustomerAddress(customerAddress, customCustomer.getAddress());
|