package cn.palmte.work.bean;

import java.math.BigDecimal;

public class SettleBean {

    //========================收入表================================

    /**
     * 设备类决算总额
     */
    private BigDecimal incomeDevice;

    /**
     * 工程类决算总额
     */
    private BigDecimal incomeEngineer;

    /**
     * 服务类决算总额
     */
    private BigDecimal incomeService;

    /**
     * 获取所有收入总额
     *
     * @return
     */
    public BigDecimal getIncomeTotal() {
        BigDecimal incomeDevice = getIncomeDevice();
        BigDecimal incomeEngineer = getIncomeEngineer();
        BigDecimal incomeService = getIncomeService();
        if (null == incomeDevice || null == incomeEngineer || null == incomeService) {
            return new BigDecimal(0);
        }
        return incomeDevice.add(incomeEngineer).add(incomeService);
    }


    //========================成本表================================

    /**
     *设备采购成本决算总额
     */
    private BigDecimal costPurchaseDevice;

    /**
     *施工采购成本决算总额
     */
    private BigDecimal costPurchaseBuild;

    /**
     *服务采购成本决算总额
     */
    private BigDecimal costPurchaseService;

    /**
     *其他采购成本决算总额
     */
    private BigDecimal costPurchaseOther;

    /**
     * 项目管理成本决算总额
     */
    private BigDecimal costProjectManage;

    /**
     * 其他成本决算总额
     */
    private BigDecimal costOther;


    /**
     * 获取所有成本总额
     *
     * @return
     */
    public BigDecimal getCostTotal() {
        BigDecimal costPurchaseDevice = getCostPurchaseDevice();
        BigDecimal costPurchaseBuild = getCostPurchaseBuild();
        BigDecimal costPurchaseService = getCostPurchaseService();
        BigDecimal costPurchaseOther = getCostPurchaseOther();
        BigDecimal costProjectManage = getCostProjectManage();
        BigDecimal costOther = getCostOther();

        if (null == costPurchaseDevice || null == costPurchaseBuild || null == costPurchaseService
                || null == costPurchaseOther || null == costProjectManage || null == costOther) {
            return new BigDecimal(0);
        }

        return costPurchaseDevice.add(costPurchaseBuild).add(costPurchaseService)
                .add(costPurchaseOther).add(costProjectManage).add(costOther);
    }

    /**
     * 获取所有成本总额
     *
     * @return
     */
    public BigDecimal getCostTotal2() {
        BigDecimal costPurchaseDevice = getCostPurchaseDevice();
        BigDecimal costPurchaseBuild = getCostPurchaseBuild();
        BigDecimal costPurchaseService = getCostPurchaseService();
        BigDecimal costPurchaseOther = getCostPurchaseOther();

        if (null == costPurchaseDevice || null == costPurchaseBuild || null == costPurchaseService
                || null == costPurchaseOther) {
            return new BigDecimal(0);
        }

        return costPurchaseDevice.add(costPurchaseBuild).add(costPurchaseService)
                .add(costPurchaseOther);
    }

    //========================管理表================================

    /**
     * 财务费用决算总额
     */
    private BigDecimal costExpropriation;

    /**
     * 公司管理费用决算总额
     */
    private BigDecimal costCompanyManage;

    /**
     * 所得税费用决算总额
     */
    private BigDecimal costIncomeTax;

    public BigDecimal getCostManageTotal() {
        BigDecimal costExpropriation = getCostExpropriation();
        BigDecimal costCompanyManage = getCostCompanyManage();
        BigDecimal costIncomeTax = getCostIncomeTax();

        if (null == costExpropriation || null == costCompanyManage || null == costIncomeTax) {
            return new BigDecimal(0);
        }

        return costExpropriation.add(costCompanyManage).add(costIncomeTax);
    }


    //========================利润率计算表================================

    /**
     * 项目毛利决算总额
     */
    private BigDecimal grossProfit;

    /**
     * 项目毛利利润率
     */
    private BigDecimal grossProfitProfitMargin;

    /**
     * 项目贡献利润决算总额
     */
    private BigDecimal contributionProfit;

