several fixes.
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
(defn sort-fn [sort-by]
|
||||
(cond
|
||||
(= "client" sort-by)
|
||||
#(-> % :transaction/client :client/name)
|
||||
#(-> % :journal-entry/client :client/name)
|
||||
|
||||
(= "account" sort-by)
|
||||
#(vector (-> % :transaction/account :account/name) (-> % :db/id))
|
||||
(= "vendor" sort-by)
|
||||
#(-> % :journal-entry/vendor :vendor/name)
|
||||
|
||||
:else
|
||||
(keyword "transaction" sort-by)))
|
||||
(keyword "journal-entry" sort-by)))
|
||||
|
||||
(defn raw-graphql-ids [db args]
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
(:sort-by args) (add-sorter-field {"client" ['[?e :journal-entry/client ?c]
|
||||
'[?c :client/name ?sorter]]
|
||||
"date" ['[?e :journal-entry/date ?sorter]]
|
||||
"vendor" ['[?e :journal-entry/vendor ?sorter]]
|
||||
"amount" ['[?e :journal-entry/amount ?sorter]]}
|
||||
args)
|
||||
|
||||
@@ -75,7 +76,6 @@
|
||||
|
||||
true
|
||||
(merge-query {:query {:find ['?e] :where ['[?e :journal-entry/date]]}}))]
|
||||
(println query)
|
||||
(cond->> query
|
||||
true (d/query)
|
||||
(:sort-by args) (apply-sort-2 args)
|
||||
|
||||
@@ -129,8 +129,8 @@
|
||||
:auto-ap/add-external-id-to-ledger {:txes add-general-ledger/add-external-id-to-ledger :requires [:auto-ap/add-yodlee-merchant2]}
|
||||
:auto-ap/add-exclude-to-transaction {:txes add-general-ledger/add-exclude-to-transaction :requires [:auto-ap/add-external-id-to-ledger]}
|
||||
:auto-ap/convert-transactions {:txes-fn `add-general-ledger/convert-transactions :requires [:auto-ap/add-external-id-to-ledger]}
|
||||
:auto-ap/bulk-load-invoice-ledger3 {:txes-fn `add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/convert-transactions]}
|
||||
:auto-ap/bulk-load-transaction-ledger3 {:txes-fn `add-general-ledger/bulk-load-transaction-ledger :requires [:auto-ap/convert-transactions]}
|
||||
#_#_:auto-ap/bulk-load-invoice-ledger3 {:txes-fn `add-general-ledger/bulk-load-invoice-ledger :requires [:auto-ap/convert-transactions]}
|
||||
#_#_:auto-ap/bulk-load-transaction-ledger3 {:txes-fn `add-general-ledger/bulk-load-transaction-ledger :requires [:auto-ap/convert-transactions]}
|
||||
|
||||
}]
|
||||
(println "Conforming database...")
|
||||
|
||||
@@ -160,7 +160,20 @@
|
||||
(mapv
|
||||
(fn [[numeric {:keys [name location]}]]
|
||||
(remove-nils
|
||||
{:account/type :account-type/expense
|
||||
{:account/type (cond (<= 1000 numeric 1999)
|
||||
:account-type/asset
|
||||
|
||||
(<= 2000 numeric 2999)
|
||||
:account-type/liability
|
||||
|
||||
(<= 3000 numeric 3999)
|
||||
:account-type/equity
|
||||
|
||||
(<= 4000 numeric 4999)
|
||||
:account-type/revenue
|
||||
|
||||
:else
|
||||
:account-type/expense)
|
||||
:account/numeric-code numeric
|
||||
:account/code (str numeric)
|
||||
:account/name name
|
||||
@@ -186,7 +199,8 @@
|
||||
:where ['[?e :invoice/total]]}
|
||||
:args [(d/db conn)]}))
|
||||
z (->> invoice-ids
|
||||
(mapv #(vector (ledger/entity-change->ledger (d/db conn) [:invoice %]))))]
|
||||
(map #(ledger/entity-change->ledger (d/db conn) [:invoice %]))
|
||||
(partition-all 100))]
|
||||
z))
|
||||
|
||||
|
||||
@@ -199,11 +213,13 @@
|
||||
z (->> transaction-ids
|
||||
(map #(ledger/entity-change->ledger (d/db conn) [:transaction %]))
|
||||
(filter identity)
|
||||
(mapv #(vector %)))]
|
||||
(partition-all 100)
|
||||
#_(mapv #(vector %)))]
|
||||
z))
|
||||
|
||||
#_(test-run (bulk-load-transaction-ledger (d/connect auto-ap.datomic/uri)))
|
||||
#_(test-run (bulk-load-invoice-ledger (d/connect auto-ap.datomic/uri)))
|
||||
#_(test-run (reset-ledger (d/connect auto-ap.datomic/uri)))
|
||||
|
||||
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
||||
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
||||
@@ -294,6 +310,15 @@
|
||||
|
||||
|
||||
|
||||
(defn reset-ledger [conn]
|
||||
(let [results (->> (d/query {:query {:find '[?e]
|
||||
:in '[$]
|
||||
:where ['[?e :journal-entry/original-entity ]]}
|
||||
:args [(d/db conn)]})
|
||||
(mapv (fn [[id]]
|
||||
[:db/retractEntity id]))
|
||||
(partition-all 100))]
|
||||
results))
|
||||
|
||||
#_(do (doseq [tran (convert-transactions (d/connect auto-ap.datomic/uri))]
|
||||
@(d/transact (d/connect auto-ap.datomic/uri) tran))
|
||||
|
||||
Reference in New Issue
Block a user