diff --git a/src/clj/auto_ap/datomic/transactions.clj b/src/clj/auto_ap/datomic/transactions.clj index 078535a1..47f95911 100644 --- a/src/clj/auto_ap/datomic/transactions.clj +++ b/src/clj/auto_ap/datomic/transactions.clj @@ -3,7 +3,8 @@ [auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields conn]] [auto-ap.graphql.utils :refer [limited-clients]] [clj-time.coerce :as c] - [clj-time.coerce :as coerce])) + [clj-time.coerce :as coerce] + [clojure.tools.logging :as log])) (defn sort-fn [sort-by] (cond @@ -102,7 +103,8 @@ :args [(:location args)]}) (:unresolved args) - (merge-query {:query {:where ['(or-join [?e] + (merge-query {:query {:where ['[?e :transaction/date] + '(or-join [?e] (not [?e :transaction/accounts]) (and [?e :transaction/accounts ?tas] (not [?tas :transaction-account/account])))]}}) @@ -136,6 +138,7 @@ (merge-query {:query {:find ['?sort-default '?e] :where ['[?e :transaction/id] '[?e :transaction/date ?sort-default]]}}))] + (log/info "query is" query) (cond->> query true (d/query) true (apply-sort-3 args) diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index c9bb638c..20d72b9f 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -1187,7 +1187,8 @@ month (range -1 7) :let [next (t/plus (t/local-date (t/year (time/local-now)) (t/month (time/local-now)) - day-of-month ) + (Math/min (Math/max day-of-month 1) + 30) ) (t/months month))] :when (not (has-fulfilled? id next recent-fulfillments))] {:identifier identifier diff --git a/src/clj/auto_ap/graphql/clients.clj b/src/clj/auto_ap/graphql/clients.clj index 9c46ac22..77783f28 100644 --- a/src/clj/auto_ap/graphql/clients.clj +++ b/src/clj/auto_ap/graphql/clients.clj @@ -31,8 +31,7 @@ :input-stream (io/make-input-stream raw-bytes {}) :metadata {:content-type "image/jpeg"} :canned-acl "public-read") - (str "https://integreat-signature-images.s3.amazonaws.com/" signature-id ".jpg") - )))) + (str "https://integreat-signature-images.s3.amazonaws.com/" signature-id ".jpg"))))) (defn edit-client [context {:keys [edit_client new_bank_accounts] :as args} value] (assert-admin (:id context)) diff --git a/src/clj/auto_ap/yodlee/core2.clj b/src/clj/auto_ap/yodlee/core2.clj index 836e7f0f..d5d780e9 100644 --- a/src/clj/auto_ap/yodlee/core2.clj +++ b/src/clj/auto_ap/yodlee/core2.clj @@ -279,20 +279,23 @@ ([client-code provider-accounts] (let [accounts (get-accounts-for-providers (client-code->login client-code) (map :id provider-accounts))] (map (fn [pa] - {:yodlee-provider-account/id (:id pa) - :yodlee-provider-account/status (:status pa) - :yodlee-provider-account/detailed-status (-> pa :dataset first :additionalStatus) - :yodlee-provider-account/client [:client/code client-code] - :yodlee-provider-account/last-updated (-> pa :dataset first :lastUpdated coerce/to-date) - :yodlee-provider-account/accounts (mapv - (fn [a] - {:yodlee-account/id (:id a) - :yodlee-account/name (str (:providerName a) " (" (:accountName a) ")") - :yodlee-account/number (:accountNumber a) - :yodlee-account/status (-> a :dataset first :additionalStatus) - :yodlee-account/available-balance (or (-> a :currentBalance :amount) - 0.0)}) - (get accounts (:id pa)))}) + (cond-> + {:yodlee-provider-account/id (:id pa) + :yodlee-provider-account/status (:status pa) + :yodlee-provider-account/detailed-status (-> pa :dataset first :additionalStatus) + :yodlee-provider-account/client [:client/code client-code] + + :yodlee-provider-account/accounts (mapv + (fn [a] + {:yodlee-account/id (:id a) + :yodlee-account/name (str (:providerName a) " (" (:accountName a) ")") + :yodlee-account/number (:accountNumber a) + :yodlee-account/status (-> a :dataset first :additionalStatus) + :yodlee-account/available-balance (or (-> a :currentBalance :amount) + 0.0)}) + (get accounts (:id pa)))} + + (-> pa :dataset first :lastUpdated) (assoc :yodlee-provider-account/last-updated (-> pa :dataset first :lastUpdated coerce/to-date)) )) provider-accounts)))) (defn refresh-provider-account [client-code id] diff --git a/src/cljs/auto_ap/views/components/layouts.cljs b/src/cljs/auto_ap/views/components/layouts.cljs index 21b5cc7a..2f8c3cb8 100644 --- a/src/cljs/auto_ap/views/components/layouts.cljs +++ b/src/cljs/auto_ap/views/components/layouts.cljs @@ -134,7 +134,7 @@ (when (> (count @clients) 1) - [navbar-drop-down {:header (str "Client: " (if @client (:name @client) + [navbar-drop-down {:header (str "Company: " (if @client (:name @client) "All")) :id ::select-client} [:div @@ -143,7 +143,7 @@ (re-frame/dispatch [::events/swap-client nil]))} "All" ] [:hr {:class "navbar-divider"}] [bind-field - [:input.input.navbar-item {:placeholder "Client name" + [:input.input.navbar-item {:placeholder "Company name" :auto-focus true :field [:value] :on-key-up (fn [k] diff --git a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs index 10f8e7d7..8722e540 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs @@ -23,6 +23,24 @@ (def signature-canvas (r/adapt-react-class (.-default canvas))) +(defn upload-replacement-button [{:keys [on-change]} text] + (let [button (atom nil)] + (r/create-class {:display-name "Upload button" + :reagent-render + (fn [] + [:<> + [:label.button {:for "upload_replacement_signature"} text] + [:input.button {:type "file" :id "upload_replacement_signature" + :style {:display "none"} + :on-change (fn [] + (let [fr (js/FileReader.)] + (.addEventListener fr "load" (fn [] + (on-change (.-result fr)))) + + (.readAsDataURL fr (aget (.-files @button) 0))) + ) + :ref (fn [i] (reset! button i))} ]])}))) + (defn signature [{:keys [signature-file signature-data on-change]}] (let [canvas (atom nil) edit-mode? (r/atom false) @@ -56,7 +74,9 @@ [:div.buttons [:a.button {:on-click (fn [] (reset! edit-mode? true))} - "Replace Signature"]]] + "Replace Signature"] + + [upload-replacement-button {:on-change on-change} "Upload replacement"]]] [:div [:div.has-text-centered.is-vcentered {:style {:width w :height h @@ -66,7 +86,9 @@ [:div.buttons [:a.button.is-primary.is-outlined {:on-click (fn [] (reset! edit-mode? true))} - "New Signature"]]])) + "New Signature"] + + [upload-replacement-button {:on-change on-change} "Upload signature"]]])) ]))) (re-frame/reg-sub diff --git a/src/cljs/auto_ap/views/pages/admin/yodlee2.cljs b/src/cljs/auto_ap/views/pages/admin/yodlee2.cljs index 353f239c..d40db8e8 100644 --- a/src/cljs/auto_ap/views/pages/admin/yodlee2.cljs +++ b/src/cljs/auto_ap/views/pages/admin/yodlee2.cljs @@ -410,23 +410,28 @@ (let [authentication @(re-frame/subscribe [::authentication]) status @(re-frame/subscribe [::status/single ::authenticating]) client-code (:code @(re-frame/subscribe [::subs/client]))] - (if (and authentication client-code) - [:div - "Authentication successful!" - [:div#fa-spot] - [:button.button.is-primary {:on-click (fn [] - (.open (.-fastlink js/window) - #js {"fastLinkURL" (:url authentication) - "accessToken" (:token authentication) - "params" #js { "configName" "Aggregation"}} - - "fa-spot") - )} - [:span [:span.icon [:i.fa.fa-external-link]] " Go to yodlee"]]] - [:button.button.is-primary {:disabled (status/disabled-for status) - :class (status/class-for status) - :on-click (dispatch-event [::authenticate-with-yodlee client-code])} - "Authenticate with Yodlee (" client-code ")"]))]) + (cond (and authentication client-code) + [:div + "Authentication successful!" + [:div#fa-spot] + [:button.button.is-primary {:on-click (fn [] + (.open (.-fastlink js/window) + #js {"fastLinkURL" (:url authentication) + "accessToken" (:token authentication) + "params" #js { "configName" "Aggregation"}} + + "fa-spot") + )} + [:span [:span.icon [:i.fa.fa-external-link]] " Go to yodlee"]]] + + client-code + [:button.button.is-primary {:disabled (status/disabled-for status) + :class (status/class-for status) + :on-click (dispatch-event [::authenticate-with-yodlee client-code])} + "Authenticate with Yodlee (" client-code ")"] + + :else + nil))]) (defn admin-yodlee-provider-accounts-content [] [:div