Subversion Repositories SmartDukaan

Rev

Rev 32681 | Rev 33529 | 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() {
63
		return this.getSettledOn()!=null && this.getDueDate().toLocalDate().isBefore(LocalDate.now());
64
	}
65
 
66
	public boolean isDefault() {
67
		return this.getSettledOn()!=null && this.getDueDate().toLocalDate().isAfter(LocalDate.now());
68
	}
69
 
70
	public boolean isDueDateCrossed() {
71
		return this.getSettledOn()!=null && this.getDueDate().toLocalDate().isAfter(LocalDate.now());
72
	}
73
 
31159 tejbeer 74
	@Transient
30859 tejbeer 75
	private List<DailyStatementModel> dailyStatementModel;
76
 
77
	public int getId() {
78
		return id;
79
	}
80
 
81
	public void setId(int id) {
82
		this.id = id;
83
	}
84
 
31159 tejbeer 85
	public BigDecimal getTotalPending() {
86
		return totalPending;
87
	}
88
 
89
	public void setTotalPending(BigDecimal totalPending) {
90
		this.totalPending = totalPending;
91
	}
92
 
30859 tejbeer 93
	public int getFofoId() {
94
		return fofoId;
95
	}
96
 
97
	public void setFofoId(int fofoId) {
98
		this.fofoId = fofoId;
99
	}
100
 
101
	public BigDecimal getInterestRate() {
102
		return interestRate;
103
	}
104
 
105
	public void setInterestRate(BigDecimal interestRate) {
106
		this.interestRate = interestRate;
107
	}
108
 
109
	public BigDecimal getIntialAmount() {
110
		return intialAmount;
111
	}
112
 
113
	public void setIntialAmount(BigDecimal intialAmount) {
114
		this.intialAmount = intialAmount;
115
	}
116
 
117
	public BigDecimal getPendingAmount() {
118
		return pendingAmount;
119
	}
120
 
121
	public void setPendingAmount(BigDecimal pendingAmount) {
122
		this.pendingAmount = pendingAmount;
123
	}
124
 
125
	public LocalDateTime getCreatedOn() {
126
		return createdOn;
127
	}
128
 
129
	public void setCreatedOn(LocalDateTime createdOn) {
130
		this.createdOn = createdOn;
131
	}
132
 
133
	public LocalDateTime getDueDate() {
134
		return dueDate;
135
	}
136
 
137
	public void setDueDate(LocalDateTime dueDate) {
138
		this.dueDate = dueDate;
139
	}
140
 
141
	public BigDecimal getInterestAccrued() {
142
		return interestAccrued;
143
	}
144
 
145
	public void setInterestAccrued(BigDecimal interestAccrued) {
146
		this.interestAccrued = interestAccrued;
147
	}
148
 
149
	public BigDecimal getInterestPaid() {
150
		return interestPaid;
151
	}
152
 
153
	public void setInterestPaid(BigDecimal interestPaid) {
154
		this.interestPaid = interestPaid;
155
	}
156
 
157
	public int getFreeDays() {
158
		return freeDays;
159
	}
160
 
161
	public void setFreeDays(int freeDays) {
162
		this.freeDays = freeDays;
163
	}
164
 
165
	public List<DailyStatementModel> getDailyStatementModel() {
166
		return dailyStatementModel;
167
	}
168
 
169
	public void setDailyStatementModel(List<DailyStatementModel> dailyStatementModel) {
170
		this.dailyStatementModel = dailyStatementModel;
171
	}
172
 
32681 amit.gupta 173
	@Override
174
	public String toString() {
175
		return "Loan{" +
176
				"id=" + id +
177
				", fofoId=" + fofoId +
178
				", interestRate=" + interestRate +
179
				", intialAmount=" + intialAmount +
180
				", pendingAmount=" + pendingAmount +
181
				", createdOn=" + createdOn +
182
				", settledOn=" + settledOn +
183
				", dueDate=" + dueDate +
184
				", interestAccrued=" + interestAccrued +
185
				", interestPaid=" + interestPaid +
186
				", freeDays=" + freeDays +
187
				", loanStatus=" + loanStatus +
188
				", totalPending=" + totalPending +
189
				", dailyStatementModel=" + dailyStatementModel +
190
				'}';
191
	}
192
 
193
	@Override
194
	public boolean equals(Object o) {
195
		if (this == o) return true;
196
		if (o == null || getClass() != o.getClass()) return false;
197
		Loan loan = (Loan) o;
198
		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);
199
	}
200
 
201
	@Override
202
	public int hashCode() {
203
		return Objects.hash(id, fofoId, interestRate, intialAmount, pendingAmount, createdOn, settledOn, dueDate, interestAccrued, interestPaid, freeDays, loanStatus, totalPending, dailyStatementModel);
204
	}
205
 
206
	public LocalDateTime getSettledOn() {
207
		return settledOn;
208
	}
209
 
210
	public void setSettledOn(LocalDateTime settledOn) {
211
		this.settledOn = settledOn;
212
	}
213
 
30929 tejbeer 214
	public boolean isLoanStatus() {
215
		return loanStatus;
216
	}
217
 
218
	public void setLoanStatus(boolean loanStatus) {
219
		this.loanStatus = loanStatus;
220
	}
221
 
30859 tejbeer 222
}