almost allow completely adding new clients and sorting and filtering.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
|
||||
(let [result (reduce-kv
|
||||
(fn [m k v]
|
||||
(if v
|
||||
(if (not (nil? v))
|
||||
(assoc m k v)
|
||||
m
|
||||
))
|
||||
|
||||
@@ -11,9 +11,12 @@
|
||||
(map (fn [c]
|
||||
(update c :client/bank-accounts
|
||||
(fn [bas]
|
||||
(map (fn [ba]
|
||||
(update ba :bank-account/type :db/ident ))
|
||||
bas)))))))
|
||||
(map (fn [i ba]
|
||||
(-> ba
|
||||
(update :bank-account/type :db/ident )
|
||||
(update :bank-account/sort-order (fn [so] (or so i)))))
|
||||
(range) bas)))))
|
||||
))
|
||||
(defn get-by-id [id]
|
||||
(->>
|
||||
(d/query (-> {:query {:find ['(pull ?e [*])]
|
||||
|
||||
@@ -63,6 +63,9 @@
|
||||
:auto-ap/add-import-status-existing-invoices {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-import-status-existing-invoices :requires [:auto-ap/add-import-status]}
|
||||
:auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers :requires [:auto-ap/add-import-status-existing-invoices]}
|
||||
:auto-ap/add-new-vendors {:txes-fn 'auto-ap.datomic.migrate.add-new-vendors/add-new-vendors :requires [:auto-ap/fix-check-numbers]}
|
||||
:auto-ap/add-account-visibility-fields {:txes-fn 'auto-ap.datomic.migrate.account-sorting/add-account-visibility-fields :requires [:auto-ap/add-new-vendors]}
|
||||
:auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible :requires [:auto-ap/add-account-visibility-fields]}
|
||||
|
||||
}]
|
||||
(println "Conforming database...")
|
||||
(println (c/ensure-conforms conn norms-map))
|
||||
|
||||
27
src/clj/auto_ap/datomic/migrate/account_sorting.clj
Normal file
27
src/clj/auto_ap/datomic/migrate/account_sorting.clj
Normal file
@@ -0,0 +1,27 @@
|
||||
(ns auto-ap.datomic.migrate.account-sorting
|
||||
(:require [datomic.api :as d]))
|
||||
|
||||
|
||||
(defn add-account-visibility-fields [conn]
|
||||
[[
|
||||
{:db/ident :bank-account/visible
|
||||
:db/valueType :db.type/boolean
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "Whether this bank account is visible"}
|
||||
{:db/ident :bank-account/sort-order
|
||||
:db/valueType :db.type/long
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "The sort order of the bank account"}]])
|
||||
|
||||
(defn make-every-account-visible [conn]
|
||||
(let [all-account-ids (d/query
|
||||
{:query {:find ['?e]
|
||||
:in ['$]
|
||||
:where ['[?e :bank-account/code]]}
|
||||
:args [(d/db conn)]}
|
||||
)]
|
||||
[(map
|
||||
(fn [[account-id]]
|
||||
{:db/id account-id :bank-account/visible true}
|
||||
)
|
||||
all-account-ids)]))
|
||||
@@ -56,6 +56,8 @@
|
||||
{:fields {:id {:type :id }
|
||||
:type {:type :ident}
|
||||
:number {:type 'String}
|
||||
:sort_order {:type 'Int}
|
||||
:visible {:type 'Boolean}
|
||||
:routing {:type 'String}
|
||||
:code {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
@@ -295,6 +297,8 @@
|
||||
:type {:type :bank_account_type}
|
||||
:number {:type 'String}
|
||||
:check_number {:type 'Int}
|
||||
:visible {:type 'Boolean}
|
||||
:sort_order {:type 'Int}
|
||||
:name {:type 'String}
|
||||
:bank_code {:type 'String}
|
||||
:routing {:type 'String}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
(let [client (when (:id edit_client) (d-clients/get-by-id (:id edit_client)))
|
||||
id (or (:db/id client) "new-client")
|
||||
_ (println id)
|
||||
_ (println edit_client)
|
||||
transactions [(remove-nils {:db/id id
|
||||
:client/code (if (str/blank? (:client/code client))
|
||||
(:code edit_client)
|
||||
@@ -46,8 +47,10 @@
|
||||
:bank-account/routing (:routing %)
|
||||
|
||||
:bank-account/name (:name %)
|
||||
:bank-account/visible (:visible %)
|
||||
:bank-account/number (:number %)
|
||||
:bank-account/check-number (:check_number %)
|
||||
:bank-account/sort-order (:sort_order %)
|
||||
|
||||
:bank-account/yodlee-account-id (:yodlee_account_id %)
|
||||
:bank-account/type (keyword "bank-account-type" (name (:type %)))
|
||||
|
||||
Reference in New Issue
Block a user