      [:td.text-right (-> record :value format-number)]
      [:td.text-right
       {:class (if (<= 0 (:gain record)) "gain" "loss")}
-      (-> record :gain format-number)]
-     [:td
-      [:div.btn-group
-       (glyph-button :remove
-                     (format "/transactions/%s/unbuy" (-> record :lot-transactions first :transaction-id))
-                     {:size :extra-small
-                      :data-method :post
-                      :data-confirm "Are you sure you want to undo this purchase?"
-                      :level :danger
-                      :title "Click here to undo this purchase"})]]]
-    (map lot-transaction-row (:lot-transactions record))))
+      (-> record :gain format-number)]]))
+
+(defn- lot-section
+  [record]
+  (html
+    [:div.row
+     [:div.col-sm-12
+      [:table.table.table-striped
+       [:tr
+        [:th.text-right "Shares Owned"]
+        [:th.text-right "Purchase Price"]
+        [:th.text-right "Current Price"]
+        [:th.text-right "Cost"]
+        [:th.text-right "Value"]
+        [:th.text-right "Gain"]]
+       (lot-row record)]]]
+    [:div.row
+     [:div.col-sm-10.col-sm-offset-2
+      (lot-transactions-table (:lot-transactions record))]]))
 
 (defn index
   [{{:keys [account-id commodity-id]} :params}]

  [:tr
   [:td.text-right (-> record :trade-date format-date)]
   [:td.text-right (format "%s%s"
                           (if (= :buy (:action record)) "+" "-")
                           (-> record :shares format-number))]
   [:td.text-right (-> record :price format-number)]
   [:td {:colspan 4} "&nbsp;"]
   [:td
    [:div.btn-group
     (when (= :sell (:action record))
       (glyph-button :remove
                     (format "/transactions/%s/unsell" (-> record :transaction-id))
                     {:size :extra-small
                      :data-method :post
                      :data-confirm "Are you sure you want to undo this sale?"
                      :level :danger
                      :title "Click here to undo this sale."}))]]])

(defn- lot-row
  [record]
  (html
    [:tr
     [:td.text-right (-> record :purchase-date format-date)]
     [:td.text-right (-> record :shares-owned format-number)]
     [:td.text-right (-> record :purchase-price format-number)]
     [:td.text-right (-> record :current-price format-number)]

        commodity (commodities/find-by-id (env :db) (Integer. commodity-id))
        records (reports/lot-report (env :db) (:id account) (:id commodity))]
    (with-lots-layout (format "Lots of %s in %s" (:symbol commodity) (:name account)) (:entity-id account) {}
      (map lot-section records)
      [:a.btn.btn-default {:href (format "/accounts/%s" (:id account))
                           :title "Click here to return to the account page"}
       "Back"])))
