Subversion Repositories SmartDukaan

Rev

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

Rev 34122 Rev 34160
Line 11... Line 11...
11
import com.smartdukaan.cron.scheduled.runnables.PurchaseMigration;
11
import com.smartdukaan.cron.scheduled.runnables.PurchaseMigration;
12
import com.spice.profitmandi.common.enumuration.*;
12
import com.spice.profitmandi.common.enumuration.*;
13
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
13
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
14
import com.spice.profitmandi.common.model.*;
14
import com.spice.profitmandi.common.model.*;
15
import com.spice.profitmandi.common.services.ReporticoService;
15
import com.spice.profitmandi.common.services.ReporticoService;
16
import com.spice.profitmandi.common.services.mandii.AccountStatusResponseOut;
-
 
17
import com.spice.profitmandi.common.services.mandii.EligibilityStatusEnum;
-
 
18
import com.spice.profitmandi.common.services.mandii.MandiiService;
16
import com.spice.profitmandi.common.services.mandii.MandiiService;
19
import com.spice.profitmandi.common.util.FileUtil;
17
import com.spice.profitmandi.common.util.FileUtil;
20
import com.spice.profitmandi.common.util.FormattingUtils;
18
import com.spice.profitmandi.common.util.FormattingUtils;
21
import com.spice.profitmandi.common.util.PdfUtils;
19
import com.spice.profitmandi.common.util.PdfUtils;
22
import com.spice.profitmandi.common.util.Utils;
20
import com.spice.profitmandi.common.util.Utils;
Line 34... Line 32...
34
import com.spice.profitmandi.dao.entity.dtr.*;
32
import com.spice.profitmandi.dao.entity.dtr.*;
35
import com.spice.profitmandi.dao.entity.fofo.*;
33
import com.spice.profitmandi.dao.entity.fofo.*;
36
import com.spice.profitmandi.dao.entity.inventory.*;
34
import com.spice.profitmandi.dao.entity.inventory.*;
37
import com.spice.profitmandi.dao.entity.logistics.AST;
35
import com.spice.profitmandi.dao.entity.logistics.AST;
38
import com.spice.profitmandi.dao.entity.logistics.ASTRepository;
36
import com.spice.profitmandi.dao.entity.logistics.ASTRepository;
39
import com.spice.profitmandi.dao.entity.logistics.WarehouseProvider;
37
import com.spice.profitmandi.dao.entity.onBoarding.LoiForm;
40
import com.spice.profitmandi.dao.entity.transaction.*;
38
import com.spice.profitmandi.dao.entity.transaction.*;
41
import com.spice.profitmandi.dao.entity.user.*;
39
import com.spice.profitmandi.dao.entity.user.*;
42
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
40
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
43
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
41
import com.spice.profitmandi.dao.entity.warehouse.WarehouseScan;
44
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
42
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
Line 48... Line 46...
48
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
46
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
49
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
47
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
50
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
48
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
51
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
49
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
52
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
50
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
-
 
51
import com.spice.profitmandi.dao.enumuration.onBorading.onBoardingFormEnums.LoiStatus;
53
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
52
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
54
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
53
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
55
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
54
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
56
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
55
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
57
import com.spice.profitmandi.dao.model.*;
56
import com.spice.profitmandi.dao.model.*;
Line 68... Line 67...
68
import com.spice.profitmandi.dao.repository.fofo.*;
67
import com.spice.profitmandi.dao.repository.fofo.*;
69
import com.spice.profitmandi.dao.repository.inventory.*;
68
import com.spice.profitmandi.dao.repository.inventory.*;
70
import com.spice.profitmandi.dao.repository.logistics.WarehouseProviderRepository;
69
import com.spice.profitmandi.dao.repository.logistics.WarehouseProviderRepository;
71
import com.spice.profitmandi.dao.repository.transaction.*;
70
import com.spice.profitmandi.dao.repository.transaction.*;
72
import com.spice.profitmandi.dao.repository.user.AddressRepository;
71
import com.spice.profitmandi.dao.repository.user.AddressRepository;
-
 
