minor fixes.

This commit is contained in:
Bryce Covert
2020-07-17 12:46:44 -07:00
parent 976cd1e7c3
commit 3737cfa628
6 changed files with 348 additions and 148 deletions

View File

@@ -117,7 +117,7 @@
'[?e2 :transaction/amount ?a2] '[?e2 :transaction/amount ?a2]
'[?e2 :transaction/bank-account ?ba] '[?e2 :transaction/bank-account ?ba]
'[(auto-ap.utils/dollars= ?a1 ?a2)] '[(auto-ap.utils/dollars= ?a1 ?a2)]
'(not [?e2 :transaction/type])]} '[?e2 :transaction/type]]}
:args [(d/since (d/db (d/connect uri)) #inst "2020-04-01")]}) :args [(d/since (d/db (d/connect uri)) #inst "2020-04-01")]})
vec vec
(map (fn [[e1 e2]] (map (fn [[e1 e2]]
@@ -127,23 +127,27 @@
:transaction/date :transaction/id :transaction/amount :transaction/date :transaction/id :transaction/amount
:transaction/description-original :transaction/description-original
:transaction/approval-status :transaction/approval-status
:transaction/type
{:transaction/client [:client/code]} {:transaction/client [:client/code]}
{:transaction/bank-account [:bank-account/code]} {:transaction/bank-account [:bank-account/code]}
{:journal-entry/_original-entity ['*]}] #_{:journal-entry/_original-entity ['*]}]
e1) e1)
(d/pull (d/db (d/connect uri)) (d/pull (d/db (d/connect uri))
[:db/id [:db/id
:transaction/date :transaction/id :transaction/amount :transaction/date :transaction/id :transaction/amount
:transaction/description-original :transaction/description-original
:transaction/type
:transaction/approval-status :transaction/approval-status
{:transaction/client [:client/code]} {:transaction/client [:client/code]}
{:transaction/bank-account [:bank-account/code]} {:transaction/bank-account [:bank-account/code]}
{:journal-entry/_original-entity ['*]}] #_{:journal-entry/_original-entity ['*]}]
e2) e2)
])) ]))
)) ))
(count matches-to-repair2) (count (filter #(= "SCSJ" (:client/code (:transaction/client (first %)))) matches-to-repair2))
(sha-256 (str "2020-05-08" "-" "SCSJ-USBMAIN2974" "-" "CHECK-5075" "-" "5000.0" "-" "0" "-" "SCSJ"))
(defn repair-transaction [[t-auto t-manual]] (defn repair-transaction [[t-auto t-manual]]
(into (into
@@ -158,7 +162,171 @@
(defn map-new-transaction-id [[t-auto t-manual]] (defn map-new-transaction-id [[t-auto t-manual]]
[[:db/add (:db/id t-manual) :transaction/id (:transaction/id t-auto)]]) [[:db/add (:db/id t-manual) :transaction/id (:transaction/id t-auto)]])
(map-new-transaction-id (first matches-to-repair)) #_(map-new-transaction-id (first matches-to-repair))
(doseq [t matches-to-repair] #_(doseq [t matches-to-repair]
@(d/transact (d/connect uri) (map-new-transaction-id t))) @(d/transact (d/connect uri) (map-new-transaction-id t)))
#_(comment
(get-accounts)
(get-provider-accounts)
(update-provider-account 18611904)
(get-provider-account-detail 11194727)
(get-specific-transactions 24370737)
[{"field" [
{"id" "SQandA--QUESTION_1-12370368"
"value" "Oprah"}
{"id" "SQandA--QUESTION_1-12369757"
"value" "Betelgeuse"}] }]
(perform-additional-authentication 18611904 {"loginForm" {"row"
[{"field" [{"id" "SQandA--txtAlphaNum--1"
"value" "Christian"}]}]}})
{"field" [{"id" "SQandA--QUESTION_1-12370368"
"value" "Oprah"}
{"id" "SQandA--QUESTION_1-12369757"
"value" "Betelgeuse"}]}
(json/write-str )
*e
(get-provider-accounts-with-accounts)
(get-provider-account-detail 18611901)
@(d/transact (d/connect uri) (fix-transactions-without-locations "NGE1" "UC"))
(->> (d/query {:query {:find ['?e '?tx '?yai '?d]
:in ['$]
:where ['[?e :bank-account/yodlee-account-id ?yai ?tx true]
'[?tx :db/txInstant ?d]]}
:args [(d/history (d/db (d/connect uri)))]})
(filter (fn [[_ _ y]]
(not= y 0)))
(group-by first)
(filter (fn [[k v]]
(> (count v) 1)))
(map (fn [[k vs]]
(let [[yodlee-id & old] (->> vs
(sort-by second)
(map (fn [[_ _ yodlee-id date]]
[yodlee-id date]))
(reverse))]
[k {:new-yodlee-id yodlee-id
:defunct-yodlee-ids (clojure.set/difference (set old) #{yodlee-id})}])))
(mapv (fn [[bank-account history]]
(d/query {:query {:find '[?t] #_['(pull $2 ?t [*]) '(pull $2 ?t2 [*])]
:in ['$ '$2 '?bank-account '?before]
:where ['[?t :transaction/bank-account ?bank-account]
'[?t :transaction/date ?date]
'[?t :transaction/amount ?tx-amount ?tx true]
'[?tx :db/txInstant ?tx-date]
'[(< ?tx-date ?before)]
'[?t2 :transaction/bank-account ?bank-account]
'[?t2 :transaction/amount ?tx-amount2 ?tx2 true]
'[?tx2 :db/txInstant ?tx2-date]
'[?t2 :transaction/date ?date]
'[(auto-ap.utils/dollars= ?tx-amount ?tx-amount2)]
'[(not= ?t ?t2)]
'[(> ?tx2-date ?before)]
]}
:args [(d/history (d/db (d/connect uri))) (d/db (d/connect uri)) bank-account (second (:new-yodlee-id history))]})))
)
20186866 24265567 24370736
(auto-ap.yodlee.core/get-specific-transactions 24265567)
(def bad-account-ids (->> (d/query {:query {:find ['?e '?tx '?yai '?d]
:in ['$]
:where ['[?e :bank-account/yodlee-account-id ?yai ?tx true]
'[?tx :db/txInstant ?d]]}
:args [(d/history (d/db (d/connect uri)))]})
(filter (fn [[_ _ y]]
(not= y 0)))
(group-by first)
(filter (fn [[k v]]
(> (count v) 1)))
(keys)))
(count
(->> (d/query {:query {:find ['?bank-account '?date '?tx-amount '?tx-account]
:in ['$]
:where ['[?t :transaction/client [:client/code "NGO"]]
'[?t :transaction/bank-account ?bank-account]
'[?t :transaction/date ?date]
'[?t :transaction/amount ?tx-amount ]
'[?t :transaction/account-id ?tx-account ]
]}
:args [(d/db (d/connect uri))]})
(group-by (fn [[ba date amount _]]
[ba date amount]))
(mapv (fn [[k v]]
[k (set (map last v))]))
(filter (fn [[k v]]
(> (count v) 1)))))
;; FINDS TRANSACTIONS THAT COME FROM DIFFERENT YODLEE IDS
(reduce
(fn [acc [k v]]
(update acc k conj v)
)
{}
(mapcat (fn [ba]
(->> (d/query {:query {:find ['?code '?date '?tx-amount '?t '?tx-account ]
:in ['$ '?bank-account]
:where ['[?t :transaction/bank-account ?bank-account]
'[?bank-account :bank-account/code ?code]
'[?t :transaction/date ?date]
'[?t :transaction/amount ?tx-amount ]
'[?t :transaction/account-id ?tx-account ]
'[(>= ?date #inst "2020-01-01")]
]}
:args [(d/db (d/connect uri) ) ba]})
(group-by (fn [[ba date amount _]]
[ba date amount]))
(filter (fn [[k v]]
(> (count (set (map last v))) 1)))
(map second)
(mapcat identity)
(map (fn [[ba _ _ id act]]
[[ba act] id]))
#_(map (fn [[_ []]]))
#_(mapv (fn [[k v]]
[k (reduce
(fn [acc [_ _ _ act id]]
(assoc acc act id ))
{}
v)]))
#_(map second)
))
bad-account-ids))
;; delete
(->> (d/pull-many (d/db (d/connect uri)) '[:db/id {:journal-entry/_original-entity [:db/id]}] '(17592232564344))
(mapcat (fn [x]
[[:db/retractEntity (:db/id x)]
[:db/retractEntity (:db/id (first (:journal-entry/_original-entity x)))]]))
(d/transact (d/connect uri) )
deref))

View File

@@ -58,53 +58,58 @@
(or (:db/ident (:account/type (accounts a))) (or (:db/ident (:account/type (accounts a)))
({:bank-account-type/check :account-type/asset ({:bank-account-type/check :account-type/asset
:bank-account-type/credit :account-type/liability} :bank-account-type/credit :account-type/liability}
(:db/ident (:bank-account/type (bank-accounts a))))))] (:db/ident (:bank-account/type (bank-accounts a))))))
(->> (d/query all-ledger-entries (->> (d/query
{:query {:find ['?d '?jel '?account '?location '?debit '?credit ] {:query {:find ['?d '?jel '?account '?location '?debit '?credit ]
:in ['$ '?client-id] :in ['$ '?client-id]
:where ['[?e :journal-entry/client ?client-id] :where ['[?e :journal-entry/client ?client-id]
'[?e :journal-entry/date ?d] '[?e :journal-entry/date ?d]
'[(<= ?d #inst "2020-09-01")] '[(<= ?d #inst "2020-09-01")]
'[?e :journal-entry/line-items ?jel] '[?e :journal-entry/line-items ?jel]
'[(get-else $ ?jel :journal-entry-line/account :account/unknown) ?account] '[(get-else $ ?jel :journal-entry-line/account :account/unknown) ?account]
'[(get-else $ ?jel :journal-entry-line/debit 0.0) ?debit] '[(get-else $ ?jel :journal-entry-line/debit 0.0) ?debit]
'[(get-else $ ?jel :journal-entry-line/credit 0.0) ?credit] '[(get-else $ ?jel :journal-entry-line/credit 0.0) ?credit]
'[(get-else $ ?jel :journal-entry-line/location "") ?location]] '[(get-else $ ?jel :journal-entry-line/location "") ?location]]
} }
:args [(d/db (d/connect uri)) client-id]}) :args [(d/db (d/connect uri)) client-id]})
(sort-by first) (sort-by first))]
(reduce (reduce
(fn [acc [_ _ account location debit credit]] (fn [acc bracket]
(-> acc (println (first all-ledger-entries))
(update-in [[location account] :debit] (fnil + 0.0) debit) (assoc acc bracket (->> all-ledger-entries
(update-in [[location account] :credit] (fnil + 0.0) credit) (filter (fn [[d]]
(update-in [[location account] :count] (fnil + 0) 1)) (<= (compare d bracket) 0)))
) (reduce
{}) (fn [acc [_ _ account location debit credit]]
(reduce-kv (-> acc
(fn [acc [location account] {:keys [debit credit count]}] (update-in [[location account] :debit] (fnil + 0.0) debit)
(let [account-type (account->type account)] (update-in [[location account] :credit] (fnil + 0.0) credit)
(conj acc {:name (if-not (= "A" location) (update-in [[location account] :count] (fnil + 0) 1))
(str (account->name account) "-" location) )
(account->name account)) {})
:id (str account "-" location) (reduce-kv
:numeric_code (account->numeric-code account) (fn [acc [location account] {:keys [debit credit count]}]
:location (or location "") (let [account-type (account->type account)]
:amount (if account-type (if (#{:account-type/asset (conj acc {:name (if-not (= "A" location)
:account-type/dividend (str (account->name account) "-" location)
:account-type/expense} account-type) (account->name account))
(- debit credit) :id (str account "-" location)
(- credit debit) :numeric_code (account->numeric-code account)
) :location (or location "")
0.0) :amount (if account-type (if (#{:account-type/asset
:account_type account-type})) :account-type/dividend
) :account-type/expense} account-type)
(- debit credit)
(- credit debit)
)
0.0)
:account_type account-type}))
)
[]) []))))
#_(map (juxt :name :count (comp int :amount))) {}
#_(sort-by first) brackets))
))
) )
;; 9804 ;; 9804

View File

@@ -137,13 +137,13 @@
(defn sum-outstanding [ids] (defn sum-outstanding [ids]
(->> (->>
(d/query {:query {:find ['?o] (d/query {:query {:find ['?id '?o]
:in ['$ '[?id ...]] :in ['$ '[?id ...]]
:where ['[?id :invoice/outstanding-balance ?o]] :where ['[?id :invoice/outstanding-balance ?o]]
} }
:args [(d/db (d/connect uri)) :args [(d/db (d/connect uri))
ids]}) ids]})
(map first) (map last)
(reduce (reduce
+ +
0.0))) 0.0)))

View File

@@ -282,6 +282,7 @@
:body (json/write-str data) :body (json/write-str data)
:as :json})) :as :json}))
(refresh-provider-account pa))) (refresh-provider-account pa)))
#_(defn get-users [] #_(defn get-users []
(let [cob-session (login-cobrand)] (let [cob-session (login-cobrand)]
(-> "https://developer.api.yodlee.com/ysl/user" (-> "https://developer.api.yodlee.com/ysl/user"

View File

@@ -6,7 +6,7 @@
[goog.string :as gstring] [goog.string :as gstring]
[auto-ap.utils :refer [dollars-0? by ]] [auto-ap.utils :refer [dollars-0? by ]]
[auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]] [auto-ap.views.pages.ledger.side-bar :refer [ledger-side-bar]]
[auto-ap.views.utils :refer [date->str date-picker bind-field standard dispatch-event local-now ->% ->$ str->date with-user]] [auto-ap.views.utils :refer [date->str date-picker bind-field standard pretty dispatch-event local-now ->% ->$ str->date with-user]]
[cljs-time.core :as t] [cljs-time.core :as t]
[re-frame.core :as re-frame])) [re-frame.core :as re-frame]))
(def ranges (def ranges
@@ -172,7 +172,6 @@
(re-frame/reg-event-fx (re-frame/reg-event-fx
::params-change ::params-change
(fn [cofx [_ params]] (fn [cofx [_ params]]
(println params)
(let [c @(re-frame/subscribe [::subs/client])] (let [c @(re-frame/subscribe [::subs/client])]
(cond-> {:db (-> (:db cofx) (cond-> {:db (-> (:db cofx)
(assoc-in [::error] nil) (assoc-in [::error] nil)
@@ -302,48 +301,65 @@
(set) (set)
(sort-by :numeric-code))) (sort-by :numeric-code)))
(defn map-periods [for-every between periods]
(defn grouping [{:keys [header type groupings location]}] (for [[_ i] (map vector periods (range))]
(let [periods @(re-frame/subscribe [::periods]) ^{:key (str "period-" i)}
all-accounts @(re-frame/subscribe [::all-accounts])]
[:<> [:<>
(doall (with-meta
(for [[grouping-name from to] groupings (for-every i)
:let [account-codes (used-accounts all-accounts [from to] location)] {:key i})
:when (seq account-codes)] (if (not= 0 i)
^{:key grouping-name} (with-meta (between i)
[:<> {:key (str "between-" i)}))]))
[:tr [:td "---" grouping-name "---"]
(for [[_ i] (map vector periods (range))]
[:<>
[:td]
[:td]
(when (not= 0 i)
[:td])])]
[:<>
(for [{:keys [numeric-code name]} account-codes]
^{:key numeric-code}
[:tr [:td name]
(for [[p i] (map vector periods (range))
:let [amount (get-in all-accounts [i [numeric-code location] :amount] 0.0)]]
[:<>
[:td.has-text-right [:a {:on-click (dispatch-event [::investigate-clicked location numeric-code numeric-code i :current])}
(->$ amount)]]
[:td.has-text-right (->% (percent-of-sales amount all-accounts i location))]
(when (not= 0 i)
[:td.has-text-right (->$ (- amount
(get-in all-accounts [(dec i) [numeric-code location] :amount] 0.0)))])])])]
[:tr [:th ]
(for [[p i] (map vector periods (range)) (defn grouping [{:keys [header type groupings location periods all-accounts]}]
:let [amount (aggregate-accounts (filter-accounts all-accounts i [from to] location))]] [:<>
[:<> (doall
[:th.has-text-right.total [:a {:on-click (dispatch-event [::investigate-clicked location from to i])} (for [[grouping-name from to] groupings
(->$ amount)]] :let [account-codes (used-accounts all-accounts [from to] location)]
[:th.has-text-right.total (->% (percent-of-sales amount all-accounts i location))] :when (seq account-codes)]
(when (not= 0 i) ^{:key grouping-name}
[:th.has-text-right.total (->$ (- amount [:<>
(aggregate-accounts (filter-accounts all-accounts (dec i) [from to] location))))])])]]))])) [:tr [:td "---" grouping-name "---"]
(map-periods
(fn [i]
[:<>
[:td]
[:td]])
(fn [i]
[:td])
periods)]
[:<>
(for [{:keys [numeric-code name]} account-codes]
^{:key numeric-code}
[:tr
[:td name]
(map-periods
(fn [i]
(let [amount (get-in all-accounts [(dec i) [numeric-code location] :amount] 0.0)]
[:<>
[:td.has-text-right [:a {:on-click (dispatch-event [::investigate-clicked location numeric-code numeric-code i :current])}
(->$ amount)]]
[:td.has-text-right (->% (percent-of-sales amount all-accounts i location))]]))
(fn [i]
[:td.has-text-right (->$ (- (get-in all-accounts [(dec i) [numeric-code location] :amount] 0.0)
(get-in all-accounts [(dec i) [numeric-code location] :amount] 0.0)))])
periods)])]
[:tr
[:th]
(map-periods
(fn [i]
(let [amount (aggregate-accounts (filter-accounts all-accounts i [from to] location))]
[:<>
[:th.has-text-right.total [:a {:on-click (dispatch-event [::investigate-clicked location from to i])}
(->$ amount)]]
[:th.has-text-right.total (->% (percent-of-sales amount all-accounts i location))]]))
(fn [i]
[:th.has-text-right.total (->$ (- (aggregate-accounts (filter-accounts all-accounts i [from to] location))
(aggregate-accounts (filter-accounts all-accounts (dec i) [from to] location))))])
periods)]]))])
@@ -356,42 +372,49 @@
[:tr [:th.is-size-5 title]] [:tr [:th.is-size-5 title]]
[grouping {:location location [grouping {:location location
:groupings (type groupings)}] :groupings (type groupings)
:periods periods
:all-accounts all-accounts}]
[:tr [:th.is-size-5 title] [:tr [:th.is-size-5 title]
(for [[i p] (map vector (range) periods) (map-periods
:let [amount (aggregate-accounts (filter-accounts all-accounts i [min-numeric-code max-numeric-code] location))]] (fn [i]
(let [amount (aggregate-accounts (filter-accounts all-accounts i [min-numeric-code max-numeric-code] location))]
[:<> [:<>
[:th.has-text-right [:a [:th.has-text-right [:a
{:on-click (dispatch-event [::investigate-clicked location min-numeric-code max-numeric-code i])} {:on-click (dispatch-event [::investigate-clicked location min-numeric-code max-numeric-code i])}
(->$ amount)]] (->$ amount)]]
[:th.has-text-right (->% (percent-of-sales amount all-accounts i location))] [:th.has-text-right (->% (percent-of-sales amount all-accounts i location))]
(when (not= 0 i) ]))
[:th.has-text-right (->$ (- amount (fn [i]
(aggregate-accounts (filter-accounts all-accounts (dec i) [min-numeric-code max-numeric-code] location))))])])]])) [:th.has-text-right (->$ (- (aggregate-accounts (filter-accounts all-accounts i [min-numeric-code max-numeric-code] location))
(aggregate-accounts (filter-accounts all-accounts (dec i) [min-numeric-code max-numeric-code] location))))])
periods)]]))
(defn subtotal [types negs title location] (defn subtotal [types negs title location]
(let [all-accounts @(re-frame/subscribe [::all-accounts]) (let [all-accounts @(re-frame/subscribe [::all-accounts])
periods @(re-frame/subscribe [::periods])] periods @(re-frame/subscribe [::periods])]
[:tr [:th.is-size-5 title] [:tr [:th.is-size-5 title]
(for [[p i] (map vector periods (range)) (map-periods
:let [amount (aggregate-accounts (mapcat (fn [t] (fn [i]
(cond->> (filter-accounts all-accounts i (ranges t) location) (let [amount (aggregate-accounts (mapcat (fn [t]
(negs t) (map #(update % :amount -)))) (cond->> (filter-accounts all-accounts i (ranges t) location)
types))]] (negs t) (map #(update % :amount -))))
[:<> types))]
[:td.has-text-right [:span (->$ amount)]] [:<>
[:td.has-text-right (->% (percent-of-sales amount all-accounts i location))] [:td.has-text-right [:span (->$ amount)]]
(when (not= 0 i) [:td.has-text-right (->% (percent-of-sales amount all-accounts i location))]]))
[:td.has-text-right (->$ (- amount (fn [i]
(aggregate-accounts (mapcat (fn [t] [:td.has-text-right (->$ (- (aggregate-accounts (mapcat (fn [t]
(cond->> (filter-accounts all-accounts (dec i) (ranges t) location) (cond->> (filter-accounts all-accounts i (ranges t) location)
(negs t) (map #(update % :amount -)))) (negs t) (map #(update % :amount -))))
types))))] types))
) (aggregate-accounts (mapcat (fn [t]
])])) (cond->> (filter-accounts all-accounts (dec i) (ranges t) location)
(negs t) (map #(update % :amount -))))
types))))])
periods)]))
(defn location-rows [location] (defn location-rows [location]
@@ -416,13 +439,16 @@
[:tbody [:tbody
[:tr [:tr
[:td.has-text-right "Period ending"] [:td.has-text-right "Period ending"]
(for [[[_ date] i] (map vector periods (range))] (map-periods
[:<> (fn [i]
[:td.has-text-right (when date [:<>
(date->str date))] [:td.has-text-right (when-let [ date (get-in periods [i 1])]
[:td] (date->str date))]
(when (not= 0 i) [:td]
[:td])])] ])
(fn [i]
[:td])
periods)]
[subtotal [:sales ] #{} "Sales" location] [subtotal [:sales ] #{} "Sales" location]
[subtotal [:cogs ] #{} "Cogs" location] [subtotal [:cogs ] #{} "Cogs" location]
[subtotal [:payroll ]#{} "Payroll" location] [subtotal [:payroll ]#{} "Payroll" location]
@@ -456,7 +482,7 @@
[:h2.title.is-4 "Range"] [:h2.title.is-4 "Range"]
[:div [:div
[:div.field.is-grouped [:div.field.is-grouped
[:p.control [:div.control
[:a.button [:a.button
{:class (when (= (:selected params) "13 periods") "is-active") {:class (when (= (:selected params) "13 periods") "is-active")
:on-click (dispatch-event :on-click (dispatch-event
@@ -473,7 +499,7 @@
"13 periods"])} "13 periods"])}
"13 periods"]] "13 periods"]]
[:p.control [:div.control
[:a.button [:a.button
{:class (when (= (:selected params) "Last week") "is-active") {:class (when (= (:selected params) "Last week") "is-active")
:on-click (dispatch-event :on-click (dispatch-event
@@ -485,7 +511,7 @@
(and-last-year [(t/minus last-sunday (t/period :days 6)) last-sunday]) (and-last-year [(t/minus last-sunday (t/period :days 6)) last-sunday])
"Last week"]))} "Last week"]))}
"Last week"]] "Last week"]]
[:p.control [:div.control
[:a.button [:a.button
{:class (when (= (:selected params) "Week to date") "is-active") {:class (when (= (:selected params) "Week to date") "is-active")
:on-click (dispatch-event [::range-selected :on-click (dispatch-event [::range-selected
@@ -496,7 +522,7 @@
(local-now)]) (local-now)])
"Week to date"])} "Week to date"])}
"Week to date"]] "Week to date"]]
[:p.control [:div.control
[:a.button [:a.button
{:class (when (= (:selected params) "Last Month") "is-active") {:class (when (= (:selected params) "Last Month") "is-active")
:on-click (dispatch-event [::range-selected :on-click (dispatch-event [::range-selected
@@ -510,7 +536,7 @@
(t/period :days 1))]) (t/period :days 1))])
"Last Month"])} "Last Month"])}
"Last Month"]] "Last Month"]]
[:p.control [:div.control
[:a.button [:a.button
{:class (when (= (:selected params) "Month to date") "is-active") {:class (when (= (:selected params) "Month to date") "is-active")
:on-click (dispatch-event [::range-selected :on-click (dispatch-event [::range-selected
@@ -520,7 +546,7 @@
(local-now)]) (local-now)])
"Month to date"])} "Month to date"])}
"Month to date"]] "Month to date"]]
[:p.control [:div.control
[:a.button [:a.button
{:class (when (= (:selected params) "Year to date") "is-active") {:class (when (= (:selected params) "Year to date") "is-active")
:on-click (dispatch-event [::range-selected :on-click (dispatch-event [::range-selected
@@ -528,7 +554,7 @@
(local-now)]) (local-now)])
"Year to date"])} "Year to date"])}
"Year to date"]] "Year to date"]]
[:p.control [:div.control
[:a.button [:a.button
{:class (when (= (:selected params) "Full year") "is-active") {:class (when (= (:selected params) "Full year") "is-active")
:on-click (dispatch-event [::range-selected :on-click (dispatch-event [::range-selected
@@ -538,8 +564,9 @@
"Full year"])} "Full year"])}
"Full year"]]]] "Full year"]]]]
(for [[_ i] (map vector periods (range))] (for [[_ i] (map vector periods (range))]
^{:key i}
[:div.field.is-grouped [:div.field.is-grouped
[:p.control [:div.control
[:p.help "From"] [:p.help "From"]
[bind-field [bind-field
[date-picker {:class-name "input" [date-picker {:class-name "input"
@@ -555,7 +582,7 @@
:popper-props (clj->js {:placement "right"}) :popper-props (clj->js {:placement "right"})
:subscription params}]]] :subscription params}]]]
[:p.control [:div.control
[:p.help "To"] [:p.help "To"]
[bind-field [bind-field
[date-picker {:class-name "input" [date-picker {:class-name "input"
@@ -589,15 +616,14 @@
[:tbody [:tbody
[:tr [:tr
[:td.has-text-right "Period Ending"] [:td.has-text-right "Period Ending"]
[:td.has-text-right (date->str (last (first periods)))] (map-periods
[:td] (fn [i]
[:<>
(for [[_ end] (rest periods)]
[:<> [:<>
[:td.has-text-right (date->str end)] [:td.has-text-right (date->str (get-in periods [i 1]))]
[:td] [:td]])
[:td.has-text-right "𝝙"]] (fn [i]
)]] [:td.has-text-right "𝝙"])
periods)]
[:<> [:<>
(for [location @(re-frame/subscribe [::locations])] (for [location @(re-frame/subscribe [::locations])]
^{:key location} ^{:key location}

View File

@@ -183,7 +183,7 @@
(instance? goog.date.DateTime selected) (instance? goog.date.DateTime selected)
(c/to-date selected) (c/to-date (time/to-default-time-zone (time/from-default-time-zone selected)))
(instance? goog.date.Date selected) (instance? goog.date.Date selected)
(c/to-date selected) (c/to-date selected)