Subversion Repositories SmartDukaan

Rev

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

Rev 33317 Rev 33355
Line 63... Line 63...
63
import com.spice.profitmandi.dao.repository.inventory.*;
63
import com.spice.profitmandi.dao.repository.inventory.*;
64
import com.spice.profitmandi.dao.repository.transaction.*;
64
import com.spice.profitmandi.dao.repository.transaction.*;
65
import com.spice.profitmandi.dao.repository.user.AddressRepository;
65
import com.spice.profitmandi.dao.repository.user.AddressRepository;
66
import com.spice.profitmandi.dao.repository.user.UserRepository;
66
import com.spice.profitmandi.dao.repository.user.UserRepository;
67
import com.spice.profitmandi.dao.repository.warehouse.*;
67
import com.spice.profitmandi.dao.repository.warehouse.*;
-
 
68
import com.spice.profitmandi.dao.service.SidbiService;
68
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
69
import com.spice.profitmandi.dao.service.biuedart.BluedartAuthService;
69
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
70
import com.spice.profitmandi.dao.service.biuedart.BluedartService;
70
import com.spice.profitmandi.dao.service.solr.FofoSolr;
71
import com.spice.profitmandi.dao.service.solr.FofoSolr;
71
import com.spice.profitmandi.service.*;
72
import com.spice.profitmandi.service.*;
72
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
73
import com.spice.profitmandi.service.integrations.CCAvenuePaymentService;
Line 1027... Line 1028...
1027
 
1028
 
1028
    @Autowired
1029
    @Autowired
1029
    InvoiceService invoiceService;
1030
    InvoiceService invoiceService;
1030
 
1031
 
1031
    public void test() throws Exception {
1032
    public void test() throws Exception {
-
 
1033
        //this.test1();
-
 
1034
        this.processSidbiDeductions();
1032
        /*List<Order> orders = orderRepository.selectByInvoiceNumber("NSDL43328");
1035
        /*List<Order> orders = orderRepository.selectByInvoiceNumber("NSDL43328");
1033
        invoiceService.saveInvoice(orders);*/
1036
        invoiceService.saveInvoice(orders);*/
1034
        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)) {
1037
        /*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)) {
1035
            try {
1038
            try {
1036
                sdCreditService.fundWallet(fofoId);
1039
                sdCreditService.fundWallet(fofoId);
1037
            } catch (ProfitMandiBusinessException pbse) {
1040
            } catch (ProfitMandiBusinessException pbse) {
1038
                LOGGER.info("Failed to fund wallet for - {}", fofoId);
1041
                LOGGER.info("Failed to fund wallet for - {}", fofoId);
1039
            }
1042
            }
1040
        }
1043
        }*/
1041
 
1044
 
1042
        //transactionService.moveOrdersFulfimentWarehouseByBillingWarehouseId(7573);
1045
        //transactionService.moveOrdersFulfimentWarehouseByBillingWarehouseId(7573);
1043
    }
1046
    }
1044
 
1047
 