72
import com.spice.profitmandi.dao.repository.user.LoiFormRepository;
73
import com.spice.profitmandi.dao.repository.user.UserRepository;
73
import com.spice.profitmandi.dao.repository.user.UserRepository;
74
import com.spice.profitmandi.dao.repository.warehouse.*;
74
import com.spice.profitmandi.dao.repository.warehouse.*;
75
import com.spice.profitmandi.dao.service.SidbiService;
75
import com.spice.profitmandi.dao.service.SidbiService;
76
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
76
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
77
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
77
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
Line 80... Line 80...
80
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
80
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
81
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
81
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
82
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
82
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
83
import com.spice.profitmandi.service.integrations.gstpro.GstProAuthService;
83
import com.spice.profitmandi.service.integrations.gstpro.GstProAuthService;
84
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
84
import com.spice.profitmandi.service.integrations.gstpro.GstProService;
85
import com.spice.profitmandi.service.integrations.gstpro.api.model.E_InvoiceCommon;
-
 
86
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
85
import com.spice.profitmandi.service.integrations.psismart.PsiSmartService;
87
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
86
import com.spice.profitmandi.service.integrations.smartping.SmartPingService;
88
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
87
import com.spice.profitmandi.service.integrations.toffee.ToffeeService;
89
import com.spice.profitmandi.service.inventory.*;
88
import com.spice.profitmandi.service.inventory.*;
90
import com.spice.profitmandi.service.offers.OfferService;
89
import com.spice.profitmandi.service.offers.OfferService;
Line 98... Line 97...
98
import com.spice.profitmandi.service.transaction.CreditNoteService;
97
import com.spice.profitmandi.service.transaction.CreditNoteService;
99
import com.spice.profitmandi.service.transaction.SDCreditService;
98
import com.spice.profitmandi.service.transaction.SDCreditService;
100
import com.spice.profitmandi.service.transaction.TransactionService;
99
import com.spice.profitmandi.service.transaction.TransactionService;
101
import com.spice.profitmandi.service.transaction.invoicing.InvoiceService;
100
import com.spice.profitmandi.service.transaction.invoicing.InvoiceService;
102
import com.spice.profitmandi.service.user.RetailerService;
101
import com.spice.profitmandi.service.user.RetailerService;
-
 
102
import com.spice.profitmandi.service.user.StoreTimelineTatService;
103
import com.spice.profitmandi.service.wallet.CommonPaymentService;
103
import com.spice.profitmandi.service.wallet.CommonPaymentService;
104
import com.spice.profitmandi.service.wallet.WalletService;
104
import com.spice.profitmandi.service.wallet.WalletService;
105
import com.spice.profitmandi.service.warehouse.PurchaseOrderService;
105
import com.spice.profitmandi.service.warehouse.PurchaseOrderService;
106
import com.spice.profitmandi.service.warehouse.WarehouseInventoryService;
106
import com.spice.profitmandi.service.warehouse.WarehouseInventoryService;
107
import com.spice.profitmandi.service.warehouse.WarehouseService;
107
import com.spice.profitmandi.service.warehouse.WarehouseService;
108
import in.shop2020.model.v1.order.OrderStatus;
108
import in.shop2020.model.v1.order.OrderStatus;
109
import in.shop2020.model.v1.order.WalletReferenceType;
109
import in.shop2020.model.v1.order.WalletReferenceType;
110
import org.apache.commons.io.output.ByteArrayOutputStream;
110
import org.apache.commons.io.output.ByteArrayOutputStream;
111
import org.apache.commons.lang.StringUtils;
111
import org.apache.commons.lang.StringUtils;
112
import org.apache.commons.lang3.tuple.Pair;
-
 
113
import org.apache.http.client.methods.CloseableHttpResponse;
112
import org.apache.http.client.methods.CloseableHttpResponse;
114
import org.apache.http.client.methods.HttpPost;
113
import org.apache.http.client.methods.HttpPost;
115
import org.apache.http.conn.HttpHostConnectException;
114
import org.apache.http.conn.HttpHostConnectException;
116
import org.apache.http.entity.StringEntity;
115
import org.apache.http.entity.StringEntity;
117
import org.apache.http.impl.client.CloseableHttpClient;
116
import org.apache.http.impl.client.CloseableHttpClient;
Line 1058... Line 1057...
1058
    @Autowired
1057
    @Autowired
1059
    GstProService gstProService;
1058
    GstProService gstProService;
1060
 
1059
 
1061
    @Autowired
1060
    @Autowired
1062
    WarehouseProviderRepository warehouseProviderRepository;
