Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
27878 amit.gupta 1
package com.spice.profitmandi.dao.model;
2
 
30670 amit.gupta 3
import com.fasterxml.jackson.annotation.JsonIgnore;
35600 amit 4
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
27878 amit.gupta 5
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
6
import com.spice.profitmandi.service.offers.ItemCriteria;
7
import com.spice.profitmandi.service.offers.PayoutSlab;
8
 
32979 amit.gupta 9
import java.time.LocalDateTime;
30651 amit.gupta 10
import java.util.List;
11
 
35600 amit 12
@JsonIgnoreProperties(ignoreUnknown = true)
27878 amit.gupta 13
public class ItemCriteriaPayout {
33745 amit.gupta 14
    private AmountType amountType;
15
    private ItemCriteria itemCriteria;
16
    private LocalDateTime startDate;
17
    private LocalDateTime endDate;
18
    private List<PayoutSlab> payoutSlabs;
19
    private String itemCriteriaString;
20
    private long achievedValue;
21
    private long shortValue;
22
    private PayoutSlab currentSlab;
23
    private PayoutSlab nextSlab;
27878 amit.gupta 24
 
33745 amit.gupta 25
    @JsonIgnore
26
    public String getCurretPayoutString() {
27
        String templateString = null;
28
        if (this.getAmountType().equals(AmountType.FIXED)) {
29
            templateString = "Rs. %f per pc";
30
        } else if (this.getAmountType().equals(AmountType.PERCENTAGE)) {
31
            templateString = "%f %%";
32
        } else {
33
            templateString = "%f %%";
34
        }
35
        return String.format(templateString, this.getCurrentSlab().getPayoutAmount());
36
    }
30651 amit.gupta 37
 
33745 amit.gupta 38
    public LocalDateTime getStartDate() {
39
        return startDate;
40
    }
32979 amit.gupta 41
 
33745 amit.gupta 42
    public void setStartDate(LocalDateTime startDate) {
43
        this.startDate = startDate;
44
    }
32979 amit.gupta 45
 
33745 amit.gupta 46
    public LocalDateTime getEndDate() {
47
        return endDate;
48
    }
32979 amit.gupta 49
 
33745 amit.gupta 50
    public void setEndDate(LocalDateTime endDate) {
51
        this.endDate = endDate;
52
    }
32979 amit.gupta 53
 
33745 amit.gupta 54
    public long getShortValue() {
55
        return shortValue;
56
    }
29785 amit.gupta 57
 
58
 
33745 amit.gupta 59
    public void setShortValue(long shortValue) {
60
        this.shortValue = shortValue;
61
    }
29785 amit.gupta 62
 
63
 
33745 amit.gupta 64
    public PayoutSlab getCurrentSlab() {
65
        return currentSlab;
66
    }
29785 amit.gupta 67
 
68
 
33745 amit.gupta 69
    public void setCurrentSlab(PayoutSlab currentSlab) {
70
        this.currentSlab = currentSlab;
71
    }
29785 amit.gupta 72
 
73
 
33745 amit.gupta 74
    public PayoutSlab getNextSlab() {
75
        return nextSlab;
76
    }
29785 amit.gupta 77
 
78
 
33745 amit.gupta 79
    public void setNextSlab(PayoutSlab nextSlab) {
80
        this.nextSlab = nextSlab;
81
    }
29785 amit.gupta 82
 
83
 
33745 amit.gupta 84
    public ItemCriteria getItemCriteria() {
27878 amit.gupta 85
        return itemCriteria;
86
    }
87
 
88
 
33745 amit.gupta 89
    public AmountType getAmountType() {
90
        return amountType;
91
    }
27878 amit.gupta 92
 
93
 
33745 amit.gupta 94
    public void setAmountType(AmountType amountType) {
95
        this.amountType = amountType;
96
    }
27878 amit.gupta 97
 
98
 
33745 amit.gupta 99
    public long getAchievedValue() {
100
        return achievedValue;
101
    }
27878 amit.gupta 102
 
103
 
33745 amit.gupta 104
    public void setAchievedValue(long achievedValue) {
105
        this.achievedValue = achievedValue;
106
    }
29785 amit.gupta 107
 
108
 
33745 amit.gupta 109
    public String getItemCriteriaString() {
27878 amit.gupta 110
        return itemCriteriaString;
111
    }
112
 
113
    public void setItemCriteriaString(String itemCriteriaString) {
114
        this.itemCriteriaString = itemCriteriaString;
115
    }
116
 
117
    @Override
33745 amit.gupta 118
    public int hashCode() {
119
        final int prime = 31;
120
        int result = 1;
121
        result = prime * result + ((amountType == null) ? 0 : amountType.hashCode());
122
        result = prime * result + ((currentSlab == null) ? 0 : currentSlab.hashCode());
123
        result = prime * result + ((itemCriteria == null) ? 0 : itemCriteria.hashCode());
124
        result = prime * result + ((itemCriteriaString == null) ? 0 : itemCriteriaString.hashCode());
125
        return result;
126
    }
27878 amit.gupta 127
 
128
 
33745 amit.gupta 129
    @Override
130
    public boolean equals(Object obj) {
131
        if (this == obj)
132
            return true;
133
        if (obj == null)
134
            return false;
135
        if (getClass() != obj.getClass())
136
            return false;
137
        ItemCriteriaPayout other = (ItemCriteriaPayout) obj;
138
        if (amountType != other.amountType)
139
            return false;
140
        if (currentSlab == null) {
141
            if (other.currentSlab != null)
142
                return false;
143
        } else if (!currentSlab.equals(other.currentSlab))
144
            return false;
145
        if (itemCriteria == null) {
146
            if (other.itemCriteria != null)
147
                return false;
148
        } else if (!itemCriteria.equals(other.itemCriteria))
149
            return false;
150
        if (itemCriteriaString == null) {
151
            if (other.itemCriteriaString != null)
152
                return false;
153
        } else if (!itemCriteriaString.equals(other.itemCriteriaString))
154
            return false;
155
        return true;
156
    }
27878 amit.gupta 157
 
158
    public void setItemCriteria(ItemCriteria itemCriteria) {
159
        this.itemCriteria = itemCriteria;
160
    }
161
 
162
    public List<PayoutSlab> getPayoutSlabs() {
163
        return payoutSlabs;
164
    }
165
 
166
    public void setPayoutSlabs(List<PayoutSlab> payoutSlabs) {
167
        this.payoutSlabs = payoutSlabs;
168
    }
169
 
170
 
33745 amit.gupta 171
    @Override
172
    public String toString() {
173
        return "ItemCriteriaPayout [amountType=" + amountType + ", itemCriteria=" + itemCriteria + ", payoutSlabs="
174
                + payoutSlabs + ", itemCriteriaString=" + itemCriteriaString + ", achievedValue=" + achievedValue
175
                + ", shortValue=" + shortValue + ", currentSlab=" + currentSlab + ", nextSlab=" + nextSlab + "]";
176
    }
27878 amit.gupta 177
 
33745 amit.gupta 178
    public boolean isWithinRange(LocalDateTime testDate) {
179
        if (startDate == null) return true;
180
        return !(testDate.isBefore(startDate) || testDate.isAfter(endDate));
181
    }
33441 amit.gupta 182
 
33736 amit.gupta 183
 
35600 amit 184
    @JsonIgnore
33745 amit.gupta 185
    public LocalDateTime getBillingEndDate() {
186
        return this.endDate == null ? null : this.endDate.plusDays(90);
187
    }
33736 amit.gupta 188
 
35600 amit 189
    @JsonIgnore
33745 amit.gupta 190
    public LocalDateTime getBillingStartDate() {
191
        return this.startDate == null ? null : this.startDate.minusDays(30);
192
    }
33736 amit.gupta 193
 
33745 amit.gupta 194
 
27878 amit.gupta 195
}