Subversion Repositories SmartDukaan

Rev

Rev 32021 | Go to most recent revision | 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 {
    int inventoryItemId;
    List<SchemeInOut> paidSios;
    List<SchemeInOut> pendingSios;
    List<OfferPayout> offerPayouts;

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

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

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        InventoryPayoutModel that = (InventoryPayoutModel) o;
        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);
    }

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

    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;
    }


    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, List<SchemeInOut> paidSios, List<SchemeInOut> pendingSios, List<OfferPayout> offerPayouts) {
        this.inventoryItemId = inventoryItemId;
        this.paidSios = paidSios;
        this.pendingSios = pendingSios;
        this.offerPayouts = offerPayouts;
    }

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

    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;
    }
}