fixed warnings.
This commit is contained in:
@@ -13,7 +13,6 @@
|
|||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[config.core :refer [env]]
|
[config.core :refer [env]]
|
||||||
[mount.core :as mount]
|
[mount.core :as mount]
|
||||||
[unilog.context :as lc]
|
|
||||||
[yang.scheduler :as scheduler])
|
[yang.scheduler :as scheduler])
|
||||||
(:import
|
(:import
|
||||||
(java.util Properties UUID)
|
(java.util Properties UUID)
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
[amazonica.aws.sqs :as sqs]
|
[amazonica.aws.sqs :as sqs]
|
||||||
[auto-ap.import.intuit :as i]
|
[auto-ap.import.intuit :as i]
|
||||||
[auto-ap.import.plaid :as p]
|
[auto-ap.import.plaid :as p]
|
||||||
[auto-ap.import.yodlee :as y]
|
|
||||||
[auto-ap.import.yodlee2 :as y2]
|
[auto-ap.import.yodlee2 :as y2]
|
||||||
[auto-ap.utils :refer [heartbeat]]
|
[auto-ap.utils :refer [heartbeat]]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
(ns auto-ap.datomic
|
(ns auto-ap.datomic
|
||||||
(:require [auto-ap.utils :refer [default-pagination-size]]
|
(:require
|
||||||
[clj-time.coerce :as coerce]
|
[auto-ap.utils :refer [default-pagination-size]]
|
||||||
[datomic.api :as d]
|
[clojure.tools.logging :as log]
|
||||||
[clojure.tools.logging :as log]
|
[config.core :refer [env]]
|
||||||
[mount.core :as mount]
|
[datomic.api :as d]
|
||||||
[config.core :refer [env]]))
|
[mount.core :as mount]))
|
||||||
|
|
||||||
(def uri (:datomic-url env))
|
(def uri (:datomic-url env))
|
||||||
|
|
||||||
@@ -20,13 +20,6 @@
|
|||||||
(defn drop-database []
|
(defn drop-database []
|
||||||
(d/delete-database uri))
|
(d/delete-database uri))
|
||||||
|
|
||||||
(defn merge-query [query-part-1 query-part-2]
|
|
||||||
(-> query-part-1
|
|
||||||
(update-in [:query :find] into (get-in query-part-2 [:query :find]))
|
|
||||||
(update-in [:query :in] into (get-in query-part-2 [:query :in]))
|
|
||||||
(update-in [:query :where] into (get-in query-part-2 [:query :where]))
|
|
||||||
(update-in [:args] into (get-in query-part-2 [:args]))))
|
|
||||||
|
|
||||||
(defn remove-nils [m]
|
(defn remove-nils [m]
|
||||||
(let [result (reduce-kv
|
(let [result (reduce-kv
|
||||||
(fn [m k v]
|
(fn [m k v]
|
||||||
@@ -548,168 +541,7 @@
|
|||||||
:where [?e :vendor/name]]
|
:where [?e :vendor/name]]
|
||||||
(d/db (d/connect uri))))
|
(d/db (d/connect uri))))
|
||||||
|
|
||||||
(defn load-vendors [vendors]
|
|
||||||
(->> vendors
|
|
||||||
(map
|
|
||||||
(fn [{:keys [primary-phone address email primary-contact secondary-email secondary-contact primary-email name default-expense-account id code secondary-phone invoice-reminder-schedule print-as]}]
|
|
||||||
(let [vendor-id (d/tempid :db.part/user)
|
|
||||||
address-id (d/tempid :db.part/user)]
|
|
||||||
(remove-nils #:vendor {:original-id id
|
|
||||||
:name name
|
|
||||||
:code (if (seq code) code nil)
|
|
||||||
:email email
|
|
||||||
:default-expense-account default-expense-account
|
|
||||||
:invoice-reminder-schedule nil
|
|
||||||
:address (remove-nils #:address {:street1 (:street1 address)
|
|
||||||
:street2 (:street2 address)
|
|
||||||
:city (:city address)
|
|
||||||
:state (:state address)
|
|
||||||
:zip (:zip address)})
|
|
||||||
:primary-contact (remove-nils #:contact {:name primary-contact
|
|
||||||
:phone primary-phone
|
|
||||||
:email primary-email})
|
|
||||||
:secondary-contact (remove-nils #:contact {:name secondary-contact
|
|
||||||
:phone secondary-phone
|
|
||||||
:email secondary-email})}))))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
(defn load-clients [clients]
|
|
||||||
(->> clients
|
|
||||||
(map
|
|
||||||
(fn [{:keys [name address id code locations email bank-accounts signature-file] client-id :id}]
|
|
||||||
(remove-nils #:client {:original-id id
|
|
||||||
:name (str name)
|
|
||||||
:code nil
|
|
||||||
:email email
|
|
||||||
:signature-file signature-file
|
|
||||||
:locations locations
|
|
||||||
:address (remove-nils #:address {:street1 (:street1 address)
|
|
||||||
:street2 (:street2 address)
|
|
||||||
:city (:city address)
|
|
||||||
:state (:state address)
|
|
||||||
:zip (:zip address)})
|
|
||||||
:bank-accounts (conj (map
|
|
||||||
(fn [{:keys [number id check-number bank-name bank-code routing name yodlee-account-id type] }]
|
|
||||||
(remove-nils #:bank-account {:number number
|
|
||||||
:original-id (str client-id "-" id)
|
|
||||||
:external-id id
|
|
||||||
:check-number check-number
|
|
||||||
:bank-name bank-name
|
|
||||||
:bank-code bank-code
|
|
||||||
:routing routing
|
|
||||||
:name name
|
|
||||||
:yodlee-account-id yodlee-account-id
|
|
||||||
:type (if type
|
|
||||||
(keyword "bank-account-type" type )
|
|
||||||
:bank-account-type/check)}))
|
|
||||||
bank-accounts)
|
|
||||||
#:bank-account {:original-id (str client-id "-" 0)
|
|
||||||
:external-id 0
|
|
||||||
:type :bank-account-type/cash})} )))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn load-invoices [invoices]
|
|
||||||
(->> invoices
|
|
||||||
(map
|
|
||||||
(fn [{:keys [id status total outstanding-balance invoice-number date customer-identifier company-id vendor-id default-location default-expense-account] invoice-id :id}]
|
|
||||||
[(remove-nils #:invoice {:original-id id
|
|
||||||
:invoice-number invoice-number
|
|
||||||
:date (coerce/to-date date)
|
|
||||||
:customer-identifier customer-identifier
|
|
||||||
:client [:client/original-id company-id]
|
|
||||||
:vendor (when vendor-id [:vendor/original-id vendor-id])
|
|
||||||
|
|
||||||
:default-location default-location
|
|
||||||
:default-expense-account default-expense-account
|
|
||||||
:total (double total)
|
|
||||||
:outstanding-balance (double outstanding-balance)
|
|
||||||
:status (keyword "invoice-status" status)})]))))
|
|
||||||
|
|
||||||
(defn load-invoices-expense-accounts [invoices-expense-accounts]
|
|
||||||
(->> invoices-expense-accounts
|
|
||||||
(map
|
|
||||||
(fn [{:keys [id expense-account-id location amount invoice-id]}]
|
|
||||||
[(remove-nils #:invoice {:original-id invoice-id
|
|
||||||
:expense-accounts [(remove-nils #:invoice-expense-account {:original-id id
|
|
||||||
:expense-account-id expense-account-id
|
|
||||||
:location location
|
|
||||||
:amount (double amount)})]})]))))
|
|
||||||
|
|
||||||
|
|
||||||
(defn load-payments [checks]
|
|
||||||
(->> checks
|
|
||||||
(map
|
|
||||||
(fn [{:keys [id s3-uuid s3-key s3-url vendor-id company-id check-number memo date amount paid-to data bank-account-id status type] invoice-id :id}]
|
|
||||||
[(remove-nils #:payment {:original-id id
|
|
||||||
:s3-uuid s3-uuid
|
|
||||||
:s3-key s3-key
|
|
||||||
:s3-url s3-url
|
|
||||||
:vendor (when vendor-id [:vendor/original-id vendor-id])
|
|
||||||
:client [:client/original-id company-id]
|
|
||||||
:bank-account (when (and bank-account-id
|
|
||||||
(not= "38-3" (str company-id "-" bank-account-id))) ;; TODO - 38-3 got removed at some ponitn
|
|
||||||
[:bank-account/original-id (str company-id "-" bank-account-id)])
|
|
||||||
:check-number check-number
|
|
||||||
:memo memo
|
|
||||||
:date (coerce/to-date date)
|
|
||||||
:amount (double amount)
|
|
||||||
:paid-to paid-to
|
|
||||||
:pdf-data data
|
|
||||||
:status (keyword "payment-status" status)
|
|
||||||
:type (if type
|
|
||||||
(keyword "payment-type" type)
|
|
||||||
:payment-type/check)})]))))
|
|
||||||
|
|
||||||
(defn load-invoices-payments [invoices-checks]
|
|
||||||
(->> invoices-checks
|
|
||||||
(map
|
|
||||||
(fn [{:keys [id invoice-id check-id amount]}]
|
|
||||||
[(remove-nils #:invoice-payment {:original-id id
|
|
||||||
:payment [:payment/original-id check-id]
|
|
||||||
:invoice [:invoice/original-id invoice-id]
|
|
||||||
:amount (double amount)})]))))
|
|
||||||
|
|
||||||
(defn load-transactions [transactions]
|
|
||||||
(let [transactions (->> transactions
|
|
||||||
(map
|
|
||||||
(fn [{:keys [id amount description-original description-simple merchant-id merchant-name
|
|
||||||
date post-date type account-id status vendor-id company-id check-id check-number
|
|
||||||
bank-account-id]}]
|
|
||||||
(remove-nils #:transaction {:original-id id
|
|
||||||
:id id
|
|
||||||
:description-original description-original
|
|
||||||
:description-simple description-simple
|
|
||||||
:merchant-id merchant-id
|
|
||||||
:merchant-name merchant-name
|
|
||||||
:date (coerce/to-date date)
|
|
||||||
:post-date (coerce/to-date post-date)
|
|
||||||
:type type
|
|
||||||
:status status
|
|
||||||
:amount (double amount)
|
|
||||||
:account-id account-id
|
|
||||||
:check-number check-number
|
|
||||||
:vendor (when vendor-id [:vendor/original-id vendor-id])
|
|
||||||
:client (when company-id [:client/original-id company-id])
|
|
||||||
:payment (when check-id [:payment/original-id check-id])
|
|
||||||
:bank-account (when (and bank-account-id
|
|
||||||
(not= "38-3" (str company-id "-" bank-account-id)))
|
|
||||||
[:bank-account/original-id (str company-id "-" bank-account-id)])})))
|
|
||||||
(partition-all 10))]
|
|
||||||
(println "transactions: " (count transactions) "batches of 50")
|
|
||||||
transactions))
|
|
||||||
|
|
||||||
(defn load-users [users]
|
|
||||||
(->> users
|
|
||||||
(map
|
|
||||||
(fn [{:keys [id role provider-id provider companies name]}]
|
|
||||||
(remove-nils #:user {:original-id id
|
|
||||||
:name name
|
|
||||||
:role (keyword "user-role" role)
|
|
||||||
:provider-id provider-id
|
|
||||||
:provider provider
|
|
||||||
:clients (map (fn [c] [:client/original-id c]) companies)})))
|
|
||||||
))
|
|
||||||
|
|
||||||
(defn query-vendors []
|
(defn query-vendors []
|
||||||
(d/q '[:find (pull ?e [*])
|
(d/q '[:find (pull ?e [*])
|
||||||
@@ -746,28 +578,28 @@
|
|||||||
:where [?e :user/original-id]]
|
:where [?e :user/original-id]]
|
||||||
(d/db (d/connect uri))))
|
(d/db (d/connect uri))))
|
||||||
|
|
||||||
(defn migrate-vendors [conn]
|
(defn migrate-vendors [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn migrate-clients [conn]
|
(defn migrate-clients [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn migrate-invoices [conn]
|
(defn migrate-invoices [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn migrate-payments [conn]
|
(defn migrate-payments [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn migrate-invoices-payments [conn]
|
(defn migrate-invoices-payments [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn migrate-invoices-expense-accounts [conn]
|
(defn migrate-invoices-expense-accounts [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn migrate-transactions [conn]
|
(defn migrate-transactions [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn migrate-users [conn]
|
(defn migrate-users [_]
|
||||||
[[]])
|
[[]])
|
||||||
|
|
||||||
(defn merge-query [query-part-1 query-part-2]
|
(defn merge-query [query-part-1 query-part-2]
|
||||||
@@ -780,7 +612,7 @@
|
|||||||
(defn add-sorter-fields [q sort-map args]
|
(defn add-sorter-fields [q sort-map args]
|
||||||
(log/info "sort-map" (pr-str sort-map))
|
(log/info "sort-map" (pr-str sort-map))
|
||||||
(reduce
|
(reduce
|
||||||
(fn [q {:keys [sort-key asc]}]
|
(fn [q {:keys [sort-key]}]
|
||||||
(merge-query q
|
(merge-query q
|
||||||
{:query {:find [(symbol (str "?sort-" sort-key))]
|
{:query {:find [(symbol (str "?sort-" sort-key))]
|
||||||
:where (sort-map
|
:where (sort-map
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
(d/db conn )
|
(d/db conn )
|
||||||
vendor-id)))
|
vendor-id)))
|
||||||
|
|
||||||
(defn get-account-by-numeric-code-and-sets [numeric-code sets]
|
(defn get-account-by-numeric-code-and-sets [numeric-code _]
|
||||||
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
(let [query (cond-> {:query {:find ['(pull ?e [* {:account/type [:db/ident :db/id]}])]
|
||||||
:in ['$ '?numeric-code]
|
:in ['$ '?numeric-code]
|
||||||
:where ['[?e :account/numeric-code ?numeric-code]]}
|
:where ['[?e :account/numeric-code ?numeric-code]]}
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
true (apply-pagination args))))
|
true (apply-pagination args))))
|
||||||
|
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db default-read ids)
|
(let [results (->> (d/pull-many db default-read ids)
|
||||||
(group-by :db/id))
|
(group-by :db/id))
|
||||||
accounts (->> ids
|
accounts (->> ids
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
(ns auto-ap.datomic.bank-accounts
|
(ns auto-ap.datomic.bank-accounts
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.datomic :refer [uri]]
|
[auto-ap.datomic :refer [uri]]
|
||||||
[clj-time.coerce :as c]
|
[datomic.api :as d]))
|
||||||
[clojure.set :refer [rename-keys]]))
|
|
||||||
|
|
||||||
(defn add-arg [query name value where & rest]
|
(defn add-arg [query name value where & rest]
|
||||||
(let [query (-> query
|
(let [query (-> query
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
(ns auto-ap.datomic.clients
|
(ns auto-ap.datomic.clients
|
||||||
(:require [auto-ap.datomic :refer [conn uri]]
|
(:require
|
||||||
[clj-time.coerce :as coerce]
|
[auto-ap.datomic :refer [conn uri]]
|
||||||
[clojure.tools.logging :as log]
|
[clj-time.coerce :as coerce]
|
||||||
[datomic.api :as d]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(defn cleanse [e]
|
(defn cleanse [e]
|
||||||
(-> e
|
(-> e
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
(ns auto-ap.datomic.expected-deposit
|
(ns auto-ap.datomic.expected-deposit
|
||||||
(:require [auto-ap.datomic :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query conn]]
|
(:require
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
[auto-ap.datomic
|
||||||
[clj-time.coerce :as c]
|
:refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query]]
|
||||||
[datomic.api :as d]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[clj-time.core :as t]))
|
[clj-time.coerce :as c]
|
||||||
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(defn <-datomic [result]
|
(defn <-datomic [result]
|
||||||
(let [transaction (first (:transaction/_expected-deposit result))
|
(let [transaction (first (:transaction/_expected-deposit result))
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
(ns auto-ap.datomic.invoices
|
(ns auto-ap.datomic.invoices
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.datomic :refer [uri merge-query apply-pagination apply-sort-3 add-sorter-fields conn]]
|
[auto-ap.datomic
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
:refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query uri]]
|
||||||
[clojure.set :refer [rename-keys]]
|
[auto-ap.datomic.accounts :as d-accounts]
|
||||||
[clj-time.coerce :as coerce]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
[auto-ap.time-utils :refer [next-dom]]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[clj-time.core :as time]
|
[auto-ap.time-utils :refer [next-dom]]
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[clj-time.coerce :as coerce]
|
||||||
[clojure.tools.logging :as log]
|
[clj-time.core :as time]
|
||||||
[auto-ap.datomic.accounts :as d-accounts]))
|
[clojure.set :refer [rename-keys]]
|
||||||
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(def default-read '[*
|
(def default-read '[*
|
||||||
{:invoice/client [:client/name :db/id :client/locations :client/code]}
|
{:invoice/client [:client/name :db/id :client/locations :client/code]}
|
||||||
@@ -41,7 +42,7 @@
|
|||||||
(->> (cond-> {:query {:find []
|
(->> (cond-> {:query {:find []
|
||||||
:in ['$]
|
:in ['$]
|
||||||
:where ['[?e :invoice/client]]}
|
:where ['[?e :invoice/client]]}
|
||||||
:args [(d/db (d/connect uri))]}
|
:args [db]}
|
||||||
|
|
||||||
(:exact-match-id args)
|
(:exact-match-id args)
|
||||||
(merge-query {:query {:in ['?e]
|
(merge-query {:query {:in ['?e]
|
||||||
@@ -162,7 +163,7 @@
|
|||||||
(apply-pagination args))))
|
(apply-pagination args))))
|
||||||
|
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db default-read ids)
|
(let [results (->> (d/pull-many db default-read ids)
|
||||||
(group-by :db/id))
|
(group-by :db/id))
|
||||||
|
|
||||||
@@ -218,10 +219,6 @@
|
|||||||
(d/pull default-read id)
|
(d/pull default-read id)
|
||||||
(<-datomic)))
|
(<-datomic)))
|
||||||
|
|
||||||
(defn update [update]
|
|
||||||
@(d/transact (d/connect uri) [update])
|
|
||||||
(get-by-id (:db/id update) ))
|
|
||||||
|
|
||||||
(defn get-multi [ids]
|
(defn get-multi [ids]
|
||||||
(map <-datomic
|
(map <-datomic
|
||||||
(-> (d/db (d/connect uri))
|
(-> (d/db (d/connect uri))
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
[filename]
|
[filename]
|
||||||
(-> (io/resource filename) (io/reader) (Util/readAll)))
|
(-> (io/resource filename) (io/reader) (Util/readAll)))
|
||||||
|
|
||||||
(defn functions [conn]
|
(defn functions [_]
|
||||||
[[{:db/ident :pay
|
[[{:db/ident :pay
|
||||||
:db/doc "Data function that increments value of attribute a by amount."
|
:db/doc "Data function that increments value of attribute a by amount."
|
||||||
:db/fn (d/function '{:lang "clojure"
|
:db/fn (d/function '{:lang "clojure"
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
:code [[:db/add e a
|
:code [[:db/add e a
|
||||||
(-> (d/entity db e) a (+ amount))]] })}]] )
|
(-> (d/entity db e) a (+ amount))]] })}]] )
|
||||||
|
|
||||||
(defn fix-pay-function [conn]
|
(defn fix-pay-function [_]
|
||||||
[[{:db/ident :pay
|
[[{:db/ident :pay
|
||||||
:db/doc "Data function that increments value of attribute a by amount."
|
:db/doc "Data function that increments value of attribute a by amount."
|
||||||
:db/fn (d/function '{:lang "clojure"
|
:db/fn (d/function '{:lang "clojure"
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
:db/valueType :db.type/string
|
:db/valueType :db.type/string
|
||||||
:db/cardinality :db.cardinality/one}]])
|
:db/cardinality :db.cardinality/one}]])
|
||||||
|
|
||||||
(defn reset-function [conn]
|
(defn reset-function [_]
|
||||||
[[{:db/ident :reset
|
[[{:db/ident :reset
|
||||||
:db/doc "Resets a relationship to the values specified "
|
:db/doc "Resets a relationship to the values specified "
|
||||||
:db/fn (d/function '{:lang "clojure"
|
:db/fn (d/function '{:lang "clojure"
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
a vs})))})}]])
|
a vs})))})}]])
|
||||||
|
|
||||||
|
|
||||||
(defn propose-invoice-fn [conn]
|
(defn propose-invoice-fn [_]
|
||||||
[[{:db/ident :propose-invoice
|
[[{:db/ident :propose-invoice
|
||||||
:db/doc "Adds an invoice if it's not found"
|
:db/doc "Adds an invoice if it's not found"
|
||||||
:db/fn (d/function '{:lang "clojure"
|
:db/fn (d/function '{:lang "clojure"
|
||||||
@@ -204,10 +204,8 @@
|
|||||||
:requires [:auto-ap/add-import-status]}
|
:requires [:auto-ap/add-import-status]}
|
||||||
:auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers
|
:auto-ap/fix-check-numbers {:txes-fn 'auto-ap.datomic.migrate.check-numbers/fix-check-numbers
|
||||||
:requires [:auto-ap/add-import-status-existing-invoices]}
|
: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]}
|
|
||||||
:auto-ap/add-account-visibility-fields {:txes-fn 'auto-ap.datomic.migrate.account-sorting/add-account-visibility-fields
|
:auto-ap/add-account-visibility-fields {:txes-fn 'auto-ap.datomic.migrate.account-sorting/add-account-visibility-fields
|
||||||
:requires [:auto-ap/add-new-vendors]}
|
:requires [:auto-ap/fix-check-numbers]}
|
||||||
:auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible
|
:auto-ap/make-every-account-visible {:txes-fn 'auto-ap.datomic.migrate.account-sorting/make-every-account-visible
|
||||||
:requires [:auto-ap/add-account-visibility-fields]}
|
:requires [:auto-ap/add-account-visibility-fields]}
|
||||||
:auto-ap/add-general-ledger6 {:txes add-general-ledger/add-general-ledger
|
:auto-ap/add-general-ledger6 {:txes add-general-ledger/add-general-ledger
|
||||||
@@ -542,7 +540,7 @@
|
|||||||
(d/release conn))
|
(d/release conn))
|
||||||
(println "Done")))
|
(println "Done")))
|
||||||
|
|
||||||
(defn -main [& args]
|
(defn -main [& _]
|
||||||
(mount/start (mount/only #{#'conn}))
|
(mount/start (mount/only #{#'conn}))
|
||||||
(migrate conn)
|
(migrate conn)
|
||||||
(mount/stop))
|
(mount/stop))
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
(:require [datomic.api :as d]))
|
(:require [datomic.api :as d]))
|
||||||
|
|
||||||
|
|
||||||
(defn add-account-visibility-fields [conn]
|
(defn add-account-visibility-fields [_]
|
||||||
[[
|
[[
|
||||||
{:db/ident :bank-account/visible
|
{:db/ident :bank-account/visible
|
||||||
:db/valueType :db.type/boolean
|
:db/valueType :db.type/boolean
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
(ns auto-ap.datomic.migrate.add-bank-account-codes
|
(ns auto-ap.datomic.migrate.add-bank-account-codes
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.datomic :refer [uri]]
|
[clojure.string :as str]
|
||||||
[clojure.string :as str]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(defn add-bank-account-codes-schema [conn]
|
(defn add-bank-account-codes-schema [_]
|
||||||
[[{:db/ident :bank-account/code
|
[[{:db/ident :bank-account/code
|
||||||
:db/valueType :db.type/string
|
:db/valueType :db.type/string
|
||||||
:db/unique :db.unique/identity
|
:db/unique :db.unique/identity
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
(ns auto-ap.datomic.migrate.add-client-codes
|
(ns auto-ap.datomic.migrate.add-client-codes
|
||||||
(:require [auto-ap.datomic :refer [uri]]
|
(:require
|
||||||
[datomic.api :as d]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(def name->code
|
(def name->code
|
||||||
(->>
|
(->>
|
||||||
[["Moscini Pizza Inc" "MPI"]
|
[["Moscini Pizza Inc" "MPI"]
|
||||||
|
|||||||
@@ -1,28 +1,3 @@
|
|||||||
(ns auto-ap.datomic.migrate.add-new-vendors
|
(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
|
|
||||||
))
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
|
|
||||||
(defn fix-check-numbers [conn]
|
(defn fix-check-numbers [conn]
|
||||||
(let [max-check-numbers (d/query {:query {:find '[?e ?check-number (max ?d)] :in ['$] :where ['[?e :bank-account/check-number ?check-number] '[?c :payment/bank-account ?e] '[?c :payment/check-number ?d]]} :args [(d/db conn)]})]
|
(let [max-check-numbers (d/query {:query {:find '[?e ?check-number (max ?d)] :in ['$] :where ['[?e :bank-account/check-number ?check-number] '[?c :payment/bank-account ?e] '[?c :payment/check-number ?d]]} :args [(d/db conn)]})]
|
||||||
[(for [[bank-account check-number max-check client] max-check-numbers
|
[(for [[bank-account check-number max-check _] max-check-numbers
|
||||||
:when (>= max-check check-number)]
|
:when (>= max-check check-number)]
|
||||||
{:db/id bank-account :payment/check-number (inc max-check)})]))
|
{:db/id bank-account :payment/check-number (inc max-check)})]))
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
:location-match/matches ["campbell brewing company"]}]}]]
|
:location-match/matches ["campbell brewing company"]}]}]]
|
||||||
[[]]))
|
[[]]))
|
||||||
|
|
||||||
(defn add-default-location [conn]
|
(defn add-default-location [_]
|
||||||
[[{:db/ident :client/default-location
|
[[{:db/ident :client/default-location
|
||||||
:db/valueType :db.type/string
|
:db/valueType :db.type/string
|
||||||
:db/cardinality :db.cardinality/one
|
:db/cardinality :db.cardinality/one
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(defn rename-codes-1 [conn]
|
(defn rename-codes-1 [_]
|
||||||
(let [result (apply concat [(rename "WE" "WME" (d/connect uri))
|
(let [result (apply concat [(rename "WE" "WME" (d/connect uri))
|
||||||
(rename "HM" "HIM" (d/connect uri))
|
(rename "HM" "HIM" (d/connect uri))
|
||||||
(rename "BES" "SBE" (d/connect uri))
|
(rename "BES" "SBE" (d/connect uri))
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
(ns auto-ap.datomic.sales-orders
|
(ns auto-ap.datomic.sales-orders
|
||||||
(:require [auto-ap.datomic :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query uri]]
|
(:require [auto-ap.datomic :refer [add-sorter-fields apply-pagination apply-sort-3 merge-query uri]]
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[auto-ap.utils :refer [dollars=]]
|
|
||||||
[clj-time.coerce :as c]
|
[clj-time.coerce :as c]
|
||||||
[datomic.api :as d]
|
[datomic.api :as d]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
@@ -98,7 +97,7 @@
|
|||||||
true (apply-sort-3 (assoc args :default-asc? false))
|
true (apply-sort-3 (assoc args :default-asc? false))
|
||||||
true (apply-pagination args))))
|
true (apply-pagination args))))
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db default-read ids)
|
(let [results (->> (d/pull-many db default-read ids)
|
||||||
(group-by :db/id))
|
(group-by :db/id))
|
||||||
payments (->> ids
|
payments (->> ids
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
(ns auto-ap.datomic.transaction-rules
|
(ns auto-ap.datomic.transaction-rules
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields]]
|
[auto-ap.datomic
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
:refer [add-sorter-fields apply-pagination apply-sort-3 merge-query uri]]
|
||||||
[clojure.set :refer [rename-keys]]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[clj-time.coerce :as c]
|
[clojure.string :as str]
|
||||||
[clojure.string :as str]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(defn <-datomic [result]
|
(defn <-datomic [result]
|
||||||
result)
|
result)
|
||||||
@@ -76,7 +76,7 @@
|
|||||||
true (apply-sort-3 args)
|
true (apply-sort-3 args)
|
||||||
true (apply-pagination args))))
|
true (apply-pagination args))))
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db default-read ids)
|
(let [results (->> (d/pull-many db default-read ids)
|
||||||
(group-by :db/id))
|
(group-by :db/id))
|
||||||
transaction-rules (->> ids
|
transaction-rules (->> ids
|
||||||
|
|||||||
@@ -1,26 +1,16 @@
|
|||||||
(ns auto-ap.datomic.transactions
|
(ns auto-ap.datomic.transactions
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields conn]]
|
[auto-ap.datomic
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
:refer [add-sorter-fields apply-pagination apply-sort-3 conn merge-query uri]]
|
||||||
[clj-time.coerce :as c]
|
[auto-ap.datomic.accounts :as d-accounts]
|
||||||
[clj-time.coerce :as coerce]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[clojure.tools.logging :as log]
|
[clj-time.coerce :as coerce]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[auto-ap.datomic.accounts :as d-accounts]))
|
[clojure.tools.logging :as log]
|
||||||
|
[datomic.api :as d]))
|
||||||
(defn sort-fn [sort-by]
|
|
||||||
(cond
|
|
||||||
(= "client" sort-by)
|
|
||||||
#(-> % :transaction/client :client/name)
|
|
||||||
|
|
||||||
(= "account" sort-by)
|
|
||||||
#(vector (-> % :transaction/account :account/name) (-> % :db/id))
|
|
||||||
|
|
||||||
:else
|
|
||||||
(keyword "transaction" sort-by)))
|
|
||||||
|
|
||||||
(defn potential-duplicate-ids [db args]
|
(defn potential-duplicate-ids [db args]
|
||||||
(if (and (:potential-duplicates args)
|
(when (and (:potential-duplicates args)
|
||||||
(:bank-account-id args))
|
(:bank-account-id args))
|
||||||
(->> (d/q '[:find ?tx ?amount ?date
|
(->> (d/q '[:find ?tx ?amount ?date
|
||||||
:in $ ?ba
|
:in $ ?ba
|
||||||
@@ -31,9 +21,9 @@
|
|||||||
(not [?tx :transaction/approval-status :transaction-approval-status/suppressed])]
|
(not [?tx :transaction/approval-status :transaction-approval-status/suppressed])]
|
||||||
db
|
db
|
||||||
(:bank-account-id args))
|
(:bank-account-id args))
|
||||||
(group-by (fn [[tx amount date]]
|
(group-by (fn [[_ amount date]]
|
||||||
[amount date]))
|
[amount date]))
|
||||||
(filter (fn [[g txes]]
|
(filter (fn [[_ txes]]
|
||||||
(> (count txes) 1)))
|
(> (count txes) 1)))
|
||||||
|
|
||||||
(vals)
|
(vals)
|
||||||
@@ -183,7 +173,7 @@
|
|||||||
true (apply-sort-3 (assoc args :default-asc? false))
|
true (apply-sort-3 (assoc args :default-asc? false))
|
||||||
true (apply-pagination args)))))
|
true (apply-pagination args)))))
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
(let [results (->> (d/pull-many db '[* {:transaction/client [:client/name :db/id :client/code]
|
||||||
:transaction/approval-status [:db/ident :db/id]
|
:transaction/approval-status [:db/ident :db/id]
|
||||||
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id :bank-account/locations :bank-account/current-balance]
|
:transaction/bank-account [:bank-account/name :bank-account/code :bank-account/yodlee-account-id :db/id :bank-account/locations :bank-account/current-balance]
|
||||||
@@ -201,8 +191,8 @@
|
|||||||
{:account-client-override/client [:db/id]}]}]}]
|
{:account-client-override/client [:db/id]}]}]}]
|
||||||
:transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]}]
|
:transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]}]
|
||||||
ids)
|
ids)
|
||||||
(map #(update % :transaction/date c/from-date))
|
(map #(update % :transaction/date coerce/from-date))
|
||||||
(map #(update % :transaction/post-date c/from-date))
|
(map #(update % :transaction/post-date coerce/from-date))
|
||||||
(map #(update % :transaction/accounts
|
(map #(update % :transaction/accounts
|
||||||
(fn [tas]
|
(fn [tas]
|
||||||
(map
|
(map
|
||||||
@@ -211,8 +201,8 @@
|
|||||||
tas))))
|
tas))))
|
||||||
(map (fn [transaction]
|
(map (fn [transaction]
|
||||||
(cond-> transaction
|
(cond-> transaction
|
||||||
(:transaction/payment transaction) (update-in [:transaction/payment :payment/date] c/from-date)
|
(:transaction/payment transaction) (update-in [:transaction/payment :payment/date] coerce/from-date)
|
||||||
(:transaction/expected-deposit transaction) (update-in [:transaction/expected-deposit :expected-deposit/date] c/from-date))
|
(:transaction/expected-deposit transaction) (update-in [:transaction/expected-deposit :expected-deposit/date] coerce/from-date))
|
||||||
))
|
))
|
||||||
(map #(dissoc % :transaction/id))
|
(map #(dissoc % :transaction/id))
|
||||||
(group-by :db/id))]
|
(group-by :db/id))]
|
||||||
@@ -257,7 +247,7 @@
|
|||||||
{:account-client-override/client [:db/id]}]}]}]
|
{:account-client-override/client [:db/id]}]}]}]
|
||||||
:transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]}]
|
:transaction/yodlee-merchant [:db/id :yodlee-merchant/yodlee-id :yodlee-merchant/name]}]
|
||||||
id)
|
id)
|
||||||
(update :transaction/date c/from-date)
|
(update :transaction/date coerce/from-date)
|
||||||
(update :transaction/post-date c/from-date)
|
(update :transaction/post-date coerce/from-date)
|
||||||
(dissoc :transaction/id)))
|
(dissoc :transaction/id)))
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
(ns auto-ap.datomic.users
|
(ns auto-ap.datomic.users
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.datomic :refer [uri]]
|
[auto-ap.datomic :refer [uri]]
|
||||||
[clojure.set :refer [rename-keys]]
|
[datomic.api :as d]))
|
||||||
[clj-time.coerce :as c]))
|
|
||||||
|
|
||||||
(defn add-arg [query name value where & rest]
|
(defn add-arg [query name value where & rest]
|
||||||
(let [query (-> query
|
(let [query (-> query
|
||||||
@@ -48,7 +47,7 @@
|
|||||||
is-first-user? (assoc :user/role :user-role/admin))])]
|
is-first-user? (assoc :user/role :user-role/admin))])]
|
||||||
(get-by-id (-> new-user-trans :tempids (get "user")))))))
|
(get-by-id (-> new-user-trans :tempids (get "user")))))))
|
||||||
|
|
||||||
(defn raw-graphql [args]
|
(defn raw-graphql [_]
|
||||||
(let [query (cond-> {:query {:find ['(pull ?e [*
|
(let [query (cond-> {:query {:find ['(pull ?e [*
|
||||||
{:user/clients [*]}
|
{:user/clients [*]}
|
||||||
{:user/role [:db/ident]}])]
|
{:user/role [:db/ident]}])]
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
(ns auto-ap.datomic.yodlee2
|
(ns auto-ap.datomic.yodlee2
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.datomic :refer [uri remove-nils merge-query apply-pagination apply-sort-3 add-sorter-fields conn]]
|
[auto-ap.datomic
|
||||||
[auto-ap.graphql.utils :refer [limited-clients]]
|
:refer [add-sorter-fields apply-pagination apply-sort-3 merge-query uri]]
|
||||||
[auto-ap.parse :as parse]
|
[auto-ap.graphql.utils :refer [limited-clients]]
|
||||||
[clj-time.coerce :as c]
|
[clj-time.coerce :as c]
|
||||||
[clojure.set :refer [rename-keys]]
|
[datomic.api :as d]))
|
||||||
[clojure.string :as str]
|
|
||||||
[clojure.tools.logging :as log]))
|
|
||||||
|
|
||||||
(def default-read '[*])
|
(def default-read '[*])
|
||||||
|
|
||||||
@@ -17,8 +15,8 @@
|
|||||||
(->> (cond-> {:query {:find []
|
(->> (cond-> {:query {:find []
|
||||||
:in ['$]
|
:in ['$]
|
||||||
:where ['[?e :yodlee-provider-account/id]]}
|
:where ['[?e :yodlee-provider-account/id]]}
|
||||||
:args [(d/db (d/connect uri))]}
|
:args [db]}
|
||||||
|
|
||||||
(limited-clients (:id args))
|
(limited-clients (:id args))
|
||||||
(merge-query {:query {:in ['[?xx ...]]
|
(merge-query {:query {:in ['[?xx ...]]
|
||||||
:where ['[?e :yodlee-provider-account/client ?xx]]}
|
:where ['[?e :yodlee-provider-account/client ?xx]]}
|
||||||
@@ -40,14 +38,13 @@
|
|||||||
true
|
true
|
||||||
(merge-query {:query {:find ['?e ]
|
(merge-query {:query {:find ['?e ]
|
||||||
:where ['[?e :yodlee-provider-account/id]]}}) )
|
:where ['[?e :yodlee-provider-account/id]]}}) )
|
||||||
|
|
||||||
|
|
||||||
(d/query)
|
(d/query)
|
||||||
(apply-sort-3 args)
|
(apply-sort-3 args)
|
||||||
(apply-pagination args)))
|
(apply-pagination args)))
|
||||||
|
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db default-read ids)
|
(let [results (->> (d/pull-many db default-read ids)
|
||||||
(group-by :db/id))]
|
(group-by :db/id))]
|
||||||
(->> ids
|
(->> ids
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
(ns auto-ap.datomic.yodlee-merchants
|
(ns auto-ap.datomic.yodlee-merchants
|
||||||
(:require [datomic.api :as d]
|
(:require
|
||||||
[auto-ap.graphql.utils :refer [->graphql]]
|
[auto-ap.datomic :refer [uri]]
|
||||||
[auto-ap.datomic :refer [uri merge-query]]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(defn get-merchants [args]
|
(defn get-merchants [_]
|
||||||
;; TODO admin?
|
;; TODO admin?
|
||||||
(let [query {:query {:find ['(pull ?e [:yodlee-merchant/name :yodlee-merchant/yodlee-id :db/id])]
|
(let [query {:query {:find ['(pull ?e [:yodlee-merchant/name :yodlee-merchant/yodlee-id :db/id])]
|
||||||
:in ['$]
|
:in ['$]
|
||||||
|
|||||||
@@ -1,28 +1,27 @@
|
|||||||
(ns auto-ap.graphql
|
(ns auto-ap.graphql
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic :refer [merge-query uri]]
|
[auto-ap.datomic :refer [merge-query uri]]
|
||||||
[auto-ap.datomic.checks :as d-checks]
|
|
||||||
[auto-ap.datomic.users :as d-users]
|
[auto-ap.datomic.users :as d-users]
|
||||||
[auto-ap.graphql.accounts :as gq-accounts]
|
[auto-ap.graphql.accounts :as gq-accounts]
|
||||||
[auto-ap.graphql.checks :as gq-checks]
|
[auto-ap.graphql.checks :as gq-checks]
|
||||||
[auto-ap.graphql.ezcater :as gq-ezcater]
|
|
||||||
[auto-ap.graphql.clients :as gq-clients]
|
[auto-ap.graphql.clients :as gq-clients]
|
||||||
[auto-ap.graphql.expected-deposit :as gq-expected-deposit]
|
[auto-ap.graphql.expected-deposit :as gq-expected-deposit]
|
||||||
|
[auto-ap.graphql.ezcater :as gq-ezcater]
|
||||||
[auto-ap.graphql.import-batch :as gq-import-batches]
|
[auto-ap.graphql.import-batch :as gq-import-batches]
|
||||||
[auto-ap.graphql.intuit-bank-accounts :as gq-intuit-bank-accounts]
|
[auto-ap.graphql.intuit-bank-accounts :as gq-intuit-bank-accounts]
|
||||||
[auto-ap.graphql.reports :as gq-reports]
|
|
||||||
[auto-ap.graphql.invoices :as gq-invoices]
|
[auto-ap.graphql.invoices :as gq-invoices]
|
||||||
[auto-ap.graphql.ledger :as gq-ledger]
|
[auto-ap.graphql.ledger :as gq-ledger]
|
||||||
|
[auto-ap.graphql.plaid :as gq-plaid]
|
||||||
|
[auto-ap.graphql.reports :as gq-reports]
|
||||||
[auto-ap.graphql.requests :as gq-requests]
|
[auto-ap.graphql.requests :as gq-requests]
|
||||||
[auto-ap.graphql.sales-orders :as gq-sales-orders]
|
[auto-ap.graphql.sales-orders :as gq-sales-orders]
|
||||||
[auto-ap.graphql.transaction-rules :as gq-transaction-rules]
|
[auto-ap.graphql.transaction-rules :as gq-transaction-rules]
|
||||||
[auto-ap.graphql.transactions :as gq-transactions]
|
[auto-ap.graphql.transactions :as gq-transactions]
|
||||||
[auto-ap.graphql.users :as gq-users]
|
[auto-ap.graphql.users :as gq-users]
|
||||||
[auto-ap.graphql.utils :refer [assert-admin assert-can-see-client]]
|
[auto-ap.graphql.utils :refer [assert-admin]]
|
||||||
[auto-ap.graphql.vendors :as gq-vendors]
|
[auto-ap.graphql.vendors :as gq-vendors]
|
||||||
[auto-ap.graphql.yodlee-merchants :as ym]
|
[auto-ap.graphql.yodlee-merchants :as ym]
|
||||||
[auto-ap.graphql.yodlee2 :as gq-yodlee2]
|
[auto-ap.graphql.yodlee2 :as gq-yodlee2]
|
||||||
[auto-ap.graphql.plaid :as gq-plaid]
|
|
||||||
[auto-ap.logging :refer [error-event info-event warn-event]]
|
[auto-ap.logging :refer [error-event info-event warn-event]]
|
||||||
[auto-ap.time :as time]
|
[auto-ap.time :as time]
|
||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
@@ -30,14 +29,14 @@
|
|||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[clojure.walk :as walk]
|
[clojure.walk :as walk]
|
||||||
|
[com.unbounce.dogstatsd.core :as statsd]
|
||||||
[com.walmartlabs.lacinia :refer [execute]]
|
[com.walmartlabs.lacinia :refer [execute]]
|
||||||
|
[com.walmartlabs.lacinia.parser :as p]
|
||||||
[com.walmartlabs.lacinia.schema :as schema]
|
[com.walmartlabs.lacinia.schema :as schema]
|
||||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||||
[datomic.api :as d]
|
[datomic.api :as d]
|
||||||
[unilog.context :as lc]
|
[unilog.context :as lc]
|
||||||
[yang.time :refer [time-it]]
|
[yang.time :refer [time-it]])
|
||||||
[com.unbounce.dogstatsd.core :as statsd]
|
|
||||||
[com.walmartlabs.lacinia.parser :as p])
|
|
||||||
(:import
|
(:import
|
||||||
(clojure.lang IPersistentMap)))
|
(clojure.lang IPersistentMap)))
|
||||||
|
|
||||||
@@ -609,7 +608,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn get-user [context args value]
|
(defn get-user [context args _]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
|
|
||||||
(let [users (d-users/get-graphql args)]
|
(let [users (d-users/get-graphql args)]
|
||||||
@@ -619,7 +618,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn get-expense-account-stats [context {:keys [client_id] } value]
|
(defn get-expense-account-stats [_ {:keys [client_id] } _]
|
||||||
(let [result (cond-> {:query {:find ['?account '?account-name '(sum ?amount)]
|
(let [result (cond-> {:query {:find ['?account '?account-name '(sum ?amount)]
|
||||||
:in ['$]
|
:in ['$]
|
||||||
:where []}
|
:where []}
|
||||||
@@ -645,7 +644,7 @@
|
|||||||
(<= x 60 ) :due-60
|
(<= x 60 ) :due-60
|
||||||
:else :due-later))
|
:else :due-later))
|
||||||
|
|
||||||
(defn get-invoice-stats [context {:keys [client_id] } value]
|
(defn get-invoice-stats [_ {:keys [client_id] } _]
|
||||||
(let [result (cond-> {:query {:find ['?name '(sum ?outstanding-balance) '(sum ?total)]
|
(let [result (cond-> {:query {:find ['?name '(sum ?outstanding-balance) '(sum ?total)]
|
||||||
:in ['$]
|
:in ['$]
|
||||||
:where []}
|
:where []}
|
||||||
@@ -687,7 +686,7 @@
|
|||||||
|
|
||||||
(def first-week-a (coerce/to-date-time #inst "1999-12-27T00:00:00.000-07:00"))
|
(def first-week-a (coerce/to-date-time #inst "1999-12-27T00:00:00.000-07:00"))
|
||||||
|
|
||||||
(defn get-cash-flow [context {:keys [client_id]} value]
|
(defn get-cash-flow [_ {:keys [client_id]} _]
|
||||||
(when client_id
|
(when client_id
|
||||||
(let [{:client/keys [week-a-credits week-a-debits week-b-credits week-b-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id)
|
(let [{:client/keys [week-a-credits week-a-debits week-b-credits week-b-debits forecasted-transactions ]} (d/pull (d/db (d/connect uri)) '[*] client_id)
|
||||||
total-cash (reduce
|
total-cash (reduce
|
||||||
@@ -841,7 +840,7 @@
|
|||||||
(defn query-name [q]
|
(defn query-name [q]
|
||||||
(try
|
(try
|
||||||
(str/join "__" (map name (:operations (p/operations (p/parse-query schema q)))))
|
(str/join "__" (map name (:operations (p/operations (p/parse-query schema q)))))
|
||||||
(catch Exception e
|
(catch Exception _
|
||||||
"unknown query")))
|
"unknown query")))
|
||||||
|
|
||||||
(defn query
|
(defn query
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
(defn get-all-graphql [context args _]
|
(defn get-all-graphql [context args _]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[accounts accounts-count ] (d-accounts/get-graphql (assoc (<-graphql args) :per-page Integer/MAX_VALUE))]
|
[accounts _ ] (d-accounts/get-graphql (assoc (<-graphql args) :per-page Integer/MAX_VALUE))]
|
||||||
(map ->graphql accounts)))
|
(map ->graphql accounts)))
|
||||||
|
|
||||||
(defn default-for-vendor [context args _]
|
(defn default-for-vendor [context args _]
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
[auto-ap.datomic.transactions :as d-transactions]
|
[auto-ap.datomic.transactions :as d-transactions]
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
[auto-ap.graphql.utils
|
[auto-ap.graphql.utils
|
||||||
:refer [->graphql <-graphql assert-admin assert-failure assert-can-see-client enum->keyword assert-not-locked assert-none-locked]]
|
:refer [->graphql <-graphql assert-admin assert-failure assert-can-see-client enum->keyword assert-not-locked]]
|
||||||
[auto-ap.numeric :refer [num->words]]
|
[auto-ap.numeric :refer [num->words]]
|
||||||
[auto-ap.time :refer [iso-date local-now parse]]
|
[auto-ap.time :refer [iso-date local-now parse]]
|
||||||
[auto-ap.utils :refer [by dollars-0?]]
|
[auto-ap.utils :refer [by dollars-0?]]
|
||||||
@@ -296,7 +296,7 @@
|
|||||||
(into (invoice-payments invoices invoice-amounts)))))
|
(into (invoice-payments invoices invoice-amounts)))))
|
||||||
|
|
||||||
|
|
||||||
(defmethod invoices->entities :payment-type/balance-credit [invoices vendor client bank-account type index invoice-amounts]
|
(defmethod invoices->entities :payment-type/balance-credit [invoices invoice-amounts]
|
||||||
(when (<= (->> invoices
|
(when (<= (->> invoices
|
||||||
(map (comp invoice-amounts :db/id))
|
(map (comp invoice-amounts :db/id))
|
||||||
(reduce + 0.0))
|
(reduce + 0.0))
|
||||||
|
|||||||
@@ -3,23 +3,22 @@
|
|||||||
[auto-ap.datomic.expected-deposit :as d-expected-deposit]
|
[auto-ap.datomic.expected-deposit :as d-expected-deposit]
|
||||||
[auto-ap.graphql.utils
|
[auto-ap.graphql.utils
|
||||||
:refer [->graphql <-graphql assert-admin ident->enum-f result->page]]
|
:refer [->graphql <-graphql assert-admin ident->enum-f result->page]]
|
||||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]))
|
||||||
[clojure.tools.logging :as log]))
|
|
||||||
|
|
||||||
(def status->graphql (ident->enum-f :expected-deposit/status))
|
(def status->graphql (ident->enum-f :expected-deposit/status))
|
||||||
|
|
||||||
(defn get-expected-deposit [context args value]
|
(defn get-expected-deposit [context args _]
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[sales-orders sales-orders-count] (d-expected-deposit/get-graphql (<-graphql args))]
|
[sales-orders sales-orders-count] (d-expected-deposit/get-graphql (<-graphql args))]
|
||||||
(result->page sales-orders sales-orders-count :data args)))
|
(result->page sales-orders sales-orders-count :data args)))
|
||||||
|
|
||||||
(defn get-all-expected-deposits [context args value]
|
(defn get-all-expected-deposits [context args _]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
(map
|
(map
|
||||||
(comp ->graphql status->graphql)
|
(comp ->graphql status->graphql)
|
||||||
(first (d-expected-deposit/get-graphql (assoc (<-graphql args) :count Integer/MAX_VALUE)))))
|
(first (d-expected-deposit/get-graphql (assoc (<-graphql args) :count Integer/MAX_VALUE)))))
|
||||||
|
|
||||||
(defn get-expected-deposit-page [context args value]
|
(defn get-expected-deposit-page [context args _]
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[expected-deposits expected-deposit-count] (d-expected-deposit/get-graphql (<-graphql args))
|
[expected-deposits expected-deposit-count] (d-expected-deposit/get-graphql (<-graphql args))
|
||||||
expected-deposits (map status->graphql expected-deposits)]
|
expected-deposits (map status->graphql expected-deposits)]
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
(ns auto-ap.graphql.import-batch
|
(ns auto-ap.graphql.import-batch
|
||||||
(:require [auto-ap.datomic
|
(:require
|
||||||
|
[auto-ap.datomic
|
||||||
:refer
|
:refer
|
||||||
[add-sorter-fields apply-pagination apply-sort-3 conn merge-query]]
|
[add-sorter-fields apply-pagination apply-sort-3 conn merge-query]]
|
||||||
[auto-ap.graphql.utils
|
[auto-ap.graphql.utils
|
||||||
:refer
|
:refer
|
||||||
[<-graphql assert-admin ident->enum-f result->page]]
|
[<-graphql assert-admin ident->enum-f result->page]]
|
||||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
[clj-time.coerce :as coerce]
|
||||||
[datomic.api :as d]))
|
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||||
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(def default-read '[:db/id
|
(def default-read '[:db/id
|
||||||
:import-batch/external-id
|
:import-batch/external-id
|
||||||
@@ -37,7 +39,7 @@
|
|||||||
true (apply-sort-3 args)
|
true (apply-sort-3 args)
|
||||||
true (apply-pagination args))))
|
true (apply-pagination args))))
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db default-read ids)
|
(let [results (->> (d/pull-many db default-read ids)
|
||||||
(group-by :db/id))]
|
(group-by :db/id))]
|
||||||
(->> ids
|
(->> ids
|
||||||
@@ -50,14 +52,14 @@
|
|||||||
[(graphql-results ids-to-retrieve db args)
|
[(graphql-results ids-to-retrieve db args)
|
||||||
matching-count]))
|
matching-count]))
|
||||||
|
|
||||||
(defn get-import-batch-page [context args value]
|
(defn get-import-batch-page [context args _]
|
||||||
(let [_ (assert-admin (:id context))
|
(let [_ (assert-admin (:id context))
|
||||||
args (assoc (:filters args) :id (:id context))
|
args (assoc (:filters args) :id (:id context))
|
||||||
[values matching-count] (get-graphql (<-graphql args))]
|
[values matching-count] (get-graphql (<-graphql args))]
|
||||||
(result->page (->> values
|
(result->page (->> values
|
||||||
(map (ident->enum-f :import-batch/source))
|
(map (ident->enum-f :import-batch/source))
|
||||||
(map (ident->enum-f :import-batch/status))
|
(map (ident->enum-f :import-batch/status))
|
||||||
(map #(update % :import-batch/date clj-time.coerce/to-date-time)))
|
(map #(update % :import-batch/date coerce/to-date-time)))
|
||||||
matching-count :data args)))
|
matching-count :data args)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
(ns auto-ap.graphql.intuit-bank-accounts
|
(ns auto-ap.graphql.intuit-bank-accounts
|
||||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql assert-admin]]
|
(:require
|
||||||
[auto-ap.datomic :refer [conn]]
|
[auto-ap.datomic :refer [conn]]
|
||||||
[datomic.api :as d]))
|
[auto-ap.graphql.utils :refer [->graphql assert-admin]]
|
||||||
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(defn get-intuit-bank-accounts [context args value]
|
(defn get-intuit-bank-accounts [context _ _]
|
||||||
#_(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
(->graphql (map first (d/q '[:find (pull ?e [*])
|
(->graphql (map first (d/q '[:find (pull ?e [*])
|
||||||
:in $
|
:in $
|
||||||
:where [?e :intuit-bank-account/external-id]]
|
:where [?e :intuit-bank-account/external-id]]
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
(ns auto-ap.graphql.invoices
|
(ns auto-ap.graphql.invoices
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic
|
[auto-ap.datomic
|
||||||
:refer [audit-transact audit-transact-batch conn remove-nils uri]]
|
:refer [audit-transact conn remove-nils uri]]
|
||||||
[auto-ap.datomic.clients :as d-clients]
|
[auto-ap.datomic.clients :as d-clients]
|
||||||
[auto-ap.datomic.invoices :as d-invoices]
|
[auto-ap.datomic.invoices :as d-invoices]
|
||||||
[auto-ap.datomic.vendors :as d-vendors]
|
[auto-ap.datomic.vendors :as d-vendors]
|
||||||
[auto-ap.graphql.checks :as gq-checks]
|
[auto-ap.graphql.checks :as gq-checks]
|
||||||
[auto-ap.time :as atime]
|
|
||||||
[auto-ap.graphql.utils
|
[auto-ap.graphql.utils
|
||||||
:as u
|
:as u
|
||||||
:refer [<-graphql
|
:refer [<-graphql
|
||||||
|
|||||||
@@ -16,14 +16,14 @@
|
|||||||
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
[com.walmartlabs.lacinia.util :refer [attach-resolvers]]
|
||||||
[datomic.api :as d]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
(defn plaid-link-token [context value args]
|
(defn plaid-link-token [context value _]
|
||||||
(when-not (:client_id value)
|
(when-not (:client_id value)
|
||||||
(throw (ex-info "Client ID is required" {:validation-error "Client ID is required"})))
|
(throw (ex-info "Client ID is required" {:validation-error "Client ID is required"})))
|
||||||
(assert-can-see-client (:id context) (:client_id value))
|
(assert-can-see-client (:id context) (:client_id value))
|
||||||
(let [client-code (:client/code (d/pull (d/db conn) [:client/code] (:client_id value)))]
|
(let [client-code (:client/code (d/pull (d/db conn) [:client/code] (:client_id value)))]
|
||||||
{:token (p/get-link-token client-code)}))
|
{:token (p/get-link-token client-code)}))
|
||||||
|
|
||||||
(defn link-plaid [context value args]
|
(defn link-plaid [context value _]
|
||||||
(when-not (:client_code value)
|
(when-not (:client_code value)
|
||||||
(throw (ex-info "Client not provided" {:validation-error "Client not provided."})))
|
(throw (ex-info "Client not provided" {:validation-error "Client not provided."})))
|
||||||
(when-not (:public_token value)
|
(when-not (:public_token value)
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
true (apply-sort-3 args)
|
true (apply-sort-3 args)
|
||||||
true (apply-pagination args))))
|
true (apply-pagination args))))
|
||||||
|
|
||||||
(defn graphql-results [ids db args]
|
(defn graphql-results [ids db _]
|
||||||
(let [results (->> (d/pull-many db default-read ids)
|
(let [results (->> (d/pull-many db default-read ids)
|
||||||
(group-by :db/id))]
|
(group-by :db/id))]
|
||||||
(->> ids
|
(->> ids
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn get-plaid-item-page [context args value]
|
(defn get-plaid-item-page [context args _]
|
||||||
|
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[plaid-items cnt] (get-graphql (<-graphql (assoc args :id (:id context))))]
|
[plaid-items cnt] (get-graphql (<-graphql (assoc args :id (:id context))))]
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
:start (:start args 0)
|
:start (:start args 0)
|
||||||
:end (+ (:start args 0) (count plaid-items))}))
|
:end (+ (:start args 0) (count plaid-items))}))
|
||||||
|
|
||||||
(defn delete-plaid-item [context args value]
|
(defn delete-plaid-item [context args _]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
(assert-present args :id)
|
(assert-present args :id)
|
||||||
@(d/transact conn [[:db/retractEntity (:id args)]])
|
@(d/transact conn [[:db/retractEntity (:id args)]])
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
[auto-ap.graphql.utils :refer [assert-admin]]
|
[auto-ap.graphql.utils :refer [assert-admin]]
|
||||||
[config.core :refer [env]]))
|
[config.core :refer [env]]))
|
||||||
|
|
||||||
(defn request-import [context value args]
|
(defn request-import [context value _]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
(:message-id (sqs/send-message {:queue-url (:requests-queue-url env)
|
(:message-id (sqs/send-message {:queue-url (:requests-queue-url env)
|
||||||
:message-body (:which value)} )))
|
:message-body (:which value)} )))
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
[auto-ap.rule-matching :as rm]
|
[auto-ap.rule-matching :as rm]
|
||||||
[auto-ap.utils :refer [dollars=]]
|
[auto-ap.utils :refer [dollars=]]
|
||||||
[clj-time.coerce :as c]
|
[clj-time.coerce :as c]
|
||||||
[clojure.set :as set]
|
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[datomic.api :as d]))
|
[datomic.api :as d]))
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
:manager :user-role/manager
|
:manager :user-role/manager
|
||||||
:user :user-role/user})
|
:user :user-role/user})
|
||||||
|
|
||||||
(defn edit-user [context {:keys [edit_user] :as args} value]
|
(defn edit-user [context {:keys [edit_user]} _]
|
||||||
(assert-admin (:id context))
|
(assert-admin (:id context))
|
||||||
(let [user (d-users/get-by-id (:id edit_user))
|
(let [user (d-users/get-by-id (:id edit_user))
|
||||||
new-clients (set (map #(Long/parseLong %) (:clients edit_user)))
|
new-clients (set (map #(Long/parseLong %) (:clients edit_user)))
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
([args key]
|
([args key]
|
||||||
(assert-present args key (name key)))
|
(assert-present args key (name key)))
|
||||||
([args key name]
|
([args key name]
|
||||||
(if (not (get args key))
|
(when (not (get args key))
|
||||||
(throw (ex-info (str "Missing field '" name "'.")
|
(throw (ex-info (str "Missing field '" name "'.")
|
||||||
{:validation-error (str "Missing field '" name "'.")})))))
|
{:validation-error (str "Missing field '" name "'.")})))))
|
||||||
|
|
||||||
@@ -87,8 +87,7 @@
|
|||||||
|
|
||||||
(defn limited-clients [id]
|
(defn limited-clients [id]
|
||||||
(cond
|
(cond
|
||||||
(or
|
(= (:user/role id) "none")
|
||||||
(= (:user/role id) "none"))
|
|
||||||
[]
|
[]
|
||||||
|
|
||||||
(= (:user/role id) "admin")
|
(= (:user/role id) "admin")
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
enum->keyword
|
enum->keyword
|
||||||
is-admin?
|
is-admin?
|
||||||
result->page]]
|
result->page]]
|
||||||
[auto-ap.utils :refer [by]]
|
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
@@ -31,7 +30,7 @@
|
|||||||
vendor-id))
|
vendor-id))
|
||||||
(set (map :db/id (:user/clients id)))))))
|
(set (map :db/id (:user/clients id)))))))
|
||||||
|
|
||||||
(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule schedule_payment_dom terms_overrides account_overrides] :as in} :vendor} value]
|
(defn upsert-vendor [context {{:keys [id name hidden terms code print_as primary_contact secondary_contact address default_account_id invoice_reminder_schedule schedule_payment_dom terms_overrides account_overrides] :as in} :vendor} _]
|
||||||
(when (and id (not (can-user-edit-vendor? id (:id context))))
|
(when (and id (not (can-user-edit-vendor? id (:id context))))
|
||||||
(assert-failure "This vendor is managed by Integreat. Please reach out to ben@integreatconsult.com for your changes."))
|
(assert-failure "This vendor is managed by Integreat. Please reach out to ben@integreatconsult.com for your changes."))
|
||||||
|
|
||||||
@@ -145,7 +144,7 @@
|
|||||||
(->graphql))
|
(->graphql))
|
||||||
log/info)))
|
log/info)))
|
||||||
|
|
||||||
(defn merge-vendors [context {:keys [from to]} value]
|
(defn merge-vendors [context {:keys [from to]} _]
|
||||||
(let [transaction (->> (d/query {:query {:find '[?x ?a2]
|
(let [transaction (->> (d/query {:query {:find '[?x ?a2]
|
||||||
:in '[$ ?vendor-from ]
|
:in '[$ ?vendor-from ]
|
||||||
:where ['[?x ?a ?vendor-from]
|
:where ['[?x ?a ?vendor-from]
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
(ns auto-ap.graphql.yodlee2
|
(ns auto-ap.graphql.yodlee2
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.datomic.yodlee2 :as d-yodlee2]
|
[auto-ap.datomic.yodlee2 :as d-yodlee2]
|
||||||
[auto-ap.graphql.utils :refer [->graphql <-graphql assert-admin]]))
|
[auto-ap.graphql.utils :refer [->graphql <-graphql]]))
|
||||||
|
|
||||||
(defn get-yodlee-provider-account-page [context args value]
|
(defn get-yodlee-provider-account-page [context args _]
|
||||||
(let [args (assoc args :id (:id context))
|
(let [args (assoc args :id (:id context))
|
||||||
[yodlee-provider-accounts cnt] (d-yodlee2/get-graphql (<-graphql (assoc args :id (:id context))))]
|
[yodlee-provider-accounts cnt] (d-yodlee2/get-graphql (<-graphql (assoc args :id (:id context))))]
|
||||||
{:yodlee_provider_accounts (map ->graphql yodlee-provider-accounts)
|
{:yodlee_provider_accounts (map ->graphql yodlee-provider-accounts)
|
||||||
@@ -12,10 +12,3 @@
|
|||||||
:start (:start args 0)
|
:start (:start args 0)
|
||||||
:end (+ (:start args 0) (count yodlee-provider-accounts))}))
|
:end (+ (:start args 0) (count yodlee-provider-accounts))}))
|
||||||
|
|
||||||
(defn get-all-yodlee-provider-accounts [context args value]
|
|
||||||
(let [args (assoc args :id (:id context))]
|
|
||||||
(map
|
|
||||||
->graphql
|
|
||||||
(first (d-yodlee2/get-graphql (assoc (<-graphql args)
|
|
||||||
:count Integer/MAX_VALUE))))))
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql]]
|
(:require [auto-ap.graphql.utils :refer [->graphql <-graphql]]
|
||||||
[auto-ap.datomic.yodlee-merchants :as d-yodlee-merchants]))
|
[auto-ap.datomic.yodlee-merchants :as d-yodlee-merchants]))
|
||||||
|
|
||||||
(defn get-yodlee-merchants [context args value]
|
(defn get-yodlee-merchants [_ args _]
|
||||||
(->graphql (d-yodlee-merchants/get-merchants (<-graphql args))))
|
(->graphql (d-yodlee-merchants/get-merchants (<-graphql args))))
|
||||||
|
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
(ns auto-ap.import.manual
|
(ns auto-ap.import.manual
|
||||||
(:require [auto-ap.datomic :refer [conn]]
|
(:require
|
||||||
[auto-ap.import.manual.common :as c]
|
[auto-ap.datomic :refer [conn]]
|
||||||
[auto-ap.import.transactions :as t]
|
[auto-ap.import.manual.common :as c]
|
||||||
[clj-time.coerce :as coerce]
|
[auto-ap.import.transactions :as t]
|
||||||
[clojure.data.csv :as csv]
|
[clj-time.coerce :as coerce]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.data.csv :as csv]
|
||||||
[datomic.api :as d]
|
[datomic.api :as d]
|
||||||
[unilog.context :as lc]))
|
[unilog.context :as lc]))
|
||||||
|
|
||||||
|
|
||||||
(defn manual-import-batch [transactions user]
|
|
||||||
)
|
|
||||||
|
|
||||||
(def columns [:status :raw-date :description-original :high-level-category nil nil :amount nil nil nil nil nil :bank-account-code :client-code])
|
(def columns [:status :raw-date :description-original :high-level-category nil nil :amount nil nil nil nil nil :bank-account-code :client-code])
|
||||||
|
|
||||||
@@ -19,9 +18,9 @@
|
|||||||
(drop 1)
|
(drop 1)
|
||||||
(map (fn [row]
|
(map (fn [row]
|
||||||
(into {} (->> (map vector columns row)
|
(into {} (->> (map vector columns row)
|
||||||
(filter (fn [[k v]] k))))))))
|
(filter (fn [[k _]] k))))))))
|
||||||
|
|
||||||
(defn manual->transaction [{:keys [description-original amount bank-account-code date] :as transaction} bank-account-lookup client-lookup]
|
(defn manual->transaction [{:keys [description-original bank-account-code] :as transaction} bank-account-lookup client-lookup]
|
||||||
(-> {:transaction/description-original description-original
|
(-> {:transaction/description-original description-original
|
||||||
:transaction/status "POSTED"}
|
:transaction/status "POSTED"}
|
||||||
(c/assoc-or-error :transaction/client #(if-let [client-id (client-lookup bank-account-code)]
|
(c/assoc-or-error :transaction/client #(if-let [client-id (client-lookup bank-account-code)]
|
||||||
@@ -46,21 +45,21 @@
|
|||||||
(d/q '[:find ?bac ?ba
|
(d/q '[:find ?bac ?ba
|
||||||
:in $
|
:in $
|
||||||
:where [?ba :bank-account/code ?bac]]
|
:where [?ba :bank-account/code ?bac]]
|
||||||
(d/db conn)))]
|
(d/db conn)))
|
||||||
(let [import-batch (t/start-import-batch :import-source/manual user)
|
import-batch (t/start-import-batch :import-source/manual user)
|
||||||
transactions (->> transactions
|
transactions (->> transactions
|
||||||
(map (fn [t]
|
(map (fn [t]
|
||||||
(manual->transaction t bank-account-code->bank-account bank-account-code->client)))
|
(manual->transaction t bank-account-code->bank-account bank-account-code->client)))
|
||||||
(t/apply-synthetic-ids ))]
|
(t/apply-synthetic-ids ))]
|
||||||
(try
|
(try
|
||||||
(doseq [transaction transactions]
|
(doseq [transaction transactions]
|
||||||
(when-not (seq (:errors transaction))
|
(when-not (seq (:errors transaction))
|
||||||
(t/import-transaction! import-batch transaction)))
|
(t/import-transaction! import-batch transaction)))
|
||||||
|
|
||||||
(t/finish! import-batch)
|
(t/finish! import-batch)
|
||||||
(assoc (t/get-stats import-batch)
|
(assoc (t/get-stats import-batch)
|
||||||
:failed-validation (count (filter :errors transactions))
|
:failed-validation (count (filter :errors transactions))
|
||||||
:sample-error (first (first (map :errors (filter :errors transactions)))))
|
:sample-error (first (first (map :errors (filter :errors transactions)))))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(t/fail! import-batch e)
|
(t/fail! import-batch e)
|
||||||
(t/get-stats import-batch)))))))
|
(t/get-stats import-batch))))))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
[clj-time.core :as time]
|
[clj-time.core :as time]
|
||||||
[datomic.api :as d]
|
[datomic.api :as d]
|
||||||
|
[digest :as di]
|
||||||
[mount.core :as mount]
|
[mount.core :as mount]
|
||||||
[unilog.context :as lc]
|
[unilog.context :as lc]
|
||||||
[yang.scheduler :as scheduler]))
|
[yang.scheduler :as scheduler]))
|
||||||
@@ -28,7 +29,8 @@
|
|||||||
(defn plaid->transaction [t]
|
(defn plaid->transaction [t]
|
||||||
#:transaction {:description-original (:name t)
|
#:transaction {:description-original (:name t)
|
||||||
:raw-id (:transaction_id t)
|
:raw-id (:transaction_id t)
|
||||||
:id (digest/sha-256 (:transaction_id t))
|
:id #_{:clj-kondo/ignore [:unresolved-var]}
|
||||||
|
(di/sha-256 (:transaction_id t))
|
||||||
:amount (if (= "credit" (:type (:account t)))
|
:amount (if (= "credit" (:type (:account t)))
|
||||||
(- (double (:amount t)))
|
(- (double (:amount t)))
|
||||||
(double (:amount t)))
|
(double (:amount t)))
|
||||||
@@ -36,7 +38,7 @@
|
|||||||
:status "POSTED"})
|
:status "POSTED"})
|
||||||
|
|
||||||
|
|
||||||
(defn import-plaid []
|
(defn import-plaid-int []
|
||||||
(lc/with-context {:source "Import plaid transactions"}
|
(lc/with-context {:source "Import plaid transactions"}
|
||||||
(let [import-batch (t/start-import-batch :import-source/plaid "Automated plaid user")
|
(let [import-batch (t/start-import-batch :import-source/plaid "Automated plaid user")
|
||||||
end (atime/local-now)
|
end (atime/local-now)
|
||||||
@@ -57,7 +59,7 @@
|
|||||||
(catch Exception e
|
(catch Exception e
|
||||||
(t/fail! import-batch e))))))
|
(t/fail! import-batch e))))))
|
||||||
|
|
||||||
(def import-plaid (allow-once import-plaid))
|
(def import-plaid (allow-once import-plaid-int))
|
||||||
|
|
||||||
(mount/defstate import-worker
|
(mount/defstate import-worker
|
||||||
:start (scheduler/every (* 1000 60 60 3) (heartbeat import-plaid "import-plaid"))
|
:start (scheduler/every (* 1000 60 60 3) (heartbeat import-plaid "import-plaid"))
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
(ns auto-ap.import.transactions
|
(ns auto-ap.import.transactions
|
||||||
(:require [auto-ap.datomic :refer [audit-transact conn remove-nils uri]]
|
(:require
|
||||||
[auto-ap.datomic.accounts :as a]
|
[auto-ap.datomic :refer [audit-transact conn remove-nils uri]]
|
||||||
[auto-ap.datomic.checks :as d-checks]
|
[auto-ap.datomic.accounts :as a]
|
||||||
[auto-ap.datomic.transaction-rules :as tr]
|
[auto-ap.datomic.checks :as d-checks]
|
||||||
[auto-ap.datomic.transactions :as d-transactions]
|
[auto-ap.datomic.transaction-rules :as tr]
|
||||||
[auto-ap.rule-matching :as rm]
|
[auto-ap.datomic.transactions :as d-transactions]
|
||||||
[auto-ap.utils :refer [dollars=]]
|
[auto-ap.rule-matching :as rm]
|
||||||
[auto-ap.yodlee.core :as client]
|
[auto-ap.time :as atime]
|
||||||
[clj-time.coerce :as coerce]
|
[auto-ap.utils :refer [dollars=]]
|
||||||
[clj-time.core :as t]
|
[clj-time.coerce :as coerce]
|
||||||
[clojure.core.cache :as cache]
|
[clj-time.core :as t]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.core.cache :as cache]
|
||||||
[datomic.api :as d]
|
[clojure.tools.logging :as log]
|
||||||
[digest :refer [sha-256]]))
|
[datomic.api :as d]
|
||||||
|
[digest :as di]))
|
||||||
|
|
||||||
(defn rough-match [client-id bank-account-id amount]
|
(defn rough-match [client-id bank-account-id amount]
|
||||||
(if (and client-id bank-account-id amount)
|
(if (and client-id bank-account-id amount)
|
||||||
@@ -35,7 +36,8 @@
|
|||||||
(cond (not (and client-id bank-account-id))
|
(cond (not (and client-id bank-account-id))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(:transaction/payment (d-transactions/get-by-id [:transaction/id (sha-256 (str id))]))
|
(:transaction/payment (d-transactions/get-by-id [:transaction/id #_{:clj-kondo/ignore [:unresolved-var]}
|
||||||
|
(di/sha-256 (str id))]))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
check-number
|
check-number
|
||||||
@@ -119,7 +121,7 @@
|
|||||||
:payment/type :payment-type/debit
|
:payment/type :payment-type/debit
|
||||||
:payment/status :payment-status/cleared
|
:payment/status :payment-status/cleared
|
||||||
:db/id payment-id})
|
:db/id payment-id})
|
||||||
(into (mapcat (fn [[vendor invoice-id invoice-amount]]
|
(into (mapcat (fn [[_ invoice-id invoice-amount]]
|
||||||
[{:invoice-payment/invoice invoice-id
|
[{:invoice-payment/invoice invoice-id
|
||||||
:invoice-payment/payment payment-id
|
:invoice-payment/payment payment-id
|
||||||
:invoice-payment/amount invoice-amount}
|
:invoice-payment/amount invoice-amount}
|
||||||
@@ -143,7 +145,7 @@
|
|||||||
(if-let [[_ _ check-number] (re-find #"(?i)check(card|[^0-9]+([0-9]*))" description-original)]
|
(if-let [[_ _ check-number] (re-find #"(?i)check(card|[^0-9]+([0-9]*))" description-original)]
|
||||||
(try
|
(try
|
||||||
(Integer/parseInt check-number)
|
(Integer/parseInt check-number)
|
||||||
(catch NumberFormatException e
|
(catch NumberFormatException _
|
||||||
nil))
|
nil))
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
@@ -238,8 +240,7 @@
|
|||||||
))))
|
))))
|
||||||
|
|
||||||
(defn maybe-code [{:transaction/keys [client amount] :as transaction} apply-rules valid-locations]
|
(defn maybe-code [{:transaction/keys [client amount] :as transaction} apply-rules valid-locations]
|
||||||
(if-let [unpaid-invoices (seq (match-transaction-to-unpaid-invoices amount client))]
|
(when (seq (match-transaction-to-unpaid-invoices amount client))
|
||||||
nil
|
|
||||||
(apply-rules transaction valid-locations)))
|
(apply-rules transaction valid-locations)))
|
||||||
|
|
||||||
(defn transaction->txs [transaction bank-account apply-rules]
|
(defn transaction->txs [transaction bank-account apply-rules]
|
||||||
@@ -294,7 +295,7 @@
|
|||||||
(log/info "Importing transactions from " source)
|
(log/info "Importing transactions from " source)
|
||||||
|
|
||||||
(reify ImportBatch
|
(reify ImportBatch
|
||||||
(import-transaction! [this transaction]
|
(import-transaction! [_ transaction]
|
||||||
(let [bank-account (d/pull (d/db conn)
|
(let [bank-account (d/pull (d/db conn)
|
||||||
[:bank-account/code
|
[:bank-account/code
|
||||||
:db/id
|
:db/id
|
||||||
@@ -318,10 +319,10 @@
|
|||||||
{:user/name user
|
{:user/name user
|
||||||
:user/role ":admin"}))))
|
:user/role ":admin"}))))
|
||||||
|
|
||||||
(get-stats [this]
|
(get-stats [_]
|
||||||
@stats)
|
@stats)
|
||||||
|
|
||||||
(fail! [this error]
|
(fail! [_ error]
|
||||||
(log/errorf "Couldn't complete import %d with error." import-id)
|
(log/errorf "Couldn't complete import %d with error." import-id)
|
||||||
(log/error error)
|
(log/error error)
|
||||||
@(d/transact conn [(merge {:db/id import-id
|
@(d/transact conn [(merge {:db/id import-id
|
||||||
@@ -329,7 +330,7 @@
|
|||||||
:import-batch/error-message (str error)}
|
:import-batch/error-message (str error)}
|
||||||
@stats)]))
|
@stats)]))
|
||||||
|
|
||||||
(finish! [this]
|
(finish! [_]
|
||||||
(log/infof "Finishing import batch %d for %s with stats %s " import-id (name source) (pr-str @stats))
|
(log/infof "Finishing import batch %d for %s with stats %s " import-id (name source) (pr-str @stats))
|
||||||
@(d/transact conn [(merge {:db/id import-id
|
@(d/transact conn [(merge {:db/id import-id
|
||||||
|
|
||||||
@@ -339,7 +340,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn synthetic-key [{:transaction/keys [date bank-account description-original amount client] } index]
|
(defn synthetic-key [{:transaction/keys [date bank-account description-original amount client] } index]
|
||||||
(str (str (some-> date coerce/to-date-time auto-ap.time/localize)) "-" bank-account "-" description-original "-" amount "-" index "-" client))
|
(str (str (some-> date coerce/to-date-time atime/localize)) "-" bank-account "-" description-original "-" amount "-" index "-" client))
|
||||||
|
|
||||||
(defn apply-synthetic-ids [transactions]
|
(defn apply-synthetic-ids [transactions]
|
||||||
(->> transactions
|
(->> transactions
|
||||||
@@ -349,7 +350,8 @@
|
|||||||
(map (fn [index transaction]
|
(map (fn [index transaction]
|
||||||
(let [raw-id (synthetic-key transaction index)]
|
(let [raw-id (synthetic-key transaction index)]
|
||||||
(assoc transaction
|
(assoc transaction
|
||||||
:transaction/id (digest/sha-256 raw-id)
|
:transaction/id #_{:clj-kondo/ignore [:unresolved-var]}
|
||||||
|
(di/sha-256 raw-id)
|
||||||
:transaction/raw-id raw-id)))
|
:transaction/raw-id raw-id)))
|
||||||
(range)
|
(range)
|
||||||
group)))))
|
group)))))
|
||||||
|
|||||||
@@ -3,16 +3,14 @@
|
|||||||
[auto-ap.datomic :refer [conn]]
|
[auto-ap.datomic :refer [conn]]
|
||||||
[auto-ap.import.transactions :as t]
|
[auto-ap.import.transactions :as t]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[auto-ap.utils :refer [allow-once heartbeat]]
|
[auto-ap.utils :refer [allow-once]]
|
||||||
[auto-ap.yodlee.core :as client]
|
[auto-ap.yodlee.core :as client]
|
||||||
[clj-time.coerce :as coerce]
|
[clj-time.coerce :as coerce]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.tools.logging :as log]
|
||||||
[com.unbounce.dogstatsd.core :as statsd]
|
[com.unbounce.dogstatsd.core :as statsd]
|
||||||
[datomic.api :as d]
|
[datomic.api :as d]
|
||||||
[digest :refer [sha-256]]
|
[digest :as di]))
|
||||||
[mount.core :as mount]
|
|
||||||
[yang.scheduler :as scheduler]))
|
|
||||||
|
|
||||||
(defn yodlee->transaction [transaction use-date-instead-of-post-date?]
|
(defn yodlee->transaction [transaction use-date-instead-of-post-date?]
|
||||||
(let [{post-date :postDate
|
(let [{post-date :postDate
|
||||||
@@ -31,7 +29,8 @@
|
|||||||
date (atime/parse date "YYYY-MM-dd")]
|
date (atime/parse date "YYYY-MM-dd")]
|
||||||
#:transaction
|
#:transaction
|
||||||
{:post-date (coerce/to-date (atime/parse post-date "YYYY-MM-dd"))
|
{:post-date (coerce/to-date (atime/parse post-date "YYYY-MM-dd"))
|
||||||
:id (sha-256 (str id))
|
:id #_{:clj-kondo/ignore [:unresolved-var]}
|
||||||
|
(di/sha-256 (str id))
|
||||||
:raw-id (str id)
|
:raw-id (str id)
|
||||||
:account-id account-id
|
:account-id account-id
|
||||||
:date (if use-date-instead-of-post-date?
|
:date (if use-date-instead-of-post-date?
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
[unilog.context :as lc]
|
[unilog.context :as lc]
|
||||||
[yang.scheduler :as scheduler]))
|
[yang.scheduler :as scheduler]))
|
||||||
|
|
||||||
(defn import-yodlee2 []
|
(defn import-yodlee2-int []
|
||||||
(lc/with-context {:source "Import yodlee2 transactions"}
|
(lc/with-context {:source "Import yodlee2 transactions"}
|
||||||
(statsd/event {:title "Yodlee2 import started"
|
(statsd/event {:title "Yodlee2 import started"
|
||||||
:text "Starting"
|
:text "Starting"
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(def import-yodlee2 (allow-once import-yodlee2))
|
(def import-yodlee2 (allow-once import-yodlee2-int))
|
||||||
|
|
||||||
|
|
||||||
(mount/defstate import-worker
|
(mount/defstate import-worker
|
||||||
|
|||||||
@@ -1,38 +1,30 @@
|
|||||||
(ns auto-ap.intuit.core
|
(ns auto-ap.intuit.core
|
||||||
(:require [auto-ap.datomic :refer [conn remove-nils]]
|
(:require
|
||||||
[amazonica.aws.s3 :as s3]
|
[amazonica.aws.s3 :as s3]
|
||||||
[auto-ap.utils :refer [by]]
|
[clj-http.client :as client]
|
||||||
[clj-http.client :as client]
|
[clojure.core.memoize :as m]
|
||||||
[clj-time.coerce :as coerce]
|
[clojure.java.io :as io]
|
||||||
[clj-time.core :as time]
|
[clojure.string :as str]
|
||||||
[clj-time.format :as f]
|
[clojure.tools.logging :as log]
|
||||||
[config.core :refer [env] :as cfg ]
|
[config.core :as cfg :refer [env]])
|
||||||
[clojure.string :as str]
|
(:import
|
||||||
[clojure.data.json :as json]
|
(org.apache.commons.codec.binary Base64)))
|
||||||
[clojure.java.io :as io]
|
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[datomic.api :as d]
|
|
||||||
[mount.core :as mount]
|
|
||||||
[unilog.context :as lc]
|
|
||||||
[yang.scheduler :as scheduler]
|
|
||||||
[clojure.core.async :as async]
|
|
||||||
[clojure.core.memoize :as m])
|
|
||||||
(:import [org.apache.commons.codec.binary Base64]))
|
|
||||||
|
|
||||||
|
;; (def authorization-code "AB11638463964I0tYPR3A1inog2HL407u2bZBXHg6LEqCbILRO")
|
||||||
|
;; (def realm-id "4620816365202617680")
|
||||||
|
|
||||||
(def authorization-code "AB11638463964I0tYPR3A1inog2HL407u2bZBXHg6LEqCbILRO")
|
;; (def company-id "4620816365202617680")
|
||||||
(def realm-id "4620816365202617680")
|
|
||||||
|
|
||||||
(def company-id "4620816365202617680")
|
;; (def base-url "https://sandbox-quickbooks.api.intuit.com/v3")
|
||||||
|
|
||||||
(def base-url "https://sandbox-quickbooks.api.intuit.com/v3")
|
|
||||||
|
|
||||||
|
|
||||||
(def prod-client-id "ABFRwAiOqQiLN66HKplXfyRE3ipD390DHsrUquflRCiOa81mxa")
|
(def prod-client-id "ABFRwAiOqQiLN66HKplXfyRE3ipD390DHsrUquflRCiOa81mxa")
|
||||||
(def prod-client-secret "xDUj04GeQXpLvrhxep1jjDYwjJWbzzOPrirUQTKF")
|
(def prod-client-secret "xDUj04GeQXpLvrhxep1jjDYwjJWbzzOPrirUQTKF")
|
||||||
(def prod-redirect-uri "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl")
|
|
||||||
(def prod-authorization-code "AB11638464998wYuapsEGtIEnRqphrw0H97XUnvEG2dK4cGUyL")
|
;; (def prod-redirect-uri "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl")
|
||||||
(def prod-realm-id "123146163906404")
|
;; (def prod-authorization-code "AB11638464998wYuapsEGtIEnRqphrw0H97XUnvEG2dK4cGUyL")
|
||||||
|
;; (def prod-realm-id "123146163906404")
|
||||||
|
|
||||||
;; "refreshToken": "AB11647191065B0olWYQ61wfq8uszBusfe6Jpn7Au7qY5exkLL",
|
;; "refreshToken": "AB11647191065B0olWYQ61wfq8uszBusfe6Jpn7Au7qY5exkLL",
|
||||||
;; "accessToken":,
|
;; "accessToken":,
|
||||||
;;
|
;;
|
||||||
@@ -122,10 +114,9 @@
|
|||||||
|
|
||||||
(defn get-all-transactions [start end]
|
(defn get-all-transactions [start end]
|
||||||
(let [token (get-fresh-access-token)]
|
(let [token (get-fresh-access-token)]
|
||||||
(let [body (:body (client/get (str prod-base-url "/company/" prod-company-id "/reports/TransactionList" "?minorversion=63&start_date=" start "&end_date=" end)
|
(:body (client/get (str prod-base-url "/company/" prod-company-id "/reports/TransactionList" "?minorversion=63&start_date=" start "&end_date=" end)
|
||||||
{:headers (with-auth prod-base-headers token)
|
{:headers (with-auth prod-base-headers token)
|
||||||
:as :json}))]
|
:as :json}))))
|
||||||
body)))
|
|
||||||
|
|
||||||
(def memoize-get-all-transactions (m/ttl get-all-transactions :ttl/threshold 60000))
|
(def memoize-get-all-transactions (m/ttl get-all-transactions :ttl/threshold 60000))
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
(ns auto-ap.parse
|
(ns auto-ap.parse
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.logging :refer [info-event]]
|
|
||||||
[auto-ap.parse.csv :as csv]
|
[auto-ap.parse.csv :as csv]
|
||||||
[auto-ap.parse.excel :as excel]
|
[auto-ap.parse.excel :as excel]
|
||||||
[auto-ap.parse.templates :as t]
|
[auto-ap.parse.templates :as t]
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
[clojure.tools.logging :as log]))
|
[clojure.tools.logging :as log]))
|
||||||
|
|
||||||
(defn determine
|
(defn determine
|
||||||
[[header :as z]]
|
[[header]]
|
||||||
(log/info "Importing with header" header)
|
(log/info "Importing with header" header)
|
||||||
(let [csv-type (cond (str/includes? (second header) "Customer's PO No.")
|
(let [csv-type (cond (str/includes? (second header) "Customer's PO No.")
|
||||||
:mama-lus
|
:mama-lus
|
||||||
@@ -34,15 +34,16 @@
|
|||||||
|
|
||||||
(defmulti parse-csv
|
(defmulti parse-csv
|
||||||
determine
|
determine
|
||||||
:default (fn default [rows]
|
:default #_{:clj-kondo/ignore [:unused-binding]}
|
||||||
|
(fn default [rows]
|
||||||
nil))
|
nil))
|
||||||
|
|
||||||
(defn parse-date-fallover [d fmts]
|
(defn parse-date-fallover [d fmts]
|
||||||
(if-let [valid-fmt (->> fmts
|
(when-let [valid-fmt (->> fmts
|
||||||
(filter (fn [f]
|
(filter (fn [f]
|
||||||
(try
|
(try
|
||||||
(u/parse-value :clj-time f d)
|
(u/parse-value :clj-time f d)
|
||||||
(catch Exception e
|
(catch Exception _
|
||||||
nil))
|
nil))
|
||||||
))
|
))
|
||||||
(first))]
|
(first))]
|
||||||
@@ -96,7 +97,7 @@
|
|||||||
[rows]
|
[rows]
|
||||||
(transduce
|
(transduce
|
||||||
(comp (drop 1)
|
(comp (drop 1)
|
||||||
(map (fn [[_ po-number despatch-number invoice-number invoice-date customer value :as row]]
|
(map (fn [[_ po-number _ invoice-number invoice-date customer value :as row]]
|
||||||
{:vendor-code "Mama Lu's Foods"
|
{:vendor-code "Mama Lu's Foods"
|
||||||
:customer-identifier customer
|
:customer-identifier customer
|
||||||
:invoice-number (str po-number "-" invoice-number )
|
:invoice-number (str po-number "-" invoice-number )
|
||||||
@@ -112,7 +113,7 @@
|
|||||||
[rows]
|
[rows]
|
||||||
(transduce
|
(transduce
|
||||||
(comp (drop 1)
|
(comp (drop 1)
|
||||||
(map (fn [[ po-number despatch-number invoice-number invoice-date customer value :as row]]
|
(map (fn [[ po-number _ invoice-number invoice-date customer value :as row]]
|
||||||
{:vendor-code "Mama Lu's Foods"
|
{:vendor-code "Mama Lu's Foods"
|
||||||
:customer-identifier customer
|
:customer-identifier customer
|
||||||
:invoice-number (str po-number "-" invoice-number )
|
:invoice-number (str po-number "-" invoice-number )
|
||||||
@@ -128,7 +129,7 @@
|
|||||||
[rows]
|
[rows]
|
||||||
(transduce
|
(transduce
|
||||||
(comp
|
(comp
|
||||||
(filter (fn [[dt _ doc-number name _ status _ _ amount :as row]]
|
(filter (fn [[_ _ _ _ _ status _ _ _ ]]
|
||||||
(= status "Billed")))
|
(= status "Billed")))
|
||||||
(map (fn [[dt _ doc-number name _ _ _ _ amount :as row]]
|
(map (fn [[dt _ doc-number name _ _ _ _ amount :as row]]
|
||||||
{:vendor-code "PHILZ COFFEE, INC"
|
{:vendor-code "PHILZ COFFEE, INC"
|
||||||
@@ -161,11 +162,12 @@
|
|||||||
[]
|
[]
|
||||||
(drop 1 rows)))
|
(drop 1 rows)))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:unused-binding]}
|
||||||
(defmethod parse-csv nil
|
(defmethod parse-csv nil
|
||||||
[rows]
|
[rows]
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(defn parse-file [file filename]
|
(defn parse-file [file _]
|
||||||
(with-open [reader (io/reader file)]
|
(with-open [reader (io/reader file)]
|
||||||
(let [rows (csv/read-csv reader :separator \,)]
|
(let [rows (csv/read-csv reader :separator \,)]
|
||||||
(parse-csv rows))))
|
(parse-csv rows))))
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
extract)]))
|
extract)]))
|
||||||
|
|
||||||
(defn parse-file
|
(defn parse-file
|
||||||
[file filename]
|
[file _]
|
||||||
(let [wb (d/load-workbook file)
|
(let [wb (d/load-workbook file)
|
||||||
text (->> wb
|
text (->> wb
|
||||||
(d/sheet-seq)
|
(d/sheet-seq)
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
(ns auto-ap.parse.util
|
(ns auto-ap.parse.util
|
||||||
(:require [clj-fuzzy.metrics :as m]
|
(:require
|
||||||
[clojure.java.shell :as sh]
|
[clj-time.core :as time]
|
||||||
[clojure.string :as str]
|
[clj-time.format :as f]
|
||||||
[clj-time.format :as f]
|
[clojure.string :as str]
|
||||||
[clj-time.core :as time]
|
[clojure.tools.logging :as log]))
|
||||||
[clojure.tools.logging :as log]))
|
|
||||||
|
|
||||||
(defmulti parse-value (fn [method _ _]
|
(defmulti parse-value (fn [method _ _]
|
||||||
method))
|
method))
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
:body
|
:body
|
||||||
:link_token))
|
:link_token))
|
||||||
|
|
||||||
(defn exchange-public-token [public-token client-code]
|
(defn exchange-public-token [public-token _]
|
||||||
(-> (client/post (str base-url "/item/public_token/exchange")
|
(-> (client/post (str base-url "/item/public_token/exchange")
|
||||||
{:as :json
|
{:as :json
|
||||||
:headers {"Content-Type" "application/json"}
|
:headers {"Content-Type" "application/json"}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
{:alg :hs512}))
|
{:alg :hs512}))
|
||||||
|
|
||||||
(defroutes routes
|
(defroutes routes
|
||||||
(GET "/oauth" {{:strs [code]} :query-params :keys [scheme] :as r {:strs [host]} :headers}
|
(GET "/oauth" {{:strs [code]} :query-params {:strs [host]} :headers}
|
||||||
(try
|
(try
|
||||||
(let [auth (-> "https://accounts.google.com/o/oauth2/token"
|
(let [auth (-> "https://accounts.google.com/o/oauth2/token"
|
||||||
(http/post
|
(http/post
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
(ns auto-ap.routes.events
|
|
||||||
(:require [auto-ap.routes.utils :refer [wrap-secure]]
|
|
||||||
[config.core :refer [env]]
|
|
||||||
[clj-http.client :as http]
|
|
||||||
[clj-time.coerce :as c]
|
|
||||||
[clj-time.core :as time]
|
|
||||||
[clj-time.periodic :as p]
|
|
||||||
[clj-time.predicates :as pred]
|
|
||||||
[clojure.data.json :as json]
|
|
||||||
[compojure.core :refer [GET PUT POST context defroutes
|
|
||||||
wrap-routes]]
|
|
||||||
[clojure.tools.logging :as log]
|
|
||||||
[unilog.context :as lc])
|
|
||||||
(:import (org.joda.time DateTime)))
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
(ns auto-ap.routes.graphql
|
(ns auto-ap.routes.graphql
|
||||||
(:require [auto-ap.routes.utils :refer [wrap-secure wrap-spec]]
|
(:require [auto-ap.routes.utils :refer [wrap-secure]]
|
||||||
[auto-ap.graphql :as ql]
|
[auto-ap.graphql :as ql]
|
||||||
[auto-ap.logging :refer [warn-event]]
|
[auto-ap.logging :refer [warn-event]]
|
||||||
[buddy.auth :refer [throw-unauthorized]]
|
[buddy.auth :refer [throw-unauthorized]]
|
||||||
[clojure.edn :as edn]
|
[clojure.edn :as edn]
|
||||||
[compojure.core :refer [GET POST PUT context defroutes
|
[compojure.core :refer [GET POST context defroutes
|
||||||
wrap-routes]]
|
wrap-routes]]
|
||||||
[clojure.tools.logging :as log]))
|
[clojure.tools.logging :as log]))
|
||||||
(defn handle-graphql [{:keys [request-method query-params body edn-params method] :as r}]
|
(defn handle-graphql [{:keys [request-method query-params] :as r}]
|
||||||
(when (= "none" (:user/role (:identity r)))
|
(when (= "none" (:user/role (:identity r)))
|
||||||
(throw-unauthorized))
|
(throw-unauthorized))
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
(defroutes routes
|
(defroutes routes
|
||||||
(wrap-routes
|
(wrap-routes
|
||||||
(context "/yodlee2" []
|
(context "/yodlee2" []
|
||||||
(GET "/fastlink" {:keys [query-params identity] :as request}
|
(GET "/fastlink" {:keys [query-params identity]}
|
||||||
(assert-can-see-client identity (d/pull (d/db conn) [:db/id] [:client/code (get query-params "client")]))
|
(assert-can-see-client identity (d/pull (d/db conn) [:db/id] [:client/code (get query-params "client")]))
|
||||||
|
|
||||||
(let [token (if-let [client-id (get query-params "client-id")]
|
(let [token (if-let [client-id (get query-params "client-id")]
|
||||||
@@ -27,9 +27,7 @@
|
|||||||
:headers {"Content-Type" "application/edn"}
|
:headers {"Content-Type" "application/edn"}
|
||||||
:body (pr-str {:token token
|
:body (pr-str {:token token
|
||||||
:url (:yodlee2-fastlink env)}) }))
|
:url (:yodlee2-fastlink env)}) }))
|
||||||
(POST "/provider-accounts/refresh/" {:keys [query-params identity edn-params]
|
(POST "/provider-accounts/refresh/" {:keys [identity edn-params]}
|
||||||
{:keys [id]} :route-params
|
|
||||||
:as request}
|
|
||||||
(assert-admin identity)
|
(assert-admin identity)
|
||||||
(log/info "refreshing " edn-params)
|
(log/info "refreshing " edn-params)
|
||||||
(try
|
(try
|
||||||
@@ -48,9 +46,8 @@
|
|||||||
:body (pr-str {:message (.getMessage e)
|
:body (pr-str {:message (.getMessage e)
|
||||||
:error (.toString e)})})))
|
:error (.toString e)})})))
|
||||||
|
|
||||||
(GET "/provider-accounts/:client/:id" {:keys [query-params identity edn-params]
|
(GET "/provider-accounts/:client/:id" {:keys [identity]
|
||||||
{:keys [client id]} :route-params
|
{:keys [client id]} :route-params}
|
||||||
:as request}
|
|
||||||
(assert-admin identity)
|
(assert-admin identity)
|
||||||
(log/info "looking-up " client id)
|
(log/info "looking-up " client id)
|
||||||
(try
|
(try
|
||||||
@@ -68,7 +65,7 @@
|
|||||||
:headers {"Content-Type" "application/edn"}
|
:headers {"Content-Type" "application/edn"}
|
||||||
:body (pr-str {:message (.getMessage e)
|
:body (pr-str {:message (.getMessage e)
|
||||||
:error (.toString e)})})))
|
:error (.toString e)})})))
|
||||||
(POST "/provider-accounts/delete/" {:keys [edn-params identity] {:keys [id]} :route-params :as request}
|
(POST "/provider-accounts/delete/" {:keys [edn-params identity]}
|
||||||
(assert-admin identity)
|
(assert-admin identity)
|
||||||
(try
|
(try
|
||||||
(yodlee/delete-provider-account (-> (:client-id edn-params)
|
(yodlee/delete-provider-account (-> (:client-id edn-params)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
(ns auto-ap.server
|
(ns auto-ap.server
|
||||||
(:gen-class)
|
(:gen-class)
|
||||||
|
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||||
(:require auto-ap.background.invoices
|
(:require auto-ap.background.invoices
|
||||||
[auto-ap.background.requests :as requests]
|
[auto-ap.background.requests :as requests]
|
||||||
[auto-ap.background.sysco :as sysco]
|
[auto-ap.background.sysco :as sysco]
|
||||||
@@ -84,7 +85,7 @@
|
|||||||
(defn shutdown-mount []
|
(defn shutdown-mount []
|
||||||
(mount/stop))
|
(mount/stop))
|
||||||
|
|
||||||
(defn -main [& args]
|
(defn -main [& _]
|
||||||
(let [without (cond-> []
|
(let [without (cond-> []
|
||||||
(not (env :run-web? )) (into [#'jetty
|
(not (env :run-web? )) (into [#'jetty
|
||||||
#'jetty-stats])
|
#'jetty-stats])
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
(ns auto-ap.square.core
|
(ns auto-ap.square.core
|
||||||
(:require [auto-ap.datomic :refer [conn remove-nils]]
|
(:require
|
||||||
[auto-ap.utils :refer [heartbeat]]
|
[auto-ap.datomic :refer [conn remove-nils]]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.time :as atime]
|
||||||
[clj-http.client :as client]
|
[auto-ap.utils :refer [heartbeat]]
|
||||||
[clj-time.coerce :as coerce]
|
[clj-http.client :as client]
|
||||||
[clj-time.core :as time]
|
[clj-time.coerce :as coerce]
|
||||||
[clj-time.periodic :as periodic]
|
[clj-time.core :as time]
|
||||||
[clj-time.format :as f]
|
[clj-time.format :as f]
|
||||||
[clojure.string :as str]
|
[clj-time.periodic :as periodic]
|
||||||
[clojure.data.json :as json]
|
[clojure.core.async :as async]
|
||||||
[clojure.tools.logging :as log]
|
[clojure.data.json :as json]
|
||||||
[datomic.api :as d]
|
[clojure.set :as set]
|
||||||
[mount.core :as mount]
|
[clojure.string :as str]
|
||||||
[unilog.context :as lc]
|
[clojure.tools.logging :as log]
|
||||||
[yang.scheduler :as scheduler]
|
[datomic.api :as d]
|
||||||
[clojure.core.async :as async]
|
[mount.core :as mount]
|
||||||
[slingshot.slingshot :refer [try+]]))
|
[slingshot.slingshot :refer [try+]]
|
||||||
|
[unilog.context :as lc]
|
||||||
|
[yang.scheduler :as scheduler]))
|
||||||
|
|
||||||
(defn client-base-headers [client]
|
(defn client-base-headers [client]
|
||||||
{"Square-Version" "2021-08-18"
|
{"Square-Version" "2021-08-18"
|
||||||
@@ -225,7 +227,7 @@
|
|||||||
(and (or (> (count (:tenders order)) 0)
|
(and (or (> (count (:tenders order)) 0)
|
||||||
(seq (:returns order)))
|
(seq (:returns order)))
|
||||||
(or (= #{} (set (map #(:status (:card_details %)) (:tenders order))))
|
(or (= #{} (set (map #(:status (:card_details %)) (:tenders order))))
|
||||||
(not= #{} (clojure.set/difference
|
(not= #{} (set/difference
|
||||||
(set (map #(:status (:card_details %)) (:tenders order)))
|
(set (map #(:status (:card_details %)) (:tenders order)))
|
||||||
#{"FAILED" "VOIDED"}))))))
|
#{"FAILED" "VOIDED"}))))))
|
||||||
(filter (fn [order]
|
(filter (fn [order]
|
||||||
@@ -519,7 +521,7 @@
|
|||||||
(mark-integration-status client {:integration-status/state :integration-state/failed
|
(mark-integration-status client {:integration-status/state :integration-state/failed
|
||||||
:integration-status/message (-> data :body str)}))
|
:integration-status/message (-> data :body str)}))
|
||||||
|
|
||||||
(catch Object e
|
(catch Object _
|
||||||
(log/warn &throw-context)
|
(log/warn &throw-context)
|
||||||
(mark-integration-status client {:integration-status/state :integration-state/failed
|
(mark-integration-status client {:integration-status/state :integration-state/failed
|
||||||
:integration-status/message (or (some-> (:wrapper &throw-context) (.getMessage ))
|
:integration-status/message (or (some-> (:wrapper &throw-context) (.getMessage ))
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
(try
|
(try
|
||||||
(time/from-time-zone (f/parse (f/formatter format) v)
|
(time/from-time-zone (f/parse (f/formatter format) v)
|
||||||
(time/time-zone-for-id "America/Los_Angeles"))
|
(time/time-zone-for-id "America/Los_Angeles"))
|
||||||
(catch Exception e
|
(catch Exception _
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(defn unparse [v format]
|
(defn unparse [v format]
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
(try
|
(try
|
||||||
|
|
||||||
(f/unparse (f/with-zone (f/formatter format) (time/time-zone-for-id "America/Los_Angeles")) v)
|
(f/unparse (f/with-zone (f/formatter format) (time/time-zone-for-id "America/Los_Angeles")) v)
|
||||||
(catch Exception e
|
(catch Exception _
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -148,8 +148,7 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn get-provider-account [client-code id]
|
(defn get-provider-account [client-code id]
|
||||||
(let [cob-session (login-user (client-code->login client-code))
|
(let [cob-session (login-user (client-code->login client-code))]
|
||||||
batch-size 100]
|
|
||||||
|
|
||||||
(-> (str (:yodlee2-base-url env) "/providerAccounts/" id)
|
(-> (str (:yodlee2-base-url env) "/providerAccounts/" id)
|
||||||
|
|
||||||
|
|||||||
135
src/clj/user.clj
135
src/clj/user.clj
@@ -1,24 +1,29 @@
|
|||||||
(ns user
|
(ns user
|
||||||
(:require [auto-ap.datomic :refer [uri]]
|
(:require
|
||||||
[config.core :refer [env]]
|
[amazonica.aws.s3 :as s3]
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.datomic :refer [uri]]
|
||||||
[auto-ap.time :as atime]
|
[auto-ap.ledger :as l]
|
||||||
[clojure.core.async :as async]
|
[auto-ap.server ]
|
||||||
[unilog.context :as lc]
|
[auto-ap.square.core :as square]
|
||||||
[auto-ap.square.core :as square]
|
[auto-ap.time :as atime]
|
||||||
[mount.core :as mount]
|
[auto-ap.utils :refer [by]]
|
||||||
[auto-ap.server ]
|
[clj-time.coerce :as c]
|
||||||
[datomic.api :as d]
|
[clj-time.core :as t]
|
||||||
[clojure.data.csv :as csv]
|
[clj-time.periodic :as per]
|
||||||
[clj-time.coerce :as c]
|
[clojure.core.async :as async]
|
||||||
[clj-time.core :as t]
|
[clojure.data.csv :as csv]
|
||||||
[clj-time.periodic :as per]
|
[clojure.java.io :as io]
|
||||||
[clojure.java.io :as io]
|
clojure.pprint
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
|
[config.core :refer [env]]
|
||||||
[amazonica.aws.s3 :as s3])
|
[datomic.api :as d]
|
||||||
(:import [org.apache.commons.io.input BOMInputStream]))
|
[mount.core :as mount]
|
||||||
|
nrepl.middleware.print
|
||||||
|
[unilog.context :as lc])
|
||||||
|
(:import
|
||||||
|
[org.apache.commons.io.input BOMInputStream]))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn mark-until-date [client end]
|
(defn mark-until-date [client end]
|
||||||
(let [conn (d/connect uri)]
|
(let [conn (d/connect uri)]
|
||||||
(doseq [p (->>
|
(doseq [p (->>
|
||||||
@@ -60,6 +65,7 @@
|
|||||||
|
|
||||||
@(d/transact conn p) (println "process 100"))))
|
@(d/transact conn p) (println "process 100"))))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn unapprove-all []
|
(defn unapprove-all []
|
||||||
(let [conn (d/connect uri)]
|
(let [conn (d/connect uri)]
|
||||||
(doseq [p (->>
|
(doseq [p (->>
|
||||||
@@ -76,12 +82,9 @@
|
|||||||
@(d/transact conn p)
|
@(d/transact conn p)
|
||||||
(println "process 100"))))
|
(println "process 100"))))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
|
|
||||||
|
|
||||||
(defn load-accounts [conn]
|
(defn load-accounts [conn]
|
||||||
(let [[header & rows] (-> "master-account-list.csv" (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv)
|
(let [[header & rows] (-> "master-account-list.csv" (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv)
|
||||||
headers (map read-string header)
|
|
||||||
code->existing-account (by :account/numeric-code (map first (d/query {:query {:find ['(pull ?e [:account/numeric-code
|
code->existing-account (by :account/numeric-code (map first (d/query {:query {:find ['(pull ?e [:account/numeric-code
|
||||||
:db/id])]
|
:db/id])]
|
||||||
:in ['$]
|
:in ['$]
|
||||||
@@ -96,7 +99,7 @@
|
|||||||
:where ['[?a :account/numeric-code ?ac]]}
|
:where ['[?a :account/numeric-code ?ac]]}
|
||||||
:args [(d/db conn) also-merge ]}))]
|
:args [(d/db conn) also-merge ]}))]
|
||||||
(into (mapv
|
(into (mapv
|
||||||
(fn [[entity id sunset-account]]
|
(fn [[entity id _]]
|
||||||
[:db/add entity id old-account-id])
|
[:db/add entity id old-account-id])
|
||||||
(d/query {:query {:find ['?e '?id '?a ]
|
(d/query {:query {:find ['?e '?id '?a ]
|
||||||
:in ['$ '?ac ]
|
:in ['$ '?ac ]
|
||||||
@@ -157,6 +160,7 @@
|
|||||||
rows)]
|
rows)]
|
||||||
@(d/transact conn txes)))
|
@(d/transact conn txes)))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn find-bad-accounts []
|
(defn find-bad-accounts []
|
||||||
(set (map second (d/query {:query {:find ['(pull ?x [*]) '?z]
|
(set (map second (d/query {:query {:find ['(pull ?x [*]) '?z]
|
||||||
:in ['$]
|
:in ['$]
|
||||||
@@ -165,6 +169,7 @@
|
|||||||
'[?x ?a ?e]]}
|
'[?x ?a ?e]]}
|
||||||
:args [(d/db (d/connect uri))]}))))
|
:args [(d/db (d/connect uri))]}))))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn delete-4-digit-accounts []
|
(defn delete-4-digit-accounts []
|
||||||
@(d/transact (d/connect uri)
|
@(d/transact (d/connect uri)
|
||||||
(transduce
|
(transduce
|
||||||
@@ -182,9 +187,10 @@
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn find-conflicting-accounts []
|
(defn find-conflicting-accounts []
|
||||||
(filter
|
(filter
|
||||||
(fn [[k v]]
|
(fn [[_ v]]
|
||||||
(> (count v) 1))
|
(> (count v) 1))
|
||||||
(reduce
|
(reduce
|
||||||
(fn [acc [e z]]
|
(fn [acc [e z]]
|
||||||
@@ -195,15 +201,15 @@
|
|||||||
:where ['[?e :account/numeric-code ?z]]}
|
:where ['[?e :account/numeric-code ?z]]}
|
||||||
:args [(d/db (d/connect uri))]}))))
|
:args [(d/db (d/connect uri))]}))))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn customize-accounts [customer filename]
|
(defn customize-accounts [customer filename]
|
||||||
(let [conn (d/connect uri)
|
(let [conn (d/connect uri)
|
||||||
[header & rows] (-> filename (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv)
|
[_ & rows] (-> filename (io/resource) io/input-stream (BOMInputStream.) (io/reader) csv/read-csv)
|
||||||
[client-id] (first (d/query (-> {:query {:find ['?e]
|
[client-id] (first (d/query (-> {:query {:find ['?e]
|
||||||
:in ['$ '?z]
|
:in ['$ '?z]
|
||||||
:where [['?e :client/code '?z]]}
|
:where [['?e :client/code '?z]]}
|
||||||
:args [(d/db (d/connect uri)) customer]})))
|
:args [(d/db (d/connect uri)) customer]})))
|
||||||
_ (println client-id)
|
_ (println client-id)
|
||||||
headers (map read-string header)
|
|
||||||
code->existing-account (by :account/numeric-code (map first (d/query {:query {:find ['(pull ?e [:account/numeric-code
|
code->existing-account (by :account/numeric-code (map first (d/query {:query {:find ['(pull ?e [:account/numeric-code
|
||||||
{:account/applicability [:db/ident]}
|
{:account/applicability [:db/ident]}
|
||||||
:db/id])]
|
:db/id])]
|
||||||
@@ -218,7 +224,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
_ (if-let [bad-rows (seq (->> rows
|
_ (when-let [bad-rows (seq (->> rows
|
||||||
(group-by (fn [[_ account]]
|
(group-by (fn [[_ account]]
|
||||||
account))
|
account))
|
||||||
vals
|
vals
|
||||||
@@ -278,13 +284,7 @@
|
|||||||
#_@(d/transact conn txes)))
|
#_@(d/transact conn txes)))
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn attach-signature [client-code filename]
|
|
||||||
@(d/transact (d/connect uri)
|
|
||||||
[{:db/id [:client/code client-code]
|
|
||||||
:client/signature-file (str "https://s3.amazonaws.com/integreat-signature-images/" filename)}]))
|
|
||||||
|
|
||||||
|
|
||||||
(defn fix-transactions-without-locations [client-code location]
|
(defn fix-transactions-without-locations [client-code location]
|
||||||
(->>
|
(->>
|
||||||
(d/query {:query {:find ['(pull ?e [*])]
|
(d/query {:query {:find ['(pull ?e [*])]
|
||||||
@@ -369,11 +369,13 @@
|
|||||||
:args [(d/db (d/connect uri))]})])
|
:args [(d/db (d/connect uri))]})])
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn go []
|
(defn go []
|
||||||
(require '[mount.core :as mount])
|
(require '[mount.core :as mount])
|
||||||
(require '[auto-ap.server])
|
(require '[auto-ap.server])
|
||||||
(mount/start-without #'auto-ap.server/jetty))
|
(mount/start-without #'auto-ap.server/jetty))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn entity-history [i]
|
(defn entity-history [i]
|
||||||
(vec (sort-by first (d/query
|
(vec (sort-by first (d/query
|
||||||
{:query {:find ['?tx '?z '?v ]
|
{:query {:find ['?tx '?z '?v ]
|
||||||
@@ -383,6 +385,7 @@
|
|||||||
'[(= ?ad true)]]}
|
'[(= ?ad true)]]}
|
||||||
:args [i (d/history (d/db (d/connect uri)))]}))))
|
:args [i (d/history (d/db (d/connect uri)))]}))))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn entity-history-with-revert [i]
|
(defn entity-history-with-revert [i]
|
||||||
(vec (sort-by first (d/query
|
(vec (sort-by first (d/query
|
||||||
{:query {:find ['?tx '?z '?v '?ad ]
|
{:query {:find ['?tx '?z '?v '?ad ]
|
||||||
@@ -391,12 +394,14 @@
|
|||||||
'[?a :db/ident ?z]]}
|
'[?a :db/ident ?z]]}
|
||||||
:args [i (d/history (d/db (d/connect uri)))]}))))
|
:args [i (d/history (d/db (d/connect uri)))]}))))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn tx-detail [i]
|
(defn tx-detail [i]
|
||||||
(map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v)
|
(map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v)
|
||||||
(:data (first
|
(:data (first
|
||||||
(d/tx-range (d/log (d/connect uri))
|
(d/tx-range (d/log (d/connect uri))
|
||||||
i
|
i
|
||||||
(inc i))))))
|
(inc i))))))
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn tx-range-detail [i]
|
(defn tx-range-detail [i]
|
||||||
(map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v)
|
(map (juxt :e #(d/ident (d/db (d/connect uri)) (:a %)) :v)
|
||||||
|
|
||||||
@@ -405,14 +410,17 @@
|
|||||||
(+ i 100)))))
|
(+ i 100)))))
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn start-db []
|
(defn start-db []
|
||||||
(mount.core/start (mount.core/only #{#'auto-ap.datomic/conn})))
|
(mount.core/start (mount.core/only #{#'auto-ap.datomic/conn})))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn touch-transaction-ledger [e]
|
(defn touch-transaction-ledger [e]
|
||||||
@(d/transact auto-ap.datomic/conn [[:db/retractEntity [:journal-entry/original-entity e]]])
|
@(d/transact auto-ap.datomic/conn [[:db/retractEntity [:journal-entry/original-entity e]]])
|
||||||
@(d/transact auto-ap.datomic/conn [(auto-ap.ledger/entity-change->ledger (d/db auto-ap.datomic/conn)
|
@(d/transact auto-ap.datomic/conn [(l/entity-change->ledger (d/db auto-ap.datomic/conn)
|
||||||
[:transaction e])]))
|
[:transaction e])]))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn mismatched-transactions []
|
(defn mismatched-transactions []
|
||||||
(let [jel-accounts (reduce
|
(let [jel-accounts (reduce
|
||||||
(fn [acc [e lia]]
|
(fn [acc [e lia]]
|
||||||
@@ -444,6 +452,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn spit-csv [columns data ]
|
(defn spit-csv [columns data ]
|
||||||
(csv/write-csv *out*
|
(csv/write-csv *out*
|
||||||
(into [(map name columns)]
|
(into [(map name columns)]
|
||||||
@@ -451,32 +460,34 @@
|
|||||||
((apply juxt columns) r )))))
|
((apply juxt columns) r )))))
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn find-queries [words]
|
(defn find-queries [words]
|
||||||
(let [obj (s3/list-objects-v2 :bucket-name (:data-bucket env)
|
(let [obj (s3/list-objects-v2 :bucket-name (:data-bucket env)
|
||||||
:prefix (str "queries/"))]
|
:prefix (str "queries/"))
|
||||||
(let [concurrent 30
|
concurrent 30
|
||||||
output-chan (async/chan)]
|
output-chan (async/chan)]
|
||||||
(async/pipeline-blocking concurrent
|
(async/pipeline-blocking concurrent
|
||||||
output-chan
|
output-chan
|
||||||
(comp
|
(comp
|
||||||
(map #(do
|
(map #(do
|
||||||
[(:key %)
|
[(:key %)
|
||||||
(str (slurp (:object-content (s3/get-object
|
(str (slurp (:object-content (s3/get-object
|
||||||
:bucket-name (:data-bucket env)
|
:bucket-name (:data-bucket env)
|
||||||
:key (:key %)))))]))
|
:key (:key %)))))]))
|
||||||
|
|
||||||
(filter #(->> words
|
(filter #(->> words
|
||||||
(every? (fn [w] (str/includes? (second %) w)))))
|
(every? (fn [w] (str/includes? (second %) w)))))
|
||||||
(map first)
|
(map first)
|
||||||
(map #(str/replace % #"queries/" ""))
|
(map #(str/replace % #"queries/" ""))
|
||||||
)
|
)
|
||||||
(async/to-chan (:object-summaries obj))
|
(async/to-chan! (:object-summaries obj))
|
||||||
true
|
true
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(println "failed " e)))
|
(println "failed " e)))
|
||||||
(async/<!! (async/into [] output-chan)))))
|
(async/<!! (async/into [] output-chan))))
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn historical-load-sales [client-code days]
|
(defn historical-load-sales [client-code days]
|
||||||
(let [client (d/pull (d/db auto-ap.datomic/conn)
|
(let [client (d/pull (d/db auto-ap.datomic/conn)
|
||||||
square/square-read
|
square/square-read
|
||||||
@@ -508,6 +519,7 @@
|
|||||||
|
|
||||||
(square/upsert-settlements client square-location)))))
|
(square/upsert-settlements client square-location)))))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn load-sales-for-day [date]
|
(defn load-sales-for-day [date]
|
||||||
(doseq [client (d/q [:find [(list 'pull '?e square/square-read ) '...]
|
(doseq [client (d/q [:find [(list 'pull '?e square/square-read ) '...]
|
||||||
:where ['?e :client/square-locations ]]
|
:where ['?e :client/square-locations ]]
|
||||||
@@ -537,7 +549,7 @@
|
|||||||
]))
|
]))
|
||||||
(into {}))]
|
(into {}))]
|
||||||
(->>
|
(->>
|
||||||
(for [[invoice-id invoice-expense-account-id target-account target-date amount expense-account location] (drop 1 data)
|
(for [[invoice-id invoice-expense-account-id target-account target-date amount _ location] (drop 1 data)
|
||||||
:let [
|
:let [
|
||||||
invoice-id (Long/parseLong invoice-id)
|
invoice-id (Long/parseLong invoice-id)
|
||||||
|
|
||||||
@@ -567,7 +579,7 @@
|
|||||||
target-expense-account-location location
|
target-expense-account-location location
|
||||||
|
|
||||||
|
|
||||||
[[payment-id payment-amount invoice-payment]] (vec (d/q
|
[[_ _ invoice-payment]] (vec (d/q
|
||||||
'[:find ?p ?a ?ip
|
'[:find ?p ?a ?ip
|
||||||
:in $ ?i
|
:in $ ?i
|
||||||
:where [?ip :invoice-payment/invoice ?i]
|
:where [?ip :invoice-payment/invoice ?i]
|
||||||
@@ -613,6 +625,7 @@
|
|||||||
vec)))
|
vec)))
|
||||||
|
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn get-schema [prefix]
|
(defn get-schema [prefix]
|
||||||
(->> (d/q '[:find ?i
|
(->> (d/q '[:find ?i
|
||||||
:in $ ?p
|
:in $ ?p
|
||||||
@@ -621,6 +634,7 @@
|
|||||||
(mapcat identity)
|
(mapcat identity)
|
||||||
vec))
|
vec))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn get-idents []
|
(defn get-idents []
|
||||||
(->> (d/q '[:find ?i
|
(->> (d/q '[:find ?i
|
||||||
:in $
|
:in $
|
||||||
@@ -631,6 +645,7 @@
|
|||||||
(sort)
|
(sort)
|
||||||
vec))
|
vec))
|
||||||
|
|
||||||
|
#_{:clj-kondo/ignore [:clojure-lsp/unused-public-var]}
|
||||||
(defn init-repl []
|
(defn init-repl []
|
||||||
(set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint))
|
(set! nrepl.middleware.print/*print-fn* clojure.pprint/pprint))
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
(ns auto-ap.client-routes
|
(ns auto-ap.client-routes)
|
||||||
(:require [bidi.bidi :as bidi]))
|
|
||||||
|
|
||||||
(def routes ["/" {"" :index
|
(def routes ["/" {"" :index
|
||||||
"login/" :login
|
"login/" :login
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
(ns auto-ap.entities.account
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[auto-ap.entities.shared :as shared]))
|
|
||||||
|
|
||||||
(s/def ::account-set string?)
|
|
||||||
(s/def ::numeric-code (s/or :numeric-string? (s/and string?
|
|
||||||
#(re-matches shared/numeric-regex %))
|
|
||||||
:numeric? int?))
|
|
||||||
(s/def ::name string?)
|
|
||||||
(s/def ::location (s/nilable (s/and string?
|
|
||||||
#(re-matches shared/only-upper-case %))))
|
|
||||||
(s/def ::type #{:dividend :expense :asset :liability :equity :revenue})
|
|
||||||
|
|
||||||
(s/def ::account (s/keys :req-un [::account-set ::numeric-code ::name ::type ::location]))
|
|
||||||
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
(ns auto-ap.entities.address
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as str]))
|
|
||||||
|
|
||||||
(s/def ::street1 (s/nilable string?))
|
|
||||||
(s/def ::street2 (s/nilable string?))
|
|
||||||
(s/def ::city (s/nilable string?))
|
|
||||||
(s/def ::state (s/nilable (s/or
|
|
||||||
:empty (s/and string? #{""})
|
|
||||||
:filled (s/and string?
|
|
||||||
#(re-matches #"[a-zA-Z]{2}" %)))))
|
|
||||||
(s/def ::zip (s/nilable string?))
|
|
||||||
|
|
||||||
(s/def ::address (s/keys :opt-un [::email
|
|
||||||
::street1
|
|
||||||
::street2
|
|
||||||
::city
|
|
||||||
::state
|
|
||||||
::zip]))
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
(ns auto-ap.entities.clients
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[auto-ap.entities.shared :as shared]
|
|
||||||
[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)
|
|
||||||
|
|
||||||
(s/def ::name ::shared/required-identifier)
|
|
||||||
(s/def ::code (s/and ::shared/required-identifier
|
|
||||||
#(re-matches #"[A-Z0-9\-]+" %)))
|
|
||||||
(s/def ::address (s/nilable ::address/address))
|
|
||||||
|
|
||||||
(s/def ::bank-name ::shared/required-identifier)
|
|
||||||
(s/def ::bank-code (s/nilable string?))
|
|
||||||
(s/def ::routing (s/nilable string?))
|
|
||||||
(s/def ::number ::shared/required-identifier)
|
|
||||||
(s/def ::type keyword?)
|
|
||||||
(s/def ::number string?)
|
|
||||||
(s/def ::yodlee-account-id string?)
|
|
||||||
|
|
||||||
(s/def ::checking-bank-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type]
|
|
||||||
:opt-un [::bank-code ::routing])
|
|
||||||
#(= (:type %) :check)))
|
|
||||||
|
|
||||||
(s/def ::credit-account (s/and (s/keys :req-un [::code ::name ::bank-name ::number ::type]
|
|
||||||
:opt-un [])
|
|
||||||
#(= (:type %) :credit)))
|
|
||||||
|
|
||||||
(s/def ::cash-account (s/and (s/keys :req-un [::type ::code ::name])
|
|
||||||
#(= (:type %) :cash)))
|
|
||||||
(s/def ::bank-account (s/or :cash ::cash-account
|
|
||||||
:checking ::checking-bank-account
|
|
||||||
:credit ::credit-account))
|
|
||||||
(s/def ::bank-accounts (s/coll-of ::bank-account))
|
|
||||||
;; disabled because graphql defaults to string representation
|
|
||||||
#_(s/def ::weekly-debits (s/nilable double?))
|
|
||||||
#_(s/def ::weekly-credits (s/nilable double?))
|
|
||||||
|
|
||||||
(s/def ::location string?)
|
|
||||||
(s/def ::locations (s/coll-of ::location :min-count 1))
|
|
||||||
|
|
||||||
(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %)
|
|
||||||
:is-empty #(= % "")))))
|
|
||||||
|
|
||||||
|
|
||||||
(s/def ::client (s/keys :req-un [::name ::code ::locations]
|
|
||||||
:opt-un [::email
|
|
||||||
::address
|
|
||||||
#_::weekly-debits
|
|
||||||
#_::weekely-credits
|
|
||||||
::bank-accounts
|
|
||||||
::id]))
|
|
||||||
|
|
||||||
|
|
||||||
(def client-spec (apply hash-map (drop 1 (s/form ::client))))
|
|
||||||
(def all-keys (map #(keyword (name %)) (concat (:req-un client-spec) (:opt-un client-spec))))
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
(ns auto-ap.entities.contact
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[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 (s/nilable string?))
|
|
||||||
(s/def ::name (s/nilable string?))
|
|
||||||
(s/def ::email (s/nilable (s/and string? (s/or :is-email #(re-matches email-regex %)
|
|
||||||
:is-empty #(= % "")))))
|
|
||||||
(s/def ::phone (s/nilable string?))
|
|
||||||
|
|
||||||
(s/def ::contact (s/keys :opt-un [::name ::email ::phone ::id]))
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
(ns auto-ap.entities.invoice
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[auto-ap.entities.shared :as shared]))
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
(ns auto-ap.entities.invoices-expense-accounts
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[auto-ap.entities.shared :as shared]))
|
|
||||||
|
|
||||||
(s/def ::vendor-id string?)
|
|
||||||
(s/def ::account-id string?)
|
|
||||||
(s/def ::amount ::shared/money)
|
|
||||||
(s/def ::location string?)
|
|
||||||
|
|
||||||
(s/def ::invoices-expense-account (s/keys :opt-un [::vendor-id ::account-id ::amount ::location]))
|
|
||||||
@@ -1,31 +1,2 @@
|
|||||||
(ns auto-ap.entities.shared
|
(ns auto-ap.entities.shared)
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as str]
|
|
||||||
))
|
|
||||||
|
|
||||||
(def date-regex #"[2]{1}[0-9]{3}-[0-9]{1,2}-[0-9]{1,2}")
|
|
||||||
(def money-regex #"\-?[0-9]+(\.[0-9]{2})?$")
|
|
||||||
(def numeric-regex #"^[0-9]+$")
|
|
||||||
(def only-upper-case #"^[A-Z]+$")
|
|
||||||
|
|
||||||
(s/def ::identifier (s/nilable string?))
|
|
||||||
(s/def ::date
|
|
||||||
#?(:cljs
|
|
||||||
(s/or :dt? #(instance? goog.date.DateTime %)
|
|
||||||
:d? #(instance? goog.date.Date %)
|
|
||||||
:str? (s/and string? #(re-matches date-regex %)))
|
|
||||||
:clj (s/or :dt? #(instance? org.joda.time.DateTime %)
|
|
||||||
:ldt? #(instance? org.joda.time.LocalDateTime %)
|
|
||||||
:ldt? #(instance? org.joda.time.LocalDate %)
|
|
||||||
:str? (s/and string? #(re-matches date-regex %)))))
|
|
||||||
|
|
||||||
(s/def ::required some?)
|
|
||||||
(s/def ::has-id (s/and map?
|
|
||||||
#(:id %)))
|
|
||||||
(s/def ::required-identifier (s/and string?
|
|
||||||
#(not (str/blank? %))))
|
|
||||||
|
|
||||||
(s/def ::money (s/or :string (s/and string?
|
|
||||||
#(re-matches money-regex %))
|
|
||||||
:float float?
|
|
||||||
:int int?))
|
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
(ns auto-ap.entities.transaction-rule
|
|
||||||
(:require [auto-ap.entities.transaction-rule-account :as transaction-rule-account]
|
|
||||||
[clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as str]))
|
|
||||||
|
|
||||||
(s/def ::client (s/nilable map?))
|
|
||||||
(s/def ::description (s/nilable (s/and string?
|
|
||||||
#( #?@(:clj (try
|
|
||||||
(re-pattern %)
|
|
||||||
true
|
|
||||||
(catch Exception _
|
|
||||||
false))
|
|
||||||
:cljs (try
|
|
||||||
(re-pattern %)
|
|
||||||
true
|
|
||||||
(catch js/Error _
|
|
||||||
false)))))))
|
|
||||||
(s/def ::amount-gte (s/or :double (s/nilable double?)
|
|
||||||
:string (s/nilable string?)))
|
|
||||||
(s/def ::amount-lte (s/or :double (s/nilable double?)
|
|
||||||
:string (s/nilable string?)))
|
|
||||||
(s/def ::dom-gte (s/nilable int?))
|
|
||||||
(s/def ::dom-lte (s/nilable int?))
|
|
||||||
(s/def ::note (s/nilable string?))
|
|
||||||
(s/def ::bank-account (s/nilable map?))
|
|
||||||
(s/def ::vendor (s/nilable map?))
|
|
||||||
(s/def ::yodlee-merchant (s/nilable map?))
|
|
||||||
(s/def ::accounts (s/coll-of ::transaction-rule-account/transaction-rule-account :min-count 1))
|
|
||||||
|
|
||||||
(s/def ::transaction-rule (s/and (s/keys :req-un [::client
|
|
||||||
::description
|
|
||||||
::amount-gte
|
|
||||||
::amount-lte
|
|
||||||
::dom-gte
|
|
||||||
::dom-lte
|
|
||||||
::note
|
|
||||||
::bank-account
|
|
||||||
::vendor
|
|
||||||
::accounts]
|
|
||||||
:opt-un [::yodlee-merchant])
|
|
||||||
|
|
||||||
(s/or :description-required #(not (str/blank? (:description %)))
|
|
||||||
:merchant-required #(not (nil? (:yodlee-merchant %))))))
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
(ns auto-ap.entities.transaction-rule-account
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as str]))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(s/def ::account map?)
|
|
||||||
(s/def ::location (s/and string?
|
|
||||||
not-empty))
|
|
||||||
|
|
||||||
(s/def ::transaction-rule-account (s/keys :req-un [::account
|
|
||||||
::location]
|
|
||||||
:opt-un []))
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
(ns auto-ap.entities.vendors
|
|
||||||
(:require [clojure.spec.alpha :as s]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[auto-ap.entities.contact :as contact]
|
|
||||||
[auto-ap.entities.address :as address]))
|
|
||||||
|
|
||||||
(s/def ::id string?)
|
|
||||||
(s/def ::identifier (s/nilable string?)) (s/def ::required-identifier (s/and string?
|
|
||||||
#(not (str/blank? %))))
|
|
||||||
|
|
||||||
(s/def ::name ::required-identifier)
|
|
||||||
(s/def ::hidden boolean?)
|
|
||||||
(s/def ::print-as (s/nilable string?))
|
|
||||||
(s/def ::terms (s/nilable int?))
|
|
||||||
(s/def ::dom (s/nilable int?))
|
|
||||||
|
|
||||||
(s/def ::invoice-reminder-schedule (s/nilable #{"Weekly" "Never" nil}))
|
|
||||||
|
|
||||||
(s/def ::primary-contact (s/nilable ::contact/contact))
|
|
||||||
(s/def ::secondary-contact (s/nilable ::contact/contact))
|
|
||||||
(s/def ::address (s/nilable ::address/address))
|
|
||||||
(s/def ::default-account-id (s/nilable string?))
|
|
||||||
|
|
||||||
(s/def ::code (s/nilable string?))
|
|
||||||
|
|
||||||
(s/def ::vendor (s/and
|
|
||||||
(s/keys :req-un [::name]
|
|
||||||
:opt-un [::code
|
|
||||||
::default-account-id
|
|
||||||
::terms
|
|
||||||
::hidden
|
|
||||||
::id
|
|
||||||
::print-as
|
|
||||||
::primary-contact
|
|
||||||
::secondary-contact
|
|
||||||
::address])
|
|
||||||
|
|
||||||
(s/or :hidden #(= (:hidden %) true)
|
|
||||||
:has-expense-account #(not (nil? (:id (:default-account %)))))))
|
|
||||||
|
|
||||||
|
|
||||||
(def vendor-spec (apply hash-map (drop 1 (s/form ::vendor))))
|
|
||||||
(def all-keys (map #(keyword (name %)) (concat (:req-un vendor-spec) (:opt-un vendor-spec))))
|
|
||||||
@@ -1,18 +1,20 @@
|
|||||||
(ns auto-ap.effects
|
(ns auto-ap.effects
|
||||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
(:require-macros [cljs.core.async.macros :refer [go]])
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require
|
||||||
[cljs-http.client :as http]
|
[auto-ap.history :as p]
|
||||||
[cljs-time.coerce :as c]
|
[auto-ap.status :as status]
|
||||||
[cljs-time.core :as time]
|
[auto-ap.views.utils :refer [date->str standard]]
|
||||||
[cljs-time.format :as format]
|
[cemerick.url :as url]
|
||||||
[cljs.core.async :refer [<! ] :as async]
|
[cljs-http.client :as http]
|
||||||
[clojure.string :as str]
|
[cljs-time.coerce :as c]
|
||||||
[clojure.walk :as walk]
|
[cljs-time.core :as time]
|
||||||
[venia.core :as v]
|
[cljs-time.format :as format]
|
||||||
[auto-ap.history :as p]
|
[cljs.core.async :refer [<!] :as async]
|
||||||
[auto-ap.views.utils :refer [date->str standard]]
|
[clojure.string :as str]
|
||||||
[auto-ap.status :as status]
|
[clojure.walk :as walk]
|
||||||
[pushy.core :as pushy]))
|
[pushy.core :as pushy]
|
||||||
|
[re-frame.core :as re-frame]
|
||||||
|
[venia.core :as v]))
|
||||||
|
|
||||||
(re-frame/reg-fx
|
(re-frame/reg-fx
|
||||||
:redirect
|
:redirect
|
||||||
@@ -26,8 +28,8 @@
|
|||||||
(pushy/set-token! p/history
|
(pushy/set-token! p/history
|
||||||
(str (.-protocol (.-location js/window)) "//" (.-host (.-location js/window)) (.-pathname (.-location js/window))
|
(str (.-protocol (.-location js/window)) "//" (.-host (.-location js/window)) (.-pathname (.-location js/window))
|
||||||
"?"
|
"?"
|
||||||
(cemerick.url/map->query (->> uri-params
|
(url/map->query (->> uri-params
|
||||||
(filter (fn [[k v]] (and v
|
(filter (fn [[_ v]] (and v
|
||||||
(or (not (seqable? v))
|
(or (not (seqable? v))
|
||||||
(not-empty v)))) )
|
(not-empty v)))) )
|
||||||
(map
|
(map
|
||||||
|
|||||||
@@ -7,17 +7,17 @@
|
|||||||
::register
|
::register
|
||||||
(let [process-one-entry (fn [{:as m :keys [id events event-fn]}]
|
(let [process-one-entry (fn [{:as m :keys [id events event-fn]}]
|
||||||
(let [_ (assert (map? m) (str "re-frame: effects handler for :forward-events expected a map or a list of maps. Got: " m))
|
(let [_ (assert (map? m) (str "re-frame: effects handler for :forward-events expected a map or a list of maps. Got: " m))
|
||||||
_ (assert (= #{:id :events :event-fn} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set)))]
|
_ (assert (= #{:id :events :event-fn} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set)))
|
||||||
(let [post-event-callback-fn (fn [event-v _]
|
post-event-callback-fn (fn [event-v _]
|
||||||
(when (events (first event-v))
|
(when (events (first event-v))
|
||||||
(re-frame/dispatch (event-fn event-v))))]
|
(re-frame/dispatch (event-fn event-v))))]
|
||||||
(re-frame/add-post-event-callback post-event-callback-fn)
|
(re-frame/add-post-event-callback post-event-callback-fn)
|
||||||
(swap! id->listen-fn assoc id post-event-callback-fn))))]
|
(swap! id->listen-fn assoc id post-event-callback-fn)))]
|
||||||
(fn [val]
|
(fn [val]
|
||||||
(cond
|
(cond
|
||||||
(map? val) (process-one-entry val)
|
(map? val) (process-one-entry val)
|
||||||
(sequential? val) (doall (map process-one-entry val))
|
(sequential? val) (doall (map process-one-entry val))
|
||||||
:else (re-frame/console :error ":forward-events expected a map or a list of maps, but got: " val)))))
|
:else (re-frame/console :error ":forward-events expected a map or a list of maps, but got: " val)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
::dispose
|
::dispose
|
||||||
(let [process-one-entry (fn [{:as m :keys [id]}]
|
(let [process-one-entry (fn [{:as m :keys [id]}]
|
||||||
(let [_ (assert (map? m) (str "re-frame: effects handler for :forward-events expected a map or a list of maps. Got: " m))
|
(let [_ (assert (map? m) (str "re-frame: effects handler for :forward-events expected a map or a list of maps. Got: " m))
|
||||||
_ (assert (= #{:id} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set)))]
|
_ (assert (= #{:id} (-> m keys set)) (str "re-frame: effects handler for :forward-events given wrong map keys" (-> m keys set)))
|
||||||
(let [f (@id->listen-fn id)
|
f (@id->listen-fn id)
|
||||||
_ (assert (some? f) (str ":forward-events asked to unregister an unknown id: " id))]
|
_ (assert (some? f) (str ":forward-events asked to unregister an unknown id: " id))]
|
||||||
(re-frame/remove-post-event-callback f)
|
(re-frame/remove-post-event-callback f)
|
||||||
(swap! id->listen-fn dissoc id))))]
|
(swap! id->listen-fn dissoc id)))]
|
||||||
(fn [val]
|
(fn [val]
|
||||||
(cond
|
(cond
|
||||||
(map? val) (process-one-entry val)
|
(map? val) (process-one-entry val)
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
[auto-ap.db :as db]
|
[auto-ap.db :as db]
|
||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
[auto-ap.views.utils :refer [with-user parse-jwt]]
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
|
[auto-ap.views.utils :refer [parse-jwt with-user]]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[goog.crypt.base64 :as b64]
|
[goog.crypt.base64 :as b64]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]))
|
||||||
[goog.crypt.base64 :as base64]))
|
|
||||||
|
|
||||||
(defn jwt->data [token]
|
(defn jwt->data [token]
|
||||||
(js->clj (.parse js/JSON (b64/decodeString (second (str/split token #"\." ))))))
|
(js->clj (.parse js/JSON (b64/decodeString (second (str/split token #"\." ))))))
|
||||||
@@ -131,14 +131,6 @@
|
|||||||
(.setItem js/localStorage "last-client-id" (:id client))
|
(.setItem js/localStorage "last-client-id" (:id client))
|
||||||
(assoc db :client (:id client))))
|
(assoc db :client (:id client))))
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
|
||||||
::change-form
|
|
||||||
(fn [db [_ location field value]]
|
|
||||||
(if value
|
|
||||||
(assoc-in db (into location field) value)
|
|
||||||
(update-in db (into location (butlast field)) dissoc (last field)))))
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::set-active-route
|
::set-active-route
|
||||||
(fn [{:keys [db]} [_ handler params route-params]]
|
(fn [{:keys [db]} [_ handler params route-params]]
|
||||||
@@ -164,7 +156,7 @@
|
|||||||
:menu nil
|
:menu nil
|
||||||
:query-params params
|
:query-params params
|
||||||
:route-params route-params)
|
:route-params route-params)
|
||||||
(auto-ap.views.pages.data-page/dispose-all))})))
|
(data-page/dispose-all))})))
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
|
|||||||
@@ -105,7 +105,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::attempted-submit
|
::attempted-submit
|
||||||
(fn [db [_ form & paths]]
|
(fn [db [_ form ]]
|
||||||
(assoc-in db [::forms form :attempted-submit?] true)))
|
(assoc-in db [::forms form :attempted-submit?] true)))
|
||||||
|
|
||||||
(defn change-handler [form customize-fn]
|
(defn change-handler [form customize-fn]
|
||||||
@@ -154,16 +154,17 @@
|
|||||||
|
|
||||||
(defn triggers-loading [form]
|
(defn triggers-loading [form]
|
||||||
(re-frame/enrich
|
(re-frame/enrich
|
||||||
(fn [db event]
|
(fn [db _]
|
||||||
(loading db form))))
|
(loading db form))))
|
||||||
|
|
||||||
(defn triggers-stop [form]
|
(defn triggers-stop [form]
|
||||||
(re-frame/enrich
|
(re-frame/enrich
|
||||||
(fn [db event]
|
(fn [db _]
|
||||||
(stop-form db form))))
|
(stop-form db form))))
|
||||||
|
|
||||||
(defn triggers-stop-loading [form]
|
(defn triggers-stop-loading [form]
|
||||||
(re-frame/enrich
|
(re-frame/enrich
|
||||||
(fn [db event]
|
(fn [db _]
|
||||||
(assoc-in db [::forms form :status] nil))))
|
(assoc-in db [::forms form :status] nil))))
|
||||||
|
|
||||||
(defn save-succeeded [db id]
|
(defn save-succeeded [db id]
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
{:errors (merge (-> me/default-errors
|
{:errors (merge (-> me/default-errors
|
||||||
(assoc ::m/missing-key {:error/message "Required"}
|
(assoc ::m/missing-key {:error/message "Required"}
|
||||||
::m/invalid-type {:error/fn
|
::m/invalid-type {:error/fn
|
||||||
(fn [a b]
|
(fn [a _]
|
||||||
(if (nil? (:value a))
|
(if (nil? (:value a))
|
||||||
"Required"
|
"Required"
|
||||||
"Invalid"))}))
|
"Invalid"))}))
|
||||||
@@ -210,7 +210,7 @@
|
|||||||
(r/as-element (into [:<>]
|
(r/as-element (into [:<>]
|
||||||
(r/children (r/current-component))))))
|
(r/children (r/current-component))))))
|
||||||
|
|
||||||
(defn vertical-control [{:keys [is-small? required?]}]
|
(defn vertical-control [{:keys [required?]}]
|
||||||
(let [[label & children] (r/children (r/current-component))]
|
(let [[label & children] (r/children (r/current-component))]
|
||||||
(consume Consumer
|
(consume Consumer
|
||||||
["fullwidth?"]
|
["fullwidth?"]
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
[pushy.core :as pushy]
|
[pushy.core :as pushy]
|
||||||
[auto-ap.routes :as routes]
|
[auto-ap.routes :as routes]
|
||||||
[auto-ap.views.utils :as u]
|
[auto-ap.views.utils :as u]
|
||||||
[cemerick.url :refer [url]]
|
|
||||||
[re-frame.core :as re-frame]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
(defn parse-url [url]
|
(defn parse-url [url]
|
||||||
|
|||||||
@@ -109,7 +109,7 @@
|
|||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::completed
|
::completed
|
||||||
[(re-frame/path [::status]) ]
|
[(re-frame/path [::status]) ]
|
||||||
(fn [db [_ single which]]
|
(fn [db [_ single _]]
|
||||||
(assoc db single {:state nil
|
(assoc db single {:state nil
|
||||||
:error nil})))
|
:error nil})))
|
||||||
|
|
||||||
@@ -135,21 +135,19 @@
|
|||||||
info-states
|
info-states
|
||||||
(->> states (filter #(:info %)))]
|
(->> states (filter #(:info %)))]
|
||||||
[:<>
|
[:<>
|
||||||
(if (seq error-states)
|
(when (seq error-states)
|
||||||
[:div.notification.is-danger.is-light
|
[:div.notification.is-danger.is-light
|
||||||
(for [state states
|
(for [state states
|
||||||
state (:error state)]
|
state (:error state)]
|
||||||
(do
|
^{:key (:message state)}
|
||||||
^{:key (:message state)}
|
[:p (or (:message state)
|
||||||
[:p (or (:message state)
|
(:error state)
|
||||||
(:error state)
|
"An unexpected error occured.")])])
|
||||||
"An unexpected error occured.")]))])
|
(when (seq info-states)
|
||||||
(if (seq info-states)
|
|
||||||
[:div.notification.is-info.is-light
|
[:div.notification.is-info.is-light
|
||||||
(for [state states]
|
(for [state states]
|
||||||
(do
|
^{:key (:info state)}
|
||||||
^{:key (:info state)}
|
[:p (:info state)])])]))
|
||||||
[:p (:info state)]))])]))
|
|
||||||
|
|
||||||
(defn big-loader [status]
|
(defn big-loader [status]
|
||||||
(when (= :loading (:state status))
|
(when (= :loading (:state status))
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
(ns auto-ap.views.components.address
|
(ns auto-ap.views.components.address
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.entities.address :as address]
|
|
||||||
[auto-ap.forms.builder :as form-builder]
|
[auto-ap.forms.builder :as form-builder]
|
||||||
[auto-ap.views.components.level :as level]))
|
[auto-ap.views.components.level :as level]))
|
||||||
|
|
||||||
@@ -20,8 +19,7 @@
|
|||||||
[:p.help "City"]
|
[:p.help "City"]
|
||||||
[:input.input.is-expanded {:type "text"
|
[:input.input.is-expanded {:type "text"
|
||||||
:placeholder "Cupertino"
|
:placeholder "Cupertino"
|
||||||
:field [:city]
|
:field [:city]}]]
|
||||||
:spec ::address/city}]]
|
|
||||||
[form-builder/field-v2 {:field :state}
|
[form-builder/field-v2 {:field :state}
|
||||||
[:p.help "State"]
|
[:p.help "State"]
|
||||||
[:input.input {:type "text"
|
[:input.input {:type "text"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
||||||
(defn admin-side-bar [params ]
|
(defn admin-side-bar []
|
||||||
(let [ap @(re-frame/subscribe [::subs/active-page])]
|
(let [ap @(re-frame/subscribe [::subs/active-page])]
|
||||||
[:div
|
[:div
|
||||||
[:p.menu-label "General"]
|
[:p.menu-label "General"]
|
||||||
@@ -45,12 +45,6 @@
|
|||||||
[:a {:href (bidi/path-for routes/routes :admin-rules), :class (str "item" (active-when ap = :admin-rules))}
|
[:a {:href (bidi/path-for routes/routes :admin-rules), :class (str "item" (active-when ap = :admin-rules))}
|
||||||
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
[:span {:class "icon icon-cog-play-1" :style {:font-size "25px"}}]
|
||||||
[:span {:class "name"} "Rules"]]]
|
[:span {:class "name"} "Rules"]]]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[:ul ]]
|
[:ul ]]
|
||||||
[:p.menu-label "Import"]
|
[:p.menu-label "Import"]
|
||||||
[:ul.menu-list
|
[:ul.menu-list
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
(:require [auto-ap.views.utils :refer [dispatch-event]]
|
(:require [auto-ap.views.utils :refer [dispatch-event]]
|
||||||
[reagent.core :as r]))
|
[reagent.core :as r]))
|
||||||
|
|
||||||
(defn fa-icon [{:keys [event icon class on-click] :as params}]
|
(defn fa-icon [{:keys [event icon on-click] :as params}]
|
||||||
[:a.button (cond-> params
|
[:a.button (cond-> params
|
||||||
true (dissoc :event :icon)
|
true (dissoc :event :icon)
|
||||||
(and (not on-click)
|
(and (not on-click)
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn sl-icon [{:keys [event icon class on-click] :as params}]
|
(defn sl-icon [{:keys [event icon on-click] :as params}]
|
||||||
[:a.button (cond-> params
|
[:a.button (cond-> params
|
||||||
true (dissoc :event :icon)
|
true (dissoc :event :icon)
|
||||||
(and (not on-click)
|
(and (not on-click)
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
[:span.icon [:i.fa.fa-plus]]
|
[:span.icon [:i.fa.fa-plus]]
|
||||||
[:span name]])
|
[:span name]])
|
||||||
|
|
||||||
(defn dropdown [{:keys [event icon class on-click] :as params}]
|
(defn dropdown [{:keys [event on-click] :as params}]
|
||||||
[:a.button (cond-> params
|
[:a.button (cond-> params
|
||||||
true (dissoc :event :icon)
|
true (dissoc :event :icon)
|
||||||
(and (not on-click)
|
(and (not on-click)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[auto-ap.subs :as subs]))
|
[auto-ap.subs :as subs]))
|
||||||
|
|
||||||
(defn drop-down-contents [{:keys [id]} children ]
|
(defn drop-down-contents [{:keys [id]}]
|
||||||
(let [toggle-fn (fn [] (re-frame/dispatch [::events/toggle-menu id]))]
|
(let [toggle-fn (fn [] (re-frame/dispatch [::events/toggle-menu id]))]
|
||||||
(r/create-class {:component-did-mount (fn [] (.addEventListener js/document "click" toggle-fn))
|
(r/create-class {:component-did-mount (fn [] (.addEventListener js/document "click" toggle-fn))
|
||||||
:component-will-unmount (fn [] (.removeEventListener js/document "click" toggle-fn))
|
:component-will-unmount (fn [] (.removeEventListener js/document "click" toggle-fn))
|
||||||
@@ -13,8 +13,8 @@
|
|||||||
(fn [children]
|
(fn [children]
|
||||||
children)})))
|
children)})))
|
||||||
|
|
||||||
(defn drop-down [{:keys [ header id is-right? class]} child]
|
(defn drop-down [{:keys [ id ]} _]
|
||||||
(let [menu-active? (re-frame/subscribe [::subs/menu-active? id])]
|
(let [_ (re-frame/subscribe [::subs/menu-active? id])]
|
||||||
(r/create-class
|
(r/create-class
|
||||||
{:reagent-render (fn [{:keys [header id is-right? class] :or {is-right? true}} child]
|
{:reagent-render (fn [{:keys [header id is-right? class] :or {is-right? true}} child]
|
||||||
(let [menu-active? @(re-frame/subscribe [::subs/menu-active? id])]
|
(let [menu-active? @(re-frame/subscribe [::subs/menu-active? id])]
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
(ns auto-ap.views.components.grid
|
(ns auto-ap.views.components.grid
|
||||||
(:require [reagent.core :as r]
|
(:require
|
||||||
[auto-ap.views.utils :refer [appearing copy-to-clipboard]]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.utils :refer [default-pagination-size]]
|
[auto-ap.utils :refer [default-pagination-size]]
|
||||||
[react :as react]
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
[re-frame.core :as re-frame]
|
[auto-ap.views.utils :refer [copy-to-clipboard]]
|
||||||
[auto-ap.views.pages.data-page :as data-page]
|
[re-frame.core :as re-frame]
|
||||||
[auto-ap.views.components.buttons :as buttons]
|
[react :as react]
|
||||||
[auto-ap.subs :as subs]
|
[reagent.core :as r]))
|
||||||
[react-dom :as react-dom]))
|
|
||||||
(set! *warn-on-infer* true)
|
(set! *warn-on-infer* true)
|
||||||
|
|
||||||
(defonce ^js/React.Context grid-context ( react/createContext "default"))
|
(defonce ^js/React.Context grid-context ( react/createContext "default"))
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
:else
|
:else
|
||||||
y))
|
y))
|
||||||
|
|
||||||
(defn paginator [{:keys [start per-page end count total on-change] :as g}]
|
(defn paginator [{:keys [start per-page end total on-change]}]
|
||||||
(let [per-page (or per-page default-pagination-size)
|
(let [per-page (or per-page default-pagination-size)
|
||||||
max-buttons 5
|
max-buttons 5
|
||||||
buttons-before (Math/floor (/ max-buttons 2))
|
buttons-before (Math/floor (/ max-buttons 2))
|
||||||
@@ -72,7 +72,7 @@
|
|||||||
[:li
|
[:li
|
||||||
[:a.pagination-link {:class (when (= current-page x)
|
[:a.pagination-link {:class (when (= current-page x)
|
||||||
"is-current")
|
"is-current")
|
||||||
:on-click (fn [e] (on-change {:start (* x per-page)
|
:on-click (fn [_] (on-change {:start (* x per-page)
|
||||||
:per-page per-page}))}
|
:per-page per-page}))}
|
||||||
(inc x)]]))
|
(inc x)]]))
|
||||||
|
|
||||||
@@ -117,11 +117,11 @@
|
|||||||
[:a.tag.is-medium.is-delete {:on-click (fn []
|
[:a.tag.is-medium.is-delete {:on-click (fn []
|
||||||
(on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])
|
(on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])
|
||||||
|
|
||||||
(defn controls [{:keys [start end count total per-page action-buttons] :as para}]
|
(defn controls [{:keys [start end count total action-buttons]}]
|
||||||
(let [children (r/children (r/current-component))]
|
(let [children (r/children (r/current-component))]
|
||||||
[:> Consumer {}
|
[:> Consumer {}
|
||||||
(fn [consume]
|
(fn [consume]
|
||||||
(let [{:strs [on-params-change params] :as consume} (js->clj consume)]
|
(let [{:strs [on-params-change params]} (js->clj consume)]
|
||||||
(r/as-element (into
|
(r/as-element (into
|
||||||
[:div {:style {:margin-bottom "1rem"}}
|
[:div {:style {:margin-bottom "1rem"}}
|
||||||
[:div.level
|
[:div.level
|
||||||
@@ -174,8 +174,8 @@
|
|||||||
:checked (if (get checked id)
|
:checked (if (get checked id)
|
||||||
"checked"
|
"checked"
|
||||||
"")
|
"")
|
||||||
:on-change (fn [x e]
|
:on-change (fn [_ _]
|
||||||
(if id
|
(when id
|
||||||
(let [checked (or checked #{})]
|
(let [checked (or checked #{})]
|
||||||
;; TODO only map once everything is moved over to data-page
|
;; TODO only map once everything is moved over to data-page
|
||||||
(if (map? checked)
|
(if (map? checked)
|
||||||
@@ -199,7 +199,7 @@
|
|||||||
]])))
|
]])))
|
||||||
(map r/as-element children))))]))
|
(map r/as-element children))))]))
|
||||||
|
|
||||||
(defn button-cell [params]
|
(defn button-cell []
|
||||||
(apply r/create-element "td" #js {"style" #js {"overflow" "visible"}}
|
(apply r/create-element "td" #js {"style" #js {"overflow" "visible"}}
|
||||||
(map r/as-element (r/children (r/current-component)))))
|
(map r/as-element (r/children (r/current-component)))))
|
||||||
|
|
||||||
@@ -244,13 +244,13 @@
|
|||||||
|
|
||||||
children)))))]))
|
children)))))]))
|
||||||
|
|
||||||
(defn sortable-header-cell [{:keys [style class sort-key sort-name asc]}]
|
(defn sortable-header-cell [{:keys [style class sort-key sort-name]}]
|
||||||
(let [children (r/children (r/current-component))]
|
(let [children (r/children (r/current-component))]
|
||||||
[:> Consumer {}
|
[:> Consumer {}
|
||||||
(fn [consume]
|
(fn [consume]
|
||||||
(let [{:strs [on-params-change params] :as consume} (js->clj consume)]
|
(let [{:strs [on-params-change params]} (js->clj consume)]
|
||||||
(r/as-element (conj (into
|
(r/as-element (conj (into
|
||||||
[:th {:on-click (fn [e]
|
[:th {:on-click (fn [_]
|
||||||
(on-params-change
|
(on-params-change
|
||||||
(toggle-sort-by {:sort (:sort params)} sort-key sort-name)))
|
(toggle-sort-by {:sort (:sort params)} sort-key sort-name)))
|
||||||
:style (assoc style
|
:style (assoc style
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
:ref (fn [n]
|
:ref (fn [n]
|
||||||
(reset! !child n))
|
(reset! !child n))
|
||||||
:tab-index 0
|
:tab-index 0
|
||||||
:onBlur (fn [e]
|
:onBlur (fn [_]
|
||||||
(js/setTimeout (fn []
|
(js/setTimeout (fn []
|
||||||
(println @!child)
|
(println @!child)
|
||||||
(println (.-activeElement js/document))
|
(println (.-activeElement js/document))
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
(re-frame/dispatch [::events/swap-client client]))
|
(re-frame/dispatch [::events/swap-client client]))
|
||||||
} name])]]))
|
} name])]]))
|
||||||
|
|
||||||
(defn navbar [ap]
|
(defn navbar []
|
||||||
(let [navbar-menu-shown? (r/atom false)]
|
(let [navbar-menu-shown? (r/atom false)]
|
||||||
(fn [ap]
|
(fn [ap]
|
||||||
(let [user (re-frame/subscribe [::subs/user])
|
(let [user (re-frame/subscribe [::subs/user])
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
(ns auto-ap.views.components.modal
|
(ns auto-ap.views.components.modal
|
||||||
(:require [re-frame.core :as re-frame]
|
(:require
|
||||||
[reagent.core :as r]
|
[auto-ap.status :as status]
|
||||||
[auto-ap.events :as events]
|
[auto-ap.views.utils :refer [appearing dispatch-event]]
|
||||||
[auto-ap.subs :as subs]
|
[re-frame.core :as re-frame]))
|
||||||
[auto-ap.status :as status]
|
|
||||||
[auto-ap.views.utils :refer [with-keys appearing dispatch-event]]))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::modal-state
|
::modal-state
|
||||||
@@ -18,7 +16,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::modal-closed
|
::modal-closed
|
||||||
(fn [{:keys [db]} [_ state]]
|
(fn [{:keys [db]} [_ _]]
|
||||||
(let [[_ status-id] (some-> db ::state :confirm :status-from )]
|
(let [[_ status-id] (some-> db ::state :confirm :status-from )]
|
||||||
(cond-> {:db (dissoc db ::state)}
|
(cond-> {:db (dissoc db ::state)}
|
||||||
status-id (assoc :dispatch [::status/completed status-id])))))
|
status-id (assoc :dispatch [::status/completed status-id])))))
|
||||||
@@ -27,7 +25,7 @@
|
|||||||
(defn global-modal []
|
(defn global-modal []
|
||||||
(let [state (re-frame/subscribe [::modal-state])]
|
(let [state (re-frame/subscribe [::modal-state])]
|
||||||
(fn []
|
(fn []
|
||||||
(if (:visible? @state)
|
(when (:visible? @state)
|
||||||
(let [{:keys [title body status-from foot class cancel? confirm]} @state]
|
(let [{:keys [title body status-from foot class cancel? confirm]} @state]
|
||||||
[:div.modal.is-active (cond-> {}
|
[:div.modal.is-active (cond-> {}
|
||||||
class (assoc :class class))
|
class (assoc :class class))
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
(ns auto-ap.views.components.multi
|
(ns auto-ap.views.components.multi
|
||||||
(:require
|
(:require
|
||||||
[cemerick.url]
|
|
||||||
#_{:clj-kondo/ignore [:unused-namespace]}
|
#_{:clj-kondo/ignore [:unused-namespace]}
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[react :as react]
|
|
||||||
[auto-ap.entities.shared :as shared]
|
|
||||||
[auto-ap.views.utils :refer [appearing-group]]
|
[auto-ap.views.utils :refer [appearing-group]]
|
||||||
[auto-ap.forms.builder :as form-builder]))
|
[auto-ap.forms.builder :as form-builder]))
|
||||||
|
|
||||||
|
|
||||||
;; TODO just embrace the fact that it will need to be remounted, and use index based keys
|
;; TODO just embrace the fact that it will need to be remounted, and use index based keys
|
||||||
(defn multi-field-v2-internal [{:keys [template key-fn allow-change? disable-new? disable-remove? schema on-change disabled new-text] prop-value :value :as props} ]
|
(defn multi-field-v2-internal [{:keys [template key-fn allow-change? disable-new? disable-remove? schema on-change disabled new-text] prop-value :value } ]
|
||||||
(let [prop-value (if (seq prop-value)
|
(let [prop-value (if (seq prop-value)
|
||||||
(vec prop-value)
|
(vec prop-value)
|
||||||
[])]
|
[])]
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
(ns auto-ap.views.components.paginator
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[auto-ap.subs :as subs]
|
|
||||||
[auto-ap.views.utils :refer [date->str]]
|
|
||||||
[reagent.core :as reagent]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[cljs-time.format :as format]))
|
|
||||||
|
|
||||||
|
|
||||||
(defn bound [x y z]
|
|
||||||
(cond
|
|
||||||
(< z x)
|
|
||||||
x
|
|
||||||
(< y x)
|
|
||||||
x
|
|
||||||
(> y z)
|
|
||||||
z
|
|
||||||
:else
|
|
||||||
y))
|
|
||||||
|
|
||||||
(defn paginator [{:keys [start end count total on-change]}]
|
|
||||||
(let [per-page 100
|
|
||||||
max-buttons 5
|
|
||||||
buttons-before (Math/floor (/ max-buttons 2))
|
|
||||||
total-pages (Math/ceil (/ total per-page))
|
|
||||||
current-page (Math/floor (/ start per-page))
|
|
||||||
first-page-button (bound 0 (- current-page buttons-before) (- total-pages max-buttons))
|
|
||||||
all-buttons (into [] (for [x (range total-pages)]
|
|
||||||
^{:key x}
|
|
||||||
[:li
|
|
||||||
[:a.pagination-link {:class (when (= current-page x)
|
|
||||||
"is-current")
|
|
||||||
:on-click (fn [e] (on-change {:start (* x per-page)}))}
|
|
||||||
(inc x)]]))
|
|
||||||
|
|
||||||
|
|
||||||
last-page-button (Math/min total-pages (+ max-buttons first-page-button))
|
|
||||||
|
|
||||||
extended-last-page-button (when (not= last-page-button total-pages)
|
|
||||||
(list
|
|
||||||
^ {:key -1} [:li [:span.pagination-ellipsis "…"]]
|
|
||||||
^ {:key -2} (last all-buttons)))
|
|
||||||
|
|
||||||
extended-first-page-button (when (not= first-page-button 0)
|
|
||||||
(list
|
|
||||||
^{:key -1} (first all-buttons)
|
|
||||||
^{:key -2} [:li [:span.pagination-ellipsis "…"]]))]
|
|
||||||
|
|
||||||
|
|
||||||
[:nav.pagination {:role "pagination"}
|
|
||||||
[:ul.pagination-list
|
|
||||||
extended-first-page-button
|
|
||||||
(apply list (subvec all-buttons first-page-button last-page-button))
|
|
||||||
extended-last-page-button
|
|
||||||
"Showing " (Math/min (inc start) total) "-" end "/" total]]))
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
(ns auto-ap.views.components.percentage-field
|
(ns auto-ap.views.components.percentage-field
|
||||||
(:require [reagent.core :as r]
|
(:require [reagent.core :as r]
|
||||||
[auto-ap.views.utils :refer [->short$]]
|
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[react :as react]))
|
[react :as react]))
|
||||||
(def good-% #"^\d{1,3}$")
|
(def good-% #"^\d{1,3}$")
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
(ns auto-ap.views.components.sort-by-list
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[auto-ap.subs :as subs]
|
|
||||||
[auto-ap.views.utils :refer [date->str]]
|
|
||||||
[reagent.core :as reagent]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[cljs-time.format :as format]))
|
|
||||||
|
|
||||||
(defn sort-by-list [{:keys [sort on-change]}]
|
|
||||||
[:div.field.is-grouped.is-grouped-multiline
|
|
||||||
(for [{:keys [sort-key sort-name asc]} sort]
|
|
||||||
^{:key sort-key}
|
|
||||||
[:div.control
|
|
||||||
[:div.tags.has-addons
|
|
||||||
[:div.tag.is-medium [:span.icon (if asc
|
|
||||||
[:i.fa.fa-sort-up]
|
|
||||||
[:i.fa.fa-sort-down])]
|
|
||||||
[:span sort-name] ]
|
|
||||||
[:a.tag.is-medium.is-delete {:on-click (fn []
|
|
||||||
(on-change {:sort (filter #(not= sort-key (:sort-key %)) sort)}))}]]])])
|
|
||||||
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
(ns auto-ap.views.components.sorter
|
|
||||||
(:require [re-frame.core :as re-frame]
|
|
||||||
[auto-ap.subs :as subs]
|
|
||||||
[auto-ap.views.utils :refer [date->str]]
|
|
||||||
[reagent.core :as reagent]
|
|
||||||
[clojure.string :as str]
|
|
||||||
[cljs-time.format :as format]))
|
|
||||||
(defn toggle-sort-by [params sort-key sort-name asc]
|
|
||||||
(let [[found? sort] (reduce
|
|
||||||
(fn [[found? sort] sort-item]
|
|
||||||
(if (= sort-key (:sort-key sort-item))
|
|
||||||
[true (conj sort
|
|
||||||
(update sort-item :asc not))]
|
|
||||||
[found? (conj sort sort-item)]))
|
|
||||||
[false []]
|
|
||||||
(:sort params))
|
|
||||||
sort (if found?
|
|
||||||
sort
|
|
||||||
(conj sort {:sort-key sort-key
|
|
||||||
:sort-name sort-name
|
|
||||||
:asc true}))]
|
|
||||||
|
|
||||||
(-> params
|
|
||||||
(assoc :sort sort))))
|
|
||||||
|
|
||||||
(defn sort-icon [which sort asc]
|
|
||||||
(let [sort-item (first (filter #(= which (:sort-key %)) sort))]
|
|
||||||
(cond
|
|
||||||
(and sort-item (:asc sort-item))
|
|
||||||
[:span.icon
|
|
||||||
[:i.fa.fa-sort-up]]
|
|
||||||
|
|
||||||
(and sort-item (not (:asc sort-item)))
|
|
||||||
[:span.icon
|
|
||||||
[:i.fa.fa-sort-down]]
|
|
||||||
|
|
||||||
:else
|
|
||||||
[:span.icon
|
|
||||||
[:i.fa.fa-sort]])))
|
|
||||||
|
|
||||||
|
|
||||||
(defn sorted-column [{:keys [on-sort sort-key sort sort-name asc style class]} & rest]
|
|
||||||
[:th {:on-click (fn [e]
|
|
||||||
(on-sort
|
|
||||||
(toggle-sort-by {:sort sort} sort-key sort-name asc)))
|
|
||||||
:style style
|
|
||||||
:class class}
|
|
||||||
rest
|
|
||||||
(sort-icon sort-key sort asc)])
|
|
||||||
@@ -166,7 +166,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn form-content [{:keys [data]}]
|
(defn form-content []
|
||||||
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
(let [is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
||||||
clients @(re-frame/subscribe [::subs/client-refs])]
|
clients @(re-frame/subscribe [::subs/client-refs])]
|
||||||
[form-builder/builder {:submit-event [::save]
|
[form-builder/builder {:submit-event [::save]
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
(ns auto-ap.views.pages.admin
|
(ns auto-ap.views.pages.admin
|
||||||
(:require-macros [cljs.core.async.macros :refer [go]])
|
(:require
|
||||||
(:require [re-frame.core :as re-frame]
|
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||||
[reagent.core :as reagent]
|
[auto-ap.views.components.layouts :refer [side-bar-layout]]))
|
||||||
[auto-ap.subs :as subs]
|
|
||||||
[auto-ap.events :as events]
|
|
||||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
|
||||||
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
|
||||||
[auto-ap.views.utils :refer [login-url]]))
|
|
||||||
|
|
||||||
(defn admin-page []
|
(defn admin-page []
|
||||||
[side-bar-layout {:side-bar [admin-side-bar {}]
|
[side-bar-layout {:side-bar [admin-side-bar {}]
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
(ns auto-ap.views.pages.admin.accounts
|
(ns auto-ap.views.pages.admin.accounts
|
||||||
(:require [auto-ap.forms :as forms]
|
(:require
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.effects.forward :as forward]
|
||||||
[auto-ap.utils :refer [replace-by]]
|
[auto-ap.forms :as forms]
|
||||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||||
[auto-ap.views.pages.admin.accounts.side-bar :as side-bar]
|
[auto-ap.views.components.buttons :as buttons]
|
||||||
[auto-ap.views.pages.admin.accounts.table :as table]
|
[auto-ap.views.components.layouts
|
||||||
[auto-ap.views.utils :refer [dispatch-event action-cell-width with-user]]
|
:refer [appearing-side-bar side-bar-layout]]
|
||||||
[auto-ap.views.components.layouts
|
[auto-ap.views.pages.admin.accounts.form :as account-form]
|
||||||
:refer
|
[auto-ap.views.pages.admin.accounts.side-bar :as side-bar]
|
||||||
[appearing-side-bar side-bar-layout]]
|
[auto-ap.views.pages.admin.accounts.table :as table]
|
||||||
[auto-ap.views.pages.admin.accounts.form :as account-form]
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
[re-frame.core :as re-frame]
|
[auto-ap.views.utils :refer [with-user]]
|
||||||
[auto-ap.views.components.grid :as grid]
|
[clojure.set :as set]
|
||||||
[auto-ap.status :as status]
|
[re-frame.core :as re-frame]
|
||||||
[auto-ap.views.components.buttons :as buttons]
|
[reagent.core :as reagent]
|
||||||
[reagent.core :as reagent]
|
[vimsical.re-frame.fx.track :as track]))
|
||||||
[clojure.string :as str]
|
|
||||||
[vimsical.re-frame.fx.track :as track]
|
|
||||||
[auto-ap.views.pages.data-page :as data-page]
|
|
||||||
[clojure.set :as set]
|
|
||||||
[auto-ap.effects.forward :as forward]))
|
|
||||||
|
|
||||||
(def default-read [:numeric-code :name :location :type :account_set :applicability :id [:client-overrides [:name [:client [:name :id]]]]])
|
(def default-read [:numeric-code :name :location :type :account_set :applicability :id [:client-overrides [:name [:client [:name :id]]]]])
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
(ns auto-ap.views.pages.admin.accounts.side-bar
|
(ns auto-ap.views.pages.admin.accounts.side-bar
|
||||||
(:require
|
(:require
|
||||||
[re-frame.core :as re-frame]
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
[auto-ap.subs :as subs]
|
|
||||||
[auto-ap.views.utils :refer [dispatch-value-change]]
|
[auto-ap.views.utils :refer [dispatch-value-change]]
|
||||||
[auto-ap.views.pages.data-page :as data-page]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
|
|
||||||
(defn accounts-side-bar [{:keys [data-page]}]
|
(defn accounts-side-bar [{:keys [data-page]}]
|
||||||
[:div
|
[:div
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
(ns auto-ap.views.pages.admin.accounts.table
|
(ns auto-ap.views.pages.admin.accounts.table
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.status :as status]
|
|
||||||
[auto-ap.views.components.buttons :as buttons]
|
[auto-ap.views.components.buttons :as buttons]
|
||||||
[auto-ap.views.components.grid :as grid]
|
[auto-ap.views.components.grid :as grid]
|
||||||
[auto-ap.views.pages.admin.accounts.form :as account-form]
|
[auto-ap.views.pages.admin.accounts.form :as account-form]
|
||||||
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
[auto-ap.views.utils :refer [action-cell-width]]
|
[auto-ap.views.utils :refer [action-cell-width]]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]))
|
||||||
[auto-ap.views.pages.data-page :as data-page]))
|
|
||||||
|
|
||||||
(defn accounts-table [{:keys [data-page]}]
|
(defn accounts-table [{:keys [data-page]}]
|
||||||
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])]
|
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])]
|
||||||
@@ -24,7 +23,7 @@
|
|||||||
[grid/header-cell {} "Location"]
|
[grid/header-cell {} "Location"]
|
||||||
[grid/header-cell {:style {:width (action-cell-width 1)}} ]]]
|
[grid/header-cell {:style {:width (action-cell-width 1)}} ]]]
|
||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [id numeric-code name type location class] :as account} (:data data)]
|
(for [{:keys [id numeric-code name type location] :as account} (:data data)]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[grid/row {:class (:class account) :id id}
|
[grid/row {:class (:class account) :id id}
|
||||||
[grid/cell {} numeric-code]
|
[grid/cell {} numeric-code]
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
(ns auto-ap.views.pages.admin.clients.form
|
(ns auto-ap.views.pages.admin.clients.form
|
||||||
(:require
|
(:require
|
||||||
[auto-ap.entities.clients :as entity]
|
|
||||||
[auto-ap.events :as events]
|
[auto-ap.events :as events]
|
||||||
[auto-ap.forms :as forms]
|
[auto-ap.forms :as forms]
|
||||||
[auto-ap.forms.builder :as form-builder]
|
[auto-ap.forms.builder :as form-builder]
|
||||||
@@ -21,7 +20,6 @@
|
|||||||
[cljs-time.core :as t]
|
[cljs-time.core :as t]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[reagent.core :as r]
|
[reagent.core :as r]
|
||||||
[react-signature-canvas]
|
|
||||||
[vimsical.re-frame.cofx.inject :as inject]
|
[vimsical.re-frame.cofx.inject :as inject]
|
||||||
[auto-ap.schema :as schema]
|
[auto-ap.schema :as schema]
|
||||||
[malli.core :as m]))
|
[malli.core :as m]))
|
||||||
@@ -178,7 +176,7 @@
|
|||||||
:identifier identifier
|
:identifier identifier
|
||||||
:amount amount})
|
:amount amount})
|
||||||
(:forecasted-transactions new-client-data))
|
(:forecasted-transactions new-client-data))
|
||||||
:bank-accounts (map-indexed (fn [i {:keys [number name check-number plaid-account intuit-bank-account include-in-reports type id code numeric-code start-date bank-name routing bank-code new? sort-order visible yodlee-account-id locations yodlee-account use-date-instead-of-post-date]}]
|
:bank-accounts (map-indexed (fn [i {:keys [number name check-number plaid-account intuit-bank-account include-in-reports type id code numeric-code start-date bank-name routing bank-code new? visible locations yodlee-account use-date-instead-of-post-date]}]
|
||||||
{:number number
|
{:number number
|
||||||
:name name
|
:name name
|
||||||
:check-number check-number
|
:check-number check-number
|
||||||
@@ -526,8 +524,7 @@
|
|||||||
"Client code"
|
"Client code"
|
||||||
[:input.input {:type "code"
|
[:input.input {:type "code"
|
||||||
:style {:width "5em"}
|
:style {:width "5em"}
|
||||||
:disabled (boolean (:id new-client))
|
:disabled (boolean (:id new-client))}]]
|
||||||
:spec ::entity/code}]]
|
|
||||||
|
|
||||||
[form-builder/field-v2 {:field :locations}
|
[form-builder/field-v2 {:field :locations}
|
||||||
"Locations"
|
"Locations"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
::filters
|
::filters
|
||||||
:<- [::specific-filters]
|
:<- [::specific-filters]
|
||||||
:<- [::subs/query-params]
|
:<- [::subs/query-params]
|
||||||
(fn [[specific-filters vendors-by-id query-params] ]
|
(fn [[specific-filters _ query-params] ]
|
||||||
(let [url-filters (-> query-params
|
(let [url-filters (-> query-params
|
||||||
(select-keys #{:name
|
(select-keys #{:name
|
||||||
:code}))
|
:code}))
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
:<- [::settled-filters]
|
:<- [::settled-filters]
|
||||||
:<- [::filters]
|
:<- [::filters]
|
||||||
:<- [::subs/active-page]
|
:<- [::subs/active-page]
|
||||||
(fn [[settled-filters filters ap ]]
|
(fn [[settled-filters filters _ ]]
|
||||||
(let [filters (or settled-filters filters)]
|
(let [filters (or settled-filters filters)]
|
||||||
{:name (:name filters)
|
{:name (:name filters)
|
||||||
:code (:code filters)})))
|
:code (:code filters)})))
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::filters-settled
|
::filters-settled
|
||||||
(fn [{:keys [db]} [_ & params]]
|
(fn [{:keys [db]} _]
|
||||||
{:db (assoc db ::settled-filters @(re-frame/subscribe [::filters]))}))
|
{:db (assoc db ::settled-filters @(re-frame/subscribe [::filters]))}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
|
|||||||
@@ -1,29 +1,22 @@
|
|||||||
(ns auto-ap.views.pages.admin.import-batches
|
(ns auto-ap.views.pages.admin.import-batches
|
||||||
(:require [auto-ap.forms :as forms]
|
(:require
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.status :as status]
|
||||||
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.components.layouts :refer [appearing-side-bar side-bar-layout]]
|
[auto-ap.views.components.admin.side-bar :refer [admin-side-bar]]
|
||||||
[auto-ap.views.pages.admin.import-batches.table :as table]
|
[auto-ap.views.components.layouts :refer [side-bar-layout]]
|
||||||
[auto-ap.views.utils :refer [dispatch-event with-user]]
|
[auto-ap.views.pages.admin.import-batches.table :as table]
|
||||||
[vimsical.re-frame.cofx.inject :as inject]
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
[vimsical.re-frame.fx.track :as track]
|
[auto-ap.views.utils :refer [dispatch-event with-user]]
|
||||||
[auto-ap.events :as events]
|
[clojure.set :as set]
|
||||||
[auto-ap.utils :refer [replace-by merge-by]]
|
[re-frame.core :as re-frame]
|
||||||
[re-frame.core :as re-frame]
|
[vimsical.re-frame.fx.track :as track]))
|
||||||
[auto-ap.status :as status]
|
|
||||||
[auto-ap.effects.forward :as forward]
|
|
||||||
[auto-ap.views.pages.data-page :as data-page]
|
|
||||||
[clojure.set :as set]
|
|
||||||
[auto-ap.views.components.buttons :as buttons]
|
|
||||||
[clojure.string :as str]))
|
|
||||||
|
|
||||||
|
|
||||||
(def default-read [:user-name :date :source :status :id :imported :suppressed :extant])
|
(def default-read [:user-name :date :source :status :id :imported :suppressed :extant])
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::params-change
|
::params-change
|
||||||
[with-user ]
|
[with-user ]
|
||||||
(fn [{:keys [db user] :as cofx} [_ params]]
|
(fn [{:keys [user]} [_ params]]
|
||||||
{:graphql {:token user
|
{:graphql {:token user
|
||||||
:owns-state {:single [::data-page/page ::page]}
|
:owns-state {:single [::data-page/page ::page]}
|
||||||
:query-obj {:venia/queries [{:query/data [:import_batch_page
|
:query-obj {:venia/queries [{:query/data [:import_batch_page
|
||||||
@@ -54,30 +47,13 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx ::request-intuit
|
(re-frame/reg-event-fx ::request-intuit
|
||||||
[with-user ]
|
[with-user ]
|
||||||
(fn [{:keys [db user] :as cofx} [_ params]]
|
(fn [{:keys [user]} [_ _]]
|
||||||
{:graphql {:token user
|
{:graphql {:token user
|
||||||
:owns-state {:single ::intuit}
|
:owns-state {:single ::intuit}
|
||||||
:query "mutation RequestIntuitImport{request_import(which: \":intuit\")}"
|
:query "mutation RequestIntuitImport{request_import(which: \":intuit\")}"
|
||||||
:on-success [::success-intuit]
|
:on-success [::success-intuit]
|
||||||
}}))
|
}}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
|
||||||
::success-yodlee
|
|
||||||
(fn [db [_ n]]
|
|
||||||
(assoc db ::msg (str "Your job " (:request-import n) " has been scheduled." ))))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::request-yodlee
|
|
||||||
[with-user ]
|
|
||||||
(fn [{:keys [db user] :as cofx} [_ params]]
|
|
||||||
{:graphql {:token user
|
|
||||||
:owns-state {:single ::yodlee}
|
|
||||||
:query "mutation RequestIntuitImport{request_import(which: \":yodlee\")}"
|
|
||||||
:on-success [::success-yodlee]
|
|
||||||
}}))
|
|
||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::success-yodlee2
|
::success-yodlee2
|
||||||
(fn [db [_ n]]
|
(fn [db [_ n]]
|
||||||
@@ -86,7 +62,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::request-yodlee2
|
::request-yodlee2
|
||||||
[with-user ]
|
[with-user ]
|
||||||
(fn [{:keys [db user] :as cofx} [_ params]]
|
(fn [{:keys [user]} [_ _]]
|
||||||
{:graphql {:token user
|
{:graphql {:token user
|
||||||
:owns-state {:single ::yodlee2}
|
:owns-state {:single ::yodlee2}
|
||||||
:query "mutation RequestIntuitImport{request_import(which: \":yodlee2\")}"
|
:query "mutation RequestIntuitImport{request_import(which: \":yodlee2\")}"
|
||||||
@@ -103,7 +79,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::request-plaid
|
::request-plaid
|
||||||
[with-user ]
|
[with-user ]
|
||||||
(fn [{:keys [db user] :as cofx} [_ params]]
|
(fn [{:keys [user]} [_ _]]
|
||||||
{:graphql {:token user
|
{:graphql {:token user
|
||||||
:owns-state {:single ::plaid}
|
:owns-state {:single ::plaid}
|
||||||
:query "mutation RequestIntuitImport{request_import(which: \":plaid\")}"
|
:query "mutation RequestIntuitImport{request_import(which: \":plaid\")}"
|
||||||
@@ -112,7 +88,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::mounted
|
::mounted
|
||||||
(fn [{:keys [db]}]
|
(fn [_]
|
||||||
{::track/register {:id ::params
|
{::track/register {:id ::params
|
||||||
:subscription [::data-page/params ::page]
|
:subscription [::data-page/params ::page]
|
||||||
:event-fn (fn [params]
|
:event-fn (fn [params]
|
||||||
@@ -131,7 +107,6 @@
|
|||||||
(fn []
|
(fn []
|
||||||
(let [user @(re-frame/subscribe [::subs/user])
|
(let [user @(re-frame/subscribe [::subs/user])
|
||||||
intuit-request-import-status @(re-frame/subscribe [::status/single ::intuit])
|
intuit-request-import-status @(re-frame/subscribe [::status/single ::intuit])
|
||||||
yodlee-request-import-status @(re-frame/subscribe [::status/single ::yodlee])
|
|
||||||
yodlee2-request-import-status @(re-frame/subscribe [::status/single ::yodlee2])
|
yodlee2-request-import-status @(re-frame/subscribe [::status/single ::yodlee2])
|
||||||
plaid-request-import-status @(re-frame/subscribe [::status/single ::plaid])
|
plaid-request-import-status @(re-frame/subscribe [::status/single ::plaid])
|
||||||
message @(re-frame/subscribe [::msg])]
|
message @(re-frame/subscribe [::msg])]
|
||||||
@@ -143,13 +118,7 @@
|
|||||||
[:div
|
[:div
|
||||||
[:div.is-pulled-right
|
[:div.is-pulled-right
|
||||||
[:div.buttons
|
[:div.buttons
|
||||||
[:button.button.is-primary-two {:aria-haspopup true
|
|
||||||
:type "button"
|
|
||||||
:on-click (dispatch-event [::request-yodlee])
|
|
||||||
:disabled (status/disabled-for yodlee-request-import-status)
|
|
||||||
:class (status/class-for yodlee-request-import-status)}
|
|
||||||
|
|
||||||
"Start Yodlee Import"]
|
|
||||||
[:button.button.is-primary-two {:aria-haspopup true
|
[:button.button.is-primary-two {:aria-haspopup true
|
||||||
:type "button"
|
:type "button"
|
||||||
:on-click (dispatch-event [::request-yodlee2])
|
:on-click (dispatch-event [::request-yodlee2])
|
||||||
|
|||||||
@@ -31,13 +31,7 @@
|
|||||||
(fn [[specific-table-params query-params]]
|
(fn [[specific-table-params query-params]]
|
||||||
(merge (select-keys query-params #{:start :sort}) specific-table-params )))
|
(merge (select-keys query-params #{:start :sort}) specific-table-params )))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(defn table* [{:keys [data-page]}]
|
||||||
::params-changed
|
|
||||||
[(re-frame/path [::table-params])]
|
|
||||||
(fn [{table-params :db} [_ params :as z]]
|
|
||||||
{:db (merge table-params params)}))
|
|
||||||
|
|
||||||
(defn table* [{:keys [id data-page]}]
|
|
||||||
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])]
|
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])]
|
||||||
[grid/grid {:data-page data-page
|
[grid/grid {:data-page data-page
|
||||||
:column-count 6}
|
:column-count 6}
|
||||||
@@ -82,7 +76,7 @@
|
|||||||
:icon "fa-external-link"}]]
|
:icon "fa-external-link"}]]
|
||||||
])]]]))
|
])]]]))
|
||||||
|
|
||||||
(defn table [params]
|
(defn table []
|
||||||
(r/create-class {:component-will-unmount (dispatch-event [::unmounted])
|
(r/create-class {:component-will-unmount (dispatch-event [::unmounted])
|
||||||
:reagent-render (fn [params]
|
:reagent-render (fn [params]
|
||||||
[table* params])}))
|
[table* params])}))
|
||||||
|
|||||||
@@ -1,46 +1,24 @@
|
|||||||
(ns auto-ap.views.pages.admin.plaid.table
|
(ns auto-ap.views.pages.admin.plaid.table
|
||||||
(:require [auto-ap.status :as status]
|
(:require
|
||||||
[auto-ap.subs :as subs]
|
[auto-ap.status :as status]
|
||||||
[auto-ap.views.components.buttons :as buttons]
|
[auto-ap.subs :as subs]
|
||||||
[auto-ap.views.components.grid :as grid]
|
[auto-ap.views.components.buttons :as buttons]
|
||||||
[auto-ap.views.components.modal :as modal]
|
[auto-ap.views.components.grid :as grid]
|
||||||
[auto-ap.views.pages.admin.users.form :as form]
|
[auto-ap.views.components.modal :as modal]
|
||||||
[auto-ap.views.utils :refer [->$ action-cell-width date->str with-user dispatch-event]]
|
[auto-ap.views.pages.data-page :as data-page]
|
||||||
[re-frame.core :as re-frame]
|
[auto-ap.views.utils
|
||||||
[auto-ap.forms :as forms]
|
:refer [->$ action-cell-width date->str dispatch-event with-user]]
|
||||||
[auto-ap.views.pages.data-page :as data-page]))
|
[re-frame.core :as re-frame]))
|
||||||
|
|
||||||
|
|
||||||
#_(re-frame/reg-event-fx
|
|
||||||
::refreshed
|
|
||||||
[with-user ]
|
|
||||||
(fn [{:keys [user db]} [_ provider-account ]]
|
|
||||||
;; this is tracked in yodlee main, for refreshing
|
|
||||||
{}))
|
|
||||||
|
|
||||||
#_(re-frame/reg-event-fx
|
|
||||||
::request-refresh
|
|
||||||
[with-user ]
|
|
||||||
(fn [{:keys [user db]} [_ provider-account client-id ]]
|
|
||||||
{:http {:token user
|
|
||||||
:method :post
|
|
||||||
:headers {"Content-Type" "application/edn"}
|
|
||||||
:uri (str "/api/yodlee2/provider-accounts/refresh/")
|
|
||||||
:owns-state {:multi ::refresh
|
|
||||||
:which provider-account}
|
|
||||||
:body {:client-id client-id
|
|
||||||
:provider-account-id provider-account}
|
|
||||||
:on-success [::refreshed provider-account]}}))
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::plaid-item-deleted
|
::plaid-item-deleted
|
||||||
(fn [{:keys [db]} [_ i result]]
|
(fn [_ _]
|
||||||
{:dispatch [::modal/modal-closed ]}))
|
{:dispatch [::modal/modal-closed ]}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::delete-plaid-item
|
::delete-plaid-item
|
||||||
[with-user ]
|
[with-user ]
|
||||||
(fn [{:keys [user db]} [_ id ]]
|
(fn [{:keys [user]} [_ id ]]
|
||||||
{:graphql {:token user
|
{:graphql {:token user
|
||||||
:owns-state {:single ::delete-plaid-item}
|
:owns-state {:single ::delete-plaid-item}
|
||||||
:query-obj
|
:query-obj
|
||||||
@@ -55,7 +33,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::delete-requested
|
::delete-requested
|
||||||
[with-user]
|
[with-user]
|
||||||
(fn [{:keys [user db]} [_ id]]
|
(fn [_ [_ id]]
|
||||||
{:dispatch
|
{:dispatch
|
||||||
[::modal/modal-requested {:title "Delete Provider account "
|
[::modal/modal-requested {:title "Delete Provider account "
|
||||||
:body [:div "Are you sure you want to delete " id "?"]
|
:body [:div "Are you sure you want to delete " id "?"]
|
||||||
@@ -66,21 +44,14 @@
|
|||||||
:close-event [::status/completed ::delete-plaid-item]}
|
:close-event [::status/completed ::delete-plaid-item]}
|
||||||
:cancel? true}]}))
|
:cancel? true}]}))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::params-changed
|
|
||||||
(fn [{:keys [db]} [_ p]]
|
|
||||||
{:db (assoc db ::params p)}))
|
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
::params
|
::params
|
||||||
(fn [db]
|
(fn [db]
|
||||||
(-> db ::params)))
|
(-> db ::params)))
|
||||||
|
|
||||||
(defn table [{:keys [status data-page]}]
|
(defn table [{:keys [data-page]}]
|
||||||
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])
|
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])
|
||||||
params @(re-frame/subscribe [::params])
|
is-admin? @(re-frame/subscribe [::subs/is-admin?])]
|
||||||
is-admin? @(re-frame/subscribe [::subs/is-admin?])
|
|
||||||
statuses @(re-frame/subscribe [::status/multi ::refresh])]
|
|
||||||
[grid/grid {:data-page data-page
|
[grid/grid {:data-page data-page
|
||||||
:column-count 5}
|
:column-count 5}
|
||||||
[grid/controls data]
|
[grid/controls data]
|
||||||
@@ -93,7 +64,7 @@
|
|||||||
[grid/header-cell {} "Accounts"]
|
[grid/header-cell {} "Accounts"]
|
||||||
[grid/header-cell {:style {:width (action-cell-width 1)}} ]]]
|
[grid/header-cell {:style {:width (action-cell-width 1)}} ]]]
|
||||||
[grid/body
|
[grid/body
|
||||||
(for [{:keys [id name accounts status last-updated clients] :as c} (:data data)]
|
(for [{:keys [id name accounts status last-updated] :as c} (:data data)]
|
||||||
^{:key (str name "-" id )}
|
^{:key (str name "-" id )}
|
||||||
[grid/row {:class (:class c) :id id}
|
[grid/row {:class (:class c) :id id}
|
||||||
[grid/cell {} id]
|
[grid/cell {} id]
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
(ns auto-ap.views.pages.admin.rules.results-modal
|
(ns auto-ap.views.pages.admin.rules.results-modal
|
||||||
(:require [auto-ap.events :as events]
|
(:require [auto-ap.views.utils :refer [date->str dispatch-event with-user]]
|
||||||
[auto-ap.subs :as subs]
|
|
||||||
[auto-ap.views.utils :refer [date->str dispatch-event with-user]]
|
|
||||||
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
|
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
|
||||||
[re-frame.core :as re-frame]
|
[re-frame.core :as re-frame]
|
||||||
[auto-ap.views.components.modal :as modal]
|
[auto-ap.views.components.modal :as modal]
|
||||||
@@ -37,11 +35,10 @@
|
|||||||
(count checked)
|
(count checked)
|
||||||
0)))
|
0)))
|
||||||
|
|
||||||
(defn results-body [params]
|
(defn results-body []
|
||||||
(let [runnable? @(re-frame/subscribe [::runnable?])
|
(let [runnable? @(re-frame/subscribe [::runnable?])
|
||||||
checked @(re-frame/subscribe [::checked])
|
checked @(re-frame/subscribe [::checked])
|
||||||
all-checked @(re-frame/subscribe [::all-checked])
|
all-checked @(re-frame/subscribe [::all-checked])]
|
||||||
checked-count @(re-frame/subscribe [::checked-count])]
|
|
||||||
[:table.table.is-fullwidth.compact
|
[:table.table.is-fullwidth.compact
|
||||||
[:tr
|
[:tr
|
||||||
(when runnable?
|
(when runnable?
|
||||||
@@ -71,7 +68,6 @@
|
|||||||
|
|
||||||
(defn foot [params]
|
(defn foot [params]
|
||||||
(let [runnable? @(re-frame/subscribe [::runnable?])
|
(let [runnable? @(re-frame/subscribe [::runnable?])
|
||||||
checked @(re-frame/subscribe [::checked])
|
|
||||||
all-checked @(re-frame/subscribe [::all-checked])
|
all-checked @(re-frame/subscribe [::all-checked])
|
||||||
checked-count @(re-frame/subscribe [::checked-count])
|
checked-count @(re-frame/subscribe [::checked-count])
|
||||||
status @(re-frame/subscribe [::status/single ::apply])]
|
status @(re-frame/subscribe [::status/single ::apply])]
|
||||||
@@ -115,8 +111,8 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-db
|
(re-frame/reg-event-db
|
||||||
::toggle-all
|
::toggle-all
|
||||||
(fn [db [_ which]]
|
(fn [db [_ _]]
|
||||||
(let [{::keys [all-checked checked test-results]} db]
|
(let [{::keys [all-checked test-results]} db]
|
||||||
(assoc db
|
(assoc db
|
||||||
::all-checked (not all-checked)
|
::all-checked (not all-checked)
|
||||||
::checked (if all-checked
|
::checked (if all-checked
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::run-clicked
|
::run-clicked
|
||||||
[with-user]
|
[with-user]
|
||||||
(fn [{:keys [user db]} [_ which]]
|
(fn [{:keys [user]} [_ which]]
|
||||||
{:graphql
|
{:graphql
|
||||||
{:token user
|
{:token user
|
||||||
:owns-state {:multi ::run
|
:owns-state {:multi ::run
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::succeeded-run
|
::succeeded-run
|
||||||
(fn [{:keys [db]} [_ transaction-rule-id result]]
|
(fn [_ [_ transaction-rule-id result]]
|
||||||
{:dispatch [::results-modal/opening (:run-transaction-rule result) transaction-rule-id true]}))
|
{:dispatch [::results-modal/opening (:run-transaction-rule result) transaction-rule-id true]}))
|
||||||
|
|
||||||
(re-frame/reg-sub
|
(re-frame/reg-sub
|
||||||
@@ -56,13 +56,6 @@
|
|||||||
(fn [[specific-table-params query-params]]
|
(fn [[specific-table-params query-params]]
|
||||||
(merge (select-keys query-params #{:start :sort}) specific-table-params )))
|
(merge (select-keys query-params #{:start :sort}) specific-table-params )))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
|
||||||
::params-changed
|
|
||||||
[(re-frame/path [::table-params])]
|
|
||||||
(fn [{table-params :db} [_ params :as z]]
|
|
||||||
{:db (merge table-params params)}))
|
|
||||||
|
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::deleted-transaction-rule
|
::deleted-transaction-rule
|
||||||
(fn []
|
(fn []
|
||||||
@@ -71,7 +64,7 @@
|
|||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::delete-transaction-rule
|
::delete-transaction-rule
|
||||||
[with-user]
|
[with-user]
|
||||||
(fn [{:keys [db user]} [_ id]]
|
(fn [{:keys [user]} [_ id]]
|
||||||
{:graphql
|
{:graphql
|
||||||
{:token user
|
{:token user
|
||||||
:owns-state {:single ::delete-transaction-rule}
|
:owns-state {:single ::delete-transaction-rule}
|
||||||
@@ -97,9 +90,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn table* [{:keys [id data-page]}]
|
(defn table* [{:keys [data-page]}]
|
||||||
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])
|
(let [{:keys [data]} @(re-frame/subscribe [::data-page/page data-page])
|
||||||
selected-client @(re-frame/subscribe [::subs/client])
|
_ @(re-frame/subscribe [::subs/client])
|
||||||
states @(re-frame/subscribe [::status/multi ::run])]
|
states @(re-frame/subscribe [::status/multi ::run])]
|
||||||
[grid/grid {:data-page data-page
|
[grid/grid {:data-page data-page
|
||||||
:column-count 6}
|
:column-count 6}
|
||||||
@@ -152,7 +145,7 @@
|
|||||||
[buttons/sl-icon {:event [::request-delete r] :icon :icon-bin-2}]
|
[buttons/sl-icon {:event [::request-delete r] :icon :icon-bin-2}]
|
||||||
[buttons/fa-icon {:event [::form/editing r] :icon :fa-pencil}]]]])]]]))
|
[buttons/fa-icon {:event [::form/editing r] :icon :fa-pencil}]]]])]]]))
|
||||||
|
|
||||||
(defn table [params]
|
(defn table []
|
||||||
(r/create-class {:component-will-unmount (dispatch-event [::unmounted])
|
(r/create-class {:component-will-unmount (dispatch-event [::unmounted])
|
||||||
:reagent-render (fn [params]
|
:reagent-render (fn [params]
|
||||||
[table* params])}))
|
[table* params])}))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
::unmounted
|
::unmounted
|
||||||
(fn [{:keys [db]} _]
|
(fn [_ _]
|
||||||
{::forward/dispose {:id ::edited-user}}))
|
{::forward/dispose {:id ::edited-user}}))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user