Subversion Repositories SmartDukaan

Rev

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

Rev 33859 Rev 33874
Line 46... Line 46...
46
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
46
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
47
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
47
import com.spice.profitmandi.dao.enumuration.fofo.PaymentStatus;
48
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
48
import com.spice.profitmandi.dao.enumuration.fofo.ReturnType;
49
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
49
import com.spice.profitmandi.dao.enumuration.fofo.ScanType;
50
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
50
import com.spice.profitmandi.dao.enumuration.inventory.VendorCatalogPricingStatus;
51
import com.spice.profitmandi.dao.enumuration.transaction.*;
51
import com.spice.profitmandi.dao.enumuration.transaction.CreditRisk;
-
 
52
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
-
 
53
import com.spice.profitmandi.dao.enumuration.transaction.PriceDropImeiStatus;
-
 
54
import com.spice.profitmandi.dao.enumuration.transaction.SchemePayoutStatus;
52
import com.spice.profitmandi.dao.model.*;
55
import com.spice.profitmandi.dao.model.*;
53
import com.spice.profitmandi.dao.repository.GenericRepository;
56
import com.spice.profitmandi.dao.repository.GenericRepository;
54
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
57
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
55
import com.spice.profitmandi.dao.repository.auth.NonSdBuyingRepository;
58
import com.spice.profitmandi.dao.repository.auth.NonSdBuyingRepository;
56
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
59
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
57
import com.spice.profitmandi.dao.repository.catalog.*;
60
import com.spice.profitmandi.dao.repository.catalog.*;
58
import com.spice.profitmandi.dao.repository.cs.*;
61
import com.spice.profitmandi.dao.repository.cs.CsService;
-
 
62
import com.spice.profitmandi.dao.repository.cs.PartnerRegionRepository;
-
 
63
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
-
 
64
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
59
import com.spice.profitmandi.dao.repository.dtr.*;
65
import com.spice.profitmandi.dao.repository.dtr.*;
60
import com.spice.profitmandi.dao.repository.fofo.*;
66
import com.spice.profitmandi.dao.repository.fofo.*;
61
import com.spice.profitmandi.dao.repository.inventory.*;
67
import com.spice.profitmandi.dao.repository.inventory.*;
62
import com.spice.profitmandi.dao.repository.logistics.WarehouseProviderRepository;
68
import com.spice.profitmandi.dao.repository.logistics.WarehouseProviderRepository;
63
import com.spice.profitmandi.dao.repository.transaction.*;
69
import com.spice.profitmandi.dao.repository.transaction.*;
64
import com.spice.profitmandi.dao.repository.user.AddressRepository;
70
import com.spice.profitmandi.dao.repository.user.AddressRepository;
65
import com.spice.profitmandi.dao.repository.user.LoiFormRepository;
-
 
66
import com.spice.profitmandi.dao.repository.user.UserRepository;
71
import com.spice.profitmandi.dao.repository.user.UserRepository;
67
import com.spice.profitmandi.dao.repository.warehouse.*;
72
import com.spice.profitmandi.dao.repository.warehouse.*;
68
import com.spice.profitmandi.dao.service.SidbiService;
73
import com.spice.profitmandi.dao.service.SidbiService;
69
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
74
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
70
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
75
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
71
import com.spice.profitmandi.dao.service.loiForm.LoiFormService;
-
 
72
import com.spice.profitmandi.dao.service.solr.FofoSolr;
76
import com.spice.profitmandi.dao.service.solr.FofoSolr;
73
import com.spice.profitmandi.service.*;
77
import com.spice.profitmandi.service.*;
74
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
78
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
75
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
79
import com.spice.profitmandi.service.integrations.RazorpayPaymentService;
76
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
80
import com.spice.profitmandi.service.integrations.bharti.model.BAGInsuranceModel;
Line 135... Line 139...
135
import java.math.RoundingMode;
139
import java.math.RoundingMode;
136
import java.nio.file.Files;
140
import java.nio.file.Files;
137
import java.nio.file.Paths;
141
import java.nio.file.Paths;
138
import java.sql.Timestamp;
142
import java.sql.Timestamp;
139
import java.text.DecimalFormat;
143
import java.text.DecimalFormat;
140
import java.text.NumberFormat;
-
 
