adding most simple balance sheet report.

This commit is contained in:
Bryce Covert
2019-04-11 22:46:30 -07:00
parent effbff04c6
commit 6ab9d89dfd
13 changed files with 298 additions and 74 deletions

View File

@@ -1,6 +1,6 @@
(ns auto-ap.datomic.transactions
(:require [datomic.api :as d]
[auto-ap.datomic :refer [uri merge-query]]
[auto-ap.datomic :refer [uri merge-query apply-sort-2 apply-sort apply-pagination add-sorter-field]]
[auto-ap.graphql.utils :refer [limited-clients]]
[clj-time.coerce :as c]))
@@ -15,31 +15,6 @@
:else
(keyword "transaction" sort-by)))
(defn add-sorter-field [q sort-map args]
(merge-query q
{:query {:find ['?sorter]
:where (sort-map
(:sort-by args)
(println "Warning, trying to sort by unsupported field" (:sort-by args)))}}))
(defn apply-sort [args sort-fn results ]
(cond->> results
sort-fn (sort-by sort-fn)
(= (:asc args) false) (reverse)))
(defn apply-sort-2 [args results ]
(let [comparator (if (= (:asc args) false)
(fn [x y] (compare y x))
(fn [x y] (compare x y)))]
(sort comparator results )))
(defn apply-pagination [args results]
{:ids (->> results
(drop (:start args 0))
(take (:count args 100))
(map last))
:count (count results)})
(defn raw-graphql-ids [db args]
(let [query (cond-> {:query {:find []