Progress on payment matching

This commit is contained in:
Bryce Covert
2021-01-23 12:26:55 -08:00
parent b00e2c5b60
commit 2d8483f2e3
3 changed files with 42 additions and 43 deletions

View File

@@ -1,6 +1,6 @@
(ns auto-ap.datomic.checks
(:require [datomic.api :as d]
[auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields]]
[auto-ap.datomic :refer [uri merge-query apply-sort-3 apply-pagination add-sorter-fields conn]]
[auto-ap.graphql.utils :refer [limited-clients]]
[auto-ap.utils :refer [dollars=]]
[clojure.set :refer [rename-keys]]
@@ -135,6 +135,7 @@
:where ['[?e :payment/date ?sort-default]]}}))]
(log/info query)
(cond->> query
true (d/query)
true (apply-sort-3 args)

View File

@@ -152,28 +152,27 @@
:icon "icon-accounting-bill"}]}
[:div
(for [payment payments]
(if (:check-number (:payment payment))
^{:key (:id payment)}
[:a.dropdown-item {:href (str (bidi/path-for routes/routes :payments )
"?"
(url/map->query {:exact-match-id (:id (:payment payment))}))
:target "_new"}
[:i.fa.fa-money-check]
[:span.icon {:class [(when (= :cleared (:status (:payment payment)))
"has-text-success")]}
[:i.fa.fa-money]]
^{:key (:id payment)}
[:a.dropdown-item {:href (str (bidi/path-for routes/routes :payments )
"?"
(url/map->query {:exact-match-id (:id (:payment payment))}))
:target "_new"}
[:i.fa.fa-money-check]
[:span.icon {:class [(when (= :cleared (:status (:payment payment)))
"has-text-success")]}
[:i.fa.fa-money]]
(if (:check-number (:payment payment))
(str "Check " (:check-number (:payment payment))
" (" (gstring/format "$%.2f" (:amount payment) ) ")"
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment))))))
(if (:check-number (:payment payment))
(str "Check " (:check-number (:payment payment))
" (" (gstring/format "$%.2f" (:amount payment) ) ")"
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment))))))
(str "Debit (" (gstring/format "$%.2f" (:amount payment) ) ") "
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment)))))
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment))))))) ]))]]
(str "Debit (" (gstring/format "$%.2f" (:amount payment) ) ") "
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment)))))
(when (= :cleared (:status (:payment payment)))
(str " - " (:post-date (:transaction (:payment payment))))))) ])]]
[:span {:style {:margin-right "1em"}}]])
(when (and (get actions :edit)
(not= ":voided" (:status i)))

View File

@@ -1,5 +1,6 @@
(ns auto-ap.views.pages.transactions.form
(:require [auto-ap.forms :as forms]
[auto-ap.status :as status]
[auto-ap.subs :as subs]
[auto-ap.views.components.button-radio :refer [button-radio]]
[auto-ap.views.components.expense-accounts-field
@@ -10,13 +11,13 @@
[auto-ap.views.components.layouts :as layouts]
[auto-ap.views.components.typeahead :refer [typeahead-entity]]
[auto-ap.views.pages.transactions.common :refer [transaction-read]]
[auto-ap.views.utils :refer [->$ date->str dispatch-event with-user]]
[auto-ap.views.utils
:refer
[->$ date->str dispatch-event pretty with-user]]
[clojure.string :as str]
[re-frame.core :as re-frame]
[auto-ap.status :as status]
[reagent.core :as r]
[react :as react]
[reagent.core :as reagent]))
[reagent.core :as r]))
;; SUBS
(re-frame/reg-sub
@@ -59,19 +60,14 @@
(-> which
(select-keys [:vendor :amount :payment :client :description-original
:yodlee-merchant :id :potential-payment-matches
:forecast-match
:forecast-match :date
:location :accounts :approval-status
:matched-rule])
(update :date #(date->str % pretty))
(assoc :original-status (:approval-status which))
(assoc :potential-payment-matches (if (:matched-rule which)
nil
potential-payment-matches))
(assoc :potential-transaction-rule-matches (if (:matched-rule which)
nil
potential-transaction-rule-matches))
(assoc :potential-autopay-invoices-matches (if (:matched-rule which)
nil
potential-autopay-invoices-matches))
(assoc :potential-payment-matches potential-payment-matches)
(assoc :potential-transaction-rule-matches potential-transaction-rule-matches)
(assoc :potential-autopay-invoices-matches potential-autopay-invoices-matches)
(update :accounts expense-accounts-field/from-graphql accounts-by-id (:amount which) locations))))))
(re-frame/reg-event-db
@@ -295,8 +291,7 @@
is-admin? @(re-frame/subscribe [::subs/is-admin?])
should-disable-for-client? (and (not is-admin?)
(not= :requires-feedback (:original-status data)))
is-already-matched? (or (:matched-rule data)
(:payment data))]
is-already-matched? (:payment data)]
(form-inline {:title "Transaction"}
[:<>
@@ -324,17 +319,21 @@
:field [:description-original]
:disabled "disabled"}])
(field "Date"
[:input.input {:type "text"
:field [:date]
:disabled "disabled"}])
(when (and (:payment data)
is-admin?)
[:p.notification.is-info.is-light>div.level>div.level-left
[:div.level-item "This transaction is linked to a payment "]
[:div.level-item [:button.button.is-warning {:on-click (dispatch-event [::unlink])} "Unlink"]]])
[tabs {:default-tab :details}
(when
(and (seq (:potential-transaction-rule-matches data))
(not is-already-matched?)
(not (:matched-rule data))
is-admin?)
[tab {:title "Transaction Rule" :key :transaction-rule}
[potential-transaction-rule-matches-box {:potential-transaction-rule-matches (:potential-transaction-rule-matches data)}]])
@@ -349,9 +348,9 @@
(when
(and (seq (:potential-payment-matches data))
(not is-already-matched?)
[tab {:title "Payment" :key :payment}
[potential-payment-matches-box {:potential-payment-matches (:potential-payment-matches data)}]]))
)
[tab {:title "Payment" :key :payment}
[potential-payment-matches-box {:potential-payment-matches (:potential-payment-matches data)}]])
[tab {:title "Details" :key :details}
[:div