Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
31903 amit.gupta 1
package com.spice.profitmandi.service.scheme;
2
 
3
import com.spice.profitmandi.dao.entity.fofo.OfferPayout;
4
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
31920 amit.gupta 5
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
6
import com.spice.profitmandi.dao.model.AmountModel;
31903 amit.gupta 7
 
8
import java.util.List;
9
import java.util.Objects;
10
 
11
public class InventoryPayoutModel {
12
    int inventoryItemId;
13
    List<SchemeInOut> schemePayouts;
14
    List<OfferPayout> offerPayouts;
15
 
16
    private double fixedAmount;
17
    private double percentageAmount;
18
    private double paidAmount;
31914 amit.gupta 19
    private double dp;
31903 amit.gupta 20
 
31989 amit.gupta 21
    public double getActualRolloutAmount() {
22
        double effectiveDp = this.getDp() - this.getFixedAmount();
32021 amit.gupta 23
        double value = effectiveDp * percentageAmount / (100 + percentageAmount);
31989 amit.gupta 24
        return this.getFixedAmount() + value;
25
    }
31903 amit.gupta 26
 
31989 amit.gupta 27
 
31920 amit.gupta 28
    public double getRolloutAmount(AmountModel amountModel) {
29
        double rollout = 0;
30
        if (amountModel.getAmountType().equals(AmountType.PERCENTAGE)) {
31
            double effectiveDp = this.getDp() - this.getFixedAmount();
32
            double totalPercentage = this.getPercentageAmount() + amountModel.getAmount();
33
            rollout = effectiveDp * (totalPercentage / (100 + totalPercentage) - (this.getPercentageAmount() / (100 + this.getPercentageAmount())));
34
        } else {
32021 amit.gupta 35
            if (amountModel.isDiscount()) {
36
                rollout = amountModel.getAmount();
37
            } else {
38
                rollout = amountModel.getAmount() * (100 / (100 + this.getPercentageAmount()));
39
            }
31920 amit.gupta 40
        }
41
        return rollout;
42
    }
43
 
31903 amit.gupta 44
    public InventoryPayoutModel(int inventoryItemId, List<SchemeInOut> schemePayouts, List<OfferPayout> offerPayouts) {
45
        this.inventoryItemId = inventoryItemId;
46
        this.schemePayouts = schemePayouts;
47
        this.offerPayouts = offerPayouts;
48
    }
49
 
50
    @Override
51
    public String toString() {
52
        return "InventoryPayoutModel{" +
53
                "inventoryItemId=" + inventoryItemId +
54
                ", schemePayouts=" + schemePayouts +
55
                ", offerPayouts=" + offerPayouts +
56
                ", fixedAmount=" + fixedAmount +
57
                ", percentageAmount=" + percentageAmount +
58
                ", paidAmount=" + paidAmount +
59
                '}';
60
    }
61
 
62
    public double getPercentageAmount() {
63
        return percentageAmount;
64
    }
65
 
66
    public void setPercentageAmount(double percentageAmount) {
67
        this.percentageAmount = percentageAmount;
68
    }
69
 
70
    public double getPaidAmount() {
31989 amit.gupta 71
        return this.paidAmount;
31903 amit.gupta 72
    }
73
 
74
    public void setPaidAmount(double paidAmount) {
75
        this.paidAmount = paidAmount;
76
    }
77
 
78
    public double getFixedAmount() {
31990 amit.gupta 79
        return this.fixedAmount;
31903 amit.gupta 80
    }
81
 
82
    public void setFixedAmount(double fixedAmount) {
83
        this.fixedAmount = fixedAmount;
84
    }
85
 
86
    public int getInventoryItemId() {
87
        return inventoryItemId;
88
    }
89
 
90
    public void setInventoryItemId(int inventoryItemId) {
91
        this.inventoryItemId = inventoryItemId;
92
    }
93
 
94
    public List<SchemeInOut> getSchemePayouts() {
95
        return schemePayouts;
96
    }
97
 
98
    public void setSchemePayouts(List<SchemeInOut> schemePayouts) {
99
        this.schemePayouts = schemePayouts;
100
    }
101
 
102
    public List<OfferPayout> getOfferPayouts() {
103
        return offerPayouts;
104
    }
105
 
31914 amit.gupta 106
    public double getDp() {
107
        return dp;
108
    }
109
 
110
    public void setDp(double dp) {
111
        this.dp = dp;
112
    }
113
 
114
    @Override
115
    public boolean equals(Object o) {
116
        if (this == o) return true;
117
        if (o == null || getClass() != o.getClass()) return false;
118
        InventoryPayoutModel that = (InventoryPayoutModel) o;
119
        return inventoryItemId == that.inventoryItemId && Double.compare(that.fixedAmount, fixedAmount) == 0 && Double.compare(that.percentageAmount, percentageAmount) == 0 && Double.compare(that.paidAmount, paidAmount) == 0 && Double.compare(that.dp, dp) == 0 && Objects.equals(schemePayouts, that.schemePayouts) && Objects.equals(offerPayouts, that.offerPayouts);
120
    }
121
 
122
    @Override
123
    public int hashCode() {
124
        return Objects.hash(inventoryItemId, schemePayouts, offerPayouts, fixedAmount, percentageAmount, paidAmount, dp);
125
    }
126
 
31903 amit.gupta 127
    public void setOfferPayouts(List<OfferPayout> offerPayouts) {
128
        this.offerPayouts = offerPayouts;
129
    }
130
}