filtering on ledger page.
This commit is contained in:
@@ -41,17 +41,17 @@
|
||||
'[?client-id :client/code ?client-code]]}
|
||||
:args [(:client-code args)]})
|
||||
|
||||
(:to-date args)
|
||||
(merge-query {:query {:in ['?to-date]
|
||||
:where ['[?e :journal-entry/date ?d]
|
||||
'[(<= ?d ?to-date)]]}
|
||||
:args [(c/to-date (:to-date args))]})
|
||||
(:start (:date-range args))
|
||||
(merge-query {:query {:in ['?start-date]
|
||||
:where ['[?e :journal-entry/date ?date]
|
||||
'[(>= ?date ?start-date)]]}
|
||||
:args [(c/to-date (:start (:date-range args)))]})
|
||||
|
||||
(:from-date args)
|
||||
(merge-query {:query {:in ['?from-date]
|
||||
:where ['[?e :journal-entry/date ?d]
|
||||
'[(>= ?d ?from-date)]]}
|
||||
:args [(c/to-date (:from-date args))]})
|
||||
(:end (:date-range args))
|
||||
(merge-query {:query {:in ['?end-date]
|
||||
:where ['[?e :journal-entry/date ?date]
|
||||
'[(<= ?date ?end-date)]]}
|
||||
:args [(c/to-date (:end (:date-range args)))]})
|
||||
|
||||
(:from-numeric-code args)
|
||||
(merge-query {:query {:in ['?from-numeric-code]
|
||||
@@ -61,6 +61,12 @@
|
||||
'[(>= ?c ?from-numeric-code)]]}
|
||||
:args [(:from-numeric-code args)]})
|
||||
|
||||
(:bank-account-id args)
|
||||
(merge-query {:query {:in ['?a]
|
||||
:where ['[?e :journal-entry/line-items ?li]
|
||||
'[?li :journal-entry-line/account ?a]]}
|
||||
:args [(:bank-account-id args)]})
|
||||
|
||||
(:to-numeric-code args)
|
||||
(merge-query {:query {:in ['?to-numeric-code]
|
||||
:where ['[?e :journal-entry/line-items ?li]
|
||||
|
||||
@@ -373,8 +373,7 @@
|
||||
|
||||
:profit_and_loss {:type :balance_sheet
|
||||
:args {:client_id {:type :id}
|
||||
:from_date {:type :iso_date}
|
||||
:to_date {:type :iso_date}}
|
||||
:date_range {:type :date_range}}
|
||||
:resolve :get-profit-and-loss}
|
||||
|
||||
|
||||
@@ -435,18 +434,17 @@
|
||||
:resolve :get-transaction-rule-page}
|
||||
|
||||
:ledger_page {:type :ledger_page
|
||||
:args {:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:bank_account_id {:type :id}
|
||||
:from_date {:type :iso_date}
|
||||
:to_date {:type :iso_date}
|
||||
:location {:type 'String}
|
||||
:from_numeric_code {:type 'Int}
|
||||
:to_numeric_code {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:sort {:type '(list :sort_item)}}
|
||||
|
||||
:resolve :get-ledger-page}
|
||||
:args {:client_id {:type :id}
|
||||
:vendor_id {:type :id}
|
||||
:bank_account_id {:type :id}
|
||||
:date_range {:type :date_range}
|
||||
:location {:type 'String}
|
||||
:from_numeric_code {:type 'Int}
|
||||
:to_numeric_code {:type 'Int}
|
||||
:start {:type 'Int}
|
||||
:sort {:type '(list :sort_item)}}
|
||||
|
||||
:resolve :get-ledger-page}
|
||||
|
||||
:payment_page {:type '(list :payment_page)
|
||||
:args {:client_id {:type :id}
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
(defn get-balance-sheet [context args value]
|
||||
(let [args (assoc args :id (:id context))
|
||||
[results] (l/get-graphql {:client-id (:client_id args)
|
||||
:to-date (coerce/to-date (:date args))
|
||||
:date-range {:end (coerce/to-date (:date args))}
|
||||
:count Integer/MAX_VALUE})
|
||||
|
||||
|
||||
@@ -105,12 +105,12 @@
|
||||
pnl (fn [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
|
||||
(time/minus (time/seconds 1))
|
||||
coerce/to-date)
|
||||
:date-range {:end (-> 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 (coerce/to-date to-date)
|
||||
:date-range {:end (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))]
|
||||
@@ -122,10 +122,10 @@
|
||||
[]
|
||||
ending-accounts)))]
|
||||
(->graphql
|
||||
{: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)))})))
|
||||
{:balance-sheet-accounts (pnl (coerce/to-date-time (:start (:date_range args)))
|
||||
(coerce/to-date-time (:end (:date_range args))))
|
||||
:comparable-balance-sheet-accounts (pnl (time/minus (coerce/to-date-time (:start (:date_range args))) (time/years 1))
|
||||
(time/minus (coerce/to-date-time (:end (:date_range args))) (time/years 1)))})))
|
||||
|
||||
#_(get-profit-and-loss nil {:client_id [:client/code "CBC"]
|
||||
:from_date "2018-01-01"
|
||||
|
||||
Reference in New Issue
Block a user