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

View File

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

View File

@@ -268,14 +268,13 @@
transaction (doall (map transaction (doall (map
(assoc-error (fn [entry] (assoc-error (fn [entry]
(let [entry (-> entry (let [entry (-> entry
(update :amount #(Double/parseDouble %))
(update :line_items (update :line_items
(fn [lis] (fn [lis]
(mapv (mapv
(fn [li ] (fn [li ]
(-> li (-> li
(update :debit #(Double/parseDouble (if (str/blank? %) "0" %))) (update :debit (fnil identity 0.0))
(update :credit #(Double/parseDouble (if (str/blank? %) "0" %))))) (update :credit (fnil identity 0.0))))
lis))))] lis))))]
(let [vendor (all-vendors (:vendor_name entry))] (let [vendor (all-vendors (:vendor_name entry))]
(when-not (all-clients (:client_code 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 )) :body (pr-str (ql/query (:identity r) (if (= request-method :get) (query-params "query") body) variables ))
:headers {"Content-Type" "application/edn"}}) :headers {"Content-Type" "application/edn"}})
(catch Throwable e (catch Throwable e
(log/info "here we are " (.getCause e))
(if-let [result (:result (ex-data e))] (if-let [result (:result (ex-data e))]
(do (log/warn "Graphql Result error" e) (do (log/warn "Graphql Result error" e)
{:status 400 {:status 400
:body (pr-str result) :body (pr-str result)
:headers {"Content-Type" "application/edn"}}) :headers {"Content-Type" "application/edn"}})
(if-let [message (:validation-error (ex-data e) )] (if-let [message (:validation-error (ex-data (.getCause e)) )]
(do (do
(warn-event "GraphQL Validation error" {:message message (warn-event "GraphQL Validation error" {:message message
:data e}) :data e})

View File

@@ -105,7 +105,7 @@
(client-override i) (client-override i)
(:name client))]) (:name client))])
[grid/cell {} (:name vendor)] [grid/cell {} (:name vendor)]
[grid/cell {} invoice-number] [glast-updatedrid/cell {} invoice-number]
[grid/cell {} (date->str date) ] [grid/cell {} (date->str date) ]
[grid/cell {} [grid/cell {}
(when due (when due

View File

@@ -108,7 +108,8 @@
:bank-accounts (map (fn [{:keys [number name check-number include-in-reports type id code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations yodlee-account]}] :bank-accounts (map (fn [{:keys [number name check-number include-in-reports type id code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations yodlee-account]}]
{:number number {:number number
:name name :name name
:check-number check-number :check-number (when-not (str/blank? check-number)
(js/parseInt check-number))
:include-in-reports include-in-reports :include-in-reports include-in-reports
:start-date (cond (not start-date) :start-date (cond (not start-date)
nil nil