// Path: dhis2-models/src/main/java/com/thoughtworks/dhis/models/DataElementType.java
// @Getter
// public enum DataElementType {
//     ADJUSTMENTS("ADJUSTMENTS"),
//     ADJUSTMENT_REASON("ADJUSTMENT_REASON"),
//     ALLOCATED("ALLOCATED"),
//     ALLOCATION_ID("string", "ALLOCATION_ID"),
//     AMC("AMC"),
//     BREAKAGE("BREAKAGE"),
//     BUFFER_STOCK("BUFFER_STOCK", true),
//     DISPENSED("DISPENSED"),
//     EMERGENCY_ORDERED_AMOUNT("EMERGENCY_ORDERED_AMOUNT"),
//     EMERGENCY_REASON_FOR_ORDER("string", "EMERGENCY_REASON_FOR_ORDER"),
//     EXPIRED("EXPIRED"),
//     FROZEN("FROZEN"),
//     LABEL_REMOVED("LABEL_REMOVED"),
//     MAX_STOCK_QUANTITY("MAX_STOCK_QUANTITY", true),
//     MIN_STOCK_QUANTITY("MIN_STOCK_QUANTITY", true),
//     MISSING("MISSING"),
//     MONTHS_OF_STOCK_ON_HAND("MONTHS_OF_STOCK_ON_HAND"),
//     NUMBER_OF_STOCK_OUT_DAYS("NUMBER_OF_STOCK_OUT_DAYS"),
//     ORDERED_AMOUNT("ORDERED_AMOUNT"),
//     ORDER_ID("string", "ORDER_ID"),
//     OTHERS("OTHERS"),
//     PROJECTED_ORDER_AMOUNT("PROJECTED_ORDER_AMOUNT"),
//     REASON_FOR_ORDER("string", "REASON_FOR_ORDER"),
//     RECEIVED("RECEIVED"),
//     RECEIVE_DATE("string", "RECEIVE_DATE"),
//     RECEIVE_SOURCE("string", "RECEIVE_SOURCE"),
//     SAFETY_STOCK("SAFETY_STOCK"),
//     STOCK_ON_HAND("STOCK_ON_HAND"),
//     TMC("TMC"),
//     VVM_CHANGE("VVM_CHANGE"),
//     WASTED("WASTED");
// 
//     private String type = "int";
//     private String activity;
//     private boolean isIndicator = false;
// 
//     DataElementType(String activity, boolean isIndicator) {
//         this.activity = activity;
//         this.isIndicator = isIndicator;
//     }
// 
//     DataElementType(String type, String activity) {
//         this.type = type;
//         this.activity = activity;
//     }
// 
//     DataElementType(String activity) {
//         this.activity = activity;
//     }
// 
//     public static boolean dataElementActivityExists(String activityString) {
//         return getDataElementStrings(false).contains(activityString.trim());
//     }
// 
//     public static boolean indicatorExists(String activityString) {
//         return getDataElementStrings(true).contains(activityString.trim());
//     }
// 
//     public static List<String> getDataElementStrings(boolean isIndicator) {
//         return from(getDataElementTypes(isIndicator)).transform(new Function<DataElementType, String>() {
//             @Override
//             public String apply(DataElementType input) {
//                 return input.getActivity();
//             }
//         }).toList();
//     }
// 
//     private static List<DataElementType> getDataElementTypes(final boolean isIndicator) {
//         List<DataElementType> types = Lists.newArrayList(DataElementType.values());
//         return from(types).filter(new Predicate<DataElementType>() {
//             @Override
//             public boolean apply(DataElementType input) {
//                 return input.isIndicator() == isIndicator;
//             }
//         }).toList();
//     }
// }


import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.thoughtworks.dhis.models.DataElementType;
import org.clintonhealthaccess.lmis.app.services.Snapshotable;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import lombok.NoArgsConstructor;
import lombok.ToString;
import static com.google.common.collect.FluentIterable.from;
import static com.google.common.collect.ImmutableList.copyOf;
import static com.google.common.collect.Lists.newArrayList;
import android.util.Log;
            @Override
            public CommoditySnapshotValue apply(CommodityAction input) {
                if (receive.isRecievingFromLGA()) {
                    return new CommoditySnapshotValue(input, quantityReceived, getAllocationPeriod());
                } else {
                    return new CommoditySnapshotValue(input, quantityReceived);
                }
            }
        };
        Function<CommodityAction, CommoditySnapshotValue> forReceiveDateAction = new Function<CommodityAction, CommoditySnapshotValue>() {
            @Override
            public CommoditySnapshotValue apply(CommodityAction input) {
                String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());

                if (receive.isRecievingFromLGA()) {
                    return new CommoditySnapshotValue(input, today, getAllocationPeriod());
                } else {
                    return new CommoditySnapshotValue(input, today);
                }
            }
        };

        Function<CommodityAction, CommoditySnapshotValue> forReceivedSource = new Function<CommodityAction, CommoditySnapshotValue>() {
            @Override
            public CommoditySnapshotValue apply(CommodityAction input) {
                String source = receive.getSource();
                return new CommoditySnapshotValue(input, source);
            }
        };

