feat(transactions): port manual bank-transaction import to SSR #8

Closed
notid wants to merge 133 commits from integreat-add-transaction-manual into master
Showing only changes of commit 4739769297 - Show all commits

View File

@@ -297,18 +297,19 @@
(defn account-grid-body* [request]
(let [snapshot (-> request :multi-form-state :snapshot)
amount-mode (or (:amount-mode snapshot) "$")
total (Math/abs (:transaction/amount snapshot))]
total (Math/abs (or (:transaction/amount snapshot) 0.0))]
(com/data-grid {:headers [(com/data-grid-header {} "Account")
(com/data-grid-header {:class "w-32"} "Location")
(com/data-grid-header {:class "w-16"}
(com/radio-card {:options [{:value "$" :content "$"}
{:value "%" :content "%"}]
:value amount-mode
:name "step-params[amount-mode]"
:hx-post (bidi/path-for ssr-routes/only-routes ::route/toggle-amount-mode)
:hx-target "#account-grid-body"
:hx-swap "outerHTML"
:hx-include "closest form"}))
(com/radio-card {:options [{:value "$" :content "$"}
{:value "%" :content "%"}]
:value amount-mode
:name "step-params[amount-mode]"
:orientation :horizontal
:hx-post (bidi/path-for ssr-routes/only-routes ::route/toggle-amount-mode)
:hx-target "#account-grid-body"
:hx-swap "outerHTML"
:hx-include "closest form"}))
(com/data-grid-header {:class "w-16"})]}
(fc/cursor-map #(transaction-account-row* {:value %
:client-id (-> request :entity :transaction/client :db/id)
@@ -1109,7 +1110,7 @@
client-id (->db-id (:transaction/client tx-data))
existing-tx (d-transactions/get-by-id tx-id)
amount-mode (or (:amount-mode tx-data) "$")
total (Math/abs (:transaction/amount existing-tx))
total (Math/abs (or (:transaction/amount existing-tx) 0.0))
tx-data (if (= "%" amount-mode)
(update tx-data :transaction/accounts
#(map (fn [account dollar-amount]
@@ -1314,12 +1315,12 @@
(fn render [cursor request]
(let [snapshot (-> request :multi-form-state :snapshot)
amount-mode (or (:amount-mode snapshot) "$")
total (Math/abs (:transaction/amount snapshot))]
(transaction-account-row*
{:value cursor
:client-id (:client-id (:query-params request))
:amount-mode amount-mode
:total total})))
total (Math/abs (or (:transaction/amount snapshot) 0.0))]
(transaction-account-row*
{:value cursor
:client-id (:client-id (:query-params request))
:amount-mode amount-mode
:total total})))
(fn build-new-row [base _]
(assoc base :transaction-account/location "Shared")))
(wrap-schema-enforce :query-schema [:map