    /**
     * 项目贡献利润利润率
     */
    private BigDecimal contributionProfitProfitMargin;

    /**
     * 项目净利润决算总额
     */
    private BigDecimal netProfit;

    /**
     * 项目净利润利润率
     */
    private BigDecimal netProfitProfitMargin;

    //========================结算现金流量表================================

    /**
     * a销售商品、提供劳务收到的现金
     * */
    private BigDecimal saleIncomeCash;
    /**
     * b收到的税费返还
     * */
    private BigDecimal taxReturn;
    /**
     * c其他与经营活动有关的现金【保证金收入】
     */
    private BigDecimal earnestMoneyIncome;
    /**
     * d购买商品、接受劳务支付的现金【设备支出+工程支出】
     */
    private BigDecimal purchaseCost;
    /**
     * e支付的各项税费
     */
    private BigDecimal taxCost;
    /**
     *f支付其他与经营活动有关的现金
     */
    private BigDecimal earnestMoneyCost;
    /**
     * g经营活动产生的现金流量净额
     * g=a+c+b-d-f-e
     */
    private BigDecimal netCashFlow;
    /**
     * h投资活动现金流入
     */
    private BigDecimal cashInflowFromInvestingActivities;
    /**
     * i投资活动现金流出
     */
    private BigDecimal cashOutflowFromInvestingActivities;
    /**
     * j投资活动产生的现金流量净额
     */
    private BigDecimal netCashFromInvestingActivities;
    /**
     * k融资资金流入【垫资计划】
     */
    private BigDecimal financingCapitalInflow;
    /**
     * l融资资金流出【还款计划】
     */
    private BigDecimal financingCapitalOutflow;
    /**
     *m筹资活动产生的现金流量净额
     * m=k-l
     */
    private BigDecimal financingCapitalCashflow;
    /**
     * n货币资金净增加额
     * n=g+j+m
     */
    private BigDecimal netIncreaseMonetaryFunds;

    /**
     * 获取所有现金流量总额
     * @return
     */
    public BigDecimal getCashFlowTotal() {
        BigDecimal saleIncomeCash = getSaleIncomeCash();
        BigDecimal taxReturn = getTaxReturn();
        BigDecimal earnestMoneyIncome = getEarnestMoneyIncome();
        BigDecimal purchaseCost = getPurchaseCost();
        BigDecimal taxCost = getTaxCost();
        BigDecimal earnestMoneyCost = getEarnestMoneyCost();
        BigDecimal netCashFlow = getNetCashFlow();
        BigDecimal cashInflowFromInvestingActivities = getCashInflowFromInvestingActivities();
        BigDecimal cashOutflowFromInvestingActivities = getCashOutflowFromInvestingActivities();
        BigDecimal netCashFromInvestingActivities = getNetCashFromInvestingActivities();
        BigDecimal financingCapitalInflow = getFinancingCapitalInflow();
        BigDecimal financingCapitalOutflow = getFinancingCapitalOutflow();
        BigDecimal financingCapitalCashflow = getFinancingCapitalCashflow();
        BigDecimal netIncreaseMonetaryFunds = getNetIncreaseMonetaryFunds();

        if (null == saleIncomeCash || null == taxReturn || null == earnestMoneyIncome || null == purchaseCost || null == taxCost
                || null == earnestMoneyCost || null == netCashFlow || null == cashInflowFromInvestingActivities ||
                null == cashOutflowFromInvestingActivities || null == netCashFromInvestingActivities ||
                null == financingCapitalInflow || null == financingCapitalOutflow || null == financingCapitalCashflow || null == netIncreaseMonetaryFunds) {
            return new BigDecimal(0);
        }

        return saleIncomeCash.add(taxReturn).add(earnestMoneyIncome).add(purchaseCost).add(taxCost).add(earnestMoneyCost)
                .add(netCashFlow).add(cashInflowFromInvestingActivities).add(cashOutflowFromInvestingActivities).add(netCashFromInvestingActivities)
                .add(financingCapitalInflow).add(financingCapitalOutflow).add(financingCapitalCashflow).add(netIncreaseMonetaryFunds);
    }

    private String projectName;

