package com.ffii.lioner.modules.lioner.reportDao;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class AppreciationChartDataDao {
    
    private String sbuName;
    
    private List<Integer> recordByMonth = Arrays.asList(new Integer[12]);

    public AppreciationChartDataDao(String sbuName){
        this.sbuName = sbuName;
        Collections.fill(recordByMonth, 0);
    }

    public void setRecordByMonthByIndex(Integer value, Integer location){
        recordByMonth.set(location, value);
    }

    public void asAccumulate() {
        Integer month = 0;
        Integer prevCount = 0;
        for (Integer data : recordByMonth) {
            if(month == 0){
                prevCount = data;
                month++;
            }
            else{
                setRecordByMonthByIndex(data + prevCount, month);
                prevCount = data + prevCount;
                month++;
            }
        }
    }
    public Integer calculateSum() {
        Integer sum = 0;
        for (Integer number : recordByMonth) {
            if(number != null){
                sum += number;
            }
        }
        return sum;
    }

    public String getSbuName() {
        return this.sbuName;
    }

    public void setSbuName(String sbuName) {
        this.sbuName = sbuName;
    }

    public List<Integer> getRecordByMonth() {
        return this.recordByMonth;
    }

    public void setRecordByMonth(List<Integer> recordByMonth) {
        this.recordByMonth = recordByMonth;
    }
    

}