141
import java.time.*;
144
import java.time.*;
142
import java.time.format.DateTimeFormatter;
145
import java.time.format.DateTimeFormatter;
143
import java.time.temporal.ChronoField;
146
import java.time.temporal.ChronoField;
144
import java.time.temporal.ChronoUnit;
147
import java.time.temporal.ChronoUnit;
145
import java.util.*;
148
import java.util.*;
Line 1038... Line 1041...
1038
    @Autowired
1041
    @Autowired
1039
    RedisCacheManager redisFortnightlyCacheManage;
1042
    RedisCacheManager redisFortnightlyCacheManage;
1040
 
1043
 
1041
    @Autowired
1044
    @Autowired
1042
    GstProAuthService gstProAuthService;
1045
    GstProAuthService gstProAuthService;
1043
    @Autowired
-
 
1044
    private MonthlyTargetRepository monthlyTargetRepository;
-
 
1045
 
1046
 
1046
    @Autowired
1047
    @Autowired
1047
    GstProService gstProService;
1048
    GstProService gstProService;
1048
 
1049
 
1049
    @Autowired
1050
    @Autowired
1050
    WarehouseProviderRepository warehouseProviderRepository;
1051
    WarehouseProviderRepository warehouseProviderRepository;
1051
    public void test() throws Exception {
1052
    public void test() throws Exception {
-
 
1053
        //sdCreditService.createLoan(175139262,76000,0,"Amount added for loan adjustment");
1052
        System.out.println("---test start----");
1054
        //this.checkfocusedModelInPartnerStock();
-
 
1055
       // List<SDCreditRequirement> sdCreditRequirements = sdCreditRequirementRepository.selectAll();
-
 
1056
        /*for (SDCreditRequirement sdCreditRequirement : sdCreditRequirements) {
-
 
1057
            long utilizationAmount = sdCreditService.getUtilizationAmount(sdCreditRequirement.getFofoId());
-
 
1058
            if (Math.abs(sdCreditRequirement.getUtilizedAmount().doubleValue() - utilizationAmount) > 5) {
-
 
1059
                sdCreditRequirement.setUtilizedAmount(BigDecimal.valueOf(utilizationAmount));
-
 
1060
            }
1053
 
1061
 
-
 
1062
        }*/
-
 
1063
        //warehouseProviderRepository.selectAllByWarehouseId(1);
-
 
1064
        /*String sellerGstin = GstProService.SANDBOX_GST_NUMBER;
-
 
1065
        E_InvoiceCommon.RespAuthPl respAuthPl = gstProAuthService.getAuthToken(sellerGstin);
-
 
1066
        if (LocalDateTime.now().isAfter(respAuthPl.getData().TokenExpiry)) {
-
 
1067
            redisFortnightlyCacheManage.getCache("gstAuthToken").evict(sellerGstin);
-
 
1068
            respAuthPl = gstProAuthService.getAuthToken(sellerGstin);
-
 
1069
        }
-
 
1070
        Map<String, String> authMap = gstProAuthService.getAuthHeaders(sellerGstin);
-
 
1071
        String authToken = respAuthPl.getData().getAuthToken();
-
 
1072
        authMap.put("AuthToken", authToken);
1054
        System.out.println("---test end ----");
1073
        authMap.put("QrCodeSize", "250");
-
 
1074
        authMap.put("ParseIrnResp", "1");
-
 
1075
        authMap.put("Content-Type", "application/json; charset=utf-8");
-
 
1076
        authMap.put("AuthToken", authToken);
-
 
1077
        authMap.put("QrCodeSize", "250");
-
 
1078
        authMap.put("ParseIrnResp", "1");
-
 
1079
        authMap.put("Content-Type", "application/json; charset=utf-8");
-
 
1080
 
-
 
1081
        System.out.println(gstProService.getEInvoiceByIrn(authMap, "5d95f5759fdfe48aeb86a7605727f37fc472d779a0f7bfbff98669e06dfd5ab2"));*/
-
 
1082
 
-
 
1083
        //List<Loan> loans = loanRepository.selectAllLoan();
-
 
1084
 
-
 
1085
        /*System.out.println(ageingService.getAllAgeingForWarehouseBilling(8718, Arrays.asList(34354)));
-
 
1086
        System.out.println(ageingService.getAllAgeingForWarehouseBilling(8646, Arrays.asList(36323)));
-
 
1087
        System.out.println(ageingService.getAllAgeingForWarehouseBilling(8954, Arrays.asList(34358)));*/
-
 
1088
        //System.out.println(ageingService.getAgeingForWarehouseBilling(8718, Arrays.asList(new ItemIdQuantity(34354,10))));
1055
    }
1089
    }
