 
 (def ^:private *accounts* (r/atom []))
 (def ^:private *commodities* (r/atom []))
-(def ^:private working-transaction (r/atom nil))
-(def ^:private account (r/atom nil))
-(def ^:private transaction-items (r/atom nil))
 
 (defn- delete
   [account]

        (rename-keys rename-map))))

(defn- handle-saved-transaction
  [transaction]
  (reset! working-transaction nil)
  (reset! transaction-items nil)
  (get-items))

(defn- save-transaction []
  (-> @working-transaction
      transform-transaction
      (transactions/create handle-saved-transaction
                           notify/danger)))

(defn- transaction-form []
  (when @working-transaction
    [:div.panel.panel-primary
     [:div.panel-heading
      [:h2.panel-title (if (:id @working-transaction)
                         "Edit Transaction"
                         "New Transaction")]]

     [:div.panel-body
      [bind-fields trx-form working-transaction]
      (util/button "Save"
                   #(save-transaction)
                   {:class "btn btn-primary"
                    :icon :ok
                    :title "Click here to save the transaction"})]]))

(defn- show-account
  [id]
  (reset! transaction-items nil)
  (accounts/get-all (:id @state/current-entity)
                    #(reset! *accounts* (-> % nest unnest))
                    notify/danger)
  (accounts/get-one id
                    (fn [a]
                      (reset! account a)
                      (get-items))
                    notify/danger)
  (with-layout
    [:section
     [:div.row
      [:div.col-md-12
       [account-header]]]
     [:div.row
      [:div.col-md-6
       [transaction-form]]
      [:div.col-md-6
       [:div.panel.panel-default
        [:div.panel-heading
         [:h2.panel-title "Transaction Items"]]
        [:div.panel-body {:style {:height "40em" :overflow "auto"}}
         [items-table transaction-items]]]]]]))

(secretary/defroute new-account-path "/accounts/new" []
  (r/render [new-account] (app-element)))

                       :title "Click here to return to the list of accounts."
                       :icon :ban-circle})]])))

(defn- account-header
  [{:keys [transaction account]}]
  [:section
   [:div.pull-right
    (util/button "New"
                 (fn []
                   (reset! transaction {:account-id (:id @account)
                                                :entity-id (:id @state/current-entity)
                                                :transaction-date (f/unparse (f/formatter "M/d/yyyy") (t/today))})
                   (with-retry
