Subversion Repositories SmartDukaan

Rev

Rev 36562 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36562 Rev 36578
Line 825... Line 825...
825
                itemIdQuantityMap.merge(fofoOrderItem.getItemId(), fofoOrderItem.getQuantity(), Integer::sum);
825
                itemIdQuantityMap.merge(fofoOrderItem.getItemId(), fofoOrderItem.getQuantity(), Integer::sum);
826
            }
826
            }
827
            smartCartService.minusOpeningStockBatch(itemIdQuantityMap, fofoOrder.getFofoId());
827
            smartCartService.minusOpeningStockBatch(itemIdQuantityMap, fofoOrder.getFofoId());
828
        }
828
        }
829
 
829
 
830
        // Flagship credit conversion: only check catalogs if partner actually has active flagship limits
830
        // Flagship credit conversion: invoice on the flagship loan links directly to purchase orders,
-
 
831
        // so we only need the sold catalog IDs — no need to re-check model_flagship table
831
        try {
832
        try {
832
            if (sdCreditService.hasActiveFlagshipLimits(fofoId)) {
833
            if (sdCreditService.hasActiveFlagshipLimits(fofoId)) {
833
                Set<Integer> soldCatalogIds = fofoItems.stream()
834
                Set<Integer> soldCatalogIds = fofoItems.stream()
834
                        .map(foi -> itemMap.get(foi.getItemId()))
835
                        .map(foi -> itemMap.get(foi.getItemId()))
835
                        .filter(Objects::nonNull)
836
                        .filter(Objects::nonNull)
836
                        .map(Item::getCatalogItemId)
837
                        .map(Item::getCatalogItemId)
837
                        .collect(Collectors.toSet());
838
                        .collect(Collectors.toSet());
838
 
839
 
839
                if (!soldCatalogIds.isEmpty()) {
840
                if (!soldCatalogIds.isEmpty()) {
840
                    Set<Integer> flagshipCatalogIds = sdCreditService.getActiveFlagshipCatalogIds(new ArrayList<>(soldCatalogIds));
-
 
841
                    if (!flagshipCatalogIds.isEmpty()) {
-
 
842
                        sdCreditService.convertFlagshipOnSale(fofoId, flagshipCatalogIds);
841
                    sdCreditService.convertFlagshipOnSale(fofoId, soldCatalogIds);
843
                    }
-
 
844
                }
842
                }
845
            }
843
            }
846
        } catch (Exception e) {
844
        } catch (Exception e) {
847
            LOGGER.error("Failed to convert flagship credits on sale for fofoId {}", fofoId, e);
845
            LOGGER.error("Failed to convert flagship credits on sale for fofoId {}", fofoId, e);
848
        }
846
        }