 (defn edit
   "Renders the edit form for an account"
   [id-or-account]
-  (layout
-    "Edit account" {}
-    (let [account (if (map? id-or-account)
-                    id-or-account
-                    (accounts/find-by-id (env :db) (Integer. id-or-account)))]
+  (let [account (if (map? id-or-account)
+                  id-or-account
+                  (accounts/find-by-id (env :db) (Integer. id-or-account)))]
+    (accounts-layout
+      "Edit account" (:entity-id account) {}
       [:div.row
        [:div.col-md-6
         [:form {:action (format "/accounts/%s" (:id account))

     [:td "&nbsp;"]]
    (map account-and-children-rows accounts)))

(defn index
  "Renders the list of accounts"
  ([entity-id] (index entity-id {}))
  ([entity-id options]
   (layout
     "Accounts" (assoc options :side-bar (budget-monitors entity-id))
     (html
       [:table.table.table-striped
        [:tr
         [:th.col-sm-6 "Name"]
         [:th.col-sm-4.text-right "Balance"]
         [:th.col-sm-2 "&nbsp;"]]
        (let [groups (accounts/select-nested-by-entity-id (env :db) (Integer. entity-id))]
          (map account-rows groups))]
       [:a.btn.btn-primary
        {:href (format "/entities/%s/accounts/new" entity-id)
         :title "Click here to add a new account."}
        "Add"]))))

(defn- transaction-item-row
  [{:keys [transaction-id

  "Renders the new account form"
  ([entity-id] (new-account entity-id {:entity-id entity-id}))
  ([entity-id account]
   (accounts-layout
     "New account" entity-id {}
     [:div.row
      [:div.col-md-6
       [:form {:action (str "/entities/" entity-id "/accounts")
