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

Closed
notid wants to merge 133 commits from integreat-add-transaction-manual into master
2 changed files with 13 additions and 7 deletions
Showing only changes of commit 9cc3418b1b - Show all commits

View File

@@ -9,7 +9,9 @@
[auto-ap.graphql.utils :refer [assert-admin]]
[auto-ap.import.manual :as manual]
[auto-ap.import.transactions :as t]
[auto-ap.permissions :refer [wrap-must]]
[auto-ap.routes.transactions :as route]
[auto-ap.routes.utils :refer [wrap-client-redirect-unauthenticated]]
[auto-ap.ssr-routes :as ssr-routes]
[auto-ap.ssr.components :as com]
[auto-ap.ssr.form-cursor :as fc]
@@ -17,16 +19,13 @@
[auto-ap.ssr.nested-form-params :refer [wrap-nested-form-params]]
[auto-ap.ssr.ui :refer [base-page]]
[auto-ap.ssr.utils
:refer [apply-middleware-to-all-handlers html-response strip
:refer [apply-middleware-to-all-handlers html-response
wrap-form-4xx-2 wrap-schema-decode wrap-schema-enforce]]
[auto-ap.permissions :refer [wrap-must]]
[auto-ap.routes.utils :refer [wrap-client-redirect-unauthenticated]]
[bidi.bidi :as bidi]
[clojure.data.csv :as csv]
[clojure.java.io :as io]
[clojure.string :as str]
[datomic.api :as dc]
[digest :as di]
[malli.core :as mc]
[slingshot.slingshot :refer [throw+]]))

View File

@@ -72,11 +72,18 @@
(is has-errors?)
(is (some (fn [[m _]] (re-find #"bank account" m)) (get-in form-errors [:table 0])))))
(testing "Unknown client (via bank-account code) is a hard error"
(testing "Unknown client fires independently when the bank account exists but is linked to no client"
@(dc/transact conn [{:db/id "orphan-ba"
:bank-account/code "ORPHAN-CHK"
:bank-account/type :bank-account-type/check}])
(let [{:keys [form-errors has-errors?]}
(sut/classify-table [{:raw-date "01/15/2024" :amount "1.00" :bank-account-code "NOPE"}])]
(sut/classify-table [{:raw-date "01/15/2024" :amount "1.00" :bank-account-code "ORPHAN-CHK"}])
msgs (map first (get-in form-errors [:table 0]))]
(is has-errors?)
(is (some (fn [[m _]] (re-find #"client" m)) (get-in form-errors [:table 0])))))
(is (some #(re-find #"Cannot find client" %) msgs)
"client-not-found error fires")
(is (not (some #(re-find #"bank account by code" %) msgs))
"bank-account-not-found error does not fire because the bank account exists")))
(testing "Invalid date is a hard error"
(let [{:keys [form-errors has-errors?]}