more fixes.
This commit is contained in:
@@ -57,7 +57,7 @@
|
||||
(merge-query {:query {:in ['?from-date]
|
||||
:where ['[?e :journal-entry/date ?d]
|
||||
'[(>= ?d ?from-date)]]}
|
||||
:args [(c/to-date (time/minus (:from-date args) (time/days 1)))]})
|
||||
:args [(c/to-date (:from-date args))]})
|
||||
|
||||
(:from-numeric-code args)
|
||||
(merge-query {:query {:in ['?from-numeric-code]
|
||||
|
||||
@@ -103,12 +103,14 @@
|
||||
(defn get-profit-and-loss [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
pnl (fn [from-date to-date]
|
||||
(println from-date to-date)
|
||||
(println "FROM" from-date to-date)
|
||||
(let [[starting-results] (l/get-graphql {:client-id (:client_id args)
|
||||
:to-date from-date
|
||||
:to-date (-> from-date
|
||||
(time/minus (time/seconds 1))
|
||||
coerce/to-date)
|
||||
:count Integer/MAX_VALUE})
|
||||
[ending-results] (l/get-graphql {:client-id (:client_id args)
|
||||
:to-date to-date
|
||||
:to-date (coerce/to-date to-date)
|
||||
:count Integer/MAX_VALUE})
|
||||
starting-accounts (by :id (roll-up starting-results))
|
||||
ending-accounts (by :id (roll-up ending-results))]
|
||||
@@ -120,10 +122,10 @@
|
||||
[]
|
||||
ending-accounts)))]
|
||||
(->graphql
|
||||
{:balance-sheet-accounts (pnl (coerce/to-date (time/minus (:from_date args) (time/days 1)))
|
||||
(coerce/to-date (:to_date args)))
|
||||
:comparable-balance-sheet-accounts (pnl (coerce/to-date (coerce/to-date (time/minus (coerce/to-date-time (:from_date args)) (time/years 1))))
|
||||
(coerce/to-date (coerce/to-date (time/minus (coerce/to-date-time (:to_date args)) (time/years 1)))))})))
|
||||
{:balance-sheet-accounts (pnl (coerce/to-date-time (:from_date args))
|
||||
(coerce/to-date-time (:to_date args)))
|
||||
:comparable-balance-sheet-accounts (pnl (time/minus (coerce/to-date-time (:from_date args)) (time/years 1))
|
||||
(time/minus (coerce/to-date-time (:to_date args)) (time/years 1)))})))
|
||||
|
||||
#_(get-profit-and-loss nil {:client_id [:client/code "CBC"]
|
||||
:from_date "2018-01-01"
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
(re-frame/reg-event-fx
|
||||
::investigate-clicked
|
||||
(fn [{:keys [db] } [_ location from-numeric-code to-numeric-code which]]
|
||||
|
||||
(println from-numeric-code to-numeric-code)
|
||||
{:db (assoc db
|
||||
::ledger-list-active? true
|
||||
::ledger-list-loading true)
|
||||
@@ -298,25 +298,28 @@
|
||||
])))
|
||||
|
||||
(defn overall-grouping [type title location]
|
||||
(list
|
||||
[:tr [:th.has-text-centered title]
|
||||
[:td]
|
||||
[:td]
|
||||
[:td]]
|
||||
(grouping {:accounts @(re-frame/subscribe [::accounts type location])
|
||||
:location location
|
||||
:groupings (type groupings)
|
||||
:comparable-accounts @(re-frame/subscribe [::comparable-accounts-by-id type location])
|
||||
})
|
||||
[:tr [:th.has-text-centered title]
|
||||
[:th.has-text-right [:a
|
||||
{:on-click (dispatch-event [::investigate-clicked location nil nil :current])}
|
||||
(->$ (reduce + 0 (map :amount @(re-frame/subscribe [::accounts type location]))))]]
|
||||
[:th.has-text-right [:a
|
||||
{:on-click (dispatch-event [::investigate-clicked location nil nil :comparable])}
|
||||
(->$ (reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id type location])))))]]
|
||||
[:th.has-text-right (->$ (- (reduce + 0 (map :amount @(re-frame/subscribe [::accounts type location])))
|
||||
(reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id type location]))))))]]))
|
||||
(let [accounts @(re-frame/subscribe [::accounts type location])
|
||||
min-numeric-code (or (first (map :numeric-code accounts)) 0)
|
||||
max-numeric-code (or (last (map :numeric-code accounts)) 0)]
|
||||
(list
|
||||
[:tr [:th.has-text-centered title]
|
||||
[:td]
|
||||
[:td]
|
||||
[:td]]
|
||||
(grouping {:accounts accounts
|
||||
:location location
|
||||
:groupings (type groupings)
|
||||
:comparable-accounts @(re-frame/subscribe [::comparable-accounts-by-id type location])
|
||||
})
|
||||
[:tr [:th.has-text-centered title]
|
||||
[:th.has-text-right [:a
|
||||
{:on-click (dispatch-event [::investigate-clicked location min-numeric-code max-numeric-code :current])}
|
||||
(->$ (reduce + 0 (map :amount @(re-frame/subscribe [::accounts type location]))))]]
|
||||
[:th.has-text-right [:a
|
||||
{:on-click (dispatch-event [::investigate-clicked location min-numeric-code max-numeric-code :comparable])}
|
||||
(->$ (reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id type location])))))]]
|
||||
[:th.has-text-right (->$ (- (reduce + 0 (map :amount @(re-frame/subscribe [::accounts type location])))
|
||||
(reduce + 0 (map :amount (vals @(re-frame/subscribe [::comparable-accounts-by-id type location]))))))]])))
|
||||
|
||||
(def profit-and-loss-content
|
||||
(with-meta
|
||||
|
||||
Reference in New Issue
Block a user