Subversion Repositories SmartDukaan

Rev

Rev 32021 | 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;
32165 amit.gupta 13
    List<SchemeInOut> paidSios;
14
    List<SchemeInOut> pendingSios;
31903 amit.gupta 15
    List<OfferPayout> offerPayouts;
16
 
17
    private double fixedAmount;
18
    private double percentageAmount;
19
    private double paidAmount;
31914 amit.gupta 20
    private double dp;
31903 amit.gupta 21
 
32165 amit.gupta 22
    public List<SchemeInOut> getPendingSios() {
23
        return pendingSios;
24
    }
25
 
26
    @Override
27
    public boolean equals(Object o) {
28
        if (this == o) return true;
29
        if (o == null || getClass() != o.getClass()) return false;
30
        InventoryPayoutModel that = (InventoryPayoutModel) o;
31
        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(paidSios, that.paidSios) && Objects.equals(pendingSios, that.pendingSios) && Objects.equals(offerPayouts, that.offerPayouts);
32
    }
33
 
34
    @Override
35
    public int hashCode() {
36
        return Objects.hash(inventoryItemId, paidSios, pendingSios, offerPayouts, fixedAmount, percentageAmount, paidAmount, dp);
37
    }
38
 
39
    public void setPendingSios(List<SchemeInOut> pendingSios) {
40
        this.pendingSios = pendingSios;
41
    }
42
 
31989 amit.gupta 43
    public double getActualRolloutAmount() {
44
        double effectiveDp = this.getDp() - this.getFixedAmount();
32021 amit.gupta 45
        double value = effectiveDp * percentageAmount / (100 + percentageAmount);
31989 amit.gupta 46
        return this.getFixedAmount() + value;
47
    }
31903 amit.gupta 48
 
31989 amit.gupta 49
 
31920 amit.gupta 50
    public double getRolloutAmount(AmountModel amountModel) {
51
        double rollout = 0;
52
        if (amountModel.getAmountType().equals(AmountType.PERCENTAGE)) {
53
            double effectiveDp = this.getDp() - this.getFixedAmount();
54
            double totalPercentage = this.getPercentageAmount() + amountModel.getAmount();
55
            rollout = effectiveDp * (totalPercentage / (100 + totalPercentage) - (this.getPercentageAmount() / (100 + this.getPercentageAmount())));
56
        } else {
32021 amit.gupta 57
            if (amountModel.isDiscount()) {
58
                rollout = amountModel.getAmount();
59
            } else {
60
                rollout = amountModel.getAmount() * (100 / (100 + this.getPercentageAmount()));
61
            }
31920 amit.gupta 62
        }
63
        return rollout;
64
    }
65
 
32165 amit.gupta 66
    public InventoryPayoutModel(int inventoryItemId, List<SchemeInOut> paidSios, List<SchemeInOut> pendingSios, List<OfferPayout> offerPayouts) {
31903 amit.gupta 67
        this.inventoryItemId = inventoryItemId;
32165 amit.gupta 68
        this.paidSios = paidSios;
69
        this.pendingSios = pendingSios;
31903 amit.gupta 70
        this.offerPayouts = offerPayouts;
71
    }
72
 
73
    @Override
74
    public String toString() {
75
        return "InventoryPayoutModel{" +
76
                "inventoryItemId=" + inventoryItemId +
32165 amit.gupta 77
                ", paidSios=" + paidSios +
31903 amit.gupta 78
                ", offerPayouts=" + offerPayouts +
79
                ", fixedAmount=" + fixedAmount +
80
                ", percentageAmount=" + percentageAmount +
81
                ", paidAmount=" + paidAmount +
82
                '}';
83
    }
84
 
85
    public double getPercentageAmount() {
86
        return percentageAmount;
87
    }
88
 
89
    public void setPercentageAmount(double percentageAmount) {
90
        this.percentageAmount = percentageAmount;
91
    }
92
 
93
    public double getPaidAmount() {
31989 amit.gupta 94
        return this.paidAmount;
31903 amit.gupta 95
    }
96
 
97
    public void setPaidAmount(double paidAmount) {
98
        this.paidAmount = paidAmount;
99
    }
100
 
101
    public double getFixedAmount() {
31990 amit.gupta 102
        return this.fixedAmount;
31903 amit.gupta 103
    }
104
 
105
    public void setFixedAmount(double fixedAmount) {
106
        this.fixedAmount = fixedAmount;
107
    }
108
 
109
    public int getInventoryItemId() {
110
        return inventoryItemId;
111
    }
112
 
113
    public void setInventoryItemId(int inventoryItemId) {
114
        this.inventoryItemId = inventoryItemId;
115
    }
116
 
32165 amit.gupta 117
    public List<SchemeInOut> getPaidSios() {
118
        return paidSios;
31903 amit.gupta 119
    }
120
 
32165 amit.gupta 121
    public void setPaidSios(List<SchemeInOut> paidSios) {
122
        this.paidSios = paidSios;
31903 amit.gupta 123
    }
124
 
125
    public List<OfferPayout> getOfferPayouts() {
126
        return offerPayouts;
127
    }
128
 
31914 amit.gupta 129
    public double getDp() {
130
        return dp;
131
    }
132
 
133
    public void setDp(double dp) {
134
        this.dp = dp;
135
    }
136
 
31903 amit.gupta 137
    public void setOfferPayouts(List<OfferPayout> offerPayouts) {
138
        this.offerPayouts = offerPayouts;
139
    }
140
}