1056
 
1090
 
1057
    public void test4() throws Exception {
1091
    public void test4() throws Exception {
1058
        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);
1092
        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);
1059
        for (Integer offerId : offerIds) {
1093
        for (Integer offerId : offerIds) {
Line 2805... Line 2839...
2805
 
2839
 
2806
                focusedModelShortageList.add(fm);
2840
                focusedModelShortageList.add(fm);
2807
            }
2841
            }
2808
 
2842
 
2809
        }
2843
        }
-
 
2844
        LOGGER.info("focusedModelShortageReportMap {}",focusedModelShortageReportMap);
2810
        if (!focusedModelShortageReportMap.isEmpty()) {
2845
        if (!focusedModelShortageReportMap.isEmpty()) {
2811
            String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2846
            String fileName = "Stock Alert-" + FormattingUtils.formatDate(LocalDateTime.now()) + ".csv";
2812
            Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2847
            Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
2813
            Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2848
            Map<String, List<List<?>>> emailRowsMap = new HashMap<>();
2814
 
2849
 
Line 2837... Line 2872...
2837
                } catch (Exception e2) {
2872
                } catch (Exception e2) {
2838
                    e2.printStackTrace();
2873
                    e2.printStackTrace();
2839
                }
2874
                }
2840
                String[] sendToArray = new String[]{
2875
                String[] sendToArray = new String[]{
2841
 
2876
 
2842
                        entry.getKey(), "apurve.shrivastava@smartdukaan.com", "puneet.bisht@smartdukaan.com"
2877
                        entry.getKey(), "alok.divedi@smartdukaan.com","ranu.rajput@smartdukaan.com"
2843
 
2878
 
2844
                };
2879
                };
2845
 
2880
 
2846
 
2881
 
2847
                try {
2882
                try {
Line 3678... Line 3713...
3678
 
3713
 
3679
    public void loanSettlement() throws Exception {
3714
    public void loanSettlement() throws Exception {
3680
        List<Loan> blockedLoans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() >= 365).collect(toList());
3715
        List<Loan> blockedLoans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() >= 365).collect(toList());
3681
        List<Loan> loans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() < 365).collect(toList());
3716
        List<Loan> loans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() < 365).collect(toList());
3682
        //Settle blocked loans only when normal loans are settled
3717
        //Settle blocked loans only when normal loans are settled
3683
        loans.addAll(blockedLoans);
3718
            loans.addAll(blockedLoans);
3684
        //TODO:Remove this code
3719
            //TODO:Remove this code
3685
        Loan specificLoan = loanRepository.selectByLoanId(20073);
3720
            Loan specificLoan = loanRepository.selectByLoanId(20073);
3686
        loans.add(0, specificLoan);
3721
            loans.add(0, specificLoan);
3687
        //TODO:Upto here
3722
            //TODO:Upto here
