BillSummary.java 845 Bytes
package fi.codecrew.moya.bortal.views;

import java.math.BigDecimal;

import fi.codecrew.moya.model.BillLine;

public class BillSummary {

	public BillSummary(String name) {
		this.name = name;
	}

	private String name;
	private BigDecimal active = BigDecimal.ZERO;
	private BigDecimal paid = BigDecimal.ZERO;
	private BigDecimal expired = BigDecimal.ZERO;

	public String getName() {
		return name;
	}

	public BigDecimal getActive() {
		return active;
	}

	public void addLine(BillLine bl) {
		if (bl.getBill().isExpired()) {
			expired = getExpired().add(bl.getQuantity());
		} else {
			active = getActive().add(bl.getQuantity());
			if (bl.getBill().getPaidDate() != null) {
				paid = getPaid().add(bl.getQuantity());
			}
		}
	}

	public BigDecimal getPaid() {
		return paid;
	}

	public BigDecimal getExpired() {
		return expired;
	}

}