Merge branch 'staging' into add-scheduled-payment-filter

This commit is contained in:
Bryce Covert
2021-01-11 12:09:10 -08:00
7 changed files with 73 additions and 40 deletions

View File

@@ -3,7 +3,8 @@
[auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields conn]] [auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields conn]]
[auto-ap.graphql.utils :refer [limited-clients]] [auto-ap.graphql.utils :refer [limited-clients]]
[clj-time.coerce :as c] [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] (defn sort-fn [sort-by]
(cond (cond
@@ -102,7 +103,8 @@
:args [(:location args)]}) :args [(:location args)]})
(:unresolved args) (:unresolved args)
(merge-query {:query {:where ['(or-join [?e] (merge-query {:query {:where ['[?e :transaction/date]
'(or-join [?e]
(not [?e :transaction/accounts]) (not [?e :transaction/accounts])
(and [?e :transaction/accounts ?tas] (and [?e :transaction/accounts ?tas]
(not [?tas :transaction-account/account])))]}}) (not [?tas :transaction-account/account])))]}})
@@ -136,6 +138,7 @@
(merge-query {:query {:find ['?sort-default '?e] (merge-query {:query {:find ['?sort-default '?e]
:where ['[?e :transaction/id] :where ['[?e :transaction/id]
'[?e :transaction/date ?sort-default]]}}))] '[?e :transaction/date ?sort-default]]}}))]
(log/info "query is" query)
(cond->> query (cond->> query
true (d/query) true (d/query)
true (apply-sort-3 args) true (apply-sort-3 args)

View File

@@ -1187,7 +1187,8 @@
month (range -1 7) month (range -1 7)
:let [next (t/plus (t/local-date (t/year (time/local-now)) :let [next (t/plus (t/local-date (t/year (time/local-now))
(t/month (time/local-now)) (t/month (time/local-now))
day-of-month ) (Math/min (Math/max day-of-month 1)
30) )
(t/months month))] (t/months month))]
:when (not (has-fulfilled? id next recent-fulfillments))] :when (not (has-fulfilled? id next recent-fulfillments))]
{:identifier identifier {:identifier identifier

View File

@@ -31,8 +31,7 @@
:input-stream (io/make-input-stream raw-bytes {}) :input-stream (io/make-input-stream raw-bytes {})
:metadata {:content-type "image/jpeg"} :metadata {:content-type "image/jpeg"}
:canned-acl "public-read") :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] (defn edit-client [context {:keys [edit_client new_bank_accounts] :as args} value]
(assert-admin (:id context)) (assert-admin (:id context))

View File

@@ -279,20 +279,23 @@
([client-code provider-accounts] ([client-code provider-accounts]
(let [accounts (get-accounts-for-providers (client-code->login client-code) (map :id provider-accounts))] (let [accounts (get-accounts-for-providers (client-code->login client-code) (map :id provider-accounts))]
(map (fn [pa] (map (fn [pa]
{:yodlee-provider-account/id (:id pa) (cond->
:yodlee-provider-account/status (:status pa) {:yodlee-provider-account/id (:id pa)
:yodlee-provider-account/detailed-status (-> pa :dataset first :additionalStatus) :yodlee-provider-account/status (:status pa)
:yodlee-provider-account/client [:client/code client-code] :yodlee-provider-account/detailed-status (-> pa :dataset first :additionalStatus)
:yodlee-provider-account/last-updated (-> pa :dataset first :lastUpdated coerce/to-date) :yodlee-provider-account/client [:client/code client-code]
:yodlee-provider-account/accounts (mapv
(fn [a] :yodlee-provider-account/accounts (mapv
{:yodlee-account/id (:id a) (fn [a]
:yodlee-account/name (str (:providerName a) " (" (:accountName a) ")") {:yodlee-account/id (:id a)
:yodlee-account/number (:accountNumber a) :yodlee-account/name (str (:providerName a) " (" (:accountName a) ")")
:yodlee-account/status (-> a :dataset first :additionalStatus) :yodlee-account/number (:accountNumber a)
:yodlee-account/available-balance (or (-> a :currentBalance :amount) :yodlee-account/status (-> a :dataset first :additionalStatus)
0.0)}) :yodlee-account/available-balance (or (-> a :currentBalance :amount)
(get accounts (:id pa)))}) 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)))) provider-accounts))))
(defn refresh-provider-account [client-code id] (defn refresh-provider-account [client-code id]

View File

@@ -134,7 +134,7 @@
(when (> (count @clients) 1) (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")) "All"))
:id ::select-client} :id ::select-client}
[:div [:div
@@ -143,7 +143,7 @@
(re-frame/dispatch [::events/swap-client nil]))} "All" ] (re-frame/dispatch [::events/swap-client nil]))} "All" ]
[:hr {:class "navbar-divider"}] [:hr {:class "navbar-divider"}]
[bind-field [bind-field
[:input.input.navbar-item {:placeholder "Client name" [:input.input.navbar-item {:placeholder "Company name"
:auto-focus true :auto-focus true
:field [:value] :field [:value]
:on-key-up (fn [k] :on-key-up (fn [k]

View File

@@ -23,6 +23,24 @@
(def signature-canvas (r/adapt-react-class (.-default canvas))) (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]}] (defn signature [{:keys [signature-file signature-data on-change]}]
(let [canvas (atom nil) (let [canvas (atom nil)
edit-mode? (r/atom false) edit-mode? (r/atom false)
@@ -56,7 +74,9 @@
[:div.buttons [:div.buttons
[:a.button {:on-click (fn [] [:a.button {:on-click (fn []
(reset! edit-mode? true))} (reset! edit-mode? true))}
"Replace Signature"]]] "Replace Signature"]
[upload-replacement-button {:on-change on-change} "Upload replacement"]]]
[:div [:div
[:div.has-text-centered.is-vcentered {:style {:width w [:div.has-text-centered.is-vcentered {:style {:width w
:height h :height h
@@ -66,7 +86,9 @@
[:div.buttons [:div.buttons
[:a.button.is-primary.is-outlined {:on-click (fn [] [:a.button.is-primary.is-outlined {:on-click (fn []
(reset! edit-mode? true))} (reset! edit-mode? true))}
"New Signature"]]])) "New Signature"]
[upload-replacement-button {:on-change on-change} "Upload signature"]]]))
]))) ])))
(re-frame/reg-sub (re-frame/reg-sub

View File

@@ -410,23 +410,28 @@
(let [authentication @(re-frame/subscribe [::authentication]) (let [authentication @(re-frame/subscribe [::authentication])
status @(re-frame/subscribe [::status/single ::authenticating]) status @(re-frame/subscribe [::status/single ::authenticating])
client-code (:code @(re-frame/subscribe [::subs/client]))] client-code (:code @(re-frame/subscribe [::subs/client]))]
(if (and authentication client-code) (cond (and authentication client-code)
[:div [:div
"Authentication successful!" "Authentication successful!"
[:div#fa-spot] [:div#fa-spot]
[:button.button.is-primary {:on-click (fn [] [:button.button.is-primary {:on-click (fn []
(.open (.-fastlink js/window) (.open (.-fastlink js/window)
#js {"fastLinkURL" (:url authentication) #js {"fastLinkURL" (:url authentication)
"accessToken" (:token authentication) "accessToken" (:token authentication)
"params" #js { "configName" "Aggregation"}} "params" #js { "configName" "Aggregation"}}
"fa-spot") "fa-spot")
)} )}
[:span [:span.icon [:i.fa.fa-external-link]] " Go to yodlee"]]] [: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) client-code
:on-click (dispatch-event [::authenticate-with-yodlee client-code])} [:button.button.is-primary {:disabled (status/disabled-for status)
"Authenticate with Yodlee (" client-code ")"]))]) :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 [] (defn admin-yodlee-provider-accounts-content []
[:div [:div