Subversion Repositories SmartDukaan

Rev

Rev 32165 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.spice.profitmandi.service.scheme;

import com.spice.profitmandi.dao.entity.fofo.OfferPayout;
import com.spice.profitmandi.dao.entity.fofo.SchemeInOut;
import com.spice.profitmandi.dao.enumuration.catalog.AmountType;
import com.spice.profitmandi.dao.model.AmountModel;

import java.util.List;
import java.util.Objects;

public class InventoryPayoutModel {

    public float getPriceDropAmount() {
        return priceDropAmount;
    }

    public void setPriceDropAmount(float priceDropAmount) {
        this.priceDropAmount = priceDropAmount;
    }

    float priceDropAmount;
    int inventoryItemId;
    List<SchemeInOut> paidSios;
    List<SchemeInOut> pendingSios;
    List<OfferPayout> offerPayouts;


    private double fixedAmount;
    private double discountAmount;

    public double getDiscountAmount() {
        return discountAmount;
    }

    public void setDiscountAmount(double discountAmount) {
        this.discountAmount = discountAmount;
    }

    private double percentageAmount;
    private double paidAmount;
    private double dp;

    public List<SchemeInOut> getPendingSios() {
        return pendingSios;
    }

    public void setPendingSios(List<SchemeInOut> pendingSios) {
        this.pendingSios = pendingSios;
    }

    public double getActualRolloutAmount() {
        double effectiveDp = this.getDp() - this.getFixedAmount();
        double value = effectiveDp * percentageAmount / (100 + percentageAmount);
        return this.getFixedAmount() + value + this.getDiscountAmount();
    }


    public double getRolloutAmount(AmountModel amountModel) {
        double rollout = 0;
        if (amountModel.getAmountType().equals(AmountType.PERCENTAGE)) {
            double effectiveDp = this.getDp() - this.getFixedAmount();
            double totalPercentage = this.getPercentageAmount() + amountModel.getAmount();
            rollout = effectiveDp * (totalPercentage / (100 + totalPercentage) - (this.getPercentageAmount() / (100 + this.getPercentageAmount())));
        } else {
            if (amountModel.isDiscount()) {
                rollout = amountModel.getAmount();
            } else {
                rollout = amountModel.getAmount() * (100 / (100 + this.getPercentageAmount()));
            }
        }
        return rollout;
    }

    public InventoryPayoutModel(int inventoryItemId, float priceDropAmount, List<SchemeInOut> paidSios, List<SchemeInOut> pendingSios, List<OfferPayout> offerPayouts) {
        this.inventoryItemId = inventoryItemId;
        this.paidSios = paidSios;
        this.pendingSios = pendingSios;
        this.offerPayouts = offerPayouts;
        this.priceDropAmount = priceDropAmount;
    }

    public double getPercentageAmount() {
        return percentageAmount;
    }

    public void setPercentageAmount(double percentageAmount) {
        this.percentageAmount = percentageAmount;
    }

    public double getPaidAmount() {
        return this.paidAmount;
    }

    public void setPaidAmount(double paidAmount) {
        this.paidAmount = paidAmount;
    }

    public double getFixedAmount() {
        return this.fixedAmount;
    }

    public void setFixedAmount(double fixedAmount) {
        this.fixedAmount = fixedAmount;
    }

    public int getInventoryItemId() {
        return inventoryItemId;
    }

    public void setInventoryItemId(int inventoryItemId) {
        this.inventoryItemId = inventoryItemId;
    }

    public List<SchemeInOut> getPaidSios() {
        return paidSios;
    }

    public void setPaidSios(List<SchemeInOut> paidSios) {
        this.paidSios = paidSios;
    }

    public List<OfferPayout> getOfferPayouts() {
        return offerPayouts;
    }

    public double getDp() {
        return dp;
    }

    public void setDp(double dp) {
        this.dp = dp;
    }

    public void setOfferPayouts(List<OfferPayout> offerPayouts) {
        this.offerPayouts = offerPayouts;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        InventoryPayoutModel that = (InventoryPayoutModel) o;
        return Float.compare(priceDropAmount, that.priceDropAmount) == 0 && inventoryItemId == that.inventoryItemId && Double.compare(fixedAmount, that.fixedAmount) == 0 && Double.compare(discountAmount, that.discountAmount) == 0 && Double.compare(percentageAmount, that.percentageAmount) == 0 && Double.compare(paidAmount, that.paidAmount) == 0 && Double.compare(dp, that.dp) == 0 && Objects.equals(paidSios, that.paidSios) && Objects.equals(pendingSios, that.pendingSios) && Objects.equals(offerPayouts, that.offerPayouts);
    }

    @Override
    public int hashCode() {
        return Objects.hash(priceDropAmount, inventoryItemId, paidSios, pendingSios, offerPayouts, fixedAmount, discountAmount, percentageAmount, paidAmount, dp);
    }

    @Override
    public String toString() {
        return "InventoryPayoutModel{" +
                "priceDropAmount=" + priceDropAmount +
                ", inventoryItemId=" + inventoryItemId +
                ", paidSios=" + paidSios +
                ", pendingSios=" + pendingSios +
                ", offerPayouts=" + offerPayouts +
                ", fixedAmount=" + fixedAmount +
                ", discountAmount=" + discountAmount +
                ", percentageAmount=" + percentageAmount +
                ", paidAmount=" + paidAmount +
                ", dp=" + dp +
                '}';
    }
}