From 205b17164b613d0dba64a525fa5f464aa5ea67a6 Mon Sep 17 00:00:00 2001 From: Bryce Covert Date: Tue, 31 May 2022 15:57:47 -0700 Subject: [PATCH] fixes rule page --- src/clj/auto_ap/graphql/accounts.clj | 3 +- .../components/expense_accounts_field.cljs | 1 + .../views/pages/admin/excel_import.cljs | 1 - .../views/pages/admin/rules/common.cljs | 5 +-- .../auto_ap/views/pages/admin/rules/form.cljs | 39 +++++++++---------- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/clj/auto_ap/graphql/accounts.clj b/src/clj/auto_ap/graphql/accounts.clj index df41f850..1e442977 100644 --- a/src/clj/auto_ap/graphql/accounts.clj +++ b/src/clj/auto_ap/graphql/accounts.clj @@ -43,7 +43,8 @@ :account/name name :account/search-terms name :account/type (keyword "account-type" (clojure.core/name type)) - :account/applicability (enum->keyword applicability "account-applicability") + :account/applicability (or (enum->keyword applicability "account-applicability") + :account-applicability/global) :account/account-set account-set :account/location location :account/numeric-code (when-not id diff --git a/src/cljs/auto_ap/views/components/expense_accounts_field.cljs b/src/cljs/auto_ap/views/components/expense_accounts_field.cljs index 5ce35fb5..06e02d4e 100644 --- a/src/cljs/auto_ap/views/components/expense_accounts_field.cljs +++ b/src/cljs/auto_ap/views/components/expense_accounts_field.cljs @@ -163,6 +163,7 @@ [:div.column.is-narrow [:p.help "Location"] [:div.control + (println account) (if-let [forced-location (:location account)] [:div.select [:select {:disabled "disabled" :style {:width "5em"} :value forced-location} [:option {:value forced-location} forced-location]]] diff --git a/src/cljs/auto_ap/views/pages/admin/excel_import.cljs b/src/cljs/auto_ap/views/pages/admin/excel_import.cljs index c5c96126..380f067e 100644 --- a/src/cljs/auto_ap/views/pages/admin/excel_import.cljs +++ b/src/cljs/auto_ap/views/pages/admin/excel_import.cljs @@ -108,7 +108,6 @@ chooseable-expense-accounts @(re-frame/subscribe [::subs/all-accounts]) change-event [::all-events/change-form [::expense-accounts]]] - (println form) [:div [:h1.title "Import Invoices from Integreat Excel"] (when (seq vendors-not-found) diff --git a/src/cljs/auto_ap/views/pages/admin/rules/common.cljs b/src/cljs/auto_ap/views/pages/admin/rules/common.cljs index e02ca388..ef1105d6 100644 --- a/src/cljs/auto_ap/views/pages/admin/rules/common.cljs +++ b/src/cljs/auto_ap/views/pages/admin/rules/common.cljs @@ -12,8 +12,7 @@ [:vendor [:name :id]] [:client [:name :id]] [:bank-account [:name :id]] - [:accounts [[:account [:id :name :numeric-code]] + [:accounts [[:account [:id :name :numeric-code :location]] :id :percentage - :location]] - ]) + :location]]]) diff --git a/src/cljs/auto_ap/views/pages/admin/rules/form.cljs b/src/cljs/auto_ap/views/pages/admin/rules/form.cljs index e80e75c3..bf967e9c 100644 --- a/src/cljs/auto_ap/views/pages/admin/rules/form.cljs +++ b/src/cljs/auto_ap/views/pages/admin/rules/form.cljs @@ -146,27 +146,24 @@ (re-frame/reg-event-db ::editing (fn [db [_ which]] - (let [accounts-by-id @(re-frame/subscribe [::subs/all-accounts-by-id (:client which)])] - (-> db (forms/start-form ::form (-> which - (select-keys [:description - :id - :client - :bank-account - :note - :amount-lte - :amount-gte - :dom-lte - :dom-gte - :vendor - :accounts - :yodlee-merchant - :transaction-approval-status]) - (update :accounts (fn [xs] - (mapv #(-> % - (assoc :amount-percentage (* (:percentage %) 100.0)) - (update :account (fn [a] - (accounts-by-id (:id a))))) - xs))))))))) + (-> db (forms/start-form ::form (-> which + (select-keys [:description + :id + :client + :bank-account + :note + :amount-lte + :amount-gte + :dom-lte + :dom-gte + :vendor + :accounts + :yodlee-merchant + :transaction-approval-status]) + (update :accounts (fn [xs] + (mapv #(-> % + (assoc :amount-percentage (* (:percentage %) 100.0))) + xs)))))))) (re-frame/reg-event-fx