private double getThisWeeksOrdersCost() { double totalCost = 0.0; for (PurchasingTransaction order : database.getPurchasingTransactions()) { if (isDateInCurrentWeek(order.getTransactionDate())) totalCost += order.getTransactionCost(); } return totalCost; }
private double getTotalCostOfOrders() { double totalCost = 0.0; for (PurchasingTransaction order : database.getPurchasingTransactions()) { totalCost += order.getTransactionCost(); } return totalCost; }
private double getPercentCostThisWeek() { double weeksCost = 0.0; double totalCost = 0.0; for (PurchasingTransaction order : database.getPurchasingTransactions()) { if (isDateInCurrentWeek(order.getTransactionDate())) { weeksCost += order.getTransactionCost(); } totalCost += order.getTransactionCost(); } return (double) weeksCost / totalCost * 100; }
private double getPercentEarlierCost() { double totalCost = 0.0; double earlierCost = 0.0; for (PurchasingTransaction order : database.getPurchasingTransactions()) { if (!isDateInCurrentWeek(order.getTransactionDate())) { earlierCost += order.getTransactionCost(); } totalCost += order.getTransactionCost(); } return (double) earlierCost / totalCost * 100; }
private int getNoOrdersThisWeek() { int noOrders = 0; // set start of week object to preceding Monday at 00:00:00 Calendar startOfWeek = Calendar.getInstance(); startOfWeek.set(Calendar.DAY_OF_YEAR, (Calendar.DAY_OF_YEAR - Calendar.DAY_OF_WEEK)); for (PurchasingTransaction order : database.getPurchasingTransactions()) { if (isDateInCurrentWeek(order.getTransactionDate())) { noOrders++; } } ordersThisWeek = noOrders; return noOrders; }