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:
@@ -24,12 +24,12 @@
|
||||
:account/name "Food"})
|
||||
|
||||
(defn invoice-count-for-client [c]
|
||||
(or
|
||||
(first (first (dc/q '[:find (count ?i)
|
||||
(or
|
||||
(first (first (dc/q '[:find (count ?i)
|
||||
:in $ ?c
|
||||
:where [?i :invoice/client ?c]]
|
||||
(dc/db conn) c)))
|
||||
0))
|
||||
0))
|
||||
|
||||
(def invoice {:customer-identifier "ABC"
|
||||
:date (coerce/to-date-time #inst "2021-01-01")
|
||||
@@ -49,11 +49,10 @@
|
||||
|
||||
(t/testing "Should only import the same invoice once"
|
||||
(t/is (thrown? Exception (sut/import-uploaded-invoice user [(assoc invoice :customer-identifier "ABC")])))
|
||||
|
||||
|
||||
|
||||
(t/is (thrown? Exception (sut/import-uploaded-invoice user [(assoc invoice
|
||||
:customer-identifier "ABC"
|
||||
:total "456.32")]))))
|
||||
:customer-identifier "ABC"
|
||||
:total "456.32")]))))
|
||||
|
||||
(t/testing "Should override location"
|
||||
(sut/import-uploaded-invoice user [(assoc invoice
|
||||
@@ -61,26 +60,26 @@
|
||||
:customer-identifier "ABC"
|
||||
:invoice-number "789")])
|
||||
(t/is (= #{["DE"]} (dc/q '[:find ?l
|
||||
:where [?i :invoice/invoice-number "789"]
|
||||
[?i :invoice/expense-accounts ?ea]
|
||||
[?ea :invoice-expense-account/location ?l]]
|
||||
(dc/db conn)))))
|
||||
:where [?i :invoice/invoice-number "789"]
|
||||
[?i :invoice/expense-accounts ?ea]
|
||||
[?ea :invoice-expense-account/location ?l]]
|
||||
(dc/db conn)))))
|
||||
|
||||
(t/testing "Should code invoice"
|
||||
(let [{{:strs [my-default-account coded-vendor]} :tempids} @(dc/transact conn
|
||||
[{:vendor/name "Coded"
|
||||
:db/id "coded-vendor"
|
||||
:vendor/terms 12
|
||||
:vendor/default-account "my-default-account"}
|
||||
{:db/id "my-default-account"
|
||||
:account/name "My default-account"}])]
|
||||
[{:vendor/name "Coded"
|
||||
:db/id "coded-vendor"
|
||||
:vendor/terms 12
|
||||
:vendor/default-account "my-default-account"}
|
||||
{:db/id "my-default-account"
|
||||
:account/name "My default-account"}])]
|
||||
(sut/import-uploaded-invoice user [(assoc invoice
|
||||
:invoice-number "456"
|
||||
:customer-identifier "ABC"
|
||||
:vendor-code "Coded")])
|
||||
:invoice-number "456"
|
||||
:customer-identifier "ABC"
|
||||
:vendor-code "Coded")])
|
||||
(let [[[result]] (dc/q '[:find (pull ?i [*])
|
||||
:where [?i :invoice/invoice-number "456"]]
|
||||
(dc/db conn))]
|
||||
:where [?i :invoice/invoice-number "456"]]
|
||||
(dc/db conn))]
|
||||
(t/is (= coded-vendor (:db/id (:invoice/vendor result))))
|
||||
(t/is (= [my-default-account]
|
||||
(map (comp :db/id :invoice-expense-account/account) (:invoice/expense-accounts result))))
|
||||
|
||||
Reference in New Issue
Block a user