scrubbed all reference to datomic.api

This commit is contained in:
2023-03-20 12:54:56 -07:00
parent 8290138156
commit 9260834135
19 changed files with 731 additions and 611 deletions

View File

@@ -2,9 +2,11 @@
(:require
[auto-ap.utils :refer [default-pagination-size by]]
[clojure.tools.logging :as log]
[clojure.edn :as edn]
[config.core :refer [env]]
[datomic.client.api :as dc]
[mount.core :as mount])
[mount.core :as mount]
[clojure.java.io :as io])
(:import
(java.util UUID)))
@@ -892,3 +894,8 @@
)
(defn transact-schema [conn]
(dc/transact conn
{:tx-data (edn/read-string (slurp (io/resource "schema.edn")))}))

View File

@@ -95,7 +95,7 @@
(defn rebuild-search-index []
(search/full-index-query
(for [result (map first (dc/qseq '[:find (pull ?v [:client/name :client/matches :db/id])
(for [result (map first (dc/q '[:find (pull ?v [:client/name :client/matches :db/id])
:in $
:where [?v :client/code]]
(dc/db conn)))

View File

@@ -99,10 +99,12 @@
due (or (and (:vendor/terms vendor)
(coerce/to-date
(time/plus date (time/days (d-vendors/terms-for-client-id vendor client_id)))))
due)
due
nil)
scheduled_payment (or scheduled_payment
(and (d-vendors/automatically-paid-for-client-id? vendor client_id)
due))
due)
nil)
_ (when-not (:db/id account)
(throw (ex-info (str "Vendor '" (:vendor/name vendor) "' does not have a default expense acount.") {:vendor-id vendor_id})))]
@@ -123,7 +125,9 @@
(defn assert-valid-expense-accounts [expense_accounts vendor_id]
(doseq [expense-account expense_accounts
:let [account (dc/pull (dc/db conn)
[:account/location]
[:db/id
:account/location
{:account/invoice-allowance [:db/ident]}]
(:account_id expense-account))]]
(when (empty? (:location expense-account))
(throw (ex-info "Expense account is missing location" {:validation-error "Expense account is missing location"})))
@@ -136,8 +140,8 @@
{:validation-error err}))))
(when (and (= :allowance/denied
(:account/invoice-allowance account))
(not= (pull-ref (dc/db conn) vendor_id :vendor/default-account)
(:db/ident (:account/invoice-allowance account)))
(not= (pull-ref (dc/db conn) :vendor/default-account vendor_id )
(:db/id account)))
(let [err (str "Account isn't allowed for invoice use.")]
(throw (ex-info err
@@ -171,7 +175,7 @@
(assert-valid-expense-accounts expense_accounts vendor_id)
(assert-invoice-amounts-add-up in)
(let [transaction-result (transact-with-ledger (add-invoice-transaction in) (:id context))]
(let [transaction-result (transact-with-ledger [(add-invoice-transaction in)] (:id context))]
(-> (d-invoices/get-by-id (get-in transaction-result [:tempids "invoice"]))
(->graphql (:id context)))))

View File

@@ -1,6 +1,6 @@
(ns auto-ap.graphql.transaction-rules
(:require
[auto-ap.datomic :refer [audit-transact conn merge-query upsert-entity]]
[auto-ap.datomic :refer [audit-transact conn merge-query upsert-entity random-tempid]]
[auto-ap.datomic.transaction-rules :as tr]
[auto-ap.datomic.transactions :as d-transactions]
[auto-ap.graphql.utils
@@ -33,7 +33,7 @@
(defn transaction-rule-account->entity [{:keys [id account_id percentage location]}]
#:transaction-rule-account {:percentage percentage
:db/id id
:db/id (or id (random-tempid))
:account account_id
:location location})

View File

@@ -280,14 +280,20 @@
(finish! [this])
(fail! [this error]))
(def bank-account-pull [:bank-account/code
:db/id
:bank-account/locations
:bank-account/start-date
{:client/_bank-accounts [:client/code :client/locked-until :client/locations :db/id]} ])
(defn start-import-batch [source user]
(let [stats (atom {:import-batch/imported 0
(let [stats (atom {:import-batch/imported 0
:import-batch/suppressed 0
:import-batch/error 0
:import-batch/not-ready 0
:import-batch/extant 0})
extant-cache (atom (cache/ttl-cache-factory {} :ttl 60000 ))
import-id (get (:tempids (dc/transact conn {:tx-data [{:db/id "import-batch"
extant-cache (atom (cache/ttl-cache-factory {} :ttl 60000 ))
import-id (get (:tempids (dc/transact conn {:tx-data [{:db/id "import-batch"
:import-batch/date (coerce/to-date (t/now))
:import-batch/source source
:import-batch/status :import-status/started
@@ -298,11 +304,7 @@
(reify ImportBatch
(import-transaction! [_ transaction]
(let [bank-account (dc/pull (dc/db conn)
[:bank-account/code
:db/id
:bank-account/locations
:bank-account/start-date
{:client/_bank-accounts [:client/code :client/locked-until :client/locations :db/id]} ]
bank-account-pull
(:transaction/bank-account transaction))
extant (get (swap! extant-cache cache/through-cache (:transaction/bank-account transaction) get-existing)
(:transaction/bank-account transaction))