Add vendor pre-population for bulk code and individual edit forms
- Add vendor-changed HTMX handlers for both bulk code and individual edit - Pre-populate default account at 100% when vendor is selected and no accounts exist - Fix render-accounts-section to render from step-params correctly - Change bulk code vendor-changed from hx-get to hx-post to include form data - Add routes for vendor-changed endpoints - Update e2e tests to cover vendor pre-population - Run lein cljfmt fix across codebase
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
nil)
|
||||
|
||||
(defmethod datomic->solr "journal-entry" [d]
|
||||
(let [i (dc/pull (dc/db conn) '[:db/id
|
||||
(let [i (dc/pull (dc/db conn) '[:db/id
|
||||
:journal-entry/amount
|
||||
:journal-entry/source
|
||||
{:journal-entry/client [:client/code :db/id]
|
||||
@@ -78,13 +78,13 @@
|
||||
"date" (some-> i :journal-entry/date c/to-date-time (atime/unparse atime/iso-date) (str "T00:00:00Z"))
|
||||
"amount" (-> i :journal-entry/amount fmt-amount)
|
||||
"description" (str
|
||||
(when (:journal-entry/source i)
|
||||
(str (:journal-entry/source i) ": "))
|
||||
(str/join ", " (set (map
|
||||
(fn [li]
|
||||
(format "%s (%s)" (:account/name (:journal-entry-line/account li))
|
||||
(:account/numeric-code (:journal-entry-line/account li))))
|
||||
(:journal-entry/line-items i)))))
|
||||
(when (:journal-entry/source i)
|
||||
(str (:journal-entry/source i) ": "))
|
||||
(str/join ", " (set (map
|
||||
(fn [li]
|
||||
(format "%s (%s)" (:account/name (:journal-entry-line/account li))
|
||||
(:account/numeric-code (:journal-entry-line/account li))))
|
||||
(:journal-entry/line-items i)))))
|
||||
"vendor_name" (-> i :journal-entry/vendor :vendor/name)
|
||||
"vendor_id" (-> i :journal-entry/vendor :db/id)
|
||||
"type" "journal-entry"}))
|
||||
@@ -123,7 +123,6 @@
|
||||
"vendor_id" (-> i :payment/vendor :db/id)
|
||||
"type" "payment"}))
|
||||
|
||||
|
||||
(defprotocol SolrClient
|
||||
(index-documents-raw [this index xs])
|
||||
(index-documents [this index xs])
|
||||
@@ -135,46 +134,45 @@
|
||||
SolrClient
|
||||
(index-documents-raw [this index xs]
|
||||
(client/post
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 5000
|
||||
"commit" true}))
|
||||
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:method "POST"
|
||||
:body (json/write-str xs)}))
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 5000
|
||||
"commit" true}))
|
||||
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:method "POST"
|
||||
:body (json/write-str xs)}))
|
||||
|
||||
(index-documents [this index xs]
|
||||
(client/post
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 5000
|
||||
"commit" true}))
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:method "POST"
|
||||
:body (json/write-str (filter identity (map datomic->solr xs)))}))
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 5000
|
||||
"commit" true}))
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:method "POST"
|
||||
:body (json/write-str (filter identity (map datomic->solr xs)))}))
|
||||
|
||||
(query [this index q]
|
||||
(-> (client/post (str (url/url solr-uri "solr" index "query"))
|
||||
{:body (json/write-str q )
|
||||
{:body (json/write-str q)
|
||||
:socket-timeout 30000
|
||||
:connection-timeout 30000
|
||||
:headers {"Content-Type" "application/json"}
|
||||
:as :json}
|
||||
)
|
||||
:as :json})
|
||||
:body
|
||||
:response
|
||||
:docs))
|
||||
(delete [this index]
|
||||
(client/post
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 15000
|
||||
"commit" true}))
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:method "POST"
|
||||
:body (json/write-str {"delete" {"query" "*:*"}})})))
|
||||
(str (assoc (url/url solr-uri "solr" index "update")
|
||||
:query {"commitWithin" 15000
|
||||
"commit" true}))
|
||||
{:headers {"Content-Type" "application/json"}
|
||||
:method "POST"
|
||||
:body (json/write-str {"delete" {"query" "*:*"}})})))
|
||||
|
||||
(defrecord MockSolrClient []
|
||||
SolrClient
|
||||
@@ -191,11 +189,7 @@
|
||||
|
||||
(def impl (if (= :solr (:solr-impl env))
|
||||
(->RealSolrClient (:solr-uri env))
|
||||
(->MockSolrClient )))
|
||||
|
||||
|
||||
|
||||
|
||||
(->MockSolrClient)))
|
||||
|
||||
(defn touch-with-ledger [i]
|
||||
(index-documents impl "invoices" [i [:journal-entry/original-entity i]]))
|
||||
@@ -205,7 +199,6 @@
|
||||
([i index]
|
||||
(index-documents impl index [i])))
|
||||
|
||||
|
||||
(defrecord InMemSolrClient [data-set-atom]
|
||||
SolrClient
|
||||
(index-documents [this index xs]
|
||||
|
||||
Reference in New Issue
Block a user