Subversion Repositories SmartDukaan

Rev

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

Rev 34363 Rev 34374
Line 1028... Line 1028...
1028
 
1028
 
1029
    public void test() throws Exception {
1029
    public void test() throws Exception {
1030
        //List<TotalLoanAmountDueModel> totalLoanAmountDueModels = loanRepository.getDueLoansByFofoId(175139438);
1030
        //List<TotalLoanAmountDueModel> totalLoanAmountDueModels = loanRepository.getDueLoansByFofoId(175139438);
1031
        //System.out.println(totalLoanAmountDueModels);
1031
        //System.out.println(totalLoanAmountDueModels);
1032
        //runOnceTasks.findCNDiff();
1032
        //runOnceTasks.findCNDiff();
-
 
1033
        System.out.println(getSuggestedLimit(300000d));
-
 
1034
        System.out.println(getSuggestedLimit(400000d));
-
 
1035
        System.out.println(getSuggestedLimit(500000d));
-
 
1036
        System.out.println(getSuggestedLimit(600000d));
-
 
1037
        System.out.println(getSuggestedLimit(700000d));
-
 
1038
        System.out.println(getSuggestedLimit(1500000d));
-
 
1039
        System.out.println(getSuggestedLimit(2000000d));
-
 
1040
        System.out.println(getSuggestedLimit(2500000d));
1033
        Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null,
1041
        //Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null, "DTDC AWb", "PFA");
1034
                "DTDC AWb", "PFA");
-
 
1035
    }
1042
    }
1036
 
1043
 
1037
    public void test4() throws Exception {
1044
    public void test4() throws Exception {
1038
        List<Integer> offerIds = Arrays.asList(2882, 2881, 2880, 2879, 2878, 2877, 2876, 2875, 2874, 2873, 2872, 2871, 2870, 2869, 2868, 2867, 2866, 2865, 2864, 2863, 2862, 2861, 2860, 2859, 2858, 2857, 2856, 2855, 2854, 2853, 2852, 2851, 2850, 2849, 2847, 2846, 2845, 2844, 2843, 2842, 2841, 2840, 2839, 2838, 2837, 2836, 2835, 2834, 2833, 2832, 2831, 2830, 2829, 2828, 2827, 2826, 2825, 2824, 2823, 2822, 2821, 2820, 2819, 2818, 2817, 2816, 2815, 2814, 2813, 2812, 2811, 2810, 2809, 2808, 2807, 2806, 2805, 2804, 2803, 2802, 2801, 2800, 2799, 2798, 2797, 2796, 2795, 2794, 2793, 2792, 2791, 2790, 2789, 2788, 2787, 2786, 2785, 2784, 2783, 2782, 2781, 2780, 2777, 2776, 2775, 2774, 2773, 2772, 2771, 2770, 2769, 2768, 2767, 2766, 2765, 2764, 2763, 2762, 2761, 2760, 2759, 2758, 2757, 2756, 2755, 2754, 2753, 2752, 2751, 2750, 2749, 2748, 2747, 2746, 2745, 2744, 2723, 2722, 2721, 2720, 2719, 2718, 2717, 2716, 2715, 2714, 2713, 2712, 2711, 2710, 2709, 2708, 2707, 2706, 2705, 2704, 2703, 2702, 2701, 2700, 2699, 2698, 2697, 2696, 2695, 2694, 2693, 2692, 2691, 2690, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2470, 2469, 2466, 2465, 2464, 2463, 2462, 2461, 2460, 2459, 2458, 2457, 2456, 2455, 2454, 2453, 2452, 2451, 2450, 2449, 2448, 2447, 2446, 2445, 2444, 2443, 2442, 2441, 2440, 2439, 2407, 2406, 2405, 2404, 2403, 2402, 2401, 2400, 2399, 2398, 2397, 2396, 2395, 2394, 2393, 2392, 2391, 2390, 2389, 2388, 2387, 2386, 2385, 2384, 2383, 2382, 2381, 2117, 2116, 2115, 2114, 2113, 2112, 2111, 2110, 2109, 2108, 2107, 2106, 2105, 2104, 2103, 2102, 2101, 2100, 2099, 2098, 2077);
1045
        List<Integer> offerIds = Arrays.asList(2882, 2881, 2880, 2879, 2878, 2877, 2876, 2875, 2874, 2873, 2872, 2871, 2870, 2869, 2868, 2867, 2866, 2865, 2864, 2863, 2862, 2861, 2860, 2859, 2858, 2857, 2856, 2855, 2854, 2853, 2852, 2851, 2850, 2849, 2847, 2846, 2845, 2844, 2843, 2842, 2841, 2840, 2839, 2838, 2837, 2836, 2835, 2834, 2833, 2832, 2831, 2830, 2829, 2828, 2827, 2826, 2825, 2824, 2823, 2822, 2821, 2820, 2819, 2818, 2817, 2816, 2815, 2814, 2813, 2812, 2811, 2810, 2809, 2808, 2807, 2806, 2805, 2804, 2803, 2802, 2801, 2800, 2799, 2798, 2797, 2796, 2795, 2794, 2793, 2792, 2791, 2790, 2789, 2788, 2787, 2786, 2785, 2784, 2783, 2782, 2781, 2780, 2777, 2776, 2775, 2774, 2773, 2772, 2771, 2770, 2769, 2768, 2767, 2766, 2765, 2764, 2763, 2762, 2761, 2760, 2759, 2758, 2757, 2756, 2755, 2754, 2753, 2752, 2751, 2750, 2749, 2748, 2747, 2746, 2745, 2744, 2723, 2722, 2721, 2720, 2719, 2718, 2717, 2716, 2715, 2714, 2713, 2712, 2711, 2710, 2709, 2708, 2707, 2706, 2705, 2704, 2703, 2702, 2701, 2700, 2699, 2698, 2697, 2696, 2695, 2694, 2693, 2692, 2691, 2690, 2494, 2493, 2492, 2491, 2490, 2489, 2488, 2487, 2486, 2485, 2484, 2483, 2482, 2481, 2480, 2479, 2478, 2477, 2476, 2475, 2474, 2473, 2472, 2471, 2470, 2469, 2466, 2465, 2464, 2463, 2462, 2461, 2460, 2459, 2458, 2457, 2456, 2455, 2454, 2453, 2452, 2451, 2450, 2449, 2448, 2447, 2446, 2445, 2444, 2443, 2442, 2441, 2440, 2439, 2407, 2406, 2405, 2404, 2403, 2402, 2401, 2400, 2399, 2398, 2397, 2396, 2395, 2394, 2393, 2392, 2391, 2390, 2389, 2388, 2387, 2386, 2385, 2384, 2383, 2382, 2381, 2117, 2116, 2115, 2114, 2113, 2112, 2111, 2110, 2109, 2108, 2107, 2106, 2105, 2104, 2103, 2102, 2101, 2100, 2099, 2098, 2077);
1039
        for (Integer offerId : offerIds) {
1046
        for (Integer offerId : offerIds) {
Line 3537... Line 3544...
3537
        for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
3544
        for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
3538
            int fofoId = customRetailerEntry.getKey();
3545
            int fofoId = customRetailerEntry.getKey();
3539
            LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
3546
            LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
3540
 
3547
 
3541
            CreditAccount creditAccount = creditAccountMap.get(fofoId);
3548
            CreditAccount creditAccount = creditAccountMap.get(fofoId);
3542
 
-
 
-
 
3549
            long utilizationAmount = sdCreditService.getUtilizationAmount(fofoId);
3543
            CurrentPartnerDailyInvestment currentPartnerDailyInvestment = currentPartnerDailyInvestmentMap.get(fofoId);
3550
            CurrentPartnerDailyInvestment currentPartnerDailyInvestment = currentPartnerDailyInvestmentMap.get(fofoId);
3544
            BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, currentPartnerDailyInvestment, fofoSidbiLimitMap.get(fofoId));
3551
            BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, currentPartnerDailyInvestment, utilizationAmount, fofoSidbiLimitMap.get(fofoId));
3545
            SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
3552
            SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
3546
 
3553
 
3547
            LOGGER.info("suggestedAmount {} ", suggestedAmount);
3554
            LOGGER.info("suggestedAmount {} ", suggestedAmount);
3548
 
3555
 
3549
            if (sdCreditRequirement == null) {
3556
            if (sdCreditRequirement == null) {
Line 3588... Line 3595...
3588
            }
3595
            }
3589
 
3596
 
3590
        }
3597
        }
