adding accounts.

This commit is contained in:
Bryce Covert
2019-04-11 10:04:59 -07:00
parent 89ae2151ea
commit bde4bb4ecb
6 changed files with 83 additions and 18 deletions

View File

@@ -81,6 +81,7 @@
:auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible :requires [:auto-ap/add-account-visibility-fields]}
:auto-ap/add-general-ledger6 {:txes add-general-ledger/add-general-ledger :requires [:auto-ap/make-every-account-visible]}
:auto-ap/add-general-ledger-fns2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/add-general-ledger-fns :requires [:auto-ap/add-general-ledger6]}
:auto-ap/add-accounts {:txes auto-ap.datomic.migrate.add-general-ledger/add-accounts :requires [:auto-ap/add-general-ledger-fns2]}
#_#_:auto-ap/bulk-load-invoice-ledger2 {:txes-fn 'auto-ap.datomic.migrate.add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/make-entity-not-unique]}
}]

View File

@@ -1,5 +1,7 @@
(ns auto-ap.datomic.migrate.add-general-ledger
(:require [datomic.api :as d]
[auto-ap.datomic :refer [remove-nils]]
[auto-ap.expense-accounts :as expense-accounts]
[auto-ap.ledger :as ledger]))
(def add-general-ledger
@@ -62,6 +64,55 @@
:db/doc "Location of the entry"}]
]
)
(def add-accounts
[[
{:db/ident :account/code
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "The code for the expense account (e.g., A1123)"}
{:db/ident :account/numeric-code
:db/valueType :db.type/long
:db/cardinality :db.cardinality/one
:db/doc "The numeric-only for the expense account (e.g., 5150)"}
{:db/ident :account/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "The name of the code (e.g., \"Telephone - HQ\")"}
{:db/ident :account/location
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "A forced location for this code, e.g., HQ."}
{:db/ident :account/account-set
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "The set of accounts this entry belongs to. Allows customization."}
{:db/ident :account/type
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one
:db/doc "The type of account, (e.g., :account-type/expense :account-type/liability)"}
{:db/ident :account-type/expense}
{:db/ident :account-type/liability}
{:db/ident :account-type/revenue}
{:db/ident :account-type/dividend}
{:db/ident :account-type/asset}
{:db/ident :account-type/equity}]
(mapv
(fn [[numeric {:keys [name location]}]]
(remove-nils
{:account/type :account-type/expense
:account/numeric-code numeric
:account/code (str numeric)
:account/name name
:account/location location
:account/account-set "default"}))
expense-accounts/chooseable-expense-accounts)])
(defn add-general-ledger-fns [conn]
[[{:db/ident :replace-general-ledger

View File

@@ -1,6 +1,6 @@
(ns auto-ap.datomic.transactions
(:require [datomic.api :as d]
[auto-ap.datomic :refer [uri]]
[auto-ap.datomic :refer [uri merge-query]]
[auto-ap.graphql.utils :refer [limited-clients]]
[clj-time.coerce :as c]))
@@ -29,13 +29,6 @@
(update-in [:query :where] conj where))]
(reduce #(update-in %1 [:query :where] conj %2) query rest)))
(defn merge-query [query-part-1 query-part-2]
(-> query-part-1
(update-in [:query :find] into (get-in query-part-2 [:query :find]))
(update-in [:query :in] into (get-in query-part-2 [:query :in]))
(update-in [:query :where] into (get-in query-part-2 [:query :where]))
(update-in [:args] into (get-in query-part-2 [:args]))))
(defn add-sorter-field [q sort-map args]
(merge-query q
{:query {:find ['?sorter]