Getting closer to datomic cloud
This commit is contained in:
@@ -1,27 +1,23 @@
|
||||
(ns auto-ap.jobs.load-historical-sales
|
||||
(:gen-class)
|
||||
(:require
|
||||
[unilog.context :as lc]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.jobs.core :refer [execute]]
|
||||
[amazonica.aws.s3 :as s3]
|
||||
[auto-ap.square.core :as square]
|
||||
[auto-ap.square.core3 :as square3]
|
||||
[clj-time.periodic :as per]
|
||||
[clj-time.core :as time]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[clojure.string :as str]
|
||||
[clj-time.coerce :as coerce]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.datomic :refer [conn audit-transact]]
|
||||
[clojure.data.csv :as csv]
|
||||
[clojure.java.io :as io]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clj-time.core :as time]
|
||||
[clj-time.periodic :as per]
|
||||
[clojure.tools.logging :as log]
|
||||
[config.core :refer [env]]
|
||||
[clojure.tools.logging :as log]))
|
||||
[datomic.client.api :as dc]
|
||||
[unilog.context :as lc]))
|
||||
|
||||
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||
(defn historical-load-sales [client days]
|
||||
(log/info "loading old approach")
|
||||
(let [client (d/pull (d/db auto-ap.datomic/conn)
|
||||
(let [client (dc/pull (dc/db auto-ap.datomic/conn)
|
||||
square/square-read
|
||||
client)]
|
||||
(doseq [square-location (:client/square-locations client)
|
||||
@@ -54,7 +50,7 @@
|
||||
|
||||
(defn historical-load-sales2 [client days]
|
||||
(log/info "loading new approach")
|
||||
(let [client (d/pull (d/db auto-ap.datomic/conn)
|
||||
(let [client (dc/pull (dc/db auto-ap.datomic/conn)
|
||||
square/square-read
|
||||
client)]
|
||||
(doseq [square-location (:client/square-locations client)
|
||||
@@ -88,7 +84,7 @@
|
||||
(defn load-historical-sales [args]
|
||||
(let [{:keys [days client]} args
|
||||
client (Long/parseLong client)
|
||||
feature-flags (-> (d/pull (d/db conn) '[:client/feature-flags] client)
|
||||
feature-flags (-> (dc/pull (dc/db conn) '[:client/feature-flags] client)
|
||||
:client/feature-flags
|
||||
set)]
|
||||
(if (get feature-flags "new-square")
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
(ns auto-ap.jobs.ntg
|
||||
(:require
|
||||
[amazonica.aws.s3 :as s3]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.datomic.clients :as d-clients]
|
||||
[auto-ap.datomic.invoices :refer [code-invoice]]
|
||||
[auto-ap.jobs.core :refer [execute]]
|
||||
[auto-ap.ledger :refer [transact-with-ledger]]
|
||||
[auto-ap.logging :as log]
|
||||
[auto-ap.parse :as parse]
|
||||
[auto-ap.time :as t]
|
||||
[auto-ap.time :as atime]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.data.csv :as csv]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[auto-ap.logging :as log :refer [capture-context->lc with-context-as]]
|
||||
[com.unbounce.dogstatsd.core :as statsd]
|
||||
[config.core :refer [env]]
|
||||
[datomic.api :as d]
|
||||
[com.brunobonacci.mulog :as mu]
|
||||
|
||||
[auto-ap.time :as atime])
|
||||
[clojure.string :as str])
|
||||
(:import
|
||||
(java.util UUID)))
|
||||
|
||||
|
||||
(def bucket-name "data.prod.app.integreatconsult.com" #_(:data-bucket env))
|
||||
|
||||
(defn read-csv [k]
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
(ns auto-ap.jobs.register-invoice-import
|
||||
(:gen-class)
|
||||
(:require
|
||||
[auto-ap.jobs.core :refer [execute]]
|
||||
[amazonica.aws.s3 :as s3]
|
||||
[datomic.api :as d]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[clojure.string :as str]
|
||||
[clj-time.coerce :as coerce]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.datomic :refer [conn pull-attr]]
|
||||
[auto-ap.jobs.core :refer [execute]]
|
||||
[auto-ap.ledger :refer [transact-with-ledger]]
|
||||
[auto-ap.datomic :refer [conn]]
|
||||
[auto-ap.time :as atime]
|
||||
[auto-ap.utils :refer [dollars=]]
|
||||
[clj-time.coerce :as coerce]
|
||||
[clojure.data.csv :as csv]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[clojure.tools.logging :as log]
|
||||
[config.core :refer [env]]
|
||||
[clojure.tools.logging :as log]))
|
||||
[datomic.client.api :as dc])
|
||||
(:import [java.util UUID]))
|
||||
|
||||
(def bucket (:data-bucket env))
|
||||
|
||||
@@ -30,12 +31,11 @@
|
||||
(throw e))))
|
||||
|
||||
(defn register-invoice-import* [data]
|
||||
(let [db (d/db conn)
|
||||
(let [db (dc/db conn)
|
||||
i->invoice-id (fn [i]
|
||||
(try (Long/parseLong i)
|
||||
(catch Exception _
|
||||
(:db/id (d/pull db '[:db/id]
|
||||
[:invoice/original-id (Long/parseLong (first (str/split i #"-")))])))))
|
||||
(pull-attr db :db/id [:invoice/original-id (Long/parseLong (first (str/split i #"-")))]))))
|
||||
invoice-totals (->> data
|
||||
(drop 1)
|
||||
(group-by first)
|
||||
@@ -57,7 +57,7 @@
|
||||
location] (drop 1 data)
|
||||
:let [invoice-id (i->invoice-id i)
|
||||
|
||||
invoice (d/entity db invoice-id)
|
||||
invoice (dc/pull db '[*] invoice-id)
|
||||
current-total (:invoice/total invoice)
|
||||
target-total (invoice-totals invoice-id) ;; TODO should include expense accounts not visible
|
||||
new-account? (not (boolean (or (some-> invoice-expense-account-id not-empty Long/parseLong)
|
||||
@@ -65,10 +65,10 @@
|
||||
|
||||
invoice-expense-account-id (or (some-> invoice-expense-account-id not-empty Long/parseLong)
|
||||
(:db/id (first (:invoice/expense-accounts invoice)))
|
||||
(d/tempid :db.part/user))
|
||||
(str (UUID/randomUUID)))
|
||||
invoice-expense-account (when-not new-account?
|
||||
(or (d/entity db invoice-expense-account-id)
|
||||
(d/entity db [:invoice-expense-account/original-id invoice-expense-account-id])))
|
||||
(or (dc/pull db '[*] invoice-expense-account-id)
|
||||
(dc/pull db '[*] [:invoice-expense-account/original-id invoice-expense-account-id])))
|
||||
current-account-id (:db/id (:invoice-expense-account/account invoice-expense-account))
|
||||
target-account-id (Long/parseLong (str/trim target-account))
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
target-expense-account-location location
|
||||
|
||||
|
||||
[[_ _ invoice-payment]] (vec (d/q
|
||||
[[_ _ invoice-payment]] (vec (dc/q
|
||||
'[:find ?p ?a ?ip
|
||||
:in $ ?i
|
||||
:where [?ip :invoice-payment/invoice ?i]
|
||||
|
||||
Reference in New Issue
Block a user