This commit is contained in:
Bryce Covert
2018-09-03 13:12:20 -07:00
parent da97d730ad
commit fe5d09c02b
8 changed files with 29 additions and 13 deletions

1
clients.clj Normal file
View File

@@ -0,0 +1 @@

View File

@@ -13,7 +13,8 @@
(defn raw-graphql [args] (defn raw-graphql [args]
(->> (d/query (->> (d/query
(cond-> {:query {:find ['(pull ?e [* {:transaction/client [:client/name :db/id]}])] (cond-> {:query {:find ['(pull ?e [* {:transaction/client [:client/name :db/id]
:transaction/bank-account [:bank-account/name :bank-account/yodlee-account-id]}])]
:in ['$] :in ['$]
:where ['[?e :transaction/original-id]]} :where ['[?e :transaction/original-id]]}
:args [(d/db (d/connect uri))]} :args [(d/db (d/connect uri))]}

View File

@@ -80,7 +80,7 @@
:else :else
q))) q)))
(defn base-graphql [{:keys [company-id vendor-id check-number bank-account-id status amount id]}] (defn base-graphql [{:keys [company-id vendor-id check-number bank-account-id status amount id statuses]}]
(cond-> base-query (cond-> base-query
(limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)]) (limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)])
@@ -89,7 +89,8 @@
(not (nil? vendor-id)) (helpers/merge-where [:= :vendor-id vendor-id]) (not (nil? vendor-id)) (helpers/merge-where [:= :vendor-id vendor-id])
(not (nil? check-number)) (helpers/merge-where [:= :check-number check-number]) (not (nil? check-number)) (helpers/merge-where [:= :check-number check-number])
(not (nil? status)) (helpers/merge-where [:= :status status]) (not (nil? status)) (helpers/merge-where [:= :status status])
(not (nil? amount)) (helpers/merge-where [:= :amount amount]))) (not (nil? amount)) (helpers/merge-where [:= :amount amount])
(seq statuses ) (helpers/merge-where [:in :status statuses])))
(defn get-graphql [{:keys [start sort-by asc id limit] :as args :or {limit 20}}] (defn get-graphql [{:keys [start sort-by asc id limit] :as args :or {limit 20}}]
(query (query

View File

@@ -142,9 +142,10 @@
(defn base-graphql [{:keys [imported company-id status id]}] (defn base-graphql [{:keys [imported company-id status id statuses]}]
(cond-> base-query (cond-> base-query
(limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)]) (limited-companies id) (helpers/merge-where [:in :company-id (limited-companies id)])
(seq statuses ) (helpers/merge-where [:in :status statuses])
(not (nil? imported)) (helpers/merge-where [:= :imported imported]) (not (nil? imported)) (helpers/merge-where [:= :imported imported])
(not (nil? status)) (helpers/merge-where [:= :status status]) (not (nil? status)) (helpers/merge-where [:= :status status])
(not (nil? company-id)) (helpers/merge-where [:= :company-id company-id]))) (not (nil? company-id)) (helpers/merge-where [:= :company-id company-id])))
@@ -152,6 +153,7 @@
(defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 20}}] (defn get-graphql [{:keys [start sort-by asc limit] :as args :or {limit 20}}]
(query (query
(cond-> (base-graphql args) (cond-> (base-graphql args)
true (add-sort-by sort-by asc) true (add-sort-by sort-by asc)
true (assoc :limit limit) true (assoc :limit limit)
start (assoc :offset start)))) start (assoc :offset start))))

View File

