Adds ability for bank accounts to have numeric accounts
This commit is contained in:
@@ -71,12 +71,7 @@
|
|||||||
:where ['[?li :journal-entry-line/account ?a]
|
:where ['[?li :journal-entry-line/account ?a]
|
||||||
'(or-join [?a ?c]
|
'(or-join [?a ?c]
|
||||||
[?a :account/numeric-code ?c]
|
[?a :account/numeric-code ?c]
|
||||||
(and [?a :bank-account/type :bank-account-type/check]
|
[?a :bank-account/numeric-code ?c])]}
|
||||||
[(ground 11100) ?c])
|
|
||||||
(and [?a :bank-account/type :bank-account-type/cash]
|
|
||||||
[(ground 11100) ?c])
|
|
||||||
(and [?a :bank-account/type :bank-account-type/credit]
|
|
||||||
[(ground 28000) ?c]))]}
|
|
||||||
:args []})
|
:args []})
|
||||||
|
|
||||||
(:from-numeric-code args)
|
(:from-numeric-code args)
|
||||||
|
|||||||
@@ -334,6 +334,9 @@
|
|||||||
:db/valueType :db.type/long
|
:db/valueType :db.type/long
|
||||||
:db/cardinality :db.cardinality/one}]]}
|
:db/cardinality :db.cardinality/one}]]}
|
||||||
:auto-ap/add-power-user-schema {:txes [[{:db/ident :user-role/power-user}]]}}
|
:auto-ap/add-power-user-schema {:txes [[{:db/ident :user-role/power-user}]]}}
|
||||||
|
:auto-ap/add-transaction-date-index {:txes [[{:db/ident :transaction/date
|
||||||
|
:db/index true}]]
|
||||||
|
:requires [:auto-ap/add-accounts]}
|
||||||
|
|
||||||
|
|
||||||
sales/norms-map
|
sales/norms-map
|
||||||
|
|||||||
@@ -1,4 +1,35 @@
|
|||||||
(ns auto-ap.datomic.migrate.clients)
|
(ns auto-ap.datomic.migrate.clients
|
||||||
|
(:require [datomic.api :as d]))
|
||||||
|
|
||||||
|
(defn migrate-bank-account-numeric-codes [conn]
|
||||||
|
(let [existing-accounts (->> (d/query {:query {:find ['?c '?t2 '?e]
|
||||||
|
:in ['$]
|
||||||
|
:where ['[?c :client/bank-accounts ?e]
|
||||||
|
'[?e :bank-account/type ?t]
|
||||||
|
'[?t :db/ident ?t2]
|
||||||
|
'(not [?e :bank-account/numeric-code])]}
|
||||||
|
:args [(d/db conn)]})
|
||||||
|
(group-by (fn [[client type]]
|
||||||
|
[client type]))
|
||||||
|
(map second)
|
||||||
|
(mapcat (fn [account-set]
|
||||||
|
(map (fn [[_ type bank-account] idx]
|
||||||
|
[bank-account (+ (condp = type
|
||||||
|
:bank-account-type/check 11300
|
||||||
|
:bank-account-type/cash 11100
|
||||||
|
:bank-account-type/credit 20100)
|
||||||
|
1
|
||||||
|
idx)])
|
||||||
|
account-set (range))
|
||||||
|
))
|
||||||
|
(mapv (fn [[bank-account numeric-code]]
|
||||||
|
{:db/id bank-account
|
||||||
|
:bank-account/numeric-code numeric-code}))
|
||||||
|
|
||||||
|
)]
|
||||||
|
[existing-accounts])
|
||||||
|
)
|
||||||
|
|
||||||
(def norms-map {::add-bank-account-start-date
|
(def norms-map {::add-bank-account-start-date
|
||||||
{:txes [[{:db/ident :bank-account/start-date
|
{:txes [[{:db/ident :bank-account/start-date
|
||||||
:db/doc "Setting this date prevents older transactions from being imported"
|
:db/doc "Setting this date prevents older transactions from being imported"
|
||||||
@@ -10,4 +41,15 @@
|
|||||||
:db/doc "A precomputed balance for the account"
|
:db/doc "A precomputed balance for the account"
|
||||||
:db/valueType :db.type/double
|
:db/valueType :db.type/double
|
||||||
:db/cardinality :db.cardinality/one
|
:db/cardinality :db.cardinality/one
|
||||||
:db/noHistory true}]]}})
|
:db/noHistory true}]]}
|
||||||
|
|
||||||
|
::add-bank-account-numeric-codes
|
||||||
|
{:txes [[{:db/ident :bank-account/numeric-code
|
||||||
|
:db/doc "The numeric code for the balance sheet"
|
||||||
|
:db/valueType :db.type/long
|
||||||
|
:db/cardinality :db.cardinality/one}]]}
|
||||||
|
|
||||||
|
::migrate-bank-account-numeric-codes
|
||||||
|
{:txes-fn `migrate-bank-account-numeric-codes
|
||||||
|
:requires [::add-bank-account-current-balance
|
||||||
|
::add-bank-account-numeric-codes]}})
|
||||||
|
|||||||
@@ -130,6 +130,7 @@
|
|||||||
:type {:type :ident}
|
:type {:type :ident}
|
||||||
:start_date {:type :iso_date}
|
:start_date {:type :iso_date}
|
||||||
:number {:type 'String}
|
:number {:type 'String}
|
||||||
|
:numeric_code {:type 'Int}
|
||||||
:sort_order {:type 'Int}
|
:sort_order {:type 'Int}
|
||||||
:visible {:type 'Boolean}
|
:visible {:type 'Boolean}
|
||||||
:include_in_reports {:type 'Boolean}
|
:include_in_reports {:type 'Boolean}
|
||||||
@@ -771,6 +772,7 @@
|
|||||||
:start_date {:type :iso_date}
|
:start_date {:type :iso_date}
|
||||||
:number {:type 'String}
|
:number {:type 'String}
|
||||||
:check_number {:type 'Int}
|
:check_number {:type 'Int}
|
||||||
|
:numeric_code {:type 'Int}
|
||||||
:visible {:type 'Boolean}
|
:visible {:type 'Boolean}
|
||||||
:include_in_reports {:type 'Boolean}
|
:include_in_reports {:type 'Boolean}
|
||||||
:sort_order {:type 'Int}
|
:sort_order {:type 'Int}
|
||||||
|
|||||||
@@ -98,6 +98,7 @@
|
|||||||
:bank-account/visible (:visible %)
|
:bank-account/visible (:visible %)
|
||||||
:bank-account/number (:number %)
|
:bank-account/number (:number %)
|
||||||
:bank-account/check-number (:check_number %)
|
:bank-account/check-number (:check_number %)
|
||||||
|
:bank-account/numeric-code (:numeric_code %)
|
||||||
:bank-account/sort-order (:sort_order %)
|
:bank-account/sort-order (:sort_order %)
|
||||||
:bank-account/locations (:locations %)
|
:bank-account/locations (:locations %)
|
||||||
|
|
||||||
|
|||||||
@@ -119,7 +119,7 @@
|
|||||||
:where ['[?e :account/name]]}
|
:where ['[?e :account/name]]}
|
||||||
:args [(d/db (d/connect uri) )]})))
|
:args [(d/db (d/connect uri) )]})))
|
||||||
|
|
||||||
bank-accounts (by :db/id (map first (d/query {:query {:find ['(pull ?e [:db/id :bank-account/name {:bank-account/type [:db/ident]}])]
|
bank-accounts (by :db/id (map first (d/query {:query {:find ['(pull ?e [:db/id :bank-account/name :bank-account/numeric-code {:bank-account/type [:db/ident]}])]
|
||||||
:in ['$]
|
:in ['$]
|
||||||
:where ['[?e :bank-account/name]]}
|
:where ['[?e :bank-account/name]]}
|
||||||
:args [(d/db (d/connect uri))]})))
|
:args [(d/db (d/connect uri))]})))
|
||||||
@@ -142,10 +142,7 @@
|
|||||||
:bank-account-type/credit :account-type/liability}
|
:bank-account-type/credit :account-type/liability}
|
||||||
(:db/ident (:bank-account/type (bank-accounts a)))))
|
(:db/ident (:bank-account/type (bank-accounts a)))))
|
||||||
:numeric_code (or (:account/numeric-code (accounts a))
|
:numeric_code (or (:account/numeric-code (accounts a))
|
||||||
(and (#{:bank-account-type/check :bank-account-type/cash} (:db/ident (:bank-account/type (bank-accounts a))))
|
(:bank-account/numeric-code (bank-accounts a)))})))
|
||||||
11100)
|
|
||||||
(and (#{:bank-account-type/credit} (:db/ident (:bank-account/type (bank-accounts a))))
|
|
||||||
28000))})))
|
|
||||||
|
|
||||||
(defn full-ledger-for-client [client-id]
|
(defn full-ledger-for-client [client-id]
|
||||||
(->> (d/query
|
(->> (d/query
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
(defn client-query [token]
|
(defn client-query [token]
|
||||||
(cond-> [:id :name :signature-file :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits :locations
|
(cond-> [:id :name :signature-file :code :email :matches :week-a-debits :week-a-credits :week-b-debits :week-b-credits :locations
|
||||||
[:location-matches [:id :location :match]]
|
[:location-matches [:id :location :match]]
|
||||||
[:bank-accounts [:id :start-date :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id
|
[:bank-accounts [:id :start-date :numeric-code :code :number :bank-name :bank-code :check-number :name :routing :type :sort-order :visible :yodlee-account-id
|
||||||
[:yodlee-account [:name :id :number]]
|
[:yodlee-account [:name :id :number]]
|
||||||
:locations :include-in-reports :current-balance :yodlee-balance-old] ]
|
:locations :include-in-reports :current-balance :yodlee-balance-old] ]
|
||||||
[:address [:street1 :street2 :city :state :zip]]
|
[:address [:street1 :street2 :city :state :zip]]
|
||||||
|
|||||||
@@ -127,11 +127,13 @@
|
|||||||
:identifier identifier
|
:identifier identifier
|
||||||
:amount amount})
|
:amount amount})
|
||||||
(:forecasted-transactions new-client-data))
|
(:forecasted-transactions new-client-data))
|
||||||
:bank-accounts (map (fn [{:keys [number name check-number include-in-reports type id 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 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]}]
|
||||||
{:number number
|
{:number number
|
||||||
:name name
|
:name name
|
||||||
:check-number (when-not (str/blank? check-number)
|
:check-number (when-not (str/blank? check-number)
|
||||||
(js/parseInt check-number))
|
(js/parseInt check-number))
|
||||||
|
:numeric-code (when-not (str/blank? check-number)
|
||||||
|
(js/parseInt numeric-code))
|
||||||
:include-in-reports include-in-reports
|
:include-in-reports include-in-reports
|
||||||
:start-date (cond (not start-date)
|
:start-date (cond (not start-date)
|
||||||
nil
|
nil
|
||||||
@@ -327,10 +329,18 @@
|
|||||||
:spec ::entity/code}]]]]
|
:spec ::entity/code}]]]]
|
||||||
[:div.field [:p.control code]])]
|
[:div.field [:p.control code]])]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[field "Nickname"
|
[field "Nickname"
|
||||||
[:input.input {:placeholder "BOA Checking #1"
|
[:input.input {:placeholder "BOA Checking #1"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :name]}]]
|
:field [:bank-accounts sort-order :name]}]]
|
||||||
|
[horizontal-field
|
||||||
|
nil
|
||||||
|
[field "Numeric Code (for finiancials)"
|
||||||
|
[:input.input {:placeholder "20101"
|
||||||
|
:type "text"
|
||||||
|
:field [:bank-accounts sort-order :numeric-code]}]]]
|
||||||
[field "Start date"
|
[field "Start date"
|
||||||
[date-picker {:class-name "input"
|
[date-picker {:class-name "input"
|
||||||
:class "input"
|
:class "input"
|
||||||
@@ -381,6 +391,7 @@
|
|||||||
:entity->text (fn [m] (str (:name m) " - " (:number m)))
|
:entity->text (fn [m] (str (:name m) " - " (:number m)))
|
||||||
:type "typeahead-v3"
|
:type "typeahead-v3"
|
||||||
:field [:bank-accounts sort-order :yodlee-account]}]]])
|
:field [:bank-accounts sort-order :yodlee-account]}]]])
|
||||||
|
|
||||||
(when (#{:credit ":credit"} type )
|
(when (#{:credit ":credit"} type )
|
||||||
[:div
|
[:div
|
||||||
|
|
||||||
@@ -392,6 +403,7 @@
|
|||||||
[:input.input {:placeholder "Bank of America"
|
[:input.input {:placeholder "Bank of America"
|
||||||
:type "text"
|
:type "text"
|
||||||
:field [:bank-accounts sort-order :bank-name]}]]]
|
:field [:bank-accounts sort-order :bank-name]}]]]
|
||||||
|
|
||||||
|
|
||||||
[horizontal-field
|
[horizontal-field
|
||||||
nil
|
nil
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
["1500 Property and Equipment" 15000 15999]
|
["1500 Property and Equipment" 15000 15999]
|
||||||
["1600 Intangible Assets" 16000 16999]
|
["1600 Intangible Assets" 16000 16999]
|
||||||
["1700 Other Assets" 17000 19999]]
|
["1700 Other Assets" 17000 19999]]
|
||||||
:liability [["2000 Accounts Payable" 21000 23999]
|
:liability [["2000 Accounts Payable" 20100 23999]
|
||||||
["2400 Accrued Expenses" 24000 24999]
|
["2400 Accrued Expenses" 24000 24999]
|
||||||
["2500 Other Liabilities" 25000 25999]
|
["2500 Other Liabilities" 25000 25999]
|
||||||
["2600 Split Accounts" 26000 26999]
|
["2600 Split Accounts" 26000 26999]
|
||||||
|
|||||||
Reference in New Issue
Block a user