excluding some stuff from PNL
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
:serialize (schema/as-conformer #(.toString %))}
|
||||
:ident {:parse (schema/as-conformer (fn [x] {:db/ident x}))
|
||||
: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))}}
|
||||
:objects
|
||||
{
|
||||
@@ -284,13 +284,13 @@
|
||||
:resolve :get-potential-payments}
|
||||
:balance_sheet {:type :balance_sheet
|
||||
:args {:client_id {:type :id}
|
||||
:date {:type 'String}}
|
||||
:date {:type :iso_date}}
|
||||
:resolve :get-balance-sheet}
|
||||
|
||||
:profit_and_loss {:type :balance_sheet
|
||||
:args {:client_id {:type :id}
|
||||
:from_date {:type 'String}
|
||||
:to_date {:type 'String}}
|
||||
:from_date {:type :iso_date}
|
||||
:to_date {:type :iso_date}}
|
||||
:resolve :get-profit-and-loss}
|
||||
|
||||
:invoice_page {:type '(list :invoice_page)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
(group-by (juxt :journal-entry-line/account :journal-entry-line/location))
|
||||
(reduce-kv (fn [result [account location] line-items]
|
||||
;; 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))
|
||||
(conj result
|
||||
{: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)
|
||||
: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})]
|
||||
(->graphql
|
||||
{:balance-sheet-accounts (roll-up results)
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
{:status 200
|
||||
:body (pr-str (ql/query (:identity r) (doto (if (= request-method :get) (query-params "query") body) println) variables ))
|
||||
:headers {"Content-Type" "application/edn"}})
|
||||
(catch Exception e
|
||||
(catch Throwable e
|
||||
|
||||
(if-let [result (:result (ex-data e))]
|
||||
{:status 400
|
||||
:body (pr-str result)
|
||||
@@ -25,9 +26,10 @@
|
||||
{:status 400
|
||||
:body (pr-str {:errors [(merge {:message message} (ex-data e))]})
|
||||
:headers {"Content-Type" "application/edn"}}
|
||||
{:status 500
|
||||
:body (pr-str {:errors [(merge {:message (.getMessage e)} (ex-data e))]})
|
||||
:headers {"Content-Type" "application/edn"}})))))
|
||||
(do (println e)
|
||||
{:status 500
|
||||
:body (pr-str {:errors [(merge {:message (.getMessage e)} (ex-data e))]})
|
||||
:headers {"Content-Type" "application/edn"}}))))))
|
||||
|
||||
|
||||
(defroutes routes
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
::report
|
||||
:comparable-balance-sheet-accounts
|
||||
(map :location)))
|
||||
(filter #(not= "A" %))
|
||||
(filter identity)
|
||||
(set)
|
||||
|
||||
(sort))))
|
||||
|
||||
(re-frame/reg-sub
|
||||
@@ -29,6 +32,11 @@
|
||||
(fn [db]
|
||||
(-> db ::report)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::error
|
||||
(fn [db]
|
||||
(-> db ::error)))
|
||||
|
||||
(re-frame/reg-sub
|
||||
::ledger-list-active?
|
||||
(fn [db]
|
||||
@@ -112,6 +120,13 @@
|
||||
(fn [db]
|
||||
(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
|
||||
::ledger-list-received
|
||||
(fn [db [_ ledger-list]]
|
||||
@@ -132,7 +147,8 @@
|
||||
:to-date (:to-date params)}
|
||||
[[: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 []
|
||||
(let [current-client @(re-frame/subscribe [::subs/client])
|
||||
user @(re-frame/subscribe [::subs/user])
|
||||
error @(re-frame/subscribe [::error])
|
||||
params @(re-frame/subscribe [::params])]
|
||||
|
||||
[:div
|
||||
@@ -399,8 +416,14 @@
|
||||
:event [::date-picked]
|
||||
:popper-props (clj->js {:placement "right"})
|
||||
: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]]
|
||||
|
||||
:else
|
||||
[:div
|
||||
[:table.table.compact.balance-sheet
|
||||
(list
|
||||
@@ -410,7 +433,7 @@
|
||||
[:td.has-text-right (when (:date params)
|
||||
(date->str (t/minus (str->date (:date params) standard) (t/years 1))))]
|
||||
[:td]]
|
||||
(for [location @(re-frame/subscribe [::locations])]
|
||||
(for [location (doto @(re-frame/subscribe [::locations]) println)]
|
||||
(list
|
||||
(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)
|
||||
|
||||
Reference in New Issue
Block a user