Subversion Repositories SmartDukaan

Rev

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

Rev 36197 Rev 36220
Line 852... Line 852...
852
    public void resendCNReport(YearMonth yearMonth) throws Exception {
852
    public void resendCNReport(YearMonth yearMonth) throws Exception {
853
        LOGGER.info("Running ResendCNReport for {}", yearMonth.toString());
853
        LOGGER.info("Running ResendCNReport for {}", yearMonth.toString());
854
        creditNoteService.resendCNReport(yearMonth);
854
        creditNoteService.resendCNReport(yearMonth);
855
    }
855
    }
856
 
856
 
-
 
857
    public void genDNs(YearMonth yearMonth) throws Exception {
-
 
858
        LOGGER.info("Running genDNs for {}", yearMonth.toString());
-
 
859
        creditNoteService.generateDebitNotesForCancelled(yearMonth);
-
 
860
    }
-
 
861
 
857
    @Autowired
862
    @Autowired
858
    BrandAgeingLimitRepository brandAgeingLimitRepository;
863
    BrandAgeingLimitRepository brandAgeingLimitRepository;
859
 
864
 
860
    @Autowired
865
    @Autowired
861
    AgeingService ageingService;
866
    AgeingService ageingService;
Line 3766... Line 3771...
3766
    @Autowired
3771
    @Autowired
3767
    private SanctionRequestRepository sanctionRequestRepository;
3772
    private SanctionRequestRepository sanctionRequestRepository;
3768
 
3773
 
3769
    public void calculateInterestAccured() throws ProfitMandiBusinessException {
3774
    public void calculateInterestAccured() throws ProfitMandiBusinessException {
3770
        List<Loan> loans = loanRepository.selectAllActiveLoan();
3775
        List<Loan> loans = loanRepository.selectAllActiveLoan();
3771
        //List<Loan> loans = Arrays.asList(loanRepository.selectByLoanId(52669));
-
 
3772
 
3776
 
3773
        for (Loan loan : loans) {
3777
        for (Loan loan : loans) {
3774
            List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
3778
            List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
3775
            Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream().collect(groupingBy(
3779
            Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream().collect(groupingBy(
3776
                    x -> x.getLoanReferenceType(), Collectors.summingDouble(x -> x.getAmount().doubleValue())));
3780
                    x -> x.getLoanReferenceType(), Collectors.summingDouble(x -> x.getAmount().doubleValue())));
3777
 
3781
 
-
 
3782
            // Interest starts from this date (inclusive). Under current policy (MIN_FREE_DAYS=1),
3778
            int freeDays = loan.getFreeDays();
3783
            // this is at minimum createdOn + 1 — billing day is always free.
3779
 
-
 
3780
            LocalDate freeDaysLimitDate = loan.getCreatedOn().plusDays(freeDays).toLocalDate();
3784
            LocalDate interestStartDate = com.spice.profitmandi.service.transaction.SDCreditServiceImpl.computeInterestStartDate(loan);
3781
 
3785
 
3782
            LOGGER.info("Loan id - {}, freeDaysLimitDate {}", loan.getId(), freeDaysLimitDate);
3786
            LOGGER.info("Loan id - {}, interestStartDate {}", loan.getId(), interestStartDate);
3783
            if (LocalDate.now().isAfter(freeDaysLimitDate)) {
3787
            if (!LocalDate.now().isBefore(interestStartDate)) {
3784
                int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(), loan.getId());
3788
                int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(), loan.getId());
3785
                LOGGER.info("loanStatementId {}", loanStatementId);
3789
                LOGGER.info("loanStatementId {}", loanStatementId);
3786
                if (loanStatementId != 0) {
3790
                if (loanStatementId != 0) {
3787
                    this.calculateInterest(loan, loanStatusAmount, loanStatementId);
3791
                    this.calculateInterest(loan, loanStatusAmount, loanStatementId);
3788
                } else {
3792
                } else {
3789
                    sdCreditService.addInterest(freeDaysLimitDate, LocalDate.now(), loan, loanStatusAmount);
3793
                    sdCreditService.addInterest(interestStartDate, LocalDate.now(), loan, loanStatusAmount);
3790
                }
3794
                }
3791
            }
3795
            }
3792
        }
3796
        }
3793
    }
3797
    }
3794
 
3798