1061
    WarehouseProviderRepository warehouseProviderRepository;
1063
    public void test() throws Exception {
-
 
1064
        //runOnceTasks.migratePurchaseFix();
-
 
1065
        //sdCreditService.fundWallet(175139079);
-
 
1066
        //runOnceTasks.migratePurchase();
-
 
1067
        //this.persistRbmTodayTargets();
-
 
1068
        //this.persistRbmTodayAchievements();
-
 
1069
        //Should return 22792
-
 
1070
 
-
 
1071
        //sdCreditService.createLoan(175139262,76000,0,"Amount added for loan adjustment");
-
 
1072
        //this.checkfocusedModelInPartnerStock();
-
 
1073
       // List<SDCreditRequirement> sdCreditRequirements = sdCreditRequirementRepository.selectAll();
-
 
1074
        /*for (SDCreditRequirement sdCreditRequirement : sdCreditRequirements) {
-
 
1075
            long utilizationAmount = sdCreditService.getUtilizationAmount(sdCreditRequirement.getFofoId());
-
 
1076
            if (Math.abs(sdCreditRequirement.getUtilizedAmount().doubleValue() - utilizationAmount) > 5) {
-
 
1077
                sdCreditRequirement.setUtilizedAmount(BigDecimal.valueOf(utilizationAmount));
-
 
1078
            }
-
 
1079
 
1062
 
1080
        }*/
1063
    @Autowired
1081
        //warehouseProviderRepository.selectAllByWarehouseId(1);
1064
    LoiFormRepository loiFormRepository;
1082
        /*String sellerGstin = GstProService.SANDBOX_GST_NUMBER;
-
 
1083
        E_InvoiceCommon.RespAuthPl respAuthPl = gstProAuthService.getAuthToken(sellerGstin);
-
 
1084
        if (LocalDateTime.now().isAfter(respAuthPl.getData().TokenExpiry)) {
-
 
1085
            redisFortnightlyCacheManage.getCache("gstAuthToken").evict(sellerGstin);
-
 
1086
            respAuthPl = gstProAuthService.getAuthToken(sellerGstin);
-
 
1087
        }
1065
    @Autowired
1088
        Map<String, String> authMap = gstProAuthService.getAuthHeaders(sellerGstin);
1066
    PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
1089
        String authToken = respAuthPl.getData().getAuthToken();
-
 
1090
        authMap.put("AuthToken", authToken);
-
 
1091
        authMap.put("QrCodeSize", "250");
1067
    @Autowired
1092
        authMap.put("ParseIrnResp", "1");
-
 
1093
        authMap.put("Content-Type", "application/json; charset=utf-8");
-
 
1094
        authMap.put("AuthToken", authToken);
1068
    StoreTimelineTatService storeTimelineTatService;
1095
        authMap.put("QrCodeSize", "250");
1069
    @Autowired
1096
        authMap.put("ParseIrnResp", "1");
1070
    PartnerDealerRepository partnerDealerRepository;
1097
        authMap.put("Content-Type", "application/json; charset=utf-8");
-
 
1098
 
-
 
1099
        System.out.println(gstProService.getEInvoiceByIrn(authMap, "5d95f5759fdfe48aeb86a7605727f37fc472d779a0f7bfbff98669e06dfd5ab2"));*/
-
 
1100
 
1071
 
1101
        //List<Loan> loans = loanRepository.selectAllLoan();
1072
    public void test() throws Exception {
1102
 
-
 
1103
        /*System.out.println(ageingService.getAllAgeingForWarehouseBilling(8718, Arrays.asList(34354)));
1073
        System.out.println("test start");
1104
        System.out.println(ageingService.getAllAgeingForWarehouseBilling(8646, Arrays.asList(36323)));
1074
//        csService.getPartnerIdSalesHeaders();
1105
        System.out.println(ageingService.getAllAgeingForWarehouseBilling(8954, Arrays.asList(34358)));*/
1075
        System.out.println("test end");
1106
        //System.out.println(ageingService.getAgeingForWarehouseBilling(8718, Arrays.asList(new ItemIdQuantity(34354,10))));
-
 
1107
    }
1076
    }
1108
 
1077
 
1109
    public void test4() throws Exception {
1078
    public void test4() throws Exception {
1110
        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);
1079
        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);