@@ -63,7 +63,8 @@
:check_number {:type 'Int} :check_number {:type 'Int}
:name {:type 'String} :name {:type 'String}
:bank_code {:type 'String} :bank_code {:type 'String}
:bank_name {:type 'String}}} :bank_name {:type 'String}
:yodlee_account_id {:type 'Int}}}
:address :address
{:fields {:street1 {:type 'String} {:fields {:street1 {:type 'String}
:street2 {:type 'String} :street2 {:type 'String}
@@ -130,6 +131,8 @@
:status {:type 'String} :status {:type 'String}
:client {:type :client} :client {:type :client}
:payment {:type :payment} :payment {:type :payment}
:bank_account {:type :bank_account
:resolve :bank-account-for-check}
:date {:type 'String} :date {:type 'String}
:post_date {:type 'String}}} :post_date {:type 'String}}}
:invoice_payment :invoice_payment
@@ -167,6 +170,7 @@
:total {:type 'String} :total {:type 'String}
:outstanding_balance {:type 'String} :outstanding_balance {:type 'String}
:invoice_number {:type 'String} :invoice_number {:type 'String}
:status {:type 'String}
:expense_accounts {:type '(list :invoices_expense_accounts)} :expense_accounts {:type '(list :invoices_expense_accounts)}
:date {:type 'String} :date {:type 'String}
:company_id {:type 'Int} :company_id {:type 'Int}
@@ -216,12 +220,14 @@
:all_invoices {:type '(list :invoice) :all_invoices {:type '(list :invoice)
:args {:client_id {:type 'String} :args {:client_id {:type 'String}
:original_id {:type 'Int}} :original_id {:type 'Int}
:statuses {:type '(list String)}}
:resolve :get-all-invoices} :resolve :get-all-invoices}
:all_payments {:type '(list :payment) :all_payments {:type '(list :payment)
:args {:client_id {:type 'String} :args {:client_id {:type 'String}
:original_id {:type 'Int}} :original_id {:type 'Int}
:statuses {:type '(list String)}}
:resolve :get-all-payments} :resolve :get-all-payments}
:transaction_page {:type '(list :transaction_page) :transaction_page {:type '(list :transaction_page)

View File

@@ -30,7 +30,7 @@
(let [query [[:all_invoices (let [query [[:all_invoices
{:client-id (query-params "client") {:client-id (query-params "client")
:original-id (query-params "original")} :original-id (query-params "original")}
[:id :total :outstanding-balance :invoice-number :date [:id :total :outstanding-balance :invoice-number :date :status
[:payments [:amount [:payment [:check-number :memo [:bank_account [:id :number :bank-name :bank-code]]]]]] [:payments [:amount [:payment [:check-number :memo [:bank_account [:id :number :bank-name :bank-code]]]]]]
[:vendor [:name :id [:primary_contact [:name]] [:address [:street1 :city :state :zip]]]] [:vendor [:name :id [:primary_contact [:name]] [:address [:street1 :city :state :zip]]]]
[:expense_accounts [:amount :id :expense_account_id :location [:expense_accounts [:amount :id :expense_account_id :location
@@ -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 [:id :check-number :amount :memo :date :status
[: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]]]]

View File

@@ -93,7 +93,7 @@
(defn manual-import [manual-transactions company-id] (defn manual-import [manual-transactions company-id]
(let [transformed-transactions (->> manual-transactions (let [transformed-transactions (->> manual-transactions
(filter #(= "posted" (:status %))) (filter #(= "posted" (:status %)))
(group-by #(select-keys % [:date :original-description :amount])) (group-by #(select-keys % [:date :description-original :amount]))
(vals) (vals)

View File

@@ -41,7 +41,8 @@
:status :status
:description_original :description_original
[:payment [:check_number :s3_url]] [:payment [:check_number :s3_url]]
[:client [:name :id]]]] [:client [:name :id]]
[:bank-account [:name :yodlee-account-id]]]]
:total :total
:start :start
:end]]]} :end]]]}
@@ -68,7 +69,7 @@
(let [{:keys [sort-by asc]} @state (let [{:keys [sort-by asc]} @state
{:keys [transactions start end count total]} @transaction-page {:keys [transactions start end count total]} @transaction-page
selected-company @(re-frame/subscribe [::subs/company]) selected-company @(re-frame/subscribe [::subs/company])
percentage-size (if selected-company "100%" "50%")] percentage-size (if selected-company "25%" "33%")]
[:div [:div
[paginator {:start start :end end :count count :total total [paginator {:start start :end end :count count :total total
:on-change (fn [p ] :on-change (fn [p ]
@@ -111,6 +112,8 @@
:sort-by sort-by :sort-by sort-by
:asc asc} :asc asc}
"Status"] "Status"]
[:th {:width percentage-size} "Bank account"]
[:th {:width percentage-size} "Yodlee bank account"]
[:th {:style {:width "10em"}} "" ]]] [:th {:style {:width "10em"}} "" ]]]
@@ -119,7 +122,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 [client check status description-original date amount id ] :as i} (:transactions @transaction-page)] (for [{:keys [client check status bank-account description-original date amount id ] :as i} (:transactions @transaction-page)]
^{:key id} ^{:key id}
[:tr {:class (:class i)} [:tr {:class (:class i)}
@@ -129,6 +132,8 @@
[:td (date->str date) ] [:td (date->str date) ]
[:td (gstring/format "$%.2f" amount )] [:td (gstring/format "$%.2f" amount )]
[:td status] [:td status]
[:td (:name bank-account )]
[:td (:yodlee-account-id bank-account )]
[:td [:td