@@ -153,7 +153,6 @@
|
|||||||
{:fields {:id {:type 'String}
|
{:fields {:id {:type 'String}
|
||||||
:amount {:type 'String}
|
:amount {:type 'String}
|
||||||
:location {:type 'String}
|
:location {:type 'String}
|
||||||
:client_id {:type :id}
|
|
||||||
:count {:type 'Int}
|
:count {:type 'Int}
|
||||||
:numeric_code {:type 'Int}
|
:numeric_code {:type 'Int}
|
||||||
:account_type {:type :account_type}
|
:account_type {:type :account_type}
|
||||||
|
|||||||
@@ -96,14 +96,13 @@
|
|||||||
(let [account (lookup-account account-id)
|
(let [account (lookup-account account-id)
|
||||||
account-type (:account_type account)]
|
account-type (:account_type account)]
|
||||||
|
|
||||||
(conj acc (merge {:id (str account-id "-" location)
|
(conj acc (merge {:id (str account-id "-" location) :location (or location "") :count count
|
||||||
:location (or location "")
|
|
||||||
:count count
|
|
||||||
:amount (if account-type (if (#{:account-type/asset
|
:amount (if account-type (if (#{:account-type/asset
|
||||||
:account-type/dividend
|
:account-type/dividend
|
||||||
:account-type/expense} account-type)
|
:account-type/expense} account-type)
|
||||||
(- debit credit)
|
(- debit credit)
|
||||||
(- credit debit))
|
(- credit debit)
|
||||||
|
)
|
||||||
0.0)}
|
0.0)}
|
||||||
account)))
|
account)))
|
||||||
)
|
)
|
||||||
@@ -143,8 +142,7 @@
|
|||||||
: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)))))
|
||||||
:numeric_code (or (:account/numeric-code (accounts a))
|
:numeric_code (or (:account/numeric-code (accounts a))
|
||||||
(:bank-account/numeric-code (bank-accounts a)))
|
(:bank-account/numeric-code (bank-accounts a)))})))
|
||||||
:client_id client-id})))
|
|
||||||
|
|
||||||
(defn full-ledger-for-client [client-id]
|
(defn full-ledger-for-client [client-id]
|
||||||
(->> (d/query
|
(->> (d/query
|
||||||
@@ -191,22 +189,14 @@
|
|||||||
(throw (ex-info "Please select a client." {:validation-error "Please select a client."})))
|
(throw (ex-info "Please select a client." {:validation-error "Please select a client."})))
|
||||||
_ (doseq [client-id client-ids]
|
_ (doseq [client-id client-ids]
|
||||||
(assert-can-see-client (:id context) client-id))
|
(assert-can-see-client (:id context) client-id))
|
||||||
all-ledger-entries (->> client-ids
|
all-ledger-entries (full-ledger-for-client (first client-ids))
|
||||||
(map (fn [client-id]
|
lookup-account (build-account-lookup (first client-ids))]
|
||||||
[client-id (full-ledger-for-client client-id)]))
|
|
||||||
(into {}))
|
|
||||||
lookup-account (->> client-ids
|
|
||||||
(map (fn [client-id]
|
|
||||||
[client-id (build-account-lookup client-id)]))
|
|
||||||
(into {}))
|
|
||||||
client-id (first client-ids)]
|
|
||||||
(->graphql
|
(->graphql
|
||||||
{:periods
|
{:periods (reduce (fn [acc {:keys [start end]}]
|
||||||
(->> (:periods args)
|
(conj acc
|
||||||
(mapv (fn [{:keys [start end]}]
|
{:accounts (roll-up-until lookup-account all-ledger-entries (coerce/to-date end) (coerce/to-date start) )}))
|
||||||
{:accounts (mapcat
|
[]
|
||||||
#(roll-up-until (lookup-account %) (all-ledger-entries %) (coerce/to-date end) (coerce/to-date start) )
|
(:periods args))})))
|
||||||
client-ids)})))})))
|
|
||||||
|
|
||||||
|
|
||||||
(defn assoc-error [f]
|
(defn assoc-error [f]
|
||||||
|
|||||||
@@ -174,7 +174,7 @@
|
|||||||
vector))
|
vector))
|
||||||
:periods (mapv (fn [[start end] ] {:start (date->str start standard) :end (date->str end standard)} )
|
:periods (mapv (fn [[start end] ] {:start (date->str start standard) :end (date->str end standard)} )
|
||||||
(:periods (:data db)))}
|
(:periods (:data db)))}
|
||||||
[[:periods [[:accounts [:name :amount :client_id :account-type :id :count :numeric-code :location]]]]]]]}
|
[[:periods [[:accounts [:name :amount :account-type :id :count :numeric-code :location]]]]]]]}
|
||||||
:on-success [::received]}
|
:on-success [::received]}
|
||||||
:set-uri-params {:periods (mapv (fn [[start end title]]
|
:set-uri-params {:periods (mapv (fn [[start end title]]
|
||||||
[(date->str start standard)
|
[(date->str start standard)
|
||||||
@@ -424,10 +424,7 @@
|
|||||||
{:key (str "between-" i)}))]))
|
{:key (str "between-" i)}))]))
|
||||||
|
|
||||||
|
|
||||||
;; reimplement include-deltas. Are numbers even correct? support actually using more than 1 client.
|
|
||||||
|
|
||||||
(defn grouping [{:keys [header type groupings location periods all-accounts]}]
|
(defn grouping [{:keys [header type groupings location periods all-accounts]}]
|
||||||
|
|
||||||
(let [params @(re-frame/subscribe [::params])]
|
(let [params @(re-frame/subscribe [::params])]
|
||||||
[:<>
|
[:<>
|
||||||
(doall
|
(doall
|
||||||
@@ -836,8 +833,7 @@
|
|||||||
(fn [dt]
|
(fn [dt]
|
||||||
(str->date dt standard))
|
(str->date dt standard))
|
||||||
period))))
|
period))))
|
||||||
:client (:client qp)
|
:client (:client qp)})
|
||||||
:include-deltas true})
|
|
||||||
::track/register {:id ::ledger-params
|
::track/register {:id ::ledger-params
|
||||||
:subscription [::data-page/params ::ledger]
|
:subscription [::data-page/params ::ledger]
|
||||||
:event-fn (fn [params] [::ledger-params-change params])}})))
|
:event-fn (fn [params] [::ledger-params-change params])}})))
|
||||||
|
|||||||
Reference in New Issue
Block a user