All data on checks are now set up.
This commit is contained in:
15
migrator/migrations/1526611275-DOWN-move-address-to-data.sql
Normal file
15
migrator/migrations/1526611275-DOWN-move-address-to-data.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- 1526611275 DOWN move-address-to-data
|
||||
alter table vendors
|
||||
add column address1 varchar (255);
|
||||
|
||||
alter table vendors
|
||||
add column address2 varchar (255);
|
||||
|
||||
alter table vendors
|
||||
add column city varchar (255);
|
||||
|
||||
alter table vendors
|
||||
add column state varchar (255);
|
||||
|
||||
alter table vendors
|
||||
add column zip varchar (255);
|
||||
18
migrator/migrations/1526611275-UP-move-address-to-data.sql
Normal file
18
migrator/migrations/1526611275-UP-move-address-to-data.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- 1526611275 UP move-address-to-data
|
||||
UPDATE vendors v
|
||||
set data = CONCAT('{ '
|
||||
, ' :address { '
|
||||
, ' :street1 "' , v.address1 , '" '
|
||||
, ' :street2 "' , v.address2 , '" '
|
||||
, ' :city "' , v.city , '" '
|
||||
, ' :state "' , v.state , '" '
|
||||
, ' :zip "' , v.zip , '" '
|
||||
, ' }'
|
||||
, ' }');
|
||||
|
||||
|
||||
alter table vendors drop column address1;
|
||||
alter table vendors drop column address2;
|
||||
alter table vendors drop column city;
|
||||
alter table vendors drop column state;
|
||||
alter table vendors drop column zip;
|
||||
@@ -5,7 +5,6 @@
|
||||
[clojure.java.jdbc :as j]
|
||||
[honeysql.core :as sql]
|
||||
[honeysql.helpers :as helpers]))
|
||||
|
||||
(def all-fields #{:name :email :data :id})
|
||||
|
||||
(def base-query (sql/build :select :*
|
||||
|
||||
@@ -7,24 +7,45 @@
|
||||
[honeysql.helpers :as helpers]
|
||||
[honeysql.format :as f]))
|
||||
|
||||
(defn fields->data [x]
|
||||
(-> x
|
||||
(assoc-in [:data :address] (:address x))
|
||||
(dissoc :address)))
|
||||
|
||||
(def all-fields [:name
|
||||
:code
|
||||
:id
|
||||
:invoice-reminder-schedule
|
||||
:primary-contact
|
||||
:primary-email
|
||||
:primary-phone
|
||||
:secondary-contact
|
||||
:secondary-email
|
||||
:secondary-phone
|
||||
:data])
|
||||
|
||||
(defn unparse [x]
|
||||
(-> x
|
||||
(select-keys entities/all-keys)))
|
||||
(-> (fields->data x)
|
||||
(select-keys all-fields)
|
||||
(clj->db)))
|
||||
|
||||
(def base-query (sql/build :select :*
|
||||
:from :vendors))
|
||||
|
||||
(defn data->fields [x]
|
||||
(-> x
|
||||
(merge (:data x))
|
||||
(dissoc :data)))
|
||||
|
||||
(defn get-all []
|
||||
(query base-query))
|
||||
(map data->fields (query base-query)))
|
||||
|
||||
(defn get-by-id [id]
|
||||
(first (query (-> base-query
|
||||
(helpers/merge-where [:= :id id])))))
|
||||
(first (map data->fields
|
||||
(query (-> base-query
|
||||
(helpers/merge-where [:= :id id]))))))
|
||||
|
||||
(defn upsert [id data]
|
||||
(println data)
|
||||
(-> (sql/build
|
||||
:update :vendors
|
||||
:set (unparse data)
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
(println companies)
|
||||
(->> companies
|
||||
(map (fn [company]
|
||||
(if-let [matches (:matches (:data company))]
|
||||
(if-let [matches (:matches company)]
|
||||
[company (apply min (map #(m/jaccard (.toLowerCase company-identifier) %) matches))]
|
||||
[company 1])))
|
||||
(filter #(< (second %) 0.25))
|
||||
|
||||
@@ -86,8 +86,8 @@
|
||||
[[:cell]
|
||||
[:cell {:colspan 5} [:paragraph
|
||||
vendor-name "\n"
|
||||
(:address1 vendor) "\n"
|
||||
(:city vendor) ", " (:state vendor) " " (:zip vendor)]]
|
||||
(:street1 (:address vendor)) "\n"
|
||||
(:city (:address vendor)) ", " (:state (:address vendor)) " " (:zip (:address vendor))]]
|
||||
[:cell {:align :right}
|
||||
"Paid to:\n"
|
||||
"Amount:\n"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(ns auto-ap.entities.vendors
|
||||
(:require [clojure.spec.alpha :as s]
|
||||
[clojure.string :as str]))
|
||||
[clojure.string :as str]
|
||||
[auto-ap.entities.address :as address]))
|
||||
|
||||
(def email-regex #"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,63}$")
|
||||
(s/def ::id int)
|
||||
@@ -14,7 +15,6 @@
|
||||
:is-empty #(= % "")))))
|
||||
(s/def ::phone (s/nilable string?))
|
||||
|
||||
(s/def ::data (s/nilable string?))
|
||||
(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil}))
|
||||
(s/def ::primary-contact ::identifier)
|
||||
(s/def ::primary-email ::email)
|
||||
@@ -23,13 +23,9 @@
|
||||
(s/def ::secondary-contact ::identifier)
|
||||
(s/def ::secondary-email ::email)
|
||||
(s/def ::secondary-phone ::phone)
|
||||
(s/def ::address ::address/address)
|
||||
|
||||
(s/def ::code (s/nilable string?))
|
||||
(s/def ::address1 (s/nilable string?))
|
||||
(s/def ::address2 (s/nilable string?))
|
||||
(s/def ::city (s/nilable string?))
|
||||
(s/def ::state (s/nilable string?))
|
||||
(s/def ::zip (s/nilable string?))
|
||||
|
||||
(s/def ::vendor (s/keys :req-un [::name]
|
||||
:opt-un [::code
|
||||
@@ -41,11 +37,8 @@
|
||||
::secondary-contact
|
||||
::secondary-email
|
||||
::secondary-phone
|
||||
::address1
|
||||
::address2
|
||||
::city
|
||||
::state
|
||||
::zip]))
|
||||
::address
|
||||
]))
|
||||
|
||||
|
||||
(def vendor-spec (apply hash-map (drop 1 (s/form ::vendor))))
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
[auto-ap.subs :as subs]
|
||||
[auto-ap.events.admin.vendors :as events]
|
||||
[auto-ap.entities.vendors :as entity]
|
||||
[auto-ap.entities.address :as address]
|
||||
[clojure.spec.alpha :as s]
|
||||
[auto-ap.views.utils :refer [login-url dispatch-value-change dispatch-event bind-field horizontal-field]]
|
||||
[cljs.reader :as edn]
|
||||
@@ -98,8 +99,8 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:placeholder "1700 Pennsylvania Ave"
|
||||
:field :address1
|
||||
:spec ::entity/address1
|
||||
:field [:address :street1]
|
||||
:spec ::address/street1
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]]
|
||||
|
||||
@@ -109,8 +110,8 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:placeholder "Suite 400"
|
||||
:field :address2
|
||||
:spec ::entity/address2
|
||||
:field [:address :street2]
|
||||
:spec ::address/street2
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]]
|
||||
|
||||
@@ -121,8 +122,8 @@
|
||||
[bind-field
|
||||
[:input.input.is-expanded {:type "text"
|
||||
:placeholder "Cupertino"
|
||||
:field :city
|
||||
:spec ::entity/city
|
||||
:field [:address :city]
|
||||
:spec ::address/city
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
[:div.control
|
||||
@@ -130,16 +131,16 @@
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:placeholder "CA"
|
||||
:field :state
|
||||
:spec ::entity/state
|
||||
:field [:address :state]
|
||||
:spec ::address/state
|
||||
:event ::events/change
|
||||
:subscription editing-vendor}]]]
|
||||
[:div.control
|
||||
[:p.help "Zip"]
|
||||
[bind-field
|
||||
[:input.input {:type "text"
|
||||
:field :zip
|
||||
:spec ::entity/zip
|
||||
:field [:address :zip]
|
||||
:spec ::address/zip
|
||||
:event ::events/change
|
||||
:subscription editing-vendor
|
||||
:placeholder "95014"}]]]]
|
||||
|
||||
Reference in New Issue
Block a user