Makes integreat run on datomic cloud

This commit is contained in:
2022-08-23 12:13:12 -07:00
parent 58b9dcf272
commit d02fba2b44
58 changed files with 2163 additions and 1257 deletions

View File

@@ -1,7 +1,7 @@
(ns auto-ap.graphql.checks
(:require
[amazonica.aws.s3 :as s3]
[auto-ap.datomic :refer [conn remove-nils]]
[auto-ap.datomic :refer [conn remove-nils plus]]
[auto-ap.datomic.accounts :as a]
[auto-ap.datomic.bank-accounts :as d-bank-accounts]
[auto-ap.datomic.checks :as d-checks]
@@ -34,9 +34,9 @@
[com.brunobonacci.mulog :as mu]
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
[config.core :refer [env]]
[datomic.api :as d]
[digest]
[clj-time.coerce :as coerce])
[clj-time.coerce :as coerce]
[datomic.client.api :as dc]
[digest])
(:import
(java.io ByteArrayOutputStream)
(java.text DecimalFormat)
@@ -230,7 +230,7 @@
[{:invoice-payment/payment (-> invoice :invoice/vendor :db/id str)
:invoice-payment/amount invoice-amount
:invoice-payment/invoice (:db/id invoice)}
[:pay (:db/id invoice) invoice-amount]])
`(d-checks/pay ~(:db/id invoice) ~invoice-amount)])
(reduce into [])))
(defn base-payment [invoices vendor client bank-account _ _ invoice-amounts]
@@ -391,7 +391,6 @@
(let [type (keyword "payment-type" (name type))
invoices (d-invoices/get-multi (map :invoice-id invoice-payments))
client (d-clients/get-by-id client-id)
invoice-amounts (by :invoice-id :amount invoice-payments)
invoices-grouped-by-vendor (group-by (comp :db/id :invoice/vendor) invoices)
vendors (->> (d/pull-many (d/db conn) d-vendors/default-read (keys invoices-grouped-by-vendor))
@@ -409,14 +408,16 @@
(reduce into [])
doall))
checks (if (= type :payment-type/check)
(conj checks [:inc (:db/id bank-account) :bank-account/check-number (count invoices-grouped-by-vendor)])
(conj checks `(plus ~(:db/id bank-account) ~:bank-account/check-number ~(count invoices-grouped-by-vendor)))
checks)]
(when (= type :payment-type/check)
(mu/trace ::making-pdfs [:checks checks]
(make-pdfs (filter #(and (= :payment-type/check (:payment/type %))
(> (:payment/amount %) 0.0))
checks))))
(transact-with-ledger checks id)
(transact-with-ledger (map #(if (map? %)
(dissoc % :payment/pdf-data)
%) checks ) id)
{:invoices (d-invoices/get-multi (map :invoice-id invoice-payments))
@@ -565,7 +566,6 @@
(log/info "Voiding " (count all-ids) args)
(void-payments-internal all-ids (:id context))
{:message (str "Succesfully voided " (count all-ids))}))
(defn get-all-payments [context args _]