1045
    public void test3() throws Exception {
1048
    public void test3() throws Exception {
Line 1074... Line 1077...
1074
        //this.updatePartnerLimit();
1077
        //this.updatePartnerLimit();
1075
        //creditNoteService.sendCnMails(YearMonth.now().minusMonths(2));
1078
        //creditNoteService.sendCnMails(YearMonth.now().minusMonths(2));
1076
        //orderService.createMissingScratchOffers();
1079
        //orderService.createMissingScratchOffers();
1077
        LocalDateTime debitNoteDate = LocalDate.of(2024, Month.APRIL, 30).atStartOfDay();
1080
        LocalDateTime debitNoteDate = LocalDate.of(2024, Month.APRIL, 30).atStartOfDay();
1078
        Map<Integer, Set<String>> fofoIdImeiReturnMap = new LinkedHashMap<>();
1081
        Map<Integer, Set<String>> fofoIdImeiReturnMap = new LinkedHashMap<>();
1079
        fofoIdImeiReturnMap.put(175139690,	new HashSet<>(Arrays.asList("862054078463472","863862077158219","866202075810858","866202077654494","866335072023651","866518078002718")));
1082
        /*fofoIdImeiReturnMap.put(175139690,	new HashSet<>(Arrays.asList("862054078463472","863862077158219","866202075810858","866202077654494","866335072023651","866518078002718")));
1080
        fofoIdImeiReturnMap.put(175139414,	new HashSet<>(Arrays.asList("356494471684303","356494471857164","356494472062590","861753065078075","863511068904178","863511069732933","864179068109203","864179068112504","864259078789978","866202076254130","866202076254775","866657078259165","866657078272846","867492065809718","867907071107955","868565073021423","868565073022223","868565073386347")));
1083
        fofoIdImeiReturnMap.put(175139414,	new HashSet<>(Arrays.asList("356494471684303","356494471857164","356494472062590","861753065078075","863511068904178","863511069732933","864179068109203","864179068112504","864259078789978","866202076254130","866202076254775","866657078259165","866657078272846","867492065809718","867907071107955","868565073021423","868565073022223","868565073386347")));
1081
        fofoIdImeiReturnMap.put(175139603,	new HashSet<>(Arrays.asList("350886063151961","356412387787135","357594162824701","357594162874771","860600078193972","863862077025350","863862077875796","863967075815072","866335073794995","866335074287874","869116067546048")));
1084
        fofoIdImeiReturnMap.put(175139603,	new HashSet<>(Arrays.asList("350886063151961","356412387787135","357594162824701","357594162874771","860600078193972","863862077025350","863862077875796","863967075815072","866335073794995","866335074287874","869116067546048")));
1082
        fofoIdImeiReturnMap.put(175139657,	new HashSet<>(Arrays.asList("350933415734746","354324787135850","354324788766356","354990352512960","354990352580181","358142881241184","866611064207332","869116067600464")));
1085
        fofoIdImeiReturnMap.put(175139657,	new HashSet<>(Arrays.asList("350933415734746","354324787135850","354324788766356","354990352512960","354990352580181","358142881241184","866611064207332","869116067600464")));
1083
        fofoIdImeiReturnMap.put(175139223,	new HashSet<>(Arrays.asList("350210770983048","350210771169027","350210771179844","350210771180784","863975067090596","866611060326797","868565075758196","869452074016992","869452074609515","869452074609556","869452074976674","869452074978654")));
1086
        fofoIdImeiReturnMap.put(175139223,	new HashSet<>(Arrays.asList("350210770983048","350210771169027","350210771179844","350210771180784","863975067090596","866611060326797","868565075758196","869452074016992","869452074609515","869452074609556","869452074976674","869452074978654")));
1084
        fofoIdImeiReturnMap.put(175139557,	new HashSet<>(Arrays.asList("861977073551795","861977073552678","861977074486819","862046062571245","862046067278226","862046067734921","862046067756866","864468070394741","864468071225506","864468071668341","864468073604740","864468074854625","866993074734475")));
1087
        fofoIdImeiReturnMap.put(175139557,	new HashSet<>(Arrays.asList("861977073551795","861977073552678","861977074486819","862046062571245","862046067278226","862046067734921","862046067756866","864468070394741","864468071225506","864468071668341","864468073604740","864468074854625","866993074734475")));
Line 1150... Line 1153...
1150
        fofoIdImeiReturnMap.put(175139366,	new HashSet<>(Arrays.asList("354324783144864","354324788632608","354889661849990","354990353239423","863967070558271","864718076129396","866657077789543","866657078285368","866657078508066","869116060977828","869116061054429","869116061208546")));
1153
        fofoIdImeiReturnMap.put(175139366,	new HashSet<>(Arrays.asList("354324783144864","354324788632608","354889661849990","354990353239423","863967070558271","864718076129396","866657077789543","866657078285368","866657078508066","869116060977828","869116061054429","869116061208546")));
1151
        fofoIdImeiReturnMap.put(175139412,	new HashSet<>(Arrays.asList("351115165488595","351115165491318","351115165491359","351115165491458","351115165492332","355358278026573","355358278081610","861888063460717","861977073052018","863816078633919","865883069477035","866335074538870","866993071639594")));
1154
        fofoIdImeiReturnMap.put(175139412,	new HashSet<>(Arrays.asList("351115165488595","351115165491318","351115165491359","351115165491458","351115165492332","355358278026573","355358278081610","861888063460717","861977073052018","863816078633919","865883069477035","866335074538870","866993071639594")));
1152
        fofoIdImeiReturnMap.put(175139504,	new HashSet<>(Arrays.asList("862054072660792","862054075971873","862054076312374","862054077948630","863816075363171","863862075442334","864718075894230","868938062122017","868938065268932","869452071940632","869452073034897","869452073158233","869452073158498","869452074159735")));
1155
        fofoIdImeiReturnMap.put(175139504,	new HashSet<>(Arrays.asList("862054072660792","862054075971873","862054076312374","862054077948630","863816075363171","863862075442334","864718075894230","868938062122017","868938065268932","869452071940632","869452073034897","869452073158233","869452073158498","869452074159735")));
1153
        fofoIdImeiReturnMap.put(175139201,	new HashSet<>(Arrays.asList("863718061956671","863862075497734","863862075596915","864718076078510","864718076134834","866335070211639","866611060437032","866611061133812")));
1156
        fofoIdImeiReturnMap.put(175139201,	new HashSet<>(Arrays.asList("863718061956671","863862075497734","863862075596915","864718076078510","864718076134834","866335070211639","866611060437032","866611061133812")));
1154
        fofoIdImeiReturnMap.put(175139362,	new HashSet<>(Arrays.asList("350201087545646","350201087547048","350201087547709","350201087548764","350201087597043","350201087597167","350201087597464","350201087597787","350201087598165","350201087600789","863718062929271","865883069477191","865883069477530","866335071174133","866518078023870","866518078243072","868938061053494")));
1157
        fofoIdImeiReturnMap.put(175139362,	new HashSet<>(Arrays.asList("350201087545646","350201087547048","350201087547709","350201087548764","350201087597043","350201087597167","350201087597464","350201087597787","350201087598165","350201087600789","863718062929271","865883069477191","865883069477530","866335071174133","866518078023870","866518078243072","868938061053494")));
1155
        fofoIdImeiReturnMap.put(175139661,	new HashSet<>(Arrays.asList("860946077691031","861977074661155","862054073218855","866335070523694","867940069973476","868938062656477")));
1158
        fofoIdImeiReturnMap.put(175139661,	new HashSet<>(Arrays.asList("860946077691031","861977074661155","862054073218855","866335070523694","867940069973476","868938062656477")));*/
1156
        fofoIdImeiReturnMap.put(175139556,	new HashSet<>(Arrays.asList("863718063534013","866335072895173","866335073390810")));
1159
        fofoIdImeiReturnMap.put(175139556,	new HashSet<>(Arrays.asList("863718063534013","866335072895173","866335073390810")));
1157
        fofoIdImeiReturnMap.put(175139721,	new HashSet<>(Arrays.asList("358250294549067","865883067508138","866993072210619")));
1160
        fofoIdImeiReturnMap.put(175139721,	new HashSet<>(Arrays.asList("358250294549067","865883067508138","866993072210619")));
1158
        fofoIdImeiReturnMap.put(175139455,	new HashSet<>(Arrays.asList("358293804087913","866518078020694","866518078021650","866518078243676","866518078571936")));
1161
        /*fofoIdImeiReturnMap.put(175139455,	new HashSet<>(Arrays.asList("358293804087913","866518078020694","866518078021650","866518078243676","866518078571936")));
1159
        fofoIdImeiReturnMap.put(175138674,	new HashSet<>(Arrays.asList("351115165482275","359197386868583","862054074428875","862054077945693","862054078556879","863967070559535","863975068705671","863975068705770","864468076196124","866186064235971","866186066185117","866186066186917","866518073607370","866518079641514","868938060476456","868938060501535","868938060717990","868938062656931")));
1162
        fofoIdImeiReturnMap.put(175138674,	new HashSet<>(Arrays.asList("351115165482275","359197386868583","862054074428875","862054077945693","862054078556879","863967070559535","863975068705671","863975068705770","864468076196124","866186064235971","866186066185117","866186066186917","866518073607370","866518079641514","868938060476456","868938060501535","868938060717990","868938062656931")));
1160
        fofoIdImeiReturnMap.put(175139559,	new HashSet<>(Arrays.asList("863718069016890","863816078879256","864468075283881","866335073245436","866335073403571","866657074268327","868024065473853","868956065899993","869452070362895","869452074030274")));
1163
        fofoIdImeiReturnMap.put(175139559,	new HashSet<>(Arrays.asList("863718069016890","863816078879256","864468075283881","866335073245436","866335073403571","866657074268327","868024065473853","868956065899993","869452070362895","869452074030274")));
1161
        fofoIdImeiReturnMap.put(175139575,	new HashSet<>(Arrays.asList("354324786659199","860388067452035","861220078009919","863816078878134","863862075841154","865388070857498","867907071407116")));
1164
        fofoIdImeiReturnMap.put(175139575,	new HashSet<>(Arrays.asList("354324786659199","860388067452035","861220078009919","863816078878134","863862075841154","865388070857498","867907071407116")));
1162
        fofoIdImeiReturnMap.put(175139686,	new HashSet<>(Arrays.asList("866657078019106","866657078032869")));
1165
        fofoIdImeiReturnMap.put(175139686,	new HashSet<>(Arrays.asList("866657078019106","866657078032869")));*/
1163
 
1166
 
1164
        this.processOrdersToRebill(fofoIdImeiReturnMap, debitNoteDate);
1167
        //this.processOrdersToRebill(fofoIdImeiReturnMap, debitNoteDate);
1165
        purchaseReturnService.processReturn(fofoIdImeiReturnMap, debitNoteDate);
1168
        purchaseReturnService.fixReturns(fofoIdImeiReturnMap, debitNoteDate);
1166
 
1169
 
1167
    }
1170
    }
