Subversion Repositories SmartDukaan

Rev

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