Subversion Repositories SmartDukaan

Rev

Rev 35765 | Rev 35776 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 35765 Rev 35771
Line 161... Line 161...
161
 
161
 
162
    @Autowired
162
    @Autowired
163
    private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
163
    private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
164
 
164
 
165
    @Autowired
165
    @Autowired
-
 
166
    private InventoryItemRepository inventoryItemRepository;
-
 
167
 
-
 
168
    @Autowired
166
    private PurchaseRepository purchaseRepository;
169
    private PurchaseRepository purchaseRepository;
167
 
170
 
168
    @Autowired
171
    @Autowired
169
    private MVCResponseSender mvcResponseSender;
172
    private MVCResponseSender mvcResponseSender;
170
 
173
 
Line 2344... Line 2347...
2344
            throws Exception {
2347
            throws Exception {
2345
        List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
2348
        List<Item> items = itemRepository.selectAllByCatalogItemId(catalogId);
2346
        Map<Integer, Item> itemMap = items.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
2349
        Map<Integer, Item> itemMap = items.stream().collect(Collectors.toMap(x -> x.getId(), x -> x));
2347
        Set<Integer> itemSet = items.stream().map(x -> x.getId()).collect(Collectors.toSet());
2350
        Set<Integer> itemSet = items.stream().map(x -> x.getId()).collect(Collectors.toSet());
2348
        List<CurrentInventorySnapshot> currentInventorySnapshots = currentInventorySnapshotRepository.selectByFofoItemIds(fofoId, itemSet);
2351
        List<CurrentInventorySnapshot> currentInventorySnapshots = currentInventorySnapshotRepository.selectByFofoItemIds(fofoId, itemSet);
-
 
2352
 
-
 
2353
        // Get activated but not sold inventory items for this fofoId
-
 
2354
        List<InventoryItem> activatedNotSoldItems = inventoryItemRepository.selectByActivatedNotSold(fofoId);
-
 
2355
 
-
 
2356
        // Group activated items by itemId with their serial numbers
-
 
2357
        Map<Integer, List<String>> activatedItemImeiMap = activatedNotSoldItems.stream()
-
 
2358
                .collect(Collectors.groupingBy(
-
 
2359
                        InventoryItem::getItemId,
-
 
2360
                        Collectors.mapping(InventoryItem::getSerialNumber, Collectors.toList())
-
 
2361
                ));
-
 
2362
 
2349
        List<InStockItemDetailModel> inStockItemDetailModels = new ArrayList<>();
2363
        List<InStockItemDetailModel> inStockItemDetailModels = new ArrayList<>();
2350
        for (CurrentInventorySnapshot snap : currentInventorySnapshots) {
2364
        for (CurrentInventorySnapshot snap : currentInventorySnapshots) {
2351
            InStockItemDetailModel inStockItemDetailModel = new InStockItemDetailModel();
2365
            InStockItemDetailModel inStockItemDetailModel = new InStockItemDetailModel();
2352
            inStockItemDetailModel.setAvailability(snap.getAvailability());
2366
            inStockItemDetailModel.setAvailability(snap.getAvailability());
2353
            inStockItemDetailModel.setItemId(snap.getItemId());
2367
            inStockItemDetailModel.setItemId(snap.getItemId());
2354
            inStockItemDetailModel.setCatalogId(itemMap.get(snap.getItemId()).getCatalogItemId());
2368
            inStockItemDetailModel.setCatalogId(itemMap.get(snap.getItemId()).getCatalogItemId());
2355
            inStockItemDetailModel.setItemDescription(itemMap.get(snap.getItemId()).getItemDescription());
2369
            inStockItemDetailModel.setItemDescription(itemMap.get(snap.getItemId()).getItemDescription());
2356
            inStockItemDetailModel.setFofoId(snap.getFofoId());
2370
            inStockItemDetailModel.setFofoId(snap.getFofoId());
-
 
2371
            // Check if this item has any activated but not sold IMEIs and set the IMEI list
-
 
2372
            List<String> activatedImeis = activatedItemImeiMap.get(snap.getItemId());
-
 
2373
            if (activatedImeis != null && !activatedImeis.isEmpty()) {
-
 
2374
                inStockItemDetailModel.setHasActivatedImei(true);
-
 
2375
                inStockItemDetailModel.setActivatedImeis(activatedImeis);
-
 
2376
            }
2357
            inStockItemDetailModels.add(inStockItemDetailModel);
2377
            inStockItemDetailModels.add(inStockItemDetailModel);
2358
        }
2378
        }
2359
 
2379
 
2360
        return responseSender.ok(inStockItemDetailModels);
2380
        return responseSender.ok(inStockItemDetailModels);
2361
    }
2381
    }
Line 2744... Line 2764...
2744
        model.addAttribute("fofoId", fofoId);
2764
        model.addAttribute("fofoId", fofoId);
2745
        model.addAttribute("warehouseId", warehouseId);
2765
        model.addAttribute("warehouseId", warehouseId);
2746
        model.addAttribute("customRetailer", customRetailer);
2766
        model.addAttribute("customRetailer", customRetailer);
2747
        model.addAttribute("shortInvest", shortInvest);
2767
        model.addAttribute("shortInvest", shortInvest);
2748
        model.addAttribute("totalDueWithInterest", totalDueWithInterest);
2768
        model.addAttribute("totalDueWithInterest", totalDueWithInterest);
-
 
2769
        model.addAttribute("interestDue", Math.subtractExact(totalDueWithInterest, sdCreditRequirement.getUtilizedAmount().intValue()));
-
 
2770
 
2749
        model.addAttribute("purchaseMtd", purchaseMtd);
2771
        model.addAttribute("purchaseMtd", purchaseMtd);
2750
        model.addAttribute("purchasedFtd", purchasedFtd);
2772
        model.addAttribute("purchasedFtd", purchasedFtd);
2751
        model.addAttribute("saleMtd", saleMtd);
2773
        model.addAttribute("saleMtd", saleMtd);
2752
        model.addAttribute("purchaseTargetFtd", purchaseTargetFtd);
2774
        model.addAttribute("purchaseTargetFtd", purchaseTargetFtd);
2753
        model.addAttribute("recoverableAmount", recoverableAmount);
2775
        model.addAttribute("recoverableAmount", recoverableAmount);