Subversion Repositories SmartDukaan

Rev

Rev 33696 | Rev 34212 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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