package BackEnd;

import java.util.ArrayList;

/*
    BenjaminWilcox
    Jun 9, 2017
    BudgetBuddy
 */
public class GenerateReport
{

    ReportPackage report;
    //saving
    private double savingTotal = 0.00;
    private double savingPercent = 0.00;
    private ArrayList<ReportItem> savingItems = new ArrayList();
    private double spendingTotal = 0.00;
    private double spendingPercent = 0.00;
    private ArrayList<ReportItem> spendingItems = new ArrayList();
    private double livingTotal = 0.00;
    private double livingPercent = 0.00;
    private ArrayList<ReportItem> livingItems = new ArrayList();
    private double investingTotal = 0.00;
    private double investingPercent = 0.00;
    private ArrayList<ReportItem> investingItems = new ArrayList();

    public GenerateReport(ReportPackage p)
    {
        report = p;
        load();
        crunch();
        display();
    }

    private void load()
    {
        System.out.println("loading numbers");
        for (int i = 0; i < report.saving.size(); i++)
        {
            savingItems.add(new ReportItem(report.saving.get(i).getAmount(), report.saving.get(i).getName()));
        }
        for (int i = 0; i < report.spending.size(); i++)
        {
            spendingItems.add(new ReportItem(report.spending.get(i).getAmount(), report.spending.get(i).getName()));
        }
        for (int i = 0; i < report.living.size(); i++)
        {
            livingItems.add(new ReportItem(report.living.get(i).getAmount(), report.living.get(i).getName()));
        }
        for (int i = 0; i < report.investing.size(); i++)
        {
            investingItems.add(new ReportItem(report.saving.get(i).getAmount(), report.saving.get(i).getName()));
        }
    }

    private void crunch()
    {
        System.out.println("crunching numbers");
        for (int i = 0; i < report.saving.size(); i++)
        {
            savingTotal += report.saving.get(i).getAmount();
        }
        for (int i = 0; i < report.spending.size(); i++)
        {
            spendingTotal += report.spending.get(i).getAmount();
        }
        for (int i = 0; i < report.living.size(); i++)
        {
            livingTotal += report.living.get(i).getAmount();
        }
        for (int i = 0; i < report.investing.size(); i++)
        {
            investingTotal += report.investing.get(i).getAmount();
        }
    }

    private void display()
    {
        System.out.println("displaying report");
    }

}