1168
 
1171
 
1169
 
1172
 
1170
    private void processOrdersToRebill(Map<Integer, Set<String>> fofoIdImeiReturnMap, LocalDateTime debitNoteDate) throws Exception {
1173
    private void processOrdersToRebill(Map<Integer, Set<String>> fofoIdImeiReturnMap, LocalDateTime debitNoteDate) throws Exception {
Line 3918... Line 3921...
3918
    public void processActivatedImeisForSchemes() throws ProfitMandiBusinessException {
3921
    public void processActivatedImeisForSchemes() throws ProfitMandiBusinessException {
3919
        schemeService.processActivatedImeisForSchemes();
3922
        schemeService.processActivatedImeisForSchemes();
3920
    }
3923
    }
3921
 
3924
 
3922
    @Autowired
3925
    @Autowired
-
 
3926
    SidbiService sidbiService;
-
 
3927
 
-
 
3928
    public void processSidbiDeductions() {
3923
    FofoSidbiSanctionRepository fofoSidbiSanctionRepository;
3929
        sidbiService.migrateSanctions();
-
 
3930
        sidbiService.processDeductions();
-
 
3931
    }
3924
 
3932
 
3925
    public void updatePartnerLimit() throws ProfitMandiBusinessException {
3933
    public void updatePartnerLimit() throws ProfitMandiBusinessException {
3926
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
3934
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
3927
        Map<Integer, List<FofoSidbiSanction>> fofoSidbiSanctionMap = fofoSidbiSanctionRepository.selectAllUptoBy(ProfitMandiConstants.SIDBI_TENUERE_MONTHS).stream().collect(Collectors.groupingBy(x -> x.getFofoId()));
3935
        Map<Integer, BigDecimal> fofoSidbiLimitMap = sidbiService.getSuggestedLimitMap();
3928
        Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3936
        Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3929
        Map<Integer, CreditAccount> creditAccountMap = creditAccountRepository.selectAllByGateways(Arrays.asList(Gateway.SIDBI, Gateway.SDDIRECT))
3937
        Map<Integer, CreditAccount> creditAccountMap = creditAccountRepository.selectAllByGateways(Arrays.asList(Gateway.SIDBI, Gateway.SDDIRECT))
3930
                .stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3938
                .stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3931
        Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3939
        Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3932
        for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
3940
        for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
Line 3934... Line 3942...
3934
            LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
3942
            LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
3935
 
3943
 
3936
            CreditAccount creditAccount = creditAccountMap.get(fofoId);
3944
            CreditAccount creditAccount = creditAccountMap.get(fofoId);
3937
 
3945
 
3938
            CurrentPartnerDailyInvestment currentPartnerDailyInvestment = currentPartnerDailyInvestmentMap.get(fofoId);
3946
            CurrentPartnerDailyInvestment currentPartnerDailyInvestment = currentPartnerDailyInvestmentMap.get(fofoId);
3939
            List<FofoSidbiSanction> fofoSidbiSanctions = fofoSidbiSanctionMap.get(fofoId);
-
 
3940
            BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, currentPartnerDailyInvestment, fofoSidbiSanctions);
3947
            BigDecimal suggestedAmount = this.getSuggestedAmount(creditAccount, currentPartnerDailyInvestment, fofoSidbiLimitMap.get(fofoId));
3941
            SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
3948
            SDCreditRequirement sdCreditRequirement = sdCreditRequirementMap.get(fofoId);
3942
 
3949
 
3943
            LOGGER.info("suggestedAmount {} ", suggestedAmount);
3950
            LOGGER.info("suggestedAmount {} ", suggestedAmount);
3944
 
3951
 
3945
            if (sdCreditRequirement == null) {
3952
            if (sdCreditRequirement == null) {
Line 3983... Line 3990...
3983
 
3990
 
3984
        }
3991
        }
3985
 
3992
 
3986
    }
3993
    }
3987
 
3994
 
3988
    private BigDecimal getSuggestedAmount(CreditAccount creditAccount, CurrentPartnerDailyInvestment currentPartnerDailyInvestment, List<FofoSidbiSanction> fofoSidbiSanctions) {
3995
    private BigDecimal getSuggestedAmount(CreditAccount creditAccount, CurrentPartnerDailyInvestment currentPartnerDailyInvestment, BigDecimal sidbiLimit) {
3989
        BigDecimal suggestedAmount = BigDecimal.ZERO;
3996
        BigDecimal suggestedAmount = BigDecimal.ZERO;
3990
        //1 LAC
3997
        //1 LAC
3991
        double limitValue = 100000;
3998
        double limitValue = 100000;
3992
        if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
3999
        if (creditAccount == null || creditAccount.getGateway().equals(Gateway.SDDIRECT)) {
3993
 
4000
 
Line 3995... Line 4002...
3995
                suggestedAmount = BigDecimal.valueOf(Math.min(currentPartnerDailyInvestment.getTotalInvestment() * 0.1, limitValue));
4002
                suggestedAmount = BigDecimal.valueOf(Math.min(currentPartnerDailyInvestment.getTotalInvestment() * 0.1, limitValue));
3996
            }
4003
            }
3997
            if (suggestedAmount.doubleValue() < 0) {
4004
            if (suggestedAmount.doubleValue() < 0) {
3998
                suggestedAmount = BigDecimal.ZERO;
4005
                suggestedAmount = BigDecimal.ZERO;
3999
            }
4006
            }
4000
        } else if (creditAccount.getGateway().equals(Gateway.SIDBI) && fofoSidbiSanctions != null && fofoSidbiSanctions.size() > 0) {
4007
        } else if (creditAccount.getGateway().equals(Gateway.SIDBI) && sidbiLimit != null) {
4001
            //Left
4008
            //Left
4002
            FofoSidbiSanction fofoSidbiSanction = fofoSidbiSanctions.get(0);
-
 
4003
            int monthsLeft = fofoSidbiSanction.getMonthsLeft(ProfitMandiConstants.SIDBI_TENUERE_MONTHS);
-
 
4004
            if (monthsLeft >= 0) {
4009
            suggestedAmount = sidbiLimit;
4005
                suggestedAmount = BigDecimal.valueOf(fofoSidbiSanction.getSanctionAmount() * monthsLeft / ProfitMandiConstants.SIDBI_TENUERE_MONTHS);
-
 
4006
            }
-
 
4007
        }
4010
        }
4008
        return suggestedAmount;
4011
        return suggestedAmount;
4009
    }
4012
    }
4010
 
4013
 
4011
    public void notifyDefaultLoans() throws ProfitMandiBusinessException, MessagingException, IOException {
4014
    public void notifyDefaultLoans() throws ProfitMandiBusinessException, MessagingException, IOException {