1111
        for (Integer offerId : offerIds) {
1080
        for (Integer offerId : offerIds) {
1112
            Offer fromOffer = offerRepository.selectById(offerId);
1081
            Offer fromOffer = offerRepository.selectById(offerId);
1113
            CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(fromOffer);
1082
            CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(fromOffer);
1114
            System.out.println("Processing offer Id " + fromOffer);
1083
            System.out.println("Processing offer Id " + fromOffer);
1115
            offerService.processActivationtOffer(createOfferRequest);
1084
            offerService.processActivationtOffer(createOfferRequest);
1116
        }
1085
        }
1117
        //sdCreditService.checkLoans();
-
 
1118
        /*System.out.println(warehouseService.moveToBad(Arrays.asList("860374066889716",
-
 
1119
                "863587077946699",
-
 
1120
                "865883067303639",
-
 
1121
                "868116066180113",
-
 
1122
                "868116066179719")));*/
-
 
1123
        /*System.out.println(warehouseService.moveToGood(Arrays.asList("354814720314877",
-
 
1124
                "43356/c21100001116",
-
 
1125
                "34850/c21100054629")));*/
-
 
1126
        //this.test1();
-
 
1127
        this.processSidbiDeductions();
-
 
1128
        /*List<Order> orders = orderRepository.selectByInvoiceNumber("NSDL43328");
-
 
1129
        invoiceService.saveInvoice(orders);*/
-
 
1130
        /*for ( int fofoId : Arrays.asList(4149607,175138674,175138854,175138934,175138958,175139138,175139150,175139245,175139259,175139306,175139324,175139344,175139346,175139362,175139386,175139395,175139412,175139452,175139455,175139460,175139462,175139463,175139488,175139489,175139499,175139504,175139508,175139511,175139513,175139521,175139524,175139531,175139532,175139557,175139559,175139576,175139603,175139605,175139608,175139612,175139621,175139630,175139638,175139657,175139661,175139690,175139697,175139716,175139731)) {
-
 
1131
            try {
-
 
1132
                sdCreditService.fundWallet(fofoId);
-
 
1133
            } catch (ProfitMandiBusinessException pbse) {
-
 
1134
                LOGGER.info("Failed to fund wallet for - {}", fofoId);
-
 
1135
            }
-
 
1136
        }*/
-
 
1137
 
1086
 
1138
        //transactionService.moveOrdersFulfimentWarehouseByBillingWarehouseId(7573);
1087
        this.processSidbiDeductions();
1139
    }
1088
    }
1140
 
1089
 
1141
    public void test3() throws Exception {
1090
    public void test3() throws Exception {
1142
        List<Long> payoutIds = Arrays.asList();
1091
        List<Long> payoutIds = Arrays.asList();
1143
        List<OfferPayout> offerPayouts = offerPayoutRepository.selectAllByIds(payoutIds);
1092
        List<OfferPayout> offerPayouts = offerPayoutRepository.selectAllByIds(payoutIds);
Line 1664... Line 1613...
1664
        }
1613
        }
1665
        return partnerIdSalesHeadersMap;
1614
        return partnerIdSalesHeadersMap;
1666
 
1615
 
1667
    }
1616
    }
1668
 
1617
 
1669
    public void persistRbmTodayTargets() throws Exception{
1618
    public void persistRbmTodayTargets() throws Exception {
1670
        rbmTargetService.setMovementWiseRbmTargets();
1619
        rbmTargetService.setMovementWiseRbmTargets();
1671
    }
1620
    }
1672
 
1621
 
1673
    public void persistRbmTodayAchievements() throws Exception{
1622
    public void persistRbmTodayAchievements() throws Exception {
1674
        rbmTargetService.setMovementWiseRbmAchievement();
1623
        rbmTargetService.setMovementWiseRbmAchievement();
1675
    }
1624
    }
1676
 
1625
 
