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