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