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:
2026-05-21 14:45:19 -07:00
parent 8bd0cee1b1
commit ba87805d4c
210 changed files with 8694 additions and 9627 deletions

View File

@@ -126,8 +126,8 @@
;; Test passes if sorting parameter is accepted and function returns successfully
(is (number? matching-count)))))
(deftest account-sorting-by-numeric-code
(testing "Account sorting by numeric code should work (default)"
(deftest account-sorting-by-numeric-code
(testing "Account sorting by numeric code should work (default)"
(with-redefs [auto-ap.solr/impl (auto-ap.solr/->InMemSolrClient (atom {}))]
;; Create test accounts before sorting
(sut/account-save {:form-params {:account/numeric-code 12372 :account/name "Numeric Account" :account/type :account-type/asset :account/location "A"} :request-method :post :identity (admin-token)})
@@ -138,8 +138,8 @@
;; Test passes if sorting parameter is accepted and function returns successfully
(is (number? matching-count))))))
(deftest account-sorting-by-type
(testing "Account sorting by type should work"
(deftest account-sorting-by-type
(testing "Account sorting by type should work"
(with-redefs [auto-ap.solr/impl (auto-ap.solr/->InMemSolrClient (atom {}))]
;; Create test accounts before sorting
(sut/account-save {:form-params {:account/numeric-code 12374 :account/name "Type Test" :account/type :account-type/asset :account/location "A"} :request-method :post :identity (admin-token)})

View File

@@ -411,7 +411,7 @@
:location "HQ"}]}
admin-identity (admin-token)]
(is (thrown? Exception (sut/import-ledger {:form-params form-params
:identity admin-identity})))))
:identity admin-identity})))))
(testing "Should produce form-errors for invalid account entries"
(let [_ (setup-test-data [(test-client :db/id "err-client-1"
@@ -430,7 +430,7 @@
:location "HQ"}]}
admin-identity (admin-token)]
(is (thrown? Exception (sut/import-ledger {:form-params form-params
:identity admin-identity}))))))
:identity admin-identity}))))))
(deftest import-ledger-with-warnings-test
(testing "Should ignore entries with only warnings"

View File

@@ -15,14 +15,14 @@
[datomic.api :as dc]))
#_(t/use-fixtures :each (fn [f]
(dc/transact conn [{:db/id "vendor-id"
:vendor/name "Test Vendor"
:vendor/default-account {:db/id "account-id"}}
{:db/id "client-id"
:client/code "TEST"
:client/locations ["Z" "E"]
:client/bank-accounts ["bank-account-id"]}])
(f)))
(dc/transact conn [{:db/id "vendor-id"
:vendor/name "Test Vendor"
:vendor/default-account {:db/id "account-id"}}
{:db/id "client-id"
:client/code "TEST"
:client/locations ["Z" "E"]
:client/bank-accounts ["bank-account-id"]}])
(f)))
(t/use-fixtures :each wrap-setup)
(t/deftest get-vendor-test
@@ -39,11 +39,11 @@
(t/deftest clientize-vendor-test
(t/testing "Should transform vendor data for a specific client"
(let [vendor {:db/id "vendor-id"
:vendor/name "Test Vendor"
:vendor/default-account {:db/id "account-id"}
:vendor/terms-overrides [{:vendor-terms-override/client {:db/id "client-id"}
:vendor/name "Test Vendor"
:vendor/default-account {:db/id "account-id"}
:vendor/terms-overrides [{:vendor-terms-override/client {:db/id "client-id"}
:vendor-terms-override/terms "New Terms"}]
:vendor/account-overrides [{:vendor-account-override/client {:db/id "client-id"}
:vendor/account-overrides [{:vendor-account-override/client {:db/id "client-id"}
:vendor-account-override/account {:db/id "client-specific-account-id"}}]}
clientized-vendor (clientize-vendor vendor "client-id")]
(t/is (= "New Terms" (:vendor/terms clientized-vendor)))