コード例 #1
0
 /**
  * Formats the Receipt records in such a way as to be able to display them in a table on the user
  * interface
  *
  * @return A two dimensional Object array of Receipt data that is used for display purposes
  */
 public Object[][] getReceiptData() {
   List<Receipt> receipts = fetchReceipts();
   Collections.sort(receipts);
   Object[][] data = new Object[receipts.size()][ReceiptTabColumns.values().length];
   int counter = 0;
   for (Receipt receipt : receipts) {
     data[counter][ReceiptTabColumns.RECEIPT_DATE.getColumn()] = receipt.getReceiptDate();
     data[counter][ReceiptTabColumns.ADDRESS.getColumn()] =
         AddressProcessUtil.getAddressForReceipt(receipt.getAddress());
     data[counter][ReceiptTabColumns.DESIGNATION.getColumn()] = receipt.getDesignation().getName();
     data[counter][ReceiptTabColumns.AMOUNT.getColumn()] = receipt.getAmount();
     data[counter][ReceiptTabColumns.NOTES.getColumn()] = receipt.getNotes();
     counter++;
   }
   return data;
 }
コード例 #2
0
 /**
  * Creates a TreeMap that contains the yearly report data. The TreeMap is in "receipt address -
  * amount" format For example: "Midcoast Baptist Church (170 Old Portland Rd, Brunswick, ME) -
  * 100.00"
  *
  * @param year The year of the data to report on
  * @return A TreeMap of yearly report data (TreeMap is used to keep the receipt addresses in
  *     alphabetical order)
  */
 TreeMap<String, BigDecimal> createYearlyReportDataMap(String year) {
   AddressFetchProcess addressFetchProcess = new AddressFetchProcess();
   TreeMap<String, BigDecimal> dataMap = new TreeMap<String, BigDecimal>();
   for (Address address : addressFetchProcess.fetchAddresses()) {
     BigDecimal amount = new BigDecimal("0.00");
     for (Receipt receipt : fetchReceipts()) {
       if (address.equals(receipt.getAddress())
           && receipt.getReceiptDate().substring(6).equals(year)) {
         amount = amount.add(new BigDecimal(receipt.getAmount()));
       }
     }
     if (!amount.toPlainString().equals("0.00")) {
       dataMap.put(AddressProcessUtil.getAddressForReceipt(address), amount);
     }
   }
   return dataMap;
 }