tons of small fixes.
This commit is contained in:
@@ -76,6 +76,8 @@
|
||||
(fn [acc [location account-id] {:keys [debit credit count]}]
|
||||
(let [account (lookup-account account-id)
|
||||
account-type (:account_type account)]
|
||||
|
||||
|
||||
(conj acc (merge {:id (str account-id "-" location)
|
||||
:location (or location "")
|
||||
:amount (if account-type (if (#{:account-type/asset
|
||||
@@ -129,17 +131,26 @@
|
||||
|
||||
(defn full-ledger-for-client [client-id]
|
||||
(->> (d/query
|
||||
{:query {:find ['?d '?jel '?account '?location '?debit '?credit ]
|
||||
:in ['$ '?client-id]
|
||||
:where ['[?e :journal-entry/client ?client-id]
|
||||
'[?e :journal-entry/date ?d]
|
||||
'[?e :journal-entry/line-items ?jel]
|
||||
'[(get-else $ ?jel :journal-entry-line/account :account/unknown) ?account]
|
||||
'[(get-else $ ?jel :journal-entry-line/debit 0.0) ?debit ]
|
||||
'[(get-else $ ?jel :journal-entry-line/credit 0.0) ?credit]
|
||||
'[(get-else $ ?jel :journal-entry-line/location "") ?location]]
|
||||
}
|
||||
:args [(d/db (d/connect uri)) client-id]})
|
||||
{:query {:find ['?d '?jel '?account '?location '?debit '?credit]
|
||||
:in ['$ '?client-id]
|
||||
:where '[[?e :journal-entry/client ?client-id]
|
||||
[?e :journal-entry/date ?d]
|
||||
[?e :journal-entry/line-items ?jel]
|
||||
(or-join [?e]
|
||||
(and [?e :journal-entry/original-entity ?i]
|
||||
(or-join [?e ?i]
|
||||
(and
|
||||
[?i :transaction/bank-account ?b]
|
||||
(or [?b :bank-account/include-in-reports true]
|
||||
(not [?b :bank-account/include-in-reports])))
|
||||
(not [?i :transaction/bank-account])))
|
||||
(not [?e :journal-entry/original-entity ]))
|
||||
[(get-else $ ?jel :journal-entry-line/account :account/unknown) ?account]
|
||||
[(get-else $ ?jel :journal-entry-line/debit 0.0) ?debit ]
|
||||
[(get-else $ ?jel :journal-entry-line/credit 0.0) ?credit]
|
||||
[(get-else $ ?jel :journal-entry-line/location "") ?location]]
|
||||
}
|
||||
:args [(d/db (d/connect uri)) client-id]})
|
||||
(sort-by first)))
|
||||
|
||||
(defn get-balance-sheet [context args value]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
[auto-ap.datomic.vendors :as d-vendors]
|
||||
[auto-ap.time :refer [parse iso-date]]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.datomic :refer [uri remove-nils]]
|
||||
[auto-ap.datomic :refer [uri remove-nils audit-transact]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.set :as set]))
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
{:db/id apwd})
|
||||
(:automatically_paid_when_due in))]))
|
||||
|
||||
transaction-result @(d/transact (d/connect uri) transaction)]
|
||||
transaction-result (audit-transact transaction (:id context))]
|
||||
|
||||
(-> (d-vendors/get-by-id (or (-> transaction-result :tempids (get "vendor"))
|
||||
id))
|
||||
@@ -100,3 +100,7 @@
|
||||
transaction (conj transaction [:db/retractEntity from])]
|
||||
@(d/transact conn transaction)
|
||||
to))
|
||||
|
||||
(defn get-graphql [context args value]
|
||||
(->graphql
|
||||
(d-vendors/get-graphql (assoc args :id (:id context)))))
|
||||
|
||||
Reference in New Issue
Block a user