1677
    public void sendPartnerInvestmentDetails() throws Exception {
1626
    public void sendPartnerInvestmentDetails() throws Exception {
1678
        this.sendPartnerInvestmentDetails(null);
1627
        this.sendPartnerInvestmentDetails(null);
Line 2628... Line 2577...
2628
                    httpPost.setHeader("Content-Type", "application/json");
2577
                    httpPost.setHeader("Content-Type", "application/json");
2629
 
2578
 
2630
                    StringEntity entity = new StringEntity(payload.toString());
2579
                    StringEntity entity = new StringEntity(payload.toString());
2631
                    httpPost.setEntity(entity);
2580
                    httpPost.setEntity(entity);
2632
                    CloseableHttpResponse response = client.execute(httpPost);
2581
                    CloseableHttpResponse response = client.execute(httpPost);
2633
                    LOGGER.info("google FCM status code: {}",response.getStatusLine().getStatusCode());
2582
                    LOGGER.info("google FCM status code: {}", response.getStatusLine().getStatusCode());
2634
                    String responseBody = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))
2583
                    String responseBody = new BufferedReader(new InputStreamReader(response.getEntity().getContent()))
2635
                            .lines().collect(Collectors.joining("\n"));
2584
                            .lines().collect(Collectors.joining("\n"));
2636
                    if (response.getStatusLine().getStatusCode() == 200) {
2585
                    if (response.getStatusLine().getStatusCode() == 200) {
2637
                        pushNotification.setSentTimestamp(LocalDateTime.now());
2586
                        pushNotification.setSentTimestamp(LocalDateTime.now());
2638
                    } else {
2587
                    } else {
Line 2867... Line 2816...
2867
                fm.setPendingIndentQty(processingQty);
2816
                fm.setPendingIndentQty(processingQty);
2868
                fm.setShortageQty(shortageQty);
2817
                fm.setShortageQty(shortageQty);
2869
                fm.setPoAvailability(allColorPoAvailability);
2818
                fm.setPoAvailability(allColorPoAvailability);
2870
                fm.setDp(tagListing.getSellingPrice());
2819
                fm.setDp(tagListing.getSellingPrice());
2871
                fm.setWarehouseName(warehouseMap.get(customRetailer.getWarehouseId()));
2820
                fm.setWarehouseName(warehouseMap.get(customRetailer.getWarehouseId()));
2872
                if(partnerIdSalesHeadersMap.get(fofoId) != null){
2821
                if (partnerIdSalesHeadersMap.get(fofoId) != null) {
2873
                    fm.setStateManager(partnerIdSalesHeadersMap.get(fofoId).getRegionalManager());
2822
                    fm.setStateManager(partnerIdSalesHeadersMap.get(fofoId).getRegionalManager());
2874
                    fm.setTerritoryManager(partnerIdSalesHeadersMap.get(fofoId).getTerritoryManager());
2823
                    fm.setTerritoryManager(partnerIdSalesHeadersMap.get(fofoId).getTerritoryManager());
2875
                }else {
2824
                } else {
2876
                    LOGGER.info("else fofoId - {}",fofoId);
2825
                    LOGGER.info("else fofoId - {}", fofoId);
2877
                    fm.setStateManager("");
2826
                    fm.setStateManager("");
2878
                    fm.setTerritoryManager("");
2827
                    fm.setTerritoryManager("");
2879
                }
2828
                }
2880
 
2829
 
2881
                fm.setItemName(items.get(0).getBrand() + items.get(0).getModelNumber() + items.get(0).getModelName());
2830
                fm.setItemName(items.get(0).getBrand() + items.get(0).getModelNumber() + items.get(0).getModelName());
Line 2883... Line 2832...
2883
 
2832
 
2884
                focusedModelShortageList.add(fm);
2833
                focusedModelShortageList.add(fm);
2885
            }
2834
            }
2886
 
2835
 
2887
        }
2836
        }
2888
        LOGGER.info("focusedModelShortageReportMap {}",focusedModelShortageReportMap);
2837
        LOGGER.info("focusedModelShortageReportMap {}", focusedModelShortageReportMap);
2889
        if (!focusedModelShortageReportMap.isEmpty()) {
2838
        if (!focusedModelShortageReportMap.isEmpty()) {
2890
            String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2839
            String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2891
            Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2840
            Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2892
            Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2841
            Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2893
 
2842
 
Line 2916... Line 2865...
2916
                } catch (Exception e2) {
2865
                } catch (Exception e2) {
2917
                    e2.printStackTrace();
2866
                    e2.printStackTrace();
2918
                }
2867
                }
2919
                String[] sendToArray = new String[]{
2868
                String[] sendToArray = new String[]{
2920
 
2869
 
2921
                        entry.getKey(), "alok.divedi@smartdukaan.com","ranu.rajput@smartdukaan.com"
2870
                        entry.getKey(), "alok.divedi@smartdukaan.com", "ranu.rajput@smartdukaan.com"
2922
 
2871
 
2923
                };
2872
                };
