Subversion Repositories SmartDukaan

Rev

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

Rev 35864 Rev 35876
Line 1... Line 1...
1
package com.spice.profitmandi.dao.entity.transaction;
1
package com.spice.profitmandi.dao.entity.transaction;
2
 
2
 
3
import com.spice.profitmandi.dao.model.DailyStatementModel;
3
import com.spice.profitmandi.dao.model.DailyStatementModel;
4
 
4
 
-
 
5
import static com.spice.profitmandi.common.model.ProfitMandiConstants.TOTAL_CREDIT_PERIOD_DAYS;
-
 
6
 
5
import javax.persistence.*;
7
import javax.persistence.*;
6
import java.math.BigDecimal;
8
import java.math.BigDecimal;
7
import java.time.LocalDate;
9
import java.time.LocalDate;
8
import java.time.LocalDateTime;
10
import java.time.LocalDateTime;
9
import java.time.temporal.ChronoUnit;
11
import java.time.temporal.ChronoUnit;
Line 90... Line 92...
90
 
92
 
91
    public boolean isDue() {
93
    public boolean isDue() {
92
        return this.canBeSettled() && !this.getDueDate().toLocalDate().isBefore(LocalDate.now());
94
        return this.canBeSettled() && !this.getDueDate().toLocalDate().isBefore(LocalDate.now());
93
    }
95
    }
94
 
96
 
-
 
97
    public LocalDate getPenaltyDate() {
-
 
98
        return this.getCreatedOn().toLocalDate().plusDays(TOTAL_CREDIT_PERIOD_DAYS - 1);
-
 
99
    }
-
 
100
 
95
    public boolean isOverdue() {
101
    public boolean isOverdue() {
96
        return this.canBeSettled() && this.getDueDate().toLocalDate().isBefore(LocalDate.now()) &&
102
        return this.canBeSettled() && this.getDueDate().toLocalDate().isBefore(LocalDate.now()) &&
97
                !this.getDueDate().plusDays(15).toLocalDate().isBefore(LocalDate.now());
103
                !this.getPenaltyDate().isBefore(LocalDate.now());
98
    }
104
    }
99
 
105
 
100
    public boolean isDefault() {
106
    public boolean isDefault() {
101
        return canBeSettled() && this.isDefault(LocalDate.now());
107
        return canBeSettled() && this.isDefault(LocalDate.now());
102
    }
108
    }
103
 
109
 
104
    public boolean isDefault(LocalDate onDate) {
110
    public boolean isDefault(LocalDate onDate) {
105
        return this.getSettledOn() == null && this.getDueDate().plusDays(15).toLocalDate().isBefore(onDate);
111
        return this.getSettledOn() == null && this.getPenaltyDate().isBefore(onDate);
106
    }
112
    }
107
 
113
 
108
    public boolean canBeSettled() {
114
    public boolean canBeSettled() {
109
        return !this.limitBlock && this.settledOn == null && (this.getCdFreeDays() == 0 || this.getDays() > this.getCdFreeDays());
115
        return !this.limitBlock && this.settledOn == null && (this.getCdFreeDays() == 0 || this.getDays() > this.getCdFreeDays());
110
    }
116
    }