excluding some stuff from PNL
This commit is contained in:
@@ -37,7 +37,7 @@
|
|||||||
:serialize (schema/as-conformer #(.toString %))}
|
:serialize (schema/as-conformer #(.toString %))}
|
||||||
:ident {:parse (schema/as-conformer (fn [x] {:db/ident x}))
|
:ident {:parse (schema/as-conformer (fn [x] {:db/ident x}))
|
||||||
:serialize (schema/as-conformer #(or (:ident %) (:db/ident %) %))}
|
:serialize (schema/as-conformer #(or (:ident %) (:db/ident %) %))}
|
||||||
:iso_date {:parse (schema/as-conformer #(coerce/to-date-time %))
|
:iso_date {:parse (schema/as-conformer #(time/parse % time/iso-date))
|
||||||
:serialize (schema/as-conformer #(time/unparse % time/iso-date))}}
|
:serialize (schema/as-conformer #(time/unparse % time/iso-date))}}
|
||||||
:objects
|
:objects
|
||||||
{
|
{
|
||||||
@@ -284,13 +284,13 @@
|
|||||||
:resolve :get-potential-payments}
|
:resolve :get-potential-payments}
|
||||||
:balance_sheet {:type :balance_sheet
|
:balance_sheet {:type :balance_sheet
|
||||||
:args {:client_id {:type :id}
|
:args {:client_id {:type :id}
|
||||||
:date {:type 'String}}
|
:date {:type :iso_date}}
|
||||||
:resolve :get-balance-sheet}
|
:resolve :get-balance-sheet}
|
||||||
|
|
||||||
:profit_and_loss {:type :balance_sheet
|
:profit_and_loss {:type :balance_sheet
|
||||||
:args {:client_id {:type :id}
|
:args {:client_id {:type :id}
|
||||||
:from_date {:type 'String}
|
:from_date {:type :iso_date}
|
||||||
:to_date {:type 'String}}
|
:to_date {:type :iso_date}}
|
||||||
:resolve :get-profit-and-loss}
|
:resolve :get-profit-and-loss}
|
||||||
|
|
||||||
:invoice_page {:type '(list :invoice_page)
|
:invoice_page {:type '(list :invoice_page)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
(group-by (juxt :journal-entry-line/account :journal-entry-line/location))
|
(group-by (juxt :journal-entry-line/account :journal-entry-line/location))
|
||||||
(reduce-kv (fn [result [account location] line-items]
|
(reduce-kv (fn [result [account location] line-items]
|
||||||
;; TODO fix
|
;; TODO fix
|
||||||
(when-not (or (:bank-account/name account) (:account/name account))
|
#_(when-not (or (:bank-account/name account) (:account/name account))
|
||||||
(println "WARNING " account line-items))
|
(println "WARNING " account line-items))
|
||||||
(conj result
|
(conj result
|
||||||
{:name (str (or (:bank-account/name account) (:account/name account)) (when-not (#{"A" } location)
|
{:name (str (or (:bank-account/name account) (:account/name account)) (when-not (#{"A" } location)
|
||||||
@@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
|
|
||||||
[comparable-results] (l/get-graphql {:client-id (:client_id args)
|
[comparable-results] (l/get-graphql {:client-id (:client_id args)
|
||||||
:to-date (coerce/to-date (time/minus (parse (:date args) iso-date) (time/years 1)))
|
:to-date (coerce/to-date (time/minus (:date args) (time/years 1)))
|
||||||
:count Integer/MAX_VALUE})]
|
:count Integer/MAX_VALUE})]
|
||||||
(->graphql
|
(->graphql
|
||||||
{:balance-sheet-accounts (roll-up results)
|
{:balance-sheet-accounts (roll-up results)
|
||||||
|
|||||||
@@ -16,7 +16,8 @@
|
|||||||
{:status 200
|
{:status 200
|
||||||
:body (pr-str (ql/query (:identity r) (doto (if (= request-method :get) (query-params "query") body) println) variables ))
|
:body (pr-str (ql/query (:identity r) (doto (if (= request-method :get) (query-params "query") body) println) variables ))
|
||||||
:headers {"Content-Type" "application/edn"}})
|
:headers {"Content-Type" "application/edn"}})
|
||||||
(catch Exception e
|
(catch Throwable e
|
||||||
|
|
||||||
(if-let [result (:result (ex-data e))]
|
(if-let [result (:result (ex-data e))]
|
||||||
{:status 400
|
{:status 400
|
||||||
:body (pr-str result)
|
:body (pr-str result)
|
||||||
@@ -25,9 +26,10 @@
|
|||||||
{:status 400
|
{:status 400
|
||||||
:body (pr-str {:errors [(merge {:message message} (ex-data e))]})
|
:body (pr-str {:errors [(merge {:message message} (ex-data e))]})
|
||||||
:headers {"Content-Type" "application/edn"}}
|
:headers {"Content-Type" "application/edn"}}
|
||||||
{:status 500
|
(do (println e)
|
||||||
:body (pr-str {:errors [(merge {:message (.getMessage e)} (ex-data e))]})
|
{:status 500
|
||||||
:headers {"Content-Type" "application/edn"}})))))
|
:body (pr-str {:errors [(merge {:message (.getMessage e)} (ex-data e))]})
|
||||||
|
:headers {"Content-Type" "application/edn"}}))))))
|
||||||
|
|
||||||
|
|
||||||
(defroutes routes
|
(defroutes routes
|
||||||
|
|||||||
@@ -21,7 +21,10 @@
|
|||||||
::report
|
::report
|
||||||
:comparable-balance-sheet-accounts
|
:comparable-balance-sheet-accounts
|
||||||
(map :location)))
|
(map :location)))
|
||||||
|
(filter #(not= "A" %))
|
||||||
|
(filter identity)
|
||||||
(set)
|
(set)
|
||||||
|
|
||||||
(sort))))
|
(sort))))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
@@ -29,6 +32,11 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db ::report)))
|
(-> db ::report)))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
::error
|
||||||
|
(fn [db]
|
||||||
|
(-> db ::error)))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::ledger-list-active?
|
::ledger-list-active?
|
||||||
(fn [db]
|
(fn [db]
|
||||||
@@ -112,6 +120,13 @@
|
|||||||
(fn [db]
|
(fn [db]
|
||||||
(assoc db ::ledger-list-active? false)))
|
(assoc db ::ledger-list-active? false)))
|
||||||
|
|
||||||
|
(re-frame/reg-event-db
|
||||||
|
::error
|
||||||
|
(fn [db [_ [error]]]
|
||||||
|
(println (:message error))
|
||||||
|
(assoc db ::error (:message error)
|
||||||
|
::loading false)))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::ledger-list-received
|
::ledger-list-received
|
||||||
(fn [db [_ ledger-list]]
|
(fn [db [_ ledger-list]]
|
||||||
@@ -132,7 +147,8 @@
|
|||||||
:to-date (:to-date params)}
|
:to-date (:to-date params)}
|
||||||
[[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]
|
[[:balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]
|
||||||
[:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]]]]}
|
[:comparable-balance-sheet-accounts [:name :amount :account-type :id :numeric-code :location]]]]]}
|
||||||
:on-success [::received]}}))
|
:on-success [::received]
|
||||||
|
:on-error [::error]}}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -309,6 +325,7 @@
|
|||||||
(fn []
|
(fn []
|
||||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||||
user @(re-frame/subscribe [::subs/user])
|
user @(re-frame/subscribe [::subs/user])
|
||||||
|
error @(re-frame/subscribe [::error])
|
||||||
params @(re-frame/subscribe [::params])]
|
params @(re-frame/subscribe [::params])]
|
||||||
|
|
||||||
[:div
|
[:div
|
||||||
@@ -399,8 +416,14 @@
|
|||||||
:event [::date-picked]
|
:event [::date-picked]
|
||||||
:popper-props (clj->js {:placement "right"})
|
:popper-props (clj->js {:placement "right"})
|
||||||
:subscription params}]]]]
|
:subscription params}]]]]
|
||||||
(if @(re-frame/subscribe [::loading])
|
(cond
|
||||||
|
error
|
||||||
|
[:div.notification.is-warning error]
|
||||||
|
|
||||||
|
@(re-frame/subscribe [::loading])
|
||||||
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
[:div [:i.icon.fa.fa-spin.fa-spinner]]
|
||||||
|
|
||||||
|
:else
|
||||||
[:div
|
[:div
|
||||||
[:table.table.compact.balance-sheet
|
[:table.table.compact.balance-sheet
|
||||||
(list
|
(list
|
||||||
@@ -410,7 +433,7 @@
|
|||||||
[:td.has-text-right (when (:date params)
|
[:td.has-text-right (when (:date params)
|
||||||
(date->str (t/minus (str->date (:date params) standard) (t/years 1))))]
|
(date->str (t/minus (str->date (:date params) standard) (t/years 1))))]
|
||||||
[:td]]
|
[:td]]
|
||||||
(for [location @(re-frame/subscribe [::locations])]
|
(for [location (doto @(re-frame/subscribe [::locations]) println)]
|
||||||
(list
|
(list
|
||||||
(overall-grouping :expense location location))))]])]))
|
(overall-grouping :expense location location))))]])]))
|
||||||
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:from-date (date->str (t/minus (local-now) (t/period :years 1)) standard)
|
{:component-will-mount #(re-frame/dispatch-sync [::params-change {:from-date (date->str (t/minus (local-now) (t/period :years 1)) standard)
|
||||||
|
|||||||
Reference in New Issue
Block a user