Subversion Repositories SmartDukaan

Rev

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

Rev 33112 Rev 33159
Line 1028... Line 1028...
1028
    @Autowired
1028
    @Autowired
1029
    InvoiceService invoiceService;
1029
    InvoiceService invoiceService;
1030
 
1030
 
1031
    public void test() throws Exception {
1031
    public void test() throws Exception {
1032
        //invoiceService.createInvoices(Arrays.asList("NSDLUK62", "NSDL39915", "NSDLHR24036", "NSDL39831", "NSNOI5266", "NSDL39849"));
1032
        //invoiceService.createInvoices(Arrays.asList("NSDLUK62", "NSDL39915", "NSDLHR24036", "NSDL39831", "NSNOI5266", "NSDL39849"));
1033
        vendorCatalogPricingLogRepository.selectByCatalogId(1024271, VendorCatalogPricingStatus.APPROVED).stream().filter(x -> x.getVendorId() == 341).forEach(x -> {
1033
        /*vendorCatalogPricingLogRepository.selectByCatalogId(1024271, VendorCatalogPricingStatus.APPROVED).stream().filter(x -> x.getVendorId() == 341).forEach(x -> {
1034
            System.out.println(x.getEffectedOn() + ", " + x.getTransferPrice());
1034
            System.out.println(x.getEffectedOn() + ", " + x.getTransferPrice());
1035
        });
1035
        });*/
-
 
1036
        List<AgeingSummaryModel> ageingSummaryModels = warehouseInventoryItemRepository.
-
 
1037
                findPartnerStockAgeingByBrand("Samsung", 0, 80);
-
 
1038
        System.out.println(ageingSummaryModels.size());
1036
        //this.setInventoryItemIdToPriceDropImei();
1039
        //this.setInventoryItemIdToPriceDropImei();
1037
        //fofoSolr.populateTagItems();
1040
        //fofoSolr.populateTagItems();
1038
        //System.out.println(smartPingService.getAllAgentsByEmail());
1041
        //System.out.println(smartPingService.getAllAgentsByEmail());
1039
        //System.out.println(psiSmartService.getRegistrationEndPoint("9990381569"));
1042
        //System.out.println(psiSmartService.getRegistrationEndPoint("9990381569"));
1040
        //migrateValentine();
1043
        //migrateValentine();
Line 3642... Line 3645...
3642
            for (Loan loan : loans) {
3645
            for (Loan loan : loans) {
3643
 
3646
 
3644
                UserWallet userWallet = userWalletRepository.selectByRetailerId(loan.getFofoId());
3647
                UserWallet userWallet = userWalletRepository.selectByRetailerId(loan.getFofoId());
3645
                SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(loan.getFofoId());
3648
                SDCreditRequirement sdCreditRequirement = sdCreditRequirementRepository.selectByFofoId(loan.getFofoId());
3646
 
3649
 
3647
                if (userWallet.getAmount() >= 100) {
-
 
3648
                    List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
3650
                List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
3649
 
-
 
3650
                    LOGGER.info("loanStatements {}", loanStatements);
-
 
3651
 
3651
 
3652
                    Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream().collect(groupingBy(x -> x.getLoanReferenceType(), Collectors.summingDouble(x -> FormattingUtils.serialize(x.getAmount()))));
3652
                LOGGER.info("loanStatements {}", loanStatements);
3653
 
3653
 
3654
                    LOGGER.info("loanStatusAmount {}", loanStatusAmount);
-
 
3655
                    Double interestAmount = loanStatusAmount.get(LoanReferenceType.INTEREST);
3654
                Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream().collect(groupingBy(x -> x.getLoanReferenceType(), Collectors.summingDouble(x -> FormattingUtils.serialize(x.getAmount()))));
3656
 
3655
 
3657
                    if (interestAmount == null) {
3656
                LOGGER.info("loanStatusAmount {}", loanStatusAmount);
3658
                        interestAmount = (double) 0;
3657
                Double interestAmount = loanStatusAmount.get(LoanReferenceType.INTEREST);
3659
                    }
-
 
3660
 
3658
 
-
 
3659
                if (interestAmount == null) {
-
 
3660
                    interestAmount = (double) 0;
-
 
3661
                }
3661
                    double principalAmount = loanStatusAmount.get(LoanReferenceType.PRINCIPAL);
3662
                double principalAmount = loanStatusAmount.get(LoanReferenceType.PRINCIPAL);
-
 
3663
                //if it can be settled
-
 
3664
                if (userWallet.getAmount() >= 100 || userWallet.getAmount() >= interestAmount + principalAmount) {
3662
                    double paidAmount = 0;
3665
                    double paidAmount = 0;
3663
                    if (userWallet.getAmount() > Math.abs(interestAmount)) {
3666
                    if (userWallet.getAmount() > Math.abs(interestAmount)) {
3664
 
3667
 
3665
                        LOGGER.info("interestAmount b {}", interestAmount);
3668
                        LOGGER.info("interestAmount b {}", interestAmount);
3666
 
3669
 
Line 3692... Line 3695...
3692
 
3695
 
3693
                            settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(userWalletAmount), loan.getFofoId(), loan.getId(), "Amount adjusted against loan", LocalDateTime.now());
3696
                            settledLoanStatement(LoanReferenceType.PRINCIPAL, BigDecimal.valueOf(userWalletAmount), loan.getFofoId(), loan.getId(), "Amount adjusted against loan", LocalDateTime.now());
3694
 
3697
 
3695
                            paidAmount += Math.abs(userWalletAmount);
3698
                            paidAmount += Math.abs(userWalletAmount);
3696
 
3699
 
3697
                            BigDecimal availableLimit = sdCreditRequirement.getAvailableLimit().add(BigDecimal.valueOf(userWalletAmount)).abs();
-
 
3698
 
-
 
3699
                            BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount().subtract(BigDecimal.valueOf(userWalletAmount)).abs();
3700
                            BigDecimal utilizationAmount = sdCreditRequirement.getUtilizedAmount().subtract(BigDecimal.valueOf(userWalletAmount)).abs();
3700
 
3701
 
3701
                            sdCreditRequirement.setUtilizedAmount(utilizationAmount);
3702
                            sdCreditRequirement.setUtilizedAmount(utilizationAmount);
3702
 
3703
 
3703
                            CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(loan.getFofoId(), Gateway.SDDIRECT);
3704
                            CreditAccount creditAccount = creditAccountRepository.selectByFofoIdAndGateway(loan.getFofoId(), Gateway.SDDIRECT);
Line 3868... Line 3869...
3868
 
3869
 
3869
    public void updatePartnerLimit() throws ProfitMandiBusinessException {
3870
    public void updatePartnerLimit() throws ProfitMandiBusinessException {
3870
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
3871
        Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
3871
        Map<Integer, List<FofoSidbiSanction>> fofoSidbiSanctionMap = fofoSidbiSanctionRepository.selectAllUptoBy(ProfitMandiConstants.SIDBI_TENUERE_MONTHS).stream().collect(Collectors.groupingBy(x->x.getFofoId()));
3872
        Map<Integer, List<FofoSidbiSanction>> fofoSidbiSanctionMap = fofoSidbiSanctionRepository.selectAllUptoBy(ProfitMandiConstants.SIDBI_TENUERE_MONTHS).stream().collect(Collectors.groupingBy(x->x.getFofoId()));
3872
        Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3873
        Map<Integer, SDCreditRequirement> sdCreditRequirementMap = sdCreditRequirementRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3873
        Map<Integer, CreditAccount> creditAccountMap = creditAccountRepository.selectAllByGateays(Arrays.asList(Gateway.SIDBI, Gateway.SDDIRECT))
3874
        Map<Integer, CreditAccount> creditAccountMap = creditAccountRepository.selectAllByGateways(Arrays.asList(Gateway.SIDBI, Gateway.SDDIRECT))
3874
                .stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3875
                .stream().filter(x -> x.isActive()).collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3875
        Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3876
        Map<Integer, CurrentPartnerDailyInvestment> currentPartnerDailyInvestmentMap = currentPartnerDailyInvestmentRepository.selectAll().stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
3876
        for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
3877
        for (Entry<Integer, CustomRetailer> customRetailerEntry : customRetailerMap.entrySet()) {
3877
            int fofoId = customRetailerEntry.getKey();
3878
            int fofoId = customRetailerEntry.getKey();
3878
            LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);
3879
            LocalDateTime firstBillingDate = transactionRepository.getFirstBillingDate(fofoId);