Subversion Repositories SmartDukaan

Rev

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

Rev 33454 Rev 33520
Line 262... Line 262...
262
        Map<Integer, CustomFofoOrderItem> itemIdCustomFofoOrderItemMap = new HashMap<>();
262
        Map<Integer, CustomFofoOrderItem> itemIdCustomFofoOrderItemMap = new HashMap<>();
263
        Map<Integer, Float> lineItemPrice = new HashMap<>(); // this is for pricing error
263
        Map<Integer, Float> lineItemPrice = new HashMap<>(); // this is for pricing error
264
 
264
 
265
        float totalAmount = 0;
265
        float totalAmount = 0;
266
        boolean noGST = false;
266
        boolean noGST = false;
267
        int changedTotalBillAmount=0;
267
        int changedTotalBillAmount = 0;
268
        for(CustomPaymentOption cpo : createOrderRequest.getPaymentOptions()){
268
        for (CustomPaymentOption cpo : createOrderRequest.getPaymentOptions()) {
269
            changedTotalBillAmount += cpo.getAmount();
269
            changedTotalBillAmount += cpo.getAmount();
270
        }
270
        }
271
        for (CustomFofoOrderItem customFofoOrderItem : createOrderRequest.getFofoOrderItems()) {
271
        for (CustomFofoOrderItem customFofoOrderItem : createOrderRequest.getFofoOrderItems()) {
272
            if(customFofoOrderItem.getPoiId() > 0){
272
            if (customFofoOrderItem.getPoiId() > 0) {
273
                PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(customFofoOrderItem.getPoiId());
273
                PendingOrderItem pendingOrderItem = pendingOrderItemRepository.selectById(customFofoOrderItem.getPoiId());
274
                if(customFofoOrderItem.getQuantity() > pendingOrderItem.getQuantity()){
274
                if (customFofoOrderItem.getQuantity() > pendingOrderItem.getQuantity()) {
275
                    throw new ProfitMandiBusinessException("itemIdQuantity", customFofoOrderItem.getItemId(), "Quantity should not be greater than order item quantity");
275
                    throw new ProfitMandiBusinessException("itemIdQuantity", customFofoOrderItem.getItemId(), "Quantity should not be greater than order item quantity");
276
                }
276
                }
277
                if(pendingOrderItem.getQuantity() > customFofoOrderItem.getQuantity()){
277
                if (pendingOrderItem.getQuantity() > customFofoOrderItem.getQuantity()) {
278
                    pendingOrderService.duplicatePendingOrder(pendingOrderItem,customFofoOrderItem.getQuantity());
278
                    pendingOrderService.duplicatePendingOrder(pendingOrderItem, customFofoOrderItem.getQuantity());
279
                }
279
                }
280
            }
280
            }
281
            // itemIds.add(customFofoOrderItem.getItemId());
281
            // itemIds.add(customFofoOrderItem.getItemId());
282
            Set<String> serialNumbers = this.serialNumberDetailsToSerialNumbers(customFofoOrderItem.getSerialNumberDetails());
282
            Set<String> serialNumbers = this.serialNumberDetailsToSerialNumbers(customFofoOrderItem.getSerialNumberDetails());
283
            if (!serialNumbers.isEmpty() && customFofoOrderItem.getQuantity() != serialNumbers.size()) {
283
            if (!serialNumbers.isEmpty() && customFofoOrderItem.getQuantity() != serialNumbers.size()) {
Line 349... Line 349...
349
                        im.setRam(serialNumberDetail.getRam());
349
                        im.setRam(serialNumberDetail.getRam());
350
                        im.setMfgDate(serialNumberDetail.getMfgDate());
350
                        im.setMfgDate(serialNumberDetail.getMfgDate());
351
                        insuredModels.add(im);
351
                        insuredModels.add(im);
352
                        // Check for free insurance code
352
                        // Check for free insurance code
353
                        try {
353
                        try {
354
                            Map<String, List<MobileInsurancePlan>> mobileInsurancePlanMap = insuranceService.getAllPlans(item.getId(), im.getDeviceSellingPrice(),false);
354
                            Map<String, List<MobileInsurancePlan>> mobileInsurancePlanMap = insuranceService.getAllPlans(item.getId(), im.getDeviceSellingPrice(), false);
355
                            LOGGER.info("mobileInsurancePlanMap - {}", mobileInsurancePlanMap);
355
                            LOGGER.info("mobileInsurancePlanMap - {}", mobileInsurancePlanMap);
356
                            MobileInsurancePlan mobileInsurancePlan = mobileInsurancePlanMap.entrySet().stream().flatMap(x -> x.getValue().stream()).filter(x -> x.getProductId().equals(serialNumberDetail.getInsurance())).findFirst().get();
356
                            MobileInsurancePlan mobileInsurancePlan = mobileInsurancePlanMap.entrySet().stream().flatMap(x -> x.getValue().stream()).filter(x -> x.getProductId().equals(serialNumberDetail.getInsurance())).findFirst().get();
357
                            LOGGER.info("SerialNumber Detqail InsuranceId - {}", serialNumberDetail.getInsurance());
357
                            LOGGER.info("SerialNumber Detqail InsuranceId - {}", serialNumberDetail.getInsurance());
358
                            LOGGER.info("product description - {}", mobileInsurancePlan);
358
                            LOGGER.info("product description - {}", mobileInsurancePlan);
359
                            if (mobileInsurancePlan.getPlanName().equals("OneAssist Damage Protection Plan")) {
359
                            if (mobileInsurancePlan.getPlanName().equals("OneAssist Damage Protection Plan")) {
Line 570... Line 570...
570
        schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
570
        schemeService.processSchemeOut(fofoOrder.getId(), fofoId);
571
 
571
 
572
        if (createOrderRequest.getPoId() != 0) {
572
        if (createOrderRequest.getPoId() != 0) {
573
            PendingOrder po = pendingOrderRepository.selectById(createOrderRequest.getPoId());
573
            PendingOrder po = pendingOrderRepository.selectById(createOrderRequest.getPoId());
574
            po.setBilledAmount(po.getBilledAmount() + totalAmount);
574
            po.setBilledAmount(po.getBilledAmount() + totalAmount);
575
            for(CustomFofoOrderItem cfoi : createOrderRequest.getFofoOrderItems()){
575
            for (CustomFofoOrderItem cfoi : createOrderRequest.getFofoOrderItems()) {
576
                PendingOrderItem poi = pendingOrderItemRepository.selectById(cfoi.getPoiId());
576
                PendingOrderItem poi = pendingOrderItemRepository.selectById(cfoi.getPoiId());
577
                poi.setStatus(OrderStatus.BILLED);
577
                poi.setStatus(OrderStatus.BILLED);
578
                poi.setBilledTimestamp(LocalDateTime.now());
578
                poi.setBilledTimestamp(LocalDateTime.now());
579
            }
579
            }
580
            po.setStatus(OrderStatus.BILLED);
580
            po.setStatus(OrderStatus.BILLED);
Line 1434... Line 1434...
1434
            }
1434
            }
1435
        }
1435
        }
1436
        return serialNumbers;
1436
        return serialNumbers;
1437
    }
1437
    }
1438
 
1438
 
-
 
1439
    static final List<String> MOP_VOILATED_BRANDS = Arrays.asList("Live Demo", "Almost New");
-
 
1440
 
1439
    private void validateDpPrice(int fofoId, Map<Integer, PriceModel> itemIdMopPriceMap, Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1441
    private void validateDpPrice(int fofoId, Map<Integer, PriceModel> itemIdMopPriceMap, Map<Integer, CustomFofoOrderItem> itemIdCustomFofoLineItemMap) throws ProfitMandiBusinessException {
1440
        if (pricingService.getMopVoilatedRetailerIds().contains(fofoId)) return;
1442
        if (pricingService.getMopVoilatedRetailerIds().contains(fofoId)) return;
1441
        for (Map.Entry<Integer, CustomFofoOrderItem> entry : itemIdCustomFofoLineItemMap.entrySet()) {
1443
        for (Map.Entry<Integer, CustomFofoOrderItem> entry : itemIdCustomFofoLineItemMap.entrySet()) {
1442
            int itemId = entry.getKey();
1444
            int itemId = entry.getKey();
1443
            CustomFofoOrderItem customFofoOrderItem = entry.getValue();
1445
            CustomFofoOrderItem customFofoOrderItem = entry.getValue();
1444
            LOGGER.info("CustomFofoOrderItem -- {}", customFofoOrderItem);
1446
            LOGGER.info("CustomFofoOrderItem -- {}", customFofoOrderItem);
1445
            PriceModel priceModel = itemIdMopPriceMap.get(itemId);
1447
            PriceModel priceModel = itemIdMopPriceMap.get(itemId);
1446
            Item item = itemRepository.selectById(itemId);
1448
            Item item = itemRepository.selectById(itemId);
1447
            if (!item.getBrand().equals("Live Demo") && (item.getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID || item.getCategoryId() == ProfitMandiConstants.TABLET_CATEGORY_ID || item.getCategoryId() == ProfitMandiConstants.LED_CATEGORY_ID) && customFofoOrderItem.getSerialNumberDetails().stream().filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber())).collect(Collectors.toList()).size() > 0) {
1449
            if (!MOP_VOILATED_BRANDS.contains(item.getBrand()) && (item.getCategoryId() == ProfitMandiConstants.MOBILE_CATEGORY_ID || item.getCategoryId() == ProfitMandiConstants.TABLET_CATEGORY_ID || item.getCategoryId() == ProfitMandiConstants.LED_CATEGORY_ID) && customFofoOrderItem.getSerialNumberDetails().stream().filter(x -> org.apache.commons.lang.StringUtils.isNotEmpty(x.getSerialNumber())).collect(Collectors.toList()).size() > 0) {
1448
                if (Utils.compareFloat(priceModel.getPrice(), customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount()) > 0) {
1450
                if (Utils.compareFloat(priceModel.getPrice(), customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount()) > 0) {
1449
                    throw new ProfitMandiBusinessException("Selling Price for ", item.getItemDescription(), "FFORDR_1010");
1451
                    throw new ProfitMandiBusinessException("Selling Price for ", item.getItemDescription(), "FFORDR_1010");
1450
                }
1452
                }
1451
            } else {
1453
            } else {
1452
                if (!item.getBrand().equals("Live Demo") && priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
1454
                if (!MOP_VOILATED_BRANDS.contains(item.getBrand()) && priceModel.getPurchasePrice() > customFofoOrderItem.getSellingPrice()) {
1453
                    throw new ProfitMandiBusinessException("Selling Price", itemRepository.selectById(itemId).getItemDescription(), "Selling Price should not be less than DP");
1455
                    throw new ProfitMandiBusinessException("Selling Price", itemRepository.selectById(itemId).getItemDescription(), "Selling Price should not be less than DP");
1454
                }
1456
                }
1455
            }
1457
            }
1456
        }
1458
        }
1457
    }
1459
    }
Line 1460... Line 1462...
1460
        if (pricingService.getMopVoilatedRetailerIds().contains(fofoId)) return;
1462
        if (pricingService.getMopVoilatedRetailerIds().contains(fofoId)) return;
1461
        Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1463
        Map<Integer, Float> invalidMopItemIdPriceMap = new HashMap<>();
1462
        for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1464
        for (Map.Entry<Integer, PriceModel> entry : itemIdMopPriceMap.entrySet()) {
1463
            CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1465
            CustomFofoOrderItem customFofoOrderItem = itemIdCustomFofoLineItemMap.get(entry.getKey());
1464
            Item item = itemRepository.selectById(customFofoOrderItem.getItemId());
1466
            Item item = itemRepository.selectById(customFofoOrderItem.getItemId());
1465
            if (!(item.getBrand().equals("Live Demo") || item.getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID || item.getCategoryId() != ProfitMandiConstants.TABLET_CATEGORY_ID) && customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount() < entry.getValue().getPrice()) {
1467
            if (!(MOP_VOILATED_BRANDS.contains(item.getBrand()) || item.getCategoryId() != ProfitMandiConstants.MOBILE_CATEGORY_ID || item.getCategoryId() != ProfitMandiConstants.TABLET_CATEGORY_ID) && customFofoOrderItem.getSellingPrice() + customFofoOrderItem.getDiscountAmount() < entry.getValue().getPrice()) {
1466
                invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
1468
                invalidMopItemIdPriceMap.put(entry.getKey(), customFofoOrderItem.getSellingPrice());
1467
            }
1469
            }
1468
        }
1470
        }
1469
 
1471
 
1470
        if (!invalidMopItemIdPriceMap.isEmpty()) {
1472
        if (!invalidMopItemIdPriceMap.isEmpty()) {