        [:div.col-md-3
         [:form {:action (format "/budgets/%s/items" budget-id)
                 :method :post}
-         (select-field item :account-id (account-options (:entity-id budget)) {:autofocus true})
+         (select-field item :account-id (account-options (:entity-id budget) {:types #{:income :expense}}) {:autofocus true})
          (number-input-field item :average)
          [:button.btn.btn-primary {:type :submit
                                    :title "Click here to save this budget item."} "Save"]

     (map #(period-heading budget %) (range 0 (:period-count budget)))
     [:th.text-right "Total"])])

(defn- budget-period-cell
  [period]
  [:td.text-right (format-number (:amount period))])

(defn- budget-item-row
  [budget item]
  [:tr
   (html
     [:td (->> item
               :account-id
               (accounts/find-by-id (env :db))
               :name)]
     (map budget-period-cell (:periods item))
     [:td.text-right (format-number (reduce + 0 (map :amount (:periods item))))])])

(defn show
  "Renders the budet details"
  [id]
  (let [budget (budgets/find-by-id (env :db) id)]
  (layout
    (str "Budget: " (:name budget)) {}
    [:div.row

      [:table.table.table-striped
       (html
       (budget-header-row budget)
       (map budget-item-row (:items budget)))]
      [:a.btn.btn-primary {:href (format "/budgets/%s/items/new" (:id budget))} "Add"]
      "&nbsp;"
      [:a.btn.btn-default {:href (format "/entities/%s/budgets" (:entity-id budget))} "Back"]]])))
