             [clj-money.validation :as validation]
             [clj-money.models.accounts :as accounts]
             [clj-money.models.transactions :as transactions]
-            [clj-money.web.money-shared :refer [account-options]]
+            [clj-money.web.money-shared :refer [account-options
+                                                budget-monitors]]
             [clj-money.util :refer [format-date]]
             [clj-money.schema :as schema])
   (:use [clj-money.web.shared :refer :all]))
+
+(defmacro with-transactions-layout
+  [page-title entity-id options & content]
+  `(with-layout
+     ~page-title (assoc ~options :side-bar (budget-monitors ~entity-id))
+     ~@content))
 
 (defn- transaction-row
   "Renders a row in the transaction table"

                     :transaction-date (t/today)}
                    {}))
  ([params transaction options]
   (with-layout "New Transaction" options
     [:div.row
      [:div.col-md-6
       [:form {:action (cond-> (path "/entities"
                                     (:entity-id params)
                                     "transactions")
                         (contains? params :redirect) (query {:redirect (-> params
                                                                            :redirect
                                                                            url-encode)})
                         true format-url)
               :method :post}
        (form-fields transaction (redirect-url (:entity-id params) params))]]])))

(defn- valid-item?
  [{account-id :account-id :as item}]

(defn edit
  ([id-or-trans] (edit id-or-trans {}))
  ([id-or-trans options]
   (let [transaction (if (map? id-or-trans)
                       id-or-trans
                       (transactions/find-by-id (env :db) id-or-trans))
         action (cond-> (path "/transactions"
                              (:id transaction))

                  (:redirect options)
                  (query {:redirect (url-encode (:redirect options))})

                  true
                  format-url)]
     (with-transactions-layout "New Transaction" (:entity-id transaction) options
       [:form {:action action
               :method :post}
        (form-fields transaction (redirect-url (:entity-id transaction) options))]))))

(defn update
  [params]
