diff --git a/src/clj/auto_ap/datomic/migrate.clj b/src/clj/auto_ap/datomic/migrate.clj index 770fc976..194ac3c6 100644 --- a/src/clj/auto_ap/datomic/migrate.clj +++ b/src/clj/auto_ap/datomic/migrate.clj @@ -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...") diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 10ca9def..2cfbc8ee 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -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}) diff --git a/src/clj/auto_ap/graphql/ledger.clj b/src/clj/auto_ap/graphql/ledger.clj index 4ca85236..dd4f0741 100644 --- a/src/clj/auto_ap/graphql/ledger.clj +++ b/src/clj/auto_ap/graphql/ledger.clj @@ -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)) diff --git a/src/clj/auto_ap/routes/graphql.clj b/src/clj/auto_ap/routes/graphql.clj index f3ec96bc..b4e332cc 100644 --- a/src/clj/auto_ap/routes/graphql.clj +++ b/src/clj/auto_ap/routes/graphql.clj @@ -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}) diff --git a/src/cljs/auto_ap/views/components/invoice_table.cljs b/src/cljs/auto_ap/views/components/invoice_table.cljs index 1ab7d47b..b1f21c0f 100644 --- a/src/cljs/auto_ap/views/components/invoice_table.cljs +++ b/src/cljs/auto_ap/views/components/invoice_table.cljs @@ -105,7 +105,7 @@ (client-override i) (:name client))]) [grid/cell {} (:name vendor)] - [grid/cell {} invoice-number] + [glast-updatedrid/cell {} invoice-number] [grid/cell {} (date->str date) ] [grid/cell {} (when due diff --git a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs index 4f20b2d6..10f8e7d7 100644 --- a/src/cljs/auto_ap/views/pages/admin/clients/form.cljs +++ b/src/cljs/auto_ap/views/pages/admin/clients/form.cljs @@ -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]}] {:number number :name name - :check-number check-number + :check-number (when-not (str/blank? check-number) + (js/parseInt check-number)) :include-in-reports include-in-reports :start-date (cond (not start-date) nil