Quality of life improvements with client login
This commit is contained in:
@@ -193,3 +193,16 @@
|
||||
(map <-datomic)))
|
||||
|
||||
|
||||
(defn get-existing-set []
|
||||
(d/query
|
||||
(cond-> {:query {:find ['?vendor '?client '?invoice-number]
|
||||
:in ['$]
|
||||
:where '[[?e :invoice/invoice-number ?invoice-number]
|
||||
[?e :invoice/vendor ?vendor]
|
||||
[?e :invoice/client ?client]
|
||||
(not [?e :invoice/status :invoice-status/voided])
|
||||
]}
|
||||
|
||||
:args [(d/db (d/connect uri))]})))
|
||||
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@
|
||||
@(d/transact
|
||||
(d/connect uri)
|
||||
(mapv
|
||||
#(auto-ap.ledger/entity-change->ledger (d/db (d/connect uri)) [:transaction %])
|
||||
#(entity-change->ledger (d/db (d/connect uri)) [:transaction %])
|
||||
(concat
|
||||
(->>
|
||||
(d/query {:query {:find ['?t ]
|
||||
|
||||
@@ -39,8 +39,6 @@
|
||||
(if-let [id (:db/id (or (clients client-code)
|
||||
(clients client)))]
|
||||
(do
|
||||
(println "FOUND CLIENT" (or (clients client-code)
|
||||
(clients client)))
|
||||
(when (not ((set (:client/locations (or (clients client-code)
|
||||
(clients client))))
|
||||
default-location))
|
||||
@@ -78,8 +76,8 @@
|
||||
(defn parse-account-numeric-code [i]
|
||||
(try
|
||||
(when-let [account-numeric-code (:account-numeric-code i)]
|
||||
(d-accounts/get-account-by-numeric-code-and-sets (Integer/parseInt account-numeric-code)
|
||||
["default"]))
|
||||
(:db/id (d-accounts/get-account-by-numeric-code-and-sets (Integer/parseInt account-numeric-code)
|
||||
["default"])))
|
||||
(catch Exception e
|
||||
(throw (Exception. (str "Could not parse expense account from value '" (:account-numeric-code i) "'") e)))))
|
||||
|
||||
@@ -481,12 +479,7 @@
|
||||
{{:keys [excel-rows]} :edn-params user :identity}
|
||||
(assert-admin user)
|
||||
(let [parsed-invoice-rows (parse-invoice-rows excel-rows)
|
||||
existing-rows (->> (d-invoices/get-graphql {:count Integer/MAX_VALUE})
|
||||
first
|
||||
(filter (fn [i] (not= :invoice-status/voided (:invoice/status i))))
|
||||
(map (fn [{:keys [:invoice/vendor :invoice/client :invoice/invoice-number]}]
|
||||
[(:db/id vendor) (:db/id client) invoice-number]))
|
||||
set)
|
||||
existing-rows (set (d-invoices/get-existing-set ))
|
||||
grouped-rows (group-by
|
||||
(fn [i]
|
||||
(cond (seq (:errors i))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
(:require [auto-ap.datomic :refer [uri]]
|
||||
|
||||
[auto-ap.utils :refer [by]]
|
||||
#_[auto-ap.ledger :as l]
|
||||
[datomic.api :as d]
|
||||
[clojure.data.csv :as csv]
|
||||
[clj-time.coerce :as c]
|
||||
@@ -300,11 +301,12 @@
|
||||
)
|
||||
vec))
|
||||
|
||||
(defn patch-missing-ledger-entries []
|
||||
;; TODO uncommenting the two below this makes lein build not work, probably related to the ledger
|
||||
#_(defn patch-missing-ledger-entries []
|
||||
@(d/transact
|
||||
(d/connect uri)
|
||||
(mapv
|
||||
#(auto-ap.ledger/entity-change->ledger (d/db (d/connect uri)) [:transaction %])
|
||||
#(l/entity-change->ledger (d/db (d/connect uri)) [:transaction %])
|
||||
(concat
|
||||
(->>
|
||||
(d/query {:query {:find ['?t ]
|
||||
@@ -317,7 +319,7 @@
|
||||
|
||||
|
||||
|
||||
(defn check-for-out-of-date-ledger [?code]
|
||||
#_(defn check-for-out-of-date-ledger [code]
|
||||
[(d/query {:query {:find ['(count ?e)]
|
||||
:in ['$ '?code]
|
||||
:where ['[?e :transaction/accounts ?ta]
|
||||
@@ -327,11 +329,13 @@
|
||||
'[?e :transaction/client ?c]
|
||||
'[?c :client/code ?code]
|
||||
]}
|
||||
:args [(d/db (d/connect uri)) ?code]})
|
||||
:args [(d/db (d/connect uri)) code]})
|
||||
|
||||
(d/query {:query {:find ['?t ]
|
||||
:in ['$]
|
||||
:where ['[?t :transaction/date]
|
||||
'[?t :transaction/client ?c]
|
||||
'[?c :client/code ?code]
|
||||
'(not [?t :transaction/approval-status :transaction-approval-status/excluded])
|
||||
'(not-join [?t] [?e :journal-entry/original-entity ?t])]}
|
||||
:args [(d/db (d/connect uri))]})
|
||||
@@ -339,9 +343,20 @@
|
||||
(d/query {:query {:find ['?t ]
|
||||
:in ['$]
|
||||
:where ['[?t :transaction/date]
|
||||
'[?t :transaction/client ?c]
|
||||
'[?c :client/code ?code]
|
||||
'(not [?t :transaction/approval-status :transaction-approval-status/excluded])
|
||||
'[?t :transaction/vendor ?v]
|
||||
'[?j :journal-entry/original-entity ?t]
|
||||
'(not [?j :journal-entry/vendor ?v])
|
||||
#_'(not-join [?t] [?e :journal-entry/original-entity ?t])]}
|
||||
:args [(d/db (d/connect uri))]})
|
||||
|
||||
(d/query {:query {:find ['(count ?i) ]
|
||||
:in ['$]
|
||||
:where ['[?i :invoice/client ?c]
|
||||
'(not [?i :invoice/status :invoice-status/voided])
|
||||
'[?c :client/code ?code]
|
||||
'(not-join [?i] [?e :journal-entry/original-entity ?i])]}
|
||||
:args [(d/db (d/connect uri))]})])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user