From d6b3048ff054f9e6074298d7aac005a7139a078f Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 24 May 2023 08:45:26 -0700 Subject: [PATCH] Makes imports more resilient --- src/clj/auto_ap/datomic.clj | 2 +- src/clj/auto_ap/jobs/ntg.clj | 5 +++-- src/clj/auto_ap/jobs/sysco.clj | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/clj/auto_ap/datomic.clj b/src/clj/auto_ap/datomic.clj index 30da1c3d..6450d28d 100644 --- a/src/clj/auto_ap/datomic.clj +++ b/src/clj/auto_ap/datomic.clj @@ -654,7 +654,7 @@ (defn audit-transact [txes id] (try - @(dc/transact conn (conj txes {:db/id "datomic.tx" + @(dc/transact-async conn (conj txes {:db/id "datomic.tx" :audit/user (str (:user/role id) "-" (:user/name id))})) (catch Exception e (mu/log ::transaction-error diff --git a/src/clj/auto_ap/jobs/ntg.clj b/src/clj/auto_ap/jobs/ntg.clj index c7ebe4b9..dc808416 100644 --- a/src/clj/auto_ap/jobs/ntg.clj +++ b/src/clj/auto_ap/jobs/ntg.clj @@ -1,7 +1,7 @@ (ns auto-ap.jobs.ntg (:require [amazonica.aws.s3 :as s3] - [auto-ap.datomic :refer [audit-transact conn]] + [auto-ap.datomic :refer [audit-transact conn random-tempid]] [auto-ap.jobs.core :refer [execute]] [auto-ap.logging :as log] [auto-ap.parse :as parse] @@ -81,7 +81,8 @@ (log/warn ::missing-client :client-hint location-hint) (swap! missing-client-hints conj location-hint)) - {:invoice/location location + {:db/id (random-tempid) + :invoice/location location :invoice/date (coerce/to-date (atime/parse ship-date atime/normal-date)) :invoice/invoice-number invoice-number :invoice/total (Double/parseDouble invoice-total) diff --git a/src/clj/auto_ap/jobs/sysco.clj b/src/clj/auto_ap/jobs/sysco.clj index e283aa80..c43c5b0b 100644 --- a/src/clj/auto_ap/jobs/sysco.clj +++ b/src/clj/auto_ap/jobs/sysco.clj @@ -3,7 +3,7 @@ [amazonica.aws.s3 :as s3] [auto-ap.datomic :refer [conn]] [auto-ap.jobs.core :refer [execute]] - [auto-ap.datomic :refer [audit-transact]] + [auto-ap.datomic :refer [audit-transact random-tempid]] [auto-ap.datomic.clients :as d-clients] [auto-ap.datomic.invoices :refer [code-invoice]] [auto-ap.parse :as parse] @@ -80,6 +80,7 @@ (log/infof "Importing %s for %s" (header-row "InvoiceNumber") (header-row "CustomerName")) (cond-> #:invoice {:invoice-number (header-row "InvoiceNumber") + :db/id (random-tempid) :total (+ total tax) :outstanding-balance (+ total tax) :location (parse/best-location-match (dc/pull (dc/db conn)