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