Subversion Repositories SmartDukaan

Rev

Rev 23531 | Rev 23574 | 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
/**
22
 * This class basically contains recharge operator details
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
38
	@Column(name="operator_id", unique=true, updatable=false)
39
	//@GeneratedValue(strategy = GenerationType.IDENTITY)
40
	private int operatorId;
41
 
23556 amit.gupta 42
	@Column(name="our_commission")
43
	private float ourCommission;
44
 
45
	@Column(name="our_commission_type")
46
	@Enumerated(EnumType.STRING)
47
	private AmountType ourCommissionType;
48
 
49
	public float getOurCommission() {
50
		return ourCommission;
51
	}
52
 
53
	public void setOurCommission(float ourCommission) {
54
		this.ourCommission = ourCommission;
55
	}
56
 
57
	public AmountType getOurCommissionType() {
58
		return ourCommissionType;
59
	}
60
 
61
	public void setOurCommissionType(AmountType ourCommissionType) {
62
		this.ourCommissionType = ourCommissionType;
63
	}
64
 
23527 ashik.ali 65
	@Column(name="amount")
66
	private float amount;
67
 
68
	@Column(name = "amount_type")
23531 ashik.ali 69
	@Enumerated(EnumType.STRING)
23527 ashik.ali 70
	private AmountType amountType;
71
 
23556 amit.gupta 72
	public String getFormattedAmount() {
73
		return FormattingUtils.formatDecimalTwoDigits(this.getAmount());
74
	}
75
 
23527 ashik.ali 76
	@Convert(converter = LocalDateTimeAttributeConverter.class)
77
	@Column(name="create_timestamp", updatable = false)
78
	private LocalDateTime createTimestamp = LocalDateTime.now();
79
 
80
	@Convert(converter = LocalDateTimeAttributeConverter.class)
81
	@Column(name="update_timestamp", updatable = false)
82
	@UpdateTimestamp
83
	private LocalDateTime updateTimestamp = LocalDateTime.now();
84
 
85
	public int getOperatorId() {
86
		return operatorId;
87
	}
88
 
89
	public void setOperatorId(int operatorId) {
90
		this.operatorId = operatorId;
91
	}
92
 
93
	public float getAmount() {
94
		return amount;
95
	}
96
 
97
	public void setAmount(float amount) {
98
		this.amount = amount;
99
	}
100
 
101
	public AmountType getAmountType() {
102
		return amountType;
103
	}
104
 
105
	public void setAmountType(AmountType amountType) {
106
		this.amountType = amountType;
107
	}
108
 
109
	public LocalDateTime getCreateTimestamp() {
110
		return createTimestamp;
111
	}
112
 
113
	public void setCreateTimestamp(LocalDateTime createTimestamp) {
114
		this.createTimestamp = createTimestamp;
115
	}
116
 
117
	public LocalDateTime getUpdateTimestamp() {
118
		return updateTimestamp;
119
	}
120
 
121
	public void setUpdateTimestamp(LocalDateTime updateTimestamp) {
122
		this.updateTimestamp = updateTimestamp;
123
	}
124
 
125
	public String getFormattedCreateTimestamp(){
126
		if(createTimestamp == null){
127
			return null;
128
		}
129
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
130
		return createTimestamp.format(formatter);
131
    }
132
 
133
	public String getFormattedUpdateTimestamp(){
134
		if(updateTimestamp == null){
135
			return null;
136
		}
137
		DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MM-YYYY HH:mm");
138
		return updateTimestamp.format(formatter);
139
    }
140
 
141
	@Override
142
	public int hashCode() {
143
		final int prime = 31;
144
		int result = 1;
23556 amit.gupta 145
		result = prime * result + Float.floatToIntBits(amount);
146
		result = prime * result + ((amountType == null) ? 0 : amountType.hashCode());
147
		result = prime * result + ((createTimestamp == null) ? 0 : createTimestamp.hashCode());
23527 ashik.ali 148
		result = prime * result + operatorId;
23556 amit.gupta 149
		result = prime * result + Float.floatToIntBits(ourCommission);
150
		result = prime * result + ((ourCommissionType == null) ? 0 : ourCommissionType.hashCode());
151
		result = prime * result + ((updateTimestamp == null) ? 0 : updateTimestamp.hashCode());
23527 ashik.ali 152
		return result;
153
	}
154
 
155
	@Override
156
	public boolean equals(Object obj) {
157
		if (this == obj)
158
			return true;
159
		if (obj == null)
160
			return false;
161
		if (getClass() != obj.getClass())
162
			return false;
163
		RechargeCommission other = (RechargeCommission) obj;
23556 amit.gupta 164
		if (Float.floatToIntBits(amount) != Float.floatToIntBits(other.amount))
165
			return false;
166
		if (amountType != other.amountType)
167
			return false;
168
		if (createTimestamp == null) {
169
			if (other.createTimestamp != null)
170
				return false;
171
		} else if (!createTimestamp.equals(other.createTimestamp))
172
			return false;
23527 ashik.ali 173
		if (operatorId != other.operatorId)
174
			return false;
23556 amit.gupta 175
		if (Float.floatToIntBits(ourCommission) != Float.floatToIntBits(other.ourCommission))
176
			return false;
177
		if (ourCommissionType != other.ourCommissionType)
178
			return false;
179
		if (updateTimestamp == null) {
180
			if (other.updateTimestamp != null)
181
				return false;
182
		} else if (!updateTimestamp.equals(other.updateTimestamp))
183
			return false;
23527 ashik.ali 184
		return true;
185
	}
186
 
187
	@Override
188
	public String toString() {
23556 amit.gupta 189
		return "RechargeCommission [operatorId=" + operatorId + ", ourCommission=" + ourCommission
190
				+ ", ourCommissionType=" + ourCommissionType + ", amount=" + amount + ", amountType=" + amountType
23527 ashik.ali 191
				+ ", createTimestamp=" + createTimestamp + ", updateTimestamp=" + updateTimestamp + "]";
192
	}
193
 
194
}