Subversion Repositories SmartDukaan

Rev

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

Rev 37327 Rev 37348
Line 2810... Line 2810...
2810
                long accessoriesTarget = 0;
2810
                long accessoriesTarget = 0;
2811
                long totalTarget = 0;
2811
                long totalTarget = 0;
2812
                int achievementPercent = 0;
2812
                int achievementPercent = 0;
2813
                String aimingTier = null;
2813
                String aimingTier = null;
2814
                if (staticScheme != null) {
2814
                if (staticScheme != null) {
-
 
2815
                    // Total achievement = retailer's purchase billings (same source used last year).
-
 
2816
                    Map<Integer, Double> schemeAchievementMap = orderRepository.selectBillingDatesBetweenSumGroupByRetailerId(
-
 
2817
                            staticScheme.getStartDateTime(), staticScheme.getEndDateTime());
-
 
2818
                    schemeAchievement = schemeAchievementMap.getOrDefault(fofoId, 0.0);
-
 
2819
 
-
 
2820
                    // Category breakdown pulls from the same purchase source (Order + LineItem + Item):
2815
                    // Mobile (10006) + LED (14202) are the primary target; accessories is everything else.
2821
                    // Mobile (10006) + LED (14202) in one bucket, everything else in accessories.
2816
                    Set<Integer> mobileLedCategoryIds = new HashSet<>(Arrays.asList(10006, 14202));
2822
                    Set<Integer> mobileLedCategoryIds = new HashSet<>(Arrays.asList(10006, 14202));
2817
                    Map<Integer, Double> mobileLedMap = fofoOrderRepository.selectSumSaleGroupByFofoIdForCategories(
2823
                    Map<Integer, Double> mobileLedMap = orderRepository.selectBilledLineRevenueByRetailerAndCategories(
2818
                            fofoId, staticScheme.getStartDateTime(), staticScheme.getEndDateTime(), mobileLedCategoryIds, true);
2824
                            fofoId, staticScheme.getStartDateTime(), staticScheme.getEndDateTime(), mobileLedCategoryIds, true);
2819
                    Map<Integer, Double> accessoriesMap = fofoOrderRepository.selectSumSaleGroupByFofoIdForCategories(
2825
                    Map<Integer, Double> accessoriesMap = orderRepository.selectBilledLineRevenueByRetailerAndCategories(
2820
                            fofoId, staticScheme.getStartDateTime(), staticScheme.getEndDateTime(), mobileLedCategoryIds, false);
2826
                            fofoId, staticScheme.getStartDateTime(), staticScheme.getEndDateTime(), mobileLedCategoryIds, false);
2821
                    mobileLedAchievement = mobileLedMap.getOrDefault(fofoId, 0.0);
2827
                    mobileLedAchievement = mobileLedMap.getOrDefault(fofoId, 0.0);
2822
                    accessoriesAchievement = accessoriesMap.getOrDefault(fofoId, 0.0);
2828
                    accessoriesAchievement = accessoriesMap.getOrDefault(fofoId, 0.0);
2823
                    schemeAchievement = mobileLedAchievement + accessoriesAchievement;
-
 
2824
 
2829
 
2825
                    mobileLedTarget = staticScheme.getTarget();
2830
                    mobileLedTarget = staticScheme.getTarget();
2826
                    // Accessories target is fixed at 1% of the assigned mobile+LED target.
2831
                    // Accessories target is fixed at 1% of the assigned mobile+LED target.
2827
                    accessoriesTarget = Math.round(mobileLedTarget * 0.01);
2832
                    accessoriesTarget = Math.round(mobileLedTarget * 0.01);
2828
                    totalTarget = mobileLedTarget + accessoriesTarget;
2833
                    totalTarget = mobileLedTarget + accessoriesTarget;