diff --git a/clients.clj b/clients.clj new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/clients.clj @@ -0,0 +1 @@ + diff --git a/src/clj/auto_ap/datomic/transactions.clj b/src/clj/auto_ap/datomic/transactions.clj index bfde2bcf..82a6b4b2 100644 --- a/src/clj/auto_ap/datomic/transactions.clj +++ b/src/clj/auto_ap/datomic/transactions.clj @@ -13,7 +13,8 @@ (defn raw-graphql [args] (->> (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 ['$] :where ['[?e :transaction/original-id]]} :args [(d/db (d/connect uri))]} diff --git a/src/clj/auto_ap/db/checks.clj b/src/clj/auto_ap/db/checks.clj index a2e612c2..afca5202 100644 --- a/src/clj/auto_ap/db/checks.clj +++ b/src/clj/auto_ap/db/checks.clj @@ -80,7 +80,7 @@ :else 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 (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? check-number)) (helpers/merge-where [:= :check-number check-number]) (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}}] (query diff --git a/src/clj/auto_ap/db/invoices.clj b/src/clj/auto_ap/db/invoices.clj index 53062c44..a68f6bfd 100644 --- a/src/clj/auto_ap/db/invoices.clj +++ b/src/clj/auto_ap/db/invoices.clj @@ -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 (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? status)) (helpers/merge-where [:= :status status]) (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}}] (query (cond-> (base-graphql args) + true (add-sort-by sort-by asc) true (assoc :limit limit) start (assoc :offset start)))) diff --git a/src/clj/auto_ap/graphql.clj b/src/clj/auto_ap/graphql.clj index 9df33cbe..11b4233d 100644 --- a/src/clj/auto_ap/graphql.clj +++ b/src/clj/auto_ap/graphql.clj @@ -63,7 +63,8 @@ :check_number {:type 'Int} :name {:type 'String} :bank_code {:type 'String} - :bank_name {:type 'String}}} + :bank_name {:type 'String} + :yodlee_account_id {:type 'Int}}} :address {:fields {:street1 {:type 'String} :street2 {:type 'String} @@ -130,6 +131,8 @@ :status {:type 'String} :client {:type :client} :payment {:type :payment} + :bank_account {:type :bank_account + :resolve :bank-account-for-check} :date {:type 'String} :post_date {:type 'String}}} :invoice_payment @@ -167,6 +170,7 @@ :total {:type 'String} :outstanding_balance {:type 'String} :invoice_number {:type 'String} + :status {:type 'String} :expense_accounts {:type '(list :invoices_expense_accounts)} :date {:type 'String} :company_id {:type 'Int} @@ -216,12 +220,14 @@ :all_invoices {:type '(list :invoice) :args {:client_id {:type 'String} - :original_id {:type 'Int}} + :original_id {:type 'Int} + :statuses {:type '(list String)}} :resolve :get-all-invoices} :all_payments {:type '(list :payment) :args {:client_id {:type 'String} - :original_id {:type 'Int}} + :original_id {:type 'Int} + :statuses {:type '(list String)}} :resolve :get-all-payments} :transaction_page {:type '(list :transaction_page) diff --git a/src/clj/auto_ap/routes/exports.clj b/src/clj/auto_ap/routes/exports.clj index 651422fb..6062b572 100644 --- a/src/clj/auto_ap/routes/exports.clj +++ b/src/clj/auto_ap/routes/exports.clj @@ -30,7 +30,7 @@ (let [query [[:all_invoices {:client-id (query-params "client") :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]]]]]] [:vendor [:name :id [:primary_contact [:name]] [:address [:street1 :city :state :zip]]]] [:expense_accounts [:amount :id :expense_account_id :location @@ -43,7 +43,7 @@ (let [query [[:all_payments {:client-id (query-params "client") :original-id (query-params "original")} - [:id :check-number :amount :memo :date + [:id :check-number :amount :memo :date :status [:invoices [[:invoice [:id]] :amount]] [:bank-account [:number :bank-name :bank-code :id]] [:vendor [:name :id [:primary-contact [:name :email :phone]] :default-expense-account [:address [:street1 :city :state :zip]]]] diff --git a/src/clj/auto_ap/yodlee/import.clj b/src/clj/auto_ap/yodlee/import.clj index 0350ab53..b36ed7d6 100644 --- a/src/clj/auto_ap/yodlee/import.clj +++ b/src/clj/auto_ap/yodlee/import.clj @@ -93,7 +93,7 @@ (defn manual-import [manual-transactions company-id] (let [transformed-transactions (->> manual-transactions (filter #(= "posted" (:status %))) - (group-by #(select-keys % [:date :original-description :amount])) + (group-by #(select-keys % [:date :description-original :amount])) (vals) diff --git a/src/cljs/auto_ap/views/pages/transactions.cljs b/src/cljs/auto_ap/views/pages/transactions.cljs index a138a3be..8b0bee83 100644 --- a/src/cljs/auto_ap/views/pages/transactions.cljs +++ b/src/cljs/auto_ap/views/pages/transactions.cljs @@ -41,7 +41,8 @@ :status :description_original [:payment [:check_number :s3_url]] - [:client [:name :id]]]] + [:client [:name :id]] + [:bank-account [:name :yodlee-account-id]]]] :total :start :end]]]} @@ -68,7 +69,7 @@ (let [{:keys [sort-by asc]} @state {:keys [transactions start end count total]} @transaction-page selected-company @(re-frame/subscribe [::subs/company]) - percentage-size (if selected-company "100%" "50%")] + percentage-size (if selected-company "25%" "33%")] [:div [paginator {:start start :end end :count count :total total :on-change (fn [p ] @@ -111,6 +112,8 @@ :sort-by sort-by :asc asc} "Status"] + [:th {:width percentage-size} "Bank account"] + [:th {:width percentage-size} "Yodlee bank account"] [:th {:style {:width "10em"}} "" ]]] @@ -119,7 +122,7 @@ [:tr [:td {:col-span 5} [: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} [:tr {:class (:class i)} @@ -129,6 +132,8 @@ [:td (date->str date) ] [:td (gstring/format "$%.2f" amount )] [:td status] + [:td (:name bank-account )] + [:td (:yodlee-account-id bank-account )] [:td