2924
 
2873
 
2925
 
2874
 
2926
                try {
2875
                try {
Line 3757... Line 3706...
3757
 
3706
 
3758
    public void loanSettlement() throws Exception {
3707
    public void loanSettlement() throws Exception {
3759
        List<Loan> blockedLoans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() >= 365).collect(toList());
3708
        List<Loan> blockedLoans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() >= 365).collect(toList());
3760
        List<Loan> loans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() < 365).collect(toList());
3709
        List<Loan> loans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() < 365).collect(toList());
3761
        //Settle blocked loans only when normal loans are settled
3710
        //Settle blocked loans only when normal loans are settled
3762
            loans.addAll(blockedLoans);
3711
        loans.addAll(blockedLoans);
3763
            //TODO:Remove this code
3712
        //TODO:Remove this code
3764
            Loan specificLoan = loanRepository.selectByLoanId(20073);
3713
        Loan specificLoan = loanRepository.selectByLoanId(20073);
3765
            loans.add(0, specificLoan);
3714
        loans.add(0, specificLoan);
3766
            //TODO:Upto here
3715
        //TODO:Upto here
3767
            if (!loans.isEmpty()) {
3716
        if (!loans.isEmpty()) {
3768
 
-
 
3769
                for (Loan loan : loans) {
-
 
3770
                    double settledAmount = sdCreditService.settleLoan(loan);
-
 
3771
 
-
 
3772
                    List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectHoldSanctionByFofoId(loan.getFofoId());
-
 
3773
                    for (SanctionRequest sanctionRequest : sanctionRequests) {
-
 
3774
 
-
 
3775
                        List<Order> orders = orderRepository.selectAllByTransactionId(sanctionRequest.getTransactionId());
-
 
3776
                        if (orders.size() == 0) {
-
 
3777
                            LOGGER.info("Could not find orders - for Sanction Request {}", sanctionRequest);
-
 
3778
                            continue;
-
 
3779
                        }
-
 
3780
 
3717
 
3781
                        if (settledAmount >= sanctionRequest.getPendingAmount().doubleValue()) {
-
 
3782
                            settledAmount -= sanctionRequest.getPendingAmount().doubleValue();
-
 
3783
                            sanctionRequest.setPendingAmount(BigDecimal.valueOf(0));
-
 
3784
                            this.sendUnholdEmail(orders);
-
 
3785
                        } else {
3718
            for (Loan loan : loans) {
3786
                            double pendinAmount = sanctionRequest.getPendingAmount().doubleValue() - settledAmount;
-
 
3787
                            System.out.println("Pending Amount - " + pendinAmount);
3719
                double settledAmount = sdCreditService.settleLoan(loan);
3788
                            sanctionRequest.setPendingAmount(BigDecimal.valueOf(pendinAmount));
-
 
3789
                            break;
-
 
3790
 
3720
 
-
 
3721
                List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectHoldSanctionByFofoId(loan.getFofoId());
-
 
3722
                for (SanctionRequest sanctionRequest : sanctionRequests) {
-
 
3723
 
-
 
3724
                    List<Order> orders = orderRepository.selectAllByTransactionId(sanctionRequest.getTransactionId());
-
 
3725
                    if (orders.size() == 0) {
-
 
3726
                        LOGGER.info("Could not find orders - for Sanction Request {}", sanctionRequest);
-
 
3727
                        continue;
3791
                        }
3728
                    }
-
 
3729
 
-
 
3730
                    if (settledAmount >= sanctionRequest.getPendingAmount().doubleValue()) {
-
 
3731
                        settledAmount -= sanctionRequest.getPendingAmount().doubleValue();
-
 
3732
                        sanctionRequest.setPendingAmount(BigDecimal.valueOf(0));
-
 
3733
                        this.sendUnholdEmail(orders);
-
 
3734
                    } else {
-
 
3735
                        double pendinAmount = sanctionRequest.getPendingAmount().doubleValue() - settledAmount;
-
 
3736
                        System.out.println("Pending Amount - " + pendinAmount);
-
 
3737
                        sanctionRequest.setPendingAmount(BigDecimal.valueOf(pendinAmount));
-
 
3738
                        break;
3792
 
3739
 
3793
                    }
3740
                    }
3794
                }
-
 
3795
 
3741
 
-
 
3742
                }
3796
            }
3743
            }
3797
 
3744
 
-
 
3745
        }
