fix: normalize account ref map to db/id in simple mode rendering

When a transaction is pre-coded, the snapshot stores :transaction-account/account
as a Datomic ref map {:db/id N} rather than a bare integer. simple-mode-fields*
and the simpleAccountId Alpine initializer both need the integer id, not the map,
to correctly populate the account typeahead value and the x-hx-val binding.
This commit is contained in:
2026-05-28 00:10:15 -07:00
parent 79ddda624a
commit 3441ae63b4

View File

@@ -191,7 +191,8 @@
(:transaction/client snapshot))
existing-row (first (or (seq (:transaction/accounts step-params))
(seq (:transaction/accounts snapshot))))
account-val (:transaction-account/account existing-row)
account-val (let [av (:transaction-account/account existing-row)]
(if (map? av) (:db/id av) av))
location-val (or (:transaction-account/location existing-row) "Shared")
account-id (when (nat-int? account-val)
(dc/pull (dc/db conn) '[:account/location] account-val))
@@ -527,8 +528,8 @@
:content-fn (fn [c] (pull-attr (dc/db conn) :vendor/name c))})]))]
(if (= mode :simple)
[:div {:x-data (hx/json {:simpleAccountId
(-> (first all-accounts)
:transaction-account/account)})}
(let [av (-> (first all-accounts) :transaction-account/account)]
(if (map? av) (:db/id av) av))})}
(simple-mode-fields* request)]
[:div
(when (<= row-count 1)