You can now type accounts.

This commit is contained in:
Bryce Covert
2019-04-11 13:59:20 -07:00
parent a9975c8a10
commit 0eedc8908d
10 changed files with 54 additions and 12 deletions

View File

@@ -82,6 +82,7 @@
:auto-ap/add-general-ledger6 {:txes add-general-ledger/add-general-ledger :requires [:auto-ap/make-every-account-visible]}
:auto-ap/add-general-ledger-fns2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/add-general-ledger-fns :requires [:auto-ap/add-general-ledger6]}
:auto-ap/add-accounts {:txes auto-ap.datomic.migrate.add-general-ledger/add-accounts :requires [:auto-ap/add-general-ledger-fns2]}
:auto-ap/add-transaction-account {:txes auto-ap.datomic.migrate.add-general-ledger/add-transaction-account :requires [:auto-ap/add-general-ledger-fns2]}
#_#_:auto-ap/bulk-load-invoice-ledger2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/make-entity-not-unique]}
}]

View File

@@ -64,6 +64,12 @@
:db/doc "Location of the entry"}]
]
)
(def add-transaction-account
[[{:db/ident :transaction/account
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one
:db/doc "The debit/credit for this transaction"}]])
(def add-accounts
[[
{:db/ident :account/code

View File

@@ -9,6 +9,9 @@
(= "client" sort-by)
#(-> % :transaction/client :client/name)
(= "account" sort-by)
#(-> % :transaction/account :account/name)
:else
(keyword "transaction" sort-by)))
@@ -64,6 +67,13 @@
(:sort-by args) (add-sorter-field {"client" ['[?e :transaction/client ?c]
'[?c :client/name ?sorter]]
"account" #_['[(get-else $ ?e :transaction/account 0) ?sorter]]
['(or (and [?e :transaction/account ?c]
[?c :account/name ?sorter])
(and
[?e :transaction/client]
[(ground 0) ?c]
[(ground "") ?sorter]))]
"description-original" ['[?e :transaction/description-original ?sorter]]
"date" ['[?e :transaction/date ?sorter]]
"amount" ['[?e :transaction/amount ?sorter]]
@@ -107,7 +117,8 @@
(defn graphql-results [ids db args]
(->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
:transaction/vendor [:db/id :vendor/name]}]
:transaction/vendor [:db/id :vendor/name]
:transaction/account [:db/id :account/name :account/numeric-code]}]
ids)
(map #(update % :transaction/date c/from-date))
(map #(update % :transaction/post-date c/from-date))
@@ -126,7 +137,8 @@
(d/pull (d/db (d/connect uri))
'[* {:transaction/client [:client/name :db/id :client/code]
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
:transaction/vendor [:db/id :vendor/name]}]
:transaction/vendor [:db/id :vendor/name]
:transaction/account [:db/id :account/name :account/numeric-code]}]
id)
(update :transaction/date c/from-date)
(update :transaction/post-date c/from-date)

View File

@@ -133,6 +133,7 @@
:status {:type 'String}
:merchant_name {:type 'String}
:client {:type :client}
:account {:type :account}
:payment {:type :payment}
:vendor {:type :vendor}
:bank_account {:type :bank_account}
@@ -371,7 +372,8 @@
:total {:type 'Float}}}
:edit_transaction
{:fields {:id {:type :id}
:vendor_id {:type :id}}}}
:vendor_id {:type :id}
:account_id {:type :id}}}}
:enums {:payment_type {:values [{:enum-value :check}
{:enum-value :cash}

View File

@@ -24,11 +24,12 @@
(defn edit-transaction [context {{:keys [id vendor_id] :as transaction} :transaction} value]
(defn edit-transaction [context {{:keys [id account_id vendor_id] :as transaction} :transaction} value]
(assert-can-see-client (:id context) (:db/id (d-transactions/get-by-id id)))
@(d/transact (d/connect uri)
[{:db/id id
:transaction/vendor vendor_id}])
:transaction/vendor vendor_id
:transaction/account account_id}])
(->graphql (d-transactions/get-by-id id))
#_(->graphql {:id id
:vendor (d-vendors/get-by-id vendor_id) }))

View File

@@ -13,7 +13,6 @@
(let [variables (some-> (query-params "variables")
edn/read-string)
body (some-> r :body slurp)]
(println "BODY" body)
{:status 200
:body (pr-str (ql/query (:identity r) (doto (if (= request-method :get) (query-params "query") body) println) variables ))
:headers {"Content-Type" "application/edn"}})