Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
23527 ashik.ali 1
package com.spice.profitmandi.dao.entity.dtr;
2
 
3
import java.io.Serializable;
4
import java.time.LocalDateTime;
5
import java.time.format.DateTimeFormatter;
6
 
7
import javax.persistence.Column;
8
import javax.persistence.Convert;
9
import javax.persistence.Entity;
23531 ashik.ali 10
import javax.persistence.EnumType;
11
import javax.persistence.Enumerated;
23527 ashik.ali 12
import javax.persistence.Id;
13
import javax.persistence.Table;
14
 
15
import org.hibernate.annotations.UpdateTimestamp;
16
 
23556 amit.gupta 17
import com.spice.profitmandi.common.util.FormattingUtils;
23527 ashik.ali 18
import com.spice.profitmandi.dao.convertor.LocalDateTimeAttributeConverter;
19
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
20
 
21
/**
23574 ashik.ali 22
 * This class basically contains recharge commission details
23527 ashik.ali 23
 * 
24
 * @author ashikali
25
 *
26
 */
27
 
28
@Entity
29
@Table(name="dtr.recharge_commission", schema = "dtr")
30
public class RechargeCommission implements Serializable{
31
 
32
	private static final long serialVersionUID = 1L;
33
 
34
	public RechargeCommission() {
35
	}
36
 
37
	@Id
23574 ashik.ali 38
	@Column(name="operator_id")
23527 ashik.ali 39
	private int operatorId;
40
 
23574 ashik.ali 41
	@Id
42
	@Column(name = "provider_id")
43
	private int providerId;
44
 
45
	@Column(name="amount")
46
	private float amount;
47
 
48
	@Column(name = "amount_type")
49
	@Enumerated(EnumType.STRING)
50
	private AmountType amountType;
51
 
23556 amit.gupta 52
	@Column(name="our_commission")
53
	private float ourCommission;
54
 
55
	@Column(name="our_commission_type")
56
	@Enumerated(EnumType.STRING)
57
	private AmountType ourCommissionType;
58
 
23574 ashik.ali 59
	@Convert(converter = LocalDateTimeAttributeConverter.class)
60
	@Column(name="create_timestamp", updatable = false)
61
	private LocalDateTime createTimestamp = LocalDateTime.now();
62
 
63
	@Convert(converter = LocalDateTimeAttributeConverter.class)
64
	@Column(name="update_timestamp", updatable = false)
65
	@UpdateTimestamp
66
	private LocalDateTime updateTimestamp = LocalDateTime.now();
67
 
23556 amit.gupta 68
	public float getOurCommission() {
69
		return ourCommission;
70
	}
71
 
72
	public void setOurCommission(float ourCommission) {
73
		this.ourCommission = ourCommission;
74
	}
75
 
76
	public AmountType getOurCommissionType() {
77
		return ourCommissionType;
78
	}
79
 
80
	public void setOurCommissionType(AmountType ourCommissionType) {
81
		this.ourCommissionType = ourCommissionType;
82
	}
23527 ashik.ali 83
 
23556 amit.gupta 84
	public String getFormattedAmount() {
85
		return FormattingUtils.formatDecimalTwoDigits(this.getAmount());
86
	}
23527 ashik.ali 87
 
88
	public int getOperatorId() {
89
		return operatorId;
90
	}
91
 
92
	public void setOperatorId(int operatorId) {
93
		this.operatorId = operatorId;
94
	}
95
 
23574 ashik.ali 96
	public int getProviderId() {
97
		return providerId;
98
	}
99
 
100
	public void setProviderId(int providerId) {
101
		this.providerId = providerId;
102
	}
103
 
23527 ashik.ali 104
	public float getAmount() {
105
		return amount;
106
	}
107
 
108
	public void setAmount(float amount) {
109
		this.amount = amount;
110
	}
111
 
112
	public AmountType getAmountType() {
113
		return amountType;
114
	}
115
 
116
	public void setAmountType(AmountType amountType) {
117
		this.amountType = amountType;
118
	}
119
 
120
	public LocalDateTime getCreateTimestamp() {
121
		return createTimestamp;
122
	}
123
 
124
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
125
		this.createTimestamp = createTimestamp;
126
	}
127
 
128
	public LocalDateTime getUpdateTimestamp() {
129
		return updateTimestamp;
130
	}
131
 
132
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
133
		this.updateTimestamp = updateTimestamp;
134
	}
135
 
136
	public String getFormattedCreateTimestamp(){
137
		if(createTimestamp == null){
138
			return null;
139
		}
140
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
141
		return createTimestamp.format(formatter);
142
    }
143
 
144
	public String getFormattedUpdateTimestamp(){
145
		if(updateTimestamp == null){
146
			return null;
147
		}
148
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
149
		return updateTimestamp.format(formatter);
150
    }
151
 
152
	@Override
153
	public int hashCode() {
154
		final int prime = 31;
155
		int result = 1;
156
		result = prime * result + operatorId;
23574 ashik.ali 157
		result = prime * result + providerId;
23527 ashik.ali 158
		return result;
159
	}
160
 
161
	@Override
162
	public boolean equals(Object obj) {
163
		if (this == obj)
164
			return true;
165
		if (obj == null)
166
			return false;
167
		if (getClass() != obj.getClass())
168
			return false;
169
		RechargeCommission other = (RechargeCommission) obj;
170
		if (operatorId != other.operatorId)
171
			return false;
23574 ashik.ali 172
		if (providerId != other.providerId)
23556 amit.gupta 173
			return false;
23527 ashik.ali 174
		return true;
175
	}
176
 
177
	@Override
178
	public String toString() {
23574 ashik.ali 179
		return "RechargeCommission [operatorId=" + operatorId + ", providerId=" + providerId + ", amount=" + amount
180
				+ ", amountType=" + amountType + ", ourCommission=" + ourCommission + ", ourCommissionType="
181
				+ ourCommissionType + ", createTimestamp=" + createTimestamp + ", updateTimestamp=" + updateTimestamp
182
				+ "]";
23527 ashik.ali 183
	}
184
 
185
}