Subversion Repositories SmartDukaan

Rev

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

Rev 33662 Rev 33695
Line 918... Line 918...
918
                    purchasedValue = totalBaseValue;
918
                    purchasedValue = totalBaseValue;
919
                } else {
919
                } else {
920
                    purchasedValue = totalBaseQty;
920
                    purchasedValue = totalBaseQty;
921
                }
921
                }
922
 
922
 
923
                PayoutSlab eligibleSlab  = null;
923
                PayoutSlab eligibleSlab = null;
924
                PayoutSlab previousSlab  = null;
-
 
925
 
924
 
926
                for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
925
                for (PayoutSlab payoutSlab : itemCriteriaPayout.getPayoutSlabs()) {
927
                    if (payoutSlab.getOnwardsAmount() <= purchasedValue) {
926
                    if (payoutSlab.getOnwardsAmount() <= purchasedValue) {
928
                        previousSlab = eligibleSlab;
-
 
929
                        eligibleSlab = payoutSlab;
927
                        eligibleSlab = payoutSlab;
930
                    } else {
928
                    } else {
931
                        break;
929
                        break;
932
                    }
930
                    }
933
                }
931
                }
-
 
932
                if (eligibleSlab == null) continue;
934
                List<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toList());
933
                List<Integer> orderIds = orders.stream().map(x -> x.getId()).collect(Collectors.toList());
935
                Map<Integer, LineItem> lineItemMap = orders.stream().collect(Collectors.toMap(x -> x.getLineItem().getId(), x -> x.getLineItem()));
934
                Map<Integer, LineItem> lineItemMap = orders.stream().collect(Collectors.toMap(x -> x.getLineItem().getId(), x -> x.getLineItem()));
936
                List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByOrderIds(orderIds);
935
                List<WarehouseScan> warehouseScans = warehouseScanRepository.selectAllByOrderIds(orderIds);
937
                LOGGER.info("Warehosue scans --> {}", warehouseScans);
936
                LOGGER.info("Warehosue scans --> {}", warehouseScans);
938
                List<Integer> warehouseInventoryItemIds = warehouseScans.stream().collect(Collectors.groupingBy(x -> x.getInventoryItemId())).entrySet()
937
                List<Integer> warehouseInventoryItemIds = warehouseScans.stream().collect(Collectors.groupingBy(x -> x.getInventoryItemId())).entrySet()
Line 970... Line 969...
970
                if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
969
                if (AmountType.PERCENTAGE.equals(itemCriteriaPayout.getAmountType())) {
971
                    finalPayout = (eligiblePayoutValue * purchasedValue) / 100;
970
                    finalPayout = (eligiblePayoutValue * purchasedValue) / 100;
972
                } else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
971
                } else if (AmountType.FIXED.equals(itemCriteriaPayout.getAmountType())) {
973
                    finalPayout = eligiblePayoutValue * purchasedValue;
972
                    finalPayout = eligiblePayoutValue * purchasedValue;
974
                } else {
973
                } else {
975
                    Map<Integer, Double> fofoCriteriaMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
974
                    Map<Integer, Double> fofoCriteriaPayoutMap = fixedSlabCriteriaPartnerMap.get(criteriaId);
976
                    LOGGER.info("fofoCriteriaMap {}", fofoCriteriaMap);
975
                    LOGGER.info("fofoCriteriaMap {}", fofoCriteriaPayoutMap);
977
                    finalPayout = eligiblePayoutValue;
976
                    finalPayout = eligiblePayoutValue;
978
                    if (fofoCriteriaMap != null) {
-
 
979
                        if (fofoCriteriaMap.containsKey(fofoId)) {
977
                    if (fofoCriteriaPayoutMap != null && fofoCriteriaPayoutMap.containsKey(fofoId)) {
980
                            double totalPayout = fofoCriteriaMap.get(fofoId);
-
 
981
                            finalPayout = eligiblePayoutValue - previousSlab.getPayoutAmount();
978
                        finalPayout = eligiblePayoutValue - fofoCriteriaPayoutMap.get(fofoId);
982
                            if (Math.abs(finalPayout) < Utils.DOUBLE_EPSILON) {
979
                        if (Math.abs(finalPayout) < Utils.DOUBLE_EPSILON) {
983
                                finalPayout = 0;
980
                            finalPayout = 0;
984
                            }
-
 
985
                        }
981
                        }
986
                    }
982
                    }
987
                }
983
                }
988
 
984
 
989
                LOGGER.info("Or - {}", finalPayout);
985
                LOGGER.info("Or - {}", finalPayout);