From 534b6e35f27d1920ed27be8620ede08b9e5c701d Mon Sep 17 00:00:00 2001 From: Bryce Date: Tue, 30 May 2023 12:30:58 -0700 Subject: [PATCH 1/3] imports invoices one at a time to avoid duplicating them --- iol_ion/src/iol_ion/tx.clj | 3 +++ src/clj/auto_ap/jobs/ntg.clj | 5 +++-- src/clj/auto_ap/routes/invoices.clj | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/iol_ion/src/iol_ion/tx.clj b/iol_ion/src/iol_ion/tx.clj index d145e245..8ad133db 100644 --- a/iol_ion/src/iol_ion/tx.clj +++ b/iol_ion/src/iol_ion/tx.clj @@ -4,6 +4,9 @@ (:import [java.util UUID])) (def random-tempid iol-ion.utils/random-tempid) +(defn composite-tempid [& pieces] + (format "hashed-%d" (.hashCode (set pieces)))) + (def by iol-ion.utils/by) (def pull-many iol-ion.utils/pull-many) (def remove-nils iol-ion.utils/remove-nils) diff --git a/src/clj/auto_ap/jobs/ntg.clj b/src/clj/auto_ap/jobs/ntg.clj index 71ecf1d9..b945959b 100644 --- a/src/clj/auto_ap/jobs/ntg.clj +++ b/src/clj/auto_ap/jobs/ntg.clj @@ -168,7 +168,7 @@ :content first Double/parseDouble) - invoice {:db/id (random-tempid) + invoice {:db/id (random-tempid ) :invoice/vendor :vendor/cintas :invoice/import-status :import-status/imported :invoice/status :invoice-status/unpaid @@ -268,7 +268,8 @@ (mark-error k) [])))) (into []))] - (audit-transact transaction {:user/name "sysco importer" :user/role "admin"}) + (doseq [t transaction] + (audit-transact [t] {:user/name "sysco importer" :user/role "admin"})) (log/info ::success :count (count transaction) :sample (take 3 transaction))) diff --git a/src/clj/auto_ap/routes/invoices.clj b/src/clj/auto_ap/routes/invoices.clj index 0ccb0e0f..4931501d 100644 --- a/src/clj/auto_ap/routes/invoices.clj +++ b/src/clj/auto_ap/routes/invoices.clj @@ -136,8 +136,8 @@ (defn import->invoice [{:keys [invoice-number source-url customer-identifier account-number total date vendor-code text full-text client-override vendor-override location-override import-status]}] (let [matching-client (cond - account-number (d-clients/exact-match account-number) - customer-identifier (d-clients/best-match customer-identifier) + account-number (:db/id (d-clients/exact-match account-number)) + customer-identifier (:db/id (d-clients/best-match customer-identifier)) client-override (Long/parseLong client-override)) matching-vendor (match-vendor vendor-code vendor-override) From 1444a661d850d9ec9adf337540ca8096f3704d7f Mon Sep 17 00:00:00 2001 From: Bryce Date: Tue, 30 May 2023 13:52:08 -0700 Subject: [PATCH 2/3] fixes sysco import. --- src/clj/auto_ap/jobs/sysco.clj | 2 +- src/clj/auto_ap/parse.clj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clj/auto_ap/jobs/sysco.clj b/src/clj/auto_ap/jobs/sysco.clj index c43c5b0b..c64d6277 100644 --- a/src/clj/auto_ap/jobs/sysco.clj +++ b/src/clj/auto_ap/jobs/sysco.clj @@ -87,7 +87,7 @@ [{:client/location-matches [:location-match/location :location-match/matches]} :client/default-location :client/locations] - matching-client) + (:db/id matching-client)) location-hint location-hint ) :date (coerce/to-date date) diff --git a/src/clj/auto_ap/parse.clj b/src/clj/auto_ap/parse.clj index 6d54d260..9557b887 100644 --- a/src/clj/auto_ap/parse.clj +++ b/src/clj/auto_ap/parse.clj @@ -124,7 +124,7 @@ (defn exact-match ([clients invoice-client-name] (->> clients - (filter (fn [{:keys [:client/matches :client/name] :as client :or {matches []}}] + (filter (fn [{:keys [:client/matches :client/location-matches :client/locations :client/name] :as client :or {matches []}}] (seq (filter (fn [m] (and From 91d2bcbf9ed9daaa65931ba67b2970b17a4455c6 Mon Sep 17 00:00:00 2001 From: Bryce Date: Wed, 31 May 2023 16:58:42 -0700 Subject: [PATCH 3/3] makes solr startable --- start-solr.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 start-solr.sh diff --git a/start-solr.sh b/start-solr.sh new file mode 100755 index 00000000..82d4b77d --- /dev/null +++ b/start-solr.sh @@ -0,0 +1,3 @@ +#/bin/bash +sudo docker run --rm -ti -v ~/dev/integreat/data/solr:/var/solr --network=bridge -p 8983:8983 solr +