Checks now have a status that gets updated
This commit is contained in:
2
migrator/migrations/1530379134-DOWN-add-check-status.sql
Normal file
2
migrator/migrations/1530379134-DOWN-add-check-status.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 1530379134 DOWN add-check-status
|
||||||
|
alter table checks drop column status;
|
||||||
2
migrator/migrations/1530379134-UP-add-check-status.sql
Normal file
2
migrator/migrations/1530379134-UP-add-check-status.sql
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
-- 1530379134 UP add-check-status
|
||||||
|
alter table checks add column status varchar(255) default 'pending';
|
||||||
@@ -85,3 +85,9 @@
|
|||||||
(defn count-graphql [args]
|
(defn count-graphql [args]
|
||||||
(:count (first (query
|
(:count (first (query
|
||||||
(assoc (base-graphql args) :select [:%count.*])))))
|
(assoc (base-graphql args) :select [:%count.*])))))
|
||||||
|
|
||||||
|
(defn update! [row]
|
||||||
|
(j/update! (get-conn)
|
||||||
|
:checks
|
||||||
|
(-> row (fields->data) (clj->db))
|
||||||
|
["id = ?" (:id row)]))
|
||||||
|
|||||||
@@ -69,7 +69,8 @@
|
|||||||
:resolve :get-company-for-check}
|
:resolve :get-company-for-check}
|
||||||
:date {:type 'String}
|
:date {:type 'String}
|
||||||
:s3_url {:type 'String}
|
:s3_url {:type 'String}
|
||||||
:check_number {:type 'Int}}}
|
:check_number {:type 'Int}
|
||||||
|
:status {:type 'String}}}
|
||||||
|
|
||||||
:transaction {:fields {:id {:type 'Int}
|
:transaction {:fields {:id {:type 'Int}
|
||||||
:amount {:type 'String}
|
:amount {:type 'String}
|
||||||
|
|||||||
@@ -52,7 +52,9 @@
|
|||||||
transaction
|
transaction
|
||||||
check-number (extract-check-number transaction)
|
check-number (extract-check-number transaction)
|
||||||
company-id (account->company account-id)
|
company-id (account->company account-id)
|
||||||
bank-account-id (yodlee-account-id->bank-account-id account-id)]]
|
bank-account-id (yodlee-account-id->bank-account-id account-id)
|
||||||
|
check-id (transaction->check-id transaction check-number company-id bank-account-id)
|
||||||
|
]]
|
||||||
|
|
||||||
(try
|
(try
|
||||||
(transactions/upsert!
|
(transactions/upsert!
|
||||||
@@ -68,7 +70,10 @@
|
|||||||
:company-id company-id
|
:company-id company-id
|
||||||
:check-number check-number
|
:check-number check-number
|
||||||
:bank-account-id (yodlee-account-id->bank-account-id account-id)
|
:bank-account-id (yodlee-account-id->bank-account-id account-id)
|
||||||
:check-id (transaction->check-id transaction check-number company-id bank-account-id)
|
:check-id check-id
|
||||||
})
|
})
|
||||||
|
(when check-id
|
||||||
|
(checks/update! {:id check-id :status "cleared"}))
|
||||||
|
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(println e))))))
|
(println e))))))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
:graphql {:token (-> cofx :db :user)
|
:graphql {:token (-> cofx :db :user)
|
||||||
:query-obj {:venia/queries [[:check_page
|
:query-obj {:venia/queries [[:check_page
|
||||||
(assoc params :company-id (:id @(re-frame/subscribe [::subs/company])))
|
(assoc params :company-id (:id @(re-frame/subscribe [::subs/company])))
|
||||||
[[:checks [:id :amount :check_number :s3_url :date [:vendor [:name :id]] [:company [:name :id]]]]
|
[[:checks [:id :status :amount :check_number :s3_url :date [:vendor [:name :id]] [:company [:name :id]]]]
|
||||||
:total
|
:total
|
||||||
:start
|
:start
|
||||||
:end]]]}
|
:end]]]}
|
||||||
@@ -104,6 +104,13 @@
|
|||||||
:sort-by sort-by
|
:sort-by sort-by
|
||||||
:asc asc}
|
:asc asc}
|
||||||
"Amount"]
|
"Amount"]
|
||||||
|
|
||||||
|
[sorted-column {:on-sort opc
|
||||||
|
:style {:width "8em" :cursor "pointer"}
|
||||||
|
:sort-key "status"
|
||||||
|
:sort-by sort-by
|
||||||
|
:asc asc}
|
||||||
|
"Status"]
|
||||||
|
|
||||||
|
|
||||||
[:th {:style {:width "10em"}} "" ]]]
|
[:th {:style {:width "10em"}} "" ]]]
|
||||||
@@ -112,7 +119,7 @@
|
|||||||
[:tr
|
[:tr
|
||||||
[:td {:col-span 5}
|
[:td {:col-span 5}
|
||||||
[:i.fa.fa-spin.fa-spinner]]]
|
[:i.fa.fa-spin.fa-spinner]]]
|
||||||
(for [{:keys [company s3-url checks check-number date amount id vendor] :as i} (:checks @check-page)]
|
(for [{:keys [company s3-url checks check-number date amount id vendor status] :as i} (:checks @check-page)]
|
||||||
^{:key id}
|
^{:key id}
|
||||||
[:tr {:class (:class i)}
|
[:tr {:class (:class i)}
|
||||||
|
|
||||||
@@ -121,6 +128,7 @@
|
|||||||
[:td check-number]
|
[:td check-number]
|
||||||
[:td (date->str date) ]
|
[:td (date->str date) ]
|
||||||
[:td (gstring/format "$%.2f" amount )]
|
[:td (gstring/format "$%.2f" amount )]
|
||||||
|
[:td status]
|
||||||
[:td
|
[:td
|
||||||
(if s3-url
|
(if s3-url
|
||||||
[:a.tag {:href s3-url :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " check-number " (" (gstring/format "$%.2f" amount ) ")")]
|
[:a.tag {:href s3-url :target "_new"} [:i.fa.fa-money-check] [:span.icon [:i.fa.fa-money]] (str " " check-number " (" (gstring/format "$%.2f" amount ) ")")]
|
||||||
|
|||||||
Reference in New Issue
Block a user