lots of changes to make ledger actually visible.

This commit is contained in:
Bryce Covert
2019-04-11 19:41:41 -07:00
parent d335055de8
commit 9549afb3ef
15 changed files with 454 additions and 55 deletions

View File

@@ -0,0 +1,116 @@
(ns auto-ap.views.pages.ledger.table
(:require [auto-ap.subs :as subs]
[auto-ap.views.components.paginator :refer [paginator]]
[auto-ap.views.components.sorter :refer [sorted-column]]
[auto-ap.views.utils :refer [date->str dispatch-event nf]]
[goog.string :as gstring]
[re-frame.core :as re-frame]))
(defn table [{:keys [id ledger-page status on-params-change vendors params check-boxes checked on-check-changed expense-event]}]
(let [opc (fn [p]
(on-params-change (merge @params p )))]
(fn [{:keys [id ledger-page status on-params-change vendors checked]}]
(let [{:keys [sort-by asc]} @params
{:keys [journal-entries start end count total]} @ledger-page
selected-client @(re-frame/subscribe [::subs/client])
percentage-size (if selected-client "25%" "33%")]
[:div
[paginator {:start start :end end :count count :total total
:on-change (fn [p ]
(on-params-change (merge @params p)))}]
"Showing " (inc start) "-" end "/" total
[:table.table.is-fullwidth
[:thead
[:tr
(when-not selected-client
[sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"}
:sort-key "client"
:sort-by sort-by
:asc asc}
"Client"])
[sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"}
:sort-key "description-original"
:sort-by sort-by
:asc asc}
"Vendor"]
[sorted-column {:on-sort opc
:style {:width "8em" :cursor "pointer"}
:sort-key "date"
:sort-by sort-by
:asc asc}
"Date"]
[sorted-column {:on-sort opc
:style {:width percentage-size :cursor "pointer"}
:sort-key "account"
:sort-by sort-by
:asc asc}
"Account"]
[sorted-column {:on-sort opc
:style {:width "8em" :cursor "pointer"}
:sort-key "amount"
:class "has-text-right"
:sort-by sort-by
:asc asc}
"Debit"]
[sorted-column {:on-sort opc
:style {:width "8em" :cursor "pointer"}
:sort-key "amount"
:class "has-text-right"
:sort-by sort-by
:asc asc}
"Credit"]
[sorted-column {:on-sort opc
:style {:width "8em" :cursor "pointer"}
:sort-key "status"
:sort-by sort-by
:asc asc}
"Status"]]]
[:tbody
(if (:loading @status)
[:tr
[:td {:col-span 5}
[:i.fa.fa-spin.fa-spinner]]]
(->>
(for [{:keys [client vendor status date amount id line-items] :as i} (:journal-entries @ledger-page)]
(into
[^{:key id}
[:tr {:class (:class i)}
(when-not selected-client
[:td (:name client)])
[:td (if vendor
(:name vendor)
(str "Merchant '" "Hello" "'"))]
#_[:td description-original]
[:td (date->str date) ]
[:td ]
[:td.has-text-right (nf amount )]
[:td.has-text-right (nf amount )]
[:td status]]]
(for [{:keys [debit credit account]} line-items]
[:tr {:class (:class i)}
(when-not selected-client
[:td ])
[:td ]
#_[:td description-original]
[:td ]
[:td (:name account)]
[:td.has-text-right (when debit (nf debit ))]
[:td.has-text-right (when credit (nf credit ))]
[:td status]]
)))
(mapcat identity)))]]]))))