Adds lock icon for locked transactions.
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
[auto-ap.graphql.utils :refer [extract-client-ids]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]))
|
||||
[datomic.api :as dc]
|
||||
[clj-time.core :as time]))
|
||||
|
||||
(defn potential-duplicate-ids [db args]
|
||||
(when (and (:potential-duplicates args)
|
||||
@@ -171,10 +172,22 @@
|
||||
true (apply-sort-3 (assoc args :default-asc? false))
|
||||
true (apply-pagination args)))))
|
||||
|
||||
(defn is-locked? [transaction]
|
||||
(let [transaction-date (some-> transaction :transaction/date coerce/to-date-time)
|
||||
bank-account-start-date (some-> transaction :transaction/bank-account :bank-account/start-date coerce/to-date-time)
|
||||
client-locked-until (some-> transaction :transaction/client :client/locked-until coerce/to-date-time)
|
||||
locked-by-client? (cond (not transaction-date) false
|
||||
(not client-locked-until) false
|
||||
:else (time/before? transaction-date client-locked-until))
|
||||
locked-by-bank-account? (cond (not transaction-date) false
|
||||
(not bank-account-start-date) false
|
||||
:else (time/before? transaction-date bank-account-start-date))]
|
||||
(or locked-by-bank-account? locked-by-client?)))
|
||||
|
||||
(defn graphql-results [ids db _]
|
||||
(let [results (->> (pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
||||
(let [results (->> (pull-many db '[* {:transaction/client [:client/name :db/id :client/code :client/locked-until]
|
||||
:transaction/approval-status [:db/ident :db/id]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id :bank-account/locations :bank-account/current-balance]
|
||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id :bank-account/locations :bank-account/current-balance :bank-account/start-date]
|
||||
:transaction/forecast-match [:db/id :forecasted-transaction/identifier]
|
||||
:transaction/vendor [:db/id :vendor/name]
|
||||
:transaction/matched-rule [:db/id :transaction-rule/note]
|
||||
@@ -190,6 +203,7 @@
|
||||
:transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]
|
||||
:transaction/plaid-merchant [:db/id :plaid-merchant/name]}]
|
||||
ids)
|
||||
(map #(assoc % :transaction/is-locked (is-locked? %)))
|
||||
(map #(update % :transaction/date coerce/from-date))
|
||||
(map #(update % :transaction/post-date coerce/from-date))
|
||||
(map #(update % :transaction/accounts
|
||||
|
||||
@@ -571,6 +571,7 @@
|
||||
(def objects
|
||||
{:transaction {:fields {:id {:type :id}
|
||||
:amount {:type 'String}
|
||||
:is_locked {:type 'Boolean}
|
||||
:description_original {:type 'String}
|
||||
:description_simple {:type 'String}
|
||||
:location {:type 'String}
|
||||
|
||||
@@ -222,8 +222,9 @@
|
||||
(map r/as-element (r/children (r/current-component)))))
|
||||
|
||||
(defn cell [params]
|
||||
(apply r/create-element "td" #js {:className (:class params)}
|
||||
(apply r/create-element "td" #js {:className (:class params) :style (some-> (:style params) clj->js)}
|
||||
(map r/as-element (r/children (r/current-component))))
|
||||
|
||||
)
|
||||
|
||||
(defn body []
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
:location
|
||||
:approval-status
|
||||
:check-number
|
||||
:is-locked
|
||||
|
||||
[:matched-rule [:note :id]]
|
||||
[:vendor [:name :id]]
|
||||
[:accounts [:id :amount :location [:account [:name :id :location :numeric-code]]]]
|
||||
|
||||
@@ -59,6 +59,12 @@
|
||||
(fn [db]
|
||||
(::table-params db)))
|
||||
|
||||
(defn lock-icon []
|
||||
[:div {:style {:position "absolute" :width "1em" :height "1em" :left "-1.25rem" :background-color "#E0E0E0" :padding "5px" :box-sizing "content-box" :border-radius "999px" :display "flex" :justify-content "center" :align-content "center" :text-align "center"}}
|
||||
[:div
|
||||
[:i.fa.fa-lock {:style {:color "#333"}}]]])
|
||||
|
||||
|
||||
(defn table [{:keys [data-page check-boxes? action-buttons]}]
|
||||
(let [selected-client @(re-frame/subscribe [::subs/client])
|
||||
{:keys [data params]} @(re-frame/subscribe [::data-page/page data-page])
|
||||
@@ -85,9 +91,16 @@
|
||||
^{:key id}
|
||||
[grid/row {:class (:class i) :id id :entity i}
|
||||
(when-not selected-client
|
||||
[grid/cell {} (:name client)])
|
||||
[grid/cell {:style {:overflow "visible" :position "relative" }}
|
||||
|
||||
(when (:is-locked i)
|
||||
[lock-icon])
|
||||
(:name client)])
|
||||
#_[:td description-original]
|
||||
[grid/cell {}
|
||||
|
||||
(when (and selected-client (:is-locked i))
|
||||
[lock-icon])
|
||||
(:name bank-account)]
|
||||
[grid/cell {} (cond vendor
|
||||
(:name vendor)
|
||||
|
||||
Reference in New Issue
Block a user