Merge branch 'port-datomic-cloud' into try-tailwind
This commit is contained in:
@@ -6,24 +6,23 @@
|
||||
(str (UUID/randomUUID)))
|
||||
|
||||
(defn get-line-items-after [db journal-entry]
|
||||
(for [jel (:journal-entry/line-items journal-entry)
|
||||
:let [next-jel (->> (dc/index-pull db {:index :avet
|
||||
:selector [:db/id :journal-entry-line/client+account+location+date]
|
||||
:start [:journal-entry-line/client+account+location+date
|
||||
(:journal-entry-line/client+account+location+date jel)
|
||||
(:db/id jel)]
|
||||
})
|
||||
(take-while (fn line-must-match-client-account-location [result]
|
||||
(and
|
||||
(= (take 3 (:journal-entry-line/client+account+location+date result))
|
||||
(take 3 (:journal-entry-line/client+account+location+date jel)))
|
||||
(not= (:db/id jel)
|
||||
(:db/id result)))
|
||||
))
|
||||
first
|
||||
:db/id)]
|
||||
:when next-jel]
|
||||
next-jel))
|
||||
(for [jel (:journal-entry/line-items journal-entry)
|
||||
next-jel (->> (dc/index-pull db {:index :avet
|
||||
:selector [:db/id :journal-entry-line/client+account+location+date]
|
||||
:start [:journal-entry-line/client+account+location+date
|
||||
(:journal-entry-line/client+account+location+date jel)
|
||||
(:db/id jel)]
|
||||
})
|
||||
(take-while (fn line-must-match-client-account-location [result]
|
||||
(and
|
||||
(= (take 3 (:journal-entry-line/client+account+location+date result))
|
||||
(take 3 (:journal-entry-line/client+account+location+date jel)))
|
||||
(not= (:db/id jel)
|
||||
(:db/id result)))
|
||||
))
|
||||
(take 2))
|
||||
:when next-jel]
|
||||
(:db/id next-jel)))
|
||||
|
||||
(def extant-read '[:db/id :journal-entry/date :journal-entry/client {:journal-entry/line-items [:journal-entry-line/account :journal-entry-line/location :db/id :journal-entry-line/client+account+location+date]}])
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -419,7 +419,7 @@
|
||||
(dissoc % :payment/pdf-data)
|
||||
%) checks ) id)]
|
||||
|
||||
(doseq [i (:tempids result)]
|
||||
(doseq [[_ i] (:tempids result)]
|
||||
(solr/touch-with-ledger i)))
|
||||
{:invoices (d-invoices/get-multi (map :invoice-id invoice-payments))
|
||||
:pdf-url (if (= type :payment-type/check)
|
||||
@@ -485,7 +485,7 @@
|
||||
:payment/date (c/to-date (parse (:date args) iso-date)))]
|
||||
(invoice-payments invoices invoice-payment-lookup))
|
||||
(:id context))]
|
||||
(doseq [i (:tempids result)]
|
||||
(doseq [[_ i] (:tempids result)]
|
||||
(solr/touch-with-ledger i)))
|
||||
(->graphql
|
||||
{:s3-url nil
|
||||
@@ -655,7 +655,7 @@
|
||||
(let [result (audit-transact (-> []
|
||||
(conj payment)
|
||||
(into (invoice-payments invoices invoice-amounts))) (:id context))]
|
||||
(doseq [n (:tempids result)]
|
||||
(doseq [[_ n] (:tempids result)]
|
||||
(solr/touch-with-ledger n)))
|
||||
(->graphql {:invoices (d-invoices/get-multi (map :db/id invoices))})))
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[auto-ap.datomic.transaction-rules :as tr]
|
||||
[auto-ap.datomic.transactions :as d-transactions]
|
||||
[auto-ap.rule-matching :as rm]
|
||||
[auto-ap.solr :as solr]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[clj-time.coerce :as coerce]
|
||||
@@ -13,8 +14,7 @@
|
||||
[clojure.core.cache :as cache]
|
||||
[clojure.tools.logging :as log]
|
||||
[datomic.api :as dc]
|
||||
[digest :as di]
|
||||
[auto-ap.solr :as solr]))
|
||||
[digest :as di]))
|
||||
|
||||
(defn rough-match [client-id bank-account-id amount]
|
||||
(if (and client-id bank-account-id amount)
|
||||
@@ -219,7 +219,8 @@
|
||||
:transaction/vendor (:db/id (:payment/vendor existing-payment))
|
||||
:transaction/location "A"
|
||||
:transaction/accounts [#:transaction-account
|
||||
{:account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"]))
|
||||
{:db/id (random-tempid)
|
||||
:account (:db/id (a/get-account-by-numeric-code-and-sets 21000 ["default"]))
|
||||
:location "A"
|
||||
:amount (Math/abs (double amount))}])))
|
||||
|
||||
@@ -234,7 +235,8 @@
|
||||
(assoc transaction
|
||||
:transaction/expected-deposit {:db/id (:db/id expected-deposit)
|
||||
:expected-deposit/status :expected-deposit-status/cleared}
|
||||
:transaction/accounts [{:transaction-account/account :account/ccp
|
||||
:transaction/accounts [{:db/id (random-tempid)
|
||||
:transaction-account/account :account/ccp
|
||||
:transaction-account/amount amount
|
||||
:transaction-account/location "A"}]
|
||||
:transaction/approval-status :transaction-approval-status/approved
|
||||
@@ -242,7 +244,7 @@
|
||||
))))
|
||||
|
||||
(defn maybe-code [{:transaction/keys [client amount] :as transaction} apply-rules valid-locations]
|
||||
(when (seq (match-transaction-to-unpaid-invoices amount client))
|
||||
(when-not (seq (match-transaction-to-unpaid-invoices amount client))
|
||||
(apply-rules transaction valid-locations)))
|
||||
|
||||
(defn transaction->txs [transaction bank-account apply-rules]
|
||||
@@ -323,7 +325,7 @@
|
||||
:import-batch/entry (:db/id transaction)}]
|
||||
{:user/name user
|
||||
:user/role ":admin"})]
|
||||
(doseq [n (:tempids result)]
|
||||
(doseq [[_ n] (:tempids result)]
|
||||
(solr/touch-with-ledger n))))))
|
||||
|
||||
(get-stats [_]
|
||||
|
||||
@@ -167,9 +167,12 @@
|
||||
(->RealSolrClient (:solr-uri env))
|
||||
(->MockSolrClient )))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(defn touch-with-ledger [i]
|
||||
(index-documents impl [i
|
||||
(pull-id (dc/db conn) [:journal-entry/original-entity i])]))
|
||||
(index-documents impl [i [:journal-entry/original-entity i]]))
|
||||
|
||||
(defn touch [i]
|
||||
(index-documents impl [i]))
|
||||
|
||||
@@ -28,42 +28,42 @@
|
||||
:account/type :account-type/equity}
|
||||
{:db/id "test-client"
|
||||
:client/code "TEST"}
|
||||
`(upsert-ledger {:db/id "journal-entry-1"
|
||||
:journal-entry/external-id "1"
|
||||
:journal-entry/date #inst "2022-01-01"
|
||||
:journal-entry/client "test-client"
|
||||
:journal-entry/line-items [{:db/id "line-1-1"
|
||||
:journal-entry-line/account "test-account-1"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/debit 10.0}
|
||||
{:db/id "line-1-2"
|
||||
:journal-entry-line/account "test-account-2"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit 10.0}]})
|
||||
`(upsert-ledger {:db/id "journal-entry-2"
|
||||
:journal-entry/date #inst "2022-01-02"
|
||||
:journal-entry/external-id "2"
|
||||
:journal-entry/client "test-client"
|
||||
:journal-entry/line-items [{:db/id "line-2-1"
|
||||
:journal-entry-line/account "test-account-1"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/debit 50.0}
|
||||
{:db/id "line-2-2"
|
||||
:journal-entry-line/account "test-account-2"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit 50.0}]})
|
||||
`(upsert-ledger {:db/id "journal-entry-3"
|
||||
:journal-entry/date #inst "2022-01-03"
|
||||
:journal-entry/external-id "3"
|
||||
:journal-entry/client "test-client"
|
||||
:journal-entry/line-items [{:db/id "line-3-1"
|
||||
:journal-entry-line/account "test-account-1"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/debit 150.0}
|
||||
{:db/id "line-3-2"
|
||||
:journal-entry-line/account "test-account-2"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit 150.0}]})]))]
|
||||
[:upsert-ledger {:db/id "journal-entry-1"
|
||||
:journal-entry/external-id "1"
|
||||
:journal-entry/date #inst "2022-01-01"
|
||||
:journal-entry/client "test-client"
|
||||
:journal-entry/line-items [{:db/id "line-1-1"
|
||||
:journal-entry-line/account "test-account-1"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/debit 10.0}
|
||||
{:db/id "line-1-2"
|
||||
:journal-entry-line/account "test-account-2"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit 10.0}]}]
|
||||
[:upsert-ledger {:db/id "journal-entry-2"
|
||||
:journal-entry/date #inst "2022-01-02"
|
||||
:journal-entry/external-id "2"
|
||||
:journal-entry/client "test-client"
|
||||
:journal-entry/line-items [{:db/id "line-2-1"
|
||||
:journal-entry-line/account "test-account-1"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/debit 50.0}
|
||||
{:db/id "line-2-2"
|
||||
:journal-entry-line/account "test-account-2"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit 50.0}]}]
|
||||
[:upsert-ledger {:db/id "journal-entry-3"
|
||||
:journal-entry/date #inst "2022-01-03"
|
||||
:journal-entry/external-id "3"
|
||||
:journal-entry/client "test-client"
|
||||
:journal-entry/line-items [{:db/id "line-3-1"
|
||||
:journal-entry-line/account "test-account-1"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/debit 150.0}
|
||||
{:db/id "line-3-2"
|
||||
:journal-entry-line/account "test-account-2"
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit 150.0}]}]]))]
|
||||
|
||||
(testing "should set running-balance on ledger entries missing them"
|
||||
|
||||
@@ -108,8 +108,9 @@
|
||||
|
||||
)
|
||||
(testing "changing a ledger entry should mark the line items as dirty"
|
||||
(d/transact conn
|
||||
[`(upsert-ledger ~{:db/id journal-entry-2
|
||||
(println "AFTER HERE")
|
||||
@(d/transact conn
|
||||
[[:upsert-ledger {:db/id journal-entry-2
|
||||
:journal-entry/date #inst "2022-01-02"
|
||||
:journal-entry/client test-client
|
||||
:journal-entry/external-id "2"
|
||||
@@ -120,7 +121,7 @@
|
||||
{:db/id "line-2-2"
|
||||
:journal-entry-line/account test-account-2
|
||||
:journal-entry-line/location "A"
|
||||
:journal-entry-line/credit 50.0}]})])
|
||||
:journal-entry-line/credit 50.0}]}]])
|
||||
(is (= [true true]
|
||||
(->> (d/pull (d/db conn) '[{:journal-entry/line-items [:journal-entry-line/dirty]}] journal-entry-2)
|
||||
(:journal-entry/line-items)
|
||||
|
||||
Reference in New Issue
Block a user