Subversion Repositories SmartDukaan

Rev

Rev 33365 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 33365 Rev 34396
Line 1... Line 1...
1
package com.spice.profitmandi.dao.service;
1
package com.spice.profitmandi.dao.service;
2
 
2
 
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
-
 
4
import com.spice.profitmandi.common.model.ProfitMandiConstants;
4
import com.spice.profitmandi.common.util.Utils;
5
import com.spice.profitmandi.common.util.Utils;
5
import com.spice.profitmandi.dao.entity.transaction.FofoSidbiSanction;
6
import com.spice.profitmandi.dao.entity.transaction.FofoSidbiSanction;
6
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
7
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
7
import com.spice.profitmandi.dao.repository.transaction.FofoSidbiSanctionRepository;
8
import com.spice.profitmandi.dao.repository.transaction.FofoSidbiSanctionRepository;
8
import com.spice.profitmandi.service.transaction.SDCreditService;
9
import com.spice.profitmandi.service.transaction.SDCreditService;
Line 28... Line 29...
28
    FofoSidbiSanctionRepository fofoSidbiSanctionRepository;
29
    FofoSidbiSanctionRepository fofoSidbiSanctionRepository;
29
 
30
 
30
    @Autowired
31
    @Autowired
31
    CreditAccountRepository creditAccountRepository;
32
    CreditAccountRepository creditAccountRepository;
32
 
33
 
33
    private static final double ONE_LAC = 100000d;
-
 
34
 
-
 
35
    private static final double PROCESSING_FEE = 1.18;
34
    private static final double PROCESSING_FEE = 1.18;
36
 
35
 
37
    private static final double STAMP_FEE = 200;
36
    private static final double STAMP_FEE = 200;
38
 
37
 
39
    private static final String WALLET_DEDUCTION_NARRATION = "SIDBI Processing Fee @1% + GST@18% + STAMP DUTY(Rs.200)";
38
    private static final String WALLET_DEDUCTION_NARRATION = "SIDBI Processing Fee @1% + GST@18% + STAMP DUTY(Rs.200)";
40
 
39
 
41
    //Logic specific to Sidbi Related Sanctions
40
    //Logic specific to Sidbi Related Sanctions
42
    //Assumptions that 1Lac upto 12 months
41
    //Assumptions that 1Lac upto 12 months
43
    private static final List<Integer> PRINCIPAL_DEDUCTIONS_PER_LAC = Arrays.asList(2115, 2147, 2179, 2212, 2245, 2279, 2313, 2348, 2383, 2419, 2455, 2492);
42
    private static final List<Integer> PRINCIPAL_DEDUCTIONS_PER_LAC = Arrays.asList(2115, 2147, 2179, 2212, 2245, 2279, 2313, 2348, 2383, 2419, 2455, 2492, 2529, 2567, 2605, 2644, 2683, 2723, 2763, 2804, 2845, 2887, 2929, 2972);
44
    private static final int CUTOFF_DATE = 10;
43
    private static final int CUTOFF_DATE = 10;
45
 
44
 
46
    public Map<Integer, BigDecimal> getSuggestedLimitMap() {
45
    public Map<Integer, BigDecimal> getSuggestedLimitMap() {
47
        Map<Integer, BigDecimal> fofoSuggetedLimitMap = new HashMap<>();
46
        Map<Integer, BigDecimal> fofoSuggetedLimitMap = new HashMap<>();
48
        List<FofoSidbiSanction> fofoSidbiSanctions = fofoSidbiSanctionRepository.selectAllUnsettled();
47
        List<FofoSidbiSanction> fofoSidbiSanctions = fofoSidbiSanctionRepository.selectAllUnsettled();
Line 56... Line 55...
56
        LOGGER.info("GetSuggestedLimitMap - {}", fofoSuggetedLimitMap);
55
        LOGGER.info("GetSuggestedLimitMap - {}", fofoSuggetedLimitMap);
57
        return fofoSuggetedLimitMap;
56
        return fofoSuggetedLimitMap;
58
    }
57
    }
59
 
58
 
60
    private double getActualLoan(double receivedAmount) {
59
    private double getActualLoan(double receivedAmount) {
61
        double number = Math.ceil(receivedAmount / ONE_LAC);
60
        double number = Math.ceil(receivedAmount / ProfitMandiConstants.ONE_LAC);
62
        return number * ONE_LAC;
61
        return number * ProfitMandiConstants.ONE_LAC;
63
    }
62
    }
64
 
63
 
65
    private double getProcessingDeductions(FofoSidbiSanction fofoSidbiSanction) {
64
    private double getProcessingDeductions(FofoSidbiSanction fofoSidbiSanction) {
66
        double processingDeductions = (fofoSidbiSanction.getLoanAmount() * PROCESSING_FEE / 100) + STAMP_FEE;
65
        double processingDeductions = (fofoSidbiSanction.getLoanAmount() * PROCESSING_FEE / 100) + STAMP_FEE;
67
        System.out.println("Processing deductions  " + processingDeductions);
66
        System.out.println("Processing deductions  " + processingDeductions);
Line 84... Line 83...
84
        if (LocalDate.now().getDayOfMonth() < 5) {
83
        if (LocalDate.now().getDayOfMonth() < 5) {
85
            monthsBetween -= 1;
84
            monthsBetween -= 1;
86
        }
85
        }
87
        if (monthsBetween > 0) {
86
        if (monthsBetween > 0) {
88
            for (int month = 1; month <= monthsBetween; month++) {
87
            for (int month = 1; month <= monthsBetween; month++) {
89
                deduction += PRINCIPAL_DEDUCTIONS_PER_LAC.get(monthsBetween - 1) * (fofoSidbiSanction.getLoanAmount() / ONE_LAC);
88
                deduction += PRINCIPAL_DEDUCTIONS_PER_LAC.get(monthsBetween - 1) * (fofoSidbiSanction.getLoanAmount() / ProfitMandiConstants.ONE_LAC);
90
            }
89
            }
91
        }
90
        }
92
        LOGGER.info("loanStartDate-  {}, Loan Amount - {}, Deduction - {}", loanStartDate, fofoSidbiSanction.getLoanAmount(), deduction);
91
        LOGGER.info("loanStartDate-  {}, Loan Amount - {}, Deduction - {}", loanStartDate, fofoSidbiSanction.getLoanAmount(), deduction);
93
        return deduction;
92
        return deduction;
94
    }
93
    }