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