3798
 
3746
 
3799
 
3747
 
3800
    }
3748
    }
3801
 
3749
 
3802
 
3750
 
Line 3998... Line 3946...
3998
 
3946
 
3999
            }
3947
            }
4000
 
3948
 
4001
        }
3949
        }
4002
        String messageText = this.getMessageForDueDateExtend(defaultLoans);
3950
        String messageText = this.getMessageForDueDateExtend(defaultLoans);
4003
        this.sendMailOfHtmlFormat(googleMailSender, new String[]{"puneet.wahi@smartdukaan.com","rahul.latwal@smartdukaan.com"}, messageText, null, subject);
3951
        this.sendMailOfHtmlFormat(googleMailSender, new String[]{"puneet.wahi@smartdukaan.com", "rahul.latwal@smartdukaan.com"}, messageText, null, subject);
4004
 
3952
 
4005
        for (Loan defaultLoan : defaultLoans) {
3953
        for (Loan defaultLoan : defaultLoans) {
4006
            List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
3954
            List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
4007
 
3955
 
4008
            double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
3956
            double amount = loanStatements.stream().map(x -> x.getAmount()).collect(Collectors.summingDouble(x -> x.doubleValue()));
Line 5107... Line 5055...
5107
 
5055
 
5108
                // Check if an entry already exists in the FofoOpeningStock table
5056
                // Check if an entry already exists in the FofoOpeningStock table
5109
                FofoOpeningStock existingStock = fofoOpeningStockRepository.findByFofoIdAndCatalogId(fofoId, catalogId);
5057
                FofoOpeningStock existingStock = fofoOpeningStockRepository.findByFofoIdAndCatalogId(fofoId, catalogId);
5110
 
5058
 
5111
                if (existingStock != null) {
5059
                if (existingStock != null) {
5112
 
-
 
-
 
5060
                    if(stockQty < 1 && existingStock.getOpeningDate().isBefore(LocalDate.now().minusDays(7))){
-
 
5061
                        fofoOpeningStockRepository.delete(existingStock);
-
 
5062
                    }
5113
                    if (existingStock.getOpeningQty() < stockQty) {
5063
                    if (existingStock.getOpeningQty() < stockQty) {
5114
                        existingStock.setOpeningQty(stockQty);
5064
                        existingStock.setOpeningQty(stockQty);
5115
                        existingStock.setCurrentQty(stockQty);
5065
                        existingStock.setCurrentQty(stockQty);
5116
                        existingStock.setOpeningDate(openingDate);
5066
                        existingStock.setOpeningDate(openingDate);
5117
                        LOGGER.info("if condition exist {}");
5067
                        LOGGER.info("if condition exist {}");
5118
                    }else if(existingStock.getCurrentQty() >= existingStock.getOpeningQty()){
5068
                    } else if (existingStock.getCurrentQty() >= existingStock.getOpeningQty()) {
5119
                            existingStock.setOpeningQty(existingStock.getCurrentQty());
5069
                        existingStock.setOpeningQty(existingStock.getCurrentQty());
5120
                            existingStock.setOpeningDate(LocalDate.now());
5070
                        existingStock.setOpeningDate(LocalDate.now());
5121
                    } else if (existingStock.getOpeningDate().isBefore(LocalDate.now().minusDays(7))) {
5071
                    } else if (existingStock.getOpeningDate().isBefore(LocalDate.now().minusDays(7))) {
5122
                        int averageQty = Math.round((existingStock.getCurrentQty() + existingStock.getOpeningQty()) / 2.0f);
5072
                        int averageQty = Math.round((existingStock.getCurrentQty() + existingStock.getOpeningQty()) / 2.0f);
5123
 
5073
 
5124
                        if (averageQty == 1 && existingStock.getOpeningQty() == 1 && existingStock.getCurrentQty() == 0) {
5074
                        if (averageQty == 1 && existingStock.getOpeningQty() == 1 && existingStock.getCurrentQty() == 0) {
5125
                            // Delete the existing stock entry from the table
5075
                            // Delete the existing stock entry from the table