From 8189a7648b361fb7a93fbae0ac90beb4465c2bfa Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 20 May 2026 21:33:44 -0700 Subject: [PATCH] Fix Datomic conflict when spreading shared location across accounts When a transaction account had 'Shared' location, spread-account was creating multiple accounts with the same :db/id but different locations, causing a datoms-conflict error in Datomic. Now generates unique tempids for all spread accounts beyond the first, preventing entity ID collisions while preserving the original account's tempid for the first location. Fixes: Two datoms in the same transaction conflict on :transaction-account/location --- src/clj/auto_ap/ssr/transaction/edit.clj | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/clj/auto_ap/ssr/transaction/edit.clj b/src/clj/auto_ap/ssr/transaction/edit.clj index b2a7a8c3..8f4afe6d 100644 --- a/src/clj/auto_ap/ssr/transaction/edit.clj +++ b/src/clj/auto_ap/ssr/transaction/edit.clj @@ -1002,6 +1002,9 @@ (let [{:keys [base-amount remainder]} (calculate-spread (:transaction-account/amount account) (count locations))] (map-indexed (fn [idx _] (assoc account + :db/id (if (= idx 0) + (:db/id account) + (random-tempid)) :transaction-account/amount (+ base-amount (if (< idx remainder) 1 0)) :transaction-account/location (nth locations idx))) locations))