
package org.missionassetfund.apps.android.models;

import java.io.Serializable;
import java.util.Date;

import org.missionassetfund.apps.android.utils.MAFDateUtils;

import com.parse.ParseClassName;
import com.parse.ParseObject;

@ParseClassName("Goal")
public class Goal extends ParseObject implements Serializable {
    private static final long serialVersionUID = 6160272793326362343L;
    public static final String GOAL_KEY = "goal";

    public static final String USER_KEY = "user";
    public static final String NAME_KEY = "name";
    public static final String DESCRIPTION_KEY = "description";
    public static final String TYPE_KEY = "type";
    public static final String STATUS_KEY = "status";
    public static final String PAYMENT_INTERVAL_KEY = "paymentInterval";
    public static final String AMOUNT_KEY = "amount";
    public static final String PAYMENT_AMOUNT_KEY = "paymentAmount";
    public static final String CURRENT_TOTAL_KEY = "currentTotal";
    public static final String NUM_PAYMENTS_KEY = "numPayments";
    public static final String GOAL_DATE_KEY = "goalDate";
    public static final String GOAL_START_DATE_KEY = "createdAt";

    public Goal() {
    }

    public User getUser() {
        return (User) getParseUser(USER_KEY);
    }

    public void setUser(User user) {
        put(USER_KEY, user);
    }

    public String getName() {
        return getString(NAME_KEY);
    }

    public void setName(String name) {
        put(NAME_KEY, name);
    }

    public String getDescription() {
        return getString(DESCRIPTION_KEY);
    }

    public void setDescription(String description) {
        put(DESCRIPTION_KEY, description);
    }

    public GoalType getType() {
        return GoalType.getTypeFromInt(getInt(TYPE_KEY));
    }

    public void setType(GoalType goalType) {
        put(TYPE_KEY, goalType.toInt());
    }

    public GoalStatus getStatus() {
        return GoalStatus.getTypeFromInt(getInt(STATUS_KEY));
    }

    public void setStatus(GoalStatus goalStatus) {
        put(STATUS_KEY, goalStatus.toInt());
    }

    public GoalPaymentInterval getPaymentInterval() {
        return GoalPaymentInterval.getTypeFromInt(getInt(PAYMENT_INTERVAL_KEY));
    }

    public void setPaymenyInterval(GoalPaymentInterval paymenyInterval) {
        put(PAYMENT_INTERVAL_KEY, paymenyInterval.toInt());
    }

    public Double getAmount() {
        return getDouble(AMOUNT_KEY);
    }

    public void setAmount(Double amount) {
        put(AMOUNT_KEY, amount);
    }

    public Double getPaymentAmount() {
        return getDouble(PAYMENT_AMOUNT_KEY);
    }

    public void setPaymentAmount(Double amount) {
        put(PAYMENT_AMOUNT_KEY, amount);
    }

    public Double getCurrentTotal() {
        return getDouble(CURRENT_TOTAL_KEY);
    }

    public void setCurrentTotal(Double amount) {
        put(CURRENT_TOTAL_KEY, amount);
    }

    public Integer getNumPayments() {
        return (Integer) getNumber(NUM_PAYMENTS_KEY);
    }

    public void setNumPayments(Integer numPayments) {
        put(NUM_PAYMENTS_KEY, numPayments);
    }

    public Date getGoalDate() {
        return getDate(GOAL_DATE_KEY);
    }

    public void setGoalDate(Date goalDate) {
        put(GOAL_DATE_KEY, goalDate);
    }

    public Date getDueDate() {
        int nextPaymentNum = getIdealNumPaymentsTillToday() + 1;
        return MAFDateUtils.addDaysToDate(getCreatedAt(), nextPaymentNum
                * getPaymentInterval().toInt());
    }

    public int getIdealNumPaymentsTillToday() {
        int daysSinceGoalCreation = MAFDateUtils.getDaysSince(getCreatedAt());
        int idealNumPayments = daysSinceGoalCreation / getPaymentInterval().toInt();
        return idealNumPayments;
    }

}

@@ -538,72 +538,8 @@
 e%22;%0A
-    public static final String DESCRIPTION_KEY = %22description%22;%0A
     
@@ -1425,198 +1425,8 @@
  %7D%0A%0A
-    public String getDescription() %7B%0A        return getString(DESCRIPTION_KEY);%0A    %7D%0A%0A    public void setDescription(String description) %7B%0A        put(DESCRIPTION_KEY, description);%0A    %7D%0A%0A
     

Remove unused description