3688
        if (!loans.isEmpty()) {
3723
            if (!loans.isEmpty()) {
3689
 
3724
 
3690
            for (Loan loan : loans) {
3725
                for (Loan loan : loans) {
3691
                double settledAmount = sdCreditService.settleLoan(loan);
3726
                    double settledAmount = sdCreditService.settleLoan(loan);
-
 
3727
 
-
 
3728
                    List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectHoldSanctionByFofoId(loan.getFofoId());
-
 
3729
                    for (SanctionRequest sanctionRequest : sanctionRequests) {
-
 
3730
 
-
 
3731
                        List<Order> orders = orderRepository.selectAllByTransactionId(sanctionRequest.getTransactionId());
-
 
3732
                        if (orders.size() == 0) {
-
 
3733
                            LOGGER.info("Could not find orders - for Sanction Request {}", sanctionRequest);
-
 
3734
                            continue;
-
 
3735
                        }
3692
 
3736
 
3693
                List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectHoldSanctionByFofoId(loan.getFofoId());
3737
                        if (settledAmount >= sanctionRequest.getPendingAmount().doubleValue()) {
-
 
3738
                            settledAmount -= sanctionRequest.getPendingAmount().doubleValue();
3694
                for (SanctionRequest sanctionRequest : sanctionRequests) {
3739
                            sanctionRequest.setPendingAmount(BigDecimal.valueOf(0));
-
 
3740
                            this.sendUnholdEmail(orders);
-
 
3741
                        } else {
-
 
3742
                            double pendinAmount = sanctionRequest.getPendingAmount().doubleValue() - settledAmount;
-
 
3743
                            System.out.println("Pending Amount - " + pendinAmount);
-
 
3744
                            sanctionRequest.setPendingAmount(BigDecimal.valueOf(pendinAmount));
-
 
3745
                            break;
3695
 
3746
 
3696
                    List<Order> orders = orderRepository.selectAllByTransactionId(sanctionRequest.getTransactionId());
-
 
3697
                    if (orders.size() == 0) {
-
 
3698
                        LOGGER.info("Could not find orders - for Sanction Request {}", sanctionRequest);
-
 
3699
                        continue;
-
 
3700
                    }
3747
                        }
3701
 
-
 
3702
                    if (settledAmount >= sanctionRequest.getPendingAmount().doubleValue()) {
-
 
3703
                        settledAmount -= sanctionRequest.getPendingAmount().doubleValue();
-
 
3704
                        sanctionRequest.setPendingAmount(BigDecimal.valueOf(0));
-
 
3705
                        this.sendUnholdEmail(orders);
-
 
3706
                    } else {
-
 
3707
                        double pendinAmount = sanctionRequest.getPendingAmount().doubleValue() - settledAmount;
-
 
3708
                        System.out.println("Pending Amount - " + pendinAmount);
-
 
3709
                        sanctionRequest.setPendingAmount(BigDecimal.valueOf(pendinAmount));
-
 
3710
                        break;
-
 
3711
 
3748
 
3712
                    }
3749
                    }
3713
 
-
 
3714
                }
3750
                }
-
 
3751
 
3715
            }
3752
            }
3716
 
3753
 
3717
        }
-
 
3718
 
3754
 
3719
 
3755
 
3720
    }
3756
    }
3721
 
3757
 
3722
 
3758
 
Line 3836... Line 3872...
3836
 
3872
 
3837
            CreditRisk creditRisk = sdCreditService.getCurrentRisk(sdCreditRequirement, firstBillingDate);
3873
            CreditRisk creditRisk = sdCreditService.getCurrentRisk(sdCreditRequirement, firstBillingDate);
3838
 
3874
 
3839
            sdCreditRequirement.setRisk(creditRisk);
3875
            sdCreditRequirement.setRisk(creditRisk);
3840
 
3876
 
3841
            if (!sdCreditRequirement.isHardLimit()) {
-
 
3842
                sdCreditRequirement.setSuggestedLimit(suggestedAmount);
3877
            sdCreditRequirement.setSuggestedLimit(suggestedAmount);
3843
                sdCreditRequirement.setLimit(suggestedAmount);
3878
            sdCreditRequirement.setLimit(suggestedAmount);
3844
            }
-
 
3845
            BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
3879
            BigDecimal utilizedLimit = new BigDecimal(sdCreditService.getUtilizationAmount(fofoId));
3846
 
3880
 
3847
            BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
3881
            BigDecimal availableLimit = sdCreditRequirement.getLimit().subtract(utilizedLimit);
3848
 
3882
 
3849
            LOGGER.info("utilizedLimit {} ", utilizedLimit);
