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:
@@ -1,8 +1,8 @@
|
||||
(ns auto-ap.ssr.transaction
|
||||
(:require
|
||||
[auto-ap.datomic
|
||||
:refer [audit-transact audit-transact-batch conn pull-attr
|
||||
pull-many]]
|
||||
:refer [audit-transact audit-transact-batch conn pull-attr
|
||||
pull-many]]
|
||||
[auto-ap.logging :as alog]
|
||||
[auto-ap.permissions :refer [wrap-must]]
|
||||
[auto-ap.query-params :refer [wrap-copy-qp-pqp]]
|
||||
@@ -20,10 +20,10 @@
|
||||
wrap-status-from-source]]
|
||||
[auto-ap.ssr.transaction.edit :as edit :refer [transaction-account-row*]]
|
||||
[auto-ap.ssr.utils
|
||||
:refer [apply-middleware-to-all-handlers entity-id html-response
|
||||
many-entity modal-response percentage ref->enum-schema
|
||||
wrap-implied-route-param wrap-merge-prior-hx
|
||||
wrap-schema-enforce]]
|
||||
:refer [apply-middleware-to-all-handlers entity-id html-response
|
||||
many-entity modal-response percentage ref->enum-schema
|
||||
wrap-implied-route-param wrap-merge-prior-hx
|
||||
wrap-schema-enforce]]
|
||||
[bidi.bidi :as bidi]
|
||||
[clojure.string :as str]
|
||||
[datomic.api :as dc]
|
||||
@@ -39,8 +39,6 @@
|
||||
|
||||
(def page (helper/page-route grid-page))
|
||||
|
||||
|
||||
|
||||
(def table (helper/table-route grid-page))
|
||||
|
||||
(def csv (helper/csv-route grid-page))
|
||||
@@ -60,29 +58,29 @@
|
||||
selected)
|
||||
all-ids (all-ids-not-locked ids)
|
||||
db (dc/db conn)]
|
||||
|
||||
|
||||
(alog/info ::bulk-delete-transactions
|
||||
:count (count all-ids)
|
||||
:sample (take 3 all-ids))
|
||||
|
||||
|
||||
;; First retract journal entries and handle payment relationships
|
||||
(audit-transact
|
||||
(mapcat (fn [i]
|
||||
(let [transaction (dc/pull db [:transaction/payment
|
||||
:transaction/expected-deposit
|
||||
:db/id] i)
|
||||
payment-id (-> transaction :transaction/payment :db/id)
|
||||
expected-deposit-id (-> transaction :transaction/expected-deposit :db/id)]
|
||||
(cond->> [[:db/retractEntity [:journal-entry/original-entity i]]]
|
||||
payment-id (into [{:db/id payment-id
|
||||
:payment/status :payment-status/pending}
|
||||
[:db/retract (:db/id transaction) :transaction/payment payment-id]])
|
||||
expected-deposit-id (into [{:db/id expected-deposit-id
|
||||
(audit-transact
|
||||
(mapcat (fn [i]
|
||||
(let [transaction (dc/pull db [:transaction/payment
|
||||
:transaction/expected-deposit
|
||||
:db/id] i)
|
||||
payment-id (-> transaction :transaction/payment :db/id)
|
||||
expected-deposit-id (-> transaction :transaction/expected-deposit :db/id)]
|
||||
(cond->> [[:db/retractEntity [:journal-entry/original-entity i]]]
|
||||
payment-id (into [{:db/id payment-id
|
||||
:payment/status :payment-status/pending}
|
||||
[:db/retract (:db/id transaction) :transaction/payment payment-id]])
|
||||
expected-deposit-id (into [{:db/id expected-deposit-id
|
||||
:expected-deposit/status :expected-deposit-status/pending}
|
||||
[:db/retract (:db/id transaction) :transaction/expected-deposit expected-deposit-id]]))))
|
||||
all-ids)
|
||||
(:identity request))
|
||||
|
||||
all-ids)
|
||||
(:identity request))
|
||||
|
||||
;; Then retract or suppress the transactions
|
||||
(audit-transact
|
||||
(mapcat (fn [i]
|
||||
@@ -94,14 +92,12 @@
|
||||
[:db/retractEntity [:journal-entry/original-entity i]]]))
|
||||
all-ids)
|
||||
(:identity request))
|
||||
|
||||
(html-response
|
||||
|
||||
(html-response
|
||||
(com/success-modal {:title "Transactions Updated"}
|
||||
[:p (str "Successfully " (if suppress "suppressed" "deleted") " " (count all-ids) " transactions.")])
|
||||
:headers {"hx-trigger" "invalidated"})))
|
||||
|
||||
|
||||
|
||||
(def key->handler
|
||||
(merge edit/key->handler
|
||||
bulk-code/key->handler
|
||||
|
||||
Reference in New Issue
Block a user