Added bank accounts being credit card accounts
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
:yodlee-cobrand-name "restserver"
|
||||
:yodlee-cobrand-login "sbCobda48aa19712a83c3ca4e935dd5e5d46b1a"
|
||||
:yodlee-cobrand-password "0a07ea32-1b5d-461b-ad0f-2752cdd77602"
|
||||
:yodlee-user-login "sbMemda48aa19712a83c3ca4e935dd5e5d46b1a1"
|
||||
:yodlee-user-password "sbMemda48aa19712a83c3ca4e935dd5e5d46b1a1#123"
|
||||
:yodlee-user-login "sbMemda48aa19712a83c3ca4e935dd5e5d46b1a2"
|
||||
:yodlee-user-password "sbMemda48aa19712a83c3ca4e935dd5e5d46b1a2#123"
|
||||
:yodlee-base-url "https://developer.api.yodlee.com/ysl"
|
||||
:yodlee-app "10003600"
|
||||
:yodlee-fastlink "https://node.developer.yodlee.com/authenticate/restserver/?channelAppName=restserver"
|
||||
|
||||
@@ -90,6 +90,13 @@
|
||||
.nav.menu {
|
||||
border-bottom: 1px solid #e1e1e1;
|
||||
}
|
||||
|
||||
.menu .icon.inline {
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
|
||||
font-size: 1.5em;
|
||||
}
|
||||
.nav.menu .nav-item .icon-btn {
|
||||
border: 3px solid #B7C6C9;
|
||||
border-radius: 90px;
|
||||
|
||||
@@ -56,7 +56,8 @@
|
||||
(->> (d/pull-many db '[* {:journal-entry/client [:client/name :client/code :db/id]
|
||||
:journal-entry/vendor [:vendor/name :db/id]
|
||||
:journal-entry/line-items [* {:journal-entry-line/account [*
|
||||
{:account/type [*]}]}]
|
||||
{:account/type [*]}
|
||||
{:bank-account/type [*]}]}]
|
||||
|
||||
}]
|
||||
ids)
|
||||
|
||||
@@ -118,6 +118,8 @@
|
||||
:requires [:auto-ap/change-expense-account-to-entity]}
|
||||
:auto-ap/add-location-to-transaction {:txes add-general-ledger/add-location-to-transaction
|
||||
:requires [:auto-ap/add-account-to-vendor]}
|
||||
:auto-ap/add-credit-bank-account {:txes add-general-ledger/add-credit-bank-account
|
||||
:requires [:auto-ap/add-location-to-transaction]}
|
||||
:auto-ap/convert-vendors {:txes-fn `add-general-ledger/convert-vendors
|
||||
:requires [:auto-ap/add-location-to-transaction]}
|
||||
:auto-ap/convert-invoices {:txes-fn `add-general-ledger/convert-invoices
|
||||
|
||||
@@ -269,6 +269,11 @@
|
||||
:db/cardinality :db.cardinality/one
|
||||
:db/doc "Location of the transaction's target"}]])
|
||||
|
||||
(def add-credit-bank-account
|
||||
[[{:db/ident :bank-account-type/credit}]])
|
||||
|
||||
|
||||
|
||||
|
||||
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
||||
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
||||
|
||||
@@ -437,6 +437,7 @@
|
||||
{:enum-value :cash}
|
||||
{:enum-value :debit}]}
|
||||
:bank_account_type {:values [{:enum-value :check}
|
||||
{:enum-value :credit}
|
||||
{:enum-value :cash}]}
|
||||
:account_type {:values [{:enum-value :dividend}
|
||||
{:enum-value :expense}
|
||||
|
||||
@@ -16,17 +16,21 @@
|
||||
:start (:start args 0)
|
||||
:end (+ (:start args 0) (count journal-entries))}))
|
||||
(defn credit-account? [account]
|
||||
(#{:account-type/liability
|
||||
:account-type/equity
|
||||
:account-type/revenue}
|
||||
(:db/ident (:account/type account))))
|
||||
(or
|
||||
(#{:account-type/liability
|
||||
:account-type/equity
|
||||
:account-type/revenue}
|
||||
(:db/ident (:account/type account)))
|
||||
(#{:bank-account-type/credit}
|
||||
(-> account :bank-account/type :db/ident ))))
|
||||
|
||||
(defn debit-account? [account]
|
||||
(or (#{:account-type/asset
|
||||
:account-type/dividend
|
||||
:account-type/expense}
|
||||
(:db/ident (:account/type account)))
|
||||
(:bank-account/name account)))
|
||||
(#{:bank-account-type/check}
|
||||
(-> account :bank-account/type :db/ident ))))
|
||||
|
||||
(defn expense-account? [account]
|
||||
(= :account-type/expense (:db/ident (:account/type account))))
|
||||
|
||||
@@ -59,7 +59,15 @@
|
||||
|
||||
(defmethod entity-change->ledger :transaction
|
||||
[db [type id]]
|
||||
(let [entity (d/pull db ['* {:transaction/vendor '[*] :transaction/client '[*] :transaction/accounts '[* {:transaction-account/account [*]}] }] id)]
|
||||
(let [entity (d/pull db ['* {:transaction/vendor '[*]
|
||||
:transaction/client '[*]
|
||||
:transaction/bank-account '[* {:bank-account/type [:db/ident]}]
|
||||
:transaction/accounts '[*
|
||||
{:transaction-account/account [*]}] }] id)
|
||||
bank-account-type (-> entity :transaction/bank-account :bank-account/type :db/ident)
|
||||
decreasing? (< (:transaction/amount entity) 0.0)
|
||||
credit-from-bank? decreasing?
|
||||
debit-from-bank? (not decreasing?)]
|
||||
(println "processing entity" entity)
|
||||
(when (:transaction/vendor entity)
|
||||
(remove-nils
|
||||
@@ -70,21 +78,20 @@
|
||||
:journal-entry/vendor (:db/id (:transaction/vendor entity))
|
||||
:journal-entry/amount (Math/abs (:transaction/amount entity))
|
||||
|
||||
:journal-entry/line-items (into [
|
||||
(remove-nils {:journal-entry-line/account (:db/id (:transaction/bank-account entity))
|
||||
:journal-entry/line-items (into [(remove-nils {:journal-entry-line/account (:db/id (:transaction/bank-account entity))
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit (when (< (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/credit (when credit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))
|
||||
:journal-entry-line/debit (when (>= (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/debit (when debit-from-bank?
|
||||
(Math/abs (:transaction/amount entity)))})
|
||||
]
|
||||
(map
|
||||
(fn [a]
|
||||
(remove-nils{:journal-entry-line/account (:db/id (:transaction-account/account a))
|
||||
:journal-entry-line/location (:transaction-account/location a)
|
||||
:journal-entry-line/debit (when (< (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/debit (when credit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))
|
||||
:journal-entry-line/credit (when (>= (:transaction/amount entity) 0.0)
|
||||
:journal-entry-line/credit (when debit-from-bank?
|
||||
(Math/abs (:transaction-account/amount a)))}))
|
||||
(:transaction/accounts entity)))
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
|
||||
(defn login-user
|
||||
([cob-session] (login-user cob-session "sbMemda48aa19712a83c3ca4e935dd5e5d46b1a2" "sbMemda48aa19712a83c3ca4e935dd5e5d46b1a2#123"))
|
||||
([cob-session] (login-user cob-session (:yodlee-user-login env) (:yodlee-user-password env)))
|
||||
([cob-session user password]
|
||||
(-> (str (:yodlee-base-url env) "/user/login")
|
||||
(client/post {:headers (merge base-headers {"Authorization" (auth-header cob-session)})
|
||||
|
||||
@@ -23,9 +23,16 @@
|
||||
(s/def ::checking-bank-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type]
|
||||
:opt-un [::bank-code ::routing])
|
||||
#(= (:type %) :check)))
|
||||
|
||||
(s/def ::credit-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type]
|
||||
:opt-un [])
|
||||
#(= (:type %) :credit)))
|
||||
|
||||
(s/def ::cash-account (s/and (s/keys :req-un [::type ::code ::name])
|
||||
#(= (:type %) :cash)))
|
||||
(s/def ::bank-account (s/or :cash ::cash-account :checking ::checking-bank-account))
|
||||
(s/def ::bank-account (s/or :cash ::cash-account
|
||||
:checking ::checking-bank-account
|
||||
:credit ::credit-account))
|
||||
(s/def ::bank-accounts (s/coll-of ::bank-account))
|
||||
|
||||
(s/def ::location string?)
|
||||
|
||||
@@ -193,10 +193,13 @@
|
||||
[:div.card {:style {:margin-bottom "1em"}}
|
||||
[:header.card-header
|
||||
[:p.card-header-title {:style {:text-overflow "ellipsis"}}
|
||||
[:span.icon
|
||||
(if ({:check ":check"} type)
|
||||
[:span.icon-check-payment-sign]
|
||||
[:span.icon-accounting-bill])]
|
||||
[:span.icon.inline
|
||||
(cond
|
||||
(#{:check ":check"} type) [:span.icon-check-payment-sign]
|
||||
|
||||
(#{:credit ":credit"} type) [:span.icon-credit-card-1]
|
||||
|
||||
:else [:span.icon-accounting-bill])]
|
||||
code ": " name]
|
||||
[:p {:style {:padding "0.75em 0.25em"}}
|
||||
[:a.button.is-outlined {:on-click (dispatch-event [::toggle-visible sort-order])} [:span.icon (if visible
|
||||
@@ -297,6 +300,40 @@
|
||||
:subscription new-client}]]]]
|
||||
[:div.field
|
||||
[:label.label "Yodlee Account"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:placeholder "Yodlee Account #"
|
||||
:type "text"
|
||||
:field [:bank-accounts sort-order :yodlee-account-id]
|
||||
:event change-event
|
||||
:subscription new-client}]]]]])
|
||||
(when (#{:credit ":credit"} type )
|
||||
[:div
|
||||
|
||||
[:label.label "Account"]
|
||||
[horizontal-field
|
||||
nil
|
||||
[:div.control
|
||||
[:p.help "Bank Name"]
|
||||
[bind-field
|
||||
[:input.input {:placeholder "Bank of America"
|
||||
:type "text"
|
||||
:field [:bank-accounts sort-order :bank-name]
|
||||
:event change-event
|
||||
:subscription new-client}]]]]
|
||||
|
||||
[horizontal-field
|
||||
nil
|
||||
[:div.control
|
||||
[:p.help "Account #"]
|
||||
[bind-field
|
||||
[:input.input {:placeholder "123456789"
|
||||
:type "text"
|
||||
:field [:bank-accounts sort-order :number]
|
||||
:event change-event
|
||||
:subscription new-client}]]]]
|
||||
[:div.field
|
||||
[:p.help "Yodlee Account"]
|
||||
[:div.control
|
||||
[bind-field
|
||||
[:input.input {:placeholder "Yodlee Account #"
|
||||
@@ -380,9 +417,11 @@
|
||||
[bank-account-card new-client bank-account (= 0 (:sort-order bank-account)) (= (:sort-order bank-account) (dec (count (:bank-accounts new-client))))])
|
||||
|
||||
[:div.columns
|
||||
[:div.column.is-half
|
||||
[:div.column.is-third
|
||||
[:a.button.is-primary.is-outlined.is-fullwidth {:on-click (dispatch-event [::add-new-bank-account :credit])} "Add Credit Account"]]
|
||||
[:div.column.is-third
|
||||
[:a.button.is-primary.is-outlined.is-fullwidth {:on-click (dispatch-event [::add-new-bank-account :check])} "Add Checking Account"]]
|
||||
[:div.column.is-half
|
||||
[:div.column.is-third
|
||||
[:a.button.is-primary.is-outlined.is-fullwidth {:on-click (dispatch-event [::add-new-bank-account :cash])} "Add Cash Account"]]]
|
||||
|
||||
#_[:h2.subtitle "Add bank account"]
|
||||
|
||||
Reference in New Issue
Block a user