    protected BigDecimal handleSpecial(BigDecimal src) {
        return null == src ? new BigDecimal(0) : src;
    }

    public BigDecimal getIncomeDevice() {
        return handleSpecial(incomeDevice);
    }

    public void setIncomeDevice(BigDecimal incomeDevice) {
        this.incomeDevice = incomeDevice;
    }

    public BigDecimal getIncomeEngineer() {
        return handleSpecial(incomeEngineer);
    }

    public void setIncomeEngineer(BigDecimal incomeEngineer) {
        this.incomeEngineer = incomeEngineer;
    }

    public BigDecimal getIncomeService() {
        return handleSpecial(incomeService);
    }

    public void setIncomeService(BigDecimal incomeService) {
        this.incomeService = incomeService;
    }

    public BigDecimal getCostPurchaseDevice() {
        return handleSpecial(costPurchaseDevice);
    }

    public void setCostPurchaseDevice(BigDecimal costPurchaseDevice) {
        this.costPurchaseDevice = costPurchaseDevice;
    }

    public BigDecimal getCostPurchaseBuild() {
        return handleSpecial(costPurchaseBuild);
    }

    public void setCostPurchaseBuild(BigDecimal costPurchaseBuild) {
        this.costPurchaseBuild = costPurchaseBuild;
    }

    public BigDecimal getCostPurchaseService() {
        return handleSpecial(costPurchaseService);
    }

    public void setCostPurchaseService(BigDecimal costPurchaseService) {
        this.costPurchaseService = costPurchaseService;
    }

    public BigDecimal getCostPurchaseOther() {
        return handleSpecial(costPurchaseOther);
    }

    public void setCostPurchaseOther(BigDecimal costPurchaseOther) {
        this.costPurchaseOther = costPurchaseOther;
    }

    public BigDecimal getCostProjectManage() {
        return handleSpecial(costProjectManage);
    }

    public void setCostProjectManage(BigDecimal costProjectManage) {
        this.costProjectManage = costProjectManage;
    }

    public BigDecimal getCostOther() {
        if (costOther == null) {
            return BigDecimal.ZERO;
        }
        return handleSpecial(costOther);
    }

    public void setCostOther(BigDecimal costOther) {
        this.costOther = costOther;
    }

    public BigDecimal getCostExpropriation() {
        return handleSpecial(costExpropriation);
    }

    public void setCostExpropriation(BigDecimal costExpropriation) {
        this.costExpropriation = costExpropriation;
    }

    public BigDecimal getCostCompanyManage() {
        return handleSpecial(costCompanyManage);
    }

    public void setCostCompanyManage(BigDecimal costCompanyManage) {
        this.costCompanyManage = costCompanyManage;
    }

    public BigDecimal getCostIncomeTax() {
        return handleSpecial(costIncomeTax);
    }

    public void setCostIncomeTax(BigDecimal costIncomeTax) {
        this.costIncomeTax = costIncomeTax;
    }

    public BigDecimal getGrossProfit() {
        return handleSpecial(grossProfit);
    }

    public void setGrossProfit(BigDecimal grossProfit) {
        this.grossProfit = grossProfit;
    }

    public BigDecimal getGrossProfitProfitMargin() {
        return handleSpecial(grossProfitProfitMargin);
    }

    public void setGrossProfitProfitMargin(BigDecimal grossProfitProfitMargin) {
        this.grossProfitProfitMargin = grossProfitProfitMargin;
    }

    public BigDecimal getContributionProfit() {
        return handleSpecial(contributionProfit);
    }

    public void setContributionProfit(BigDecimal contributionProfit) {
        this.contributionProfit = contributionProfit;
    }

    public BigDecimal getContributionProfitProfitMargin() {
        return handleSpecial(contributionProfitProfitMargin);
    }

    public void setContributionProfitProfitMargin(BigDecimal contributionProfitProfitMargin) {
        this.contributionProfitProfitMargin = contributionProfitProfitMargin;
    }

    public BigDecimal getNetProfit() {
        return handleSpecial(netProfit);
    }

    public void setNetProfit(BigDecimal netProfit) {
        this.netProfit = netProfit;
    }