// Path: dhis2-models/src/main/java/com/thoughtworks/dhis/models/DataElementType.java
// @Getter
// public enum DataElementType {
//     ADJUSTMENTS("ADJUSTMENTS"),
//     ADJUSTMENT_REASON("ADJUSTMENT_REASON"),
//     ALLOCATED("ALLOCATED"),
//     ALLOCATION_ID("string", "ALLOCATION_ID"),
//     AMC("AMC"),
//     BREAKAGE("BREAKAGE"),
//     BUFFER_STOCK("BUFFER_STOCK", true),
//     DISPENSED("DISPENSED"),
//     EMERGENCY_ORDERED_AMOUNT("EMERGENCY_ORDERED_AMOUNT"),
//     EMERGENCY_REASON_FOR_ORDER("string", "EMERGENCY_REASON_FOR_ORDER"),
//     EXPIRED("EXPIRED"),
//     FROZEN("FROZEN"),
//     LABEL_REMOVED("LABEL_REMOVED"),
//     MAX_STOCK_QUANTITY("MAX_STOCK_QUANTITY", true),
//     MIN_STOCK_QUANTITY("MIN_STOCK_QUANTITY", true),
//     MISSING("MISSING"),
//     MONTHS_OF_STOCK_ON_HAND("MONTHS_OF_STOCK_ON_HAND"),
//     NUMBER_OF_STOCK_OUT_DAYS("NUMBER_OF_STOCK_OUT_DAYS"),
//     ORDERED_AMOUNT("ORDERED_AMOUNT"),
//     ORDER_ID("string", "ORDER_ID"),
//     OTHERS("OTHERS"),
//     PROJECTED_ORDER_AMOUNT("PROJECTED_ORDER_AMOUNT"),
//     REASON_FOR_ORDER("string", "REASON_FOR_ORDER"),
//     RECEIVED("RECEIVED"),
//     RECEIVE_DATE("string", "RECEIVE_DATE"),
//     RECEIVE_SOURCE("string", "RECEIVE_SOURCE"),
//     SAFETY_STOCK("SAFETY_STOCK"),
//     STOCK_ON_HAND("STOCK_ON_HAND"),
//     TMC("TMC"),
//     VVM_CHANGE("VVM_CHANGE"),
//     WASTED("WASTED");
// 
//     private String type = "int";
//     private String activity;
//     private boolean isIndicator = false;
// 
//     DataElementType(String activity, boolean isIndicator) {
//         this.activity = activity;
//         this.isIndicator = isIndicator;
//     }
// 
//     DataElementType(String type, String activity) {
//         this.type = type;
//         this.activity = activity;
//     }
// 
//     DataElementType(String activity) {
//         this.activity = activity;
//     }
// 
//     public static boolean dataElementActivityExists(String activityString) {
//         return getDataElementStrings(false).contains(activityString.trim());
//     }
// 
//     public static boolean indicatorExists(String activityString) {
//         return getDataElementStrings(true).contains(activityString.trim());
//     }
// 
//     public static List<String> getDataElementStrings(boolean isIndicator) {
//         return from(getDataElementTypes(isIndicator)).transform(new Function<DataElementType, String>() {
//             @Override
//             public String apply(DataElementType input) {
//                 return input.getActivity();
//             }
//         }).toList();
//     }
// 
//     private static List<DataElementType> getDataElementTypes(final boolean isIndicator) {
//         List<DataElementType> types = Lists.newArrayList(DataElementType.values());
//         return from(types).filter(new Predicate<DataElementType>() {
//             @Override
//             public boolean apply(DataElementType input) {
//                 return input.isIndicator() == isIndicator;
//             }
//         }).toList();
//     }
// }


// Path: app/src/main/java/org/clintonhealthaccess/lmis/app/models/ReceiveItem.java
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.thoughtworks.dhis.models.DataElementType;
import org.clintonhealthaccess.lmis.app.services.Snapshotable;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import lombok.NoArgsConstructor;
import lombok.ToString;
import static com.google.common.collect.FluentIterable.from;
import static com.google.common.collect.ImmutableList.copyOf;
import static com.google.common.collect.Lists.newArrayList;
import android.util.Log;

            @Override
            public CommoditySnapshotValue apply(CommodityAction input) {
                if (receive.isRecievingFromLGA()) {
                    return new CommoditySnapshotValue(input, quantityReceived, getAllocationPeriod());
                } else {
                    return new CommoditySnapshotValue(input, quantityReceived);
                }
            }
        };
        Function<CommodityAction, CommoditySnapshotValue> forReceiveDateAction = new Function<CommodityAction, CommoditySnapshotValue>() {
            @Override
            public CommoditySnapshotValue apply(CommodityAction input) {
                String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());

                if (receive.isRecievingFromLGA()) {
                    return new CommoditySnapshotValue(input, today, getAllocationPeriod());
                } else {
                    return new CommoditySnapshotValue(input, today);
                }
            }
        };

        Function<CommodityAction, CommoditySnapshotValue> forReceivedSource = new Function<CommodityAction, CommoditySnapshotValue>() {
            @Override
            public CommoditySnapshotValue apply(CommodityAction input) {
                String source = receive.getSource();
                return new CommoditySnapshotValue(input, source);
            }
        };

        List<CommoditySnapshotValue> receivedValues = filterCommodityActions(DataElementType.RECEIVED.getActivity()).transform(forReceivedAction).toList();