package eu.dnetlib.goldoa.domain;

import com.google.gwt.user.client.rpc.IsSerializable;

import java.util.Date;

/**
 * Created by antleb on 3/8/15.
 */
public class Budget implements IsSerializable {

	public enum Status implements IsSerializable {
		INCOMPLETE("Incomplete", 1),
		SUBMITTED("Submitted", 2),
		INITIALLY_APPROVED("Initially approved", 4),
		APPROVED("Approved", 8),
		REJECTED("Rejected", 16),
		ACCOUNTING_PROCESSING("Processing payment", 32),
		ACCOUNTING_ONHOLD("Processing payment", 64),
		ACCOUNTING_DENIED("Payment denied", 128),
		ACCOUNTING_PAID("Paid", 256),
		EXPIRED("Expired", 512);

		private String value;
		private int code;

		Status(String value, int code) {
			this.value = value;
			this.code = code;
		}

		public String getValue() {
			return value;
		}

		public int getCode() {
			return code;
		}

		public static Status forStatus(int status) {
			if (status == 1)
				return INCOMPLETE;
			else
				return Status.values()[((int) Math.round(Math.log(status)/Math.log(2)))];
		}
	}
	
	private String id;
	private Date date;
	private Date startDate;
	private Date endDate;
	private Float amountRequested;
	private Float amountGranted;
	private Currency currency;
	private Float remaining;
	int statusCode;
	private String user;
	private String organisation;
	private String publisher;
	private BankAccount bankAccount;
	private Float transfer_cost;
	private Float other_cost;
	private Date datePaid;
	private String invoice;

	public Budget() {
	}

	public Budget(String id) {
		this.id = id;
	}

	public Budget(String id, Date date, Date startDate, Date endDate, Float amountRequested, Float amountGranted, Currency currency, Float remaining, int statusCode, String user, String organisation, String publisher, BankAccount bankAccount, Float transfer_cost, Float other_cost, Date datePaid, String invoice) {
		this.id = id;
		this.date = date;
		this.startDate = startDate;
		this.endDate = endDate;
		this.amountRequested = amountRequested;
		this.amountGranted = amountGranted;
		this.currency = currency;
		this.remaining = remaining;
		this.statusCode = statusCode;
		this.user = user;
		this.organisation = organisation;
		this.publisher = publisher;
		this.bankAccount = bankAccount;
		this.transfer_cost = transfer_cost;
		this.other_cost = other_cost;
		this.datePaid = datePaid;
		this.invoice = invoice;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public Date getEndDate() {
		return endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	public Float getAmountRequested() {
		return amountRequested;
	}

	public void setAmountRequested(Float amountRequested) {
		this.amountRequested = amountRequested;
	}

	public Float getAmountGranted() {
		return amountGranted;
	}

	public void setAmountGranted(Float amountGranted) {
		this.amountGranted = amountGranted;
	}

	public Currency getCurrency() {
		return currency;
	}

	public void setCurrency(Currency currency) {
		this.currency = currency;
	}

	public Float getRemaining() {
		return remaining;
	}

	public void setRemaining(Float remaining) {
		this.remaining = remaining;
	}

	public int getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getOrganisation() {
		return organisation;
	}

	public void setOrganisation(String organisation) {
		this.organisation = organisation;
	}

	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public BankAccount getBankAccount() {
		return bankAccount;
	}

	public void setBankAccount(BankAccount bankAccount) {
		this.bankAccount = bankAccount;
	}

	public Float getTransfer_cost() {
		return transfer_cost;
	}

	public void setTransfer_cost(Float transfer_cost) {
		this.transfer_cost = transfer_cost;
	}

	public Float getOther_cost() {
		return other_cost;
	}

	public void setOther_cost(Float other_cost) {
		this.other_cost = other_cost;
	}

	public Date getDatePaid() {
		return datePaid;
	}

	public void setDatePaid(Date datePaid) {
		this.datePaid = datePaid;
	}

	public String getInvoice() {
		return invoice;
	}

	public void setInvoice(String invoice) {
		this.invoice = invoice;
	}
}