    public BigDecimal getNetProfitProfitMargin() {
        return handleSpecial(netProfitProfitMargin);
    }

    public void setNetProfitProfitMargin(BigDecimal netProfitProfitMargin) {
        this.netProfitProfitMargin = netProfitProfitMargin;
    }

    public BigDecimal getSaleIncomeCash() {
        return handleSpecial(saleIncomeCash);
    }

    public void setSaleIncomeCash(BigDecimal saleIncomeCash) {
        this.saleIncomeCash = saleIncomeCash;
    }

    public BigDecimal getTaxReturn() {
        return handleSpecial(taxReturn);
    }

    public void setTaxReturn(BigDecimal taxReturn) {
        this.taxReturn = taxReturn;
    }

    public BigDecimal getEarnestMoneyIncome() {
        return handleSpecial(earnestMoneyIncome);
    }

    public void setEarnestMoneyIncome(BigDecimal earnestMoneyIncome) {
        this.earnestMoneyIncome = earnestMoneyIncome;
    }

    public BigDecimal getPurchaseCost() {
        return handleSpecial(purchaseCost);
    }

    public void setPurchaseCost(BigDecimal purchaseCost) {
        this.purchaseCost = purchaseCost;
    }

    public BigDecimal getTaxCost() {
        return handleSpecial(taxCost);
    }

    public void setTaxCost(BigDecimal taxCost) {
        this.taxCost = taxCost;
    }

    public BigDecimal getEarnestMoneyCost() {
        return handleSpecial(earnestMoneyCost);
    }

    public void setEarnestMoneyCost(BigDecimal earnestMoneyCost) {
        this.earnestMoneyCost = earnestMoneyCost;
    }

    public BigDecimal getCashInflowFromInvestingActivities() {
        return handleSpecial(cashInflowFromInvestingActivities);
    }

    public void setCashInflowFromInvestingActivities(BigDecimal cashInflowFromInvestingActivities) {
        this.cashInflowFromInvestingActivities = cashInflowFromInvestingActivities;
    }

    public BigDecimal getCashOutflowFromInvestingActivities() {
        return handleSpecial(cashOutflowFromInvestingActivities);
    }

    public void setCashOutflowFromInvestingActivities(BigDecimal cashOutflowFromInvestingActivities) {
        this.cashOutflowFromInvestingActivities = cashOutflowFromInvestingActivities;
    }

    public BigDecimal getNetCashFromInvestingActivities() {
        return handleSpecial(netCashFromInvestingActivities);
    }

    public void setNetCashFromInvestingActivities(BigDecimal netCashFromInvestingActivities) {
        this.netCashFromInvestingActivities = netCashFromInvestingActivities;
    }

    public BigDecimal getFinancingCapitalInflow() {
        return handleSpecial(financingCapitalInflow);
    }

    public void setFinancingCapitalInflow(BigDecimal financingCapitalInflow) {
        this.financingCapitalInflow = financingCapitalInflow;
    }

    public BigDecimal getFinancingCapitalOutflow() {
        return handleSpecial(financingCapitalOutflow);
    }

    public void setFinancingCapitalOutflow(BigDecimal financingCapitalOutflow) {
        this.financingCapitalOutflow = financingCapitalOutflow;
    }

    public BigDecimal getFinancingCapitalCashflow() {
        return handleSpecial(financingCapitalCashflow);
    }

    public void setFinancingCapitalCashflow(BigDecimal financingCapitalCashflow) {
        this.financingCapitalCashflow = financingCapitalCashflow;
    }

    public BigDecimal getNetIncreaseMonetaryFunds() {
        return handleSpecial(netIncreaseMonetaryFunds);
    }

    public void setNetIncreaseMonetaryFunds(BigDecimal netIncreaseMonetaryFunds) {
        this.netIncreaseMonetaryFunds = netIncreaseMonetaryFunds;
    }

    public BigDecimal getNetCashFlow() {
        return handleSpecial(netCashFlow);
    }

    public void setNetCashFlow(BigDecimal netCashFlow) {
        this.netCashFlow = netCashFlow;
    }

    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }
}
