fixes for staging, parsing

This commit is contained in:
Bryce Covert
2020-12-27 08:28:50 -08:00
parent c9f35cf7b4
commit 544a69432c
6 changed files with 29 additions and 26 deletions

View File

@@ -9,6 +9,7 @@
[auto-ap.datomic.migrate.sales :as sales]
[auto-ap.datomic.migrate.clients :as clients]
[auto-ap.datomic.migrate.audit :as audit]
[auto-ap.datomic.migrate.yodlee2 :as yodlee2]
[clojure.java.io :as io]
[io.rkn.conformity :as c]
@@ -334,6 +335,7 @@
sales/norms-map
clients/norms-map
ledger/norms-map
yodlee2/norms-map
audit/norms-map)
]
(println "Conforming database...")

View File

@@ -40,17 +40,15 @@
:serialize #(or (:ident %) (:db/ident %) %)}
:iso_date {:parse #(time/parse % time/iso-date)
:serialize #(time/unparse % time/iso-date)}
:money {:parse #(do
(log/info "parsing money...")
(cond (and (string? %)
(not (str/blank? %)))
(Double/parseDouble %)
:money {:parse #(cond (and (string? %)
(not (str/blank? %)))
(Double/parseDouble %)
(int? %)
(double %)
(int? %)
(double %)
:else
%))
:else
%)
:serialize #(cond (double? %)
(str %)
@@ -60,15 +58,17 @@
:else
%)
}
:percentage {:parse #(cond (and (string? %)
(not (str/blank? %)))
(Double/parseDouble %)
:percentage {:parse #(do
(log/info "value is" %)
(cond (and (string? %)
(not (str/blank? %)))
(Double/parseDouble %)
(int? %)
(str %)
(int? %)
(double %)
:else
%)
:else
%))
:serialize #(if (double? %)
(str %)
%)}}
@@ -681,14 +681,14 @@
:import_ledger_line_item {:fields {:account_identifier {:type 'String}
:location {:type 'String}
:debit {:type 'String}
:credit {:type 'String}}}
:debit {:type :money}
:credit {:type :money}}}
:import_ledger_entry {:fields {:source {:type 'String}
:external_id {:type 'String}
:client_code {:type 'String}
:date {:type 'String}
:vendor_name {:type 'String}
:amount {:type 'String}
:amount {:type :money}
:note {:type 'String}
:cleared_against {:type 'String}
:line_items {:type '(list :import_ledger_line_item)}}}
@@ -1309,7 +1309,7 @@
(do
(warn-event "validation error" {:validation-error v
:data (ex-data e)})
(throw (Exception. v))
(throw e)
#_{:errors [{:message v}]})
(do
(error-event "query error" {:error e})

View File

@@ -268,14 +268,13 @@
transaction (doall (map
(assoc-error (fn [entry]
(let [entry (-> entry
(update :amount #(Double/parseDouble %))
(update :line_items
(fn [lis]
(mapv
(fn [li ]
(-> li
(update :debit #(Double/parseDouble (if (str/blank? %) "0" %)))
(update :credit #(Double/parseDouble (if (str/blank? %) "0" %)))))
(update :debit (fnil identity 0.0))
(update :credit (fnil identity 0.0))))
lis))))]
(let [vendor (all-vendors (:vendor_name entry))]
(when-not (all-clients (:client_code entry))

View File

@@ -19,13 +19,14 @@
:body (pr-str (ql/query (:identity r) (if (= request-method :get) (query-params "query") body) variables ))
:headers {"Content-Type" "application/edn"}})
(catch Throwable e
(log/info "here we are " (.getCause e))
(if-let [result (:result (ex-data e))]
(do (log/warn "Graphql Result error" e)
{:status 400
:body (pr-str result)
:headers {"Content-Type" "application/edn"}})
(if-let [message (:validation-error (ex-data e) )]
(if-let [message (:validation-error (ex-data (.getCause e)) )]
(do
(warn-event "GraphQL Validation error" {:message message
:data e})