Supporting new action.
This commit is contained in:
@@ -78,7 +78,7 @@
|
|||||||
:plugins [[lein-figwheel "0.5.13"]
|
:plugins [[lein-figwheel "0.5.13"]
|
||||||
[lein-pdo "0.1.1"]
|
[lein-pdo "0.1.1"]
|
||||||
[cider/cider-nrepl "0.16.0"]]
|
[cider/cider-nrepl "0.16.0"]]
|
||||||
:jvm-opts ["-Dconfig=config/dev.edn" #_#_"--add-modules" "java.xml.bind"]}
|
:jvm-opts ["-Dconfig=config/dev.edn" "--add-modules" "java.xml.bind"]}
|
||||||
:uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]}
|
:uberjar {:prep-tasks [["cljsbuild" "once" "min"] "compile"]}
|
||||||
:provided {:dependencies [[org.clojure/clojurescript "1.10.238"]
|
:provided {:dependencies [[org.clojure/clojurescript "1.10.238"]
|
||||||
[reagent "0.7.0"]
|
[reagent "0.7.0"]
|
||||||
|
|||||||
BIN
resources/BellaSaratoga.jpg
Normal file
BIN
resources/BellaSaratoga.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
resources/Dan_Sig.1.jpg
Normal file
BIN
resources/Dan_Sig.1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
BIN
resources/MioVicino.jpg
Normal file
BIN
resources/MioVicino.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
BIN
resources/iguanas.jpg
Normal file
BIN
resources/iguanas.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
18
scratch-sessions/fix-account-id.sql
Normal file
18
scratch-sessions/fix-account-id.sql
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
(defn original-base-id [{:keys [date bank-account-id description-original company-id amount]} index]
|
||||||
|
(str (t/to-time-zone date (t/time-zone-for-offset -7)) "-" description-original "-" (double amount) "-" index "-" company-id))
|
||||||
|
|
||||||
|
(defn new-base-id [{:keys [date bank-account-id description-original company-id amount]} index]
|
||||||
|
(str (t/to-time-zone date (t/time-zone-for-offset -7)) "-" bank-account-id "-" description-original "-" (double amount) "-" index "-" company-id))
|
||||||
|
|
||||||
|
(defn replacements []
|
||||||
|
(loop [rows (get-graphql {:limit 100000})
|
||||||
|
replacements []
|
||||||
|
i 0]
|
||||||
|
(let [result (->> rows
|
||||||
|
(filter #(= (:id %) (sha-256 (original-base-id % i))))
|
||||||
|
(map #(assoc % :new-id (sha-256 (new-base-id % i)))))]
|
||||||
|
(if (= 10 i)
|
||||||
|
(into replacements result)
|
||||||
|
(recur rows (into replacements result ) (inc i))))))
|
||||||
@@ -307,11 +307,11 @@
|
|||||||
:resolve :mutation/print-checks}
|
:resolve :mutation/print-checks}
|
||||||
|
|
||||||
:add_handwritten_check {:type :check_result
|
:add_handwritten_check {:type :check_result
|
||||||
:args {:invoice_id {:type 'Int}
|
:args {:invoice_id {:type 'String}
|
||||||
:amount {:type 'Float}
|
:amount {:type 'Float}
|
||||||
:date {:type 'String}
|
:date {:type 'String}
|
||||||
:check_number {:type 'Int}
|
:check_number {:type 'Int}
|
||||||
:bank_account_id {:type 'Int}}
|
:bank_account_id {:type 'String}}
|
||||||
:resolve :mutation/add-handwritten-check}
|
:resolve :mutation/add-handwritten-check}
|
||||||
:edit_user {:type :user
|
:edit_user {:type :user
|
||||||
:args {:edit_user {:type :edit_user}}
|
:args {:edit_user {:type :edit_user}}
|
||||||
|
|||||||
@@ -6,22 +6,16 @@
|
|||||||
[com.walmartlabs.lacinia :refer [execute]]
|
[com.walmartlabs.lacinia :refer [execute]]
|
||||||
[com.walmartlabs.lacinia.executor :as executor]
|
[com.walmartlabs.lacinia.executor :as executor]
|
||||||
[com.walmartlabs.lacinia.resolve :as resolve]
|
[com.walmartlabs.lacinia.resolve :as resolve]
|
||||||
[auto-ap.db.invoices-checks :as invoices-checks]
|
|
||||||
[auto-ap.db.checks :as checks]
|
|
||||||
[auto-ap.datomic.checks :as d-checks]
|
[auto-ap.datomic.checks :as d-checks]
|
||||||
[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.datomic.clients :as d-clients]
|
[auto-ap.datomic.clients :as d-clients]
|
||||||
[auto-ap.datomic.bank-accounts :as d-bank-accounts]
|
[auto-ap.datomic.bank-accounts :as d-bank-accounts]
|
||||||
[auto-ap.db.invoices-checks :as invoices-checks]
|
|
||||||
[auto-ap.db.vendors :as vendors]
|
|
||||||
[auto-ap.db.invoices :as invoices]
|
|
||||||
[auto-ap.db.utils :refer [query]]
|
|
||||||
[auto-ap.datomic :refer [uri]]
|
[auto-ap.datomic :refer [uri]]
|
||||||
[auto-ap.utils :refer [by]]
|
[auto-ap.utils :refer [by]]
|
||||||
[auto-ap.numeric :refer [num->words]]
|
[auto-ap.numeric :refer [num->words]]
|
||||||
[config.core :refer [env]]
|
[config.core :refer [env]]
|
||||||
[auto-ap.db.companies :as companies]
|
|
||||||
[auto-ap.time :refer [parse normal-date iso-date local-now]]
|
[auto-ap.time :refer [parse normal-date iso-date local-now]]
|
||||||
[amazonica.aws.s3 :as s3]
|
[amazonica.aws.s3 :as s3]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
@@ -265,6 +259,7 @@
|
|||||||
(conj [:inc (:db/id bank-account) :bank-account/check-number 1])
|
(conj [:inc (:db/id bank-account) :bank-account/check-number 1])
|
||||||
(into (invoice-payments invoices invoice-amounts)))))
|
(into (invoice-payments invoices invoice-amounts)))))
|
||||||
|
|
||||||
|
|
||||||
(defmethod invoices->entities :payment-type/debit [invoices vendor client bank-account type index invoice-amounts]
|
(defmethod invoices->entities :payment-type/debit [invoices vendor client bank-account type index invoice-amounts]
|
||||||
(let [payment (assoc (base-payment invoices vendor client bank-account type index invoice-amounts)
|
(let [payment (assoc (base-payment invoices vendor client bank-account type index invoice-amounts)
|
||||||
:payment/type :payment-type/debit
|
:payment/type :payment-type/debit
|
||||||
@@ -323,26 +318,22 @@
|
|||||||
:end (+ (:start args 0) (count payments))}]))
|
:end (+ (:start args 0) (count payments))}]))
|
||||||
|
|
||||||
(defn add-handwritten-check [context args value]
|
(defn add-handwritten-check [context args value]
|
||||||
(let [invoice (invoices/get-by-id (:invoice_id args))
|
(let [invoice (d-invoices/get-by-id (:invoice_id args))
|
||||||
|
bank-account-id (Long/parseLong (:bank_account_id args))
|
||||||
|
bank-account (d-bank-accounts/get-by-id bank-account-id)
|
||||||
_ (assert-can-see-company (:id context) (:company-id invoice))
|
_ (assert-can-see-company (:id context) (:company-id invoice))
|
||||||
check (checks/insert! {:s3-uuid nil
|
base-payment (base-payment [invoice] (:invoice/vendor invoice)
|
||||||
:s3-key nil
|
(:invoice/client invoice)
|
||||||
:s3-url nil
|
bank-account :payment-type/check 0 {(Long/parseLong (:invoice_id args)) (:amount args)})]
|
||||||
:check-number (:check_number args)
|
@(d/transact (d/connect uri)
|
||||||
:date (parse (:date args) iso-date)
|
[(assoc base-payment
|
||||||
:amount (:amount args)
|
:payment/check-number (:check_number args)
|
||||||
:bank-account-id (:bank_account_id args)
|
:payment/date (c/to-date (parse (:date args) iso-date))
|
||||||
:vendor-id (:vendor-id invoice)
|
:payment/amount (:amount args))
|
||||||
:company-id (:company-id invoice)
|
[:pay (:db/id invoice) (:amount args)]])
|
||||||
:invoices [(:invoice_id args)]})]
|
|
||||||
|
|
||||||
(invoices-checks/insert-multi! [{:invoice-id (:invoice_id args)
|
|
||||||
:check-id (:id check)
|
|
||||||
:amount (:amount args)}])
|
|
||||||
(invoices/apply-payment (:invoice_id args) (:amount args))
|
|
||||||
(->graphql
|
(->graphql
|
||||||
{:s3-url nil
|
{:s3-url nil
|
||||||
:invoices [(invoices/get-by-id (:invoice_id args))]})))
|
:invoices [(d-invoices/get-by-id (:invoice_id args))]})))
|
||||||
|
|
||||||
|
|
||||||
(defn void-check [context {id :payment_id} value]
|
(defn void-check [context {id :payment_id} value]
|
||||||
|
|||||||
@@ -70,14 +70,16 @@
|
|||||||
(->graphql))))
|
(->graphql))))
|
||||||
|
|
||||||
(defn void-invoice [context {id :invoice_id} value]
|
(defn void-invoice [context {id :invoice_id} value]
|
||||||
(let [invoice (d-invoices/get-by-id id)
|
(let [invoice (d-invoices/get-by-id id)
|
||||||
_ (assert-can-see-company (:id context) (:company-id invoice))
|
_ (assert-can-see-company (:id context) (:company-id invoice))
|
||||||
updated-invoice (d-invoices/update {:db/id (Long/parseLong id)
|
updated-invoice (d-invoices/update {:db/id (Long/parseLong id)
|
||||||
:invoice/total 0.0
|
:invoice/total 0.0
|
||||||
:invoice/outstanding-balance 0.0
|
:invoice/outstanding-balance 0.0
|
||||||
:invoice/status :invoice-status/voided})]
|
:invoice/status :invoice-status/voided})]
|
||||||
(-> updated-invoice
|
;; TODO void out all expense accounts
|
||||||
(->graphql))))
|
|
||||||
|
(-> updated-invoice
|
||||||
|
(->graphql))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@
|
|||||||
|
|
||||||
(defn can-see-company? [identity company]
|
(defn can-see-company? [identity company]
|
||||||
(or (= "admin" (:role identity))
|
(or (= "admin" (:role identity))
|
||||||
((set (map :db/id (:user/companies identity))) (:db/id company))))
|
((set (map :db/id (:user/companies identity))) (:db/id company))
|
||||||
|
((set (map :db/id (:user/companies identity))) company)))
|
||||||
|
|
||||||
(defn assert-can-see-company [identity company]
|
(defn assert-can-see-company [identity company]
|
||||||
(when-not (can-see-company? identity company)
|
(when-not (can-see-company? identity company)
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
(:require
|
(:require
|
||||||
[hiccup.core :refer [html]]
|
[hiccup.core :refer [html]]
|
||||||
[auto-ap.routes.utils :refer [wrap-secure]]
|
[auto-ap.routes.utils :refer [wrap-secure]]
|
||||||
[compojure.core :refer [GET POST context defroutes
|
[compojure.core :refer [GET POST context defroutes wrap-routes]]))
|
||||||
wrap-routes]]))
|
|
||||||
(defroutes routes
|
(defroutes routes
|
||||||
(wrap-routes
|
(wrap-routes
|
||||||
(context "/checks" [])
|
(context "/checks" [])
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
(let [query [[:all_payments
|
(let [query [[:all_payments
|
||||||
{:client-id (query-params "client")
|
{:client-id (query-params "client")
|
||||||
:original-id (query-params "original")}
|
:original-id (query-params "original")}
|
||||||
[:id :check-number :amount :memo :date :status
|
[:id :check-number :amount :memo :date :status :type
|
||||||
[:invoices [[:invoice [:id]] :amount]]
|
[:invoices [[:invoice [:id]] :amount]]
|
||||||
[:bank-account [:number :bank-name :bank-code :id]]
|
[:bank-account [:number :bank-name :bank-code :id]]
|
||||||
[:vendor [:name :id [:primary-contact [:name :email :phone]] :default-expense-account [:address [:street1 :city :state :zip]]]]
|
[:vendor [:name :id [:primary-contact [:name :email :phone]] :default-expense-account [:address [:street1 :city :state :zip]]]]
|
||||||
|
|||||||
@@ -47,12 +47,24 @@
|
|||||||
:body
|
:body
|
||||||
:account)))
|
:account)))
|
||||||
|
|
||||||
|
(defn get-account [i]
|
||||||
|
(let [cob-session (login-cobrand)
|
||||||
|
user-session (login-user cob-session)]
|
||||||
|
(-> (str (:yodlee-base-url env) (str "/accounts/" i))
|
||||||
|
(client/get {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
|
:as :json})
|
||||||
|
:body
|
||||||
|
:account)))
|
||||||
|
|
||||||
(defn get-provider-accounts []
|
(defn get-provider-accounts []
|
||||||
(let [cob-session (login-cobrand)
|
(let [cob-session (login-cobrand)
|
||||||
user-session (login-user cob-session)]
|
user-session (login-user cob-session)]
|
||||||
(-> (str (:yodlee-base-url env) "/providerAccounts")
|
(-> (str (:yodlee-base-url env) "/providerAccounts")
|
||||||
(client/get {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
(-> (client/get {:headers (merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
:as :json}))))
|
:as :json})
|
||||||
|
:body
|
||||||
|
:providerAccount)
|
||||||
|
)))
|
||||||
|
|
||||||
(defn get-transactions []
|
(defn get-transactions []
|
||||||
(let [cob-session (login-cobrand)
|
(let [cob-session (login-cobrand)
|
||||||
@@ -77,6 +89,58 @@
|
|||||||
(recur (concat transactions transaction-batch) (+ batch-size skip))
|
(recur (concat transactions transaction-batch) (+ batch-size skip))
|
||||||
transactions)))))
|
transactions)))))
|
||||||
|
|
||||||
|
(defn get-provider-accounts []
|
||||||
|
(let [cob-session (login-cobrand)
|
||||||
|
user-session (login-user cob-session)
|
||||||
|
batch-size 100
|
||||||
|
get-transaction-batch (fn []
|
||||||
|
(-> (str (:yodlee-base-url env) "/providerAccounts")
|
||||||
|
|
||||||
|
(client/get {:headers (doto
|
||||||
|
(merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
|
println)
|
||||||
|
:as :json})
|
||||||
|
:body
|
||||||
|
))]
|
||||||
|
|
||||||
|
(get-transaction-batch)))
|
||||||
|
|
||||||
|
(defn update-provider-account [pa]
|
||||||
|
(let [cob-session (login-cobrand)
|
||||||
|
user-session (login-user cob-session)
|
||||||
|
batch-size 100]
|
||||||
|
|
||||||
|
(-> (str (:yodlee-base-url env) "/providerAccounts?providerAccountIds=" pa)
|
||||||
|
|
||||||
|
(client/put {:headers (doto
|
||||||
|
(merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
|
println)
|
||||||
|
:body "{\"dataSetName\": [\"BASIC_AGG_DATA\"]}"
|
||||||
|
:as :json}))))
|
||||||
|
|
||||||
|
(defn get-specific-transactions []
|
||||||
|
(let [cob-session (login-cobrand)
|
||||||
|
user-session (login-user cob-session)
|
||||||
|
batch-size 100
|
||||||
|
get-transaction-batch (fn [skip]
|
||||||
|
(-> (str (:yodlee-base-url env) "/transactions?top=" batch-size "&skip=" skip "&accountId=16422358")
|
||||||
|
(doto println)
|
||||||
|
|
||||||
|
(client/get {:headers (doto
|
||||||
|
(merge base-headers {"Authorization" (auth-header cob-session user-session)})
|
||||||
|
println)
|
||||||
|
:as :json})
|
||||||
|
:body
|
||||||
|
:transaction
|
||||||
|
))]
|
||||||
|
|
||||||
|
(loop [transactions []
|
||||||
|
skip 0]
|
||||||
|
(let [transaction-batch (get-transaction-batch skip)]
|
||||||
|
(if (seq transaction-batch)
|
||||||
|
(recur (concat transactions transaction-batch) (+ batch-size skip))
|
||||||
|
transactions)))))
|
||||||
|
|
||||||
(defn get-access-token []
|
(defn get-access-token []
|
||||||
(let [cob-session (login-cobrand)
|
(let [cob-session (login-cobrand)
|
||||||
user-session (login-user cob-session)
|
user-session (login-user cob-session)
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
(mapcat (fn [transaction-group]
|
(mapcat (fn [transaction-group]
|
||||||
(map
|
(map
|
||||||
(fn [index {:keys [date description-original high-level-category amount account-id] :as transaction}]
|
(fn [index {:keys [date description-original high-level-category amount account-id] :as transaction}]
|
||||||
{:id (str date "-" description-original "-" amount "-" index "-" company-id)
|
{:id (str date "-" account-id "-" description-original "-" amount "-" index "-" company-id)
|
||||||
:bank-account-id account-id
|
:bank-account-id account-id
|
||||||
:date (time/unparse date "YYYY-MM-dd")
|
:date (time/unparse date "YYYY-MM-dd")
|
||||||
:amount {:amount amount}
|
:amount {:amount amount}
|
||||||
|
|||||||
@@ -332,7 +332,7 @@
|
|||||||
:bank-account-id bank-account-id
|
:bank-account-id bank-account-id
|
||||||
:invoice_id (:id invoice)
|
:invoice_id (:id invoice)
|
||||||
}
|
}
|
||||||
[[:invoices [:id :outstanding-balance [:checks [:amount [:check [:amount :s3_url :check_number ]]]]]]]]}]}
|
[[:invoices [:id :outstanding-balance [:payments [:amount [:payment [:amount :s3_url :check_number ]]]]]]]]}]}
|
||||||
:on-success [::handwrite-checks-succeeded]}})))
|
:on-success [::handwrite-checks-succeeded]}})))
|
||||||
|
|
||||||
(re-frame/reg-event-fx
|
(re-frame/reg-event-fx
|
||||||
@@ -491,7 +491,7 @@
|
|||||||
[:tr
|
[:tr
|
||||||
[:td.expandable [:div.control
|
[:td.expandable [:div.control
|
||||||
[bind-field
|
[bind-field
|
||||||
[typeahead {:matches (map (fn [x] [(:id x) (:name x)]) chooseable-expense-accounts)
|
[typeahead {:matches (map (fn [x] [(:id x) (str (:id x) " - " (:name x))]) chooseable-expense-accounts)
|
||||||
:type "typeahead"
|
:type "typeahead"
|
||||||
:field [:invoice :expense-accounts index :expense-account-id]
|
:field [:invoice :expense-accounts index :expense-account-id]
|
||||||
:event change-event
|
:event change-event
|
||||||
|
|||||||
Reference in New Issue
Block a user