3591
 
3598
 
3592
    }
3599
    }
-
 
3600
    private static final NavigableMap<Double, Double> discountMap = new TreeMap<>();
-
 
3601
    static {
-
 
3602
        discountMap.put(6*ProfitMandiConstants.ONE_LAC, 0.2);   // Up to 6 -> 20%
-
 
3603
        discountMap.put(10*ProfitMandiConstants.ONE_LAC, 0.25);  // 6-10 -> 25%
-
 
3604
        discountMap.put(20*ProfitMandiConstants.ONE_LAC, 0.3); // Above 10 -> 30%
-
 
3605
        discountMap.put(Double.MAX_VALUE, 0.4); // Above 10 -> 30%
3593
 
3606
    }
-
 
3607
    public  BigDecimal getSuggestedLimit(double investmentValue) {
-
 
3608
        double percentageValue = discountMap.ceilingEntry(investmentValue).getValue();
-
 
3609
        return BigDecimal.valueOf(investmentValue * percentageValue);
-
 
3610
    }
3594
    private BigDecimal getSuggestedAmount(CreditAccount creditAccount, CurrentPartnerDailyInvestment currentPartnerDailyInvestment, BigDecimal sidbiLimit) {
3611
    private BigDecimal getSuggestedAmount(CreditAccount creditAccount, CurrentPartnerDailyInvestment currentPartnerDailyInvestment, long utilizationAmount,  BigDecimal sidbiLimit) {
3595
        BigDecimal suggestedAmount = BigDecimal.ZERO;
3612
        BigDecimal suggestedAmount = BigDecimal.ZERO;
3596
        //1 LAC
3613
        //1 LAC
3597
        double limitValue = 100000;
-
 
3598
        if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
3614
        if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
3599
 
3615
 
3600
            if (currentPartnerDailyInvestment != null) {
3616
            if (currentPartnerDailyInvestment != null) {
3601
                suggestedAmount = BigDecimal.valueOf(Math.min(currentPartnerDailyInvestment.getTotalInvestment() * 0.1, limitValue));
3617
                suggestedAmount = getSuggestedLimit(currentPartnerDailyInvestment.getTotalInvestment() - utilizationAmount);
3602
            }
3618
            }
3603
            if (suggestedAmount.doubleValue() < 0) {
3619
            if (suggestedAmount.doubleValue() < 0) {
3604
                suggestedAmount = BigDecimal.ZERO;
3620
                suggestedAmount = BigDecimal.ZERO;
3605
            }
3621
            }
3606
        } else if (creditAccount.getGateway().equals(Gateway.SIDBI) && sidbiLimit != null) {
3622
        } else if (creditAccount.getGateway().equals(Gateway.SIDBI) && sidbiLimit != null) {