| Line 367... |
Line 367... |
| 367 |
Set<Integer> itemIds = inventoryItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
|
367 |
Set<Integer> itemIds = inventoryItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
|
| 368 |
Set<Integer> catalogIds = itemRepository.selectByIds(itemIds).stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
368 |
Set<Integer> catalogIds = itemRepository.selectByIds(itemIds).stream().map(x -> x.getCatalogItemId()).collect(Collectors.toSet());
|
| 369 |
List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIdsAndCatalogIds(schemeIds, catalogIds);
|
369 |
List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIdsAndCatalogIds(schemeIds, catalogIds);
|
| 370 |
|
370 |
|
| 371 |
Map<Integer, Set<Scheme>> catalogIdSchemesMap = this.toCatalogIdSchemesMap(schemeItems, schemes);
|
371 |
Map<Integer, Set<Scheme>> catalogIdSchemesMap = this.toCatalogIdSchemesMap(schemeItems, schemes);
|
| 372 |
Map<InventoryItem, Set<Scheme>> inventoryItemSchemsMap = new HashMap<>();
|
372 |
Map<InventoryItem, Set<Scheme>> inventoryItemSchemesMap = new HashMap<>();
|
| 373 |
for (InventoryItem inventoryItem : inventoryItems) {
|
373 |
for (InventoryItem inventoryItem : inventoryItems) {
|
| - |
|
374 |
LOGGER.info("inventoryItem {}", inventoryItem);
|
| - |
|
375 |
LOGGER.info("inventoryItem.getItem() {}", inventoryItem.getItem());
|
| - |
|
376 |
LOGGER.info("catalogIdSchemesMap {}", catalogIdSchemesMap);
|
| 374 |
if (catalogIdSchemesMap.containsKey(inventoryItem.getItem().getCatalogItemId())) {
|
377 |
if (catalogIdSchemesMap.containsKey(inventoryItem.getItem().getCatalogItemId())) {
|
| 375 |
inventoryItemSchemsMap.put(inventoryItem, catalogIdSchemesMap.get(inventoryItem.getItem().getCatalogItemId()));
|
378 |
inventoryItemSchemesMap.put(inventoryItem, catalogIdSchemesMap.get(inventoryItem.getItem().getCatalogItemId()));
|
| 376 |
}
|
379 |
}
|
| 377 |
}
|
380 |
}
|
| 378 |
return inventoryItemSchemsMap;
|
381 |
return inventoryItemSchemesMap;
|
| 379 |
}
|
382 |
}
|
| 380 |
|
383 |
|
| 381 |
@Override
|
384 |
@Override
|
| 382 |
public void processSchemeIn(int purchaseId, int retailerId) throws ProfitMandiBusinessException {
|
385 |
public void processSchemeIn(int purchaseId, int retailerId) throws ProfitMandiBusinessException {
|
| 383 |
LOGGER.info("Trying to process SchemeIn with purchaseId [{}] and retailerId [{}]", purchaseId, retailerId);
|
386 |
LOGGER.info("Trying to process SchemeIn with purchaseId [{}] and retailerId [{}]", purchaseId, retailerId);
|
| Line 395... |
Line 398... |
| 395 |
return;
|
398 |
return;
|
| 396 |
}
|
399 |
}
|
| 397 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
|
400 |
List<InventoryItem> inventoryItems = inventoryItemRepository.selectByPurchaseId(purchaseId);
|
| 398 |
|
401 |
|
| 399 |
Set<Integer> itemIds = inventoryItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
|
402 |
Set<Integer> itemIds = inventoryItems.stream().map(x -> x.getItemId()).collect(Collectors.toSet());
|
| - |
|
403 |
Map<Integer, Item> itemsMap = itemRepository.selectByIds(itemIds).stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
404 |
inventoryItems.stream().forEach(x -> x.setItem(itemsMap.get(x.getItemId())));
|
| - |
|
405 |
|
| 400 |
LocalDateTime billingDate = purchaseService.getBillingDateOfPurchase(purchaseId);
|
406 |
LocalDateTime billingDate = purchaseService.getBillingDateOfPurchase(purchaseId);
|
| 401 |
Set<Integer> itemIdsSet = tagListingRepository.selectByItemIdsAndTagIds(itemIds, tagIds).stream()
|
407 |
Set<Integer> itemIdsSet = tagListingRepository.selectByItemIdsAndTagIds(itemIds, tagIds).stream()
|
| 402 |
.filter(x -> x.getEolDate() == null || x.getEolDate().isAfter(billingDate)).map(x -> x.getItemId())
|
408 |
.filter(x -> x.getEolDate() == null || x.getEolDate().isAfter(billingDate)).map(x -> x.getItemId())
|
| 403 |
.collect(Collectors.toSet());
|
409 |
.collect(Collectors.toSet());
|
| 404 |
// Only consider inventory items that were not returned
|
410 |
// Only consider inventory items that were not returned
|