use of model.db.Spending in project amos-ss17-alexa by c-i-ber.
the class AmosAlexaSimpleTestImpl method resetTestCategory.
private void resetTestCategory() {
// Delete old test category
List<Category> categories = DynamoDbMapper.getInstance().loadAll(Category.class);
Category category = null;
List<String> testCategoryIds = new ArrayList<>();
for (Category cat : categories) {
if (cat.getName().equals(TEST_CATEGORY_NAME)) {
testCategoryIds.add(cat.getId());
category = cat;
DynamoDbMapper.getInstance().delete(cat);
// DynamoDbClient.instance.deleteItem(Category.TABLE_NAME, cat);
}
}
List<Spending> dbSpendings = dynamoDbMapper.loadAll(Spending.class);
for (Spending spending : dbSpendings) {
String catId;
try {
catId = spending.getCategoryId();
} catch (Exception e) {
continue;
}
if (testCategoryIds.contains(catId)) {
dynamoDbMapper.delete(spending);
}
}
}
use of model.db.Spending in project amos-ss17-alexa by c-i-ber.
the class BudgetManager method getSpendingAmount.
private double getSpendingAmount(String categoryId, DateTime start, DateTime end) {
double sum = 0;
List<Spending> dbSpendings = dynamoDbMapper.loadAll(Spending.class);
for (Spending spending : dbSpendings) {
if (spending.getCategoryId().equals(categoryId)) {
if (spending.getCreationDateTimeAsDateTime().isAfter(start) && spending.getCreationDateTimeAsDateTime().isBefore(end)) {
sum += spending.getAmount();
}
}
}
return sum;
}
Aggregations