allows you to use date instead of post date
This commit is contained in:
@@ -72,4 +72,9 @@
|
||||
:db/doc "collection of email contacts"
|
||||
:db/valueType :db.type/ref
|
||||
:db/cardinality :db.cardinality/many}]]}
|
||||
::add-use-date
|
||||
{:txes [[{:db/ident :bank-account/use-date-instead-of-post-date?
|
||||
:db/doc "Yodlee amex works weird"
|
||||
:db/valueType :db.type/boolean
|
||||
:db/cardinality :db.cardinality/one}]]}
|
||||
})
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
[datomic.api :as d]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler])
|
||||
[yang.scheduler :as scheduler]
|
||||
[clojure.set :as set])
|
||||
(:import
|
||||
(java.util UUID)
|
||||
(org.apache.commons.codec.binary Base64)))
|
||||
@@ -138,6 +139,7 @@
|
||||
:bank-account/numeric-code (:numeric_code %)
|
||||
:bank-account/sort-order (:sort_order %)
|
||||
:bank-account/locations (:locations %)
|
||||
:bank-account/use-date-instead-of-post-date? (boolean (:use_date_instead_of_post_date %))
|
||||
|
||||
:bank-account/yodlee-account-id (:yodlee_account_id %)
|
||||
:bank-account/type (keyword "bank-account-type" (name (:type %)))}
|
||||
@@ -167,6 +169,10 @@
|
||||
(when (:square_auth_token edit_client)
|
||||
(square/upsert-locations (-> result :tempids (get id) (or id) d-clients/get-by-id)))
|
||||
(-> (-> result :tempids (get id) (or id) d-clients/get-by-id)
|
||||
|
||||
(update :client/bank-accounts
|
||||
(fn [bas]
|
||||
(map #(set/rename-keys % {:bank-account/use-date-instead-of-post-date? :use-date-instead-of-post-date}) bas)))
|
||||
(update :client/location-matches
|
||||
(fn [lms]
|
||||
(mapcat (fn [lm]
|
||||
@@ -257,6 +263,9 @@
|
||||
(->graphql
|
||||
(->> (d-clients/get-all)
|
||||
(filter #(can-see-client? (:id context) %))
|
||||
(map (fn [c]
|
||||
(update c :client/bank-accounts (fn [bas]
|
||||
(map #(set/rename-keys % {:bank-account/use-date-instead-of-post-date? :use-date-instead-of-post-date}) bas)))))
|
||||
(map (fn [c]
|
||||
(if (is-admin? (:id context))
|
||||
c
|
||||
@@ -469,6 +478,7 @@
|
||||
:yodlee_account {:type :yodlee_account}
|
||||
:plaid_account {:type :plaid_account}
|
||||
:intuit_bank_account {:type :intuit_bank_account}
|
||||
:use_date_instead_of_post_date {:type 'Boolean}
|
||||
:locations {:type '(list String)}}}
|
||||
|
||||
:forecasted_transaction {:fields {:identifier {:type 'String}
|
||||
@@ -542,6 +552,7 @@
|
||||
:bank_name {:type 'String}
|
||||
:locations {:type '(list String)}
|
||||
:yodlee_account_id {:type 'Int}
|
||||
:use_date_instead_of_post_date {:type 'Boolean}
|
||||
:intuit_bank_account {:type :id}
|
||||
:plaid_account {:type :id}
|
||||
:yodlee_account {:type 'Int}}}})
|
||||
|
||||
@@ -12,10 +12,9 @@
|
||||
[datomic.api :as d]
|
||||
[digest :refer [sha-256]]
|
||||
[mount.core :as mount]
|
||||
[unilog.context :as lc]
|
||||
[yang.scheduler :as scheduler]))
|
||||
|
||||
(defn yodlee->transaction [transaction]
|
||||
(defn yodlee->transaction [transaction use-date-instead-of-post-date?]
|
||||
(let [{post-date :postDate
|
||||
account-id :accountId
|
||||
date :date
|
||||
@@ -23,8 +22,6 @@
|
||||
{amount :amount} :amount
|
||||
{description-original :original
|
||||
description-simple :simple} :description
|
||||
{merchant-id :id
|
||||
merchant-name :name} :merchant
|
||||
base-type :baseType
|
||||
type :type
|
||||
status :status} transaction
|
||||
@@ -37,7 +34,9 @@
|
||||
:id (sha-256 (str id))
|
||||
:raw-id (str id)
|
||||
:account-id account-id
|
||||
:date (coerce/to-date date)
|
||||
:date (if use-date-instead-of-post-date?
|
||||
(coerce/to-date (atime/parse post-date "YYYY-MM-dd"))
|
||||
(coerce/to-date date))
|
||||
:amount (double amount)
|
||||
:description-original (some-> description-original (str/replace #"\s+" " "))
|
||||
:description-simple (some-> description-simple (str/replace #"\s+" " "))
|
||||
@@ -51,18 +50,19 @@
|
||||
nil)
|
||||
(let [import-batch (t/start-import-batch :import-source/yodlee "Automated yodlee user")]
|
||||
(try
|
||||
(let [account-lookup (d/q '[:find ?ya ?ba ?c
|
||||
(let [account-lookup (d/q '[:find ?ya ?ba ?ud ?c
|
||||
:in $
|
||||
:where [?ba :bank-account/yodlee-account-id ?ya]
|
||||
[(get-else $ ?ba :bank-account/use-date-instead-of-post-date? false) ?ud]
|
||||
[?c :client/bank-accounts ?ba]]
|
||||
(d/db conn))]
|
||||
(doseq [[yodlee-account bank-account client-id] account-lookup
|
||||
(doseq [[yodlee-account bank-account use-date-instead-of-post-date? client-id] account-lookup
|
||||
transaction (try
|
||||
(client/get-specific-transactions yodlee-account (client/get-auth-header))
|
||||
(catch Exception e
|
||||
(log/warn e)
|
||||
[]))]
|
||||
(t/import-transaction! import-batch (assoc (yodlee->transaction transaction)
|
||||
(t/import-transaction! import-batch (assoc (yodlee->transaction transaction use-date-instead-of-post-date?)
|
||||
:transaction/bank-account bank-account
|
||||
:transaction/client client-id)))
|
||||
|
||||
|
||||
@@ -19,17 +19,19 @@
|
||||
nil)
|
||||
(let [import-batch (t/start-import-batch :import-source/yodlee2 "Automated yodlee2 user")]
|
||||
(try
|
||||
(let [account-lookup (d/q '[:find ?ya ?ba ?cd
|
||||
(let [account-lookup (d/q '[:find ?ya ?ba ?cd ?ud
|
||||
:in $
|
||||
:where
|
||||
[?ba :bank-account/yodlee-account ?y]
|
||||
[(get-else $ ?ba :bank-account/use-date-instead-of-post-date? false) ?ud]
|
||||
[?c :client/bank-accounts ?ba]
|
||||
[?c :client/code ?cd]
|
||||
[?y :yodlee-account/id ?ya]]
|
||||
[?y :yodlee-account/id ?ya]
|
||||
]
|
||||
(d/db conn))]
|
||||
(doseq [[yodlee-account bank-account client-code] account-lookup
|
||||
(doseq [[yodlee-account bank-account client-code use-date-instead-of-post-date?] account-lookup
|
||||
transaction (client2/get-specific-transactions client-code yodlee-account)]
|
||||
(t/import-transaction! import-batch (assoc (y/yodlee->transaction transaction)
|
||||
(t/import-transaction! import-batch (assoc (y/yodlee->transaction transaction use-date-instead-of-post-date?)
|
||||
:transaction/bank-account bank-account
|
||||
:transaction/client [:client/code client-code])))
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
[:yodlee-account [:name :id :number]]
|
||||
[:plaid-account [:name :id :number]]
|
||||
[:intuit-bank-account [:name :id :external-id]]
|
||||
:use-date-instead-of-post-date
|
||||
:locations :include-in-reports :current-balance :yodlee-balance-old] ]
|
||||
[:address [:street1 :street2 :city :state :zip]]
|
||||
[:forecasted-transactions [:id :amount :identifier :day-of-month]]]
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
:identifier identifier
|
||||
:amount amount})
|
||||
(:forecasted-transactions new-client-data))
|
||||
:bank-accounts (map (fn [{:keys [number name check-number plaid-account intuit-bank-account include-in-reports type id code numeric-code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations yodlee-account]}]
|
||||
:bank-accounts (map (fn [{:keys [number name check-number plaid-account intuit-bank-account include-in-reports type id code numeric-code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations yodlee-account use-date-instead-of-post-date]}]
|
||||
{:number number
|
||||
:name name
|
||||
:check-number (when-not (str/blank? check-number)
|
||||
@@ -165,6 +165,7 @@
|
||||
:sort-order sort-order
|
||||
:visible visible
|
||||
:locations (mapv :location locations)
|
||||
:use-date-instead-of-post-date use-date-instead-of-post-date
|
||||
:yodlee-account-id (when-not (str/blank? yodlee-account-id)
|
||||
(js/parseInt yodlee-account-id))
|
||||
:yodlee-account (:id yodlee-account)
|
||||
@@ -418,6 +419,12 @@
|
||||
:entity->text (fn [m] (str (:name m) " - " (:number m)))
|
||||
:type "typeahead-v3"
|
||||
:field [:bank-accounts sort-order :yodlee-account]}]]
|
||||
[:div.field
|
||||
[:label.checkbox
|
||||
[raw-field
|
||||
[:input {:type "checkbox"
|
||||
:field [:bank-accounts sort-order :use-date-instead-of-post-date]}]]
|
||||
" (Yodlee only) Use 'date' instead of 'postDate'"]]
|
||||
[field "Intuit Bank Account"
|
||||
[typeahead-v3 {:entities @(re-frame/subscribe [::subs/intuit-bank-accounts])
|
||||
:entity->text (fn [m] (str (:name m)))
|
||||
@@ -458,6 +465,12 @@
|
||||
:entity->text (fn [m] (str (:name m) " - " (:number m)))
|
||||
:type "typeahead-v3"
|
||||
:field [:bank-accounts sort-order :yodlee-account]}]]
|
||||
[:div.field
|
||||
[:label.checkbox
|
||||
[raw-field
|
||||
[:input {:type "checkbox"
|
||||
:field [:bank-accounts sort-order :use-date-instead-of-post-date]}]]
|
||||
" (Yodlee only) Use 'date' instead of 'postDate'"]]
|
||||
[field "Intuit Bank Account"
|
||||
[typeahead-v3 {:entities @(re-frame/subscribe [::subs/intuit-bank-accounts])
|
||||
:entity->text (fn [m] (str (:name m)))
|
||||
|
||||
Reference in New Issue
Block a user