adding new vendors

This commit is contained in:
Bryce Covert
2019-02-14 21:18:26 -08:00
parent b5ea345532
commit 7e1de79fea
8 changed files with 202 additions and 4 deletions

View File

@@ -62,6 +62,7 @@
:auto-ap/add-import-status {:txes auto-ap.datomic.migrate.invoice-converter/add-import-status :requires [:auto-ap/add-default-location-2]}
:auto-ap/add-import-status-existing-invoices {:txes-fn 'auto-ap.datomic.migrate.invoice-converter/add-import-status-existing-invoices :requires [:auto-ap/add-import-status]}
:auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers :requires [:auto-ap/add-import-status-existing-invoices]}
:auto-ap/add-new-vendors {:txes-fn 'auto-ap.datomic.migrate.add-new-vendors/add-new-vendors :requires [:auto-ap/fix-check-numbers]}
}]
(println "Conforming database...")
(println (c/ensure-conforms conn norms-map))

View File

@@ -0,0 +1,27 @@
(ns auto-ap.datomic.migrate.add-new-vendors
(:require [datomic.api :as d]
[auto-ap.datomic :refer [uri]]
[clojure.data.csv :as csv]
[clojure.java.io :as io]
[clojure.string :as str])
(:import [org.apache.commons.io.input BOMInputStream]))
(defn add-new-vendors [conn]
(let [[header & rows] (-> "vendor-list.csv" (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv)
headers (map read-string header)
new-vendors [(reduce
(fn [rows r]
(conj rows (reduce
(fn [r [header value]]
(condp = header
[:vendor/address] r
[:vendor/default-expense-account] (assoc-in r header (Integer/parseInt (str/replace value #"A" "")))
[:vendor/invoice-reminder-schedule] r
(assoc-in r header value)))
{}
(map vector headers r))))
[]
rows)]]
(println (ffirst new-vendors))
new-vendors
))

View File

@@ -3,11 +3,17 @@
[auto-ap.datomic :refer [uri]]))
(defn get-graphql [args]
(prn (->> (d/q '[:find (pull ?e [*])
:where [?e :vendor/name]]
(d/db (d/connect uri)))
(map first)
(take 5)))
(->> (d/q '[:find (pull ?e [*])
:where [?e :vendor/name]]
(d/db (d/connect uri)))
(->> (d/q '[:find (pull ?e [*])
:where [?e :vendor/name]]
(d/db (d/connect uri)))
(map first)
#_(map (fn [c]
(update c :client/bank-accounts
(fn [bas]