
package org.missionassetfund.apps.android.models;

import java.util.Date;

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

@ParseClassName("Transaction")
public class Transaction extends ParseObject {
    public static final String USER_KEY = "user";
    public static final String GOAL_KEY = "goal";
    public static final String CREATED_AT_KEY = "createdAt";
    public static final String AMOUNT_KEY = "amount";
    public static final String DESCRIPTION_KEY = "description";
    public static final String TYPE_KEY = "type";
    public static final String CATEGORY_KEY = "category";

    public Transaction() {
        super();
    }

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

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

    public Goal getGoal() {
        return (Goal) getParseObject(GOAL_KEY);
    }

    public void setGoal(Goal goal) {
        put(GOAL_KEY, goal);
    }

    public Date getCreatedAt() {
        return getDate(CREATED_AT_KEY);
    }

    public void setCreatedAt(Date createdAt) {
        put(CREATED_AT_KEY, createdAt);
    }

    public Float getAmount() {
        return (Float) getNumber(AMOUNT_KEY);
    }

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

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

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

    // TODO: Discuss if hardcode 'type' via an enum or have a dummy Transaction Type Model
    public String getType() {
        return getString(TYPE_KEY);
    }

    public void setType(String type) {
        put(TYPE_KEY, type);
    }

    // TODO: Discuss if hardcode 'category' via an enum or have a dummy
    // Transaction Type Model
    public String getCategory() {
        return getString(CATEGORY_KEY);
    }

    public void setCategory(String category) {
        put(CATEGORY_KEY, category);
    }
}

@@ -597,16 +597,662 @@
 tegory%22;
+%0A    %0A    public enum TransactionType %7B%0A        UNDEFINED(0),%0A        DEBIT(1),%0A        CREDIT(2);%0A        %0A        private int typeValue;%0A        %0A        private TransactionType(int typeValue) %7B%0A            this.typeValue = typeValue;%0A        %7D%0A        %0A        public int toInt() %7B%0A            return typeValue;%0A        %7D%0A        %0A        public static TransactionType getTypeFromInt(int typeValue) %7B%0A            switch (typeValue) %7B%0A                case 1:%0A                    return DEBIT;%0A                case 2:%0A                    return CREDIT;%0A                default:%0A                    return UNDEFINED;%0A            %7D%0A        %7D%0A    %7D
 %0A%0A    pu
@@ -1276,25 +1276,8 @@
 ) %7B%0A
-        super();%0A
     
@@ -2127,71 +2127,14 @@
     
-// TODO: Discuss if hardcode 'type' via an enum or have a dummy
+public
  Tra
@@ -2145,38 +2145,13 @@
 tion
- 
 Type 
-Model%0A    public String 
 getT
@@ -2173,25 +2173,53 @@
  return 
-getString
+TransactionType.getTypeFromInt(getInt
 (TYPE_KE
@@ -2216,24 +2216,25 @@
 nt(TYPE_KEY)
+)
 ;%0A    %7D%0A%0A   
@@ -2254,22 +2254,31 @@
 setType(
-String
+TransactionType
  type) %7B
@@ -2304,16 +2304,24 @@
 EY, type
+.toInt()
 );%0A    %7D

Add TransactionType Enum