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

@@ -23,11 +23,11 @@
line-2-2
line-3-1
line-3-2]} (:tempids @(d/transact conn [{:db/id "test-account-1"
:account/type :account-type/asset}
{:db/id "test-account-2"
:account/type :account-type/equity}
{:db/id "test-client"
:client/code "TEST"}
:account/type :account-type/asset}
{:db/id "test-account-2"
:account/type :account-type/equity}
{:db/id "test-client"
:client/code "TEST"}
[:upsert-ledger {:db/id "journal-entry-1"
:journal-entry/external-id "1"
:journal-entry/date #inst "2022-01-01"
@@ -66,19 +66,18 @@
:journal-entry-line/credit 150.0}]}]]))]
(testing "should set running-balance on ledger entries missing them"
(sut/upsert-running-balance)
(println (d/pull (d/db conn) '[*] line-1-1))
(is (= [-10.0 -60.0 -210.0]
(map #(pull-attr (d/db conn) :journal-entry-line/running-balance %) [line-1-1 line-2-1 line-3-1
])))
(map #(pull-attr (d/db conn) :journal-entry-line/running-balance %) [line-1-1 line-2-1 line-3-1])))
(is (= [10.0 60.0 210.0]
(map #(pull-attr (d/db conn) :journal-entry-line/running-balance %) [line-1-2 line-2-2 line-3-2]))))
(testing "should recompute if the data is out of date"
(d/transact conn
(d/transact conn
[{:db/id line-1-1
:journal-entry-line/dirty true
:journal-entry-line/running-balance 123810.23}])
@@ -89,7 +88,7 @@
(testing "should recompute every entry after the out of date one"
(d/transact conn
(d/transact conn
[{:db/id line-1-1
:journal-entry-line/dirty true
:journal-entry-line/debit 70.0}])
@@ -98,40 +97,39 @@
(map #(pull-attr (d/db conn) :journal-entry-line/running-balance %) [line-1-1 line-2-1 line-3-1]))))
(testing "should not recompute entries that aren't dirty"
(d/transact conn
(d/transact conn
[{:db/id line-1-1
:journal-entry-line/dirty false
:journal-entry-line/debit 90.0}])
(sut/upsert-running-balance)
(is (= [-70.0 -120.0 -270.0]
(map #(pull-attr (d/db conn) :journal-entry-line/running-balance %) [line-1-1 line-2-1 line-3-1])))
(map #(pull-attr (d/db conn) :journal-entry-line/running-balance %) [line-1-1 line-2-1 line-3-1]))))
)
(testing "changing a ledger entry should mark the line items as dirty"
(println "AFTER HERE")
@(d/transact conn
[[:upsert-ledger {:db/id journal-entry-2
:journal-entry/date #inst "2022-01-02"
:journal-entry/client test-client
:journal-entry/external-id "2"
:journal-entry/line-items [{:db/id "line-2-1"
:journal-entry-line/account test-account-1
:journal-entry-line/location "A"
:journal-entry-line/debit 50.0}
{:db/id "line-2-2"
:journal-entry-line/account test-account-2
:journal-entry-line/location "A"
:journal-entry-line/credit 50.0}]}]])
@(d/transact conn
[[:upsert-ledger {:db/id journal-entry-2
:journal-entry/date #inst "2022-01-02"
:journal-entry/client test-client
:journal-entry/external-id "2"
:journal-entry/line-items [{:db/id "line-2-1"
:journal-entry-line/account test-account-1
:journal-entry-line/location "A"
:journal-entry-line/debit 50.0}
{:db/id "line-2-2"
:journal-entry-line/account test-account-2
:journal-entry-line/location "A"
:journal-entry-line/credit 50.0}]}]])
(is (= [true true]
(->> (d/pull (d/db conn) '[{:journal-entry/line-items [:journal-entry-line/dirty]}] journal-entry-2)
(:journal-entry/line-items)
(map :journal-entry-line/dirty))))
(testing "should also mark the next entry as dirty, so that if a ledger entry is changed, the old accounts get updated"
(is (= [false false]
(->> (d/pull (d/db conn) '[{:journal-entry/line-items [:journal-entry-line/dirty]}] journal-entry-1)
(:journal-entry/line-items)
(map :journal-entry-line/dirty))))
(is (= [true true]
(->> (d/pull (d/db conn) '[{:journal-entry/line-items [:journal-entry-line/dirty]}] journal-entry-2)
(:journal-entry/line-items)
(map :journal-entry-line/dirty))))
(testing "should also mark the next entry as dirty, so that if a ledger entry is changed, the old accounts get updated"
(is (= [false false]
(->> (d/pull (d/db conn) '[{:journal-entry/line-items [:journal-entry-line/dirty]}] journal-entry-1)
(:journal-entry/line-items)
(map :journal-entry-line/dirty))))
(is (= [true true]
(->> (d/pull (d/db conn) '[{:journal-entry/line-items [:journal-entry-line/dirty]}] journal-entry-2)
(:journal-entry/line-items)
(map :journal-entry-line/dirty))))))))
(map :journal-entry-line/dirty))))))))