3883
            LOGGER.info("utilizedLimit {} ", utilizedLimit);
Line 4488... Line 4522...
4488
        sb.append("</tbody></table></body></html>");
4522
        sb.append("</tbody></table></body></html>");
4489
 
4523
 
4490
        return sb.toString();
4524
        return sb.toString();
4491
    }
4525
    }
4492
 
4526
 
-
 
4527
    @Autowired
-
 
4528
    private MonthlyTargetRepository monthlyTargetRepository;
4493
 
4529
 
4494
    public void monthlyTargetForPartner() throws MessagingException, ProfitMandiBusinessException, IOException {
4530
    public void monthlyTargetForPartner() throws MessagingException, ProfitMandiBusinessException, IOException {
4495
 
4531
 
4496
        LocalDateTime curDate = LocalDateTime.now();
4532
        LocalDateTime curDate = LocalDateTime.now();
4497
        List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
4533
        List<MonthlyTarget> monthlyTargets = monthlyTargetRepository.selectByDate(YearMonth.now());
Line 5004... Line 5040...
5004
        }
5040
        }
5005
        // Return the constructed HTML message
5041
        // Return the constructed HTML message
5006
        return message;
5042
        return message;
5007
    }
5043
    }
5008
 
5044
 
-
 
5045
    @Autowired
-
 
5046
    private FofoOpeningStockRepository fofoOpeningStockRepository;
-
 
5047
 
-
 
5048
    public void createOpeningStockPartyWise() throws Exception {
-
 
5049
        // Get all partner stock data
-
 
5050
        Map<Integer, List<PartnerOpeningStockByTodayModel>> partnerOpeningStockByTodayMap = currentInventorySnapshotRepository.getAllPartnerTodayStock();
-
 
5051
 
-
 
5052
 
-
 
5053
        for (Map.Entry<Integer, List<PartnerOpeningStockByTodayModel>> entry : partnerOpeningStockByTodayMap.entrySet()) {
-
 
5054
            int fofoId = entry.getKey();
-
 
5055
            List<PartnerOpeningStockByTodayModel> partnerStockList = entry.getValue();
-
 
5056
 
-
 
5057
            for (PartnerOpeningStockByTodayModel partnerStock : partnerStockList) {
-
 
5058
                int catalogId = partnerStock.getCatalogId();
-
 
5059
                int openingQtyFromModel = partnerStock.getOpeningQty();
-
 
5060
                LocalDate openingDate = partnerStock.getOpeningDate();
-
 
5061
 
-
 
5062
                // Check if an entry already exists in the FofoOpeningStock table
-
 
5063
                FofoOpeningStock existingStock = fofoOpeningStockRepository.findByFofoIdAndCatalogId(fofoId, catalogId);
-
 
5064
 
-
 
5065
                if (existingStock != null) {
-
 
5066
 
-
 
5067
                    if (existingStock.getOpeningQty() < openingQtyFromModel) {
-
 
5068
 
-
 
5069
                        existingStock.setOpeningQty(openingQtyFromModel);
-
 
5070
                        existingStock.setCurrentQty(openingQtyFromModel);
-
 
5071
                        existingStock.setOpeningDate(openingDate);
-
 
5072
                        LOGGER.info("if condition exist {}");
-
 
5073
                    }
-
 
5074
                } else {
-
 
5075
                    LOGGER.info("else condition exist");
-
 
5076
                    FofoOpeningStock newStock = new FofoOpeningStock();
-
 
5077
                    newStock.setFofoId(fofoId);
-
 
5078
                    newStock.setCatalogId(catalogId);
-
 
5079
                    newStock.setOpeningQty(openingQtyFromModel);
-
 
5080
                    newStock.setCurrentQty(openingQtyFromModel);
-
 
5081
                    newStock.setOpeningDate(openingDate);
-
 
5082
                    fofoOpeningStockRepository.persist(newStock);
-
 
5083
 
-
 
5084
                }
-
 
5085
            }
-
 
5086
        }
-
 
5087
    }
-
 
5088
 
-
 
5089
 
5009
}
5090
}
5010
// 2284"
5091
// 2284"
5011
5092