bank accounts can now have locations.

This commit is contained in:
Bryce Covert
2019-06-04 07:08:10 -07:00
parent cf2319b681
commit 7ac17c9cbc
13 changed files with 90 additions and 18 deletions

View File

@@ -132,6 +132,7 @@
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/add-external-id-to-ledger]}
:auto-ap/add-transaction-rules {:txes add-general-ledger/add-transaction-rules :requires [:auto-ap/convert-transactions]}
:auto-ap/add-bank-account-locations {:txes add-general-ledger/add-bank-account-locations :requires [:auto-ap/add-transaction-rules]}

View File

@@ -400,6 +400,12 @@
{:db/ident :transaction-approval-status/excluded}
]])
(def add-bank-account-locations
[[{:db/ident :bank-account/locations
:db/valueType :db.type/string
:db/cardinality :db.cardinality/many
:db/doc "Which bank accounts this bank account is valid for"}]])
(def add-credit-bank-account
[[{:db/ident :bank-account-type/credit}]])

View File

@@ -94,7 +94,7 @@
(defn graphql-results [ids db args]
(let [results (->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
:transaction/approval-status [:db/ident :db/id]
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id :bank-account/locations]
:transaction/vendor [:db/id :vendor/name]
:transaction/matched-rule [:db/id :transaction-rule/note]
:transaction/accounts [:transaction-account/amount
@@ -123,7 +123,7 @@
(d/pull (d/db (d/connect uri))
'[* {:transaction/client [:client/name :db/id :client/code :client/locations]
:transaction/approval-status [:db/ident :db/id]
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id]
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id :bank-account/locations]
:transaction/vendor [:db/id :vendor/name]
:transaction/matched-rule [:db/id :transaction-rule/note]
:transaction/accounts [:transaction-account/amount

View File

@@ -84,7 +84,8 @@
:name {:type 'String}
:bank_code {:type 'String}
:bank_name {:type 'String}
:yodlee_account_id {:type 'Int}}}
:yodlee_account_id {:type 'Int}
:locations {:type '(list String)}}}
:balance_sheet_account
{:fields {:id {:type 'String}
:amount {:type 'String}
@@ -470,6 +471,7 @@
:bank_code {:type 'String}
:routing {:type 'String}
:bank_name {:type 'String}
:locations {:type '(list String)}
:yodlee_account_id {:type 'Int}}}
:edit_user
{:fields {:id {:type :id}

View File

@@ -51,6 +51,7 @@
:bank-account/number (:number %)
:bank-account/check-number (:check_number %)
:bank-account/sort-order (:sort_order %)
:bank-account/locations (:locations %)
:bank-account/yodlee-account-id (:yodlee_account_id %)
:bank-account/type (keyword "bank-account-type" (name (:type %)))

View File

@@ -138,8 +138,8 @@
:transaction/amount (:transaction/amount transaction)}
transaction-rule
;; TODO use bank account locations as well
(-> transaction :transaction/client :client/locations)))]
(or (-> transaction :transaction/bank-account :bank-account/locations)
(-> transaction :transaction/client :client/locations))))]
(map (fn [x] [:db/retractEntity (:db/id x)] )
(:transaction/accounts transaction)))))
(-> (d-transactions/get-by-id transaction_id)

View File

@@ -11,7 +11,8 @@
[auto-ap.datomic.clients :as d-clients]
[auto-ap.time :as time]
[auto-ap.datomic.transaction-rules :as tr]
[auto-ap.rule-matching :as rm]))
[auto-ap.rule-matching :as rm]
[clojure.string :as str]))
@@ -77,7 +78,7 @@
bank-account-id (:db/id bank-account)
client (:client/_bank-accounts bank-account)
client-id (:db/id client)
valid-locations (:client/locations client)
valid-locations (or (:bank-account/locations bank-account) (:client/locations client))
check (transaction->payment transaction check-number client-id bank-account-id amount id)]
:when (and client-id
(not (existing (sha-256 (str id)))))]
@@ -87,7 +88,8 @@
:id (sha-256 (str id))
:account-id account-id
:date (coerce/to-date (time/parse date "YYYY-MM-dd"))
:yodlee-merchant (when (and merchant-id merchant-name)
:yodlee-merchant (when (and merchant-id merchant-name (not (str/blank? merchant-id)))
{:yodlee-merchant/yodlee-id merchant-id
:yodlee-merchant/name merchant-name})
:amount (double amount)