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]

View File

@@ -337,6 +337,7 @@
9365 {:name "Office Maintenance - HQ" :parent 9300 :location "HQ" }
9370 {:name "Utilities - HQ" :parent 9300 :location "HQ" }
9380 {:name "Telephone - HQ" :parent 9300 :location "HQ" }
9383 {:name "Storage - HQ" :parent 9380 :location "HQ" }
9500 {:name "HQ Interest and Bank Expenses" :parent nil :location "HQ" }
9510 {:name "Bank Fees - HQ" :parent 9500 :location "HQ" }
9520 {:name "NSF Fees - HQ" :parent 9500 :location "HQ" }

View File

@@ -54,6 +54,12 @@
(fn [db]
(vals (:vendors db))))
(re-frame/reg-sub
::sorted-vendors
:<- [::vendors]
(fn [vendors]
(sort-by :name vendors)))
(re-frame/reg-sub
::admin
(fn [db]

View File

@@ -24,7 +24,7 @@
(set (mapcat :in (::s/problems (s/explain-data spec v)))))
(defn vendors-table []
(let [vendors (re-frame/subscribe [::subs/vendors])
(let [vendors (re-frame/subscribe [::subs/sorted-vendors])
editing-vendor (:editing @(re-frame/subscribe [::subs/admin]))]
[:table {:class "table", :style {:width "100%"}}