From 3441ae63b464991834fb381dc6db31fc9f7aba41 Mon Sep 17 00:00:00 2001 From: Bryce Date: Thu, 28 May 2026 00:10:15 -0700 Subject: [PATCH] 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. --- src/clj/auto_ap/ssr/transaction/edit.clj | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/clj/auto_ap/ssr/transaction/edit.clj b/src/clj/auto_ap/ssr/transaction/edit.clj index 61221cde..87be5931 100644 --- a/src/clj/auto_ap/ssr/transaction/edit.clj +++ b/src/clj/auto_ap/ssr/transaction/edit.clj @@ -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)