| 30859 |
tejbeer |
1 |
package com.spice.profitmandi.dao.entity.transaction;
|
|
|
2 |
|
| 32681 |
amit.gupta |
3 |
import com.spice.profitmandi.dao.model.DailyStatementModel;
|
|
|
4 |
|
|
|
5 |
import javax.persistence.*;
|
| 30859 |
tejbeer |
6 |
import java.math.BigDecimal;
|
| 33528 |
amit.gupta |
7 |
import java.time.LocalDate;
|
| 30859 |
tejbeer |
8 |
import java.time.LocalDateTime;
|
| 33528 |
amit.gupta |
9 |
import java.time.temporal.ChronoUnit;
|
| 30859 |
tejbeer |
10 |
import java.util.List;
|
| 32681 |
amit.gupta |
11 |
import java.util.Objects;
|
| 30859 |
tejbeer |
12 |
|
|
|
13 |
@Entity
|
| 32074 |
tejbeer |
14 |
@Table(name = "transaction.loan")
|
| 33827 |
ranu |
15 |
@NamedQueries({
|
|
|
16 |
@NamedQuery(name = "Loan.getLoansCountWithFofoID", query = "select new com.spice.profitmandi.dao.model.LoanCountByFofoIdModel(" +
|
|
|
17 |
" cast(fofoId as int), count(id))" +
|
|
|
18 |
" from Loan " +
|
|
|
19 |
" where fofoId in (:fofoIds) " +
|
|
|
20 |
" group by fofoId "),
|
| 34212 |
ranu |
21 |
|
|
|
22 |
@NamedQuery(name = "Loan.findBlockedLoans", query = "SELECT l FROM Loan l WHERE l.freeDays > 364")
|
| 33827 |
ranu |
23 |
})
|
|
|
24 |
|
| 30859 |
tejbeer |
25 |
public class Loan {
|
|
|
26 |
|
|
|
27 |
@Id
|
|
|
28 |
@Column(name = "id", unique = true, updatable = false)
|
|
|
29 |
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
|
30 |
private int id;
|
|
|
31 |
|
|
|
32 |
@Column(name = "fofo_id")
|
|
|
33 |
private int fofoId;
|
|
|
34 |
|
|
|
35 |
@Column(name = "interest_rate")
|
|
|
36 |
private BigDecimal interestRate;
|
|
|
37 |
|
|
|
38 |
@Column(name = "intial_amount")
|
|
|
39 |
private BigDecimal intialAmount;
|
|
|
40 |
|
|
|
41 |
@Column(name = "pending_amount")
|
|
|
42 |
private BigDecimal pendingAmount;
|
|
|
43 |
|
|
|
44 |
@Column(name = "created_on")
|
|
|
45 |
private LocalDateTime createdOn;
|
|
|
46 |
|
| 32681 |
amit.gupta |
47 |
@Column(name = "settled_on")
|
|
|
48 |
private LocalDateTime settledOn;
|
|
|
49 |
|
| 30859 |
tejbeer |
50 |
@Column(name = "due_date")
|
|
|
51 |
private LocalDateTime dueDate;
|
|
|
52 |
|
|
|
53 |
@Column(name = "interest_accured")
|
|
|
54 |
private BigDecimal interestAccrued;
|
|
|
55 |
|
|
|
56 |
@Column(name = "interest_paid")
|
|
|
57 |
private BigDecimal interestPaid;
|
|
|
58 |
|
|
|
59 |
@Column(name = "free_days")
|
|
|
60 |
private int freeDays;
|
|
|
61 |
|
|
|
62 |
@Transient
|
| 30929 |
tejbeer |
63 |
private boolean loanStatus;
|
|
|
64 |
|
|
|
65 |
@Transient
|
| 31159 |
tejbeer |
66 |
private BigDecimal totalPending;
|
|
|
67 |
|
| 33528 |
amit.gupta |
68 |
public long getDays() {
|
|
|
69 |
return ChronoUnit.DAYS.between(this.getCreatedOn().toLocalDate(), LocalDateTime.now()) + 1;
|
|
|
70 |
}
|
|
|
71 |
|
|
|
72 |
public boolean isDue() {
|
| 33532 |
amit.gupta |
73 |
return this.getSettledOn()==null && !this.getDueDate().toLocalDate().isBefore(LocalDate.now());
|
| 33528 |
amit.gupta |
74 |
}
|
|
|
75 |
|
| 33529 |
amit.gupta |
76 |
public boolean isOverdue() {
|
| 33532 |
amit.gupta |
77 |
return this.getSettledOn()==null && this.getDueDate().toLocalDate().isBefore(LocalDate.now()) &&
|
|
|
78 |
!this.getDueDate().plusDays(15).toLocalDate().isBefore(LocalDate.now());
|
| 33528 |
amit.gupta |
79 |
}
|
|
|
80 |
|
| 33529 |
amit.gupta |
81 |
public boolean isDefault() {
|
| 33532 |
amit.gupta |
82 |
return this.getSettledOn()==null && this.getDueDate().plusDays(15).toLocalDate().isBefore(LocalDate.now());
|
| 33528 |
amit.gupta |
83 |
}
|
|
|
84 |
|
| 31159 |
tejbeer |
85 |
@Transient
|
| 30859 |
tejbeer |
86 |
private List<DailyStatementModel> dailyStatementModel;
|
|
|
87 |
|
|
|
88 |
public int getId() {
|
|
|
89 |
return id;
|
|
|
90 |
}
|
|
|
91 |
|
|
|
92 |
public void setId(int id) {
|
|
|
93 |
this.id = id;
|
|
|
94 |
}
|
|
|
95 |
|
| 31159 |
tejbeer |
96 |
public BigDecimal getTotalPending() {
|
|
|
97 |
return totalPending;
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
public void setTotalPending(BigDecimal totalPending) {
|
|
|
101 |
this.totalPending = totalPending;
|
|
|
102 |
}
|
|
|
103 |
|
| 30859 |
tejbeer |
104 |
public int getFofoId() {
|
|
|
105 |
return fofoId;
|
|
|
106 |
}
|
|
|
107 |
|
|
|
108 |
public void setFofoId(int fofoId) {
|
|
|
109 |
this.fofoId = fofoId;
|
|
|
110 |
}
|
|
|
111 |
|
|
|
112 |
public BigDecimal getInterestRate() {
|
|
|
113 |
return interestRate;
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
public void setInterestRate(BigDecimal interestRate) {
|
|
|
117 |
this.interestRate = interestRate;
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
public BigDecimal getIntialAmount() {
|
|
|
121 |
return intialAmount;
|
|
|
122 |
}
|
|
|
123 |
|
|
|
124 |
public void setIntialAmount(BigDecimal intialAmount) {
|
|
|
125 |
this.intialAmount = intialAmount;
|
|
|
126 |
}
|
|
|
127 |
|
|
|
128 |
public BigDecimal getPendingAmount() {
|
|
|
129 |
return pendingAmount;
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
public void setPendingAmount(BigDecimal pendingAmount) {
|
|
|
133 |
this.pendingAmount = pendingAmount;
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
public LocalDateTime getCreatedOn() {
|
|
|
137 |
return createdOn;
|
|
|
138 |
}
|
|
|
139 |
|
|
|
140 |
public void setCreatedOn(LocalDateTime createdOn) {
|
|
|
141 |
this.createdOn = createdOn;
|
|
|
142 |
}
|
|
|
143 |
|
|
|
144 |
public LocalDateTime getDueDate() {
|
|
|
145 |
return dueDate;
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
public void setDueDate(LocalDateTime dueDate) {
|
|
|
149 |
this.dueDate = dueDate;
|
|
|
150 |
}
|
|
|
151 |
|
|
|
152 |
public BigDecimal getInterestAccrued() {
|
|
|
153 |
return interestAccrued;
|
|
|
154 |
}
|
|
|
155 |
|
|
|
156 |
public void setInterestAccrued(BigDecimal interestAccrued) {
|
|
|
157 |
this.interestAccrued = interestAccrued;
|
|
|
158 |
}
|
|
|
159 |
|
|
|
160 |
public BigDecimal getInterestPaid() {
|
|
|
161 |
return interestPaid;
|
|
|
162 |
}
|
|
|
163 |
|
|
|
164 |
public void setInterestPaid(BigDecimal interestPaid) {
|
|
|
165 |
this.interestPaid = interestPaid;
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
public int getFreeDays() {
|
|
|
169 |
return freeDays;
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
public void setFreeDays(int freeDays) {
|
|
|
173 |
this.freeDays = freeDays;
|
|
|
174 |
}
|
|
|
175 |
|
|
|
176 |
public List<DailyStatementModel> getDailyStatementModel() {
|
|
|
177 |
return dailyStatementModel;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
public void setDailyStatementModel(List<DailyStatementModel> dailyStatementModel) {
|
|
|
181 |
this.dailyStatementModel = dailyStatementModel;
|
|
|
182 |
}
|
|
|
183 |
|
| 33696 |
amit.gupta |
184 |
public boolean isLimit() {
|
|
|
185 |
return this.getFreeDays() >= 365;
|
|
|
186 |
}
|
|
|
187 |
|
| 32681 |
amit.gupta |
188 |
@Override
|
|
|
189 |
public String toString() {
|
|
|
190 |
return "Loan{" +
|
|
|
191 |
"id=" + id +
|
|
|
192 |
", fofoId=" + fofoId +
|
|
|
193 |
", interestRate=" + interestRate +
|
|
|
194 |
", intialAmount=" + intialAmount +
|
|
|
195 |
", pendingAmount=" + pendingAmount +
|
|
|
196 |
", createdOn=" + createdOn +
|
|
|
197 |
", settledOn=" + settledOn +
|
|
|
198 |
", dueDate=" + dueDate +
|
|
|
199 |
", interestAccrued=" + interestAccrued +
|
|
|
200 |
", interestPaid=" + interestPaid +
|
|
|
201 |
", freeDays=" + freeDays +
|
|
|
202 |
", loanStatus=" + loanStatus +
|
|
|
203 |
", totalPending=" + totalPending +
|
|
|
204 |
", dailyStatementModel=" + dailyStatementModel +
|
|
|
205 |
'}';
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
@Override
|
|
|
209 |
public boolean equals(Object o) {
|
|
|
210 |
if (this == o) return true;
|
|
|
211 |
if (o == null || getClass() != o.getClass()) return false;
|
|
|
212 |
Loan loan = (Loan) o;
|
|
|
213 |
return id == loan.id && fofoId == loan.fofoId && freeDays == loan.freeDays && loanStatus == loan.loanStatus && Objects.equals(interestRate, loan.interestRate) && Objects.equals(intialAmount, loan.intialAmount) && Objects.equals(pendingAmount, loan.pendingAmount) && Objects.equals(createdOn, loan.createdOn) && Objects.equals(settledOn, loan.settledOn) && Objects.equals(dueDate, loan.dueDate) && Objects.equals(interestAccrued, loan.interestAccrued) && Objects.equals(interestPaid, loan.interestPaid) && Objects.equals(totalPending, loan.totalPending) && Objects.equals(dailyStatementModel, loan.dailyStatementModel);
|
|
|
214 |
}
|
|
|
215 |
|
|
|
216 |
@Override
|
|
|
217 |
public int hashCode() {
|
|
|
218 |
return Objects.hash(id, fofoId, interestRate, intialAmount, pendingAmount, createdOn, settledOn, dueDate, interestAccrued, interestPaid, freeDays, loanStatus, totalPending, dailyStatementModel);
|
|
|
219 |
}
|
|
|
220 |
|
|
|
221 |
public LocalDateTime getSettledOn() {
|
|
|
222 |
return settledOn;
|
|
|
223 |
}
|
|
|
224 |
|
|
|
225 |
public void setSettledOn(LocalDateTime settledOn) {
|
|
|
226 |
this.settledOn = settledOn;
|
|
|
227 |
}
|
|
|
228 |
|
| 30929 |
tejbeer |
229 |
public boolean isLoanStatus() {
|
|
|
230 |
return loanStatus;
|
|
|
231 |
}
|
|
|
232 |
|
|
|
233 |
public void setLoanStatus(boolean loanStatus) {
|
|
|
234 |
this.loanStatus = loanStatus;
|
|
|
235 |
}
|
|
|
236 |
|
| 30859 |
tejbeer |
237 |
}
|